@font-face { font-family: 'Big Shoulders Display'; font-style: normal; font-weight: 800; font-display: swap; src: url('fonts/big-shoulders-display-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'Big Shoulders Display'; font-style: normal; font-weight: 900; font-display: swap; src: url('fonts/big-shoulders-display-latin-900-normal.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/archivo-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/archivo-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/archivo-latin-700-normal.woff2') format('woff2'); }

:root {
  --mat: #2547A8;
  --mat-deep: #1B3784;
  --chalk: #FFFFFF;
  --tape: #FFC93C;
  --tape-ink: #3A2A00;
  --paper: #EEF2F8;
  --card: #FFFFFF;
  --ink: #16213F;
  --muted: #56627F;
  --line: #D3DBEA;
  --danger: #C0392B;

  --display: 'Big Shoulders Display', 'Arial Narrow', Impact, sans-serif;
  --body: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0F1830;
    --card: #17223F;
    --ink: #E8EDF7;
    --muted: #A3AECA;
    --line: #2A3758;
    --danger: #FF7A6B;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--tape); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--gutter) calc(48px + env(safe-area-inset-bottom));
}

/* ---------- Stick figures ---------- */
.mat {
  background: var(--mat);
  border-radius: var(--r-md);
  overflow: hidden;
  position: relative;
}
.figure { display: block; width: 100%; height: auto; }
.fig-ground { stroke: rgba(255, 255, 255, .28); stroke-width: 2; stroke-linecap: round; }
.fig-near polyline, .fig-far polyline { stroke: var(--chalk); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.fig-far polyline { stroke-opacity: .42; }
.fig-head { fill: var(--chalk); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--r-md);
  padding: 14px 20px; min-height: 52px;
  font-weight: 700; font-size: 17px;
  background: var(--card); color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--line);
  transition: transform .08s ease;
}
.btn:active { transform: scale(.98); }
.btn-tape { background: var(--tape); color: var(--tape-ink); box-shadow: none; }
.btn-mat { background: var(--mat); color: var(--chalk); box-shadow: none; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-text {
  background: none; border: 0; padding: 8px 4px; color: var(--muted);
  font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.btn-danger { color: var(--danger); }

/* ---------- Sign in ---------- */
.signin { min-height: 100dvh; display: flex; flex-direction: column; }
.signin-hero {
  background: var(--mat);
  color: var(--chalk);
  padding: calc(28px + env(safe-area-inset-top)) var(--gutter) 0;
}
.signin-hero-inner { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 8px; }
.signin-title {
  font: 900 clamp(84px, 26vw, 168px)/.8 var(--display);
  margin: 0 0 18px;
  letter-spacing: -.01em;
}
.signin-title span { display: block; font-size: .42em; font-weight: 800; letter-spacing: .01em; margin-top: 8px; line-height: .95; }
.signin-hero .figure { max-width: 260px; margin-left: auto; }
.signin-body { padding-top: 24px; flex: 1; }
.lede { font-size: 18px; margin: 0 0 24px; max-width: 34ch; }
.field-label { display: block; font-weight: 600; margin-bottom: 6px; }
.signin-form { display: flex; gap: 8px; }
.input {
  flex: 1; min-width: 0;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  background: var(--card); padding: 12px 14px; min-height: 52px; font-size: 18px;
}
.input:focus { border-color: var(--mat); outline: none; box-shadow: 0 0 0 3px rgba(37, 71, 168, .25); }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.error { color: var(--danger); font-weight: 600; font-size: 15px; margin: 8px 0 0; }

/* ---------- Home ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 0 6px;
}
.hello { font-weight: 600; }
.menu-btn {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 14px; font-weight: 600; font-size: 15px;
}

.today-panel { margin-top: 12px; }
.day-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.day-num {
  font: 900 clamp(76px, 22vw, 128px)/.82 var(--display);
  margin: 0;
  letter-spacing: -.01em;
}
.day-num small { font-size: .32em; font-weight: 800; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.phase { margin: 18px 0 0; color: var(--muted); max-width: 46ch; }
.phase b { color: var(--ink); }

.targets {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 18px 0; border-top: 1.5px solid var(--line); border-bottom: 1.5px solid var(--line);
}
.target { padding: 10px 0; }
.target + .target { padding-left: 14px; border-left: 1.5px solid var(--line); }
.target b { display: block; font: 800 40px/1 var(--display); }
.target span { color: var(--muted); font-size: 14px; }

.viewing-note {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-md);
  padding: 6px 6px 6px 14px; margin-bottom: 14px; font-size: 15px;
}

.section-title { font-size: 20px; font-weight: 700; margin: 34px 0 4px; }
.section-sub { color: var(--muted); margin: 0 0 14px; font-size: 15px; }

.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; list-style: none; padding: 0; margin: 0; }
.move {
  display: block; width: 100%; text-align: left; padding: 0; border: 0; background: none;
}
.move .mat { display: block; aspect-ratio: 5 / 4; }
.move .figure { position: absolute; inset: 0; height: 100%; }
.move-cat { position: absolute; top: 8px; left: 10px; color: rgba(255,255,255,.75); font-size: 13px; font-weight: 600; }
.move-name { display: block; font-weight: 700; margin-top: 6px; line-height: 1.25; }
.move-meta { display: block; color: var(--muted); font-size: 14px; }

.how { padding-left: 1.2em; margin: 0; color: var(--ink); }
.how li { margin: 4px 0; }

/* 30-day grid */
.grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; list-style: none; padding: 0; margin: 0; }
.cell {
  width: 100%; aspect-ratio: 1; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 800 22px/1 var(--display); padding: 0; position: relative;
}
.cell small { font: 600 11px/1.2 var(--body); color: var(--muted); margin-top: 2px; }
.cell.done { background: var(--mat); border-color: var(--mat); color: var(--chalk); }
.cell.done small { color: rgba(255,255,255,.8); }
.cell.today { border: 3px solid var(--tape); }
.cell.locked { color: var(--muted); background: transparent; }
.cell.selected { box-shadow: 0 0 0 3px var(--ink); }
.cell.final:not(.done) { border-style: dashed; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; border: 1.5px solid var(--line); }
.legend .l-done { background: var(--mat); border-color: var(--mat); }
.legend .l-today { border: 2.5px solid var(--tape); }
.legend .l-final { border-style: dashed; }

/* sets chart */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding-top: 18px; border-bottom: 1.5px solid var(--line); }
.bar { flex: 1; background: var(--line); border-radius: 3px 3px 0 0; min-height: 3px; position: relative; }
.bar.has { background: var(--mat); }
.bar.final.has { background: var(--tape); }
.bar span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 4px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat b { display: block; font: 800 32px/1 var(--display); }
.stat span { color: var(--muted); font-size: 13px; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }
.history li span { color: var(--muted); }

.finished {
  background: var(--tape); color: var(--tape-ink);
  border-radius: var(--r-lg); padding: 20px; margin-top: 16px;
}
.finished h2 { font: 900 44px/.9 var(--display); margin: 0 0 8px; }
.finished p { margin: 0 0 14px; }

/* ---------- Bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(10, 16, 34, .55); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.sheet {
  background: var(--paper); width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 10px var(--gutter) calc(24px + env(safe-area-inset-bottom));
  animation: up .2s ease;
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: var(--r-lg); }
}
.sheet-handle { width: 40px; height: 4px; background: var(--line); border-radius: 2px; margin: 0 auto 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sheet h2 { font: 900 40px/.95 var(--display); margin: 0 0 4px; }
.sheet .mat { margin: 14px 0; aspect-ratio: 5 / 4; }
.sheet .mat .figure { position: absolute; inset: 0; height: 100%; }
.close-btn { border: 0; background: var(--card); border-radius: 999px; width: 40px; height: 40px; font-size: 22px; line-height: 1; flex: none; box-shadow: inset 0 0 0 1.5px var(--line); }
.cues { padding-left: 1.3em; margin: 0 0 14px; }
.cues li { margin: 6px 0; }
.easier { background: var(--card); border-radius: var(--r-md); padding: 12px 14px; border-left: 4px solid var(--tape); }
.easier b { display: block; }
.menu-list { display: grid; gap: 10px; margin-top: 8px; }
.confirm p { margin: 0 0 16px; }
.confirm .row { display: flex; gap: 10px; }
.confirm .row .btn { flex: 1; }

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }

/* ---------- Workout ---------- */
.workout {
  position: fixed; inset: 0; z-index: 30;
  background: var(--ink); color: var(--chalk);
  display: flex; flex-direction: column;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) calc(16px + env(safe-area-inset-bottom));
  overflow: auto;
}
@media (prefers-color-scheme: dark) { .workout { background: #0A1124; } }
.workout-inner { max-width: 560px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; flex: 1; gap: 12px; }
.w-top { display: flex; justify-content: space-between; align-items: center; }
.w-top .btn-text { color: rgba(255,255,255,.75); }
.w-day { font-weight: 600; color: rgba(255,255,255,.75); }
.clock {
  font: 900 clamp(88px, 30vw, 150px)/.85 var(--display);
  color: var(--tape); text-align: center; margin: 4px 0 0;
  font-variant-numeric: tabular-nums; letter-spacing: .01em;
}
.clock.paused { opacity: .45; }
.clock-label { text-align: center; color: rgba(255,255,255,.7); font-size: 15px; margin-top: -2px; }
.timebar { height: 6px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; }
.timebar i { display: block; height: 100%; background: var(--tape); width: 0; }
.w-move { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.w-move .mat { aspect-ratio: 16 / 10; }
.w-move .mat .figure { position: absolute; inset: 0; height: 100%; width: 100%; }
.w-move-name { font: 900 clamp(36px, 10vw, 52px)/.95 var(--display); margin: 0; }
.w-move-meta { color: rgba(255,255,255,.8); margin: 4px 0 0; font-size: 17px; }
.w-move-meta b { color: var(--tape); font-size: 22px; }
.w-tips { color: var(--chalk); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; opacity: .8; }
.w-strip { display: flex; gap: 6px; }
.w-strip span { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,.18); }
.w-strip span.on { background: var(--chalk); }
.w-bottom { margin-top: auto; display: grid; gap: 10px; }
.w-done { min-height: 76px; font-size: 22px; }
.w-row { display: flex; justify-content: space-between; align-items: center; color: rgba(255,255,255,.8); font-size: 15px; }
.w-row b { color: var(--chalk); font: 800 26px/1 var(--display); margin-right: 4px; }
.w-row .btn-text { color: rgba(255,255,255,.75); }
.w-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.w-controls .btn { background: rgba(255,255,255,.1); color: var(--chalk); box-shadow: none; }

.getready { text-align: center; margin: auto 0; }
.getready .clock { font-size: clamp(140px, 48vw, 240px); }
.getready p { font-size: 18px; color: rgba(255,255,255,.8); }

.summary { margin: auto 0; text-align: center; }
.summary h1 { font: 900 clamp(64px, 20vw, 110px)/.85 var(--display); color: var(--tape); margin: 0 0 6px; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 18px 0 6px; }
.stepper button { width: 56px; height: 56px; border-radius: 999px; border: 0; background: rgba(255,255,255,.12); color: var(--chalk); font-size: 28px; font-weight: 700; }
.stepper output { font: 900 96px/1 var(--display); min-width: 2ch; }
.summary .hint { color: rgba(255,255,255,.7); }
.summary .error { color: #FF9B8F; }

@media (min-width: 560px) {
  .moves { grid-template-columns: repeat(4, 1fr); }
  .grid { grid-template-columns: repeat(10, 1fr); }
}

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

.grid > li, .moves > li { display: block; min-width: 0; }
