* {
    box-sizing: border-box;
}

:root,
[data-theme="pitwall"] {
    /* Pit Wall — phosphor green on black. The original look. */
    --bg: #0a0c0a;
    --bg-2: #080a08;
    --bg-3: #0a1a10;
    --panel: #0e140e;
    --panel-2: #101410;
    --surface-1: #111;
    --surface-2: #1a1a1a;
    --surface-3: #222;
    --line: #1a3d24;
    --line-2: #333;
    --line-3: #444;
    --text: #e8fff0;
    --text-2: #d2ffe3;
    --text-3: #8fbf9f;
    --text-4: #666;
    --text-hi: #fff;
    --ink: #03150a;
    --accent: #00ff66;
    --accent-rgb: 0, 255, 102;
    --accent-hover: #00cc55;
    --accent-soft: #8f8;
    --accent-dim: #1a3a2a;
    --accent-deep: #0f2a18;
    --accent-muted: #6a9a78;
    --warn: #ffaa00;
    --warn-2: #ffcc00;
    --warn-soft: #ffcc66;
    --warn-deep: #c9a227;
    --warn-dim: #2a2208;
    --crit: #ff4d6d;
    --crit-soft: #ff8a9a;
    --crit-dim: #3a1a1a;
    --info: #88ccff;
    --info-soft: #9ec9ff;
    --info-deep: #5a9ae0;
    --info-dim: #1a3a6e;
    --radius: 10px;
    --pad-cell: 10px 12px;
    --pad-tab: 12px 16px;

    /* Type scale (1.2 minor third off 14px) and a 4px space scale. Every
       padding/margin below picks from these instead of inventing a number. */
    --fs-micro: 11px;
    --fs-small: 12px;
    --fs-body: 14px;
    --fs-lead: 17px;
    --fs-title: 20px;
    --fs-display: 26px;
    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 24px;
    --s6: 36px;
    --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

    /* Legacy aliases — older rules still say --green. Kept so a theme only has
       to define --accent and both names follow it. */
    --green: var(--accent);
    --green-hover: var(--accent-hover);
}

/* Amber CRT — the old timing-monitor amber. Easier on the eyes at 3am. */
[data-theme="amber"] {
    --bg: #0b0906;
    --bg-2: #080604;
    --bg-3: #1a1206;
    --panel: #14100a;
    --panel-2: #171208;
    --surface-1: #141210;
    --surface-2: #1e1a14;
    --surface-3: #262019;
    --line: #4a3413;
    --line-2: #3a2f1e;
    --line-3: #4a3d26;
    --text: #ffeccd;
    --text-2: #f0d7a8;
    --text-3: #b39463;
    --text-4: #7a6540;
    --text-hi: #fffaf0;
    --ink: #1a1204;
    --accent: #ffb000;
    --accent-rgb: 255, 176, 0;
    --accent-hover: #d99500;
    --accent-soft: #ffd48a;
    --accent-dim: #3a2a0c;
    --accent-deep: #2e2008;
    --accent-muted: #a8834a;
    --warn: #ffd166;
    --warn-2: #ffe08a;
    --warn-soft: #ffe9b0;
    --warn-deep: #c9a227;
    --warn-dim: #2e2510;
    --crit: #ff5c5c;
    --crit-soft: #ff9b8f;
    --crit-dim: #3a1a14;
    --info: #7fd4ff;
    --info-soft: #a8e3ff;
    --info-deep: #4a9ec4;
    --info-dim: #16303c;
}

/* Le Mans Night — cool blue, for long dark stints. */
[data-theme="lemans"] {
    --bg: #060a12;
    --bg-2: #04070d;
    --bg-3: #0a1626;
    --panel: #0d1626;
    --panel-2: #101c2e;
    --surface-1: #101720;
    --surface-2: #16202e;
    --surface-3: #1e2a3a;
    --line: #1e3a5f;
    --line-2: #26364a;
    --line-3: #32475e;
    --text: #e6f0ff;
    --text-2: #c2d8f5;
    --text-3: #7d97b8;
    --text-4: #5a6d85;
    --text-hi: #fff;
    --ink: #04101f;
    --accent: #4da3ff;
    --accent-rgb: 77, 163, 255;
    --accent-hover: #3d86d6;
    --accent-soft: #9ecbff;
    --accent-dim: #12283f;
    --accent-deep: #0d2136;
    --accent-muted: #6d8bad;
    --warn: #ffb648;
    --warn-2: #ffcb75;
    --warn-soft: #ffdb9e;
    --warn-deep: #c98f2e;
    --warn-dim: #2e2413;
    --crit: #ff5f6d;
    --crit-soft: #ff96a0;
    --crit-dim: #34161d;
    --info: #8fe3d0;
    --info-soft: #b4efe2;
    --info-deep: #4fa899;
    --info-dim: #113029;
}

/* Monaco Harbour — deep violet-blue, yacht lights on water. */
[data-theme="monaco"] {
    --bg: #0a0610;
    --bg-2: #07040c;
    --bg-3: #160a22;
    --panel: #120a1a;
    --panel-2: #16101f;
    --surface-1: #15101c;
    --surface-2: #1e1628;
    --surface-3: #281e34;
    --line: #3a2458;
    --line-2: #322640;
    --line-3: #423252;
    --text: #f0e6ff;
    --text-2: #d4c2f0;
    --text-3: #9a84b8;
    --text-4: #6e5a88;
    --text-hi: #fff;
    --ink: #10081a;
    --accent: #c084fc;
    --accent-rgb: 192, 132, 252;
    --accent-hover: #a855f7;
    --accent-soft: #e0b8ff;
    --accent-dim: #2a1840;
    --accent-deep: #1e1030;
    --accent-muted: #8a6aaa;
    --warn: #ffb648;
    --warn-2: #ffcb75;
    --warn-soft: #ffdb9e;
    --warn-deep: #c98f2e;
    --warn-dim: #2e2413;
    --crit: #ff5f8a;
    --crit-soft: #ff96b0;
    --crit-dim: #34161d;
    --info: #7dd3fc;
    --info-soft: #a5e4ff;
    --info-deep: #4aa8c4;
    --info-dim: #122e3c;
}

/* Spa Forest — deep Ardennes green, night under the canopy. */
[data-theme="spa"] {
    --bg: #060a06;
    --bg-2: #040704;
    --bg-3: #0a160a;
    --panel: #0c140c;
    --panel-2: #101810;
    --surface-1: #101610;
    --surface-2: #162016;
    --surface-3: #1e2a1e;
    --line: #1e4a28;
    --line-2: #26362a;
    --line-3: #324738;
    --text: #e6ffe8;
    --text-2: #c2f0c8;
    --text-3: #7db88a;
    --text-4: #5a8568;
    --text-hi: #fff;
    --ink: #041004;
    --accent: #3dd68c;
    --accent-rgb: 61, 214, 140;
    --accent-hover: #2bb872;
    --accent-soft: #8aefb8;
    --accent-dim: #123028;
    --accent-deep: #0d241c;
    --accent-muted: #5a9a78;
    --warn: #ffb648;
    --warn-2: #ffcb75;
    --warn-soft: #ffdb9e;
    --warn-deep: #c98f2e;
    --warn-dim: #2e2413;
    --crit: #ff5f6d;
    --crit-soft: #ff96a0;
    --crit-dim: #34161d;
    --info: #7fd4ff;
    --info-soft: #a8e3ff;
    --info-deep: #4a9ec4;
    --info-dim: #16303c;
}

/* Monza Red — Italian racing red on near-black. */
[data-theme="monza"] {
    --bg: #0c0606;
    --bg-2: #0a0404;
    --bg-3: #1a0a0a;
    --panel: #140c0c;
    --panel-2: #181010;
    --surface-1: #161010;
    --surface-2: #201616;
    --surface-3: #2a1e1e;
    --line: #4a1e1e;
    --line-2: #3a2626;
    --line-3: #4a3232;
    --text: #ffe6e6;
    --text-2: #f0c8c8;
    --text-3: #b88484;
    --text-4: #885a5a;
    --text-hi: #fff;
    --ink: #1a0808;
    --accent: #ef4444;
    --accent-rgb: 239, 68, 68;
    --accent-hover: #dc2626;
    --accent-soft: #fca5a5;
    --accent-dim: #3a1414;
    --accent-deep: #2a0e0e;
    --accent-muted: #a85a5a;
    --warn: #ffb648;
    --warn-2: #ffcb75;
    --warn-soft: #ffdb9e;
    --warn-deep: #c98f2e;
    --warn-dim: #2e2413;
    --crit: #ff6b8a;
    --crit-soft: #ff9ab0;
    --crit-dim: #3a1420;
    --info: #7fd4ff;
    --info-soft: #a8e3ff;
    --info-deep: #4a9ec4;
    --info-dim: #16303c;
}

/* Silverstone — cool steel grey, British overcast. */
[data-theme="silverstone"] {
    --bg: #080a08;
    --bg-2: #060806;
    --bg-3: #101410;
    --panel: #0e1210;
    --panel-2: #121612;
    --surface-1: #121612;
    --surface-2: #1a1e1a;
    --surface-3: #222822;
    --line: #2e3a32;
    --line-2: #2a322c;
    --line-3: #3a443c;
    --text: #e8f0ea;
    --text-2: #c8d4cc;
    --text-3: #8a9a90;
    --text-4: #5e6e64;
    --text-hi: #fff;
    --ink: #060806;
    --accent: #94a3b8;
    --accent-rgb: 148, 163, 184;
    --accent-hover: #7b8fa6;
    --accent-soft: #cbd5e1;
    --accent-dim: #1e2830;
    --accent-deep: #141c22;
    --accent-muted: #6a7a88;
    --warn: #ffb648;
    --warn-2: #ffcb75;
    --warn-soft: #ffdb9e;
    --warn-deep: #c98f2e;
    --warn-dim: #2e2413;
    --crit: #ff5f6d;
    --crit-soft: #ff96a0;
    --crit-dim: #34161d;
    --info: #7dd3fc;
    --info-soft: #a5e4ff;
    --info-deep: #4aa8c4;
    --info-dim: #122e3c;
}

/* Fuji Dawn — deep crimson on near-black (matches the red UI look). */
[data-theme="fuji"] {
    --bg: #0a0608;
    --bg-2: #080406;
    --bg-3: #160a0e;
    --panel: #10080c;
    --panel-2: #140a10;
    --surface-1: #140c10;
    --surface-2: #1c1216;
    --surface-3: #26181e;
    --line: #3a1820;
    --line-2: #2e1a20;
    --line-3: #3e242c;
    --text: #ffe8ec;
    --text-2: #f0c8d0;
    --text-3: #b88890;
    --text-4: #886068;
    --text-hi: #fff;
    --ink: #1a080c;
    --accent: #e11d48;
    --accent-rgb: 225, 29, 72;
    --accent-hover: #be123c;
    --accent-soft: #fb7185;
    --accent-dim: #3a1018;
    --accent-deep: #2a0a10;
    --accent-muted: #a85868;
    --warn: #ffb648;
    --warn-2: #ffcb75;
    --warn-soft: #ffdb9e;
    --warn-deep: #c98f2e;
    --warn-dim: #2e2413;
    --crit: #ff6b8a;
    --crit-soft: #ff9ab0;
    --crit-dim: #3a1420;
    --info: #7dd3fc;
    --info-soft: #a5e4ff;
    --info-deep: #4aa8c4;
    --info-dim: #122e3c;
}

/* Daytona Dusk — warm sunset orange on dark asphalt. */
[data-theme="daytona"] {
    --bg: #0c0806;
    --bg-2: #0a0604;
    --bg-3: #1a120a;
    --panel: #14100a;
    --panel-2: #18140c;
    --surface-1: #16120e;
    --surface-2: #201a14;
    --surface-3: #2a221a;
    --line: #4a3418;
    --line-2: #3a2e1e;
    --line-3: #4a3c28;
    --text: #fff0e0;
    --text-2: #f0d8c0;
    --text-3: #b89870;
    --text-4: #887050;
    --text-hi: #fffaf0;
    --ink: #1a1008;
    --accent: #fb923c;
    --accent-rgb: 251, 146, 60;
    --accent-hover: #f97316;
    --accent-soft: #fdba74;
    --accent-dim: #3a2410;
    --accent-deep: #2a1a0a;
    --accent-muted: #a87848;
    --warn: #ffd166;
    --warn-2: #ffe08a;
    --warn-soft: #ffe9b0;
    --warn-deep: #c9a227;
    --warn-dim: #2e2510;
    --crit: #ff5c5c;
    --crit-soft: #ff9b8f;
    --crit-dim: #3a1a14;
    --info: #7fd4ff;
    --info-soft: #a8e3ff;
    --info-deep: #4a9ec4;
    --info-dim: #16303c;
}

/* Daylight — high-contrast light, for a bright room or a daytime stream. */
[data-theme="daylight"] {
    --bg: #f2f5f0;
    --bg-2: #e8ece6;
    --bg-3: #dfe8e0;
    --panel: #ffffff;
    --panel-2: #f7faf6;
    --surface-1: #eef2ec;
    --surface-2: #e4eae2;
    --surface-3: #d8e0d6;
    --line: #c2d0be;
    --line-2: #cdd6ca;
    --line-3: #b8c4b5;
    --text: #10201a;
    --text-2: #2c4038;
    --text-3: #5d7268;
    --text-4: #7d8f86;
    --text-hi: #05100c;
    --ink: #ffffff;
    --accent: #0b7a3d;
    --accent-rgb: 11, 122, 61;
    --accent-hover: #0a6534;
    --accent-soft: #3fa168;
    --accent-dim: #d6ecdd;
    --accent-deep: #c3e2ce;
    --accent-muted: #4f7a62;
    --warn: #a05a00;
    --warn-2: #b06a00;
    --warn-soft: #c98a2e;
    --warn-deep: #7d4700;
    --warn-dim: #f6e6cc;
    --crit: #b3202f;
    --crit-soft: #d14a58;
    --crit-dim: #f7dcdf;
    --info: #12578f;
    --info-soft: #3d7cb0;
    --info-deep: #0d4270;
    --info-dim: #d8e6f3;
}

/* Mono — no hue at all. For glare, colour-blind viewing, or clean capture. */
[data-theme="mono"] {
    --bg: #000;
    --bg-2: #000;
    --bg-3: #0e0e0e;
    --panel: #0b0b0b;
    --panel-2: #0f0f0f;
    --surface-1: #141414;
    --surface-2: #1c1c1c;
    --surface-3: #242424;
    --line: #2e2e2e;
    --line-2: #333;
    --line-3: #444;
    --text: #fff;
    --text-2: #d6d6d6;
    --text-3: #9a9a9a;
    --text-4: #6e6e6e;
    --text-hi: #fff;
    --ink: #000;
    --accent: #fff;
    --accent-rgb: 255, 255, 255;
    --accent-hover: #c9c9c9;
    --accent-soft: #e0e0e0;
    --accent-dim: #262626;
    --accent-deep: #1a1a1a;
    --accent-muted: #8a8a8a;
    --warn: #ffd400;
    --warn-2: #ffe14d;
    --warn-soft: #ffeb8a;
    --warn-deep: #b39400;
    --warn-dim: #2b2510;
    --crit: #ff3b30;
    --crit-soft: #ff7a72;
    --crit-dim: #331411;
    --info: #4db8ff;
    --info-soft: #8ad1ff;
    --info-deep: #2b7ab3;
    --info-dim: #10293a;
}

/* Theme picker (dropdown). Was a cycle button — reaching a theme meant
   stepping through the others, and the light one at full brightness in a dark
   room is genuinely unpleasant to hit by accident. */
.theme-picker {
    position: relative;
    display: inline-block;
}

.theme-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-1);
    border: 1px solid var(--surface-3);
    color: var(--text-2);
    border-radius: 8px;
    padding: 8px 12px;
    min-height: 0;
    margin: 0;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}
.theme-trigger:hover { border-color: var(--accent); color: var(--text); }
.theme-trigger:focus-visible { outline: none; box-shadow: var(--ring); }
.theme-trigger:active { transform: none; }

.theme-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--accent);
    box-shadow: 0 0 0 1px var(--line) inset;
    flex: none;
}
.theme-name { min-width: 84px; text-align: left; }
.theme-caret { font-size: 10px; color: var(--text-4); }

.theme-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 10005;
    min-width: 210px;
    max-height: min(70vh, 480px);
    overflow-y: auto;
    padding: 6px;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .55);
}
.theme-menu[hidden] { display: none; }

.theme-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.theme-menu button:hover { background: var(--surface-2); color: var(--text); }
.theme-menu button:active { transform: none; }
.theme-menu button:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--accent);
}
.theme-menu button.is-current { background: var(--accent-dim); color: var(--text); }
.theme-menu button.is-current::after {
    content: "\2713";
    margin-left: auto;
    color: var(--accent);
    font-weight: 700;
}
.theme-menu .tnote {
    margin-left: auto;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-4);
}
.theme-menu button.is-current .tnote { margin-left: 0; }

/* Each swatch previews its own theme's background and accent, so the light
   one is identifiable before you select it. */
.theme-menu .sw {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex: none;
    box-shadow: 0 0 0 1px rgba(128, 128, 128, .45) inset;
}
.theme-menu .sw[data-sw="pitwall"]     { background: linear-gradient(135deg, #0a0c0a 50%, #00ff66 50%); }
.theme-menu .sw[data-sw="amber"]       { background: linear-gradient(135deg, #0b0906 50%, #ffb000 50%); }
.theme-menu .sw[data-sw="lemans"]      { background: linear-gradient(135deg, #060a12 50%, #4da3ff 50%); }
.theme-menu .sw[data-sw="monaco"]      { background: linear-gradient(135deg, #0a0610 50%, #c084fc 50%); }
.theme-menu .sw[data-sw="spa"]         { background: linear-gradient(135deg, #060a06 50%, #3dd68c 50%); }
.theme-menu .sw[data-sw="monza"]       { background: linear-gradient(135deg, #0c0606 50%, #ef4444 50%); }
.theme-menu .sw[data-sw="silverstone"] { background: linear-gradient(135deg, #080a08 50%, #94a3b8 50%); }
.theme-menu .sw[data-sw="fuji"]        { background: linear-gradient(135deg, #0a0608 50%, #e11d48 50%); }
.theme-menu .sw[data-sw="daytona"]     { background: linear-gradient(135deg, #0c0806 50%, #fb923c 50%); }
.theme-menu .sw[data-sw="mono"]        { background: linear-gradient(135deg, #000 50%, #fff 50%); }
.theme-menu .sw[data-sw="daylight"]    { background: linear-gradient(135deg, #f2f5f0 50%, #0b7a3d 50%); }

/* Themed surfaces should cross-fade rather than snap */
body, .panel, .content, table, th, td, .tab, .subtab {
    transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
@media (prefers-reduced-motion: reduce) {
    body, .panel, .content, table, th, td, .tab, .subtab, .theme-trigger {
        transition: none;
    }
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 12px 90px;
}

body.has-race-ticker #app {
    padding-top: 44px;
}

/* ========== GLOBAL RACE TICKER (static — no clone / no marquee) ========== */
.race-ticker {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10050;
    height: 36px;
    background: linear-gradient(180deg, var(--accent-deep) 0%, var(--bg-3) 100%);
    border-bottom: 1px solid rgba(var(--accent-rgb), 0.35);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.race-ticker::-webkit-scrollbar {
    display: none;
}
.race-ticker[hidden] {
    display: none !important;
}
.race-ticker-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-width: 100%;
    width: max-content;
    margin: 0 auto;
    padding: 0 8px;
    box-sizing: border-box;
}
.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    height: 100%;
    border-right: 1px solid rgba(var(--accent-rgb), 0.12);
    white-space: nowrap;
    flex-shrink: 0;
}
.ticker-item:last-child {
    border-right: none;
}
.ticker-item .tk-label {
    color: var(--accent-muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.ticker-item .tk-val {
    color: var(--text);
    font-variant-numeric: tabular-nums;
    font-weight: 750;
    font-size: 13px;
}
.ticker-item .tk-val.accent { color: var(--accent); }
.ticker-item .tk-val.warn { color: var(--warn-soft); }
.ticker-item .tk-val.crit { color: var(--crit-soft); }
.ticker-item .tk-val.muted { color: var(--accent-muted); font-weight: 600; }

/* ========== TOP BAR ========== */
.top-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    margin: 10px 0;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.top-bar-left,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
}

.brand-logo-img {
    height: 100px;
    width: 150px;
}

.top-actions {
    display: flex;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
}

.top-btn {
    flex: 1;
    height: 42px;
    padding: 0 12px;
    border: none;
    border-radius: 8px;
    background: var(--green);
    color: var(--ink);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

    .top-btn:active {
        transform: scale(0.97);
    }

.room-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-1);
    border: 1px solid var(--surface-3);
    border-radius: 8px;
    padding: 8px 12px;
}

.room-label {
    color: var(--text-3);
    font-size: 0.8rem;
}

.room-code {
    color: var(--accent);
    font-family: monospace;
    font-size: 0.95rem;
    font-weight: 600;
}

.room-copy-btn {
    padding: 6px 12px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 36px;
}

.gmt-clock {
    margin-left: auto;
    background: var(--surface-1);
    border: 1px solid var(--surface-3);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--accent);
    font-family: monospace;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ========== TABS ========== */
.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

    .tabs::-webkit-scrollbar {
        display: none;
    }

.tab {
    flex: 1 0 auto;
    text-align: center;
    padding: 11px var(--s4);
    border-radius: 8px;
    color: var(--text-3);
    font-weight: 650;
    font-size: var(--fs-body);
    cursor: pointer;
    white-space: nowrap;
    transition: color .14s ease, background-color .14s ease;
}

    .tab.active {
        background: var(--green);
        color: var(--ink);
    }

.content {
    display: none;
    padding: 8px 0 16px;
}

    .content.active {
        display: block;
    }

/* ========== SUBTABS ========== */
.subtabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 14px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

    .subtabs::-webkit-scrollbar {
        display: none;
    }

.subtab {
    flex: 0 0 auto;
    padding: 10px 14px;
    border-radius: 7px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
    white-space: nowrap;
}

    .subtab.active {
        color: var(--text-hi);
        background: rgba(var(--accent-rgb), 0.2);
        box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.5);
    }

.subcontent {
    display: none;
}

    .subcontent.active {
        display: block;
    }

/* ========== TYPE ========== */
h1, h2 {
    margin: 0 0 12px;
    color: var(--text);
    font-weight: 750;
}

h1 {
    font-size: 1.25rem;
}

h2 {
    margin-top: 22px;
    font-size: 1.05rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: 6px;
}

/* ========== TABLES ========== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 16px;
    background: var(--panel);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    min-width: 320px;
}

.table-wrap table {
    margin-bottom: 0;
}

th, td {
    border: 1px solid var(--line);
    padding: 11px 12px;
    text-align: left;
    font-size: 13px;
    color: var(--text);
    vertical-align: middle;
}

th {
    background: var(--accent-dim);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    position: sticky;
    top: 0;
    z-index: 2;
}

/* This used to be a GLOBAL rule forcing every table's first column to behave
   like a label column — a hangover from settings being built as tables. It
   broke real data tables (live.html carries an override to undo it). It is now
   opt-in via .kv, so a data table is just a data table. */
.kv td:first-child {
    width: 42%;
    max-width: 220px;
    word-break: break-word;
    color: var(--text-2);
}

/* Figures line up and stop jittering as they tick. */
td, th { font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; }

/* ========== ACTION ROWS ========== */
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.tire-controls {
    margin-bottom: 16px;
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
}

/* ========== INPUTS ========== */
input[type="text"],
input[type="number"],
select,
input[type="datetime-local"],
input[type="time"],
input[type="date"] {
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    outline: none;
    font-size: 16px; /* stops iOS zoom */
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    caret-color: var(--green);
}

input[type="datetime-local"],
input[type="time"],
input[type="date"] {
    color-scheme: dark;
}

/* Soft invalid style – only subtle, not crazy pink boxes */
input.invalid,
select.invalid {
    border-color: var(--crit-soft) !important;
    box-shadow: 0 0 0 1px rgba(255, 77, 109, 0.25) !important;
}

input[type="color"] {
    width: 48px;
    height: 40px;
    padding: 3px;
    border: 1px solid var(--line);
    background: var(--bg-2);
    border-radius: 8px;
}

/* ========== BUTTONS ========== */
/* Button hierarchy. Everything used to be a filled green button, so nothing
   read as the primary action. Default is now the SECONDARY treatment; opt in
   to .btn-primary for the one action that matters in a view, .btn-ghost for
   tertiary. Destructive actions get .btn-danger. */
button {
    background: var(--surface-1);
    color: var(--text);
    border: 1px solid var(--line-2);
    border-radius: 8px;
    padding: 0 var(--s4);
    margin: 0 var(--s2) var(--s2) 0;
    font-size: var(--fs-body);
    font-weight: 600;
    cursor: pointer;
    min-height: 42px;
    transition: border-color .14s ease, background-color .14s ease, color .14s ease;
}
button:hover { border-color: var(--accent); color: var(--text); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button[disabled] { opacity: .45; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--ink);
    font-weight: 700;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--ink); }

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-3);
}
.btn-ghost:hover { color: var(--text); border-color: var(--line-2); }

.btn-danger { border-color: var(--crit-dim); color: var(--crit); }
.btn-danger:hover { border-color: var(--crit); color: var(--crit); }


/* Tire controls – make the number inputs readable */
.tire-controls input[type="number"] {
    width: 64px !important;
    min-width: 64px;
    padding: 6px 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-2);
    background: var(--surface-2);
    border: 1px solid var(--line-2);
    border-radius: 4px;
    text-align: center;
}

    .tire-controls input[type="number"]:focus {
        border-color: var(--accent);
        outline: none;
    }

/* Slightly wider for the life limit */
#maxWearLimit {
    width: 72px !important;
}

/* ========== FOOTER ========== */
#siteFooter {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--bg-2);
    border-top: 1px solid var(--line);
    color: var(--text-3);
    font-size: 12px;
}

    #siteFooter button {
        margin: 0;
        padding: 8px 18px;
        background: transparent;
        color: var(--green);
        border: 1px solid var(--green);
        min-height: 40px;
    }

/* ========== LOBBY ========== */
#lobby {
    background: var(--bg) !important;
}

.lobby-card {
    background: var(--surface-1);
    border: 1px solid var(--accent);
    border-radius: 14px;
    padding: 28px 20px;
    width: 100%;
    max-width: 360px;
    margin: 16px;
    text-align: center;
    box-shadow: 0 0 40px rgba(var(--accent-rgb), 0.08);
}

.lobby-title {
    margin: 0 0 6px;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--accent);
}

.lobby-subtitle {
    margin: 0 0 22px;
    color: var(--text-4);
    font-size: 0.9rem;
}

.lobby-btn-primary {
    width: 100%;
    padding: 15px;
    background: var(--accent);
    color: var(--ink);
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    min-height: 50px;
}

.lobby-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--line-3);
    font-size: 0.8rem;
}

.lobby-line {
    flex: 1;
    height: 1px;
    background: var(--surface-3);
}

.lobby-join-row {
    display: flex;
    gap: 8px;
}

.lobby-input {
    flex: 1;
    padding: 13px 14px;
    background: var(--bg-2);
    border: 1px solid var(--line-2);
    border-radius: 8px;
    color: var(--accent);
    font-family: monospace;
    font-size: 1rem;
    min-height: 50px;
}

.lobby-btn-secondary {
    padding: 13px 18px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    font-weight: 700;
    min-height: 50px;
}

.lobby-error {
    color: var(--crit);
    font-size: 0.85rem;
    margin: 14px 0 0;
    min-height: 1.2em;
}

/* ========== TOAST ========== */
#toast {
    display: none;
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-1);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    z-index: 10000;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.55);
}

/* ========== DESKTOP (restore nicer layout) ========== */
@media (min-width: 769px) {
    .top-bar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
    }

    .top-bar-left,
    .top-bar-right {
        width: auto;
        flex-wrap: nowrap;
    }

    .top-actions {
        flex: none;
        justify-content: flex-start;
    }

    .top-btn {
        flex: none;
        height: 36px;
        font-size: 13px;
    }

    .brand-logo-img {
        height: 44px;
    }

    #app {
        padding: 0 16px 70px;
    }

    input[type="text"],
    input[type="number"],
    select,
    input[type="datetime-local"],
    input[type="time"] {
        font-size: 14px;
        min-height: 38px;
        width: auto;
    }

    td:first-child {
        width: auto;
        max-width: none;
    }
}

select.tire-pick {
    width: 100%;
    min-width: 88px;
    margin-top: 3px;
    font-size: 11px;
    padding: 3px 4px;
    background: var(--surface-2);
    border: 1px solid var(--line-2);
    color: var(--text-hi);
    border-radius: 4px;
}

.life-num {
    display: block;
}

.field-hint {
    display: none;
    position: fixed;
    z-index: 10001;
    max-width: 260px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-2);
    background: var(--surface-1);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

    .field-hint strong {
        color: var(--text-hi);
    }

    .field-hint.is-visible {
        display: block;
    }

.bmc-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    opacity: 0.85;
}

    .bmc-link:hover {
        opacity: 1;
        text-decoration: underline;
    }

.stint-type-legend {
    margin: 8px 0 10px;
    font-size: 12px;
    color: var(--text-3);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}

    .stint-type-legend .legend-label {
        color: var(--text-3);
    }

    .stint-type-legend .legend-item {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

.stint-type-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    border: 1px solid;
    box-sizing: border-box;
}

    .stint-type-chip.std {
        background: var(--accent-dim);
        color: var(--accent);
        border-color: var(--accent);
    }

    .stint-type-chip.fs {
        background: var(--warn-dim);
        color: var(--warn-2);
        border-color: var(--warn-2);
    }

    .stint-type-chip.wet {
        background: var(--info-dim);
        color: var(--info);
        border-color: var(--info);
    }

.stint-type-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    line-height: 1;
    box-sizing: border-box;
}

    .stint-type-btn:hover {
        filter: brightness(1.15);
    }

.driver-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 88px;
    max-width: 140px;
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.25);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    /* on the driver's own colour — not a themed surface */
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .driver-chip:hover {
        filter: brightness(1.1);
    }

    .driver-chip.empty {
        background: var(--surface-3);
        color: var(--text-3);
        border-color: var(--line-3);
    }

.driver-menu {
    position: fixed;
    z-index: 10002;
    min-width: 160px;
    width: max-content;
    max-width: min(280px, calc(100vw - 16px));
    /* no max-height, no overflow-y */
    background: var(--surface-1);
    border: 1px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    padding: 6px;
}

    /* Menu items are list rows, not standalone buttons. Without these resets
       the global button rule applies its 42px min-height and 8px right/bottom
       margin to every item, which inflates each row to ~50px and gaps them —
       a full roster then runs off the bottom of the screen. */
    .driver-menu button {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        min-height: 0;
        margin: 0;
        border: none;
        background: transparent;
        color: var(--text-2);
        font-size: 13px;
        font-weight: 600;
        padding: 8px 10px;
        border-radius: 6px;
        cursor: pointer;
        text-align: left;
    }
    .driver-menu button:active { transform: none; }
    .driver-menu button:focus-visible {
        outline: none;
        box-shadow: inset 0 0 0 2px var(--accent);
    }
    /* Long rosters scroll inside the menu rather than off the page. */
    .driver-menu {
        max-height: min(60vh, 420px);
        overflow-y: auto;
    }

        .driver-menu button:hover {
            background: var(--surface-2);
        }

    .driver-menu button.is-unavailable {
        color: var(--text-4);
        cursor: not-allowed;
    }
    .driver-menu button.is-unavailable:hover { background: transparent; }
    .driver-menu button.is-unavailable .swatch { opacity: .4; }
    .driver-menu button.is-current { color: var(--text); background: var(--accent-dim); }
    .driver-menu .tick { margin-left: auto; color: var(--accent); font-weight: 700; }
    .driver-menu-empty {
        padding: 10px;
        font-size: 13px;
        color: var(--text-4);
    }

    .driver-menu .swatch {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        flex-shrink: 0;
    }

.tire-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 64px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--line-2);
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    cursor: default;
    line-height: 1;
}

    .tire-chip.has-tires {
        border-color: var(--accent);
        background: var(--accent-dim);
        color: var(--accent);
    }

    .tire-chip:hover {
        filter: brightness(1.12);
    }

.tire-chip-num {
    font-size: 13px;
    font-weight: 800;
}

.tire-chip-label {
    font-size: 10px;
    opacity: 0.85;
    text-transform: uppercase;
    
    letter-spacing: 0.03em;
}

.rec-pill {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
    max-width: 160px;
    line-height: 1.3;
}

.tire-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 18px;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: var(--bg-2);
    border: 1px solid var(--accent-dim);
    border-radius: 10px;
}

.tire-stat-val.fresh {
    color: var(--accent);
    font-size: 1.2em;
}

.tire-stat-val.scrub {
    color: var(--info);
    font-size: 1.2em;
}

.tire-setup-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line-2);
    border-radius: 8px;
}

.tire-shortage {
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--warn);
    background: var(--warn-dim);
    color: var(--warn-soft);
    font-size: 13px;
}

.tire-override {
    margin-top: 5px;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.2;
}

    .tire-override.fresh {
        background: var(--info-dim);
        border: 1px solid var(--info-deep);
        color: var(--info-soft);
    }

    .tire-override.scrub {
        background: var(--warn-dim);
        border: 1px solid var(--warn-deep);
        color: var(--warn-soft);
    }

.tire-override-menu {
    position: fixed;
    z-index: 10002;
    min-width: 140px;
    background: var(--surface-1);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 12px 32px rgba(0,0,0,.55);
}

    .tire-override-menu button {
        display: block;
        width: 100%;
        text-align: left;
        padding: 8px 10px;
        border: none;
        background: transparent;
        color: var(--text-2);
        cursor: pointer;
        border-radius: 6px;
    }

        .tire-override-menu button:hover {
            background: var(--accent-dim);
            color: var(--accent);
        }

.tire-override.keep {
    background: var(--surface-2);
    border: 1px solid var(--line-3);
    color: var(--text-3);
}

.tire-override:hover {
    filter: brightness(1.15);
}
.tire-shortage {
    margin: 0 0 12px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--warn);
    background: var(--warn-dim);
    color: var(--warn-soft);
    font-size: 13px;
    font-weight: 600;
}

    .tire-shortage[hidden] {
        display: none !important;
    }

.color-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    vertical-align: middle;
    margin-right: 8px;
}

.color-hex {
    font-size: 12px;
    color: var(--text-3);
    font-family: ui-monospace, monospace;
    vertical-align: middle;
}

.laptime-input {
    width: 88px;
    text-align: center;
    font-weight: 600;
}

#driverFactorsBody td {
    vertical-align: middle;
    padding: 10px 12px;
}

/* ========== LIVE SCHEDULE (iframe) ========== */
.live-stint-table {
    width: 100%;
    border-collapse: collapse;
}

    .live-stint-table th,
    .live-stint-table td {
        border: 1px solid var(--line);
        padding: 10px 8px;
        text-align: center;
        vertical-align: middle;
        font-size: 13px;
    }

    .live-stint-table th {
        background: var(--accent-dim);
        color: var(--text-2);
        font-size: 11px;
        font-weight: 650;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .live-stint-table tr.live-row {
        background: rgba(var(--accent-rgb), 0.1);
    }

    .live-stint-table tr.next-row {
        background: rgba(255, 204, 0, 0.08);
    }

    .live-stint-table tr.done-row {
        opacity: 0.45;
    }

.tire-count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line-2);
    font-weight: 700;
    font-size: 13px;
}

.status-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.04em;
}

    .status-pill.live {
        background: var(--accent);
        color: var(--ink);
    }

    .status-pill.next {
        background: var(--warn-2);
        color: var(--ink);
    }

    .status-pill.done {
        background: var(--line-2);
        color: var(--text-3);
    }

    .status-pill.queued {
        background: var(--surface-3);
        color: var(--text-4);
        border: 1px solid var(--line-2);
    }

    .status-pill.frozen {
        background: var(--line-2);
        color: var(--text-2);
        border: 1px solid var(--text-4);
    }

.live-section {
    margin: 8px 0 20px;
}

.live-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    flex-wrap: wrap;
}

.live-section-title {
    margin: 0;
    font-size: 13px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.tire-legend {
    display: flex;
    gap: 8px;
    font-size: 11px;
}

    .tire-legend .leg {
        padding: 3px 8px;
        border-radius: 4px;
        font-weight: 600;
    }

    .tire-legend .fresh {
        background: var(--info-dim);
        color: var(--info);
    }

    .tire-legend .scrub {
        background: var(--warn-dim);
        color: var(--warn-soft);
    }

    .tire-legend .low {
        background: var(--crit-dim);
        color: var(--crit);
    }

.tire-pool-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 8px 16px 10px;
    font-size: 13px;
    color: var(--text-2);
}

    .tire-pool-bar strong {
        color: var(--accent);
        font-variant-numeric: tabular-nums;
    }

.live-tire-table td {
    vertical-align: middle;
}

.live-tire-table .life-num {
    display: block;
    font-size: 13px;
}

.live-nested-tabs {
    padding: 8px 16px 0;
    border-bottom: 1px solid var(--surface-3);
}

.nest-panel {
    display: none;
    padding-top: 8px;
}

    .nest-panel.active {
        display: block;
    }

    .nest-panel[hidden] {
        display: none !important;
    }

.tire-plan-pill {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
}

    .tire-plan-pill.fresh {
        background: var(--info-dim);
        color: var(--info);
        border: 1px solid var(--info-deep);
    }

    .tire-plan-pill.scrub {
        background: var(--warn-dim);
        color: var(--warn-soft);
        border: 1px solid var(--warn-deep);
    }

    .tire-plan-pill.keep {
        background: var(--surface-3);
        color: var(--text-3);
        border: 1px solid var(--line-3);
    }
.stint-type-pill.locked,
.driver-chip:not(button) {
    opacity: 0.75;
    cursor: not-allowed;
}
/* ========== FORMS =========================================================
   Settings were built as two-column <table>s: a table is for data you compare
   across rows, not for input you fill in. Real fields group by meaning, carry
   their own help text, wrap on narrow screens, and let a label point at its
   input. This is the vocabulary those panes now use. */
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: var(--s4);
    margin-bottom: var(--s5);
}
.field-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
    font-size: var(--fs-small);
    font-weight: 650;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--text-3);
}
.field > input,
.field > select { width: 100%; }
.field .hint {
    font-size: var(--fs-small);
    color: var(--text-4);
    line-height: 1.45;
}
.field .unit {
    font-size: var(--fs-small);
    color: var(--text-4);
    font-variant-numeric: tabular-nums;
}

/* A computed value shown alongside inputs — same footprint as a field so the
   grid stays even, but visibly not editable. */
.field.is-derived > .value {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 var(--s3);
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--accent);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

/* Section headings: one level, consistent, with a rule that spans the row. */
.section {
    display: flex;
    align-items: baseline;
    gap: var(--s3);
    margin: var(--s5) 0 var(--s3);
}
.section::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}
.section h2, .section h3 {
    margin: 0;
    font-size: var(--fs-small);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
}
.section .section-note {
    font-size: var(--fs-small);
    color: var(--text-4);
}

/* Focus is visible on every interactive thing, not just buttons. */
input:focus-visible,
select:focus-visible,
.tab:focus-visible,
.subtab:focus-visible,
summary:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* Stint type picker — mirrors the driver menu. Both reset min-height/margin
   because the global button rule would otherwise inflate menu rows to 42px
   and gap them, which is what broke these menus once already. */
.stint-type-menu {
    position: fixed;
    z-index: 10002;
    min-width: 180px;
    width: max-content;
    padding: 6px;
    background: var(--surface-1);
    border: 1px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .55);
}
.stint-type-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.stint-type-menu button:hover { background: var(--surface-2); color: var(--text); }
.stint-type-menu button:active { transform: none; }
.stint-type-menu button:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--accent);
}
.stint-type-menu button.is-current { background: var(--accent-dim); color: var(--text); }
.stint-type-menu .swatch {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.stint-type-menu .tcode {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-4);
    font-weight: 700;
}
.stint-type-menu button.is-current .tcode { margin-left: auto; }
.stint-type-menu .tick { color: var(--accent); font-weight: 700; }

/* The type chip itself is a compact pill, not a full-size button. */
.stint-type-btn {
    min-height: 0;
    margin: 0;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
    cursor: pointer;
}
.stint-type-btn:active { transform: none; }
.stint-type-btn.locked { cursor: default; opacity: .7; }

/* Fuel-balance toggle: on-state reads as selected, not as a primary action. */
#btnFuelBalance.is-on {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

/* ============================================================
   UX pass — modes, disclosure, and the plan strip.
   ============================================================ */

/* Modes are persistent state; actions are one-shot. They used to share one
   row and look identical, so a toggle read as a button you press and forget. */
.mode-row {
    display: flex;
    align-items: center;
    gap: var(--s2);
    flex-wrap: wrap;
    margin-bottom: var(--s2);
    padding: var(--s2) var(--s3);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.mode-label {
    font-size: var(--fs-micro);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
}
.mode-label:not(:first-child) { margin-left: var(--s3); }
.mode-toggle {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: var(--fs-small);
    cursor: pointer;
}
.mode-toggle:hover { background: var(--accent-deep); }

/* Recording: at least one stint has actually run, so the numbers in this
   table are a record rather than a proposal. Set automatically from the
   schedule itself — there is no switch to leave in the wrong position. */
#stintScheduleTable[data-mode="recording"] input {
    border-color: var(--warn);
    background: var(--warn-dim);
}
#stintScheduleTable[data-mode="planning"] input {
    border-color: var(--line-2);
}

/* Columns for a stint type that has no rates entered yet. */
.fs-col[hidden], tr.alt-stint-row[hidden] { display: none; }

/* The plan strip is fixed to the bottom; keep the last row reachable. */
body.has-plan-strip { padding-bottom: 52px; }

/* New race, in the live view. Mirrors the rule live.js injects, so the button
   is themeable from here once live.html loads this file. Outlined like Copy —
   a control that discards a race's progress should not read as a primary
   action, and it should not be dimmed with opacity either, which goes muddy
   on a dark panel rather than quiet. */
.new-race-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: var(--fs-small, 13px);
    line-height: 1;
    padding: 8px 14px;
    border-radius: var(--radius, 8px);
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--line-2);
    cursor: pointer;
    transition: color .12s, border-color .12s;
}
.new-race-btn:hover:not(:disabled) {
    color: var(--crit);
    border-color: var(--crit);
}
.new-race-btn:disabled {
    color: var(--text-4);
    border-color: var(--line);
    cursor: default;
}

/* Room name, in the top-bar chip.
 *
 * It was styled as a label that happened to be clickable, which is the same
 * as not being clickable — nobody hovers a caption. It now reads as a control:
 * a dashed underline at rest, a pencil beside it, and a filled outline on
 * hover. Unnamed it says "Name this room" rather than "Room", because the
 * label has to be the invitation.
 */
.room-chip .room-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-3);
    font: inherit;
    font-size: var(--fs-small, 12px);
    padding: 2px 6px;
    cursor: pointer;
    max-width: 200px;
}
.room-chip .room-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-bottom: 1px dashed var(--line-3);
}
.room-chip .room-name-pencil {
    opacity: .5;
    font-size: 11px;
    flex: 0 0 auto;
}
.room-chip .room-name:hover {
    color: var(--text);
    border-color: var(--line-3);
    background: var(--panel-2);
}
.room-chip .room-name:hover .room-name-pencil { opacity: 1; }
.room-chip .room-name:hover .room-name-text { border-bottom-color: transparent; }
.room-chip .room-name.is-named {
    color: var(--text);
    font-weight: 600;
}


/* Fuel-vs-energy advice under the per-lap rates. Quiet when the ratio is
   right, amber when litres are being carried for nothing — the cost of a bad
   ratio is dead weight and a longer stop, neither of which announces itself. */
.ratio-advice {
    margin: 0 0 var(--s4, 16px);
    font-size: var(--fs-small, 12px);
    line-height: 1.5;
}
.ratio-advice:empty { display: none; }
.ratio-advice.ok { color: var(--text-4); }
.ratio-advice.warn { color: var(--warn); }

/* ---------- Hover help (hints.js) ---------- */
.info-tip {
    /* The global button rule gives every button 42px min-height, padding and
     * a margin - which is what turned the (i) into a tall oval. Undo all of
     * it; this is an icon, not a button that happens to be small. */
    min-height: 0;
    min-width: 0;
    margin: 0 0 0 6px;
    box-sizing: border-box;
    flex: none;
    transition: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    padding: 0;
    border: 1px solid var(--text-4);
    border-radius: 50%;
    background: transparent;
    color: var(--text-4);
    font: italic 700 10px/1 Georgia, serif;
    text-transform: none;
    letter-spacing: 0;
    vertical-align: 1px;
    cursor: help;
}
    .info-tip:active { transform: none; }
    .info-tip:hover,
    .info-tip:focus-visible {
        box-shadow: none;
        border-color: var(--accent);
        color: var(--accent);
        outline: none;
    }
.has-tip {
    cursor: help;
    text-decoration: underline dotted var(--text-4);
    text-underline-offset: 3px;
}
#tipPop {
    display: none;
    position: fixed;
    z-index: 10001;
    max-width: 280px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-2);
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    text-transform: none;
    letter-spacing: 0;
}
    #tipPop.is-visible { display: block; }
    #tipPop strong, #tipPop b { color: var(--text-hi); }

/* ---------- Links to other tabs (utils.js goToTab) ---------- */
.go-link {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
    text-underline-offset: 2px;
    cursor: pointer;
}
    .go-link:hover { text-decoration-color: var(--accent); }

/* ---------- Two-way switch (tire wear: one average / per corner) ---------- */
.seg-toggle {
    display: inline-flex;
    border: 1px solid var(--line-2);
    border-radius: 8px;
    overflow: hidden;
    margin: 0 0 var(--s3);
}
    .seg-toggle button {
        min-height: 0;
        margin: 0;
        padding: 6px 14px;
        border: 0;
        border-radius: 0;
        background: transparent;
        color: var(--text-3);
        font-size: var(--fs-small);
        font-weight: 600;
    }
    .seg-toggle button + button { border-left: 1px solid var(--line-2); }
    .seg-toggle button:active { transform: none; }
    .seg-toggle button.active {
        background: var(--accent);
        color: var(--ink);
    }
/* .field-grid sets display:grid, which beats the hidden attribute - that
 * is why the per-corner boxes never actually hid. */
.field-grid[hidden] { display: none; }

/* ---------- Tire inputs card (Plan > Tire schedule) ----------
 * One grid: label | FL | FR | RL | RR | switch. The wear wrappers use
 * display:contents so their inputs sit in the corner columns directly. */
.tire-inputs {
    display: grid;
    grid-template-columns: max-content repeat(4, minmax(64px, 88px)) max-content;
    gap: 6px 8px;
    align-items: center;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: var(--bg-2);
    border: 1px solid var(--line-2);
    border-radius: 10px;
    width: max-content;
    max-width: 100%;
}
    .tire-inputs input {
        width: 100%;
        min-width: 0;
        height: 30px;
        padding: 0 8px;
        font-size: 13px;
        font-variant-numeric: tabular-nums;
    }
    .tire-inputs .ti-row { display: contents; }
    .tire-inputs .ti-row[hidden] { display: none; }
    .tire-inputs .ti-span { grid-column: span 4; }
    /* Same look as the table headers below (th): accent-dim fill,
     * text-2, 11px caps - so the card reads as part of the same table. */
    .tire-inputs .ti-col,
    .tire-inputs .ti-label {
        background: var(--accent-dim);
        color: var(--text-2);
        font-size: 11px;
        font-weight: 650;
        letter-spacing: .03em;
        text-transform: uppercase;
        border-radius: 6px;
    }
    .tire-inputs .ti-col {
        text-align: center;
        padding: 5px 0;
    }
    .tire-inputs .ti-label {
        display: flex;
        align-items: center;
        height: 30px;
        padding: 0 10px;
        white-space: nowrap;
    }
    .tire-inputs .ti-label .info-tip {
        border-color: var(--text-3);
        color: var(--text-3);
    }
    .tire-inputs .seg-toggle { margin: 0 0 0 4px; }
    .tire-inputs .seg-toggle button { padding: 4px 10px; }

@media (max-width: 560px) {
    .tire-inputs {
        grid-template-columns: repeat(4, 1fr);
        width: auto;
    }
    .tire-inputs > span:empty { display: none; }
    .tire-inputs .ti-label,
    .tire-inputs .seg-toggle { grid-column: 1 / -1; margin: 4px 0 0; }
    .tire-inputs .ti-col { display: none; }
}

/* ---------- Plan > Pit schedule: compact layout ---------- */
.plan-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
    .plan-toolbar button,
    .plan-toolbar summary {
        min-height: 32px;
        margin: 0;
        padding: 0 12px;
        font-size: var(--fs-small);
    }
    .plan-toolbar .mode-toggle { min-height: 28px; }
.plan-toolbar-sep {
    width: 1px;
    height: 22px;
    background: var(--line-2);
    margin: 0 4px;
}

/* "More" holds the destructive actions, pushed to the right. */
.more-menu {
    position: relative;
    margin-left: auto;
}
    .more-menu > summary {
        list-style: none;
        display: inline-flex;
        align-items: center;
        border: 1px solid var(--line-2);
        border-radius: 8px;
        color: var(--text-2);
        font-weight: 600;
        cursor: pointer;
        user-select: none;
    }
    .more-menu > summary::-webkit-details-marker { display: none; }
    .more-menu[open] > summary { border-color: var(--accent); }
.more-menu-list {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 210px;
    padding: 6px;
    background: var(--surface-1);
    border: 1px solid var(--line-2);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
    .more-menu-list button {
        width: 100%;
        text-align: left;
        justify-content: flex-start;
    }

/* Denser rows: 30px inputs and tighter cells take each stint row from
 * ~58px to ~40px, so a 9-stint race fits without scrolling. */
#stintScheduleTable th,
#stintScheduleTable td { padding: 6px 10px; }
#stintScheduleTable input {
    min-height: 0;
    height: 30px;
    padding: 0 8px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
#stintScheduleTable .end-time-input { width: 96px; }
#stintScheduleTable .laps-input { width: 60px; text-align: center; }
#stintScheduleTable .stint-type-btn,
#stintScheduleTable .tire-chip,
#stintScheduleTable .driver-chip { height: 24px; }

/* Fuel saving + deltas side by side when there is room. */
.plan-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0 24px;
}
@media (min-width: 1100px) {
    .plan-bottom { grid-template-columns: minmax(320px, 2fr) minmax(0, 3fr); }
}
.plan-bottom-col { min-width: 0; }

/* The tire card inputs: the global 44px min-height beats height. */
.tire-inputs input { min-height: 0; }

/* ============================================================
   Density pass — Setup and Plan tabs (v1.5.0)
   One table/input size for the planner: 30px inputs, 6px cells.
   Scoped to the planner tabs so live.html is untouched.
   ============================================================ */
#tab0 th, #tab0 td,
#tab1 th, #tab1 td { padding: 6px 10px; }
#tab0 td input, #tab1 td input {
    min-height: 0;
    height: 30px;
    padding: 0 8px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
#tab0 .field > input,
#tab0 .field > select {
    min-height: 0;
    height: 34px;
    padding: 0 10px;
}
#tab0 .field.is-derived > .value { min-height: 34px; }
#tab0 .field-grid { gap: var(--s3); margin-bottom: var(--s4); }
#tab0 .section { margin: var(--s4) 0 var(--s2); }

/* Setup > Basic: five short values on one row. */
.field-grid.setup-row {
    grid-template-columns: minmax(90px, 120px) minmax(200px, 240px) minmax(150px, 180px) minmax(90px, 120px) minmax(90px, 120px);
    justify-content: start;
}
@media (max-width: 900px) {
    .field-grid.setup-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* A button that belongs to a section, at the right end of its header line. */
.section .section-action {
    order: 2;
    min-height: 0;
    margin: 0;
    padding: 2px 8px;
    font-size: var(--fs-small);
    align-self: center;
}

/* Per-lap rates: label column hugs its text, inputs fixed width. */
.rates-table td:first-child { white-space: nowrap; width: 1%; }
.rates-table td input { width: 76px; }
.rates-table th { white-space: nowrap; }

/* Tire schedule: allocation + corner inputs side by side. */
.tire-top {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 10px;
}
    .tire-top .tire-toolbar,
    .tire-top .tire-inputs { margin-bottom: 0; }
    .tire-top .tire-toolbar {
        flex: 1 1 320px;
        font-size: 13px;
        gap: 10px 14px;
        align-content: center;
    }
.tire-toolbar #startingTireSets {
    width: 64px;
    min-height: 0;
    height: 30px;
    padding: 0 8px;
}
.tire-toolbar .btn-primary {
    min-height: 32px;
    margin: 0;
    padding: 0 12px;
    font-size: var(--fs-small);
}

/* Tire schedule table: one line per cell. */
#tireScheduleTable td { text-align: center; }
#tireScheduleTable .tire-cell {
    white-space: nowrap;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
    #tireScheduleTable .tc-out {
        margin-left: 4px;
        font-size: 11px;
        font-weight: 500;
        opacity: .8;
    }
#tireScheduleTable .tire-override {
    min-height: 0;
    margin: 0 0 0 6px;
    padding: 1px 7px;
    font-size: 9.5px;
    vertical-align: 1px;
}
    #tireScheduleTable .tire-override:active { transform: none; }
#tireScheduleTable .tire-rec {
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}
#tireScheduleTable .driver-chip { height: 24px; }

/* ============================================================
   v1.7 polish — app chrome, Advanced, Drivers, lobby, footer
   ============================================================ */

/* ---- Header: one row, tabs inline ---- */
.top-bar { margin: 10px 0 12px; }
.brand { display: inline-flex; align-items: center; flex: none; }
.brand-logo-img,
.top-bar .brand-logo-img {
    height: 30px;
    width: auto;
    display: block;
}
.top-bar .tabs {
    margin: 0;
    padding: 3px;
    gap: 2px;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: 10px;
    flex: 0 1 auto;
}
.top-bar .tab {
    flex: 0 0 auto;
    padding: 7px 16px;
    font-size: 13.5px;
    border-radius: 7px;
}
    .top-bar .tab:hover { color: var(--text); }
    .top-bar .tab.active {
        background: rgba(var(--accent-rgb), .16);
        color: var(--accent);
        box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .45);
    }
.top-bar .top-actions { flex: none; gap: 6px; }
.top-bar .top-btn {
    flex: none;
    height: 34px;
    padding: 0 12px;
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--line-2);
    font-weight: 600;
    font-size: 13px;
}
    .top-bar .top-btn:hover { border-color: var(--accent); color: var(--text); }
.top-bar .room-chip { padding: 5px 6px 5px 12px; }
.top-bar .room-copy-btn { min-height: 28px; padding: 3px 10px; margin: 0; }
.top-bar .gmt-clock { margin-left: 0; padding: 7px 12px; }
@media (min-width: 769px) {
    .top-bar { padding: 8px 12px; gap: 16px; }
    .top-bar-left { gap: 18px; }
    .top-bar-right { gap: 8px; }
}
@media (max-width: 768px) {
    .top-bar .tabs { width: 100%; }
    .top-bar .tab { flex: 1 0 auto; }
}

/* ---- Subtabs: quieter than the main tabs ---- */
.subtabs {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    padding: 0;
    gap: 4px;
    margin-bottom: 14px;
}
.subtab {
    padding: 8px 12px 9px;
    border-radius: 0;
    color: var(--text-3);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
    .subtab:hover { color: var(--text); }
    .subtab.active {
        background: transparent;
        box-shadow: none;
        color: var(--text-hi);
        border-bottom-color: var(--accent);
    }

/* ---- Footer: a line at the end of the page, not a fixed slab ---- */
#siteFooter {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 18px;
    margin-top: 28px;
    padding: 12px 16px;
    background: transparent;
    font-size: 12px;
}
#siteFooter .footer-links { display: flex; gap: 6px; align-items: center; }
#siteFooter button,
#siteFooter .bmc-link {
    min-height: 0;
    margin: 0;
    padding: 4px 10px;
    border: 0;
    background: transparent;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}
    #siteFooter button:hover,
    #siteFooter .bmc-link:hover { color: var(--accent); }
@media (min-width: 769px) { #app { padding-bottom: 16px; } }

/* ---- Getting started: compact grid (beats onboarding.js's injected CSS) ---- */
body .onboard { margin-bottom: 14px; }
body .onboard-head { padding: 8px 14px; }
body .onboard-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2px 8px;
    padding: 6px 4px;
}
body .ob-step { padding: 6px 10px; }
body .ob-note { font-size: 12px; }
body .onboard .ob-go {
    min-height: 0;
    margin: 4px 0 0;
    padding: 0;
    border: 0;
    background: none;
    font-size: 12px;
}

/* ---- Setup > Advanced: sized to the values ---- */
.field-grid.adv-row {
    grid-template-columns: repeat(auto-fill, minmax(170px, 210px));
    justify-content: start;
}

/* ---- Drivers > Roster ---- */
#rosterTable { width: auto; min-width: 560px; }
#rosterTable th, #rosterTable td { padding: 6px 10px; }
#rosterTable td input { min-height: 0; height: 30px; padding: 0 8px; font-size: 13px; }
#rosterTable .rs-name input { width: 200px; }
#rosterTable .rs-num { width: 72px; }
#rosterTable .rs-lap { width: 84px; }
#rosterTable .rs-color { width: 1%; }
#rosterTable .rs-color input[type="color"] {
    width: 30px;
    height: 30px;
    padding: 2px;
    border-radius: 8px;
    cursor: pointer;
}
#rosterTable .rs-del { width: 1%; text-align: right; }
#rosterTable .empty-row { text-align: center; color: var(--text-3); padding: 18px; }
.btn-icon-danger {
    min-height: 0;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--text-4);
    font-size: 18px;
    line-height: 1;
}
    .btn-icon-danger:hover { color: var(--crit); border-color: var(--crit); background: var(--crit-dim); }

/* ---- Drivers > Availability ---- */
.avail-intro { margin: 0 0 10px; font-size: 12.5px; color: var(--text-3); }
#availabilityTable { width: auto; }
#availabilityTable th, #availabilityTable td { padding: 3px 6px; font-size: 12px; }
#availabilityTable th { text-align: center; }
#availabilityTable .av-hour { text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; width: 56px; }
#availabilityTable .av-stints { color: var(--text-4); text-align: left; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#availabilityTable .av-driver { min-width: 96px; background: var(--accent-dim); }
#availabilityTable .av-driver .driver-chip { height: 22px; min-width: 0; font-size: 11.5px; }
#availabilityTable .av-cell {
    text-align: center;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
    user-select: none;
    transition: background-color .1s ease;
}
    #availabilityTable .av-cell.on {
        background: color-mix(in srgb, var(--drv) 26%, transparent);
        box-shadow: inset 3px 0 0 var(--drv);
        color: var(--text);
        font-weight: 650;
    }
    #availabilityTable .av-cell.off { background: transparent; color: var(--text-4); }
    #availabilityTable .av-cell:hover { background: color-mix(in srgb, var(--drv) 40%, transparent); }

/* ---- Lobby / landing ---- */
.lobby-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, 380px);
    gap: 48px;
    align-items: center;
    width: min(1040px, 100% - 32px);
    margin: auto;
}
.lobby-logo { height: 44px; width: auto; display: block; margin-bottom: 26px; }
.lobby-headline {
    margin: 0 0 12px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.1;
    letter-spacing: -.02em;
    color: var(--text-hi);
}
.lobby-lede { margin: 0 0 26px; max-width: 52ch; font-size: 15px; line-height: 1.6; color: var(--text-2); }
.lobby-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.lobby-points li {
    display: grid;
    gap: 2px;
    padding-left: 14px;
    border-left: 2px solid rgba(var(--accent-rgb), .6);
}
.lobby-points b { color: var(--text); font-size: 14px; }
.lobby-points span { color: var(--text-3); font-size: 13px; }
#lobby .lobby-card {
    margin: 0;
    max-width: none;
    padding: 26px 22px;
    text-align: left;
    border-color: var(--line-2);
    background: var(--panel);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .45), 0 0 0 1px rgba(var(--accent-rgb), .08);
}
.lobby-card-title { margin: 0 0 16px; font-size: 16px; color: var(--text); }
#lobby .lobby-btn-primary { width: 100%; }
#lobby .lobby-join-row { display: flex; gap: 8px; }
#lobby .lobby-input { flex: 1; min-height: 44px; margin: 0; text-transform: none; letter-spacing: .08em; font-family: ui-monospace, Consolas, monospace; }
#lobby .lobby-btn-secondary { margin: 0; min-height: 44px; }
@media (max-width: 820px) {
    .lobby-wrap { grid-template-columns: 1fr; gap: 24px; padding: 24px 0; }
    #lobby { overflow-y: auto; align-items: flex-start !important; }
}

/* v1.7 fixes after render check */
.field-grid.setup-row {
    grid-template-columns: minmax(120px, 140px) minmax(220px, 250px) minmax(170px, 200px) minmax(120px, 140px) minmax(110px, 130px);
}
#tab0 .field > label { white-space: nowrap; }
#tab0 .field.is-derived > .value { white-space: nowrap; font-size: 14px; }
.top-bar .room-name { min-height: 0; margin: 0; padding: 2px 4px; }
.top-bar .top-btn { min-height: 0; margin: 0; }
.roster-wrap,
#sub22 .table-wrap { width: fit-content; max-width: 100%; }
.roster-wrap #rosterTable,
#sub22 #availabilityTable { width: auto; }
#lobby {
    background:
        radial-gradient(ellipse 60% 50% at 18% 30%, rgba(var(--accent-rgb), .09), transparent 70%),
        radial-gradient(ellipse 40% 40% at 85% 75%, rgba(var(--accent-rgb), .05), transparent 70%),
        var(--bg) !important;
}
.lobby-card-title { border: 0; padding: 0; }
body .onboard-x { min-height: 0; margin: 0; padding: 2px 6px; }

/* Driver chips are <button>s in the tables: undo the global 42px min-height
 * that made every schedule row ~48px tall. */
#stintScheduleTable .driver-chip,
#tireScheduleTable .driver-chip,
.live-stint-table .driver-chip { min-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; }

/* ============================================================
   Split view (js/split-view.js)
   ============================================================ */
.split-btn {
    display: none;                      /* shown on wide screens only */
    align-items: center;
    gap: 7px;
    min-height: 0;
    height: 34px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--line-2);
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
    .split-btn:hover { border-color: var(--accent); color: var(--text); }
    .split-btn:active { transform: none; }
    .split-btn .pw-icon {
        width: 14px;
        height: 11px;
        border: 1.5px solid currentColor;
        border-radius: 2px;
        background: linear-gradient(90deg, transparent 45%, currentColor 45%, currentColor 55%, transparent 55%);
    }
    .split-btn.is-on {
        color: var(--accent);
        border-color: rgba(var(--accent-rgb), .6);
        background: rgba(var(--accent-rgb), .14);
    }
@media (min-width: 1100px) { .split-btn { display: inline-flex; } }

body.split-on #app { max-width: none; }
body.split-on .split-wrap {
    display: grid;
    grid-template-columns: minmax(0, var(--split-l, 1fr)) 10px minmax(0, var(--split-r, 1fr));
    column-gap: 4px;
    align-items: start;
}
.pane-main { min-width: 0; }
.pane-split,
.split-handle {
    position: sticky;
    top: 8px;
    height: calc(100vh - 16px);
}
body.has-race-ticker .pane-split,
body.has-race-ticker .split-handle { top: 50px; height: calc(100vh - 58px); }
.pane-split {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg);
}
    .pane-split iframe { display: block; width: 100%; height: 100%; border: 0; }
.split-handle {
    cursor: col-resize;
    border-radius: 5px;
    background: linear-gradient(90deg, transparent 4px, var(--line-2) 4px, var(--line-2) 6px, transparent 6px);
}
    .split-handle:hover { background: linear-gradient(90deg, transparent 3px, var(--accent) 3px, var(--accent) 7px, transparent 7px); }
body.split-dragging { cursor: col-resize; user-select: none; }
body.split-dragging iframe { pointer-events: none; }
.pane-split[hidden], .split-handle[hidden] { display: none; }
/* The live Race tab sizes to the viewport; in a pane it sizes to the pane. */
body.split-on #liveFrame { height: calc(100vh - 110px) !important; }

/* ---- Inside the second pane: tabs only, no page chrome ---- */
body.is-embed #app { max-width: none; padding: 0 10px 10px; }
body.is-embed .top-bar { margin: 8px 0 8px; padding: 4px; border-radius: 10px; }
body.is-embed .top-bar-right,
body.is-embed .brand,
body.is-embed #raceTicker,
body.is-embed #siteFooter,
body.is-embed #onboardBox,
body.is-embed #planStrip,
body.is-embed #splitPane,
body.is-embed #splitHandle { display: none !important; }
body.is-embed.has-race-ticker #app { padding-top: 0; }
body.is-embed.has-plan-strip { padding-bottom: 0; }
body.is-embed #liveFrame { height: calc(100vh - 64px) !important; }

/* ---- Split view: both panes mirror each other ----
 * Left: the main tab bar moved into .pane-main by split-view.js.
 * Right: the embedded app's own bar, with its header chrome stripped.
 * Same bar, same position, same spacing, so tabs and subtabs line up. */
.pane-main > nav.tabs,
body.is-embed .top-bar nav.tabs {
    display: flex;
    width: fit-content;
    margin: 0 0 10px;
    padding: 3px;
    gap: 2px;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.pane-main > nav.tabs .tab,
body.is-embed .top-bar nav.tabs .tab {
    flex: 0 0 auto;
    padding: 7px 16px;
    font-size: 13.5px;
    border-radius: 7px;
}
.pane-main > nav.tabs .tab.active,
body.is-embed .top-bar nav.tabs .tab.active {
    background: rgba(var(--accent-rgb), .16);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .45);
}
body.is-embed #app { padding: 0; }
body.is-embed .top-bar {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    display: block;
}
body.is-embed .top-bar-left { gap: 0; }
/* No frame round the second pane: the divider separates them, and a border
 * on one side only is what made the right pane look inset. */
.pane-split { border: 0; border-radius: 0; background: transparent; }

/* ---- Footer stays put ----
 * As a plain line after the content it jumped to a new height on every tab.
 * The app area now always fills the screen, so on any tab that fits, the
 * footer sits at the bottom of the window in the same place; on long tabs it
 * is below the content, out of view until you scroll there. The plan strip,
 * when shown, is fixed to the bottom, so the footer sits above it. */
@media (min-width: 769px) {
    #siteFooter { margin-top: 0; height: 50px; box-sizing: border-box; }
    #app { min-height: calc(100vh - 50px); box-sizing: border-box; }
    body.has-plan-strip #app { min-height: calc(100vh - 50px - 52px); }
}
body.is-embed #app { min-height: 0; }

/* ============================================================
   One design language (v1.9)
   Tab levels:   1 = boxed pill bar (Setup/Plan/Race/Drivers)
                 2 = underline bar with a hairline (subtabs, live tabs)
   Toolbars:     32px buttons, 13px/600, 8px radius, 8px gaps
   Card titles:  11px uppercase, .06em, --text-3
   Section rule: 12px uppercase heading + hairline (.section)
   ============================================================ */
.subtabs { margin-bottom: 14px; }
.subtab { padding: 8px 12px 9px; font-size: 13px; }
.plan-toolbar { padding: 8px 10px; gap: 8px; }
.plan-toolbar button,
.plan-toolbar summary,
.tire-toolbar .btn-primary {
    height: 32px;
    min-height: 0;
    margin: 0;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
}
.tire-inputs .ti-col, .tire-inputs .ti-label { letter-spacing: .06em; }
th { letter-spacing: .06em; }
.section h2, .section h3 { font-size: 12px; letter-spacing: .08em; }
/* Race tab starts at the same height as every other tab's subtabs. */
#tab4 { padding-top: 8px !important; }

/* Stint type with no rates of its own (planned with Standard values). */
.stint-type-btn .no-rates-mark { margin-left: 2px; font-size: 9px; font-weight: 800; color: var(--warn); }
.stint-type-menu .tnote { margin-left: 6px; font-size: 10.5px; font-weight: 500; color: var(--warn); }

/* Landing: says up front which game this is for. */
.lobby-badge {
    display: inline-block;
    margin: 0 0 14px;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), .45);
    background: rgba(var(--accent-rgb), .10);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.lobby-logo + .lobby-badge { margin-top: -6px; }
