@font-face { font-family: Roboto; src: url('/roboto-400.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Roboto Condensed'; src: url('/roboto-condensed-700.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --back: #a8a8a8;
  --paper: #f2f2f2;
  --ink: #202020;
  --muted: #3a3a3a;
  --line: #20202026;
  --orchid: #b067a1;
  --orchid-dark: #87477c;
  --yellow: #f0e87d;
  --glass: linear-gradient(145deg, #ffffffe8, #eeeeeede);
  --lift: 6px 8px 18px #0000001c, -3px -3px 10px #ffffff24, inset 0 1px 1px #fff;
  font-family: Roboto, system-ui, sans-serif;
  color: var(--ink);
  background: var(--back);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
body:not(.running) { background: var(--back); }
h1, h2, h3, .remaining { font-family: 'Roboto Condensed', system-ui, sans-serif; font-weight: 700; }
h1 { font-size: clamp(2.55rem, 11vw, 3.8rem); letter-spacing: -.035em; line-height: 1; margin: 0 0 .65rem; }
h2 { font-size: 1.62rem; margin: 0; letter-spacing: -.018em; }
h3, p { margin: 0; }
button, input, select { font: inherit; }
button { min-height: 44px; cursor: pointer; border-radius: 14px; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .4; }
button:enabled:active { transform: translateY(1px); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.shell {
  max-width: 37rem;
  margin: auto;
  min-height: 100svh;
  padding: calc(1.05rem + env(safe-area-inset-top)) 1.15rem calc(1.5rem + env(safe-area-inset-bottom));
}
.topbar, .section-heading, .dialog-heading, .block-top, .card-actions, .run-header {
  display: flex; align-items: center; justify-content: space-between; gap: .65rem;
}
.topbar { margin-bottom: 1.5rem; }
.topbar h1 { margin: 0; font-size: clamp(2rem, 9vw, 2.8rem); }
.brand {
  display: block;
  width: min(100%, 20rem);
}
.brand img { display: block; width: 100%; height: auto; }
.icon-button, .secondary {
  border: 1px solid #b067a173;
  color: var(--orchid-dark);
  background: linear-gradient(150deg, #f8f2f7, #e5d8e2);
  box-shadow: 0 4px 9px #00000014, inset 0 1px 1px #fff;
}
.icon-button { display: grid; place-items: center; width: 46px; }
.hero {
  padding: 0 .15rem 1.5rem;
  border-bottom: 1px solid #20202033;
}
.section-heading { margin: 1.4rem 0 1rem; }
.primary, .secondary { padding: .65rem .9rem; font-weight: 700; }
.primary {
  border: 1px solid #8e893b;
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 0 4px 8px #00000018, inset 0 1px 1px #ffffffe0;
}
.text-button { border: 1px solid #b067a147; padding: .5rem .65rem; color: var(--orchid-dark); background: #f6edf4; font-weight: 700; }
#back { margin: -.3rem 0 .35rem; }
#editor h1 { margin-block: .4rem 1rem; }
.workout-card, .block, .empty, dialog {
  border: 1px solid #fff9;
  background: var(--glass);
  box-shadow: var(--lift);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.workout-card, .block, .empty {
  padding: 1rem;
  margin-bottom: .85rem;
  border-radius: 22px;
}
.workout-card h3 { font-size: 1.72rem; line-height: 1.1; overflow-wrap: anywhere; }
.workout-card p, .empty { color: var(--muted); line-height: 1.4; }
.workout-card p { margin: .45rem 0 .95rem; }
.card-actions { justify-content: flex-end; flex-wrap: wrap; }
.card-actions .primary { min-width: 6.45rem; }
.secondary.active-action { background: var(--yellow); color: var(--ink); border-color: #8e893b; }
.offline-status { font-size: .875rem; color: var(--muted); margin: 1rem 0; line-height: 1.4; }
.offline-status.ready::before {
  content: ''; display: inline-block; width: .52rem; height: .52rem; margin-right: .55rem;
  border-radius: 50%; background: #2b734d; box-shadow: 0 0 0 3px #2b734d1a;
}
#workout-form > .field { margin: 1.35rem 0 1.5rem; }
#workout-form h2 { margin-bottom: .65rem; }
.field { display: grid; gap: .35rem; min-width: 0; color: var(--muted); font-size: .9rem; }
.field input, .field select {
  width: 100%; min-width: 0; min-height: 46px; padding: .55rem .65rem;
  background: #f2f2f2; color: var(--ink); border: 1px solid #737373; border-radius: 12px; font-size: 1rem;
  box-shadow: inset 0 2px 5px #00000014, 0 1px #ffffff80;
}
.ready-field { max-width: 24rem; }
.ready-field span { font-size: .875rem; }
.ready-field select { max-width: 13rem; }
.block-top { align-items: flex-start; margin-bottom: .6rem; }
.block-top h3 { padding-top: .55rem; font-size: 1.2rem; }
.block-actions { display: flex; gap: .3rem; flex-shrink: 0; }
.block-actions .secondary { min-width: 44px; padding: .4rem; }
.block-values { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .75rem; }
.block-values.single { grid-template-columns: minmax(0, 9rem); }
.add-actions, .editor-actions, .sound-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin: .8rem 0 0; }
.editor-actions { margin-top: 1.4rem; }
.danger, .error { color: #891b4b; }
.error { margin: .5rem 0; line-height: 1.4; }
dialog { width: min(calc(100% - 2rem), 31rem); color: var(--ink); border-radius: 24px; padding: 1.15rem; }
dialog::backdrop { background: #20202099; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.setting { display: flex; align-items: center; gap: 1rem; cursor: pointer; padding: 1rem 0; border-top: 1px solid var(--line); }
.setting span { flex: 1; }
.setting small, .setting-note { display: block; color: var(--muted); line-height: 1.45; }
.setting small { margin-top: .35rem; }
.setting input { width: 1.6rem; height: 1.6rem; flex-shrink: 0; accent-color: var(--orchid-dark); }
.setting-note { margin: .6rem 0; font-size: .9rem; }
.cue-volume { margin-top: 1rem; grid-template-columns: 1fr auto; align-items: center; }
.cue-volume output { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.cue-volume input {
  grid-column: 1 / -1; padding: 0; border: 0; box-shadow: none;
  accent-color: var(--orchid-dark);
}
.backup-settings { margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.backup-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .8rem; }
.backup-actions button { flex: 1 1 8rem; }
.import-names { padding-left: 1.3rem; margin: 1rem 0; }
.import-names li { padding-block: .3rem; overflow-wrap: anywhere; line-height: 1.4; }

body.running { background: #000; }
.run {
  --phase-accent: var(--yellow);
  --phase-glow: #f0e87d20;
  --sweep: 0deg;
  min-height: 100svh; margin: auto; max-width: 37rem; display: flex; flex-direction: column;
  padding: calc(1rem + env(safe-area-inset-top)) 1.15rem calc(1.15rem + env(safe-area-inset-bottom));
  color: #f2f2f2; background: #000;
}
.run[data-phase="rest"], .run[data-phase="ready"] { --phase-accent: var(--orchid); --phase-glow: #b067a124; }
.run-header { color: #d2d2d2; min-width: 0; min-height: 44px; }
#run-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wake-status {
  display: flex; align-items: center; justify-content: space-between; gap: .7rem;
  margin-top: .55rem; padding: .55rem .75rem;
  border: 1px solid #414141; border-radius: 14px; background: #151515;
  color: #d2d2d2; font-size: .875rem; line-height: 1.35;
}
.wake-status[data-state="active"] { color: var(--yellow); }
.wake-status:is([data-state="failed"], [data-state="interrupted"], [data-state="unsupported"]) {
  color: var(--yellow); border-color: #706c3a; background: #1c1b10;
}
.wake-status button { flex-shrink: 0; }
.run-main { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 1.15rem 0; }
.run-dial {
  display: grid;
  position: relative;
  isolation: isolate;
  place-items: center;
  width: min(100%, 78vw, 22rem);
  aspect-ratio: 1;
  padding: 1rem;
  border: 1px solid #ffffff1a;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 0%, var(--phase-glow), transparent 59%), #0d0d0d;
  box-shadow: 0 0 24px var(--phase-glow), inset 0 2px 4px #fff2, inset 0 -5px 13px #000;
}
.run-dial::before {
  content: '';
  position: absolute;
  inset: 6px;
  z-index: -1;
  border-radius: 50%;
  background: conic-gradient(var(--phase-accent) 0deg var(--sweep), #ffffff2b var(--sweep));
  -webkit-mask-image: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask-image: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
}
.dial-content { width: 100%; }
.phase { font: 700 clamp(1.05rem, 5vw, 1.65rem) 'Roboto Condensed', sans-serif; color: var(--phase-accent); overflow-wrap: anywhere; max-width: 84%; margin: 0 auto .2rem; }
.remaining { font-size: clamp(3.1rem, 19vw, 6.85rem); line-height: 1; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.progress, .up-next { color: #d2d2d2; line-height: 1.35; margin-top: .65rem; overflow-wrap: anywhere; max-width: 100%; }
.progress { margin-top: 1.25rem; font-weight: 700; }
.up-next { color: #a8a8a8; font-size: .9rem; }
.run-controls { text-align: center; }
#run-status { color: #a8a8a8; font-size: .875rem; min-height: 1.25em; margin-bottom: .65rem; }
.run-button {
  background: var(--orchid);
  border: 1px solid var(--orchid);
  box-shadow: inset 0 1px 1px #fff2;
  color: #000; padding: .5rem .7rem; font-weight: 700;
}
.pause {
  width: 100%; min-height: 52px;
  background: var(--orchid);
  border: 1px solid var(--orchid);
  box-shadow: inset 0 1px 1px #fff5;
  color: #000;
  font-weight: 700;
}
.run-button.active-action, .pause[data-action="resume"] { background: var(--yellow); border-color: var(--yellow); }
.run-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; margin-top: .55rem; }
.run :focus-visible { outline-color: var(--phase-accent); }
@media (max-width: 355px) {
  .shell, .run { padding-inline: .85rem; }
  .card-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-actions .primary { grid-column: 1 / -1; }
  .block { padding-inline: .7rem; }
  .block-top { gap: .3rem; }
  .run-actions .run-button { padding-inline: .35rem; }
}
