:root {
  --bg: #0b0d10;
  --card: #14181d;
  --card-2: #1b2128;
  --line: #262d36;
  --text: #e8ecf1;
  --muted: #8a94a3;
  --accent: #c6ff3d;
  --accent-ink: #0b0d10;
  --danger: #ff6b6b;
  --tabs-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { overflow-x: hidden; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.num, .big { font-variant-numeric: tabular-nums; }

#app {
  max-width: 560px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom));
}

/* tab bar */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: rgba(11, 13, 16, .94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs a {
  flex: 1; max-width: 140px; min-height: var(--tabs-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
#tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs a[aria-current="page"] { color: var(--accent); }

/* typography */
.eyebrow { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 2px 0 0; font-size: 26px; line-height: 1.15; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.big { font-weight: 800; letter-spacing: -.03em; line-height: .95; }

/* layout bits */
.head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.head .titles { min-width: 0; }
.stack > * + * { margin-top: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }

.icon-btn {
  width: 48px; height: 48px; flex: none; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[disabled] { opacity: .35; cursor: default; }

.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; background: var(--card-2); color: var(--muted); border: 1px solid var(--line);
}
.pill.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pill.warn { color: #ffd166; border-color: #5b4a1d; }

/* hero (today) */
.hero { padding: 18px; }
.hero .miles { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 10px 0 8px; }
.hero .qty { display: flex; align-items: baseline; gap: 6px; }
.hero .qty .big { font-size: 72px; }
.hero .qty .unit { font-size: 20px; font-weight: 700; color: var(--muted); }
.hero .pace { text-align: right; font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.1; padding-bottom: 6px; }
.hero .pace small { display: block; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.hero h2 { margin: 6px 0 2px; font-size: 19px; }
.hero p { margin: 0; color: #c5ccd6; font-size: 15px; }
.hero.rest .big { font-size: 56px; }
.hero.wide .qty .big { font-size: 56px; }
.hero .pace { white-space: nowrap; }

/* buttons */
.btn {
  width: 100%; min-height: 64px; border-radius: 16px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-size: 20px; font-weight: 800; letter-spacing: .01em;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .6; }
.cta {
  position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); z-index: 5;
  margin: 0 -18px -18px; padding: 20px 18px 14px; border-radius: 0 0 18px 18px;
  background: linear-gradient(to bottom, rgba(20, 24, 29, 0), var(--card) 34%);
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); min-height: 52px; font-size: 16px; font-weight: 700; }
.btn.small { min-height: 48px; font-size: 15px; }

/* forms */
.field { display: block; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.field input, .field textarea {
  width: 100%; min-height: 52px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card-2); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.field textarea { font-size: 16px; font-weight: 500; min-height: 84px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { margin: 8px 2px 0; font-size: 14px; color: var(--muted); min-height: 20px; }
.hint b { color: var(--accent); font-variant-numeric: tabular-nums; }
.feel { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.feel button {
  min-height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--card-2);
  font-size: 22px; font-weight: 800; cursor: pointer;
}
.feel button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.feel-legend { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); }

/* banners & status */
.banner { border-radius: 16px; padding: 14px 16px; background: #1d2a0f; border: 1px solid #3a5a12; color: #dff7a8; }
.banner b { color: var(--accent); }
.done-card { border-color: #3a5a12; }
.done-card .check { color: var(--accent); font-weight: 800; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }

/* progress bars */
.bar { height: 10px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.bar-label { display: flex; justify-content: space-between; margin-top: 6px; font-size: 13px; color: var(--muted); }

/* plan */
.week { padding: 0; overflow: hidden; }
.week.current { border-color: #4b6b17; }
.week-head {
  width: 100%; min-height: 72px; padding: 14px 16px; display: block; text-align: left; background: none; border: 0; cursor: pointer;
}
.week-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.week-top h3 { margin: 0; font-size: 19px; }
.week-mi { text-align: right; flex: none; }
.week-mi .big { font-size: 34px; }
.week-mi small { color: var(--muted); font-weight: 700; margin-left: 3px; }
.week-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 10px; }
.days { display: none; border-top: 1px solid var(--line); }
.week.open .days { display: block; }
.day {
  width: 100%; min-height: 60px; padding: 10px 16px; display: flex; align-items: center; gap: 12px;
  text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.day:last-child { border-bottom: 0; }
.card.day { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 18px; }
.day .dow { width: 38px; flex: none; font-size: 13px; font-weight: 800; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.day.today .dow { color: var(--accent); }
.day .what { flex: 1; min-width: 0; }
.day .what b { display: block; font-size: 16px; }
.day .what span { font-size: 13px; color: var(--muted); }
.day .mi { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; flex: none; }
.day .st { width: 22px; flex: none; text-align: center; font-weight: 800; color: var(--accent); }
.day.rest .what b, .day.before .what b { color: var(--muted); font-weight: 600; }
.day.before { opacity: .55; }
.chev { transition: transform .15s; flex: none; width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.week.open .chev { transform: rotate(180deg); }
.race-card { text-align: center; padding: 26px 18px; border-color: #4b6b17; }
.race-card .big { font-size: 64px; color: var(--accent); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar a.btn { text-decoration: none; display: grid; place-items: center; }
.empty { text-align: center; padding: 36px 18px; }
.empty .big { font-size: 40px; }

/* login */
.signed-out #tabs { display: none; }
.login { padding-top: 12vh; }
.login h1 { font-size: 32px; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  z-index: 20; max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 14px; background: #f2f5f8; color: #0b0d10;
  font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); }

@media (min-width: 700px) { #app { padding-top: 28px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* coach */
.coach-answer { margin: 0; white-space: pre-wrap; line-height: 1.5; }
.coach-out:empty { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card-2); font-weight: 600; font-size: 15px; cursor: pointer; }
.chip:active { background: var(--line); }
#coach-q { min-height: 52px; }
#coach-q { width: 100%; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card-2); }
#coach-q:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* ---------- notices, queue banner ---------- */
.notice .two { gap: 10px; }
.btn.danger { color: #ffb4b4; border-color: #5a2b2b; }
.warn-card { border-color: #5b4a1d; }
.warn-card.sev-3 { border-color: #7a2f2f; }
.moves { margin: 0; padding: 0; list-style: none; }
.moves li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; color: #c5ccd6; }
.moves li b { color: var(--text); }

/* hurt form */
.chip[aria-checked="true"], .sev-btn[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.sev { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sev-btn { min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--card-2); font-weight: 700; font-size: 15px; cursor: pointer; }

/* ---------- progress ---------- */
.unit-lg { font-size: 22px; font-weight: 700; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tiles.three { grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; min-width: 0; }
.tiles.three .tile { background: var(--card-2); padding: 10px; }
.tile .v { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.tiles.three .tile .v { font-size: 22px; }
.tile .l { margin-top: 4px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); font-weight: 600; }
.legend .key { display: inline-flex; align-items: center; gap: 7px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.sw.planned { background: var(--planned); }
.sw.actual { background: var(--accent); }
.sw.line { width: 16px; height: 2px; border-radius: 1px; background: var(--planned); }
.sw.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
:root { --planned: #6b7686; }

svg.chart { width: 100%; height: auto; display: block; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
svg.chart text { font-family: inherit; }
svg.chart .tick { font-size: 9px; fill: var(--muted); font-variant-numeric: tabular-nums; }
svg.chart .tick.strong { fill: var(--text); font-weight: 700; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .ax { stroke: #3a444f; stroke-width: 1; }
svg.chart .c-planned { fill: var(--planned); }
svg.chart .c-actual { fill: var(--accent); }
svg.chart .sel { fill: var(--card-2); }
svg.chart .now { fill: var(--accent); }
svg.chart .l-planned { fill: none; stroke: var(--planned); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .dot-actual { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
svg.chart .dot-planned { fill: var(--planned); stroke: var(--card); stroke-width: 2; }
svg.chart .cross { stroke: var(--muted); stroke-width: 1; }
svg.chart .hit { cursor: pointer; outline: none; }
svg.chart .hit:focus-visible { stroke: var(--accent); stroke-width: 1.5; }
.readout { min-height: 128px; }
.hero-count .big { color: var(--text); }

.table-card summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700; color: var(--muted); }
.table-card table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.table-card th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); }
.table-card td { padding: 9px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.table-card th:nth-child(n+3), .table-card td.num { text-align: right; }
.table-card tr.cur td { color: var(--accent); font-weight: 700; }

/* ---------- calculator ---------- */
.rows .r { display: flex; justify-content: space-between; align-items: baseline; padding: 11px 0; border-top: 1px solid var(--line); font-size: 17px; }
.rows .r:first-child { border-top: 0; }
.goal-table { display: grid; gap: 8px; }
.goal-table .gh, .goal-table .gr { display: grid; grid-template-columns: 52px 1fr 1fr 1.25fr 1.25fr; gap: 6px; align-items: center; text-align: right; }
.goal-table .gh { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 0 12px; }
.goal-table .gh span:first-child, .goal-table .gr b { text-align: left; }
.goal-table .gr { min-height: 56px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--card-2); font-size: 15px; cursor: pointer; width: 100%; }
.goal-table .gr b { font-size: 17px; }
.goal-table .gr.on { border-color: var(--accent); }
.splits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 12px; margin-top: 8px; }
.splits .s { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

/* ---------- add a run ---------- */
.proposal { background: var(--card-2); }
.err { margin: 0; color: var(--danger); font-weight: 600; }
.hint.warn { color: #ffd166; min-height: 0; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; font-size: 15px; cursor: pointer; }
.check input { width: 26px; height: 26px; flex: none; accent-color: #c6ff3d; }
.field input[type="date"] { color-scheme: dark; }
#ri-text { width: 100%; min-height: 84px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card-2); }
#ri-text:focus { outline: 2px solid var(--accent); border-color: transparent; }
.proposal .field input[type="text"] { font-size: 18px; }

/* ---------- update banner ---------- */
#update-banner { position: fixed; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top)); z-index: 30; max-width: 536px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 16px; background: #f2f5f8; color: #0b0d10; font-weight: 700; box-shadow: 0 8px 28px rgba(0, 0, 0, .5); }
#update-banner span { flex: 1; }
#update-banner .btn { width: auto; min-height: 48px; padding: 0 20px; }

/* ---------- heart rate ---------- */
svg.chart .dot-approx { fill: var(--card); stroke: var(--accent); stroke-width: 2; }
svg.chart .sel-ring { fill: none; stroke: var(--text); stroke-width: 1.5; }
.stats .stat .v { font-size: 24px; }
.table-card td.muted, .table-card .num.muted { color: var(--muted); }

/* ---------- coach chat ---------- */
#tabs a { position: relative; }
#tabs .dot { position: absolute; top: 10px; left: calc(50% + 8px); width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.chat { display: flex; flex-direction: column; min-height: calc(100vh - 200px); }
.thread { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-bottom: 14px; }
.msg { display: flex; flex-direction: column; gap: 10px; max-width: 92%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; }
.bubble { padding: 12px 16px; border-radius: 20px; font-size: 16.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot .bubble { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.user .bubble { background: #22300a; border: 1px solid #3f5a12; border-bottom-right-radius: 6px; color: #eaf8c4; }
.msg .draft { background: var(--card-2); width: min(100%, 520px); }
.chat-empty { padding: 18px 4px; }
.dots { display: inline-flex; gap: 5px; align-items: center; vertical-align: middle; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.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; } }
.composer { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); z-index: 6; display: flex; gap: 10px; align-items: flex-end; margin: 0 -16px; padding: 12px 16px 10px; background: linear-gradient(to bottom, rgba(11, 13, 16, 0), var(--bg) 24%); }
.composer textarea { flex: 1; min-height: 52px; max-height: 120px; padding: 13px 16px; border-radius: 26px; border: 1px solid var(--line); background: var(--card-2); font-size: 17px; line-height: 1.35; resize: none; }
.composer textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.composer .send { width: 84px; flex: none; min-height: 52px; border-radius: 26px; }
.pill.status-open { color: #ffd166; border-color: #5b4a1d; }
.pill.status-in_progress { color: #8ecbff; border-color: #24465f; }
.pill.status-done { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pill.status-declined { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: .6; } }

/* ---------- plan check ---------- */
.wk-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.wk-table th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); }
.wk-table th:nth-child(n+2), .wk-table td.num { text-align: right; }
.wk-table td { padding: 10px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.btn[disabled].ghost { opacity: .45; }
