:root {
  --bg: #1c1b1f;
  --surface: #2b2930;
  --variant: #49454f;
  --primary: #d0bcff;
  --on-primary: #381e72;
  --text: #e6e1e5;
  --muted: #cac4d0;
  --white: #ffffff;
  --danger: #ff5252;
  --dialog: #1e1e24;
  --idle: #2c2c35;
  color-scheme: dark;
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.app {
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.welcome {
  padding: 0 20px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 12px;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--primary);
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--primary);
}

.scroll {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 8px;
}

.card, .panel {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
}

.panel { background: var(--variant); }

.card-title-row, .stepper-row, .health-head, .log-row, .move-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--white);
}

.info-badge, .index-badge, .log-badge, .health-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(208, 188, 255, 0.15);
  color: var(--primary);
  flex: 0 0 auto;
}

.index-badge {
  width: 28px;
  height: 28px;
  background: rgba(208, 188, 255, 0.12);
  font-size: 13px;
  font-weight: 800;
}

.copy, .move-cat, .stepper-sub, .log-date, .health-copy {
  margin: 10px 0 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.section-label {
  margin: 8px 0 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
}

.stepper-label {
  margin: 0;
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
}

.stepper-sub { margin: 2px 0 0; font-size: 12px; }

.stepper-controls { display: flex; align-items: center; gap: 12px; }

.round {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--white);
  display: grid;
  place-items: center;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--variant);
  color: var(--primary);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.icon-btn.muted { color: var(--muted); }

.divider {
  height: 1px;
  margin: 14px 0;
  background: rgba(158, 158, 175, 0.12);
}

.health-card {
  background: rgba(34, 37, 42, 0.45);
  border: 1px solid rgba(158, 158, 175, 0.2);
  border-radius: 16px;
  padding: 16px;
}

.health-name {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--primary);
}

.health-status {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--white);
}

.health-copy { margin: 10px 0 0; font-size: 12px; line-height: 1.45; }

.move {
  width: 100%;
  text-align: left;
  border: 0;
  background: var(--surface);
  border-radius: 12px;
  padding: 14px;
  color: inherit;
}

.move.open { background: var(--variant); }

.move-name {
  margin: 0;
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
}

.move-cat { margin: 0; font-size: 11px; }

.move-main, .fav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.move-copy { margin: 10px 0 0; font-size: 13px; line-height: 1.4; color: var(--text); }

.cue-label {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.cue { margin: 2px 0 0; font-size: 12px; color: var(--text); }

.heart, .chevron {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
}

.heart.on { color: var(--primary); }

.start, .home-btn {
  height: 56px;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.home-btn { color: #000; width: 100%; margin: 0; }

.legal-bar {
  padding: 2px 16px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.legal-bar p { margin: 0; }

.legal-links {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 2px;
}

.legal-bar button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 6px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.legal { padding: 0 20px; }

.legal h2 {
  margin: 18px 0 6px;
  font-size: 16px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--white);
}

.legal p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.legal-updated {
  margin-top: 8px;
  font-size: 12px;
}

.legal-back {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
  padding: 12px 0 4px;
}

.nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
}

.nav button {
  border: 0;
  background: transparent;
  color: rgba(202, 196, 208, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 0;
}

.nav button[aria-current="page"] { color: var(--primary); }

.nav-icon {
  display: grid;
  place-items: center;
  height: 32px;
  min-width: 56px;
  border-radius: 16px;
}

.nav button[aria-current="page"] .nav-icon { background: var(--variant); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat {
  background: var(--surface);
  border-radius: 16px;
  padding: 10px 4px;
  text-align: center;
}

.stat svg { color: var(--primary); }

.stat strong {
  display: block;
  margin-top: 6px;
  color: var(--white);
  font-size: 15px;
}

.stat span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.chart-title, .cal-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--primary);
}

.bars {
  height: 130px;
  margin-top: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 4px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.bar-track {
  width: 14px;
  height: 80px;
  border-radius: 8px 8px 0 0;
  background: rgba(205, 255, 0, 0.12);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  background: var(--primary);
  border-radius: 8px 8px 0 0;
  min-height: 0;
}

.bar-col span, .cal-head span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.bar-col.today span { color: var(--primary); }

.cal-head, .cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cal-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--white);
  text-align: center;
}

.month-btn { width: 36px; height: 36px; }

.cal-head { margin-top: 14px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }

.day, .day-empty {
  aspect-ratio: 1;
  margin: 4px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
}

.day { border: 1px solid rgba(158, 158, 175, 0.12); color: var(--white); }

.day.done {
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
  font-weight: 900;
}

.chips { display: flex; gap: 8px; padding-bottom: 12px; flex-wrap: wrap; }

.chip {
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--white);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

.chip.on { background: var(--primary); color: var(--on-primary); }

.empty {
  text-align: center;
  padding: 24px;
}

.empty h2 { margin: 12px 0 6px; font-size: 16px; color: var(--white); }

.empty p { margin: 0; color: var(--text); font-size: 13px; line-height: 1.4; }

.log-title { margin: 0; color: var(--white); font-size: 14px; font-weight: 700; }

.log-date { margin: 0; font-size: 11px; }

.log-time { margin: 0; color: var(--primary); font-weight: 800; font-size: 14px; text-align: right; }

.log-meta { margin: 0; color: var(--muted); font-size: 11px; text-align: right; }

.countdown, .active, .done {
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  overflow: auto;
}

.countdown { position: relative; justify-content: center; padding: 24px; }

.countdown-center, .done-hero { text-align: center; }

.count-ring, .stage {
  position: relative;
  margin: 16px auto;
}

.count-ring { width: min(240px, 72vw); height: min(240px, 72vw); }

.stage {
  width: min(230px, 78vw);
  height: min(230px, 78vw);
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--variant);
  overflow: hidden;
}

canvas { width: 100%; height: 100%; display: block; }

#figure { position: absolute; inset: 14px; width: auto; height: auto; }

#ring { position: absolute; inset: 0; }

.count-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 80px;
  font-weight: 900;
  color: var(--white);
}

.up-next-label {
  margin: 30px 0 6px;
  letter-spacing: 1.5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}

.up-next-name, .exercise-name {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  color: var(--white);
}

.quit-prep { position: absolute; top: 8px; right: 8px; }

.segments { display: flex; gap: 4px; padding: 4px 0 10px; }

.segments span {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--idle);
}

.segments span.done, .segments span.current { background: var(--primary); }

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
}

.meta-row .elapsed { color: var(--muted); }

.exercise-name { font-size: 26px; margin-top: 14px; }

.category {
  margin: 4px 0 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.5px;
  color: var(--primary);
}

.rest-label {
  margin: 14px 0 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--primary);
}

.instructions {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}

.time-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(16, 16, 18, 0.88);
  color: var(--primary);
  font-size: 22px;
  font-weight: 900;
}

.coach {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 10px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(26, 26, 34, 0.9);
  border: 1px solid rgba(205, 255, 0, 0.2);
  text-align: left;
}

.coach .who {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--primary);
}

.coach p { margin: 4px 0 0; font-size: 13px; line-height: 1.4; color: var(--white); font-weight: 500; }

.coach.muted .who, .coach.muted svg { color: #9e9e9e; }

.controls {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.control-cluster { display: flex; align-items: center; gap: 16px; }

.skip {
  width: 50px;
  height: 50px;
  border: 0;
  border-radius: 50%;
  background: var(--variant);
  color: var(--primary);
  display: grid;
  place-items: center;
}

.play {
  width: 70px;
  height: 70px;
  border: 0;
  border-radius: 50%;
  background: var(--white);
  color: #000;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.play.paused { background: var(--primary); color: var(--on-primary); }

.quit {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 61, 0, 0.5);
  background: rgba(255, 61, 0, 0.24);
  color: var(--danger);
  display: grid;
  place-items: center;
}

.done { gap: 22px; justify-content: space-between; overflow: auto; }

.trophy {
  width: 160px;
  height: 160px;
  margin: 14px auto 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(208, 188, 255, 0.12);
  color: var(--primary);
  animation: pop 0.7s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

@keyframes pop {
  from { transform: scale(0.2); }
  to { transform: scale(1); }
}

.champion {
  margin: 28px 0 0;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--primary);
}

.done h2 {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 800;
  color: var(--white);
}

.done-lead {
  margin: 10px 12px 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 12px;
}

.summary span {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
}

.summary strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  color: var(--white);
}

.summary .span { grid-column: 1 / -1; height: 1px; background: rgba(158, 158, 175, 0.12); }

.done-health { border-radius: 14px; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 5;
}

.dialog {
  width: min(360px, 100%);
  background: var(--dialog);
  border-radius: 20px;
  padding: 20px;
}

.dialog h2 { margin: 0; font-size: 18px; color: var(--white); }

.dialog p { margin: 10px 0 0; color: #d3d3d3; font-size: 14px; line-height: 1.45; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.danger, .resume {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
}

.danger { border: 0; background: var(--danger); color: white; }

.resume { background: transparent; color: white; border: 1px solid rgba(128, 128, 128, 0.5); }

.install {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 8px;
}

@media (max-width: 360px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .exercise-name { font-size: 22px; }
}
