:root {
  --bg: #0e1116; --panel: #161b22; --panel-2: #1d242e; --line: #2a333f;
  --text: #eef2f6; --muted: #8b97a6; --accent: #ff9f43; --accent-ink: #1a1206; --ok: #4cd18a;
  --fig: #e6ebf1; --fig-far: #7c8896; --fig-hi: #ff9f43; --fig-hi-far: #b8773a;
  --floor: #3a4553; --mat: #2f6e8f; --mattop: #1c3542; --wall: #1a2029; --base: #2a323d; --shadow: rgba(0,0,0,.55);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f4ef; --panel: #ffffff; --panel-2: #efece6; --line: #dcd7cd;
    --text: #1b1f24; --muted: #66707c; --accent: #e8720c; --accent-ink: #fff; --ok: #1f9d5a;
    --fig: #26303b; --fig-far: #8d98a5; --fig-hi: #e8720c; --fig-hi-far: #f0a868;
    --floor: #b9b2a5; --mat: #6fa6c2; --mattop: #d8e6ec; --wall: #ebe6dc; --base: #d3ccbf; --shadow: rgba(0,0,0,.18);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
.screen { display: none; min-height: 100dvh; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.screen.on { display: flex; flex-direction: column; }

/* ---------- home ---------- */
.home-top { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; }
.brand { font-weight: 700; font-size: 20px; letter-spacing: .2px; }
.today { color: var(--muted); font-size: 14px; }
.streak { margin: 28px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.streak b { font-size: 64px; line-height: 1; font-variant-numeric: tabular-nums; }
.streak span { color: var(--muted); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 22px; }
.week div { text-align: center; font-size: 12px; color: var(--muted); }
.week i { display: block; height: 30px; border-radius: 8px; background: var(--panel-2); margin-top: 4px; }
.week i.done { background: var(--ok); }
.week i.now { outline: 2px solid var(--accent); outline-offset: -2px; }
.list { list-style: none; padding: 0; margin: 0 0 18px; border-top: 1px solid var(--line); }
.list li { display: flex; justify-content: space-between; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.list li span { color: var(--muted); font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.mode { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel-2); border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.mode button { padding: 10px; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; }
.mode button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.start {
  width: 100%; min-height: 30vh; border-radius: 28px; background: var(--accent); color: var(--accent-ink);
  font-size: 44px; font-weight: 800; letter-spacing: .5px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.start small { font-size: 16px; font-weight: 600; opacity: .8; letter-spacing: 0; }
.start:disabled { opacity: .5; }
.start:active { transform: scale(.985); }
.hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- session ---------- */
#run { padding-top: max(10px, env(safe-area-inset-top)); }
.bar { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s linear; }
.meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin: 8px 2px 0; font-variant-numeric: tabular-nums; }
.ex { font-size: 30px; font-weight: 800; margin: 10px 0 0; line-height: 1.1; }
.sub { color: var(--accent); font-weight: 700; font-size: 18px; min-height: 25px; margin-top: 4px; }
.stage { position: relative; margin: 8px -16px 0; background: var(--panel); border-block: 1px solid var(--line); }
.stage svg { display: block; width: 100%; height: auto; max-height: 40vh; }
.cap { position: absolute; left: 12px; top: 8px; font-size: 12px; color: var(--muted); }
.next-pill { position: absolute; right: 10px; top: 8px; font-size: 12px; font-weight: 700; color: var(--accent-ink); background: var(--accent); padding: 2px 8px; border-radius: 99px; display: none; }
.big { text-align: center; font-size: 22vmin; font-weight: 800; line-height: 1; margin: 10px 0 2px; font-variant-numeric: tabular-nums; min-height: 1em; }
.big.small { font-size: 9vmin; }
.biglabel { text-align: center; color: var(--muted); font-weight: 600; min-height: 22px; }
.cue { font-size: 20px; line-height: 1.35; text-align: center; margin: 10px 4px 0; min-height: 2.7em; }
.ctrls { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 10px; margin-top: 14px; }
.ctrls button { height: 68px; border-radius: 18px; background: var(--panel-2); font-weight: 700; font-size: 17px; }
.ctrls #pause { background: var(--text); color: var(--bg); font-size: 20px; }
.ready { width: 100%; height: 64px; border-radius: 18px; margin-top: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 20px; display: none; }
.ready.on { display: block; }

.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; z-index: 5; }
.overlay.on { display: flex; }
.overlay h2 { font-size: 40px; margin: 0 0 10px; }
.overlay button { width: min(420px, 100%); height: 64px; border-radius: 18px; font-weight: 800; font-size: 20px; background: var(--panel-2); }
.overlay button.primary { background: var(--accent); color: var(--accent-ink); }

/* ---------- done ---------- */
#done { align-items: center; justify-content: center; text-align: center; gap: 8px; }
#done .tick { width: 96px; height: 96px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 56px; display: grid; place-items: center; margin-bottom: 8px; }
#done h1 { margin: 0; font-size: 36px; }
#done p { color: var(--muted); margin: 0 0 18px; }
#done button { width: min(420px, 100%); height: 60px; border-radius: 18px; background: var(--panel-2); font-weight: 700; }

/* ---------- figure ---------- */
.fx-floor { fill: var(--floor); }
.fx-mat { fill: var(--mat); }
.fx-mattop { fill: var(--mattop); }
.fx-wall { fill: var(--wall); }
.fx-base { fill: var(--base); }
.fx-limb, .fx-neck, .fx-torso { stroke: var(--fig); stroke-linecap: round; stroke-linejoin: round; fill: none; }
.fx-torso { fill: var(--fig); }
.fx-limb.arm { stroke-width: 11px; }
.fx-limb.leg { stroke-width: 15px; }
.fx-limb.foot { stroke-width: 8px; }
.fx-neck { stroke-width: 11px; }
.fx-head, .fx-hand { fill: var(--fig); }
.fx-shadow { stroke: var(--shadow); stroke-width: 11px; stroke-linecap: round; stroke-linejoin: round; }
.far { stroke: var(--fig-far); }
.fx-hand.far { fill: var(--fig-far); }
.hi { stroke: var(--fig-hi); }
.fx-torso.hi { fill: var(--fig-hi); }
.fx-hand.hi { fill: var(--fig-hi); }
.far.hi { stroke: var(--fig-hi-far); }
.fx-hand.far.hi { fill: var(--fig-hi-far); }
.fx-halo { stroke: var(--panel); stroke-linecap: round; stroke-linejoin: round; fill: none; }
.fx-halo.arm { stroke-width: 16px; }
.fx-halo.leg { stroke-width: 20px; }
.fx-halo.foot { stroke-width: 13px; }
.fx-halo-dot { fill: var(--panel); }
