:root {
  /* Layout idea: one phone-width column, a huge condensed day name as the hero, quiet cards below. */
  --bg: #eceef1;
  --surface: #ffffff;
  --ink: #0d1117;
  --muted: #5b6470;
  --line: #d3d8de;
  --accent: #1f3bff;
  --accent-ink: #ffffff;
  --good: #14915a;
  --warn: #b97f00;
  --bad: #cf3d2b;
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d12; --surface: #151922; --ink: #f1f3f6; --muted: #98a1ad; --line: #272d3a;
    --accent: #7388ff; --accent-ink: #0b0d12; --good: #3fc98a; --warn: #f0b93a; --bad: #ff6b57;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d12; --surface: #151922; --ink: #f1f3f6; --muted: #98a1ad; --line: #272d3a;
  --accent: #7388ff; --accent-ink: #0b0d12; --good: #3fc98a; --warn: #f0b93a; --bad: #ff6b57;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }

#app { max-width: 520px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
main { flex: 1; padding: calc(20px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 110px max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 14px; }

.display { font-family: var(--display); font-weight: 900; text-transform: uppercase; letter-spacing: 0.01em; line-height: 0.88; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* Hero */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 6px 0 2px; }
.hero .day { font-size: clamp(96px, 34vw, 168px); margin-left: -4px; }
.hero .meta { text-align: right; padding-bottom: 12px; display: flex; flex-direction: column; gap: 2px; }
.hero .streak { font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 1; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { font-family: var(--display); font-weight: 800; font-size: 34px; text-transform: uppercase; line-height: 0.95; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.btn { border: 1px solid var(--ink); background: transparent; border-radius: 4px; padding: 12px 16px; font-weight: 600; min-height: 46px; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.ghost { border-color: var(--line); color: var(--muted); }

/* WHOOP */
.whoop { border-left: 6px solid var(--line); }
.whoop.good { border-left-color: var(--good); }
.whoop.warn { border-left-color: var(--warn); }
.whoop.bad { border-left-color: var(--bad); }
.whoop .score { font-family: var(--display); font-weight: 900; font-size: 72px; line-height: 0.85; }
.whoop.good .score { color: var(--good); } .whoop.warn .score { color: var(--warn); } .whoop.bad .score { color: var(--bad); }
.stats { display: flex; gap: 18px; flex-wrap: wrap; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-family: var(--display); font-size: 24px; font-weight: 800; line-height: 1; }
.stats span { font-size: 12px; color: var(--muted); }
.pill { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 99px; padding: 3px 9px; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 6px 12px; font-size: 13px; min-height: 34px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.list li span:last-child { color: var(--muted); white-space: nowrap; }

/* Tabs */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs .in { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
nav.tabs button { border: 0; background: transparent; padding: 15px 2px; font-family: var(--display); font-weight: 800; font-size: 19px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border-top: 3px solid transparent; }
nav.tabs button[aria-current="page"] { color: var(--ink); border-top-color: var(--accent); }

/* Week */
.week { display: flex; flex-direction: column; }
.wday { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.wday:first-child { border-top: 0; }
.wday .d { font-family: var(--display); font-weight: 800; font-size: 26px; text-transform: uppercase; }
.wday.today .d { color: var(--accent); }
.dots { display: flex; gap: 6px; font-size: 12px; color: var(--muted); align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--muted); display: inline-block; }
.dot.on { background: var(--good); border-color: var(--good); }

/* Overlays */
.overlay { position: fixed; inset: 0; background: var(--bg); z-index: 10; overflow-y: auto; }
.overlay .in { max-width: 520px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 130px max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 14px; min-height: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ex { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.ex h3 { font-family: var(--display); font-weight: 800; font-size: 26px; text-transform: uppercase; line-height: 1; }
.set { display: grid; grid-template-columns: 26px 1fr 1fr 48px; gap: 8px; align-items: center; }
.set .n { font-family: var(--display); font-weight: 800; font-size: 20px; color: var(--muted); }
.set input[type="number"] { width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--bg); border-radius: 4px; padding: 10px; font-variant-numeric: tabular-nums; }
.set .check { width: 48px; height: 44px; border: 1.5px solid var(--ink); border-radius: 4px; background: transparent; font-weight: 700; }
.set.done .check { background: var(--good); border-color: var(--good); color: #fff; }
.set.done input { opacity: 0.6; }
.sethead { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.restbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--ink); color: var(--bg); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); z-index: 11; }
.restbar .in2 { max-width: 520px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.restbar .t { font-family: var(--display); font-weight: 900; font-size: 40px; line-height: 1; }
.restbar .btn { border-color: var(--bg); color: var(--bg); }
.restbar .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Flow player */
.flow { text-align: left; justify-content: space-between; }
.flow .count { font-family: var(--display); font-weight: 900; font-size: clamp(96px, 30vw, 150px); line-height: 0.8; }
.flow .name { font-family: var(--display); font-weight: 800; font-size: 36px; text-transform: uppercase; line-height: 0.95; text-wrap: balance; }
.stage { display: flex; flex-direction: column; gap: 12px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.25s linear; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

textarea { width: 100%; min-height: 90px; border: 1px solid var(--line); background: var(--bg); border-radius: 4px; padding: 10px; font-size: 13px; }
.hist li { align-items: baseline; }
@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }

/* Hand-drawn figures */
.exhead { display: grid; grid-template-columns: 1fr 112px; gap: 10px; align-items: start; }
.sketch { width: 112px; aspect-ratio: 1; }
.sketch.big { width: min(100%, 300px, 40vh); margin: 0 auto; }
.sketch svg { display: block; width: 100%; height: 100%; overflow: visible; }
.sketch path, .sketch line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.sketch .sk-o { stroke: var(--ink); }
.sketch .sk-f { stroke: var(--surface); }
.sketch .sk-far-o { stroke: var(--muted); }
.sketch .sk-far-f { stroke: var(--surface); }
.sketch .sk-leg-o { stroke-width: 12; } .sketch .sk-leg-f { stroke-width: 9; }
.sketch .sk-arm-o { stroke-width: 9.6; } .sketch .sk-arm-f { stroke-width: 6.8; }
.sketch .sk-neck-o { stroke-width: 8; } .sketch .sk-neck-f { stroke-width: 5.2; }
.sketch .sk-torso-o { stroke: var(--ink); stroke-width: 20; }
.sketch .sk-torso { stroke-width: 17; }
.sketch .sk-pelvis { stroke: var(--ink); stroke-width: 1.3; }
.sketch .sk-short { stroke-width: 12.5; }
.sketch .sk-short-far { opacity: 0.7; }
.sketch .sk-shoe { stroke: var(--ink); stroke-width: 7; }
.sketch .sk-shoe-far { stroke: var(--muted); }
.sketch .sk-skin { fill: var(--surface); stroke: var(--ink); stroke-width: 1.7; }
.sketch .sk-skin-far { stroke: var(--muted); }
.sketch .sk-hair { stroke: var(--ink); stroke-width: 5; }
.sketch .sk-eye { fill: var(--ink); stroke: none; }
.sketch .sk-gesture { fill: none; stroke: var(--ink); stroke-width: 0.9; opacity: 0.45; }
.sketch .sk-paper { fill: var(--surface); stroke: none; }
.sketch .sk-hatch-ink { stroke: var(--ink); stroke-width: 1.5; stroke-linecap: butt; }
.sketch .sk-hatch-accent { stroke: var(--accent); stroke-width: 1.7; stroke-linecap: butt; }
.sketch .sk-floor { stroke: var(--muted); stroke-width: 1.6; opacity: 0.7; }
.sketch .sk-floor2 { stroke-width: 0.9; opacity: 0.5; }
.sketch .sk-shadow { stroke: var(--muted); stroke-width: 1.1; opacity: 0.6; }
.sketch .sk-prop { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; opacity: 0.7; }
.sketch .sk-prop2 { stroke-width: 0.9; opacity: 0.45; }
.sketch .sk-cable { stroke: var(--ink); stroke-width: 1.1; opacity: 0.6; }
.sketch .sk-weight { fill: var(--ink); stroke: var(--surface); stroke-width: 1.2; }

/* Food */
.foodform { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.foodform > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
input[type="text"], .foodform input, #food-goal { width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--bg); border-radius: 4px; padding: 10px; min-height: 44px; }
.list li .chip { margin-left: 8px; min-height: 28px; padding: 2px 10px; font-size: 12px; color: var(--muted); }

/* Home */
.hero .day { font-size: clamp(72px, 24vw, 120px); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; min-height: 150px; }
.tile .sketch { display: block; width: 96px; align-self: center; }
.tile .tname { font-family: var(--display); font-weight: 800; font-size: 24px; text-transform: uppercase; line-height: 0.95; }
.trow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.trow:first-of-type { border-top: 0; }
.pair { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }
.pill.ok { border-color: var(--good); color: var(--good); }
.chip.st-on { border-color: var(--good); color: var(--good); }
.chip.st-tbd { border-color: var(--warn); color: var(--warn); }
.chip.st-paused { color: var(--muted); }
select, #synckey { border: 1px solid var(--line); background: var(--bg); border-radius: 4px; padding: 10px; min-height: 44px; max-width: 60%; font: inherit; color: inherit; }
#synckey { max-width: none; width: 100%; }
.flow .count.long { font-size: clamp(72px, 22vw, 120px); }
.stage.nosk { display: block; }
.stage.nosk .count { font-size: clamp(120px, 40vw, 220px); }
.stage.nosk .count.long { font-size: clamp(96px, 30vw, 170px); }

/* iPhone Duo, folded. In Safari the cover screen gives pages about 382 px of width (466 from the Home Screen) and it is short,
   so on short screens the sketch sits beside the countdown and nothing scrolls. One move, one number, readable from a cup holder. */
@media (max-height: 740px) and (min-width: 360px) {
  .stage:not(.nosk) { display: grid; grid-template-columns: 1fr 1.1fr; align-items: center; gap: 12px; }
  .sketch.big { width: 100%; max-width: 44vh; }
  .overlay .flow.in { padding-bottom: 20px; }
  .flow .name { font-size: 30px; }
}
/* iPhone Duo, open: a near-square inner screen (about 890 to 951 px wide). Two columns, split at the fold. */
@media (min-width: 800px) {
  #app, nav.tabs .in, .overlay .in, .restbar .in2 { max-width: 940px; }
  main:not(.home), .overlay .in:not(.flow) { display: block; columns: 2; column-gap: 28px; }
  main:not(.home) > *, .overlay .in:not(.flow) > * { break-inside: avoid; margin-bottom: 14px; }
  main:not(.home) > header, main:not(.home) > .topbar, main:not(.home) > p, .overlay .in:not(.flow) > .topbar, .overlay .in:not(.flow) > h1 { column-span: all; }
  main.home { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; align-items: start; }
  main.home > .hero { grid-column: 1 / -1; }
  main.home > .tiles { grid-column: 2; grid-row: 2 / span 3; grid-template-columns: 1fr 1fr 1fr; }
  .tile { min-height: 132px; } .tile .sketch { width: 84px; } .tile .tname { font-size: 21px; }
  main.home > section { grid-column: 1; }
  .stage:not(.nosk) { gap: 28px; }
  .sketch.big { max-width: 60vh; }
  .flow .count { font-size: 190px; }
  .flow .count.long { font-size: 130px; }
  .flow .name { font-size: 44px; }
}

a { color: var(--accent); }
