/* Sporťák – barvy z orientační mapy: papír, inkoust, fialová tisku tratě.
   Světlý režim na :root, tmavý jen přepisuje tokeny (systém i ruční přepínač). */
:root {
  color-scheme: light;
  --paper: #f6f5f0;
  --surface: #ffffff;
  --surface-2: #efede6;
  --ink: #16181b;
  --ink-2: #474a4f;
  --muted: #6a6d72;
  --line: #dedcd3;
  --accent: #a3196f;          /* fialová tratě, 6,9:1 na papíře */
  --accent-soft: #f6e3ee;
  --forest: #2f7d3a;          /* zelená mapy – terén */
  --open: #f2c230;            /* žlutá mapy – otevřený prostor */
  --contour: #a85a1c;         /* hnědá vrstevnic */
  --water: #2b7bb9;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #0ca30c;
  --warn: #c98500;
  --bad: #d03b3b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .05), 0 4px 14px rgba(20, 20, 20, .04);
  --font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Saira Semi Condensed", "Arial Narrow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #111316;
    --surface: #1a1d21;
    --surface-2: #23272c;
    --ink: #ecebe6;
    --ink-2: #c4c3bd;
    --muted: #9c9e9f;
    --line: #2f343a;
    --accent: #ef6cb6;
    --accent-soft: #3a1f30;
    --forest: #5cb868;
    --open: #e2b52a;
    --contour: #d88a4d;
    --water: #5aa6e0;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111316;
  --surface: #1a1d21;
  --surface-2: #23272c;
  --ink: #ecebe6;
  --ink-2: #c4c3bd;
  --muted: #9c9e9f;
  --line: #2f343a;
  --accent: #ef6cb6;
  --accent-soft: #3a1f30;
  --forest: #5cb868;
  --open: #e2b52a;
  --contour: #d88a4d;
  --water: #5aa6e0;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0; letter-spacing: .005em; }
h1 { font-size: clamp(28px, 5vw, 40px); }
h2 { font-size: 24px; margin-bottom: 14px; }
h3 { font-size: 18px; }
p { margin: 0 0 10px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 16px; }

/* --- hlavička --- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.top-inner { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font: 700 21px var(--font-head); flex: none; }
.brand svg { color: var(--accent); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 7px 12px; border-radius: 999px; color: var(--ink-2); text-decoration: none;
  font-weight: 600; font-size: 15px; white-space: nowrap;
}
.tabs a:hover { background: var(--surface-2); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--paper); }
@media (max-width: 640px) {
  .top-inner { flex-wrap: wrap; row-gap: 6px; padding-bottom: 8px; }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; margin-inline: -4px; }
  .tabs a { padding: 6px 7px; font-size: 13.5px; }
  .tabs { gap: 0; justify-content: space-between; }
}
.theme {
  flex: none; width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); display: grid; place-items: center; cursor: pointer;
}
.theme .i-moon { display: none; }
:root[data-theme="dark"] .theme .i-sun { display: none; }
:root[data-theme="dark"] .theme .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme .i-moon { display: block; }
}

main { padding-block: 22px 40px; }
section.view { display: grid; gap: 18px; }
.loading { color: var(--muted); }

/* --- karty --- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); min-width: 0;
}
.card > h2:first-child, .card > h3:first-child { margin-bottom: 10px; }
.sub { color: var(--muted); font-size: 14px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }

/* --- hlavní karta závodu --- */
.hero {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px);
  padding: 22px; display: grid; gap: 14px;
}
.hero::after { /* kontrolní kolečko jako vodoznak */
  content: ""; position: absolute; right: -40px; top: -40px; width: 220px; height: 220px;
  border: 14px solid var(--accent); border-radius: 50%; opacity: .09; pointer-events: none;
}
.hero .when { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; }
.countdown { font: 700 clamp(44px, 9vw, 64px)/1 var(--font-head); color: var(--accent); }
.countdown small { font-size: .38em; color: var(--ink-2); font-weight: 600; margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); font-size: 14px; font-weight: 600; color: var(--ink-2);
}
.chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 700; text-decoration: none; width: fit-content;
}
:root[data-theme="dark"] .btn { color: #1a0d15; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn { color: #1a0d15; } }

/* --- týden --- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 760px) { .week { grid-template-columns: 1fr; } }
.day {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface);
  display: grid; gap: 4px; align-content: start; min-height: 120px;
}
@media (max-width: 760px) { .day { min-height: 0; grid-template-columns: 74px 1fr; column-gap: 12px; } .day .what, .day .why { grid-column: 2; } }
.day .dname { font: 600 14px var(--font-head); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.day .kind { font-weight: 700; font-size: 15px; display: flex; gap: 6px; align-items: center; }
.day .kind i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.day .what { font-size: 14px; color: var(--ink-2); }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.day.past { opacity: .6; }
.day.race { background: var(--accent-soft); border-color: var(--accent); }
.k-rest { background: var(--line); }
.k-easy { background: var(--forest); }
.k-quality { background: var(--series-2); }
.k-map { background: var(--accent); }
.k-race { background: var(--accent); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.k-opt { background: var(--open); }

/* --- dlaždice čísel --- */
.tile .label { font-size: 14px; color: var(--muted); font-weight: 600; }
.tile .value { font: 700 34px/1.1 var(--font-head); margin-top: 2px; }
.tile .value small { font-size: 16px; color: var(--ink-2); font-weight: 600; margin-left: 3px; }
.tile .delta { font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.tile .delta b { color: var(--good); }
.tile svg { display: block; margin-top: 8px; width: 100%; height: 34px; }

/* --- zjištění --- */
.insight { border-left: 4px solid var(--accent); }
.insight .num { font: 700 26px var(--font-head); }
.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }

/* --- texty plánu --- */
.prose h3 { margin: 16px 0 6px; }
.prose ul { margin: 0 0 10px; padding-left: 20px; }
.prose li { margin-bottom: 4px; }
.prose li::marker { color: var(--accent); }
.voices { display: grid; gap: 10px; }
.voice { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); font: 700 15px var(--font-head); color: var(--ink);
  border: 2px solid var(--line);
}
.voice b { display: block; }
.voice p { margin: 2px 0 0; color: var(--ink-2); font-size: 15px; }
.decide { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.decide + .decide { margin-top: 8px; }
.redflag { border-left: 4px solid var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }

/* --- tabulky --- */
.tablewrap { overflow-x: auto; margin-inline: -4px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; position: sticky; top: 0; background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.me td { font-weight: 700; background: var(--accent-soft); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td.wrapc { white-space: normal; min-width: 180px; }
.ratio { display: inline-block; height: 8px; border-radius: 4px; background: var(--series-1); vertical-align: middle; }

/* --- grafy --- */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .lbl { fill: var(--ink-2); font-size: 12px; font-weight: 600; font-family: var(--font); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.dot { border-radius: 50%; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button {
  font: 600 14px var(--font); border: 0; background: transparent; color: var(--ink-2);
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

.tip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--paper);
  padding: 8px 10px; border-radius: 10px; font-size: 13px; line-height: 1.4; max-width: 260px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
.tip b { font-size: 15px; }

/* --- mezičasy --- */
.legs { display: grid; gap: 3px; margin-top: 10px; }
.leg { display: grid; grid-template-columns: 34px 1fr 64px; gap: 8px; align-items: center; font-size: 13px; }
.leg .bar { height: 12px; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.leg.mist .bar { background: var(--series-2); }
.leg .t { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
details.race-detail td { white-space: normal; }

.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.checklist input { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 3px; flex: none; }

.foot { display: flex; justify-content: space-between; gap: 10px; padding-block: 18px 28px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.foot a { color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  section.view { animation: fade .25s ease-out; }
  @keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}
