/* ==========================================================================
   F1 Scraper — Editorial Motorsport Design System
   ========================================================================== */

/* Reset and base */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    /* Spacing scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Type scale */
    --text-xs: 0.7rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: 2.5rem;
    --text-4xl: 3.5rem;

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;

    /* Transitions */
    --transition-fast: 120ms ease;
    --transition-base: 200ms ease;
    --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* F1 Light (default — steel blue) */
    --primary: #1565c0;
    --primary-hover: #1e88e5;
    --primary-glow: rgba(21, 101, 192, 0.10);
    --primary-dark: #0d47a1;
    --primary-subtle: rgba(21, 101, 192, 0.05);

    --bg: #f4f6f9;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9fb;
    --bg-hover: #edf0f5;
    --bg-surface: #e8ecf2;

    --text: #141820;
    --text-secondary: #3a4050;
    --text-muted: #606878;
    --text-dim: #98a0b0;

    --border: #d0d6e0;
    --border-subtle: #e2e6ee;

    --gold: #b8860b;
    --silver: #6b7280;
    --bronze: #a0522d;
    --success: #16a34a;
    --warning: #ca8a04;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.09);
    --shadow-glow: 0 4px 16px rgba(21, 101, 192, 0.18);

    --map-land: #d4dae5;
    --map-label-bg: rgba(255, 255, 255, 0.92);
    --map-label-shadow: #98a0b0;
}

/* ==========================================================================
   F1 Dark
   ========================================================================== */

[data-mode="dark"] {
    --primary: #42a5f5;
    --primary-hover: #64b5f6;
    --primary-glow: rgba(66, 165, 245, 0.15);
    --primary-dark: #1e88e5;
    --primary-subtle: rgba(66, 165, 245, 0.06);

    --bg: #0a0c10;
    --bg-elevated: #10131a;
    --bg-card: #151920;
    --bg-card-hover: #1a1f28;
    --bg-hover: #202630;
    --bg-surface: #181d26;

    --text: #e8ecf0;
    --text-secondary: #a8b0c0;
    --text-muted: #687080;
    --text-dim: #485060;

    --border: #283040;
    --border-subtle: #1c2430;

    --gold: #f5c518;
    --silver: #c4c8d0;
    --bronze: #c87533;
    --success: #22c55e;
    --warning: #f5c518;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 4px 16px rgba(66, 165, 245, 0.3);

    --map-land: #1a2030;
    --map-label-bg: rgba(0, 0, 0, 0.75);
    --map-label-shadow: #000;
}

/* ==========================================================================
   Ferrari Light
   ========================================================================== */

[data-theme="ferrari"] {
    --primary: #c80000;
    --primary-hover: #e81010;
    --primary-glow: rgba(200, 0, 0, 0.12);
    --primary-dark: #a00000;
    --primary-subtle: rgba(200, 0, 0, 0.06);

    --bg: #faf5f4;
    --bg-elevated: #ffffff;
    --bg-card: #fff8f7;
    --bg-card-hover: #fef2f0;
    --bg-hover: #f5eae8;
    --bg-surface: #f0e6e4;

    --text: #1f0c0a;
    --text-secondary: #4a2a26;
    --text-muted: #7a5550;
    --text-dim: #aa8e8a;

    --border: #e0c8c4;
    --border-subtle: #ecdcda;

    --gold: #b8860b;
    --silver: #6b7280;
    --bronze: #a0522d;
    --success: #16a34a;
    --warning: #ca8a04;

    --shadow-sm: 0 1px 3px rgba(100, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(100, 0, 0, 0.06);
    --shadow-lg: 0 8px 32px rgba(100, 0, 0, 0.08);
    --shadow-glow: 0 4px 16px rgba(200, 0, 0, 0.18);

    --map-land: #e5d0cc;
    --map-label-bg: rgba(255, 248, 247, 0.92);
    --map-label-shadow: #aa8e8a;
}

/* ==========================================================================
   Ferrari Dark
   ========================================================================== */

[data-theme="ferrari"][data-mode="dark"] {
    --primary: #dc0000;
    --primary-hover: #ff2a2a;
    --primary-glow: rgba(220, 0, 0, 0.22);
    --primary-dark: #a80000;
    --primary-subtle: rgba(220, 0, 0, 0.10);

    --bg: #140808;
    --bg-elevated: #221010;
    --bg-card: #2a1414;
    --bg-card-hover: #341a1a;
    --bg-hover: #3e2020;
    --bg-surface: #301616;

    --text: #f5ece6;
    --text-secondary: #cbb8ae;
    --text-muted: #967a6e;
    --text-dim: #6b5248;

    --border: #4e2a2a;
    --border-subtle: #3a1c1c;

    --gold: #f5c518;
    --silver: #c4c8d0;
    --bronze: #c87533;
    --success: #22c55e;
    --warning: #f5c518;

    --shadow-sm: 0 2px 8px rgba(80, 0, 0, 0.4);
    --shadow-md: 0 8px 32px rgba(80, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(60, 0, 0, 0.5);
    --shadow-glow: 0 4px 20px rgba(220, 0, 0, 0.4);

    --map-land: #361818;
    --map-label-bg: rgba(20, 8, 8, 0.9);
    --map-label-shadow: #000;
}

/* ==========================================================================
   McLaren Light
   ========================================================================== */

[data-theme="mclaren"] {
    --primary: #e06800;
    --primary-hover: #ff8800;
    --primary-glow: rgba(224, 104, 0, 0.12);
    --primary-dark: #b85500;
    --primary-subtle: rgba(224, 104, 0, 0.06);

    --bg: #faf7f2;
    --bg-elevated: #ffffff;
    --bg-card: #fffaf4;
    --bg-card-hover: #fef4ea;
    --bg-hover: #f5ece0;
    --bg-surface: #f0e5d8;

    --text: #1f1408;
    --text-secondary: #4a3518;
    --text-muted: #7a6040;
    --text-dim: #aa9470;

    --border: #e0d0b8;
    --border-subtle: #ece0d0;

    --gold: #b8860b;
    --silver: #6b7280;
    --bronze: #a0522d;
    --success: #16a34a;
    --warning: #ca8a04;

    --shadow-sm: 0 1px 3px rgba(80, 40, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(80, 40, 0, 0.06);
    --shadow-lg: 0 8px 32px rgba(80, 40, 0, 0.08);
    --shadow-glow: 0 4px 16px rgba(224, 104, 0, 0.18);

    --map-land: #e5d8c4;
    --map-label-bg: rgba(255, 250, 244, 0.92);
    --map-label-shadow: #aa9470;
}

/* ==========================================================================
   McLaren Dark
   ========================================================================== */

[data-theme="mclaren"][data-mode="dark"] {
    --primary: #ff8000;
    --primary-hover: #ff9933;
    --primary-glow: rgba(255, 128, 0, 0.20);
    --primary-dark: #d66a00;
    --primary-subtle: rgba(255, 128, 0, 0.08);

    --bg: #120e08;
    --bg-elevated: #1e1810;
    --bg-card: #261e14;
    --bg-card-hover: #30261a;
    --bg-hover: #3a2e20;
    --bg-surface: #2c2216;

    --text: #f5efe6;
    --text-secondary: #c8b8a4;
    --text-muted: #918068;
    --text-dim: #665840;

    --border: #4a3820;
    --border-subtle: #362814;

    --gold: #f5c518;
    --silver: #c4c8d0;
    --bronze: #c87533;
    --success: #22c55e;
    --warning: #f5c518;

    --shadow-sm: 0 2px 8px rgba(60, 30, 0, 0.4);
    --shadow-md: 0 8px 32px rgba(60, 30, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(40, 20, 0, 0.5);
    --shadow-glow: 0 4px 20px rgba(255, 128, 0, 0.35);

    --map-land: #302414;
    --map-label-bg: rgba(18, 14, 8, 0.9);
    --map-label-shadow: #000;
}

/* ==========================================================================
   Sunset Boulevard Light
   ========================================================================== */

[data-theme="sunset"] {
    --primary: #e76f51;
    --primary-hover: #f4a261;
    --primary-glow: rgba(231, 111, 81, 0.12);
    --primary-dark: #c45a3f;
    --primary-subtle: rgba(231, 111, 81, 0.06);

    --bg: #faf6f0;
    --bg-elevated: #ffffff;
    --bg-card: #fef9f2;
    --bg-card-hover: #fcf2e8;
    --bg-hover: #f5e8d8;
    --bg-surface: #f0e2d0;

    --text: #1a2e38;
    --text-secondary: #3a5060;
    --text-muted: #607078;
    --text-dim: #98a0a8;

    --border: #d8c8b0;
    --border-subtle: #e8d8c4;

    --gold: #b8860b;
    --silver: #6b7280;
    --bronze: #a0522d;
    --success: #16a34a;
    --warning: #ca8a04;

    --shadow-sm: 0 1px 3px rgba(60, 30, 10, 0.06);
    --shadow-md: 0 4px 16px rgba(60, 30, 10, 0.06);
    --shadow-lg: 0 8px 32px rgba(60, 30, 10, 0.08);
    --shadow-glow: 0 4px 16px rgba(231, 111, 81, 0.18);

    --map-land: #e5d4be;
    --map-label-bg: rgba(254, 249, 242, 0.92);
    --map-label-shadow: #98a0a8;
}

/* ==========================================================================
   Sunset Boulevard Dark
   ========================================================================== */

[data-theme="sunset"][data-mode="dark"] {
    --primary: #f4a261;
    --primary-hover: #e9c46a;
    --primary-glow: rgba(244, 162, 97, 0.20);
    --primary-dark: #e76f51;
    --primary-subtle: rgba(244, 162, 97, 0.08);

    --bg: #0c1a20;
    --bg-elevated: #142028;
    --bg-card: #1a2830;
    --bg-card-hover: #203038;
    --bg-hover: #283840;
    --bg-surface: #1e2c34;

    --text: #f5ece0;
    --text-secondary: #c8b8a0;
    --text-muted: #908068;
    --text-dim: #605040;

    --border: #3a4e58;
    --border-subtle: #2c3e48;

    --gold: #f5c518;
    --silver: #c4c8d0;
    --bronze: #c87533;
    --success: #22c55e;
    --warning: #f5c518;

    --shadow-sm: 0 2px 8px rgba(10, 20, 30, 0.4);
    --shadow-md: 0 8px 32px rgba(10, 20, 30, 0.35);
    --shadow-lg: 0 16px 48px rgba(5, 10, 20, 0.5);
    --shadow-glow: 0 4px 20px rgba(244, 162, 97, 0.35);

    --map-land: #1e3040;
    --map-label-bg: rgba(12, 26, 32, 0.9);
    --map-label-shadow: #000;
}

/* ==========================================================================
   Modern Minimalist Light
   ========================================================================== */

[data-theme="minimalist"] {
    --primary: #36454f;
    --primary-hover: #4a5a66;
    --primary-glow: rgba(54, 69, 79, 0.10);
    --primary-dark: #2a3640;
    --primary-subtle: rgba(54, 69, 79, 0.05);

    --bg: #f8f8f8;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f5f5f5;
    --bg-hover: #eeeeee;
    --bg-surface: #e8e8e8;

    --text: #1a1a1a;
    --text-secondary: #404040;
    --text-muted: #6a6a6a;
    --text-dim: #a0a0a0;

    --border: #d3d3d3;
    --border-subtle: #e2e2e2;

    --gold: #b8860b;
    --silver: #6b7280;
    --bronze: #a0522d;
    --success: #16a34a;
    --warning: #ca8a04;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.07);
    --shadow-glow: 0 4px 16px rgba(54, 69, 79, 0.14);

    --map-land: #d3d3d3;
    --map-label-bg: rgba(255, 255, 255, 0.92);
    --map-label-shadow: #a0a0a0;
}

/* ==========================================================================
   Modern Minimalist Dark
   ========================================================================== */

[data-theme="minimalist"][data-mode="dark"] {
    --primary: #708090;
    --primary-hover: #8a9aa8;
    --primary-glow: rgba(112, 128, 144, 0.18);
    --primary-dark: #56687a;
    --primary-subtle: rgba(112, 128, 144, 0.08);

    --bg: #0e0e0e;
    --bg-elevated: #161616;
    --bg-card: #1c1c1c;
    --bg-card-hover: #242424;
    --bg-hover: #2a2a2a;
    --bg-surface: #202020;

    --text: #e8e8e8;
    --text-secondary: #b0b0b0;
    --text-muted: #787878;
    --text-dim: #505050;

    --border: #383838;
    --border-subtle: #2c2c2c;

    --gold: #f5c518;
    --silver: #c4c8d0;
    --bronze: #c87533;
    --success: #22c55e;
    --warning: #f5c518;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 4px 20px rgba(112, 128, 144, 0.30);

    --map-land: #282828;
    --map-label-bg: rgba(14, 14, 14, 0.9);
    --map-label-shadow: #000;
}

/* ==========================================================================
   Botanical Garden Light
   ========================================================================== */

[data-theme="botanical"] {
    --primary: #4a7c59;
    --primary-hover: #5a9068;
    --primary-glow: rgba(74, 124, 89, 0.12);
    --primary-dark: #3a6448;
    --primary-subtle: rgba(74, 124, 89, 0.06);

    --bg: #f5f3ed;
    --bg-elevated: #ffffff;
    --bg-card: #faf8f4;
    --bg-card-hover: #f2efe8;
    --bg-hover: #ece8de;
    --bg-surface: #e6e2d6;

    --text: #1c2418;
    --text-secondary: #3a4430;
    --text-muted: #606858;
    --text-dim: #98a088;

    --border: #d0caba;
    --border-subtle: #dcd8cc;

    --gold: #b8860b;
    --silver: #6b7280;
    --bronze: #a0522d;
    --success: #16a34a;
    --warning: #f9a620;

    --shadow-sm: 0 1px 3px rgba(30, 40, 20, 0.06);
    --shadow-md: 0 4px 16px rgba(30, 40, 20, 0.06);
    --shadow-lg: 0 8px 32px rgba(30, 40, 20, 0.08);
    --shadow-glow: 0 4px 16px rgba(74, 124, 89, 0.18);

    --map-land: #c8d4b8;
    --map-label-bg: rgba(250, 248, 244, 0.92);
    --map-label-shadow: #98a088;
}

/* ==========================================================================
   Botanical Garden Dark
   ========================================================================== */

[data-theme="botanical"][data-mode="dark"] {
    --primary: #5a9068;
    --primary-hover: #6aa878;
    --primary-glow: rgba(90, 144, 104, 0.20);
    --primary-dark: #4a7c59;
    --primary-subtle: rgba(90, 144, 104, 0.08);

    --bg: #0c1210;
    --bg-elevated: #141e18;
    --bg-card: #1a2820;
    --bg-card-hover: #203028;
    --bg-hover: #283830;
    --bg-surface: #1e2c24;

    --text: #e8ece4;
    --text-secondary: #b0b8a4;
    --text-muted: #788068;
    --text-dim: #505840;

    --border: #344030;
    --border-subtle: #283420;

    --gold: #f5c518;
    --silver: #c4c8d0;
    --bronze: #c87533;
    --success: #22c55e;
    --warning: #f9a620;

    --shadow-sm: 0 2px 8px rgba(10, 20, 10, 0.4);
    --shadow-md: 0 8px 32px rgba(10, 20, 10, 0.35);
    --shadow-lg: 0 16px 48px rgba(5, 10, 5, 0.5);
    --shadow-glow: 0 4px 20px rgba(90, 144, 104, 0.35);

    --map-land: #1e3424;
    --map-label-bg: rgba(12, 18, 16, 0.9);
    --map-label-shadow: #000;
}

/* ==========================================================================
   Dark mode shared overrides (noise texture, select arrow, etc.)
   ========================================================================== */

[data-mode="dark"] body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.015'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
}

[data-mode="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23737385' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

[data-mode="dark"] .data-table .position.gold {
    text-shadow: 0 0 12px rgba(245, 197, 24, 0.3);
}

[data-mode="dark"] .navbar {
    box-shadow: none;
}

[data-mode="dark"] .alert-warning {
    background: rgba(245, 197, 24, 0.06);
    border-color: rgba(245, 197, 24, 0.2);
}

/* Base typography */
body {
    margin: 0;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: var(--text-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark mode overrides are keyed off [data-mode="dark"] above */

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

h1, h2, h3, h4, h5 {
    font-family: 'Outfit', 'DM Sans', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.navbar {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
    padding: 0 var(--space-xl);
    height: 60px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.nav-brand a {
    font-family: 'Outfit', sans-serif;
    font-size: var(--text-lg);
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.nav-brand a::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 20px;
    background: var(--primary);
    border-radius: 2px;
}

.nav-links {
    display: flex;
    gap: 0;
}

.nav-links a {
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0 var(--space-md);
    height: 60px;
    display: flex;
    align-items: center;
    position: relative;
    transition: color var(--transition-base);
}

.nav-links a:hover {
    color: var(--text);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: var(--space-md);
    right: var(--space-md);
    height: 2px;
    background: var(--primary);
    transform: scaleX(0);
    transition: transform var(--transition-smooth);
}

.nav-links a:hover::after {
    transform: scaleX(1);
}

/* Theme controls */
.theme-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Theme picker dropdown */
.theme-picker {
    position: relative;
}

.theme-picker-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 100px;
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm) var(--space-xs) var(--space-xs);
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    transition: all var(--transition-base);
    font-family: 'Outfit', sans-serif;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    height: 34px;
}

.theme-picker-btn:hover {
    color: var(--text);
    border-color: var(--primary);
    background: var(--bg-hover);
}

.theme-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

.theme-picker-menu {
    display: none;
    position: absolute;
    top: calc(100% + var(--space-sm));
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    min-width: 180px;
    padding: var(--space-xs);
    animation: fadeIn 0.15s ease;
}

.theme-picker-menu.open {
    display: block;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-family: inherit;
    transition: background var(--transition-fast);
}

.theme-option:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.theme-option.active {
    color: var(--primary);
    font-weight: 600;
}

.theme-option .swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    position: relative;
}

.theme-option.active .swatch::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--primary);
}

.theme-option .theme-name {
    flex: 1;
}

/* Mode toggle (light/dark) */
.mode-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 100px;
    cursor: pointer;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--transition-base);
    padding: 0;
    flex-shrink: 0;
}

.mode-toggle:hover {
    color: var(--text);
    border-color: var(--primary);
    background: var(--bg-hover);
}

.mode-toggle svg {
    width: 15px;
    height: 15px;
    transition: transform var(--transition-smooth);
}

.mode-toggle:hover svg {
    transform: rotate(15deg);
}

/* Show/hide icons based on mode — light default shows sun, dark shows moon */
.mode-toggle .icon-sun { display: block; }
.mode-toggle .icon-moon { display: none; }

[data-mode="dark"] .mode-toggle .icon-sun { display: none; }
[data-mode="dark"] .mode-toggle .icon-moon { display: block; }

.nav-search {
    margin-left: auto;
    position: relative;
}

.nav-search input {
    padding: var(--space-sm) var(--space-md);
    padding-left: 2.25rem;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--bg);
    color: var(--text);
    width: 240px;
    font-size: var(--text-sm);
    font-family: inherit;
    transition: all var(--transition-base);
}

.nav-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    width: 300px;
}

.nav-search input::placeholder {
    color: var(--text-dim);
}

.nav-search::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border: 2px solid var(--text-dim);
    border-radius: 50%;
    pointer-events: none;
}

.nav-search::after {
    content: '';
    position: absolute;
    left: 1.55rem;
    top: calc(50% + 5px);
    width: 2px;
    height: 6px;
    background: var(--text-dim);
    transform: rotate(-45deg);
    pointer-events: none;
}

/* Search dropdown */
.search-dropdown {
    position: absolute;
    top: calc(100% + var(--space-sm));
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    z-index: 100;
    display: none;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.search-dropdown:not(:empty) {
    display: block;
}

.search-results-content {
    padding: var(--space-sm);
}

.search-section h4 {
    margin: var(--space-sm) var(--space-sm) var(--space-xs);
    color: var(--text-dim);
    font-family: 'Outfit', sans-serif;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.search-item {
    display: block;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: var(--text-sm);
    transition: background var(--transition-fast);
}

.search-item:hover {
    background: var(--bg-hover);
    text-decoration: none;
}

.search-empty {
    padding: var(--space-lg);
    color: var(--text-muted);
    text-align: center;
    font-size: var(--text-sm);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-2xl);
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
    text-align: center;
    padding: var(--space-3xl) 0 var(--space-2xl);
    position: relative;
}

.hero::before {
    content: '';
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 300px;
    background: radial-gradient(ellipse, var(--primary-glow) 0%, transparent 70%);
    pointer-events: none;
}

.hero h1 {
    font-size: var(--text-4xl);
    margin: 0 0 var(--space-md);
    background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
}

.hero p {
    color: var(--text-muted);
    font-size: var(--text-lg);
    margin: 0;
    font-weight: 400;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    transition: all var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary) 0%, transparent 100%);
    opacity: 0;
    transition: opacity var(--transition-smooth);
}

.card:hover {
    border-color: var(--border);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card:hover::before {
    opacity: 1;
}

.card .btn:last-child {
    margin-top: auto;
}

.season-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
    margin: var(--space-xl) 0;
}

.card h2 {
    margin-top: 0;
    margin-bottom: var(--space-sm);
    color: var(--text);
    font-size: var(--text-xl);
}

.card p {
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-top: 0;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-xs);
    color: var(--text-dim);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-family: 'Outfit', sans-serif;
}

select, input[type="text"], input[type="search"] {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    color: var(--text);
    font-size: var(--text-sm);
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

select:focus, input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236e6e80' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-sm);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    pointer-events: none;
}

.btn:hover {
    background: var(--primary-dark);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.btn-secondary::after {
    display: none;
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text);
    box-shadow: none;
}

.btn-small {
    padding: 0.25rem 0.75rem;
    font-size: var(--text-xs);
}

/* ==========================================================================
   Controls bar
   ========================================================================== */

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: flex-end;
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.controls .form-group {
    margin-bottom: 0;
    min-width: 140px;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.data-table th,
.data-table td {
    padding: 0.625rem var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
    background: var(--bg-elevated);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.1em;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table .position {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    width: 48px;
    text-align: center;
    font-size: var(--text-sm);
}

.data-table .points {
    color: var(--gold);
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.data-table .team {
    color: var(--text-muted);
}

.data-table .empty {
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-2xl);
}

.data-table.compact th,
.data-table.compact td {
    padding: var(--space-sm) 0.625rem;
}

.data-table a {
    color: var(--text);
    transition: color var(--transition-fast);
}

.data-table a:hover {
    color: var(--primary);
}

.data-table .muted a {
    color: var(--text-muted);
}

.data-table .muted a:hover {
    color: var(--primary);
}

/* ==========================================================================
   Content Grid (table + chart)
   ========================================================================== */

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

.chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    min-height: 400px;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.chart-header h2 {
    font-size: var(--text-lg);
    margin: 0;
}

.chart-toggle {
    display: flex;
    gap: var(--space-xs);
}

.btn-active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-active:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.chart-section h2 {
    font-size: var(--text-lg);
    margin-top: 0;
    margin-bottom: var(--space-md);
}

.chart-section canvas {
    max-height: 500px;
}

/* ==========================================================================
   Championship Leaders
   ========================================================================== */

.controls-split {
    display: flex;
    gap: var(--space-lg);
    align-items: flex-start;
}

.season-controls-table {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    border-collapse: collapse;
}

.season-controls-table td {
    padding: var(--space-sm) var(--space-md);
}

.season-controls-table td:first-child {
    color: var(--text-muted);
    font-size: var(--text-sm);
    white-space: nowrap;
}

.season-controls-table td:first-child a {
    color: var(--text-muted);
    text-decoration: none;
}

.season-controls-table td:first-child a:hover {
    color: var(--primary);
}

.season-controls-table .leader-name {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--primary);
}

.season-controls-table .leader-points {
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-left: var(--space-sm);
}

.championship-leaders-table {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    border-collapse: collapse;
}

.championship-leaders-table td {
    padding: var(--space-sm) var(--space-md);
}

.championship-leaders-table td:first-child {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.championship-leaders-table td:first-child a {
    color: var(--text-muted);
    text-decoration: none;
}

.championship-leaders-table td:first-child a:hover {
    color: var(--primary);
}

.championship-leaders-table .leader-name {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--primary);
}

.championship-leaders-table .leader-points {
    color: var(--text-muted);
    font-size: var(--text-sm);
    text-align: right;
}

/* ==========================================================================
   Races
   ========================================================================== */

.races-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: var(--space-xl);
    align-items: start;
}

@media (max-width: 900px) {
    .races-grid {
        grid-template-columns: 1fr;
    }
}

.race-cards {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.race-card {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.race-card:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.race-card.active {
    border-color: var(--primary);
    background: var(--bg-hover);
    box-shadow: inset 3px 0 0 var(--primary);
}

.race-round {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    color: var(--primary);
    min-width: 36px;
    font-size: var(--text-sm);
}

.race-name {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: var(--text-sm);
}

.race-circuit,
.race-date {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.race-results-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.race-header {
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.race-header h3 {
    margin: 0 0 var(--space-sm);
    font-family: 'Outfit', sans-serif;
}

/* Circuit dropdown */
.circuit-dropdown {
    position: relative;
    display: inline-block;
}

.circuit-link {
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    font-size: var(--text-sm);
    transition: color var(--transition-fast);
}

.circuit-link:hover {
    color: var(--primary);
}

.circuit-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 100;
    min-width: 160px;
    padding: var(--space-xs) 0;
    margin-top: var(--space-xs);
}

.circuit-dropdown:hover .circuit-dropdown-menu {
    display: block;
}

.circuit-dropdown-menu a {
    display: block;
    padding: var(--space-sm) var(--space-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

.circuit-dropdown-menu a:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.race-meta {
    display: flex;
    gap: var(--space-md);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.hint {
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-2xl);
    font-size: var(--text-sm);
}

/* ==========================================================================
   Comparison
   ========================================================================== */

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.comparison-tables {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.comparison-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.comparison-card h3 {
    margin-top: 0;
    margin-bottom: var(--space-md);
    font-size: var(--text-base);
    font-family: 'Outfit', sans-serif;
}

/* ==========================================================================
   Statistics
   ========================================================================== */

.stats-summary {
    margin-top: var(--space-3xl);
    text-align: center;
}

.stats-summary h2 {
    font-size: var(--text-xl);
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: var(--space-lg);
}

.stats-grid {
    display: flex;
    justify-content: center;
    gap: var(--space-2xl);
    margin-top: var(--space-md);
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-family: 'Outfit', sans-serif;
    font-size: var(--text-3xl);
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.stat-label {
    color: var(--text-dim);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
    transition: all var(--transition-smooth);
}

.stat-card:hover {
    border-color: var(--border);
}

.stat-card .stat-value {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-xs);
}

.stat-card .stat-label {
    font-size: var(--text-xs);
}

/* Stat cards within summary */
.summary-stats {
    margin-bottom: var(--space-xl);
}

.summary-stats .stats-grid {
    justify-content: flex-start;
    gap: var(--space-md);
}

.summary-stats .stat-card {
    min-width: 120px;
}

/* Teams section */
.teams-section {
    margin: var(--space-xl) 0;
}

.teams-section h2 {
    margin-bottom: var(--space-md);
}

.teams-section .data-table {
    max-width: 600px;
}

/* Team actions */
.team-actions {
    margin-top: var(--space-lg);
}

/* Checkbox filters */
.checkbox-filters {
    display: flex;
    gap: var(--space-md);
    align-items: center;
}

/* ==========================================================================
   Profiles
   ========================================================================== */

.profile-header {
    margin-bottom: var(--space-xl);
}

.profile-header h1 {
    margin-bottom: var(--space-sm);
    font-size: var(--text-3xl);
}

.profile-meta {
    display: flex;
    gap: var(--space-md);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.nationality-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.nationality-link:hover {
    color: var(--primary);
}

.subtitle {
    color: var(--text-muted);
    margin-top: calc(-1 * var(--space-sm));
    font-size: var(--text-sm);
}

.country-stats {
    margin-bottom: var(--space-xl);
}

.country-stats .stats-grid {
    justify-content: flex-start;
    gap: var(--space-md);
}

/* ==========================================================================
   Pages
   ========================================================================== */

.page-header {
    margin-bottom: var(--space-lg);
}

.page-header h1 {
    margin-bottom: var(--space-xs);
    font-size: var(--text-2xl);
}

.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.page-header-row h1 {
    margin: 0;
}

.filter-form {
    display: contents;
}

.filter-info {
    margin-bottom: var(--space-lg);
    color: var(--text-muted);
    font-size: var(--text-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--primary-subtle);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary);
}

.filter-info strong {
    color: var(--text);
}

.country-link {
    color: var(--text);
    font-weight: 500;
    transition: color var(--transition-fast);
}

.country-link:hover {
    color: var(--primary);
}

.data-table .wins {
    color: var(--success);
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

/* ==========================================================================
   Clickable Stat Cards
   ========================================================================== */

.stat-link {
    text-decoration: none;
    transition: all var(--transition-smooth);
    cursor: pointer;
    display: block;
}

.stat-link:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.stat-link .stat-value {
    color: var(--text);
    transition: color var(--transition-fast);
}

.stat-link:hover .stat-value {
    color: var(--primary);
}

.stat-link:hover .stat-card {
    border-color: var(--primary);
}

.stat-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.stat-disabled .stat-value {
    color: var(--text-dim);
}

/* ==========================================================================
   Breadcrumb
   ========================================================================== */

.breadcrumb {
    display: flex;
    gap: var(--space-sm);
    color: var(--text-dim);
    font-size: var(--text-xs);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.breadcrumb a {
    color: var(--text-dim);
    transition: color var(--transition-fast);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb span {
    color: var(--text-dim);
}

/* ==========================================================================
   Tabs
   ========================================================================== */

.filter-tabs {
    display: flex;
    gap: 0;
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.tab {
    padding: var(--space-sm) var(--space-md);
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
    transition: all var(--transition-base);
    position: relative;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab:hover {
    color: var(--text);
    text-decoration: none;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
}

.tab.disabled {
    color: var(--text-dim);
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==========================================================================
   Results Count
   ========================================================================== */

.results-count {
    color: var(--text-dim);
    margin-bottom: var(--space-md);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: var(--space-3xl);
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: var(--space-lg);
    font-size: var(--text-sm);
}

/* ==========================================================================
   Table Enhancements
   ========================================================================== */

.data-table .muted {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.data-table .time {
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    color: var(--text-muted);
    font-size: var(--text-xs);
}

/* Podium position colors with glow effect */
.data-table .position.gold {
    color: var(--gold);
    font-weight: 800;
}

.data-table .position.silver {
    color: var(--silver);
    font-weight: 800;
}

.data-table .position.bronze {
    color: var(--bronze);
    font-weight: 800;
}

/* ==========================================================================
   Sortable Tables
   ========================================================================== */

.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem !important;
    transition: background var(--transition-fast);
}

.sortable-header:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.sortable-header::after {
    content: '\2195';
    position: absolute;
    right: 0.5rem;
    opacity: 0.25;
    font-size: var(--text-xs);
}

.sortable-header.sort-asc::after {
    content: '\2191';
    opacity: 0.8;
    color: var(--primary);
}

.sortable-header.sort-desc::after {
    content: '\2193';
    opacity: 0.8;
    color: var(--primary);
}

.sort-hint {
    color: var(--text-dim);
    font-size: var(--text-xs);
    margin-left: var(--space-sm);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

/* ==========================================================================
   Race Detail
   ========================================================================== */

.race-meta-info {
    display: flex;
    gap: var(--space-lg);
    color: var(--text-muted);
    margin-top: var(--space-sm);
    font-size: var(--text-sm);
    flex-wrap: wrap;
    align-items: baseline;
}

.race-start-times {
    font-size: var(--text-xs);
    color: var(--text-dim);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.details-table {
    width: 100%;
    max-width: 400px;
}

.details-table th,
.details-table td {
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--text-sm);
}

.details-table th {
    text-align: left;
    color: var(--text-dim);
    font-weight: 500;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.age-note {
    color: var(--text-dim);
    font-size: var(--text-xs);
    margin-left: 0.25rem;
}

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    margin: var(--space-xl) 0;
    font-size: var(--text-sm);
}

.alert-warning {
    background: rgba(202, 138, 4, 0.08);
    border: 1px solid rgba(202, 138, 4, 0.25);
}

/* Dark mode alert-warning is handled in [data-mode="dark"] block */

.alert code {
    background: var(--bg);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--text-xs);
    border: 1px solid var(--border);
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-dim);
    border-top: 1px solid var(--border-subtle);
    margin-top: var(--space-3xl);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: 'Outfit', sans-serif;
}

footer a {
    color: var(--text-dim);
    transition: color var(--transition-fast);
}

footer a:hover {
    color: var(--primary);
}

/* ==========================================================================
   Sprint
   ========================================================================== */

.sprint-indicator {
    color: var(--gold);
    font-size: 0.85em;
    font-weight: 600;
}

/* Race/Sprint tabs */
.race-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
}

.tab-btn {
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--text-sm);
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    transition: all var(--transition-base);
}

.tab-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--border);
}

.tab-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.tab-btn:disabled,
.tab-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* ==========================================================================
   DNF
   ========================================================================== */

.position.dnf {
    color: var(--text-dim);
    font-style: italic;
    font-weight: 400;
}

/* ==========================================================================
   Year Navigation (inline styles from templates)
   ========================================================================== */

.year-nav-controls {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
}

.filter-subtabs {
    display: flex;
    gap: 0;
    margin-bottom: var(--space-md);
}

.filter-subtabs .subtab {
    padding: var(--space-sm) var(--space-md);
    text-decoration: none;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    font-size: var(--text-sm);
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
    transition: all var(--transition-base);
}

.filter-subtabs .subtab:hover {
    color: var(--text);
}

.filter-subtabs .subtab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Stagger animation for page load */
.card,
.stat-card,
.race-card {
    animation: fadeIn 0.4s ease backwards;
}

.season-grid .card:nth-child(1) { animation-delay: 0ms; }
.season-grid .card:nth-child(2) { animation-delay: 60ms; }
.season-grid .card:nth-child(3) { animation-delay: 120ms; }
.season-grid .card:nth-child(4) { animation-delay: 180ms; }
.season-grid .card:nth-child(5) { animation-delay: 240ms; }

.stats-grid .stat-card:nth-child(1) { animation-delay: 100ms; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 160ms; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 220ms; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 280ms; }

/* Table row stagger (first 15 rows) */
.data-table tbody tr {
    animation: fadeIn 0.3s ease backwards;
}
.data-table tbody tr:nth-child(1)  { animation-delay: 0ms; }
.data-table tbody tr:nth-child(2)  { animation-delay: 20ms; }
.data-table tbody tr:nth-child(3)  { animation-delay: 40ms; }
.data-table tbody tr:nth-child(4)  { animation-delay: 60ms; }
.data-table tbody tr:nth-child(5)  { animation-delay: 80ms; }
.data-table tbody tr:nth-child(6)  { animation-delay: 100ms; }
.data-table tbody tr:nth-child(7)  { animation-delay: 120ms; }
.data-table tbody tr:nth-child(8)  { animation-delay: 140ms; }
.data-table tbody tr:nth-child(9)  { animation-delay: 160ms; }
.data-table tbody tr:nth-child(10) { animation-delay: 180ms; }
.data-table tbody tr:nth-child(11) { animation-delay: 200ms; }
.data-table tbody tr:nth-child(12) { animation-delay: 220ms; }
.data-table tbody tr:nth-child(13) { animation-delay: 240ms; }
.data-table tbody tr:nth-child(14) { animation-delay: 260ms; }
.data-table tbody tr:nth-child(15) { animation-delay: 280ms; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .navbar {
        padding: 0 var(--space-md);
        gap: var(--space-md);
    }

    .nav-links {
        display: none;
    }

    .nav-search input {
        width: 160px;
    }

    .container {
        padding: var(--space-lg);
    }

    .hero h1 {
        font-size: var(--text-2xl);
    }

    .stats-grid {
        flex-wrap: wrap;
        gap: var(--space-md);
    }

    .stat-value {
        font-size: var(--text-2xl);
    }

    .controls {
        padding: var(--space-md);
    }

    .filter-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ==========================================================================
   Selection
   ========================================================================== */

::selection {
    background: var(--primary);
    color: white;
}

/* ==========================================================================
   Calendar Page
   ========================================================================== */

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-lg);
    margin-top: var(--space-lg);
}

@media (max-width: 1200px) {
    .calendar-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .calendar-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .calendar-grid {
        grid-template-columns: 1fr;
    }
}

.calendar-month {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.calendar-month h3 {
    margin: 0 0 0.75rem;
    text-align: center;
    font-size: var(--text-base);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--text);
}

.calendar-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.calendar-table th {
    padding: 0.25rem;
    text-align: center;
    font-weight: 500;
    color: var(--text-dim);
    font-size: var(--text-xs);
    font-family: 'Outfit', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calendar-table td {
    padding: 0.25rem;
    text-align: center;
    height: 2rem;
    vertical-align: middle;
}

.calendar-table td.empty {
    background: transparent;
}

.calendar-table td span {
    color: var(--text-dim);
}

.calendar-table td.race-day {
    background: var(--primary);
    border-radius: var(--radius-sm);
    position: relative;
}

.calendar-table td.race-day a {
    color: white;
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    height: 100%;
}

.calendar-table td.race-day:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
    transition: all var(--transition-fast);
    z-index: 10;
}

/* Race tooltip */
.race-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 20;
    pointer-events: none;
    text-align: left;
    min-width: 160px;
}

.race-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border-subtle);
}

.calendar-table td.race-day:hover .race-tooltip {
    display: block;
}

.race-tooltip-name {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text);
    margin-bottom: 0.125rem;
}

.race-tooltip-circuit {
    font-size: var(--text-xs);
    color: var(--text-dim);
    margin-bottom: 0.375rem;
}

.race-tooltip-time {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.5;
}

.race-tooltip-label {
    color: var(--text-dim);
    font-weight: 500;
}

.calendar-table td.sprint-day {
    background: linear-gradient(135deg, var(--primary) 0%, var(--gold) 100%);
}

.sprint-badge {
    font-size: 0.7em;
}

.calendar-legend {
    display: flex;
    gap: var(--space-lg);
    justify-content: center;
    margin-top: var(--space-lg);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: var(--radius-sm);
}

.legend-dot.race {
    background: var(--primary);
}

.legend-dot.sprint {
    background: linear-gradient(135deg, var(--primary) 0%, var(--gold) 100%);
}

/* ==========================================================================
   Map / Tour Page
   ========================================================================== */

.tour-container {
    display: flex;
    gap: var(--space-lg);
    margin-top: var(--space-lg);
    height: calc(100vh - 320px);
    min-height: 500px;
}

.map-container {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}

#world-map {
    width: 100%;
    height: 100%;
}

.tour-sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.tour-controls {
    display: flex;
    gap: var(--space-sm);
}

.tour-controls .btn {
    flex: 1;
}

.tour-progress {
    text-align: center;
    font-family: 'Outfit', sans-serif;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-muted);
}

.tour-info {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    min-height: 100px;
}

.tour-info .info-placeholder {
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-md) 0;
    font-size: var(--text-sm);
}

.tour-info .race-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: var(--space-sm);
}

.tour-info .race-round-badge {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: var(--text-sm);
}

.tour-info .race-title {
    font-family: 'Outfit', sans-serif;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text);
}

.tour-info .race-circuit {
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
    font-size: var(--text-sm);
}

.tour-info .race-date {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.tour-info .race-distance {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.tour-info .race-link {
    margin-top: 0.75rem;
}

.tour-list {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tour-list h3 {
    margin: 0 0 var(--space-sm);
    font-size: var(--text-xs);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: 'Outfit', sans-serif;
}

.tour-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
}

.race-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.race-item:hover {
    background: var(--bg-hover);
}

.race-item.active {
    background: var(--primary);
    color: white;
}

.race-item.active .circuit-name {
    color: rgba(255, 255, 255, 0.8);
}

.race-item .race-round {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.2rem var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    min-width: 35px;
    text-align: center;
    color: var(--text);
}

.race-item.active .race-round {
    background: rgba(255, 255, 255, 0.2);
    border-color: transparent;
    color: white;
}

.race-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.race-details .race-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: var(--text-sm);
}

.race-details .circuit-name {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* D3 Map SVG styles */
.country {
    fill: var(--map-land);
    stroke: var(--border);
    stroke-width: 0.5px;
}

.circuit-marker {
    fill: var(--primary);
    stroke: white;
    stroke-width: 1.5px;
    cursor: pointer;
    transition: r 0.2s ease;
}

.circuit-marker.visited {
    fill: var(--primary);
}

.circuit-marker.current {
    fill: var(--gold);
    stroke: var(--primary);
    stroke-width: 2px;
}

.circuit-marker.unvisited {
    fill: var(--text-dim);
    opacity: 0.6;
}

.circuit-marker.sprint {
    stroke: var(--gold);
    stroke-width: 2.5px;
}

.circuit-marker.sprint.current {
    stroke: var(--gold);
    stroke-width: 3px;
}

.route-line {
    fill: none;
    stroke: var(--primary);
    stroke-width: 2px;
    stroke-linecap: round;
    opacity: 0.7;
}

.race-label {
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 600;
    fill: var(--text);
    text-anchor: middle;
    pointer-events: none;
    text-shadow:
        -1px -1px 0 var(--map-label-shadow),
        1px -1px 0 var(--map-label-shadow),
        -1px 1px 0 var(--map-label-shadow),
        1px 1px 0 var(--map-label-shadow);
}

.race-label-bg {
    fill: var(--map-label-bg);
    rx: 4;
    ry: 4;
}

.route-distance-label {
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 600;
    fill: var(--primary);
    text-anchor: middle;
    pointer-events: none;
}

@media (max-width: 900px) {
    .tour-container {
        flex-direction: column;
        height: auto;
    }

    .map-container {
        height: 400px;
    }

    .tour-sidebar {
        width: 100%;
    }

    .tour-list {
        max-height: 300px;
    }
}

/* ==========================================================================
   Compare Page
   ========================================================================== */

.compare-intro {
    margin-bottom: var(--space-md);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

#compareChart {
    max-height: 400px;
}

/* ==========================================================================
   Races List Page — horizontal strip + results below
   ========================================================================== */

.races-layout {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    position: relative;
}

.race-strip {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: var(--space-sm);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Slim horizontal scrollbar for the strip */
.race-strip::-webkit-scrollbar {
    height: 4px;
}

.race-strip::-webkit-scrollbar-track {
    background: transparent;
}

.race-strip::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 100px;
}

.race-strip .race-card {
    flex-shrink: 0;
    width: 180px;
    flex-direction: column;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    position: relative;
}

.race-strip .race-card .race-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.race-strip .race-card .race-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.race-strip .race-card .race-circuit {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.race-card-tooltip {
    display: none;
    position: absolute;
    transform: translateX(-50%) translateY(-100%);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.375rem 0.625rem;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 20;
    pointer-events: none;
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.5;
    text-align: left;
}

.race-card-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border-subtle);
}

.race-card-tooltip.visible {
    display: block;
}

.race-card.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.race-card.selected .race-round,
.race-card.selected .race-circuit,
.race-card.selected .race-date {
    color: rgba(255, 255, 255, 0.8);
}

.race-results-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

/* ==========================================================================
   Controls Layout (filter form inline)
   ========================================================================== */

.controls .filter-form {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.controls .form-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin: 0;
}

.controls .form-group label {
    margin: 0;
    white-space: nowrap;
}

.controls .form-group select {
    width: auto;
    min-width: 100px;
}

/* ==========================================================================
   Circuit Pages
   ========================================================================== */

.circuit-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: var(--space-sm);
}

.circuit-tabs .tab-btn {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-base);
}

.circuit-tabs .tab-btn:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.circuit-tabs .tab-btn.active {
    color: white;
    background: var(--primary);
}

.map-links {
    margin-top: var(--space-xl);
}

.map-links h2 {
    margin-bottom: var(--space-md);
}

.map-buttons {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.btn-map {
    padding: 0.625rem var(--space-lg);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: var(--text-sm);
    transition: all var(--transition-base);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.btn-map.apple-maps {
    background: #1d1d1f;
    color: #fff;
}

.btn-map.apple-maps:hover {
    background: #333;
}

.btn-map.google-maps {
    background: #4285f4;
    color: #fff;
}

.btn-map.google-maps:hover {
    background: #3367d6;
}

.btn-map.osm {
    background: #7ebc6f;
    color: #fff;
}

.btn-map.osm:hover {
    background: #6ba85d;
}

.profile-details {
    margin-top: var(--space-lg);
}

/* Circuit info two-column layout */
.circuit-info-layout {
    display: flex;
    gap: var(--space-xl);
    align-items: flex-start;
}

.circuit-info-layout .details-table {
    flex: 1;
    min-width: 0;
}

.circuit-map {
    flex: 1;
    max-width: 500px;
}

.circuit-map a {
    display: block;
    cursor: zoom-in;
}

.circuit-map img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base);
}

.circuit-map a:hover img {
    box-shadow: var(--shadow-md);
}

/* Circuit map lightbox */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.lightbox-overlay.open {
    display: flex;
    animation: lightboxFadeIn 0.2s ease;
}

@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: calc(90vh - 60px);
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.4);
}

.lightbox-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-card);
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    z-index: 1;
    line-height: 1;
}

.lightbox-close:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.lightbox-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-top: var(--space-md);
    width: 100%;
    max-width: 500px;
}

.lightbox-title {
    color: rgba(255, 255, 255, 0.9);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: var(--text-sm);
}

.lightbox-download {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.lightbox-download:hover {
    background: rgba(255, 255, 255, 0.22);
    color: white;
    box-shadow: none;
}

.lightbox-download svg {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .circuit-info-layout {
        flex-direction: column;
    }

    .circuit-map {
        max-width: 100%;
    }

    .lightbox-overlay {
        padding: var(--space-md);
    }

    .lightbox-close {
        top: -8px;
        right: -8px;
    }
}

/* ==========================================================================
   Driver Info
   ========================================================================== */

.career-years {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* ==========================================================================
   Control Box (races calendar)
   ========================================================================== */

.control-box {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 0.625rem var(--space-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.control-box label,
.control-box span {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* ==========================================================================
   Admin Page
   ========================================================================== */

.admin-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--space-xl);
    align-items: start;
}

.admin-form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.admin-form-card h3 {
    margin: 0 0 var(--space-sm) 0;
    font-size: var(--text-lg);
    color: var(--text);
}

.admin-hint {
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin: 0 0 var(--space-md) 0;
}

.admin-hint-inline {
    font-weight: 400;
    color: var(--text-muted);
}

/* Form fields */
.admin-form-field {
    flex: 1;
}

.admin-form-field label {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
    font-weight: 500;
}

.admin-form-field select,
.admin-form-field input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-family: inherit;
}

.admin-form-action {
    flex-shrink: 0;
}

/* Add driver form */
.admin-add-driver-fields {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.admin-team-drop-row {
    display: flex;
    gap: var(--space-md);
    align-items: flex-end;
}

.admin-team-drop-field {
    flex: 1;
}

.admin-drop-zone-input {
    transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-drop-zone-input.drag-over {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Entries header */
.admin-entries-header {
    margin-bottom: var(--space-md);
}

.admin-entries-header h3 {
    margin: 0;
    font-size: var(--text-lg);
    color: var(--text);
}

/* Entries list (vertical) */
.admin-entries-list {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.admin-entry-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s, box-shadow 0.15s;
}

.admin-entry-row:last-child {
    border-bottom: none;
}

.admin-entry-row:hover {
    background: var(--bg-hover);
}

.admin-entry-row.drag-over {
    background: color-mix(in srgb, var(--primary) 10%, var(--bg));
    box-shadow: inset 0 0 0 2px var(--primary);
}

.admin-entry-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-entry-driver {
    font-weight: 500;
    font-size: var(--text-base);
}

.admin-entry-driver a {
    color: var(--text);
    text-decoration: none;
}

.admin-entry-driver a:hover {
    color: var(--primary);
}

.admin-entry-team {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.admin-entry-team a {
    color: var(--text-muted);
    text-decoration: none;
}

.admin-entry-team a:hover {
    color: var(--primary);
}

/* Bulk actions bar */
.admin-bulk-actions {
    margin-top: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.admin-select-all-label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.btn-danger {
    background: #c0392b;
    color: #fff;
    border: none;
}

.btn-danger:hover {
    background: #a93226;
}

/* Teams panel (sidebar) */
.admin-teams-card {
    position: sticky;
    top: var(--space-lg);
}

.admin-teams-search {
    margin-bottom: var(--space-sm);
}

.admin-teams-list {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.admin-team-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0.4rem var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    cursor: grab;
    transition: background 0.15s;
    font-size: var(--text-sm);
    user-select: none;
}

.admin-team-item:last-child {
    border-bottom: none;
}

.admin-team-item:hover {
    background: var(--bg-hover);
}

.admin-team-item.dragging {
    opacity: 0.5;
}

.admin-drag-handle {
    color: var(--text-dim);
    font-size: var(--text-lg);
    line-height: 1;
}

.admin-team-name {
    flex: 1;
    color: var(--text);
}

.admin-teams-add-form {
    display: flex;
    gap: var(--space-sm);
}

.admin-teams-add-form input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-family: inherit;
}

/* Copy from season (collapsible) */
.admin-copy-section summary {
    cursor: pointer;
    list-style: none;
}

.admin-copy-section summary::-webkit-details-marker {
    display: none;
}

.admin-copy-section summary h3 {
    display: inline;
}

.admin-copy-section summary h3::before {
    content: "\25B6\00a0";
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.admin-copy-section[open] summary h3::before {
    content: "\25BC\00a0";
}

.admin-copy-section .admin-hint {
    margin-top: var(--space-md);
}

/* Source entries list (copy from season) */
.admin-source-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: var(--space-md) 0 var(--space-sm);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.admin-source-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.admin-source-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background 0.15s;
}

.admin-source-item:last-child {
    border-bottom: none;
}

.admin-source-item:hover {
    background: var(--bg-hover);
}

.admin-source-item.already-added {
    opacity: 0.5;
    cursor: default;
}

.admin-source-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-source-driver {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text);
}

.admin-source-team {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 960px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-teams-card {
        position: static;
    }
}

@media (max-width: 768px) {
    .admin-add-driver-fields {
        flex-direction: column;
        gap: var(--space-sm);
    }

    .admin-team-drop-row {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-form-action {
        align-self: flex-start;
    }
}

/* ---- Championship odds: clinch grid & checklist ---- */
.clinch-section { margin-top: 2rem; }
.clinch-grid { border-collapse: collapse; margin: 1rem 0; }
.clinch-grid th,
.clinch-grid td { border: 1px solid rgba(128, 128, 128, 0.4); padding: 0.4rem 0.6rem; text-align: center; }
.clinch-grid td { width: 2.2rem; height: 2.2rem; }
.clinch-clinched { background-color: #4caf50; }
.clinch-leads { background-color: #f5c542; }
.clinch-behind { background-color: #e05c4b; }
.legend span { display: inline-block; width: 1.1rem; height: 1.1rem; line-height: 1.1rem; text-align: center; margin: 0 0.15rem 0 0.5rem; color: transparent; border-radius: 2px; vertical-align: middle; }
.clinch-checklist { list-style: none; padding-left: 0; }
.clinch-checklist li { padding: 0.35rem 0; border-bottom: 1px solid rgba(128, 128, 128, 0.25); }
.clinch-checklist li.can-clinch { font-weight: 600; background: rgba(76, 175, 80, 0.12); }