:root {
  --bg: #f4f2ee; --panel: #ffffff; --ink: #1d2126; --muted: #69707a; --line: #e2ded6;
  --accent: #d2491f; --accent-ink: #ffffff; --ok: #2f7d4f; --warn: #b7791f; --err: #b3261e;
  --bike: #2a6fdb; --run: #d2491f; --ski: #0f8a8a; --strength: #7b4fc2; --swim: #1f8fc4; --other: #8a8f98;
  --base: #9bb7d4; --build: #2a6fdb; --peak: #d2491f; --taper: #c99a1d; --recov: #2f7d4f;
  --la: #d2491f; --gly: #2f7d4f; --ext: #9aa3ae; --fat: #c99a1d; --cho: #2a6fdb;
  --radius: 10px; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15181c; --panel: #1d2126; --ink: #e9e6e0; --muted: #9aa1aa; --line: #2d333a;
          --ext: #5d6670; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: inherit; }
header.top { display: flex; align-items: center; gap: 28px; padding: 0 24px; height: 56px;
             background: var(--ink); color: var(--bg); position: sticky; top: 0; z-index: 5; }
header.top .brand { font-weight: 700; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; }
header.top .brand .mark { width: 22px; height: 19px; display: block; }   /* logo: the rising lactate curve (static/icon.svg) */
header.top .brand .mark path { fill: none; stroke: var(--accent); stroke-width: 17; stroke-linecap: round; }
header.top .brand .mark circle { fill: currentColor; }
header.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
header.top nav a { text-decoration: none; padding: 6px 12px; border-radius: 6px; opacity: .75; white-space: nowrap; }
header.top nav a.on, header.top nav a:hover { opacity: 1; background: rgba(255,255,255,.1); }
/* medium-wide screens: nine entries must fit without scrolling the bar */
@media (max-width: 1500px) and (min-width: 701px) {
  header.top { gap: 14px; padding: 0 16px; }
  header.top nav { gap: 0; }
  header.top nav a { padding: 6px 7px; font-size: 14px; }
}
@media (max-width: 1180px) and (min-width: 701px) {
  header.top .brand { font-size: 0; gap: 0; }                                     /* logo only */
  header.top nav a { padding: 6px 5px; font-size: 13px; }
  header.top .who { gap: 6px; }
}
@media (prefers-color-scheme: dark) { header.top { background: #0d0f12; color: var(--ink); } }
header.top form button { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.3); }
header.top .who { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
header.top .who a { color: inherit; text-decoration: none; opacity: .85; }
footer.foot { max-width: 1240px; margin: 0 auto; padding: 0 24px 24px; }
.narrow { max-width: 460px; margin: 40px auto; }
main { max-width: 1240px; margin: 0 auto; padding: 24px; }
h1 { font-size: 26px; margin: 4px 0 18px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } main { padding: 16px; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card.tight { padding: 12px 14px; }
.stat .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat .s { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
       background: var(--line); color: var(--ink); text-transform: uppercase; letter-spacing: .04em; }
.tag.cycling { background: var(--bike); color: #fff; } .tag.running { background: var(--run); color: #fff; }
.tag.xcski { background: var(--ski); color: #fff; } .tag.strength { background: var(--strength); color: #fff; }
.tag.swimming { background: var(--swim); color: #fff; }
.tag.ok { background: var(--ok); color: #fff; } .tag.warn { background: var(--warn); color: #fff; }
.tag.err { background: var(--err); color: #fff; } .tag.indoor { background: #444; color: #fff; }
.bar { border-left: 4px solid var(--other); }
.bar.cycling { border-color: var(--bike); } .bar.running { border-color: var(--run); }
.bar.xcski { border-color: var(--ski); } .bar.strength { border-color: var(--strength); } .bar.swimming { border-color: var(--swim); }
button, .btn { font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line);
               background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--err); }
button:hover, .btn:hover { filter: brightness(.96); }
input, select, textarea { font: inherit; font-size: 14px; padding: 7px 9px; border-radius: 7px; border: 1px solid var(--line);
                          background: var(--bg); color: var(--ink); width: 100%; }
textarea { font-family: var(--mono); font-size: 12px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .05em; }
label.inline { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); }
label.inline input { width: auto; }
form.inline { display: flex; align-items: center; gap: 8px; margin: 0; }
form.inline input { width: auto; min-width: 0; flex: 1; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* plan form: only the fields of the chosen plan type (new plan: the select, edit: data-kind) and sport - CSS only,
   so it also works without JavaScript; browsers without :has() show every field and the server ignores the rest */
.planform:has([name=kind] [value=race]:checked) [data-kinds]:not([data-kinds~=race]),
.planform:has([name=kind] [value=time_goal]:checked) [data-kinds]:not([data-kinds~=time_goal]),
.planform:has([name=kind] [value=metabolic]:checked) [data-kinds]:not([data-kinds~=metabolic]),
.planform:has([name=kind] [value=fitness]:checked) [data-kinds]:not([data-kinds~=fitness]),
.planform[data-kind=race] [data-kinds]:not([data-kinds~=race]),
.planform[data-kind=time_goal] [data-kinds]:not([data-kinds~=time_goal]),
.planform[data-kind=metabolic] [data-kinds]:not([data-kinds~=metabolic]),
.planform[data-kind=fitness] [data-kinds]:not([data-kinds~=fitness]),
.planform:not(:has([name=sport] [value=running]:checked)) .run,
.planform:not(:has([name=sport] [value=cycling]:checked)) .ride,
.planform:not(:has([name=sport] [value=xcski]:checked)) .ski,
.planform:has([name=sport] [value=xcski]:checked) .course { display: none; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: #e6f2ea; color: #1f5a37; border: 1px solid #b9dcc6; }
.flash.err { background: #fbe9e7; color: #8a1f17; border-color: #f0c2bc; }
@media (prefers-color-scheme: dark) { .flash { background: #183323; color: #bfe5cd; border-color: #24543a; }
  .flash.err { background: #3a1916; color: #f6c9c3; border-color: #6a2a24; } }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 960px) { .week { grid-template-columns: 1fr; } }
.day { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 160px; }
.day.today { outline: 2px solid var(--accent); }
.day .dh { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.day .dh b { font-size: 13px; }
.wo { display: block; text-decoration: none; padding: 8px 10px; margin-bottom: 8px; border-radius: 7px; background: var(--bg); }
.wo .n { font-weight: 600; font-size: 13px; line-height: 1.3; }
.wo .m { font-size: 12px; color: var(--muted); margin-top: 3px; }
.chart { width: 100%; height: 240px; position: relative; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12px;
              padding: 4px 8px; border-radius: 5px; white-space: nowrap; display: none; z-index: 2; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; vertical-align: middle; margin-right: 5px; border-radius: 2px; }
.steps td { font-size: 14px; }
.steps tr.rep td { background: var(--bg); font-weight: 600; }
.steps tr.inrep td:first-child { padding-left: 24px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.kv2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 20px; align-items: start; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

.phase { display:inline-block; font-size:11px; font-weight:600; padding:2px 8px; border-radius:99px; color:#fff; text-transform:uppercase; letter-spacing:.04em; }
.phase.base { background: var(--base); color: #1d2126; } .phase.build { background: var(--build); } .phase.peak { background: var(--peak); }
.phase.taper { background: var(--taper); } .phase.recovery { background: var(--recov); }
details.pweek { border-top: 1px solid var(--line); padding: 8px 0; }
details.pweek summary { display:flex; gap:10px; align-items:center; flex-wrap:wrap; color: var(--ink); font-size:14px; }
details.pweek table td { font-size: 13px; }
.checks { display:flex; gap:10px; flex-wrap:wrap; } .checks label { margin:0; }

/* ---- Phone layout (below 700 px only; desktop is unaffected) -------------------------------------------- */
nav.tabs, .sheet, .mobile-only { display: none; }
@media (max-width: 700px) {
  body { font-size: 16px; }
  header.top { height: auto; min-height: 52px; padding: env(safe-area-inset-top) 16px 0; gap: 8px 14px; flex-wrap: wrap; }
  header.top > * { min-height: 52px; display: flex; align-items: center; }
  .app header.top nav, .app header.top .who, header.top .wide { display: none; }
  .app header.top .brand { flex: 1; }
  main { padding: 16px; }
  footer.foot { padding: 0 16px calc(84px + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
  .mobile-only { display: block; }
  .card { padding: 14px; }
  .g2 > [style*="span"], .g3 > [style*="span"] { grid-column: auto !important; }

  nav.tabs { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
             background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  nav.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; min-height: 56px;
               text-decoration: none; font-size: 11px; color: var(--muted); -webkit-tap-highlight-color: transparent; }
  nav.tabs a.on { color: var(--accent); font-weight: 600; }
  nav.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .sheet:target { display: block; position: fixed; inset: 0; z-index: 20; }
  .sheet .scrim { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
  .sheet nav { position: absolute; left: 0; right: 0; bottom: 0; background: var(--panel); border-radius: 14px 14px 0 0;
               padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
  .sheet nav a { padding: 14px 4px; border-bottom: 1px solid var(--line); text-decoration: none; font-size: 16px; }
  .sheet nav a.on { color: var(--accent); font-weight: 600; }
  .sheet nav form { margin-top: 14px; } .sheet nav form button { width: 100%; }

  button, .btn { min-height: 44px; padding: 10px 16px; font-size: 15px; }
  header.top form button { min-height: 36px; padding: 6px 12px; }
  input, select, textarea { font-size: 16px; min-height: 44px; }        /* 16 px: iOS does not zoom into the field */
  textarea { font-size: 14px; }
  input[type=checkbox], input[type=radio] { min-height: 0; width: 22px; height: 22px; flex: none; }
  .row > * { flex-basis: 100%; }
  .actions > .btn, .actions > button, .actions > form { flex: 0 1 auto; }

  /* wide tables scroll inside their card instead of widening the page */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td.num { white-space: nowrap; }
  .kv { grid-template-columns: minmax(0, auto) 1fr; }
  .chart { height: 200px; }

  .day { min-height: 0; } .day:not(:has(.wo)) { padding: 8px 10px; }
  .wo { padding: 10px 12px; }
  .wo .n { font-size: 15px; } .wo .m { font-size: 13px; }

  .today-card .steps { width: 100%; display: table; }
  .today-card .steps td { padding: 5px 6px; font-size: 14px; }
}
.today-card { margin-bottom: 16px; }
.today-card .when { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.today-card h2 { font-size: 19px; margin: 2px 0 6px; }
.today-card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }

/* ---- messages and running jobs (bottom right; above the tab bar on phones) ------------------------------ */
.notices { position: fixed; right: 16px; bottom: 16px; z-index: 30; display: flex; flex-direction: column; gap: 8px;
           width: min(420px, calc(100vw - 32px)); pointer-events: none; }
#jobs { display: flex; flex-direction: column; gap: 8px; }
.toast, .job { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px;
               border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 14px; line-height: 1.35;
               box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.toast { animation: fade-out .4s ease 6s forwards; }
.job.done { animation: fade-out .4s ease 12s forwards; }
.toast.err, .job.err { background: var(--err); color: #fff; animation: none; }
.job > div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.job .small { opacity: .8; }
.job a { color: inherit; font-weight: 600; white-space: nowrap; }
.notices button.x { background: transparent; border: 0; color: inherit; font-size: 20px; line-height: 1; padding: 0 4px;
                    min-height: 0; margin-left: auto; }
.spin { width: 16px; height: 16px; flex: none; border: 2px solid currentColor; border-right-color: transparent;
        border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }
@media (max-width: 700px) {
  .notices { left: 16px; right: 16px; width: auto; bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* ---- line charts (uPlot): live legend, drag to zoom ------------------------------------------------------ */
.uplot { font-family: inherit; }
.uplot .u-legend { font-size: 12px; color: var(--muted); text-align: left; margin-top: 2px; display: block; overflow: visible; }
.uplot .u-legend th, .uplot .u-legend td { border: 0; padding: 1px 4px; font-size: 12px; text-transform: none;
                                           letter-spacing: 0; font-weight: 400; color: var(--muted); white-space: nowrap; }
.uplot .u-legend .u-value { color: var(--ink); font-variant-numeric: tabular-nums; }
/* uPlot colours the marker through its inline border (colour + solid / dashed): keep it, only make it a dash */
.uplot .u-legend .u-marker { width: 16px; height: 0; border-width: 3px 0 0 0 !important; border-radius: 0;
                             background: transparent !important; vertical-align: middle; margin-right: 2px; }
.uplot .u-legend .u-series:first-child .u-value { font-weight: 600; }
.uplot .u-select { background: rgba(127, 127, 127, .18); }
.chart:has(.uplot) { height: auto; }
.chart-hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
@media (hover: none) { .chart-hint { display: none; } }

/* ---- Metabolic Profile: sub-tabs, body data, parameter origins ------------------------------------------- */
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 18px; flex-wrap: wrap; }
.subtabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.subtabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
h2.section { margin: 22px 0 10px; }
.bodyrow { display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: end; margin-bottom: 10px; }
.bodyrow .src { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-bottom: 8px; }
/* Prehab & Strength: exercise cards with line figures (templates/prehab.html, workouts/figures.py) */
.exgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.excard { display: flex; flex-direction: column; gap: 2px; scroll-margin-top: 70px; }
.excard p, .excard ul { margin: 4px 0; }
.excard .cues { padding-left: 18px; }
.exhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.exhead h3 { margin: 4px 0; text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--ink); }
.star { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 4px; }
.star.on { color: var(--accent); }
.exfig { width: 100%; max-width: 320px; height: auto; display: block; margin: 0 auto 4px; color: var(--ink); }
.exfig .b { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.exfig .far { opacity: .45; }
.exfig .h { fill: none; stroke: currentColor; stroke-width: 2.4; }
.exfig .e { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linejoin: round; }
.exfig .e.w { stroke-width: 2; }
.exfig .e.d { stroke-dasharray: 3 2; }
.exfig .a { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* muscle map (workouts/anatomy.py): body outline muted, muscle groups, the trained ones in the accent colour */
.exvis { display: flex; align-items: center; gap: 6px; }
.exvis .exfig { flex: 1; min-width: 0; margin: 0 0 4px; }
.mmap { display: block; height: auto; }
.mmap.compact { width: 64px; flex: none; }
.mmap .sk { fill: var(--bg); stroke: var(--line); stroke-width: 1; }
.mmap .mu { fill: var(--line); stroke: var(--panel); stroke-width: .6; }
.mmap .mu.on { fill: var(--accent); }
.mmap a .mu { cursor: pointer; } .mmap a:hover .mu { fill: var(--muted); } .mmap a:hover .mu.on { fill: var(--accent); }
.mmap .ld { stroke: var(--muted); stroke-width: .5; fill: none; }
.mmap text { fill: var(--muted); font-size: 7.5px; } .mmap text.on { fill: var(--ink); font-weight: 700; }
.mmap .vw { font-size: 7px; text-transform: uppercase; letter-spacing: .08em; }
.mmap-card .mmap { width: 100%; max-width: 640px; margin: 0 auto; }
.mmap-card p { text-align: center; margin: 4px 0 0; }
/* page loading bar (static/app.js): appears only if loading takes longer than a moment */
html.nav-loading::before { content: ""; position: fixed; top: 0; left: 0; height: 3px; z-index: 100; background: var(--accent);
  width: 0; animation: nav-bar 12s cubic-bezier(.1, .7, .3, 1) .25s forwards; pointer-events: none; }
@keyframes nav-bar { from { width: 0; } 15% { width: 45%; } to { width: 92%; } }
@media (prefers-reduced-motion: reduce) { html.nav-loading::before { animation: none; width: 100%; opacity: .7; } }
/* Metabolic power lollipops (templates/_lollipop.html, web/gauges.py) */
.lolli { width: 100%; max-width: 560px; height: auto; display: block; }
.lolli .axis { stroke: var(--line); stroke-width: 1; }
.lolli .st { stroke: var(--line); stroke-width: 3; stroke-linecap: round; }
.lolli .dot { fill: var(--accent); stroke: var(--accent); stroke-width: 2; }
.lolli .dot.hollow { fill: var(--panel); }
.lolli .mlss .dot { fill: var(--la); stroke: var(--la); } .lolli .fatmax .dot { fill: var(--fat); stroke: var(--fat); }
.lolli .carbmax .dot { fill: var(--cho); stroke: var(--cho); }
.lolli text { fill: var(--ink); font-size: 11.5px; } .lolli .vl { font-weight: 600; } .lolli .vl.muted { fill: var(--muted); }
/* Metabolic Profile gauges (templates/_gauge.html, web/gauges.py) */
.gauges { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin: 6px 0 10px; }
.gauge { margin: 0; text-align: center; min-width: 0; }
.gauge svg { width: 100%; max-width: 210px; display: block; margin: 0 auto; }
.gauge path { fill: none; stroke-width: 9; }
.gauge .track { stroke: var(--line); }
.gauge .seg.ok { stroke: var(--ok); } .gauge .seg.warn { stroke: var(--warn); } .gauge .seg.err { stroke: var(--err); }
.gauge .marker { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.gauge .opt { fill: var(--ink); opacity: .75; }
.gauge text { fill: var(--ink); }
.gauge .v { font-size: 19px; font-weight: 700; } .gauge .v.ok { fill: var(--ok); } .gauge .v.warn { fill: var(--warn); }
.gauge .v.err { fill: var(--err); }
.gauge .u { font-size: 8.5px; fill: var(--muted); } .gauge .l { font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.gauge figcaption { margin-top: 2px; line-height: 1.35; }
.tag.origin { background: var(--line); color: var(--ink); }
.tag.origin.paper { background: var(--ok); color: #fff; } .tag.origin.literature { background: #4f7a5f; color: #fff; }
.tag.origin.calibrated { background: var(--bike); color: #fff; } .tag.origin.assumed { background: var(--warn); color: #fff; }
.tag.origin.estimated { background: var(--strength); color: #fff; } .tag.origin.measured { background: var(--ski); color: #fff; }
.origins { display: flex; flex-direction: column; gap: 6px; }
table.params td { vertical-align: top; }

/* ---- Dashboard: traffic-light status, legend, zones ------------------------------------------------------- */
.stat.lv { border-left: 4px solid var(--line); }
.stat.lv.ok { border-left-color: var(--ok); } .stat.lv.warn { border-left-color: var(--warn); } .stat.lv.err { border-left-color: var(--err); }
.stat .v .dot { margin-left: 8px; vertical-align: middle; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--line); margin-right: 6px; }
.lv.ok .dot, .dot.ok { background: var(--ok); } .lv.warn .dot, .dot.warn { background: var(--warn); } .lv.err .dot, .dot.err { background: var(--err); }
.stat .s b { color: var(--ink); font-weight: 600; }
.legend-box { margin-top: 8px; color: var(--muted); }
.legend-box summary { cursor: pointer; }
.legend-box ul { list-style: none; padding: 0; margin: 4px 0 0; } .legend-box li { margin: 2px 0; }
.legend-box .grid { margin-top: 8px; }
.zone-sport { min-width: 0; }
table.zones td.num { white-space: nowrap; }
table.zones td:first-child { border-left: 4px solid var(--line); white-space: nowrap; }
table.zones tr.z1 td:first-child { border-left-color: #8a8f98; } table.zones tr.z2 td:first-child { border-left-color: var(--ok); }
table.zones tr.z3 td:first-child { border-left-color: var(--warn); } table.zones tr.z4 td:first-child { border-left-color: var(--run); }
table.zones tr.z5 td:first-child { border-left-color: var(--err); } table.zones tr.z6 td:first-child { border-left-color: #7a3fbf; }

/* ---- Calendar ------------------------------------------------------------------------------------------- */
.cal-head { justify-content: space-between; margin-bottom: 14px; }
.cal-head h1 { margin: 0; min-width: 220px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg a { padding: 7px 14px; text-decoration: none; color: var(--muted); font-size: 14px; border-left: 1px solid var(--line); }
.seg a:first-child { border-left: 0; } .seg a.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.cal-month { display: grid; grid-template-columns: 34px repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-month .dn { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; }
.cal-month .wk { font-size: 11px; color: var(--muted); text-decoration: none; padding-top: 8px; text-align: center; }
.cal-month .wk:hover { color: var(--accent); }
.cal-month .cell { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 5px 6px; min-height: 96px; min-width: 0; }
.cal-month .cell.out { opacity: .5; } .cal-month .cell.today { outline: 2px solid var(--accent); }
.cal-month .num { display: block; font-size: 12px; font-weight: 600; text-decoration: none; color: var(--ink); margin: 0 0 3px 2px; }
.chip { display: block; font-size: 11.5px; line-height: 1.3; padding: 2px 5px; margin-top: 3px; border-radius: 4px; background: var(--bg);
        text-decoration: none; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.bar { border-left-width: 3px; }
.chip.act { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.chip.act.cycling { color: var(--bike); } .chip.act.running { color: var(--run); } .chip.act.xcski { color: var(--ski); } .chip.act.strength { color: var(--strength); } .chip.act.swimming { color: var(--swim); }
.st { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; background: var(--warn); vertical-align: 1px; }
.st.ok { background: var(--ok); } .st.done { background: var(--muted); }
.cal-legend { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.chip-key { font-size: 12px; padding: 1px 6px; border-radius: 4px; background: var(--bg); }
.chip-key.bar { border-left: 3px solid var(--other); } .chip-key.act { border: 1px dashed var(--line); background: transparent; }
.wo.act { background: transparent; border-top: 1px dashed var(--line); border-right: 1px dashed var(--line); border-bottom: 1px dashed var(--line); }
.cal-year { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 960px) { .cal-year { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-top: 8px; }
.mini .dn { font-size: 10px; color: var(--muted); text-align: center; }
.mini a { display: block; font-size: 10px; text-align: center; line-height: 20px; border-radius: 3px; text-decoration: none; color: var(--ink); background: var(--bg); }
.mini a.h1 { background: color-mix(in srgb, var(--ok) 25%, var(--bg)); } .mini a.h2 { background: color-mix(in srgb, var(--ok) 50%, var(--bg)); }
.mini a.h3 { background: color-mix(in srgb, var(--ok) 75%, var(--bg)); color: #fff; } .mini a.h4 { background: var(--ok); color: #fff; }
/* races and calibration tests (calendar markers, upcoming races) */
.ev { display: inline-block; font-size: 11px; line-height: 1.4; padding: 0 6px; margin: 1px 0; border-radius: 9px; text-decoration: none;
      background: color-mix(in srgb, var(--err) 14%, var(--bg)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--err) 45%, var(--bg));
      max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.ev.b_race { background: color-mix(in srgb, var(--warn) 14%, var(--bg)); border-color: color-mix(in srgb, var(--warn) 45%, var(--bg)); }
.ev.test { background: color-mix(in srgb, var(--bike) 12%, var(--bg)); border-color: color-mix(in srgb, var(--bike) 40%, var(--bg)); }
.cell .ev, .day .ev { display: block; }
.mini a.ev-race, .mini a.ev-test { position: relative; }
.mini a.ev-race::after, .mini a.ev-test::after { content: ""; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--err); }
.mini a.ev-test::after { background: var(--bike); }
.mini a.plan { box-shadow: inset 0 0 0 1.5px var(--accent); } .mini a.today { font-weight: 700; outline: 2px solid var(--accent); }

/* ---- Calibration tests: workout graph per protocol --------------------------------------------------------- */
.wprof { margin: 6px 0 4px; position: relative; }
.wprof svg { width: 100%; height: 120px; display: block; }
.wprof .base { stroke: var(--line); stroke-width: 1; }
.wprof rect.z1 { fill: #8a8f98; } .wprof rect.z2 { fill: var(--ok); } .wprof rect.z3 { fill: var(--warn); }
.wprof rect.z4 { fill: var(--run); } .wprof rect.z5 { fill: var(--err); } .wprof rect.z6 { fill: #7a3fbf; }
.wprof rect.allout { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 3 2; }
.wprof .marks { position: absolute; top: 0; left: 0; right: 0; height: 14px; font-size: 11px; color: var(--ink); }
.wprof .marks span { position: absolute; transform: translateX(-50%); white-space: nowrap; font-weight: 600; }
.wprof figcaption { margin-top: 2px; }
.wsec { display: flex; flex-wrap: wrap; gap: 4px 6px; list-style: none; padding: 0; margin: 6px 0 10px; font-size: 12.5px; }
.wsec li { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.wsec li.allout { border-color: var(--ink); }
.wsec li + li::before { content: "→ "; color: var(--muted); }
.tips summary { cursor: pointer; font-weight: 600; }
.tips ul { margin: 6px 0 0; padding-left: 18px; }

@media (max-width: 700px) {
  .desktop-only { display: none !important; }            /* e.g. the upcoming-races columns folded into the race cell */
  .bodyrow { grid-template-columns: 1fr; gap: 4px; }
  .subtabs { flex-wrap: nowrap; overflow-x: auto; }
  .subtabs a { white-space: nowrap; padding: 10px 12px; }
  .cal-head h1 { min-width: 0; width: 100%; }
  .seg a { padding: 10px 12px; }
  .cal-month { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
  .cal-month .wk { display: none; }
  .cal-month .dn { padding: 0; text-align: center; font-size: 10px; }
  .cal-month .cell { min-height: 54px; padding: 3px; border-radius: 6px; }
  .cal-month .num { text-align: center; margin: 0 0 2px; }
  .cal-month .chip { display: inline-block; width: 8px; height: 8px; padding: 0; margin: 1px; border-radius: 50%; font-size: 0;
                     border: 0; background: var(--other); }
  .cal-month .chip.cycling { background: var(--bike); } .cal-month .chip.running { background: var(--run); }
  .cal-month .chip.xcski { background: var(--ski); } .cal-month .chip.strength { background: var(--strength); }
  .cal-month .chip.swimming { background: var(--swim); }
  .cal-month .chip.act { background: transparent; box-shadow: inset 0 0 0 2px currentColor; }
  .cal-month .chip .st { display: none; }
  .cal-year { grid-template-columns: 1fr 1fr; gap: 8px; }
  .mini a { line-height: 18px; }
  .stat .v { font-size: 22px; }
  /* dashboard numbers two per row: Readiness | Form, Fitness | Fatigue, Time >= MLSS | Glycogen */
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid.stats > .stat { padding: 10px 12px; }
  .grid.stats .stat .v { font-size: 20px; }
  .grid.stats .stat .k { font-size: 11px; letter-spacing: .03em; }
  .grid.stats .stat .s { font-size: 12px; overflow-wrap: anywhere; }
  .grid.g4.stats > :nth-child(4) { order: 1; }
  .grid.g4.stats > :nth-child(2), .grid.g4.stats > :nth-child(3) { order: 2; }
  .mmap-card { padding: 10px 4px; }
  .kv2 { grid-template-columns: minmax(0, 1fr); }      /* thresholds: the two lists stacked */                 /* By muscle: the map takes the whole width */
}
