/* ==========================================================================
   Exercise AI — design system
   One accent, generous whitespace, soft cards. Mobile-first; the layout widens
   to a centred column on desktop rather than stretching.
   ========================================================================== */

:root {
  --accent: #6366f1;
  --accent-soft: #818cf8;
  --accent-ink: #ffffff;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f2f7;
  --border: #e6e8f0;
  --text: #14151f;
  --muted: #6b7088;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow: 0 1px 2px rgba(20, 21, 31, .04), 0 8px 24px rgba(20, 21, 31, .06);
  --shadow-lg: 0 12px 40px rgba(20, 21, 31, .12);

  --nav-h: 64px;
  --max-w: 560px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0b0b12;
    --surface: #16171f;
    --surface-2: #1e1f2a;
    --border: #282a38;
    --text: #f2f3f7;
    --muted: #9aa0b8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  }
}

:root[data-theme="dark"] {
  --bg: #0b0b12;
  --surface: #16171f;
  --surface-2: #1e1f2a;
  --border: #282a38;
  --text: #f2f3f7;
  --muted: #9aa0b8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.app {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px 18px calc(var(--nav-h) + env(safe-area-inset-bottom) + 32px);
  min-height: 100dvh;
}

/* --- typography ----------------------------------------------------------- */

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: 1rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.center { text-align: center; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .7rem;
  font-weight: 700;
  color: var(--accent);
}

.page-head { margin-bottom: 20px; }
.page-head h1 { margin-bottom: 4px; }

/* --- layout helpers ------------------------------------------------------- */

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 28px; }

/* --- surfaces ------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card--flat { box-shadow: none; }

.hero {
  background: linear-gradient(135deg, var(--accent), #8b5cf6 55%, #a855f7);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: -40% -30% auto auto;
  width: 220px; height: 220px;
  background: rgba(255, 255, 255, .14);
  border-radius: 50%;
}
.hero h1, .hero h2 { color: #fff; }
.hero .muted { color: rgba(255, 255, 255, .78); }

/* --- buttons -------------------------------------------------------------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 13px 22px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  transition: transform .12s ease, opacity .12s ease, background .12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--subtle { background: var(--surface-2); color: var(--text); }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn--lg { padding: 16px 24px; font-size: 1.05rem; }
.btn--sm { padding: 8px 14px; font-size: .85rem; }

.link {
  background: none; border: none; padding: 0;
  color: var(--accent); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
}

/* --- choice chips / option cards ------------------------------------------ */

.options { display: grid; gap: 10px; }
.options--2 { grid-template-columns: 1fr 1fr; }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .12s ease;
}
.option:active { transform: scale(.985); }
.option[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.option__icon { font-size: 1.5rem; line-height: 1; }
.option__label { font-weight: 600; }
.option__hint { font-size: .8rem; color: var(--muted); }
.option__check {
  margin-left: auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: grid; place-items: center;
  flex: none;
}
.option[aria-pressed="true"] .option__check {
  background: var(--accent);
  border-color: var(--accent);
}
.option[aria-pressed="true"] .option__check::after {
  content: "";
  width: 10px; height: 6px;
  border: 2px solid #fff;
  border-top: 0; border-right: 0;
  transform: rotate(-45deg) translateY(-1px);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .9rem;
  font-weight: 550;
  cursor: pointer;
}
.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
}

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 600;
  text-transform: capitalize;
}
.tag--accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

/* --- inputs --------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .85rem; font-weight: 600; color: var(--muted); }

input[type="text"], input[type="number"], input[type="search"], select {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, .option:focus-visible, .btn:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- onboarding ----------------------------------------------------------- */

.progress-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 24px;
}
.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  border-radius: 999px;
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}

.step { animation: rise .35s cubic-bezier(.2, .7, .3, 1); }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.step__actions {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

/* --- exercise rows -------------------------------------------------------- */

.ex-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}
.ex-row__media {
  width: 56px; height: 56px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface-2);
  flex: none;
}
.ex-row__name { font-weight: 600; font-size: .95rem; }
.ex-row__meta { font-size: .78rem; color: var(--muted); }
.ex-row__done { color: var(--success); font-weight: 700; }

/* --- workout player ------------------------------------------------------- */

.player__media {
  width: 100%;
  aspect-ratio: 1;
  max-height: 320px;
  object-fit: contain;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.set-row {
  display: grid;
  grid-template-columns: 32px 1fr 1fr 48px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
}
.set-row input { text-align: center; padding: 11px 6px; }
.set-row__n {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-weight: 700; font-size: .8rem;
  color: var(--muted);
}
.set-row--done .set-row__n { background: var(--success); color: #fff; }
.set-row__check {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--muted);
}
.set-row--done .set-row__check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.set-head {
  display: grid;
  grid-template-columns: 32px 1fr 1fr 48px;
  gap: 8px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 700;
}

.rest-timer {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  width: min(var(--max-w), calc(100vw - 36px));
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 40;
  animation: rise .25s ease;
}
.rest-timer__time { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rest-timer button {
  background: color-mix(in srgb, currentColor 15%, transparent);
  color: inherit;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* --- stats ---------------------------------------------------------------- */

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
}
.stat__value { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.stat__label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar {
  display: grid;
  grid-template-columns: 88px 1fr 40px;
  align-items: center;
  gap: 10px;
  font-size: .82rem;
}
.bar__track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar__fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
}
.bar__value { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.spark { width: 100%; height: 72px; overflow: visible; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: var(--accent); }

/* --- bottom nav ----------------------------------------------------------- */

/* `display: flex` beats the browser's default [hidden] rule, so without this the
   router's `nav.hidden = true` does nothing and the nav sits over the workout. */
.nav[hidden] { display: none; }

.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  z-index: 30;
}
.nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 600;
}
.nav a svg {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav a[aria-current="page"] { color: var(--accent); }

/* --- feedback / misc ------------------------------------------------------ */

.emoji-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.emoji-scale button {
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 1.4rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .12s ease;
}
.emoji-scale button[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  transform: scale(1.06);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px);
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 60;
  max-width: calc(100vw - 32px);
}
.toast--show { opacity: 1; transform: translate(-50%, 0); }

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty__icon { font-size: 2.5rem; margin-bottom: 12px; }

.boot {
  display: grid;
  place-items: center;
  gap: 16px;
  min-height: 70dvh;
  color: var(--muted);
}
.boot__pulse {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(.85); opacity: .5; }
  50% { transform: scale(1); opacity: 1; }
}

.steps-list { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.steps-list li { padding-left: 4px; }
.steps-list li::marker { color: var(--accent); font-weight: 700; }

.divider { height: 1px; background: var(--border); margin: 4px 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
