:root {
  --bg: #f6f5f2; --surface: #ffffff; --ink: #1d1d1b; --muted: #6b6a66; --line: #e3e1db;
  --accent: #fc4c02; /* Strava orange, used only for Strava links/buttons */
  --good: #2f8f5b; --good-bg: #e5f3ea;
  --watch: #b7791f; --watch-bg: #fbf0dc;
  --alert: #c2412d; --alert-bg: #fbe5e1;
  --none: #6b6a66; --none-bg: #ecebe7;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --surface: #222220; --ink: #f1f0ec; --muted: #a3a19b; --line: #34332f;
    --good: #5fc48b; --good-bg: #1d3327; --watch: #e3aa4f; --watch-bg: #3a2e18;
    --alert: #ef7a66; --alert-bg: #3d221d; --none: #a3a19b; --none-bg: #2c2b28;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .3rem; }
.top { display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { font-weight: 700; text-decoration: none; }
.brand span { font-weight: 400; color: var(--muted); }
.navlink { color: var(--muted); font-size: .9rem; }
main { margin: 0 auto; padding: 24px 16px 48px; }
main.narrow { max-width: 560px; }
main.wide { max-width: 860px; }
.lede { font-size: 1.05rem; color: var(--muted); }
.small { font-size: .875rem; color: var(--muted); }
.facts { padding-left: 1.1rem; }
.facts li { margin: .35rem 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 18px 0; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input:not([type]), input[type=password], input[type=search] {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--bg); color: var(--ink); margin-bottom: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 6px 0 18px; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.btn { appearance: none; border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--alert); border-color: var(--alert); }
.small-btn { padding: 6px 12px; font-size: .875rem; }
.strava-btn { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; }
.strava-btn img { display: block; height: 48px; }
.error { color: var(--alert); background: var(--alert-bg); padding: 10px 12px; border-radius: 8px; }
.foot { display: flex; gap: 16px; justify-content: center; align-items: center;
  padding: 20px 16px 32px; font-size: .85rem; color: var(--muted); }
.pwrd { height: 22px; }
code { font-size: .9em; }

/* dashboard */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.chip b { margin-left: 4px; }
.chip.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.chip.good b { color: var(--good); } .chip.watch b { color: var(--watch); }
.chip.alert b { color: var(--alert); } .chip.none b { color: var(--none); }
.athletes { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.athlete { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--none);
  border-radius: var(--radius); overflow: hidden; }
.athlete.good { border-left-color: var(--good); } .athlete.watch { border-left-color: var(--watch); }
.athlete.alert { border-left-color: var(--alert); }
summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; }
.avatar.ph { display: grid; place-items: center; background: var(--none-bg); color: var(--muted); font-weight: 700; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.name { font-weight: 650; }
.lastline { font-size: .875rem; color: var(--muted); }
.gap { text-align: right; min-width: 52px; line-height: 1.1; }
.gap b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.gap small { color: var(--muted); font-size: .75rem; }
.good .gap b { color: var(--good); } .watch .gap b { color: var(--watch); }
.alert .gap b { color: var(--alert); } .none .gap b { color: var(--none); }
.detail { padding: 4px 14px 16px; border-top: 1px solid var(--line); }
.lastcard { padding: 12px 0 4px; }
.lc-title { font-weight: 600; margin-bottom: 8px; }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--watch-bg); color: var(--watch); margin-left: 6px; vertical-align: 2px; }
.tag.muted { background: var(--none-bg); color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 0 0 10px; }
.stats div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.stats dt { font-size: .75rem; color: var(--muted); }
.stats dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.strava-link { color: var(--accent); font-weight: 600; font-size: .9rem; }
.weekline { font-size: .9rem; margin: 12px 0 6px; }
.runs { width: 100%; border-collapse: collapse; font-size: .85rem; }
.runs th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 6px 4px; }
.runs td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.runs a { text-decoration: none; }
.runs .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.empty p { margin: .3rem 0; }
@media (max-width: 520px) {
  .runs th:nth-child(4), .runs td:nth-child(4) { display: none; }
}

/* minimum-distance goal */
.goal-pill { align-self: flex-start; margin-top: 4px; font-size: .75rem; font-weight: 650;
  padding: 2px 8px; border-radius: 999px; }
.goal-pill.under { background: var(--alert-bg); color: var(--alert); }
.goal-pill.met { background: var(--good-bg); color: var(--good); }
.chip.under b { color: var(--alert); }
.stats .d-under { background: var(--alert-bg); } .stats .d-under dd { color: var(--alert); }
.stats .d-met { background: var(--good-bg); } .stats .d-met dd { color: var(--good); }
.stats dd small { font-size: .8rem; font-weight: 600; }
.runs .m-under { color: var(--alert); font-weight: 650; }
.runs .m-met { color: var(--good); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.goalform { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.goalform label { font-size: .875rem; }
.goalrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.goalrow input { width: 96px; margin: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--bg); color: var(--ink); }
.goalrow .unit { color: var(--muted); margin-right: 4px; }
.hint { margin: 6px 0 0; }

/* coach nav */
.coachnav { display: flex; gap: 4px; align-items: center; font-size: .9rem; }
.coachnav a { text-decoration: none; padding: 6px 10px; border-radius: 8px; color: var(--muted); }
.coachnav a.on { color: var(--ink); background: var(--bg); font-weight: 600; }
.coachnav a.out { margin-left: 4px; }
@media (max-width: 420px) { .brand span { display: none; } }

/* week view */
.weeknav { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; margin-bottom: 14px; }
.weektitle { text-align: center; }
.weektitle h1 { margin: 0; }
.weektitle p { margin: 2px 0 0; }
.weeknav .btn { font-size: 1.3rem; line-height: 1; padding: 6px 14px; text-decoration: none; }
.notice { background: var(--good-bg); color: var(--good); padding: 10px 12px; border-radius: 8px; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 14px; }
.summary div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.summary b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.summary b small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.summary span { font-size: .8rem; color: var(--muted); line-height: 1.25; display: block; }
.summary .bad b { color: var(--alert); }
@media (max-width: 560px) { .summary { grid-template-columns: repeat(2, 1fr); } }
.bulk { margin-top: 0; }
.bulk label { font-size: .875rem; }

.wrow { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--none);
  border-radius: var(--radius); overflow: hidden; }
.wrow.met { border-left-color: var(--good); }
.wrow.under { border-left-color: var(--alert); }
.score { text-align: right; min-width: 52px; line-height: 1.1; }
.score b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.score small { color: var(--muted); font-size: .75rem; }
.wrow.met .score b { color: var(--good); }
.wrow.under .score b { color: var(--alert); }
.dots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--none-bg); border: 2px solid var(--muted); }
.dot.met { background: var(--good); border-color: var(--good); }
.dot.under { background: var(--alert-bg); border-color: var(--alert); }
.goalline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 14px 12px;
  border-top: 1px dashed var(--line); font-size: .875rem; }
.goalline label { margin: 0; font-weight: 600; }
.goalline input { width: 84px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--bg); color: var(--ink); }
.goalline .unit { color: var(--muted); }
.carried { color: var(--muted); }
.carried.set { color: var(--ink); }
.savebar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 12px;
  padding: 12px 0; margin-top: 8px; background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
.savebar #dirty { color: var(--watch); font-weight: 600; }

/* history */
.bar { display: block; height: 6px; border-radius: 3px; background: var(--none-bg); margin-top: 6px; max-width: 280px; }
.bar span { display: block; height: 100%; border-radius: 3px; background: var(--muted); }
.wrow.met .bar span { background: var(--good); }
.wrow.under .bar span { background: var(--alert); }
a.chip { text-decoration: none; }
