/* Race Ready – styles
   1 Tokens & base · 2 Layout & panels · 3 Buttons, forms & switches · 4 Header
   5 Races box · 6 Race form · 7 Calendar panel · 8 Calendar grid · 9 Sports dialog
   10 Data file · 11 Toolbox · 12 Toast & print */

/* ---------- 1 Tokens & base ---------- */
:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --ink: #16202e;
  --muted: #64707f;
  --line: #dfe3e9;
  --navy: #1f3a5f;
  --navy-2: #2b4c78;
  --race: #c62828;
  --brand: #4A7148;        /* logo green */
  --brand-ink: #26332A;
  --brand-soft: #eef4ed;
  --good: #1c7a33;
  --bad: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.05);
  --font-head: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --lock-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h1zm2 0h6V7a3 3 0 0 0-6 0v3z'/%3E%3C/svg%3E");
  /* Sport colour scales (--<sport>-1 … -5) are set from app.js, see applyColors(). */
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font-body); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-head); letter-spacing: .02em; margin: 0; text-transform: uppercase; }
.muted { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-size: 13px; padding: 4px 0; }

/* ---------- 2 Layout & panels ---------- */
.layout { padding: 20px 24px; display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; padding: 16px; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.panel + .panel { margin-top: 16px; }
.credits { margin: 14px 4px 0; font-size: 12px; line-height: 1.5; color: var(--muted); text-align: center; }
.panel h2 { font-size: 21px; margin-bottom: 10px; color: var(--navy); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
/* Races header: "10 upcoming" stays on one line, with a slightly tighter header so Simple / Detailed still fits */
#raceCount { white-space: nowrap; font-size: 12px; }
#racesPanel .panel-head { gap: 6px; }
#racesPanel .collapse-btn { gap: 5px; }
#racesPanel .seg button { padding: 4px 6px; }
.panel-head h2 { margin: 0; }
/* Collapsible panels (Races, Data file, Toolbox) */
.collapse-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.collapse-btn h2 { margin: 0; }
.chev { transition: transform .15s; flex: none; }
.collapse-btn .chev { color: var(--navy); }
[aria-expanded="false"] > .chev { transform: rotate(-90deg); }
.panel.collapsed .panel-head { margin-bottom: 0; }
.panel.collapsed .collapsible-body, .panel.collapsed .seg { display: none; }

/* ---------- 3 Buttons, forms & switches ---------- */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 13px; font-weight: 600; cursor: pointer; }
.btn:hover { background: #f7f8fa; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.primary.danger { background: var(--bad); border-color: var(--bad); }
.btn.primary.danger:hover { background: #912018; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-ico { vertical-align: -2px; margin-right: 4px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.spaced { margin-top: 10px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 5px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--bg); color: var(--ink); }

.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 9px; }
.field label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; }
.field textarea { resize: vertical; min-height: 44px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--navy-2); outline-offset: -1px; border-color: transparent; }
.field input:disabled { background: #eef0f3; color: var(--muted); cursor: not-allowed; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 11px; color: var(--muted); line-height: 1.35; }

/* Segmented buttons (Simple/Detailed, Numbers) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.seg button { border: 0; background: #fff; padding: 4px 9px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }

/* On/off switch */
.switch-row { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.switch-row b { display: block; font-weight: 600; }
.switch { position: relative; width: 34px; height: 20px; flex: none; margin-top: 1px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: #cfd5dd; border-radius: 99px; transition: background .15s; }
.switch span::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + span { background: var(--navy); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--navy-2); outline-offset: 2px; }

.lock-ico { display: inline-block; width: 11px; height: 11px; vertical-align: -1px; margin-left: 3px;
  background: currentColor; -webkit-mask: var(--lock-svg) no-repeat center / contain; mask: var(--lock-svg) no-repeat center / contain; }

/* ---------- 4 Header ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-inner { padding: 14px 24px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
/* Logo, from race-ready-logo/header-snippet.html */
.rr-logo { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.rr-logo img { width: 40px; height: 40px; display: block; }
.rr-logo span { font: 600 24px/1 "Lexend", system-ui, sans-serif; letter-spacing: -0.01em; color: var(--brand-ink); }
.rr-logo span b { font-weight: 600; color: var(--brand); }
.brand-sub { border-left: 1px solid var(--line); padding-left: 20px; }
.brand-sub h1 { font-size: 22px; line-height: 1.1; color: var(--navy); display: inline-block; }
/* Test build of the web version: a badge next to the calendar name and an amber line at the top (section 14b) */
.channel-badge { display: inline-block; margin-left: 8px; vertical-align: 3px; background: #b7791f; color: #fff;
  font: 700 10.5px/1 var(--font-body); text-transform: uppercase; letter-spacing: .05em; padding: 4px 8px; border-radius: 99px; }
.channel-badge[hidden] { display: none; }
/* Web version: "A new version of Race Ready is ready" – above the header, and stays at the top of the screen
   until Reload now or Later */
.update-banner { position: sticky; top: 0; z-index: 50; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px;
  padding: 8px 16px; background: #e4ecf7; border-bottom: 1px solid #c9d6ea; color: var(--navy); font-size: 13.5px; }
.update-banner[hidden] { display: none; }
body.test-channel .topbar { box-shadow: inset 0 3px 0 #e7b54a; }
/* Long quotes wrap instead of pushing the Help button onto a second line (the Season | Week switch follows the quote) */
.quote { margin: 2px 0 0; color: var(--muted); font-size: 13px; font-style: italic; cursor: pointer; max-width: min(640px, 30vw); }
.quote:hover { color: var(--ink); }
.countdown { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.countdown .big { font-family: var(--font-head); font-size: 40px; line-height: 1; color: var(--brand); }
.countdown .lbl { color: var(--muted); font-size: 13px; }
.countdown .lbl strong { color: var(--ink); display: block; font-size: 15px; }
.countdown .motivation { display: block; max-width: 300px; border: 0; background: none; padding: 0; text-align: left; cursor: pointer;
  font-size: 13px; color: var(--brand); font-style: italic; line-height: 1.35; }
.countdown .motivation:hover { text-decoration: underline; }
/* Sport icon left of the countdown (Material Symbols) */
.msi { font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal; line-height: 1; letter-spacing: normal;
  text-transform: none; white-space: nowrap; direction: ltr; -webkit-font-smoothing: antialiased; font-feature-settings: "liga"; }
.race-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 1px;
  min-width: 32px; height: 32px; padding: 0 6px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); }
.race-icon .msi { font-size: 21px; }
.race-icon.multi .msi { font-size: 15px; }
.race-icon .badge { position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 1px solid #d5e3d3; display: grid; place-items: center; }
.race-icon .badge .msi { font-size: 10px; }
.no-icons .race-icon { display: none; }
/* Help Center button (top right), with the same divider as between the logo and the heading */
.help-wrap { display: flex; align-items: center; align-self: stretch; border-left: 1px solid var(--line); padding-left: 20px; margin-left: -4px; }
.help-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--brand); background: #fff; color: var(--brand);
  font: 700 24px/1 var(--font-head); cursor: pointer; display: grid; place-items: center; padding: 0; }
.help-btn:hover { background: var(--brand); color: #fff; }

/* ---------- 5 Races box ---------- */
.races { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
/* minmax(0, 1fr): the text column may shrink, so long content never pushes the buttons out of the card */
.race { border: 1px solid var(--line); border-left: 4px solid var(--race); border-radius: 9px; padding: 8px 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; cursor: pointer; }
.race:hover { background: #fafbfc; }
.race.past { opacity: .7; }
.race.planned { border-left-style: dashed; }
/* Result edge: green = finished (finish time entered), black = DNF; replaces the planned/confirmed edge */
.race.finished { border-left: 4px solid var(--good); }
.race.dnf { border-left: 4px solid #111; }
.dnf-label { color: #111; }
.race-top { display: flex; align-items: center; gap: 6px; }
.race-name { font-weight: 600; }
.race-meta { color: var(--muted); font-size: 12px; }
.race-when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.race-actions { display: flex; }
/* Detailed view: name row with the buttons top right, then full-width info lines */
.races:not(.simple) .race { row-gap: 3px; align-items: start; }
.races:not(.simple) .race-top { grid-column: 1; grid-row: 1; align-items: flex-start; padding-top: 2px; }
.races:not(.simple) .race-top .prio { margin-top: 2px; }
.races:not(.simple) .race-name { line-height: 1.3; overflow-wrap: anywhere; }
.races:not(.simple) .race-actions { grid-column: 2; grid-row: 1; margin: -2px -4px 0 0; }
.races:not(.simple) .race-actions .icon-btn { padding: 3px; }
.race-line { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.race-line .race-meta { min-width: 0; }
.race-line .status { flex: none; }
.race-countdown { flex: none; font-size: 12px; color: var(--ink); white-space: nowrap; }
.prio { font-size: 10px; font-weight: 700; color: #fff; background: var(--race); border-radius: 4px; padding: 1px 5px; }
.prio.B { background: #5b6472; }
.prio.C { background: #9aa2ad; }
.status { font-size: 10px; font-weight: 600; border-radius: 4px; padding: 0 5px; border: 1px solid transparent; cursor: pointer; line-height: 16px; }
.status.confirmed { background: #e3f5e3; color: #1c6a1c; border-color: #b7dfb6; }
.status.planned { background: #fff; color: var(--muted); border: 1px dashed #9aa2ad; }
.status:hover { filter: brightness(.95); }
.type-dots { display: inline-flex; gap: 2px; vertical-align: middle; }
.type-dots i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
/* Simple view */
.races.simple { gap: 3px; }
.races.simple .race { padding: 5px 8px; }
.races.simple .race-top { min-width: 0; }
.races.simple .race-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Result card: target, adjusted target, finish and gaps */
.result { grid-column: 1 / -1; min-width: 0; margin-top: 2px; padding: 7px 9px; background: #f5f7f9; border-radius: 7px; font-size: 12px; display: grid; gap: 2px; }
.result .row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 10px; }
.result .row > span:first-child { color: var(--muted); }
.result .row b, .result .row > .gap { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; }
.result .verdict { margin-top: 4px; padding-top: 5px; border-top: 1px solid var(--line); font-weight: 600; flex-wrap: nowrap; white-space: nowrap; }
.result .add-finish { justify-self: start; margin-top: 2px; border: 1px dashed var(--navy-2); background: #fff; color: var(--navy); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; cursor: pointer; }
.gap { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gap.good { color: var(--good); }
.gap.bad { color: var(--bad); }
/* Completed races archive */
.archive { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.archive-toggle { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 13px; }
.archive-toggle:hover { color: var(--ink); }
#archiveList { margin-top: 8px; }
/* Year headings in the archive (when it spans more than one year) */
.archive-year button { display: flex; align-items: center; gap: 5px; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none;
  padding: 4px 2px; cursor: pointer; font: 700 15px var(--font-head, inherit); letter-spacing: .03em; color: var(--navy); text-align: left; }
.archive-year button::before { content: '›'; display: inline-block; width: 10px; transition: transform .15s; }
.archive-year button[aria-expanded="true"]::before { transform: rotate(90deg); }
.archive-year button:hover { color: var(--ink); }
.archive-year:not(:first-child) { margin-top: 6px; }
.archive .race.past { opacity: .8; }

/* ---------- 6 Race form ---------- */
details.add summary { cursor: pointer; font-weight: 600; color: var(--navy); list-style: none; }
details.add summary::-webkit-details-marker { display: none; }
details.add summary h2 { margin: 0; }
details.add[open] summary { margin-bottom: 10px; }
/* Triathlon distances: compact 4-column grid of equal buttons (full names in the line below / tooltip) */
.tri-dist { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin: 2px 0; }
.tri-dist .sport-chip { justify-content: center; padding: 5px 2px; border-radius: 7px; font-size: 11.5px; white-space: nowrap; min-width: 0; }
/* Run / trail run: three per row (5 km · 10 km · Half marathon / Marathon · Other) – "Half marathon" may wrap on a narrow form */
#runDistBtns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#runDistBtns .sport-chip { white-space: normal; line-height: 1.15; text-align: center; }
/* "Other": the Distance field sits right under the buttons, without a second "Distance" label */
#triDistanceField:not([hidden]) ~ #distanceField, #runDistanceField:not([hidden]) + #distanceField { margin-top: -4px; }
#triDistanceField:not([hidden]) ~ #distanceField label, #runDistanceField:not([hidden]) + #distanceField label { display: none; }
.finish-row { display: flex; gap: 6px; align-items: stretch; }
.finish-row .time-input { flex: 1; min-width: 0; }
.sport-chip.dnf-btn { flex: none; padding: 0 14px; border-radius: 8px; font-weight: 700; }
.sport-chip.dnf-btn[aria-pressed="true"] { background: #111; border-color: #111; color: #fff; }
#triDistInfo b { color: var(--ink); }
.past-hint { display: block; margin: -4px 0 9px; color: var(--navy); }
.target-box { border: 1px dashed #cfd5dd; border-radius: 9px; padding: 10px 10px 1px; margin-bottom: 9px; background: #fafbfc; }
/* Optional race info in the form */
.more-info { border: 1px dashed #cfd5dd; border-radius: 9px; padding: 8px 10px; margin-bottom: 9px; }
.more-info summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--navy); }
.more-info[open] summary { margin-bottom: 8px; }
.more-info .field:last-child { margin-bottom: 2px; }
/* Race info links on the race event card */
.race-info { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.race-info a, .race-info span { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; line-height: 18px; padding: 0 7px;
  border: 1px solid var(--line); border-radius: 99px; background: #fff; color: var(--navy); text-decoration: none; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.race-info a:hover { border-color: var(--navy); }
.race-info span { color: var(--muted); }
.race-info svg { flex: none; }
.race-info [data-edit] { cursor: help; }

/* ---------- 7 Calendar panel ---------- */
.plan-panel { padding: 0; overflow: hidden; }
.plan-top { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; }
/* The legend takes the free space and wraps inside it, so the season dates stay on the same line on smaller screens */
.plan-legend { flex: 1 1 300px; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.legend-title { font-size: 12px; margin-right: 2px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 3px 11px 3px 9px; cursor: pointer; }
.legend-item:hover { background: #f7f8fa; }
.legend-item i { width: 3px; height: 16px; display: inline-block; background: var(--race); }
.legend-item i.dashed { background: repeating-linear-gradient(to bottom, var(--race) 0 4px, transparent 4px 8px); }
.legend-item[aria-pressed="false"] { opacity: .45; text-decoration: line-through; border-style: dashed; }
.settings { margin-left: auto; display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.settings .field { margin: 0; }
.settings input { width: auto; }
.toolbar { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #fafbfc; }
.toolbar .lbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-right: 2px; }
.toolbar .lbl.gap-left { margin-left: 6px; }
/* Controls that belong together wrap as one block on smaller screens */
.tool-group { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tool-group.right { margin-left: auto; }
/* Effort buttons: number + shade + name, so they also serve as the scale legend.
   "armed" = cells are selected and a click will set them. */
.setbtns { display: inline-flex; gap: 4px; }
.setbtn { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 44px; padding: 3px 4px 2px;
  border-radius: 7px; border: 1px solid var(--line); background: #fff; cursor: help; }
.setbtn .sw { width: 24px; height: 17px; border-radius: 4px; display: grid; place-items: center; font-size: 11px; font-weight: 700; border: 1px solid var(--line); }
.setbtn small { font-size: 10px; font-weight: 600; color: var(--muted); white-space: nowrap; line-height: 1.2; }
.setbtns.armed .setbtn { cursor: pointer; border-color: var(--navy-2); box-shadow: 0 0 0 1px var(--navy-2) inset; }
.setbtns.armed .setbtn:hover { background: var(--navy); }
.setbtns.armed .setbtn:hover small { color: #fff; }
.effort-scale { position: relative; display: inline-flex; align-items: center; gap: 8px; }
.effort-help { position: absolute; top: calc(100% + 8px); left: 0; z-index: 20; width: 380px; padding: 12px 14px;
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(16,24,40,.18);
  font-size: 12.5px; line-height: 1.5; font-weight: 400; text-transform: none; letter-spacing: 0; }
.effort-help b { display: block; margin-bottom: 4px; font-size: 13px; color: var(--navy); }
.selinfo { font-size: 12px; color: var(--muted); max-width: 330px; line-height: 1.3; }
.grid-tip { padding: 10px 16px; margin: 0; }
/* Effort warnings (week before / after a race) */
.warnbar { padding: 8px 16px; background: #fffaeb; border-bottom: 1px solid #f5d27a; font-size: 12.5px; display: grid; gap: 3px; max-height: 150px; overflow-y: auto; }
.warn-head { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer;
  font-size: 12.5px; font-weight: 700; color: #8a5a00; text-align: left; }
.warn-head:hover { color: #5c3d00; }
.warn-list { display: grid; gap: 3px; }
.warn-item { border: 0; background: none; padding: 1px 0; text-align: left; cursor: pointer; color: var(--ink); font-size: 12.5px; line-height: 1.4; }
.warn-item:hover { text-decoration: underline; }
.warn-item .wk { font-weight: 700; color: #8a5a00; margin-right: 6px; }

/* ---------- 7b Week planner (feature 'trainingPlanner') ----------
   Week mode: the week view replaces the side panels and the calendar; its parts sit on the page as cards. */
.view-switch { align-self: center; }
.view-switch button { padding: 7px 16px; font-size: 13px; }
body.week-mode .layout { grid-template-columns: minmax(0, 1fr); }
body.week-mode .layout > aside { display: none; }
body.week-mode .plan-panel { background: none; border: 0; box-shadow: none; overflow: visible; }
body.week-mode .plan-panel > :not(#weekView) { display: none; }
.grid thead tr.weeks th.wk-open { cursor: pointer; }
.grid thead tr.weeks th.wk-open:hover { background: var(--navy); text-decoration: underline; }
.week-view { display: grid; gap: 14px; }
.wk-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.wk-box h3 { font-size: 17px; color: var(--navy); }
.wk-box-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 10px; }

/* Week bar */
.wk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.wk-arrow { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; color: var(--navy); }
.wk-heading { display: flex; flex-direction: column; line-height: 1.1; min-width: 118px; }
.wk-heading h2 { font-size: 30px; color: var(--navy); }
.wk-heading span { font-size: 13px; color: var(--muted); }
.wk-pill { font-size: 12.5px; font-weight: 600; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 11px; color: var(--ink); }
.wk-pill.phase { background: #e4ecf7; border-color: #e4ecf7; color: var(--navy); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.wk-actions .btn { min-height: 44px; }

/* This week vs. season plan */
.wk-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 10px; }
.wk-tile { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 76px; background: #fff; }
.wk-tile.flag { background: #fff8e8; border-color: #e7b54a; }
.wk-tile-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.wk-tile-top b { font-size: 14px; }
.wk-target { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--ink); }
.wk-tile.total .wk-target { color: #8a5300; }
.wk-tile-sched { margin-top: 4px; font-size: 13px; color: var(--muted); }
.wk-flag { margin-top: 4px; font-size: 12.5px; font-weight: 600; color: #8a5300; }
.wk-total { margin-top: 2px; font-size: 13px; color: var(--muted); }
.wk-total .big { font: 700 26px/1 var(--font-head); color: var(--ink); margin-right: 4px; }
.wk-bar-track { position: relative; height: 7px; border-radius: 99px; background: #eef0f3; margin-top: 8px; }
.wk-bar-track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--navy); }
.wk-bar-track b { position: absolute; top: -3px; width: 2px; height: 13px; background: #b7791f; }
.wk-dot { width: 9px; height: 9px; border-radius: 2px; background: var(--c); flex: none; }
.wk-warns:not(:empty) { display: grid; gap: 6px; margin-top: 10px; }
.wk-warn { margin: 0; display: flex; gap: 8px; align-items: flex-start; background: #fdf0ee; color: #7a2a1c; border-radius: 8px; padding: 9px 12px; font-size: 13px; line-height: 1.4; }
.wk-warn svg { flex: none; margin-top: 1px; }

/* Day columns */
.wk-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
@media (max-width: 1100px) { .wk-days { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
.wk-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; overflow: hidden; }
.wk-day.today { border: 2px solid var(--navy); }
.wk-day.over { box-shadow: 0 0 0 2px var(--navy-2); }
.wk-dayhead { width: 100%; display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; border: 0; border-bottom: 1px solid var(--line);
  background: #fff; padding: 9px 10px; text-align: left; cursor: pointer; color: var(--ink); font: inherit; }
.wk-dayhead:hover { background: #f7f8fa; }
.wk-dayhead b { display: block; font: 700 17px/1.1 var(--font-head); text-transform: uppercase; color: var(--navy); }
.wk-dayhead small { font-size: 12px; color: var(--muted); }
.wk-daytime { font-size: 12.5px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.wk-day.today .wk-dayhead { background: var(--navy); border-color: var(--navy); }
.wk-day.today .wk-dayhead b, .wk-day.today .wk-dayhead small, .wk-day.today .wk-daytime { color: #fff; }
.wk-daybody { padding: 8px; display: flex; flex-direction: column; gap: 7px; }
.wk-list { display: flex; flex-direction: column; gap: 7px; }
.wk-list:empty { display: none; }
.wk-rest { border: 1.5px dashed #a991d4; background: #f6f2fc; color: #4f3a86; border-radius: 9px; padding: 9px 8px; text-align: center; cursor: pointer; font: inherit; }
.wk-rest b { display: block; font-size: 14px; }
.wk-rest small { display: block; font-size: 12px; margin-top: 2px; }
.wk-race { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--race); border-radius: 8px; padding: 6px 8px; overflow-wrap: anywhere; }
.wk-card { position: relative; background: var(--tint); border-radius: 9px; padding: 8px 9px; font-size: 12px; cursor: grab; min-width: 0; border: 1px solid transparent; }
.wk-card:hover { border-color: var(--c); }
.wk-card.dragging { opacity: .4; }
.wk-card.skipped { opacity: .55; }
.wk-card.skipped .wk-title { text-decoration: line-through; }
.wk-card-top { display: flex; align-items: center; gap: 6px; }
.wk-sport { font-weight: 600; color: var(--dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-time { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.wk-title { font-weight: 700; font-size: 14px; line-height: 1.25; margin-top: 3px; overflow-wrap: anywhere; }
.wk-meta { margin-top: 3px; color: var(--muted); font-size: 12px; }
.wk-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; padding-right: 24px; min-height: 20px; }
.wk-effort { font-size: 11px; font-weight: 600; border-radius: 6px; padding: 1px 7px; }
.wk-effort.e1, .wk-effort.e2 { background: #e3f1e7; color: #2f6b45; }
.wk-effort.e3 { background: #fff0cc; color: #7a5200; }
.wk-effort.e4 { background: #fbe3de; color: #9c2f1c; }
.wk-effort.e5 { background: #f6cfc6; color: #7a1f10; }
.wk-status { font-size: 11.5px; font-weight: 600; }
.wk-status.done { color: #1c6a1c; }
.wk-status.skipped { color: var(--muted); }
.wk-check { position: absolute; right: 8px; bottom: 8px; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid #9aa2ad; background: #fff; color: transparent;
  font-size: 12px; font-weight: 700; line-height: 1; padding: 0; cursor: pointer; display: grid; place-items: center; }
.wk-check:hover:not(:disabled) { border-color: #1c6a1c; color: #1c6a1c; }
.wk-check:disabled { opacity: .35; cursor: not-allowed; }
.sess-status button:disabled { opacity: .4; cursor: not-allowed; }
.wk-check[aria-pressed="true"] { background: #1c6a1c; border-color: #1c6a1c; color: #fff; }
.wk-daynote { background: #f1f3f6; border: 0; border-radius: 8px; padding: 8px 9px; font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; color: var(--ink); white-space: pre-line; overflow-wrap: anywhere; }
.wk-add { border: 1.5px dashed #c4cbd5; background: transparent; border-radius: 9px; min-height: 40px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.wk-add:hover { background: #f7f8fa; color: var(--navy); border-color: var(--navy-2); }
.wk-quick { background: #fff; border: 1.5px solid var(--navy-2); border-radius: 9px; padding: 7px; display: flex; flex-direction: column; gap: 6px; }
.wk-qsports { display: flex; flex-wrap: wrap; gap: 4px; }
.wk-qsport { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 3px 8px; font-size: 11.5px; font-weight: 600; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-qsport[aria-pressed="true"] { background: var(--tint); border-color: var(--c); box-shadow: 0 0 0 1px var(--c) inset; }
.wk-quick input { border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 12.5px; width: 100%; min-width: 0; }
.wk-quick input:focus { outline: 2px solid var(--navy-2); outline-offset: -1px; border-color: transparent; }
.wk-qfoot { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.wk-qfoot .btn.small { padding: 4px 8px; font-size: 12px; }
.wk-qfoot .icon-btn { margin-left: auto; padding: 2px 4px; font-size: 12px; line-height: 1; }
.wk-notes h3 { margin-bottom: 8px; }
.wk-notes textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fafbfc; resize: vertical; min-height: 56px; }

/* Session panel and day dialog */
.dlg.session-dlg { width: min(460px, calc(100vw - 32px)); }
.dlg.day-dlg { width: min(400px, calc(100vw - 32px)); }
.sess-sub { display: block; font-size: 13px; margin-top: 2px; }
.session-dlg .opt, .day-dlg .opt { text-transform: none; letter-spacing: 0; font-weight: 400; }
.sess-sports { display: flex; flex-wrap: wrap; gap: 6px; }
.sess-sport { border: 1px solid var(--line); background: #fff; color: var(--dark); border-radius: 99px; padding: 7px 14px; font-weight: 600; font-size: 13px; cursor: pointer; }
.sess-sport[aria-pressed="true"] { background: var(--tint); border-color: var(--c); box-shadow: 0 0 0 1px var(--c) inset; }
.sess-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: #eef0f3; border-radius: 9px; padding: 4px; }
.sess-types button { border: 0; background: transparent; border-radius: 7px; padding: 7px 4px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; }
.sess-types button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.sess-row { display: grid; grid-template-columns: 1.35fr 1fr 1fr 1fr; gap: 8px; }
.sess-row.three { grid-template-columns: repeat(3, 1fr); }
.sess-row .field input { padding: 8px 8px; min-width: 0; }
.sess-efforts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.sess-efforts button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); cursor: pointer; line-height: 1.25; }
.sess-efforts button b { display: block; font-size: 15px; color: var(--ink); }
.sess-efforts button[aria-pressed="true"].e1, .sess-efforts button[aria-pressed="true"].e2 { background: #e3f1e7; border-color: #2f6b45; color: #2f6b45; }
.sess-efforts button[aria-pressed="true"].e3 { background: #fff0cc; border-color: #b7791f; color: #7a5200; }
.sess-efforts button[aria-pressed="true"].e4 { background: #fbe3de; border-color: #9c2f1c; color: #9c2f1c; }
.sess-efforts button[aria-pressed="true"].e5 { background: #f6cfc6; border-color: #7a1f10; color: #7a1f10; }
.sess-efforts button[aria-pressed="true"] b { color: inherit; }
.sess-repeat { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 9px; font-size: 13px; }
.sess-repeat input[type="date"] { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.sess-check { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; margin: 0 0 9px; cursor: pointer; }
.sess-repeat .sess-check { margin: 0; }
.sess-complete { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 2px; }
.sess-status { align-self: flex-start; }
.sess-status button { padding: 6px 10px; }
.sess-preview { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.sess-preview:empty { display: none; }
.sess-preview i { width: 9px; height: 9px; border-radius: 2px; background: var(--c); flex: none; }
.sess-foot { gap: 8px; flex-wrap: wrap; }
.sess-spacer { flex: 1; }
#sessDelete, #sessDeleteSeries { color: var(--bad); }

/* Import a training plan (feature 'planImport') */
.dlg.import-dlg { width: min(760px, calc(100vw - 32px)); }
.imp-step { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.imp-step:first-of-type { border-top: 0; padding-top: 2px; }
.dlg .imp-step h3 { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); text-transform: uppercase;
  letter-spacing: .02em; font-size: 17px; color: var(--navy); margin: 0 0 6px; }
.imp-step .step { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font: 700 13px/1 var(--font-body); }
.imp-step p { margin: 0 0 6px; }
.imp-how { margin: 0 0 10px; padding-left: 20px; font-size: 13px; line-height: 1.55; }
.imp-prompt { align-self: center; font-size: 12.5px; }
/* "How the import works": shown while the ⓘ icon is hovered or has keyboard focus. It floats above the dialog
   (position: fixed, placed by placeImportHelp in app.js), so it is never cut off by the dialog's edge. */
.imp-info { align-self: center; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  color: var(--muted); cursor: help; }
.imp-info:hover, .imp-info:focus-visible { color: var(--navy); background: #eef0f3; outline: none; }
.imp-help { display: none; position: fixed; z-index: 20; width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 12px 16px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(16,24,40,.18); font-size: 12.5px; line-height: 1.5; cursor: default; }
.imp-help.open { display: block; }
.imp-help b { display: block; margin-bottom: 4px; font-size: 13px; color: var(--navy); }
.imp-help-p { display: block; margin-top: 6px; }
.imp-help-p i { font-style: normal; font-weight: 700; }
.imp-prompt summary { cursor: pointer; color: var(--navy); font-weight: 600; }
.imp-prompt pre { white-space: pre-wrap; font-size: 11.5px; background: #f6f7f9; border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 220px; overflow: auto; margin: 6px 0 0; }
#importText { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 12px/1.4 Consolas, "SF Mono", Menlo, monospace; resize: vertical; }
.imp-paste-row { align-items: center; margin-top: 6px; }
.imp-status { font-size: 12.5px; color: var(--muted); }
.imp-status.ok { color: var(--ink); font-size: 13px; line-height: 1.5; padding: 8px 12px; background: #eef6ef; border-radius: 8px; }
.imp-status.bad { color: var(--bad); font-weight: 600; }
.imp-place { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; justify-items: start; gap: 6px 10px; margin-bottom: 10px; font-size: 13px; }
.imp-place input[type="date"], .imp-place select { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; max-width: 100%; }
.imp-radio { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
/* Race-day decision: plan sessions on or after the chosen race's day */
.imp-conflict { background: #fff8e8; border: 1px solid #e7b54a; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px;
  display: grid; gap: 6px; }
.imp-conflict h4 { margin: 0; font-size: 14px; color: #8a5300; }
.imp-conflict p { margin: 0 0 2px; color: #8a5300; }
.imp-conflict .imp-radio { align-items: flex-start; font-weight: 500; }
.imp-conflict .imp-radio input { margin-top: 3px; }
.imp-conflict .imp-radio b { font-weight: 600; }
.imp-conflict .imp-radio small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.imp-sports:not(:empty) { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; font-size: 13px; align-items: center; }
.imp-sports label { display: inline-flex; align-items: center; gap: 6px; }
.imp-sports select { border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }
.imp-summary { font-weight: 600; font-size: 13px; margin: 0 0 6px; }
.imp-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.imp-week { padding: 6px 10px; border-top: 1px solid var(--line); }
.imp-week:first-child { border-top: 0; }
.imp-week h4 { margin: 2px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.imp-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 2px 0; cursor: pointer; }
.imp-row .wk-dot { width: 8px; height: 8px; }
.imp-row .d { width: 74px; flex: none; color: var(--muted); }
.imp-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-row .m { color: var(--muted); white-space: nowrap; }
.imp-row.off { opacity: .45; }
.imp-plans:not(:empty) { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; font-size: 13px; }
.imp-plans h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.imp-plan { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.imp-plan span { flex: 1; min-width: 0; }

/* ---------- 8 Calendar grid ---------- */
.grid-scroll { overflow-x: auto; position: relative; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 12px; user-select: none; }
.grid th, .grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; }
.grid .rowh { position: sticky; left: 0; z-index: 3; background: #fff; text-align: left; padding: 0 12px; min-width: 150px; font-weight: 600; white-space: nowrap; box-shadow: 1px 0 0 var(--line); }
.grid thead th { background: var(--navy); color: #fff; font-weight: 700; height: 24px; border-color: #355685; }
.grid thead .rowh { background: var(--navy); color: #fff; }
.grid thead tr.months th { text-transform: uppercase; font-size: 11px; letter-spacing: .03em; }
.grid thead tr.weeks th { font-size: 11px; min-width: 36px; width: 36px; background: var(--navy-2); }
.grid thead tr.weeks th.now { background: #ffb199; color: var(--navy); }
.rowh .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 8px; vertical-align: -1px; }
/* Value cells: equal neighbours merge into one band (see cellHTML) */
.cell { height: 32px; text-align: center; font-weight: 600; cursor: cell; background: #fff; color: #c7ccd3; }
.cell.v0 { font-weight: 400; }
.cell.dark { color: #fff; }
.cell.lite { color: var(--ink); }
.cell.sel { outline: 2px solid var(--ink); outline-offset: -2px; position: relative; z-index: 1; }
.cell.hn span { visibility: hidden; }
.cell.hn:hover span, .cell.hn.sel span { visibility: visible; }
/* Race week lines (dashed for planned races) and the current week */
/* Race line on the race day inside the week: --rx is the day's position in % (set by renderGrid) */
.race-col { position: relative; }
.race-col::before { content: ''; position: absolute; top: 0; bottom: 0; left: calc(var(--rx, 0%) - 1px); width: 2px;
  background: var(--race); pointer-events: none; z-index: 1; }
.race-col.planned::before { background: repeating-linear-gradient(to bottom, var(--race) 0 4px, transparent 4px 8px); }
.now-col { background-image: linear-gradient(rgba(255,177,153,.18), rgba(255,177,153,.18)); }
tr.group-gap td, tr.group-gap th { height: 8px; border-bottom: 1px solid var(--line); background: #fafbfc; }
/* Total load row */
tr.total td { height: 54px; vertical-align: bottom; text-align: center; position: relative; }
.tbar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; padding: 4px 0 3px; gap: 2px; }
.tbar i { width: 18px; background: var(--navy-2); border-radius: 3px 3px 0 0; display: block; min-height: 1px; }
.tbar span { font-size: 10px; color: var(--muted); font-weight: 600; }
.tbar b { font-size: 11px; line-height: 1; color: #d97706; }
tr.total td.warn .tbar i { background: #f59e0b; }
tr.total td.warn .tbar span { color: #b45309; }
.grid thead tr.weeks th { position: relative; }
.grid thead tr.weeks th.warn::after { content: '!'; position: absolute; top: 1px; right: 1px; width: 11px; height: 11px; border-radius: 50%;
  background: #f59e0b; color: #1f2937; font-size: 9px; line-height: 11px; text-align: center; font-weight: 800; }
/* Notes row */
tr.notes td { height: 44px; vertical-align: top; cursor: text; }
tr.notes td:hover { background: #f7f8fa; }
/* At most 3 lines (longer notes end in "…"), so a long note never stretches the row; the full note is in the tooltip */
tr.notes .ntext { font-size: 10px; line-height: 1.2; padding: 4px 3px; color: #4a4f58; word-break: break-word;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
tr.races-row th, tr.notes th { vertical-align: middle; }
/* Races row: names are laid over it as flags starting at each race line,
   stacked into extra lanes when they would overlap (see layoutRaceLabels). */
tr.races-row td { height: 44px; }
tr.races-row th { color: var(--race); }
.race-labels { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 2; }
.rlabel { position: absolute; white-space: nowrap; font-size: 11px; line-height: 18px; height: 20px; padding: 0 7px 0 6px;
  color: var(--race); font-weight: 600; background: #fff; border: 1px solid #efb4b4; border-left: 0; border-radius: 0 5px 5px 0; cursor: pointer; }
.rlabel:hover { background: #fff4f2; }
.rlabel.planned { font-style: italic; font-weight: 500; border-style: dashed; border-left: 0; color: #b84a4a; }
.rlabel small { color: var(--muted); font-weight: 500; font-style: normal; margin-left: 4px; }
.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 40% { background: #ffd9cc; } 100% { background: transparent; } }

/* ---------- 9 Sports dialog ---------- */
.dlg { border: 0; border-radius: 14px; padding: 20px 22px; width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgba(16,24,40,.3); color: var(--ink); }
.dlg::backdrop { background: rgba(22,32,46,.45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.dlg-head h2 { font-size: 26px; color: var(--navy); }
.dlg h3 { font-family: var(--font-body); text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.dlg-intro { margin: 0 0 14px; }
.dlg-note { margin: 8px 0 0; }
.dlg-cols { display: grid; grid-template-columns: 300px 1fr; gap: 24px; }
@media (max-width: 720px) { .dlg-cols { grid-template-columns: 1fr; } }
.dlg-foot { display: flex; justify-content: flex-end; margin-top: 16px; }
.active-sports { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.active-sports li { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px 4px 4px; }
.active-sports .name { flex: 1; font-weight: 600; }
.active-sports input[type=color] { width: 28px; height: 26px; border: 0; padding: 0; background: none; cursor: pointer; }
.active-sports .icon-btn { padding: 3px 5px; font-size: 13px; line-height: 1; }
.active-sports .icon-btn:disabled { opacity: .3; cursor: default; }
.sport-search { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.sport-group { margin-bottom: 10px; }
.sport-group h4 { margin: 0 0 5px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sport-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.sport-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 3px 10px 3px 7px; font-size: 12px; font-weight: 500; cursor: pointer; }
.sport-chip i { width: 10px; height: 10px; border-radius: 3px; }
.sport-chip:hover { background: #f7f8fa; }
.sport-chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.custom-sport { display: flex; gap: 6px; margin-top: 6px; }
.custom-sport input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }

/* Help Center */
.help-dlg { width: min(720px, calc(100vw - 32px)); }
.help-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.help-nav button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.help-nav button:hover, .help-nav button[aria-current="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.help-body { max-height: calc(100vh - 220px); overflow-y: auto; padding-right: 4px; }
.help-topic { padding: 2px 0 4px; }
.dlg .help-topic h3 { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .02em; font-size: 19px; color: var(--navy); margin: 0 0 6px; }
.help-topic p { margin: 0 0 8px; }
.help-topic ul { margin: 0; padding-left: 18px; display: grid; gap: 5px; }
.help-topic ul + p { margin-top: 10px; }
.help-topic li .help-cont { margin: 6px 0 0; }
.help-about { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; font-size: 13px; }
.help-about dt { font-weight: 700; color: var(--navy); }
.help-about dd { margin: 0; }
.help-scale { display: flex; flex-wrap: wrap; gap: 6px; }
.help-scale span { border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 600; background: #fafbfc; }
/* Same shades as the Effort buttons, so the help shows the colour grading */
.help-scale span:nth-child(2) { background: var(--holiday-1); }
.help-scale span:nth-child(3) { background: var(--holiday-2); }
.help-scale span:nth-child(4) { background: var(--holiday-3); }
.help-scale span:nth-child(5) { background: var(--holiday-4); color: #fff; }
.help-scale span:nth-child(6) { background: var(--holiday-5); color: #fff; }

/* Plan for one race */
.plan-dlg { width: min(560px, calc(100vw - 32px)); }
/* Plan my season, and the "Are you sure?" window (askConfirm) */
.season-dlg, .confirm-dlg, .note-dlg { width: min(440px, calc(100vw - 32px)); }
.update-dlg { width: min(500px, calc(100vw - 32px)); }
.update-steps { margin: 8px 0 0; padding-left: 20px; }
.update-steps li { margin-bottom: 6px; }
.update-dlg .dlg-foot { gap: 8px; }
.note-dlg #noteWeek { margin: 0 0 10px; }
.note-dlg #noteText { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.note-dlg #noteText:focus { outline: 2px solid var(--navy-2); outline-offset: -1px; border-color: transparent; }
.confirm-dlg #confirmText { margin: 4px 0 0; }
.confirm-dlg .dlg-foot { gap: 8px; }
.season-dlg .season-intro { margin: 4px 0 10px; color: var(--muted); }
.season-dlg #seasonDlgText { margin: 4px 0 0; font-weight: 600; }
.season-dlg .dlg-foot { gap: 8px; }
.finish-dlg { width: min(420px, calc(100vw - 32px)); }
.finish-race { margin: 2px 0 12px; color: var(--muted); }
.finish-race b { color: var(--ink); }
.finish-dlg .dlg-foot { gap: 8px; }
.plan-intro { margin: 4px 0 8px; font-weight: 600; color: var(--brand); }
.plan-summary { margin: 4px 0 12px; line-height: 1.5; }
.plan-summary small { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
/* "Thinking" moment before the plan window */
.think-dlg { width: 340px; text-align: center; padding: 26px 22px 20px; cursor: pointer; }
.think-spinner { width: 34px; height: 34px; margin: 0 auto 14px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--brand); animation: think-spin .8s linear infinite; }
.think-msg { margin: 0; min-height: 2.6em; font-weight: 600; color: var(--navy); line-height: 1.3; }
@keyframes think-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .think-spinner { animation-duration: 3s; } }
.plan-options { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.plan-options legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.plan-option { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.plan-option:has(input:checked) { border-color: var(--navy-2); background: #f5f8fc; }
.plan-option:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.plan-option input { margin-top: 3px; accent-color: var(--navy); }
.plan-option small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: 2px; }
.plan-note { margin: 12px 0 0; }

/* Initial setup */
.setup-dlg { width: min(640px, calc(100vw - 32px)); }
.setup-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.setup-hero h2 { font-size: 26px; color: var(--navy); }
.setup-hero p { margin: 2px 0 0; font-size: 13px; }
.setup-step { margin-bottom: 16px; }
.dlg .setup-step h3 { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); text-transform: uppercase;
  letter-spacing: .02em; font-size: 17px; color: var(--navy); margin: 0 0 8px; }
.setup-step .step { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center;
  font: 700 13px/1 var(--font-body); }
.setup-step .sport-chips { margin-bottom: 6px; }
.setup-step .field { margin-bottom: 0; }
.setup-note { margin: 4px 0 16px; padding: 9px 12px; background: var(--brand-soft); border-radius: 8px; font-size: 12.5px; color: #34502f; }
.setup-step .switch-row .muted { display: block; font-size: 12.5px; }
.setup-step .switch-row b .muted { display: inline; font-weight: 400; }
.setup-load { display: flex; align-items: center; gap: 12px; }
.setup-load .btn { flex: none; }
/* The buttons stay visible at the bottom of the window while the steps scroll (the setup is taller than most screens) */
.setup-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; position: sticky; bottom: -20px; z-index: 1;
  margin: 0 -22px -20px; padding: 12px 22px 16px; background: #fff; border-top: 1px solid var(--line); }
.setup-foot .spacer { flex: 1; }

/* ---------- 10 Data file ---------- */
.file-about { margin: 0 0 10px; line-height: 1.45; }
.filebox { border-radius: 9px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; border: 1px solid var(--line); background: #fafbfc; }
.filebox.ok { border-color: #b7dfb6; background: #f1faf1; }
.filebox.warn { border-color: #f5d27a; background: #fffaeb; }
.filebox.err { border-color: #f1b0b0; background: #fff3f3; }
.filebox b { display: block; margin-bottom: 2px; }
.filebadge { display: inline-flex; align-items: center; max-width: 100%; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 99px; padding: 5px 12px; margin-bottom: 10px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filebadge:hover { background: #f7f8fa; }
/* short status next to the "Data file" heading, visible while the box is collapsed */
.file-mini { display: inline-flex; align-items: center; gap: 5px; margin-left: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.filebadge i, .file-mini i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9aa2ad; }
.filebadge i { margin-right: 6px; }
.filebadge.ok i, .file-mini.ok i { background: #5ad15a; }
.filebadge.warn i, .file-mini.warn i { background: #ffc531; }
.filebadge.err i, .file-mini.err i { background: #ff6b6b; }

/* ---------- 11 Toolbox ---------- */
.tool-sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
/* Toolbox actions: a compact two-column grid of equal buttons (Update across the full width) */
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tool-grid .btn { width: 100%; text-align: center; }
.tool-grid .wide { grid-column: 1 / -1; }
.tool-label { display: block; font-weight: 600; margin-bottom: 5px; }
.tool-text { margin: 0 0 10px; }
.season-plan-panel h2 { margin-bottom: 6px; }
.season-plan-panel .tool-text { font-size: 12.5px; margin-bottom: 8px; }
.season-plan-panel #planSeasonBtn { width: 100%; margin-top: 2px; }
.season-plan-panel .hint { display: block; margin-top: 6px; text-align: center; }
.name-row { display: flex; gap: 6px; margin-bottom: 4px; }
.name-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.name-row input:focus { outline: 2px solid var(--navy-2); outline-offset: -1px; border-color: transparent; }

/* ---------- 12 Toast & print ---------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
.toast.show { opacity: 1; }
@media print {
  @page { size: landscape; margin: 8mm; }
  body { background: #fff; }
  .layout { display: block; padding: 0; }
  aside, .toolbar, .settings, .countdown, .grid-tip, .help-wrap, .warnbar { display: none !important; }
  .panel { box-shadow: none; border: 0; }
  .grid-scroll { overflow: visible; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
