/* Coach — app styles.
   Type: Barlow (a face drawn from road signs and plates), semi-condensed for figures and titles.
   Colour: chalk and asphalt, with road-marking yellow kept for what is "now" or "do this". */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("/fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("/fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("/fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 500; font-display: swap; src: url("/fonts/barlow-semi-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap; src: url("/fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --bg: #f1f4f6;
  --surface: #ffffff;
  --ink: #14202b;
  --ink-2: #47545f;
  --muted: #6f7b85;
  --line: #dde3e8;
  --axis: #c2cbd2;
  --road: #f6c700;
  --road-ink: #14202b;
  --focus: #1c5cab;
  --good: #0ca30c;
  --warn: #d03b3b;
  --bubble-me: #14202b;
  --bubble-me-ink: #ffffff;
  /* data: identity (fixed per entity) */
  --c-fitness: #2a78d6;
  --c-fatigue: #eb6834;
  --c-form: #1baf7a;
  /* data: intensity, one hue, light to dark */
  --z0: #c2cbd2; --z1: #86b6ef; --z2: #5598e7; --z3: #2a78d6; --z4: #1c5cab; --z5: #104281;
  --todo: #b7d3f6;
  --track: #cde2fb;
  --sans: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cond: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  --tab-h: 62px;
}

/* asphalt: the dark values. Used for the whole app in dark mode, and for the
   "today" panel in both modes. */
.asphalt {
  color-scheme: dark;
  --bg: #121a21;
  --surface: #1b252e;
  --ink: #f2f5f7;
  --ink-2: #b9c3cb;
  --muted: #8a96a0;
  --line: #2b3742;
  --axis: #3a4753;
  --focus: #86b6ef;
  --good: #0ca30c;
  --warn: #e66767;
  --bubble-me: #f6c700;
  --bubble-me-ink: #14202b;
  --c-fitness: #3987e5;
  --c-fatigue: #d95926;
  --c-form: #199e70;
  --z0: #4a5763; --z1: #1c5cab; --z2: #2a78d6; --z3: #5598e7; --z4: #86b6ef; --z5: #b7d3f6;
  --todo: #1c5cab;
  --track: #184f95;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121a21; --surface: #1b252e; --ink: #f2f5f7; --ink-2: #b9c3cb; --muted: #8a96a0;
    --line: #2b3742; --axis: #3a4753; --focus: #86b6ef; --warn: #e66767;
    --bubble-me: #f6c700; --bubble-me-ink: #14202b;
    --c-fitness: #3987e5; --c-fatigue: #d95926; --c-form: #199e70;
    --z0: #4a5763; --z1: #1c5cab; --z2: #2a78d6; --z3: #5598e7; --z4: #86b6ef; --z5: #b7d3f6;
    --todo: #1c5cab; --track: #184f95;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); }
.page { padding: 0 18px; }
.page.stale { opacity: .55; transition: opacity .15s; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 6px 18px; }
.brand { font: 600 15px/1 var(--cond); letter-spacing: .02em; color: var(--ink-2); }
.top-actions { display: flex; gap: 2px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; border-radius: 12px; color: var(--ink-2); }
.icon-btn:active { background: var(--line); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- type ---------- */
.title { font: 600 30px/1.1 var(--cond); letter-spacing: -.005em; margin: 6px 0 16px; }
.h2 { font: 600 19px/1.2 var(--cond); margin: 30px 0 10px; }
.h2:first-child { margin-top: 8px; }
.sub { color: var(--ink-2); }
.small { font-size: 13.5px; }
.muted { color: var(--muted); }
.num { font-family: var(--cond); font-weight: 600; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--axis); background: transparent; font-weight: 600; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--road); border-color: var(--road); color: var(--road-ink); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.quiet { border-color: transparent; color: var(--ink-2); padding: 0 10px; min-height: 40px; font-weight: 500; }
.btn.danger { color: var(--warn); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; white-space: nowrap; }
.btn-row .btn.primary { flex: 2; }

/* ---------- notices ---------- */
.notice { border-left: 3px solid var(--warn); background: var(--surface); padding: 10px 12px; border-radius: 0 8px 8px 0; margin: 0 0 14px; font-size: 14.5px; }
.notice p + p { margin-top: 4px; }
.empty { color: var(--ink-2); padding: 6px 0 2px; }

/* ---------- today panel ---------- */
.today { background: var(--surface); color: var(--ink); border-radius: 16px; padding: 18px 16px 14px; }
.today .kicker { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink-2); font-size: 14.5px; }
.today .kicker .mark { width: 18px; height: 4px; background: var(--road); border-radius: 2px; }
.today .w-name { font: 600 26px/1.12 var(--cond); margin: 8px 0 8px; }
.today .done-tag { color: var(--ink); }
.meta { display: flex; flex-wrap: wrap; align-items: center; column-gap: 14px; row-gap: 2px; color: var(--ink-2); font-size: 14.5px; }
.meta > span { display: inline-flex; align-items: center; gap: 6px; }
.meta svg { width: 16px; height: 16px; }
.meta .num { font-size: 16px; color: var(--ink); }
.chart { width: 100%; touch-action: pan-y; }
.chart svg { overflow: visible; }
.today .chart { margin: 14px 0 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-2); margin: 6px 0 2px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend b { font-family: var(--cond); font-weight: 600; color: var(--ink); margin-left: 4px; }
.legend .ln i { height: 3px; width: 14px; border-radius: 2px; vertical-align: 3px; }

/* ---------- steps ---------- */
.steps { margin-top: 10px; border-top: 1px solid var(--line); }
.steps summary { list-style: none; cursor: pointer; padding: 10px 0 8px; font-weight: 500; font-size: 14.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.steps summary::-webkit-details-marker { display: none; }
.steps summary svg { width: 16px; height: 16px; transition: transform .15s; }
.steps[open] summary svg { transform: rotate(90deg); }
.block + .block { margin-top: 10px; }
.block-h { font-weight: 600; font-size: 14.5px; display: flex; gap: 8px; align-items: baseline; }
.block-h .reps { font-family: var(--cond); background: var(--road); color: var(--road-ink); padding: 0 7px; border-radius: 5px; font-size: 14px; }
.step { display: grid; grid-template-columns: 78px 1fr; gap: 10px; padding: 3px 0; font-size: 15px; }
.step .d { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.step .cue { color: var(--muted); }
.notes { white-space: pre-wrap; font-size: 15px; color: var(--ink-2); margin-top: 8px; }

/* ---------- data fields (head-unit grid) ---------- */
.fields { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.field { padding: 12px 0 12px 14px; border-left: 1px solid var(--line); min-width: 0; }
.field:first-child { border-left: 0; padding-left: 0; }
.field .v { font: 600 34px/1 var(--cond); }
.field .l { margin-top: 6px; font-size: 13.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.field .l i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.field .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.fields.minor { border-top: 0; margin-top: 0; }
.fields.minor .field .v { font-size: 24px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.status svg { width: 16px; height: 16px; }
.status.good svg { color: var(--good); }
.status.warn svg { color: var(--warn); }
.form-hint { margin-top: 10px; font-size: 14.5px; color: var(--ink-2); }

/* ---------- rows ---------- */
.rows { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.row .grow { flex: 1; min-width: 0; }
.row .grow > span { display: block; }
.row .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r { text-align: right; flex: none; }
.row .r .num { font-size: 18px; }
.row .chev { color: var(--muted); width: 18px; height: 18px; flex: none; }
.wx { display: flex; align-items: center; gap: 12px; }
.wx svg { width: 30px; height: 30px; color: var(--ink-2); flex: none; }
.wx .temps { font: 600 22px/1 var(--cond); }
.commute { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 12px; border-top: 1px solid var(--line); }
.commute > div { padding: 10px 0 0 14px; border-left: 1px solid var(--line); }
.commute > div:first-child { border-left: 0; padding-left: 0; }
.commute .v { font: 600 18px/1.2 var(--cond); }
.brief { white-space: pre-wrap; color: var(--ink-2); font-size: 15.5px; }
.brief.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- plan: week strip ---------- */
.week .tot { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.week .tot .v { font: 600 22px/1 var(--cond); }
.week .tot .v small { font: 400 13.5px var(--sans); color: var(--ink-2); margin-left: 6px; }
.week .tot .l { font-size: 13px; color: var(--ink-2); margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.week .tot .l i { width: 10px; height: 10px; border-radius: 2px; }
.strip { margin-top: 12px; }

/* ---------- plan: roadbook ---------- */
.road { margin-top: 8px; }
.stop { display: grid; grid-template-columns: 48px 1fr; column-gap: 14px; position: relative; padding-bottom: 20px; }
.stop::before { content: ""; position: absolute; left: 54.5px; top: 10px; bottom: -10px; width: 1px; background: var(--axis); }
.stop:last-child::before { display: none; }
.stop .when { text-align: right; padding-top: 1px; }
.stop .when .wd { font-size: 13px; color: var(--ink-2); line-height: 1.1; }
.stop .when .dn { font: 600 24px/1 var(--cond); }
.stop .body { position: relative; padding-left: 16px; min-width: 0; }
.stop .body::before { content: ""; position: absolute; left: -6px; top: 8px; width: 11px; height: 11px; border-radius: 50%; background: var(--bg); border: 2px solid var(--axis); }
.stop.is-today .body::before { background: var(--road); border-color: var(--road); box-shadow: 0 0 0 3px var(--bg); }
.stop.has-work .body::before { border-color: var(--ink); }
.stop.is-today.has-work .body::before { border-color: var(--road); }
.stop .day-wx { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); min-height: 26px; }
.stop .day-wx svg { width: 18px; height: 18px; }
.stop .rest { color: var(--muted); font-size: 14.5px; padding-top: 2px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 10px; margin-top: 8px; }
.card .w-name { font: 600 19px/1.2 var(--cond); margin-bottom: 4px; }
.card .chart { margin: 10px 0 2px; }
.card.done { opacity: .72; }
.card .why { font-size: 14.5px; color: var(--ink-2); margin-top: 8px; }
.done-list { margin-top: 8px; font-size: 14.5px; color: var(--ink-2); }
.done-list .status { color: var(--ink); }
.proposal { border: 2px solid var(--road); border-radius: 16px; padding: 16px 14px; margin: 18px 0 6px; background: var(--surface); }
.proposal .h2 { margin-top: 0; }
.proposal .summary { color: var(--ink-2); white-space: pre-wrap; margin-bottom: 4px; }
.proposal .p-day { border-top: 1px solid var(--line); padding: 12px 0; }
.proposal .p-day .when { font-size: 13.5px; color: var(--ink-2); }
.proposal .p-day .w-name { font: 600 18px/1.2 var(--cond); margin: 1px 0 3px; }
.proposal .p-day .chart { margin: 8px 0 0; }
.working { display: flex; align-items: center; gap: 12px; color: var(--ink-2); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; gap: 8px; padding: 4px 14px 150px; }
.day-sep { align-self: center; font-size: 12.5px; color: var(--muted); margin: 10px 0 2px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.42; }
.msg.coach { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.user { align-self: flex-end; background: var(--bubble-me); color: var(--bubble-me-ink); border-bottom-right-radius: 5px; }
.msg .kind { display: block; font: 600 14px/1.2 var(--cond); margin-bottom: 4px; color: var(--ink-2); }
.msg time { display: block; font-size: 11.5px; opacity: .6; margin-top: 4px; text-align: right; }
.msg.typing { color: var(--muted); padding: 14px 16px; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 10px 12px 10px; z-index: 5; }
.composer .in { max-width: 536px; margin: 0 auto; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 2px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--axis); background: var(--surface); border-radius: 999px; padding: 7px 13px; font-size: 14.5px; font-weight: 500; }
.box { display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--axis); border-radius: 22px; padding: 5px 5px 5px 16px; }
.box textarea { flex: 1; border: 0; background: none; resize: none; outline: none; padding: 9px 0; max-height: 120px; line-height: 1.35; }
.send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--road); color: var(--road-ink); display: grid; place-items: center; flex: none; }
.send[disabled] { background: var(--line); color: var(--muted); }
.send svg { width: 20px; height: 20px; }

/* ---------- progress ---------- */
.panel { background: var(--surface); border-radius: 14px; padding: 14px 14px 10px; }
.panel + .panel { margin-top: 12px; }
.panel .h3 { font: 600 17px/1.2 var(--cond); }
.goal .big { font: 600 44px/1 var(--cond); }
.goal .big small { font-size: 20px; font-weight: 500; color: var(--ink-2); margin-left: 4px; }
.meter { position: relative; height: 12px; background: var(--track); border-radius: 6px; margin: 16px 0 6px; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c-fitness); border-radius: 6px; min-width: 12px; }
.meter .tick { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--ink); border-radius: 1px; }
.meter-ends { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.chart-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
details.table { margin-top: 6px; font-size: 13.5px; }
details.table summary { color: var(--ink-2); cursor: pointer; padding: 6px 0; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 0 6px 10px; border-bottom: 1px solid var(--line); font-weight: 400; }
th { color: var(--ink-2); font-weight: 500; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }

/* chart internals */
.grid { stroke: var(--line); stroke-width: 1; }
.base { stroke: var(--axis); stroke-width: 1; }
.tick-l { fill: var(--muted); font: 400 11px var(--sans); font-variant-numeric: tabular-nums; }
.ref { stroke: var(--ink-2); stroke-width: 1; }
.ref-l { fill: var(--ink-2); font: 500 11px var(--sans); }
.z0 { fill: var(--z0); } .z1 { fill: var(--z1); } .z2 { fill: var(--z2); } .z3 { fill: var(--z3); } .z4 { fill: var(--z4); } .z5, .z6, .z7 { fill: var(--z5); }
.hit { fill: transparent; }
.cross { stroke: var(--ink-2); stroke-width: 1; }
.ring { stroke: var(--surface); stroke-width: 2; }
#tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 13px; line-height: 1.35; padding: 6px 9px; border-radius: 8px; max-width: 240px; display: none; }
#tip b { font-family: var(--cond); font-weight: 600; font-size: 14px; }
#tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ---------- tab bar ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--tab-h); }
.tab { background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12.5px; font-weight: 500; color: var(--muted); position: relative; }
.tab .ic { width: 52px; height: 28px; border-radius: 14px; display: grid; place-items: center; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] .ic { background: var(--road); color: var(--road-ink); }
.tab .badge { position: absolute; top: 9px; left: calc(50% + 12px); width: 9px; height: 9px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(8, 14, 20, .5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 90dvh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 8px 18px calc(22px + env(safe-area-inset-bottom)); }
.sheet.enter { animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--axis); margin: 4px auto 12px; }
.sheet-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sheet-h .title { font-size: 24px; margin: 0 0 4px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; margin: 16px 0 4px; }
.stats .v { font: 600 22px/1.1 var(--cond); }
.stats .l { font-size: 13px; color: var(--ink-2); }
pre.diag { white-space: pre-wrap; font: 400 14px/1.5 var(--sans); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 12px 0 0; }

/* language choice */
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.seg button { min-height: 46px; border-radius: 10px; border: 1px solid var(--axis); background: var(--surface); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--road); border-color: var(--road); color: var(--road-ink); font-weight: 600; }
.sheet .row .status svg { width: 20px; height: 20px; }

/* ---------- sign-in ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 340px; }
.login .logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 18px; }
.login h1 { font: 600 32px/1.1 var(--cond); margin-bottom: 6px; }
.login p { color: var(--ink-2); margin-bottom: 22px; }
.login label { display: block; font-weight: 500; margin-bottom: 6px; }
.login input { width: 100%; height: 50px; border-radius: 10px; border: 1px solid var(--axis); background: var(--surface); padding: 0 14px; margin-bottom: 14px; }
.login .err { color: var(--warn); margin: 0 0 12px; min-height: 22px; }
.loading { padding: 40px 18px; color: var(--muted); }

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