:root {
  --bg: #0b0f14;
  --card: #141a22;
  --card-2: #1b232d;
  --line: #263140;
  --text: #e8eef6;
  --muted: #8fa0b4;
  --accent: #3ddc84;
  --accent-2: #35a7ff;
  --warn: #ffb020;
  --bad: #ff6b6b;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Android reports a 0px inset, so the tabbar sat flush against the system
     gesture bar and its last pixels swallowed the presses. A 22px floor keeps
     the three tabs hittable on both platforms, and #app reserves the same
     height so the last card does not slide under the bar. */
  --tab-bottom: max(calc(8px + var(--safe-bottom)), 22px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
}

#app { max-width: 720px; margin: 0 auto; padding-bottom: calc(60px + var(--tab-bottom)); }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(11, 15, 20, .85));
  backdrop-filter: blur(8px);
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: .5px; }
.brand .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 10px; height: 34px; font-size: 16px; cursor: pointer;
  /* Two-character labels ("档案") did not fit the old fixed 34px square: 16px
     each means 32px of text inside 22px of content box, so the box broke the
     word and the second character hung out below the border. */
  min-width: 34px; width: auto; padding: 0 9px; white-space: nowrap;
}
.ghost:active { background: var(--card-2); }

/* Two buttons on the right of the bar: the title stays left and the pair is
   spaced as one group rather than spread across the whole width. */
.topbar-actions { display: flex; gap: 6px; }

/* --- cards --- */
main { padding: 4px 12px 12px; display: grid; gap: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .meta, .meta { color: var(--muted); font-size: 12px; }
/* Right-aligned but allowed to shrink: a CTL/ATL/TSB that grows a digit should
   wrap its own text, not drop to the next flex line and sit under the title. */
.card-head .meta { flex: 1 1 0%; min-width: 0; text-align: right; }

/* --- hero --- */
/* Grid, not flex: the ring takes the left column, the three short race lines take
   the right one, and the verdict drops to full width underneath. Sharing the row
   with the ring squeezed it into 212px and wrapped one sentence over three lines. */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 12px 16px; align-items: center; }
.hero-ring { position: relative; width: 108px; height: 108px; flex: 0 0 auto; }
.hero-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.hero-ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.hero-ring .track { stroke: #1f2833; }
.hero-ring .value { stroke: var(--accent); stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset .6s ease; }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-label strong { font-size: 26px; line-height: 1; }
.ring-label span { font-size: 11px; color: var(--muted); margin-top: 4px; }

.hero-body { min-width: 0; }
.hero-line { font-size: 15px; font-weight: 600; }
.hero-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.hero-foot { grid-column: 1 / -1; min-width: 0; }
/* The gap verdict is a whole sentence with a plan inside it. It used to share a
   line with the target and the PB, which on a phone wrapped into an unreadable
   smear; it gets its own full-width line instead. */
.hero-note { color: var(--muted); font-size: 12px; line-height: 1.55; }
.hero-note:empty { display: none; }
.factors { list-style: none; margin: 8px 0 0; padding: 0; }
.factors li { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Shown only when the readiness score rests on thin evidence, so "100 很好"
   never reads as reassurance it has not earned. */
.hero-flag { display: inline-block; font-size: 11px; padding: 3px 8px; border-radius: 999px; background: #3a2a1c; color: var(--warn); margin-bottom: 6px; }
.hero-flag[hidden] { display: none; }

/* --- today --- */
.today-kind { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #22303f; color: var(--accent-2); }
.today-title { font-size: 17px; font-weight: 600; margin: 8px 0 4px; }
.today-detail { color: var(--muted); font-size: 13px; }
.today-stats { display: flex; gap: 18px; margin-top: 12px; }
.today-stats div { font-size: 12px; color: var(--muted); }
.today-stats strong { display: block; font-size: 16px; color: var(--text); font-weight: 600; }
/* The lines the engine wrote for this session before it was run. A session whose
   bar is invisible is a session nobody can argue with, so the bar goes on the
   card and not only in the database. */
.today-bars { margin-top: 10px; font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.today-kind.key { background: #1d3a2c; color: var(--accent); }
/* A session that last session's evidence moved. The card says so out loud: a plan
   that changes with no sentence next to it is a plan nobody trusts. */
.tuned-note {
  margin-top: 9px; padding: 8px 10px; border-left: 2px solid var(--accent);
  background: var(--card-2); border-radius: 6px; font-size: 12px; line-height: 1.55;
}
.week-outline { margin-top: 8px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.week-outline[hidden] { display: none; }
.expect-list { margin: 0; padding: 0; list-style: none; }
.expect-list li { position: relative; padding-left: 14px; font-size: 13px; line-height: 1.7; }
.expect-list li::before {
  content: ''; position: absolute; left: 0; top: 9px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2);
}
/* The evening half of the today card. Once the run is in, the card stops
   prescribing and reports: the engine's sentence is the biggest thing under the
   title, because reading it is why the card changed at all. */
.today-kind.race { background: #3a2a1c; color: var(--warn); }
.recap-line { margin-top: 6px; font-size: 13.5px; line-height: 1.55; }
.recap-next { margin-top: 10px; font-size: 12px; color: var(--accent-2); letter-spacing: .2px; }
.body-line {
  margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted); letter-spacing: .2px;
}
.body-line.dim { opacity: .55; }
/* Today's conditions, above the body line: on a hot morning this sentence is the
   most actionable thing on the card, so it is not buried in the detail text. */
.today-weather {
  margin-top: 10px; font-size: 11.5px; color: var(--accent-2); letter-spacing: .2px;
}

/* --- week --- */
.week-bar { height: 6px; border-radius: 999px; background: #1f2833; overflow: hidden; margin-bottom: 12px; }
.week-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s ease; }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day {
  border-radius: 12px; padding: 8px 4px; text-align: center; cursor: pointer;
  background: var(--card-2); border: 1px solid transparent; min-height: 74px;
}
.day.is-today { border-color: var(--accent-2); }
.day .wd { font-size: 11px; color: var(--muted); }
.day .title {
  font-size: 10px; line-height: 1.25; margin-top: 6px; word-break: normal;
  overflow-wrap: anywhere;
  /* Four characters in a 33px cell: plain wrapping gave "3 + 1", leaving one
     orphan character on its own line. Balanced wrapping gives "2 + 2". */
  text-wrap: balance;
}
.day .km { font-size: 10px; color: var(--muted); margin-top: 4px; }
.day.rest .title { color: var(--muted); }
.day.quality .title { color: var(--accent); }
.day.long .title { color: var(--accent-2); }
.day.race .title { color: var(--warn); }
.day.done { opacity: .55; }
/* A run the watch recorded is the opposite of "done, faded out" — it is the
   only cell on the grid that is a fact rather than a plan. */
.day.actual { opacity: 1; border-color: rgba(61, 220, 132, .35); }
.day.actual .title { color: var(--accent); }
/* A dot, not a badge: the day already carries a title and a distance, and a note
   is a footnote to the prescription rather than a second session. */
.day.advice { position: relative; }
.day.advice::after {
  content: ''; position: absolute; top: 5px; right: 5px;
  width: 5px; height: 5px; border-radius: 50%; background: #35a7ff;
}
/* Same dot in the weekly list, inline after the session title: the row is a
   table cell, so it cannot be positioned into a corner. */
.adv-dot {
  display: inline-block; width: 5px; height: 5px; margin-left: 5px;
  border-radius: 50%; background: #35a7ff; vertical-align: middle;
}

/* --- ability --- */
/* minmax(0, 1fr) rather than 1fr: at 375 px the pace cells were 0.8 px wider
   than the card and pushed a horizontal scrollbar onto the whole page. */
/* Six bands, three per row. Each cell carries three numbers (pace, heart rate,
   zone), so five in a row squeezed the heart rate out; six divides evenly into
   two rows of three with no cell left hanging, which is also how the ladder
   reads: recovery → easy → marathon / threshold → interval → repetition. */
.paces { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-top: 10px; }
.paces div {
  position: relative; overflow: hidden; border-radius: 10px; padding: 9px 2px 8px;
  text-align: center; background: linear-gradient(180deg, var(--wash), transparent 72%), var(--card-2);
}
/* The colour is the intensity ladder, cool to hot, and it lives on the top edge
   and in the heart rate rather than as a full-bleed background: six saturated
   cards would fight the numbers sitting on top of them. */
.paces div::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--tone); opacity: .75;
}
.paces div:nth-child(1) { --tone: #4c8dff; --wash: rgba(76,141,255,.13); }  /* Z1 恢复 */
.paces div:nth-child(2) { --tone: #35c6c6; --wash: rgba(53,198,198,.12); }  /* Z2 轻松 */
.paces div:nth-child(3) { --tone: #5fd068; --wash: rgba(95,208,104,.11); }  /* Z3 有氧 */
.paces div:nth-child(4) { --tone: #ffc247; --wash: rgba(255,194,71,.12); }  /* Z4 阈值 */
.paces div:nth-child(5) { --tone: #ff8a4c; --wash: rgba(255,138,76,.12); }  /* Z5 间歇 */
.paces div:nth-child(6) { --tone: #ff6b6b; --wash: rgba(255,107,107,.12); }  /* R 冲刺 */
.paces b { display: block; font-size: 12px; white-space: nowrap; }
/* The "-6:41" suffix lives inside the bold pace and must stay on its line; the
   block rule below is for the stacked heart rate and label, not for this. */
.paces b .to { display: inline; font-size: 8px; font-weight: 400; color: var(--muted); }
.paces span { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; }
/* The heart rate is a second dimension of the same prescription, so it carries
   the band's own colour instead of disappearing into the label. */
.paces span.hr { font-size: 10px; color: var(--tone); font-variant-numeric: tabular-nums; }
/* Grey for a number we do not have: a missing band should not be able to pass
   for a prescription. */
.paces span.hr.missing { color: var(--muted); }
/* "轻松 Z2": the Chinese word carries the meaning, the zone id ties the cell to
   the heart-rate ladder without needing a legend underneath. */
.paces i { font-style: normal; opacity: .6; }
/* What the fitness index is and where it came from. Two short paragraphs, not a
   third number: "VDOT 43.2" was the one thing on the card with no explanation. */
.ability-why { margin-top: 10px; font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.ability-basis { margin-top: 2px; font-size: 11px; color: var(--muted); opacity: .8; line-height: 1.7; font-variant-numeric: tabular-nums; }

/* --- chart --- */
/* The height belongs to the svg, not the container: the legend now lives inside
   the container, and a fixed 96px box would push it into the card below. */
.chart svg { display: block; width: 100%; height: 96px; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .ctl { fill: none; stroke: var(--accent-2); stroke-width: 2; }
.chart .atl { fill: none; stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 3 3; }

/* The legend is drawn with borders rather than an icon font so the solid and
   dashed swatches are literally the same strokes as the lines above them. */
.chart-legend { display: flex; gap: 14px; margin-top: 6px; font-size: 11px; color: var(--muted); }
.chart-legend span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.chart-legend i { width: 16px; height: 0; border-top: 2px solid currentColor; }
.chart-legend .ctl { color: var(--accent-2); }
.chart-legend .atl { color: var(--warn); }
.chart-legend .atl i { border-top-style: dashed; border-top-width: 1.5px; }

/* Weather sits under the zone bars as its own row: the bpm in bold is the one to
   compare across runs, the note explains why the raw number is higher. */
.rv-weather { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.rv-weather b { font-weight: 600; color: var(--fg); margin-left: 8px; font-variant-numeric: tabular-nums; }
.rv-weather i { font-style: normal; margin-left: 6px; font-size: 11px; opacity: .8; }

/* --- lists --- */
.act { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.act:last-child { border-bottom: 0; }
.act .date { font-size: 12px; color: var(--muted); width: 60px; flex: 0 0 auto; }
.act .main { flex: 1; min-width: 0; }
.act .main b { font-size: 15px; }
.act .main span { display: block; font-size: 12px; color: var(--muted); }
.act .pace { font-variant-numeric: tabular-nums; color: var(--accent); font-size: 15px; }
/* The class of the run, beside its distance: "11.26 km" alone does not answer
   what kind of session it was, and that is what a look back is for. */
.act-tag {
  display: inline-block; margin-left: 7px; padding: 1px 6px;
  border-radius: 999px; background: var(--card-2); border: 1px solid var(--line);
  font-size: 10.5px; font-style: normal; font-weight: 500;
  color: var(--muted); vertical-align: 1px; white-space: nowrap;
}
.act-tag.hot { color: var(--accent); border-color: rgba(61, 220, 132, .38); }

/* --- forms --- */
.drop {
  display: block; text-align: center; padding: 22px 12px; margin-bottom: 10px;
  border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 13px; cursor: pointer;
}
.drop:active { background: var(--card-2); }
.drop.busy { border-color: var(--accent); color: var(--accent); }

.row { display: flex; gap: 8px; margin-bottom: 14px; }
.btn {
  flex: 1; background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 12px; font-size: 14px; cursor: pointer;
}
.btn:active { transform: scale(.99); }
.btn.primary { background: var(--accent); color: #06210f; border-color: transparent; font-weight: 600; }
.btn[disabled] { opacity: .5; }

.signal h3 { font-size: 13px; margin: 4px 0 10px; color: var(--muted); font-weight: 500; }
.signal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.signal-head h3 { margin: 4px 0 10px; }
.signal-head .meta { font-size: 11px; }
.signal-note {
  margin-top: 10px; font-size: 12px; line-height: 1.5; color: var(--muted);
  background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px;
}
.signal-note.bad { color: var(--bad); border-color: rgba(255, 107, 107, .35); }
/* One line of "it happened" above the page, not an alert(): a modal would hide
   the plan the athlete just asked for. It times out on its own. */
.flash {
  margin: 0 0 12px; padding: 10px 12px; font-size: 13px; line-height: 1.5;
  color: var(--text); background: rgba(61, 220, 132, .12);
  border: 1px solid rgba(61, 220, 132, .35); border-radius: 12px;
}
.flash[hidden] { display: none; }
.flash.bad { background: rgba(255, 107, 107, .12); border-color: rgba(255, 107, 107, .35); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.grid2 label { font-size: 12px; color: var(--muted); display: grid; gap: 4px; }
.grid2 input, .grid2 select {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 9px 10px; font-size: 14px; width: 100%;
}
/* Which days he is free. Seven taps rather than a dropdown: the answer is a set,
   and a set is what the plan is built from. */
.day-pick { margin: 4px 0 12px; }
.day-pick-label {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
  font-size: 12px; color: var(--muted); margin-bottom: 7px;
}
.day-pick-label span { font-size: 11px; opacity: .7; }
.day-chips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.day-chip {
  padding: 8px 0; border-radius: 9px; font-size: 12px; font-weight: 500;
  background: var(--card-2); border: 1px solid var(--line); color: var(--muted);
}
.day-chip.on {
  color: var(--accent); border-color: rgba(61, 220, 132, .45);
  background: rgba(61, 220, 132, .1);
}
.log { margin-top: 14px; font-size: 12px; color: var(--muted); }
.log div { padding: 3px 0; }
.log .log-sep { margin-top: 12px; color: var(--text); opacity: .65; }
.log .bad-text { color: var(--bad); }

/* --- the gate --- */
/* One screen, one job: say who you are. It covers the console instead of being a
   separate page so that a refresh after login lands straight on the dashboard
   without a second round trip. */
.gate {
  position: fixed; inset: 0; z-index: 60; display: flex;
  align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(120% 90% at 50% 0%, #16202b 0%, var(--bg) 60%);
  overflow-y: auto;
}
.gate[hidden] { display: none; }
.gate-card {
  width: 100%; max-width: 420px; padding: 22px 20px 18px;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
}
.gate-brand {
  font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px;
}
.gate-foot { margin-top: 14px; font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.gate-icp { margin-top: 10px; font-size: 11px; color: var(--muted); text-align: center; }

/* --- ICP 备案号 --- */
/* 备案要求它在页面上可见，不要求它好看：最小的字号、最淡的颜色、贴到 tabbar 上方
   的安全区里。没配 PANDARUN_ICP 时 app.js 直接把整行 hidden，不占位。 */
.icp {
  padding: 18px 16px calc(10px + env(safe-area-inset-bottom));
  font-size: 11px; line-height: 1.6; color: var(--muted); text-align: center;
}
.icp[hidden] { display: none; }
.icp a, .gate-icp a { color: inherit; text-decoration: none; }

/* --- account row in the profile sheet --- */
.account-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card-2);
}
.account-row .who { display: grid; gap: 2px; font-size: 14px; }
.account-row .who span { font-size: 11.5px; color: var(--muted); }
.account-row .row { margin: 0; }
.account-row .btn { flex: 0 0 auto; padding: 8px 12px; font-size: 13px; }

.user-row {
  display: grid; gap: 2px; padding: 11px 12px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card-2);
}
.user-row .top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.user-row .name { font-size: 14px; }
.user-row .tag { font-size: 11px; color: var(--muted); }
.user-row .tag.admin { color: var(--accent); }
.user-row .tag.off { color: var(--warn); }
.user-row .actions { display: flex; gap: 6px; margin-top: 8px; }
.user-row .actions .btn { padding: 7px 10px; font-size: 12px; }
.user-row .actions .btn.danger { color: var(--bad); border-color: rgba(255, 107, 107, .35); }

/* --- tabbar --- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  max-width: 720px; margin: 0 auto;
  padding: 8px 8px var(--tab-bottom);
  background: rgba(15, 20, 27, .92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  background: none; border: 0; color: var(--muted); font-size: 12px;
  padding: 8px 0; cursor: pointer; border-radius: 10px;
}
.tabbar button.active { color: var(--text); background: var(--card-2); }

/* --- views --- */
.only-data { display: none; }
.view-data .only-data { display: block; }
/* The data tab is the log and the tools. The week grid, the readiness ring and
   the load chart are the dashboard — showing the same card twice made the tab
   look like a second copy of the home page rather than a different place. */
.view-data #heroCard,
.view-data #todayCard,
.view-data #weekCard,
.view-data #abilityCard,
.view-data #loadCard { display: none; }

/* --- chat panel --- */
.panel {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column;
  background: var(--bg); max-width: 720px; margin: 0 auto;
}
.panel[hidden] { display: none; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 16px; }
.messages { flex: 1; overflow-y: auto; padding: 14px 16px; display: grid; gap: 10px; align-content: start; }
.msg { max-width: 86%; padding: 10px 12px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; }
.msg.user { justify-self: end; background: var(--accent); color: #06210f; }
.msg.assistant { justify-self: start; background: var(--card); border: 1px solid var(--line); }
.msg.system { justify-self: center; background: transparent; color: var(--muted); font-size: 12px; }
/* A failed turn is an error, not a status note: give it a colour so it is not
   skimmed past like the "还没有对话" hint. */
.msg.error { justify-self: stretch; background: rgba(255, 107, 107, .1); border: 1px solid rgba(255, 107, 107, .35); color: var(--bad); font-size: 12px; }
/* A photo is taller than a line of text, so it gets a ceiling and rounded
   corners; the caption, if any, sits under it inside the same bubble. */
.msg-img { display: block; max-width: 100%; max-height: 240px; border-radius: 10px; }
.msg-img + span { display: block; margin-top: 6px; }
/* Date separators in the restored transcript: "今天" / "昨天" / "10 月 28 日". */
.msg-day { justify-self: center; padding: 2px 0; font-size: 11px; color: var(--muted); letter-spacing: .3px; }

/* A notice the engine wrote by itself. Full width and tinted so it cannot be
   mistaken for something the coach said after being asked. */
.msg.adjust {
  justify-self: stretch; max-width: 100%;
  background: rgba(61, 220, 132, .07);
  border: 1px solid rgba(61, 220, 132, .26);
  font-size: 13px; line-height: 1.55;
}
.msg-tag {
  display: inline-block; margin-bottom: 5px; padding: 1px 6px; border-radius: 4px;
  background: rgba(61, 220, 132, .16); color: var(--accent);
  font-size: 10.5px; letter-spacing: .4px;
}
/* The record of a change the athlete asked for, tinted blue so the transcript
   keeps straight who decided what: green is the engine, blue is him. */
.msg.edit {
  justify-self: stretch; max-width: 100%;
  background: rgba(53, 167, 255, .07);
  border: 1px solid rgba(53, 167, 255, .26);
  font-size: 13px; line-height: 1.55;
}
.msg.edit .msg-tag { background: rgba(53, 167, 255, .16); color: #35a7ff; }
/* A change waiting for a tap. Stretched like a notice because it is a form: read
   three lines, press once — and nothing is written until that press. */
.msg.ec-card {
  justify-self: stretch; max-width: 100%;
  background: var(--card-2); border: 1px solid rgba(53, 167, 255, .3);
  font-size: 13px; line-height: 1.5;
}
.msg.ec-card.done { border-color: var(--line); }
.msg.ec-card .msg-tag { background: rgba(53, 167, 255, .16); color: #35a7ff; }
.ec-sum { margin-bottom: 6px; }
.ec-list { margin: 0; padding: 0; list-style: none; }
.ec-list li { padding: 6px 0; border-top: 1px dashed var(--line); }
.ec-list li:first-child { border-top: 0; }
.ec-was { color: var(--muted); }
.ec-now { font-weight: 600; }
.ec-why { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); }
/* The session line is the target; the sentence under it is the point. */
.ec-day { font-size: 11.5px; color: var(--muted); }
.ec-advice { margin-top: 3px; line-height: 1.6; }
.ec-no { margin-top: 4px; font-size: 12px; color: var(--warn); }
.ec-err { margin-top: 6px; font-size: 12px; color: var(--bad); }
.ec-note { margin-top: 4px; font-size: 12px; color: var(--muted); }
.ec-actions { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.ec-actions .btn { flex: 0 0 auto; padding: 8px 16px; font-size: 13px; border-radius: 10px; }
.ec-actions .link { margin: 0; }
.warn {
  margin: 0 16px 8px; padding: 8px 10px; border-radius: 10px;
  background: rgba(255, 176, 32, .12); color: var(--warn); font-size: 12px;
}
/* The attachment strip sits between the transcript and the composer and only
   exists while a photo is pending; hiding it must not leave a doubled rule. */
.attach {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-top: 1px solid var(--line); background: var(--card);
}
.attach[hidden] { display: none; }
.attach:not([hidden]) + .composer { border-top-color: transparent; }
.attach img {
  width: 54px; height: 54px; flex: 0 0 auto; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card-2);
}
.attach .ghost { width: 28px; height: 28px; font-size: 13px; }
/* "4.1 MB → 190 KB": the compression is invisible unless it is printed. */
.attach-meta {
  flex: 1 1 auto; min-width: 0; margin-right: 2px;
  font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
}

.composer {
  display: flex; gap: 8px;
  padding: 10px 12px max(calc(10px + var(--safe-bottom)), 18px);
  border-top: 1px solid var(--line); background: var(--card);
}
/* Same reason as the tabbar: on a phone with no reported inset, 10px of padding
   under the send button is inside the gesture zone. */
.composer .pic {
  flex: 0 0 auto; align-self: flex-end; margin-bottom: 3px;
  width: 38px; height: 38px; display: grid; place-items: center;
}
.composer .pic[disabled] { opacity: .45; }
.composer textarea {
  flex: 1; resize: none; background: var(--card-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 14px; max-height: 120px;
}
.composer .btn { flex: 0 0 72px; }

/* --- detail sheet --- */
/* A phone puts the back affordance top-left and a title bar above the content,
   so the sheet is a panel with a sticky nav, not a card with a floating ✕ on the
   far side from where the thumb already is. */
.sheet {
  position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet[hidden] { display: none; }
.sheet-panel {
  background: var(--card); width: 100%; max-width: 720px;
  border-radius: 20px 20px 0 0; max-height: 82vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.sheet-nav {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-bottom: 1px solid var(--line); min-height: 48px;
}
/* 44 px is the smallest target Apple's guidelines allow to hit reliably with a
   thumb; 38 was only comfortable with a mouse. */
.nav-back {
  width: 44px; height: 44px; flex: 0 0 auto; cursor: pointer;
  background: transparent; border: 0; color: var(--text);
  font-size: 30px; line-height: 1; border-radius: 10px;
  display: grid; place-items: center; padding: 0 0 3px;
}
.nav-back:active { background: var(--card-2); }
.nav-title { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.sheet-body {
  flex: 1 1 auto; overflow-y: auto;
  padding: 16px 16px calc(24px + var(--safe-bottom));
}

.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.detail-head { margin-top: 16px; font-size: 12px; color: var(--muted); letter-spacing: .3px; }

.zone-row { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.zone-row .zn { width: 100px; flex: 0 0 auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.zone-row .zn i { font-style: normal; opacity: .75; margin-left: 5px; }
/* "Z4 乳酸阈 167-178": the range is the part he reads on the watch, so it rides
   in the label column rather than behind a tap. */
.zone-row .zn b { font-weight: 400; font-size: 10px; margin-left: 4px; opacity: .85; font-variant-numeric: tabular-nums; }
.zone-track { flex: 1; height: 6px; background: var(--card-2); border-radius: 3px; overflow: hidden; }
.zone-track i { display: block; height: 100%; border-radius: 3px; }
.zone-track .z1 { background: #47617c; }
.zone-track .z2 { background: var(--accent-2); }
.zone-track .z3 { background: var(--accent); }
.zone-track .z4 { background: var(--warn); }
.zone-track .z5 { background: var(--bad); }
.zone-row .zt { width: 52px; flex: 0 0 auto; text-align: right; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.splits { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; margin-top: 10px; }
.splits div { background: var(--card-2); border-radius: 8px; padding: 6px; text-align: center; font-size: 12px; }
.splits span { display: block; color: var(--muted); font-size: 10px; }

/* --- full-screen review --------------------------------------------------- */
/* A debrief is longer than a phone sheet can hold: four sections plus a comment.
   The same element grows to a page instead of stacking another scroll area. */
.sheet.full { background: var(--bg); }
.sheet.full .sheet-panel {
  height: 100%; max-height: 100vh; border-radius: 0;
  padding-top: env(safe-area-inset-top, 0px);
}

.rv-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
/* The title never shrinks. Flex used to squeeze a 24px Chinese heading into a
   two-character column ("先认识 / 你") whenever the subtitle beside it was long;
   with wrap on, the subtitle drops to its own line instead. */
.rv-title { flex: 0 0 auto; font-size: 24px; font-weight: 600; letter-spacing: -.3px; }
.rv-sub { flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: 12.5px; }
.rv-section { margin-top: 22px; }
.rv-section h3 {
  margin: 0 0 8px; font-size: 11.5px; font-weight: 500;
  color: var(--muted); letter-spacing: .6px;
}
.rv-card { background: var(--card-2); border-radius: 12px; padding: 12px; }
.rv-note { font-size: 13.5px; line-height: 1.6; }
.rv-meta { margin-top: 8px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rv-comment {
  background: var(--card-2); border-radius: 12px; padding: 14px;
  font-size: 14px; line-height: 1.7; border-left: 2px solid var(--accent);
}
.rv-comment.dim { color: var(--muted); border-left-color: var(--line); }
/* The coach's note: blue rather than green, because it is not the plan. The left
   rule is what stops it from reading as another prescription line. */
.adv-card { border-left: 2px solid #35a7ff; }
.adv-text { font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; }
.adv-line {
  margin-top: 10px; padding: 8px 10px; border-radius: 10px;
  background: rgba(53, 167, 255, .08); border-left: 2px solid #35a7ff;
  font-size: 12.5px; line-height: 1.55;
}
/* The illness grade: three chips above the number fields, because it is the only
   entry on this form that is not a measurement. Selected state mirrors .tr-chip
   so the two chip rows on the app do not look like different widgets. */
.sig-chips { display: flex; gap: 6px; margin-bottom: 10px; }
.sig-chips button {
  flex: 1 1 0; min-width: 0; padding: 7px 2px; border-radius: 9px;
  border: 1px solid var(--line); background: none; color: var(--muted);
  font-size: 12px; cursor: pointer;
}
.sig-chips button.on {
  border-color: var(--accent-2); background: rgba(255, 176, 32, .1);
  color: var(--text); font-weight: 600;
}
.sig-chips button[data-illness="2"].on {
  border-color: var(--bad); background: rgba(255, 107, 107, .1); color: var(--bad);
}
.link {
  margin-top: 8px; background: none; border: 0; padding: 4px 0;
  color: var(--muted); font-size: 12px; text-decoration: underline; cursor: pointer;
}

/* ---------- the race ---------- */

/* The hero has one door on it: the race pack before the gun, the result after.
   Muted rather than accent-coloured, because on a normal Tuesday it is not
   there at all and the readiness ring should stay the loudest thing. */
.race-cta {
  display: block; margin-top: 10px; padding: 0;
  background: none; border: 0; font: inherit; font-size: 12.5px;
  color: var(--accent-2); cursor: pointer;
}
.race-cta[hidden] { display: none; }
.race-cta:active { opacity: .6; }

.race-count { margin-top: 6px; font-size: 12px; color: var(--muted); }
.race-goal strong { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.race-goal span { margin-left: 10px; font-size: 12.5px; color: var(--muted); }

.race-seg, .race-split, .race-tl {
  display: grid; gap: 8px; padding: 7px 0;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.race-seg { grid-template-columns: 92px 58px 1fr; }
.race-split { grid-template-columns: 62px 1fr 1fr 58px; font-variant-numeric: tabular-nums; }
.race-tl { grid-template-columns: 66px 1fr; }
/* The last row of a card would otherwise draw a line under empty space. */
.race-seg:last-child, .race-split:last-child, .race-tl:last-child {
  border-bottom: 0; padding-bottom: 0;
}
.race-seg .rs-pace { font-weight: 600; font-variant-numeric: tabular-nums; }
.race-seg .rs-note, .race-tl .rt-text { color: var(--muted); font-size: 12.5px; }
.race-tl .rt-at {
  color: var(--muted); font-size: 11.5px;
  font-variant-numeric: tabular-nums; letter-spacing: .2px;
}
.race-split.head { color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
/* The pack table is three columns, and the pace is as wide as the number needs:
   a second ``1fr`` left half the card empty between 24:05 and 4:49. */
.race-splits.pack .race-split { grid-template-columns: 62px 1fr max-content; }
.race-split.final { font-weight: 600; }
.race-split .slow { color: var(--bad); }
.race-split .fast { color: var(--accent); }

.race-gear { display: flex; flex-wrap: wrap; gap: 6px; }
.race-chip {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; font-size: 12px; color: var(--muted);
}
.race-tips {
  margin: 0; padding-left: 18px;
  font-size: 12.5px; line-height: 1.75; color: var(--muted);
}

.rr-main { display: flex; align-items: baseline; gap: 10px; }
.rr-main strong { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rr-main span { color: var(--muted); font-size: 12.5px; }
.race-badge {
  display: inline-block; margin-top: 8px; padding: 5px 10px; border-radius: 999px;
  background: rgba(61, 220, 132, .13); color: var(--accent); font-size: 12px;
}

.race-form { display: flex; align-items: flex-end; gap: 8px; margin-top: 14px; }
.race-form label {
  flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--muted);
}
/* 16 px: anything smaller makes iOS zoom the whole page when the field takes
   focus, and the sheet does not zoom back out. */
.race-form input {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font: inherit; font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.race-form .btn { flex: 0 0 auto; }
/* The error sits inside the card, under the button he just pressed; the hero's
   own note line is a different element with a different job. */
.race-err { color: var(--bad); }

/* Three fields stacked: on a 340 px card a row of three inputs is 100 px each,
   and "跑了多少公里" does not fit in 100 px. A grid keeps the labels aligned and
   the button full width, which is the thumb's target. */
.ck-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px;
}
.ck-form label {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  font-size: 12px; color: var(--muted);
}
.ck-form label:first-child { grid-column: 1 / -1; }
/* width + min-width, both: an input's default size (20 characters) is its
   intrinsic minimum, and a 1fr grid column will not shrink below it — the form
   overflowed a 390 px phone by 50 px with the button hanging off the screen. */
.ck-form input {
  width: 100%; min-width: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font: inherit; font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.ck-form .btn { grid-column: 1 / -1; }

/* Ten targets on one row. 340 px / 10 is 34 px per chip before the gaps, so the
   chips are 30 px wide with a 4 px gap: small, but the whole run of them is one
   swipe away from the thumb and a wrong tap is one tap to undo. */
.rpe-row { display: flex; gap: 4px; margin-top: 4px; }
.rpe {
  flex: 1 1 0; min-width: 0; padding: 9px 0; border-radius: 9px;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--line);
  font: inherit; font-size: 14px; font-variant-numeric: tabular-nums; cursor: pointer;
}
/* Colour, weight and border all move together: a chip that is only slightly
   brighter is not a selection on a phone at arm's length. */
.rpe.on {
  background: var(--accent); color: #06210f; border-color: transparent; font-weight: 700;
}
.rpe:active { transform: scale(.96); }

/* The chart is stretched to the card width, so the pace figure is positioned in
   percent over it instead of drawn as SVG text (which would be squashed by
   preserveAspectRatio="none"). */
.lap-line-wrap { position: relative; margin-top: 8px; }
/* pan-y rather than none: the chart claims horizontal swipes for the selection
   and leaves vertical swipes to the page, so dragging past it still scrolls the
   review instead of trapping the finger. */
.lap-line { display: block; width: 100%; height: 104px; touch-action: pan-y; cursor: pointer; }
.lap-line .area { fill: url(#lapFill); }
.lap-line .line {
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-linejoin: round; stroke-linecap: round;
}
.lap-line circle { fill: var(--card-2); stroke: var(--accent); stroke-width: 2; }
/* The drop line from the selected point to the baseline, so the finger and the
   number are obviously talking about the same kilometre. */
.lap-line .guide { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: .55; }
.lap-line .pick { fill: var(--text); stroke: var(--accent); stroke-width: 2; }
.lap-line .pick.fast { fill: var(--warn); stroke: var(--bg); }

/* The heart rate chart is the pace chart with a different colour and a shorter
   box: same columns, same guide line, one less thing to learn. Its points take
   the zone colour the table below already uses, so "this kilometre went amber"
   reads the same way in both places. */
.lap-line.hr { height: 88px; }
.lap-line.hr .area { fill: url(#hrFill); }
.lap-line.hr .line { stroke: var(--bad); }
.lap-line.hr .guide { stroke: var(--bad); }
.lap-line.hr .pick { stroke: var(--bad); }
.lap-line.hr .pick.peak { fill: var(--bad); stroke: var(--bg); }
.lap-line.hr circle { fill: var(--card-2); stroke: var(--muted); stroke-width: 1.6; }
.lap-line.hr circle.z1 { stroke: #47617c; }
.lap-line.hr circle.z2 { stroke: var(--accent-2); }
.lap-line.hr circle.z3 { stroke: var(--accent); }
.lap-line.hr circle.z4 { stroke: var(--warn); }
.lap-line.hr circle.z5 { stroke: var(--bad); }
/* The pace chart's label is the card's own text colour; this one is red before
   it is anything else, so the two tags never look like the same reading. */
.hr-wrap .lap-tag { color: var(--bad); }
.hr-wrap .lap-tag.peak { color: #fff; }

/* The same pair at one-second resolution. There are no dots on these: four
   hundred of them is a hedge, not a reading. What replaces them is colour —
   every stretch of heart rate is filled with the colour of its own zone, so the
   shape of the effort is legible before anything is tapped, and ten minutes of
   amber reads as a hard day even where the pace never moved. */
.lap-line.fine { height: 116px; }
.lap-line.hr.fine { height: 96px; }
/* The kilometre crossings, ruled so a time axis does not lose the address the
   table below is still written in. */
.lap-line .kmrule { stroke: var(--line); stroke-width: 1; opacity: .8; }
/* Standing still is drawn as ground rather than as a hole: the line breaks
   because no pace exists there, and the band says he was there all along. */
.lap-line .rest { fill: var(--muted); opacity: .13; }
.lap-line.hr .zonefill { stroke: none; }
.lap-line.hr .zonefill.z1 { fill: #47617c; opacity: .16; }
.lap-line.hr .zonefill.z2 { fill: var(--accent-2); opacity: .16; }
.lap-line.hr .zonefill.z3 { fill: var(--accent); opacity: .18; }
.lap-line.hr .zonefill.z4 { fill: var(--warn); opacity: .22; }
.lap-line.hr .zonefill.z5 { fill: var(--bad); opacity: .28; }
/* A stopped moment has no pace to point at, so its marker falls to the baseline
   and takes the grey of the band it happened in. */
.lap-line .pick.idle { fill: var(--muted); stroke: var(--bg); }
.lap-tag.idle { color: var(--muted); }

/* One label, not twenty-one: it sits above the selected point and follows the
   finger. The halo in the card's own colour keeps it readable where the line
   runs straight through it. */
.lap-tag {
  position: absolute; transform: translate(-50%, calc(-100% - 6px));
  font-size: 12px; line-height: 1; color: var(--text); font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 3px var(--card-2), 0 0 6px var(--card-2), 0 0 9px var(--card-2);
}
.lap-tag.fast { color: var(--warn); }

/* The readout under the chart: whichever kilometre is selected, spelled out with
   the heart rate and cadence that the pace alone does not explain. */
.lap-read {
  margin: 6px 0 8px; min-height: 18px; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lap-read b { color: var(--text); font-weight: 600; }
.lap-read i { font-style: normal; margin: 0 6px; opacity: .5; }

/* --- per-kilometre table ------------------------------------------------ */
/* The line says how the pace moved; these rows say what it cost. Four columns,
   the way a watch prints them: which kilometre, the clock at the end of it, the
   pace, the heart. Cadence and climb are not repeated twenty-one times -- the
   readout above gives them for whichever row is selected. */
.lap-table { margin-top: 12px; }
.lap-row {
  display: grid; grid-template-columns: 22px 46px minmax(0, 1fr) 52px;
  align-items: center; gap: 7px; padding: 5px 4px; margin: 0 -4px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.lap-row:last-child { border-bottom: 0; }
/* The kilometre the chart is pointing at. */
.lap-row.sel { background: rgba(255, 255, 255, .045); border-radius: 6px; }
.lap-head {
  padding: 0 0 6px; color: var(--muted); font-size: 10.5px;
  letter-spacing: .3px; border-bottom-color: var(--line);
}
.lap-km { color: var(--muted); }
.lap-clock { color: var(--muted); }
.lap-pace { display: flex; align-items: center; gap: 7px; min-width: 0; }
/* The pace is a number in a column of numbers: fixed width, same left edge on
   every row, so "was kilometre 14 slower than 13" is answered by reading down
   without chasing digits that shifted along with a bar. The quote marks are the
   watch's own grammar -- 4'44" is a rate, 4:44 looks like a short time. */
.lap-num { flex: 0 0 auto; min-width: 3.7em; font-weight: 600; letter-spacing: .2px; }
.lap-num.fast { color: var(--warn); }
/* Longer bar = faster kilometre, on a track that shows what full would have
   been. The fill wears the heart-rate zone of that kilometre, because a 4:50
   that cost 141 and a 4:50 that cost 172 are not the same kilometre. */
.lap-track { flex: 1 1 auto; min-width: 0; height: 7px; border-radius: 4px;
  background: rgba(255, 255, 255, .07); overflow: hidden; }
.lap-bar { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.lap-bar.z1 { background: #47617c; }
.lap-bar.z2 { background: var(--accent-2); }
.lap-bar.z3 { background: var(--accent); }
.lap-bar.z4 { background: var(--warn); }
.lap-bar.z5 { background: var(--bad); }
.lap-hr { display: flex; align-items: center; gap: 5px; }
.lap-hr i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); flex: 0 0 auto; }
.lap-hr.z1 i { background: #47617c; }
.lap-hr.z2 i { background: var(--accent-2); }
.lap-hr.z3 i { background: var(--accent); }
.lap-hr.z4 i { background: var(--warn); }
.lap-hr.z5 i { background: var(--bad); }

/* The rebuilt warmup / work / recovery / cooldown. Four columns fit 390 px, and
   the work rows get the one accent the page saves for "this is the session" —
   the easy metres around them are context, not something being judged. */
.iv-table { margin-top: 12px; }
.iv-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 54px 54px;
  align-items: center; gap: 6px; padding: 6px 4px; margin: 0 -4px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.iv-row:last-child { border-bottom: 0; }
.iv-head {
  padding: 0 0 6px; color: var(--muted); font-size: 10.5px;
  letter-spacing: .3px; border-bottom-color: var(--line);
}
.iv-tag, .iv-p { color: var(--muted); }
.iv-work { background: rgba(255, 255, 255, .045); border-radius: 6px; }
.iv-work .iv-tag { color: var(--accent); font-weight: 600; }
.iv-work .iv-p { color: var(--text); font-weight: 600; }

/* --- the whole log ------------------------------------------------------ */
.card-head .link-btn {
  margin-left: auto; flex: 0 0 auto; cursor: pointer;
  background: transparent; border: 0; padding: 4px 0 4px 8px;
  color: var(--accent); font-size: 12.5px; font-family: inherit;
}
.card-head .link-btn:active { opacity: .6; }
.run-month {
  margin: 18px 0 2px; font-size: 11.5px; color: var(--muted); letter-spacing: .4px;
}
.run-month:first-child { margin-top: 0; }
.run-sum {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: var(--muted); padding-bottom: 10px;
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.list-more { padding: 16px 0 4px; text-align: center; font-size: 12px; color: var(--muted); }

/* --- the week ------------------------------------------------------------ */
/* Three numbers on one line: the week is a summary, and a summary that needs
   scrolling is a page, not a summary. */
.wk-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.wk-stat { padding: 10px 6px; border-radius: 10px; background: var(--bg); text-align: center; }
.wk-stat b {
  display: block; font-size: 19px; font-weight: 600; letter-spacing: -.3px;
  font-variant-numeric: tabular-nums;
}
.wk-stat span { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }

.wk-line {
  display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.wk-line:first-child { padding-top: 0; }
.wk-line:last-child { padding-bottom: 0; border-bottom: 0; }
.wk-line > span { font-size: 12px; color: var(--muted); }
.wk-line > b { font-weight: 500; }
.wk-dim { color: var(--muted); }

.wk-list { padding-top: 4px; padding-bottom: 4px; }
.wk-row {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px;
  align-items: baseline; padding: 9px 0;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.wk-row:last-child { border-bottom: 0; }
.wk-row .wd { font-size: 12px; color: var(--muted); }
.wk-row .tt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-row .tt i {
  margin-left: 6px; padding: 0 5px; border-radius: 4px;
  background: rgba(255, 176, 32, .14); color: var(--warn);
  font-style: normal; font-size: 11px;
}
.wk-row .vv { color: var(--muted); font-variant-numeric: tabular-nums; }
.wk-row.ok .vv { color: var(--text); }
.wk-row.miss .vv { color: var(--bad); }
.wk-row.soon { opacity: .72; }
.wk-row.today { margin: 0 -8px; padding: 9px 8px; border-radius: 8px; background: rgba(255, 255, 255, .045); }
.wk-row[data-act] { cursor: pointer; }
.wk-row[data-act]:active { opacity: .65; }
/* A day that was asked for and never recorded is the one row worth tapping: it
   opens the form that writes it in. */
.wk-row[data-miss] { cursor: pointer; }
.wk-row[data-miss]:active { opacity: .65; }

/* --- moving between weeks ------------------------------------------------ */
/* Sticky: which week this page is, and how to leave it, must not scroll away
   from the page they belong to. The negative margin lets the bar bleed to the
   panel edges while the body keeps its 16px padding. */
.wk-bar {
  position: sticky; top: 0; z-index: 3;
  margin: -16px -16px 14px; padding: 8px 16px 10px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
/* Sticky is measured against the body's content box, which sits 16px down
   because of its padding — so the bar has to claim those 16px back or the
   numbers scroll through the gap above it. */
.wk-bar { top: -16px; }
.wk-nav {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center; gap: 6px;
}
/* Ghost arrows: the page already has a circled ‹ in the header, and two of them
   stacked in the corner is a mis-tap waiting to happen. */
.wk-step {
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
  font-size: 21px; line-height: 1; cursor: pointer;
}
.wk-step:disabled { opacity: .22; cursor: default; }
.wk-step:active:not(:disabled) { background: var(--card-2); color: var(--text); }
.wk-mid { min-width: 0; text-align: center; }
.wk-mid b { display: block; font-size: 15px; font-weight: 600; }
.wk-mid span { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); }

.wk-strip {
  display: flex; gap: 6px; margin-top: 9px;
  overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
}
.wk-strip::-webkit-scrollbar { display: none; }
.wk-chip {
  flex: 0 0 auto; min-width: 58px; padding: 5px 9px 6px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--card-2); color: var(--muted);
  font: inherit; text-align: center; cursor: pointer; scroll-snap-align: center;
}
.wk-chip b { display: block; font-size: 11.5px; font-weight: 600; color: var(--text); }
.wk-chip span { display: block; margin-top: 1px; font-size: 10.5px; font-variant-numeric: tabular-nums; }
.wk-chip.on { border-color: var(--accent); background: rgba(61, 220, 132, .1); }
.wk-chip.now { box-shadow: inset 0 0 0 1px rgba(53, 167, 255, .45); }
.wk-chip.race b { color: var(--warn); }
/* Week numbers restart with every block, so two "第 1 周" chips are honest — a
   gap marks where one plan hands over to the next. */
.wk-chip.block { margin-left: 8px; }
.wk-chip:active { opacity: .7; }

/* --- trend ------------------------------------------------------------- */
/* The window chips are sticky for the same reason the week bar is: the page is
   long by design, and "8 周 / 16 周 / 32 周" is how you read it differently. */
.tr-bar {
  position: sticky; top: -16px; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: -16px -16px 12px; padding: 9px 16px 10px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.tr-chips { display: flex; gap: 6px; }
.tr-chip {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--card-2); color: var(--muted);
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.tr-chip.on { border-color: var(--accent); background: rgba(61, 220, 132, .1); color: var(--text); font-weight: 600; }
.tr-chip:active { opacity: .7; }
.tr-bar-meta { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* 专项密度: three numbers and a bar, above the charts because it answers the
   question they cannot — whether the long runs in this block contained the work
   the race needs. The bar is the split between the two kinds; grey is volume,
   green is the specific block. */
.tr-density {
  display: grid; gap: 7px; margin-bottom: 12px; padding: 11px 13px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card-2);
}
.tr-density-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tr-density-top b { font-size: 13px; font-weight: 600; }
.tr-density-top span { color: var(--muted); font-size: 11.5px; }
.tr-density-counts { font-size: 12.5px; color: var(--text); }
.tr-density-counts i { margin: 0 5px; font-style: normal; color: var(--muted); }
.tr-density-bar { display: flex; height: 5px; border-radius: 999px; overflow: hidden; background: var(--card); }
.tr-density-bar i { display: block; height: 100%; }
.tr-density-bar .base { background: rgba(255, 255, 255, .18); }
.tr-density-bar .mp { background: var(--accent); }
.tr-density-read { font-size: 11.5px; line-height: 1.6; color: var(--muted); }

/* A warning is a card, not a line of text: it has a title in the coach's voice
   and a sentence that says what to do about it, and it is the first thing on
   the page when there is one. */
.tr-flags { display: grid; gap: 8px; margin-bottom: 12px; }
.tr-flag {
  padding: 11px 13px; border-radius: 12px;
  border: 1px solid var(--line); border-left: 3px solid var(--muted);
  background: var(--card-2); font-size: 12.5px; line-height: 1.6; color: var(--muted);
}
.tr-flag b { display: block; margin-bottom: 3px; font-size: 13px; font-weight: 600; color: var(--text); }
.tr-flag.red { border-left-color: var(--bad); background: rgba(255, 107, 107, .07); }
.tr-flag.red b { color: var(--bad); }
.tr-flag.warn { border-left-color: var(--warn); background: rgba(255, 176, 32, .06); }
.tr-flag.warn b { color: var(--warn); }
.tr-flag.ok { border-left-color: var(--accent); }
.tr-flag.info { border-left-color: var(--accent-2); }
/* The calm ones sit under the charts and say so: three paragraphs of "all good"
   above the lines would bury the one that is not. */
.tr-flags.quiet { margin-top: 14px; margin-bottom: 0; }
.tr-flags.quiet .tr-flag { background: transparent; padding: 8px 13px; }

/* The trend page is a stack of cards like the dashboard, but the sheet panel
   behind it is the same grey as a card: twelve pixels between two identical
   colours reads as one block, not as white space. The panel goes dark for this
   page so the cards float the way they do on the home screen. */
#sheet[data-view="trend"] .sheet-panel { background: var(--bg); }

/* The cards live in the sheet body, which has no grid gap of its own — the
   dashboard's spacing comes from ``main``. Without this they stack into one grey
   block with no seam between two different charts. */
.tr-cards { display: grid; gap: 12px; }
.tr-card { padding-bottom: 10px; }
.tr-canvas { margin-top: 2px; }
.tr-svg { display: block; width: 100%; height: 96px; overflow: visible; }
/* Every path on these charts is a line, never an area. A series whose class had
   no rule above fell back to the SVG default — solid black fill — and drew a
   black polygon over the bars it was supposed to annotate. */
.tr-svg path { fill: none; }
.tr-svg .axis { stroke: var(--line); stroke-width: 1; }
.tr-svg .ctl { fill: none; stroke: var(--accent-2); stroke-width: 2; stroke-linejoin: round; }
.tr-svg .atl { fill: none; stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 3 3; stroke-linejoin: round; }
.tr-svg .acwr { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.tr-svg .pace { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.tr-svg .ef { fill: none; stroke: var(--accent-2); stroke-width: 2; stroke-linejoin: round; }
.tr-svg .vdot { fill: none; stroke: var(--warn); stroke-width: 2; stroke-linejoin: round; }
/* The safe band is a background, so it is drawn first and kept faint enough that
   a line crossing it still reads as the line. */
.tr-svg .band { fill: rgba(61, 220, 132, .1); }
.tr-svg .red { stroke: var(--bad); stroke-width: 1; stroke-dasharray: 4 4; opacity: .75; }
.tr-svg .bar { fill: var(--accent); opacity: .55; }
.tr-svg .bar.on { opacity: 1; }
/* The bar behind each bar is what the plan asked for: a light block, so the part
   sticking up above the green one is the week that came up short. It was an
   outline, which is not "浅色" by any reading of the axis note under it. */
.tr-svg .plan { fill: rgba(255, 255, 255, .13); stroke: none; }
.tr-svg .guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; }
.tr-svg .guide.off { opacity: 0; }
.tr-svg .pick { fill: var(--text); stroke: var(--accent); stroke-width: 2; pointer-events: none; }
.tr-svg .hit { cursor: pointer; }

.tr-read {
  min-height: 18px; margin-top: 8px;
  font-size: 12.5px; color: var(--text); font-variant-numeric: tabular-nums;
}
.tr-read b { font-weight: 600; margin-right: 8px; }
.tr-read i { font-style: normal; margin: 0 6px; color: var(--muted); }
.tr-axis {
  display: flex; justify-content: space-between; gap: 8px; margin-top: 4px;
  font-size: 11px; color: var(--muted);
}
.tr-axis span:nth-child(2) { text-align: center; opacity: .85; }
