/* Season Manager - dark, simple. */
/* Outfit (SIL OFL, see fonts/OFL-Outfit.txt), self-hosted. */
@font-face { font-family: "Outfit"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/outfit-latin-ext-500.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Outfit"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/outfit-latin-500.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Outfit"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/outfit-latin-ext-600.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Outfit"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/outfit-latin-600.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Outfit"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/outfit-latin-ext-700.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Outfit"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/outfit-latin-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Outfit"; font-style: normal; font-weight: 800; font-display: swap; src: url("fonts/outfit-latin-ext-800.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Outfit"; font-style: normal; font-weight: 800; font-display: swap; src: url("fonts/outfit-latin-800.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
:root {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1c2029;
  --surface-3: #242935;
  --border: #2a303c;
  --border-strong: #3a4150;
  --text: #e7e9ee;
  --muted: #8d95a7;
  --faint: #5d6476;
  --accent: #5b9dff;
  --accent-strong: #3d84f5;
  --accent-soft: rgba(91, 157, 255, .14);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, .12);
  --ok: #4fd18b;
  --warn: #f5b84d;
  --gold: #f2c94c;
  --silver: #c4cbd8;
  --bronze: #d99a62;
  --dropped: #7fb2ff;
  --side-orange: #ffa112;
  --side-blue: #0059a6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --font: "Outfit", "Product Sans", "Google Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; color: var(--text); }
body { font: 500 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }

/* Carbon-fibre background. Pure CSS (CSP: no inline/external images). */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(27deg, #0b0c0e 5px, transparent 5px) 0 5px,
    linear-gradient(207deg, #0b0c0e 5px, transparent 5px) 10px 0,
    linear-gradient(27deg, #16181c 5px, transparent 5px) 0 10px,
    linear-gradient(207deg, #16181c 5px, transparent 5px) 10px 5px,
    linear-gradient(90deg, #101216 10px, transparent 10px),
    linear-gradient(#12141a 25%, #0f1115 25%, #0f1115 50%, transparent 50%, transparent 75%, #1a1d23 75%, #1a1d23);
  background-color: #0e1014;
  background-size: 20px 20px, 20px 20px, 20px 20px, 20px 20px, 20px 20px, 20px 20px;
}

/* ---------- Layout ---------- */
.topbar {
  position: static;
  display: flex; align-items: center; gap: 24px;
  height: 56px; padding: 0 24px;
  background: var(--side-orange); color: #1a1100;
  border-bottom: 1px solid #c97a00;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #1a1100; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { width: 22px; height: 22px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #4a3000; padding: 6px 12px; border-radius: var(--radius-sm); }
.nav a:hover { color: #1a1100; background: rgba(0, 0, 0, .12); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(0, 0, 0, .55); }
.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 80px; }
.page.wide { max-width: none; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head .spacer { flex: 1; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty h2 { color: var(--text); margin-bottom: 6px; }
.empty .btn { margin-top: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { color: var(--danger); border-color: rgba(255, 107, 107, .4); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 30px; padding: 0; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- Forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; }
label.field > span { color: var(--muted); font-size: 13px; }
.hint { color: var(--faint); font-size: 12.5px; }
input[type=text], input[type=search], input[type=url], input[type=email], input[type=password], input[type=number], input[type=date], input:not([type]), select, textarea {
  height: 36px; padding: 0 11px; width: 100%;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 110px; font-family: var(--mono); font-size: 13px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
select { padding-right: 28px; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.error-text { color: var(--danger); font-size: 13px; min-height: 1em; }

/* Toggle switch */
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 10px 0; border-top: 1px solid var(--border); }
.switch:first-child { border-top: 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { flex: none; width: 36px; height: 20px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; margin-top: 1px; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--accent-strong); border-color: var(--accent-strong); }
.switch input:checked + .track::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch .label { display: flex; flex-direction: column; }
.switch .label small { color: var(--faint); font-size: 12.5px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

/* ---------- Front page (logged out): welcome + login, views/auth.js + views/welcome.js ---------- */
.landing { min-height: 100vh; display: flex; flex-direction: column; }
.landing .topbar .spacer { flex: 1; }
.beta-badge { font-size: 12.5px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; white-space: nowrap; }
.landing-grid { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 48px 24px 40px;
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "intro auth" "more auth";
  column-gap: 48px; row-gap: 32px; align-content: start; }
.welcome-intro { grid-area: intro; }
.welcome-more { grid-area: more; display: flex; flex-direction: column; gap: 32px; }
.landing-auth { grid-area: auth; align-self: start; position: sticky; top: 24px; }
.landing-auth > .hint { text-align: center; margin-top: 14px; }
.auth-title { margin-bottom: 18px; }
.welcome-intro h1 { font-size: 34px; line-height: 1.15; margin-bottom: 14px; }
.welcome-intro .lead { font-size: 16.5px; color: var(--muted); max-width: 60ch; }
.welcome-more h3 { margin-bottom: 14px; }
.welcome-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.welcome-steps li { counter-increment: step; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px 14px 52px; position: relative; display: flex; flex-direction: column; gap: 4px; }
.welcome-steps li::before { content: counter(step); position: absolute; left: 14px; top: 14px; width: 26px; height: 26px;
  border-radius: 50%; background: var(--side-orange); color: #1a1100; font-weight: 800; display: grid; place-items: center; }
.welcome-steps li span { color: var(--muted); font-size: 13.5px; }
.faq { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.faq details + details { border-top: 1px solid var(--border); }
.faq summary { padding: 12px 16px; cursor: pointer; list-style: none; font-weight: 600; display: flex; gap: 10px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: '▸'; color: var(--faint); width: 10px; transition: transform .12s; }
.faq details[open] > summary::before { transform: rotate(90deg); }
.faq summary:hover { background: var(--surface-2); }
.faq details p { padding: 0 16px 14px 36px; color: var(--muted); }
.landing-foot { text-align: center; padding: 0 24px 24px; }
@media (max-width: 860px) {
  .landing-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "intro" "auth" "more"; padding-top: 28px; }
  .landing-auth { position: static; max-width: 420px; width: 100%; justify-self: center; }
  .welcome-intro h1 { font-size: 27px; }
}
.segmented { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; margin-bottom: 20px; }
.segmented button { flex: 1; height: 30px; border: 0; background: transparent; color: var(--muted); border-radius: 4px; font: inherit; cursor: pointer; }
.segmented button.active { background: var(--surface-3); color: var(--text); }

/* ---------- Season list ---------- */
.season-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.season-card { display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: border-color .12s, transform .12s; position: relative; }
.season-card:hover { border-color: var(--border-strong); }
.season-card h2 { padding-right: 34px; word-break: break-word; }
.season-card .meta { display: flex; gap: 14px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.season-card .leader { display: flex; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; }
.season-card .menu-btn { position: absolute; top: 12px; right: 10px; }
.progress { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }

/* Menus */
.menu { position: fixed; z-index: 60; min-width: 180px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 5px; box-shadow: var(--shadow); }
.menu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: transparent; color: var(--text); font: inherit; border-radius: 4px; cursor: pointer; }
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }

/* ---------- Season page ---------- */
.season-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; flex-wrap: wrap; }
.season-title { font-size: 22px; font-weight: 700; background: transparent; border: 1px solid transparent; color: var(--text); padding: 2px 8px; margin-left: -9px; border-radius: var(--radius-sm); min-width: 120px; width: auto; height: 38px; }
.season-title:hover { border-color: var(--border); }
.season-title:focus { border-color: var(--border-strong); background: var(--bg); }
.save-state { font-size: 12.5px; color: var(--faint); display: flex; align-items: center; gap: 6px; }
.save-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.save-state.pending::before { background: var(--warn); }
.save-state.error { color: var(--danger); }
.save-state.error::before { background: var(--danger); }
.history-btns { display: flex; gap: 2px; margin-left: auto; }
.history-btns .btn:disabled { opacity: .4; cursor: default; background: transparent; }
.tabs { display: flex; gap: 4px; margin: 10px 0 0; overflow-x: auto; }
.tabs a { padding: 8px 16px; color: #4a3000; border-radius: var(--radius-sm); white-space: nowrap; }
.tabs a:hover { color: #1a1100; background: rgba(0, 0, 0, .12); text-decoration: none; }
.tabs a.active { color: #fff; background: var(--side-blue); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child > td { border-bottom: 0; }
th { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface); position: sticky; top: 0; z-index: 2; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.c, th.c { text-align: center; }
tbody tr:hover > td:not(.wk):not([class*="wk-"]) { background: rgba(255, 255, 255, .02); }
.sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); }
th.sticky-col { z-index: 3; }
tbody tr:hover > td.sticky-col { background: #1a1d25; }
.pos { width: 44px; font-weight: 700; text-align: center; }
.pos-1 { color: var(--gold); }
.pos-2 { color: var(--silver); }
.pos-3 { color: var(--bronze); }
.total { font-weight: 700; font-size: 15px; }
.before-drops { color: var(--faint); font-weight: 500; font-size: 10px; margin-left: 4px; }
.cell-dropped { color: var(--dropped); font-style: italic; opacity: .75; }
.cell-zero { color: var(--faint); }
.driver-name { font-weight: 600; }
.venue-abbr { display: block; font-size: 10.5px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--faint); }
.team-name { color: var(--muted); }
.legend { display: flex; gap: 18px; color: var(--faint); font-size: 12.5px; margin-top: 10px; flex-wrap: wrap; }
.legend .cell-dropped { opacity: 1; }
.section-gap { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }

/* ---------- Results grid ---------- */
.results-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.results { width: auto; }
.results th, .results td { padding: 0; border-right: 1px solid var(--border); }
.results th { text-transform: none; letter-spacing: 0; font-size: 13px; }
.results .driver-cell { padding: 0 12px; min-width: 170px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.results .driver-cell small { display: block; color: var(--faint); font-size: 11.5px; line-height: 1.2; }
.results .round-head { padding: 8px 8px 6px; vertical-align: top; min-width: 128px; }
.results .round-head .rn { display: flex; gap: 10px; white-space: nowrap; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.results .round-head .rn-end { display: flex; gap: 6px; align-items: center; }
.results .round-head .round-sort { border: 1px solid transparent; background: transparent; color: inherit; font: inherit; font-size: 12px; line-height: 1; padding: 2px 4px; border-radius: 4px; cursor: pointer; opacity: .6; }
.results .round-head .round-sort:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
.results .round-head .round-sort.on { opacity: 1; background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.results .round-head input, .results .round-head select { display: block; height: 26px; font-size: 12.5px; padding: 0 6px; background: var(--surface-2); border-color: var(--border); }
.results .round-head select { margin-top: 4px; background-position: calc(100% - 12px) 11px, calc(100% - 7px) 11px; padding-right: 20px; }
.rc { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; align-items: center; gap: 2px 6px; padding: 6px 8px; }
.rc .p { grid-row: span 2; width: 40px; height: 32px; text-align: center; padding: 0; font-weight: 700; background: var(--bg); border-color: var(--border); font-variant-numeric: tabular-nums; }
.rc .p.code { font-size: 11px; color: var(--warn); }
.rc .p.shared { border-color: var(--warn); }
.rc .p.invalid { border-color: var(--danger); }
.rc .flags { display: flex; gap: 3px; }
.rc .flag { height: 17px; padding: 0 5px; font-size: 10.5px; font-weight: 700; border-radius: 3px; border: 1px solid var(--border); background: transparent; color: var(--faint); cursor: pointer; line-height: 1; }
.rc .flag:hover { color: var(--text); border-color: var(--border-strong); }
.rc .flag.on.pole { background: rgba(242, 201, 76, .18); border-color: rgba(242, 201, 76, .55); color: var(--gold); }
.rc .flag.ret { padding: 0 4px; }
.rc .flag.on.ret { background: rgba(239, 207, 255, .14); border-color: rgba(239, 207, 255, .5); color: #efcfff; }
.rc .flag.on.fl { background: rgba(176, 124, 255, .18); border-color: rgba(176, 124, 255, .55); color: #c6a3ff; }
.rc .flag.on.led, .rc .flag.on.mostLed { background: rgba(77, 171, 247, .16); border-color: rgba(77, 171, 247, .55); color: #74c0fc; }
.rc .pts { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.2; }
.rc .pts.dropped { color: var(--dropped); font-style: italic; }
.rc .adj { grid-column: 1 / -1; height: 22px; font-size: 11.5px; padding: 0 5px; margin-top: 3px; background: var(--bg); border-color: var(--border); }
.rc .adj.neg { color: var(--danger); }
.rc .adj.pos { color: var(--ok); }
.results tbody td.summary { padding: 0 12px; text-align: right; font-variant-numeric: tabular-nums; }
.results tbody td.summary.total { font-weight: 700; }
.results thead th.summary { padding: 8px 12px; text-align: right; vertical-align: bottom; }
.results-tools { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.results-tools .spacer { flex: 1; }
.sort-select { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 2px 0 10px; font-size: 13px; color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.sort-select select { height: 26px; width: auto; border: 0; background-color: transparent; color: var(--text); font-size: 13px; padding-left: 4px; }

/* ---------- Lists (drivers, rounds, drop rules) ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: grid; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .idx { color: var(--faint); font-variant-numeric: tabular-nums; text-align: right; }
.drivers-list .list-row { grid-template-columns: 28px minmax(140px, 2fr) minmax(120px, 1.5fr) auto; }
.team-changes { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; margin-top: -2px; }
.team-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 9px; border-radius: 12px; background: var(--accent-soft); color: var(--text); }
.team-chip strong { color: var(--accent); font-weight: 700; }
.chip-x { display: inline-flex; padding: 2px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.chip-x:hover { color: var(--danger); background: var(--danger-soft); }
.team-switch { font-size: 10.5px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; margin: -2px 0 3px; }
/* Every row is its own grid: only fixed / capped tracks before the flexible extras column keep the rows aligned.
   Venue + track are capped, the space to the right goes to optional per-round fields (.round-extras, e.g. "Sprint of"). */
.rounds-list .list-row { grid-template-columns: 28px minmax(140px, 280px) minmax(130px, 250px) 54px 64px 150px 130px minmax(0, 1fr) auto; }
.rounds-list.with-sprint .list-row { grid-template-columns: 28px minmax(140px, 280px) minmax(130px, 250px) 54px 64px 150px 130px auto minmax(0, 1fr) auto; }
.rounds-list .sprint-check { white-space: nowrap; }
.rounds-list .round-extras { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.rounds-list .sprint-of { width: 220px; max-width: 100%; }
.rounds-list .results-count { font-size: 12px; width: 74px; text-align: right; margin-right: 6px; white-space: nowrap; }
.rounds-list .sprint-row .idx { color: var(--muted); }
.abbr-in { text-transform: uppercase; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: .05em; }
.abbr-in::placeholder { text-transform: uppercase; }
.drop-list .list-row { grid-template-columns: auto 80px auto 80px auto 1fr auto; }
.row-actions { display: flex; gap: 2px; }
.dup { border-color: var(--warn) !important; }

/* Points table editor */
.points-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.points-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--faint); }
.points-grid input { height: 32px; text-align: center; padding: 0 4px; }
.points-preview { display: flex; flex-wrap: wrap; gap: 4px; }
.points-preview span { font-size: 12px; padding: 1px 7px; border-radius: 10px; background: var(--surface-3); color: var(--muted); font-variant-numeric: tabular-nums; }
.ps-list .list-row { grid-template-columns: minmax(160px, 1fr) 3fr auto; }
.ps-tree + .ps-tree, .ps-folder + .ps-folder, .ps-folder + .ps-list { margin-top: 6px; }
.ps-folder { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.ps-folder > summary { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; list-style: none; user-select: none; }
.ps-folder > summary::-webkit-details-marker { display: none; }
.ps-folder > summary::before { content: '▸'; color: var(--faint); width: 10px; transition: transform .12s; }
.ps-folder[open] > summary::before { transform: rotate(90deg); }
.ps-folder > summary:hover { background: var(--surface-3); border-radius: var(--radius-sm); }
.ps-folder > summary .spacer { flex: 1; }
.ps-folder-icon { color: var(--accent); display: inline-flex; }
.ps-folder-body { padding: 4px 12px 8px 22px; background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.ps-folder-body > .ps-tree > .ps-folder:first-child { margin-top: 6px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* ---------- Wikipedia-style results matrix ---------- */
:root {
  --wk-text: #202122;
  --wk-gold: #ffffbf;
  --wk-silver: #dfdfdf;
  --wk-bronze: #ffdf9f;
  --wk-pts: #dfffdf;
  --wk-cls: #cfcfff;
  --wk-ret: #efcfff;
  --wk-dnq: #ffcfcf;
  --wk-dsq: #000000;
  --wk-dns: #ffffff;
}
.view-switch { margin: 0; width: auto; }
.view-switch button { padding: 0 14px; }
.wk-layout { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.wk-wrap { flex: 1 1 560px; min-width: 0; background: var(--surface); }
.wk-table { border-collapse: separate; border-spacing: 0; width: auto; min-width: 100%; }
.wk-table th, .wk-table td { border-bottom: 1px solid var(--bg); border-right: 1px solid var(--bg); padding: 0; }
.wk-table th { padding: 7px 4px; text-align: center; font-size: 11.5px; letter-spacing: .02em; }
.wk-table tbody tr:hover > td.wk-pos, .wk-table tbody tr:hover > td.wk-name { background: var(--surface-3); }
.wk-table tbody tr:hover > td.wk { box-shadow: inset 0 0 0 100px rgba(0, 0, 0, .06); }
.wk-table .wk-pos { width: 44px; min-width: 44px; text-align: center; font-weight: 700; background: var(--surface); }
.wk-table .wk-name { padding: 6px 12px; text-align: left; background: var(--surface); min-width: 150px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-table td.wk-name { font-weight: 600; }
.wk-table td.wk-name small { display: block; color: var(--faint); font-size: 11.5px; font-weight: 500; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.wk-table th.wk-name { text-align: left; }
.sticky-col-2 { position: sticky; left: 44px; z-index: 1; }
th.sticky-col-2 { z-index: 3; }
.wk-table .wk-round { min-width: 40px; }
.wk-table .wk-points { padding: 6px 12px; text-align: center; font-weight: 700; font-size: 15px; background: var(--surface-3); font-variant-numeric: tabular-nums; min-width: 62px; }
.wk-table th.wk-points { font-size: 11.5px; font-weight: 700; background: var(--surface); }
.wk-table td.wk-points small { display: block; font-size: 9.5px; font-weight: 500; color: var(--faint); }
.wk { text-align: center; font-weight: 600; font-size: 13px; color: var(--wk-text); padding: 7px 5px; min-width: 40px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.wk sup { font-size: 9px; font-weight: 700; margin-left: 1px; vertical-align: 5px; line-height: 0; }
.wk-gold { background: var(--wk-gold); }
.wk-silver { background: var(--wk-silver); }
.wk-bronze { background: var(--wk-bronze); }
.wk-pts { background: var(--wk-pts); }
.wk-cls { background: var(--wk-cls); }
.wk-ret { background: var(--wk-ret); }
.wk-dnq { background: var(--wk-dnq); }
.wk-dsq { background: var(--wk-dsq); color: #fff; }
.wk-dns { background: var(--wk-dns); }
.wk-empty { background: transparent; }
.wk-none { background: transparent; color: var(--muted); }
.wk-dropped { font-style: italic; opacity: .7; }
.wk-alt { color: #c6a3ff; font-size: 9px; font-weight: 700; margin-left: 2px; }
.wk-stack { vertical-align: top; }
.wk-stack .wk { display: block; padding: 4px 5px; border-bottom: 1px solid var(--bg); }
.wk-stack .wk:last-child { border-bottom: 0; }
.wk-stack .wk-empty { min-height: 26px; }
.wk-blank { background: transparent; color: var(--text); }
/* Key box, laid out like Wikipedia's F1 results key */
.wk-key-wrap { flex: 0 0 auto; max-width: 100%; }
.wk-key-wrap .hint { max-width: 272px; margin-top: 8px; }
.wk-key { width: 272px; border-collapse: collapse; font-size: 13px; line-height: 1.35; background: var(--surface); }
.wk-key th, .wk-key td { border: 1px solid #54595d; padding: 4px 7px; white-space: normal; text-align: left; position: static; }
.wk-key th { background: #27292d; color: var(--text); font-weight: 700; text-align: center; font-size: 13.5px; text-transform: none; letter-spacing: 0; font-size: 13px; }
.wk-key .wk-key-title { padding: 5px 7px; }
.wk-key td { color: var(--wk-text); vertical-align: middle; }
.wk-key td.wk-blank, .wk-key td:not([class]), .wk-key td.wk-key-link { color: var(--text); background: var(--surface); }
.wk-key td.wk-dsq { color: #fff; }
.wk-key .wk-key-colour { width: 74px; }
.wk-key td.wk-key-link { color: #88a3e8; }
@media (max-width: 900px) { .wk-key-wrap { flex: 1 1 100%; } }

/* ---------- Sprint / second points system ---------- */
.alt-tag { margin-left: 6px; font-size: 10px; padding: 0 6px; background: rgba(176, 124, 255, .16); color: #c6a3ff; text-transform: uppercase; letter-spacing: .04em; }
.results .round-head.alt { background: rgba(176, 124, 255, .06); }
.alt-mark { display: inline-block; margin-left: 3px; font-size: 9.5px; font-weight: 700; line-height: 14px; width: 14px; text-align: center; border-radius: 3px; background: rgba(176, 124, 255, .2); color: #c6a3ff; vertical-align: 1px; }
.results tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--surface-2); border-top: 1px solid var(--border-strong); border-bottom: 0; }
.results tfoot td.sticky-col { z-index: 4; padding: 8px 12px; font-weight: 600; }
.results tfoot td.sticky-col small a { color: var(--faint); }
.results tfoot td.sticky-col small a:hover { color: var(--accent); }
.results tfoot .alt-cell { padding: 8px; }
.results tfoot .alt-cell .check { font-size: 12.5px; color: var(--muted); }
.results tfoot .alt-cell.on .check { color: #c6a3ff; }

/* ---------- Position check (Results tab) ---------- */
.btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.rc .p.dup-pos { border-color: var(--danger); background: var(--danger-soft); }
.results tfoot .check-row td.sticky-col small { display: block; color: var(--faint); font-weight: 500; font-size: 11px; }
.results tfoot .check-cell { padding: 7px 8px; font-size: 12px; line-height: 1.35; vertical-align: top; white-space: nowrap; }
.results tfoot .check-cell > span { display: inline-block; vertical-align: top; }
.check-icon { width: 16px; height: 16px; margin-right: 6px; border-radius: 50%; text-align: center; font-size: 10.5px; font-weight: 700; line-height: 16px; }
.results tfoot .check-cell.is-ok { color: var(--ok); }
.check-cell.is-ok .check-icon { background: rgba(79, 209, 139, .16); }
.results tfoot .check-cell.is-bad { color: var(--danger); background: #2a1c22; }
.check-cell.is-bad .check-icon { background: var(--danger); color: var(--bg); }
.results tfoot .check-cell.is-empty { color: var(--faint); }
.results tfoot tr:not(:last-child) td { bottom: auto; }

/* ---------- Results import ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 28px 16px; text-align: center; color: var(--muted);
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); cursor: pointer; transition: border-color .12s, background .12s; }
.dropzone strong { color: var(--accent); }
.dropzone small { color: var(--faint); font-size: 12.5px; margin-top: 6px; max-width: 460px; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.busy { opacity: .6; pointer-events: none; }
.import-options { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; flex-wrap: wrap; }
.check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent-strong); }
.check select { width: auto; height: 30px; }
.check input.num-input { width: 64px; height: 30px; text-align: right; }
.import-race { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.import-race.skipped { opacity: .55; }
.import-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.import-head select { width: auto; max-width: 100%; }
.import-head .faint { font-size: 12.5px; }
.import-details summary { cursor: pointer; color: var(--muted); padding: 2px 0 8px; }
.import-table td { padding: 5px 10px; vertical-align: middle; }
.import-table td small { display: block; font-size: 11.5px; }
.import-table select { height: 30px; font-size: 13px; min-width: 200px; }
.import-table tr.skipped td:not(:last-child) { opacity: .4; }
.wiki-pick { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; border-top: 1px solid var(--border); }
.wiki-url { display: flex; gap: 8px; }
.wiki-url input { flex: 1; min-width: 0; }
.wiki-round-tools select { width: auto; height: 30px; max-width: 260px; }
.wiki-rounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.wiki-round { gap: 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; flex-wrap: nowrap; }
.wiki-round:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.wiki-round.empty { opacity: .55; }
.wiki-round-n { color: var(--faint); font-size: 11.5px; min-width: 1.6em; text-align: right; }
.wiki-round small { font-size: 11px; }
.import-table .warn { color: var(--warn); }
.fl-mark { color: #c6a3ff; }
.import .table-wrap { max-height: 340px; overflow: auto; }

/* ---------- Dialog ---------- */
dialog { padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog.wide { width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(5, 6, 8, .7); }
dialog .dlg-body { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
dialog .dlg-body > p { color: var(--muted); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface-3); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow); max-width: 360px; animation: toast-in .18s ease-out; }
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 720px) {
  .topbar { padding: 0 14px; gap: 12px; }
  .brand span { display: none; }
  .page { padding: 20px 14px 60px; }
  .drivers-list .list-row { grid-template-columns: 22px 1fr auto; }
  .drivers-list .list-row .team-in { grid-column: 2; }
  .rounds-list .list-row { grid-template-columns: 22px 1fr auto; }
  .rounds-list.with-sprint .list-row { grid-template-columns: 22px 1fr auto; }
  .rounds-list .list-row > :nth-child(n+3) { grid-column: 2; }
  .rounds-list .list-row > .row-actions { grid-column: 3; grid-row: 1; }
  .rounds-list .round-extras:empty { display: none; }
}

/* ---------- Multiclass racing (views/season/classes.js) ---------- */
.class-chip { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 12px; font-weight: 700;
  color: #fff; background: var(--cls, #868e96); white-space: nowrap; letter-spacing: .02em; }
.class-jump { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -6px 0 16px; font-size: 13px; }
.class-jump a .class-chip { cursor: pointer; }
.class-head { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; scroll-margin-top: 70px; }
.class-head h3 { margin: 0; }
.class-section + .class-section { margin-top: 8px; }
table.results tr.class-head-row > td { background: var(--surface-2); border-top: 2px solid var(--cls, var(--border-strong)); padding-top: 8px; padding-bottom: 8px; }
table.results tr.class-head-row > td small { margin-left: 8px; color: var(--muted); }
table.results tr.in-class > td.driver-cell { box-shadow: inset 3px 0 0 var(--cls, transparent); }
select.class-in { width: 130px; flex: none; box-shadow: inset 4px 0 0 var(--cls, transparent); }
select.class-in.no-class { color: var(--muted); }
.class-row input[type=color] { width: 38px; height: 32px; padding: 2px; flex: none; background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; }
.class-list .list-row { grid-template-columns: 38px minmax(100px, 1fr) minmax(140px, 1.5fr) auto auto; }
.drivers-list.with-class .list-row { grid-template-columns: 28px minmax(140px, 2fr) minmax(120px, 1.5fr) 130px auto; }
@media (max-width: 720px) {
  .class-list .list-row { grid-template-columns: 38px 1fr auto; }
  .class-list .list-row select { grid-column: 1 / -1; }
  .drivers-list.with-class .list-row { grid-template-columns: 22px 1fr auto; }
  .drivers-list.with-class .list-row .class-in { grid-column: 2; width: 100%; }
}
.wiki-mode { margin: 12px 0 8px; }
.wiki-classes { margin-bottom: 12px; }
.wiki-import-mode { margin: 12px 0 4px; gap: 6px; }
.wiki-import-mode .row { align-items: center; gap: 12px; }
.wiki-import-mode .segmented { margin-bottom: 0; flex: 1; max-width: 480px; }
.wiki-import-mode .hint { margin: 0; }
.wiki-class-row { display: grid; grid-template-columns: 1fr auto 160px; gap: 10px; align-items: center; }
@media (max-width: 720px) { .wiki-class-row { grid-template-columns: 1fr; } }
.class-list .list-row .faint { white-space: nowrap; }
@media (max-width: 720px) { .card-head { flex-wrap: wrap; } }

/* Standings tables (drivers, teams): blue headline bar + blue frame; table body stays Wikipedia dark style. */
.table-wrap.blue-frame { background: color-mix(in srgb, var(--side-blue) 38%, var(--bg)); border-color: var(--side-blue); padding: 6px; }
.blue-frame thead th, .blue-frame th.wk-points, .blue-frame th.wk-pos, .blue-frame th.wk-name { background: var(--side-blue); color: #fff; }
.topbar .btn.ghost { color: #1a1100; }
.topbar .btn.ghost:hover { color: #1a1100; background: rgba(0, 0, 0, .12); }

/* Season page: orange bar around title + tabs, selected tab blue. */
.season-bar { background: var(--side-orange); color: #1a1100; border-radius: var(--radius); padding: 12px 16px 12px; margin-bottom: 22px; }
.season-bar .season-head { margin-bottom: 0; }
.season-bar .season-title { color: #1a1100; background: transparent; }
.season-bar .season-title:hover { border-color: rgba(0, 0, 0, .3); }
.season-bar .season-title:focus { border-color: rgba(0, 0, 0, .55); background: rgba(255, 255, 255, .35); }
.season-bar .btn.ghost, .season-bar .save-state { color: #1a1100; }
.season-bar .btn.ghost:hover { color: #1a1100; background: rgba(0, 0, 0, .12); }
.season-bar .save-state.error { color: #8a0000; }

/* Other season tabs (Results, Drivers, Rounds, Settings): same blue design as the standings tables. */
.season-body .card { background: color-mix(in srgb, var(--side-blue) 38%, var(--bg)); border-color: var(--side-blue); overflow: hidden; }
.season-body .card-head { background: var(--side-blue); color: #fff; margin: -20px -20px 16px; padding: 12px 20px; }
.season-body .card-head h2, .season-body .card-head h3 { color: #fff; }
.season-body .results-wrap { background: color-mix(in srgb, var(--side-blue) 38%, var(--bg)); border-color: var(--side-blue); }
.season-body .results thead th { background: var(--side-blue); color: #fff; }
.season-body .results thead th .rn { color: rgba(255, 255, 255, .8); }

/* Seasons overview: blue cards with headline bar. */
.season-card { background: color-mix(in srgb, var(--side-blue) 38%, var(--bg)); border-color: var(--side-blue); overflow: hidden; }
.season-card:hover { border-color: var(--accent); }
.season-card h2 { background: var(--side-blue); color: #fff; margin: -18px -18px 0; padding: 14px 52px 14px 18px; }
.season-card .menu-btn { color: #fff; top: 8px; }
.season-card .menu-btn:hover { background: rgba(255, 255, 255, .15); color: #fff; }
.season-card .meta { color: rgba(255, 255, 255, .75); }
.season-card .leader { border-top-color: rgba(255, 255, 255, .18); }
.season-card .progress { background: rgba(0, 0, 0, .35); }

/* Black outline on white text (readability on blue/dark bars). stroke is painted behind the fill. */
.blue-frame thead th, .blue-frame th.wk-points, .blue-frame th.wk-pos, .blue-frame th.wk-name,
.season-body .card-head, .season-body .card-head h2, .season-body .card-head h3,
.season-body .results thead th,
.season-card h2, .season-card .menu-btn,
.tabs a.active, .nav a.active, .btn.primary {
  -webkit-text-stroke: 2px #000;
  paint-order: stroke fill;
}

/* Round flags */
.wk-flag { display: block; width: 22px; height: 16px; object-fit: cover; margin: 3px auto 0; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55); }
.flag-btn { padding: 0; width: 54px; justify-content: center; }
.flag-btn.auto { border-style: dashed; }
.flag-btn img { width: 28px; height: 21px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55); }
.flag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 12px 0; max-height: 52vh; overflow-y: auto; }
.flag-tile { display: flex; align-items: center; gap: 8px; text-align: left; padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.flag-tile:hover { border-color: var(--side-blue); background: var(--surface-3); }
.flag-tile.active { border-color: var(--side-orange); box-shadow: inset 0 0 0 1px var(--side-orange); }
.flag-tile img, .flag-tile .flag-none { flex: none; width: 28px; height: 21px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55); }
.flag-tile .flag-none { display: grid; place-items: center; background: var(--surface); color: var(--muted); font-weight: 700; }
.flag-tile span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Season progression charts (views/season/progression.js) ---------- */
.prog-title { margin: 18px 0 8px; }
.prog-wrap { padding: 8px 4px; margin-bottom: 6px; }
.prog-chart { display: block; font: 500 12px var(--font); }
.prog-grid line { stroke: var(--border); stroke-width: 1; }
.prog-axis text { fill: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.prog-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.prog-hit { fill: none; stroke: transparent; stroke-width: 12; }
.prog-series circle { stroke: var(--surface); stroke-width: 2; }
.prog-series, .prog-label { cursor: pointer; transition: opacity .12s; }
.prog-label-hit { fill: transparent; }
.prog-pos { fill: var(--muted); font-variant-numeric: tabular-nums; }
.prog-name { fill: var(--text); }
.prog-chart.has-focus .prog-series:not(.on), .prog-chart.has-focus .prog-label:not(.on) { opacity: .15; }
.prog-series.on .prog-line { stroke-width: 3.5; }
.prog-series.on circle { r: 5; }
.prog-label.on .prog-label-hit { fill: var(--surface-3); }

/* Race results (HTML export, views/season/race-results.js): one blue card per round. */
.race-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; align-items: start; }
.race-card { background: color-mix(in srgb, var(--side-blue) 38%, var(--bg)); border: 1px solid var(--side-blue); border-radius: var(--radius); overflow: hidden; scroll-margin-top: 70px; }
.race-head { display: flex; align-items: center; gap: 10px; background: var(--side-blue); color: #fff; padding: 10px 14px; }
.race-head .wk-flag { margin: 0; flex: none; }
.race-no { font-weight: 800; font-size: 13px; background: rgba(0, 0, 0, .35); border-radius: 4px; padding: 1px 7px; flex: none; }
.race-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.race-title strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; -webkit-text-stroke: 2px #000; paint-order: stroke fill; }
.race-title small { color: rgba(255, 255, 255, .78); font-size: 12px; }
.race-class { padding: 10px 12px 2px; }
.race-track { padding: 9px 14px 0; font-size: 13px; }
.race-table { width: 100%; }
.race-table th { position: static; background: transparent; padding: 7px 10px; }
.race-table td { padding: 4px 10px; border-bottom-color: rgba(255, 255, 255, .06); }
.race-table td.wk { width: 48px; min-width: 48px; padding: 4px 5px; border-bottom: 1px solid var(--bg); }
.race-table th.race-pos { width: 48px; text-align: center; }
.race-table td.team-name { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.race-table tbody tr:last-child td { border-bottom: 0; }
.export-options { gap: 0; margin: 14px 0 6px; }

/* Export page (HTML file and PDF print, views/season/export-page.js). */
.export-root .topbar { position: sticky; top: 0; z-index: 20; }
.export-root .topbar .nav a { white-space: nowrap; }
.export-bar { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; padding: 14px 18px; }
.export-bar h1 { color: #1a1100; font-size: 24px; }
.export-facts { color: #4a3000; font-weight: 600; }
.export-section { scroll-margin-top: 70px; }
.export-section + .export-section { margin-top: 44px; }
.export-title { font-size: 21px; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--side-orange); }
.export-section .class-head, .export-section [id] { scroll-margin-top: 70px; }
.export-foot { margin-top: 48px; font-size: 12.5px; text-align: center; }
.race-winner { color: rgba(255, 255, 255, .78); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.race-winner b { color: #fff; font-weight: 700; }
/* Standings tab: collapsible cards (<details>), collapsed = header only. */
details.race-card > summary { cursor: pointer; list-style: none; user-select: none; }
details.race-card > summary::-webkit-details-marker { display: none; }
details.race-card > summary:hover { background: color-mix(in srgb, var(--side-blue) 82%, #fff); }
details.race-card > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.race-chevron { margin-left: auto; flex: none; width: 9px; height: 9px; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(45deg); margin-top: -4px; transition: transform .15s; }
details.race-card[open] .race-chevron { transform: rotate(-135deg); margin-top: 4px; }
.race-results-panel .section-head { align-items: center; }

/* PDF export (views/season/export-pdf.js): html.printing = the export page is in .print-root, waiting for
   the print dialog. On screen it sits off-canvas at the printed width, laid out exactly as printed, so
   export-pdf.js can measure it (scale wide tables, mark blocks that fit on a page as .print-keep);
   in print it is the only thing shown, dark like the site, A4 landscape. A normal Ctrl+P is unaffected. */
.print-root { display: none; }
html.printing .print-root { display: block; position: absolute; left: -20000px; top: 0; width: 1060px; }
html.printing .print-root .topbar { display: none; } /* section links only help in the HTML file */
html.printing .print-root .page { max-width: none; padding: 0; }
html.printing .print-root .export-bar { margin-bottom: 16px; }
html.printing .print-root .class-jump { display: none; }
/* The key stays beside the matrix, the matrix scales to fit. */
html.printing .print-root .wk-layout { flex-wrap: nowrap; }
html.printing .print-root .wk-wrap { flex: 1 1 auto; }
html.printing .print-root .wk-key-wrap { flex: 0 0 auto; }
html.printing .print-root .wk-key { font-size: 11px; line-height: 1.25; width: 250px; }
html.printing .print-root .wk-key th, html.printing .print-root .wk-key td { padding: 2px 6px; font-size: 11px; }
html.printing .print-root .wk-key-wrap .hint { max-width: 250px; font-size: 11px; }
/* Race results: three compact cards per row; inline-blocks never split across pages. A card taller than
   a page (big multiclass fields) gets the full width and may break between rows. */
html.printing .print-root .race-grid { display: block; }
html.printing .print-root .race-card { display: inline-block; width: calc((100% - 20px) / 3); margin: 0 10px 10px 0; vertical-align: top; }
html.printing .print-root .race-card:nth-child(3n) { margin-right: 0; }
html.printing .print-root .race-card.print-tall { display: block; width: auto; margin-right: 0; }
html.printing .print-root .race-head { padding: 7px 10px; }
html.printing .print-root .race-table th { padding: 4px 8px; }
html.printing .print-root .race-table td { padding: 2px 8px; font-size: 12px; }
html.printing .print-root .race-table td.wk { padding: 2px 4px; width: 38px; min-width: 38px; }
html.printing .print-root .race-table td.team-name { max-width: 110px; }
html.printing .print-root .race-table .total { font-size: 13px; }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  html.printing, html.printing body { background: var(--bg) !important; min-height: 0; }
  html.printing * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html.printing body::before { display: none; }
  html.printing body > :not(.print-root) { display: none !important; }
  html.printing .print-root { position: static; width: auto; }
  .print-root .table-wrap { overflow: visible; }
  .print-root th, .print-root .sticky-col, .print-root .sticky-col-2 { position: static; }
  .print-root .export-section + .export-section { break-before: page; margin-top: 0; }
  .print-root tr, .print-root .print-keep, .print-root .wk-key-wrap { break-inside: avoid; }
  .print-root .export-title, .print-root .section-head, .print-root .class-head, .print-root .prog-title, .print-root .race-head { break-after: avoid; }
  .print-root .export-foot { margin-top: 20px; }
}

/* What-if indicators (views/season/what-if.js) */
.wi-summary { margin: 0 0 10px; color: var(--muted); font-size: 13px; cursor: help; }
.wi-summary strong { color: var(--text); }
.wi-good { color: var(--ok); font-weight: 700; }
.wk-table .wi-col, .wk-table td.wi-max, .wk-table td.wi-title { min-width: 58px; font-size: 12.5px; }
.wk-table td.wi-max { color: var(--muted); }
td.wi-max { color: var(--muted); }
td.wi-title { white-space: nowrap; }
.wi-badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.wi-clinched { background: rgba(79, 209, 139, .16); color: var(--ok); }
.wi-out { background: var(--danger-soft); color: var(--danger); }
.wi-need { color: var(--text); font-weight: 700; }
.wi-gap { color: var(--muted); }
.wi-when, .wk-table td.wk-points small.wi-when { display: inline; color: var(--muted); font-weight: 400; font-size: 11.5px; }
tr.wi-row-out > td.wk-name, tr.wi-row-out > td.driver-name, tr.wi-row-out > td.team-name { opacity: .55; }
.wi-champion { margin-left: 8px; background: rgba(242, 201, 76, .16); color: var(--gold); vertical-align: 1px; white-space: nowrap; }

/* Guest drivers (views/season/guests.js) */
.guest-tag { display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--border-strong);
  color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; vertical-align: 1px; white-space: nowrap; }
.wk-name .guest-tag, .driver-cell .guest-tag { margin-left: 6px; }
tr.guest-row > td.wk-name, tr.guest-row > td.driver-name, tr.guest-row > td.team-name, tr.guest-row > td.pos, tr.guest-row > td.wk-pos { opacity: .6; font-style: italic; }
.guest-check { display: inline-flex; align-items: center; gap: 5px; margin-right: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.guest-mode { margin-bottom: 0; max-width: 420px; }

/* Driver highlight (views/season/highlight.js; keys = SeasonDocument::HIGHLIGHTS). Tint as a background-image layer so
   the cell keeps its (sticky / hover) background colour underneath; name text in the colour. */
.hl-red { --hl: #ff6b6b; --hl-bg: rgba(255, 107, 107, .20); }
.hl-orange { --hl: #ffa94d; --hl-bg: rgba(255, 169, 77, .20); }
.hl-yellow { --hl: #ffd43b; --hl-bg: rgba(255, 212, 59, .17); }
.hl-green { --hl: #51cf66; --hl-bg: rgba(81, 207, 102, .18); }
.hl-cyan { --hl: #3bc9db; --hl-bg: rgba(59, 201, 219, .18); }
.hl-blue { --hl: #74a9ff; --hl-bg: rgba(116, 169, 255, .20); }
.hl-purple { --hl: #b197fc; --hl-bg: rgba(177, 151, 252, .20); }
.hl-pink { --hl: #f783ac; --hl-bg: rgba(247, 131, 172, .20); }
td.hl { background-image: linear-gradient(var(--hl-bg), var(--hl-bg)) !important; color: var(--hl); }
input.hl { color: var(--hl); box-shadow: inset 4px 0 0 var(--hl); }
.hl-name { color: var(--hl); }
.hl-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--hl); flex: none; }
.hl-swatch.none { background: transparent; border: 1.5px dashed var(--border-strong); }
.hl-item { display: inline-flex; align-items: center; gap: 8px; }

/* Share dialog (views/season/share.js) and the public share page (assets/js/share.js). */
.share-row { display: flex; gap: 10px; }
.share-row .share-url { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; }
.share-actions { flex-wrap: wrap; }

/* Round slider (Standings tab, views/season/round-slider.js): rewind the standings to an earlier round.
   Switch + caption in the "Drivers" heading row; the control itself is an orange marker in the drivers table. */
.standings-head { align-items: center; flex-wrap: wrap; }
.round-slider { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; flex: 1 1 auto; min-width: 0; margin-left: 8px; }
.round-slider[hidden], .round-slider-row[hidden] { display: none !important; }
.round-slider .switch { padding: 0; border-top: 0; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.round-slider .switch .track { margin-top: 0; }
.round-slider-row { display: flex; align-items: center; gap: 10px; flex: none; }
.round-caption { flex: none; width: 190px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; transition: opacity .15s; }
.round-caption.loading { opacity: .5; }
:root { --rewind: #ff6a1a; }
.rw-wrap { position: relative; }
.rw-head { cursor: ew-resize; user-select: none; touch-action: none; }
/* Wide transparent grab strip; the orange line is ::before, the knob sits in the blue header bar.
   z-index 2 + later in the DOM: above the round headers, below the sticky Pos / Driver columns (3). */
.rw-marker { position: absolute; z-index: 2; width: 18px; margin-left: -9px; cursor: ew-resize; touch-action: none; outline: none; }
.rw-marker[hidden] { display: none; }
.rw-marker::before { content: ''; position: absolute; left: 7.5px; top: 0; bottom: 0; width: 3px; border-radius: 2px; background: var(--rewind); box-shadow: 0 0 6px rgba(255, 106, 26, .45); }
.rw-knob { position: absolute; left: 1px; top: -2px; width: 16px; height: 16px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--rewind); box-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.rw-marker:focus-visible .rw-knob { outline: 2px solid #fff; outline-offset: 1px; }
/* Rounds after the marker: greyed out (results stay readable underneath). */
.rw-future { filter: grayscale(1) brightness(.55); }
th.rw-future { filter: none; color: rgba(255, 255, 255, .45); }
th.rw-future img { opacity: .4; }
td.rw-future sup { opacity: .8; }

/* Registration: honeypot field for bots (views/auth.js) - off-screen, never seen by people. */
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Admin page (views/admin.js) ---------- */
.tag.tag-warn { background: rgba(245, 184, 77, .16); color: var(--warn); }
.tag + .tag, .driver-name + .tag { margin-left: 6px; }
.admin-filter { width: 260px; max-width: 100%; }
.admin-table td.admin-actions { text-align: right; }
.admin-table td.admin-actions .btn + .btn { margin-left: 6px; }
.admin-table tr.admin-pending > td { color: var(--muted); }
.admin-at-limit { color: var(--warn); font-weight: 700; }
/* While an admin is "logged in as" another profile (app.js impersonationBar) */
.impersonation-bar {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 7px 24px; background: var(--danger); color: #1a0000; font-size: 14px;
}
.impersonation-bar .btn { color: #1a0000; border-color: rgba(0, 0, 0, .35); background: rgba(255, 255, 255, .25); }
.tag.tag-danger { background: var(--danger-soft); color: var(--danger); }
input.mono { font-family: var(--mono); }
