:root {
    --brand-primary: #1B3A5C;
    --brand-accent: #2dd4bf;
    --focus-ring: #2dd4bf;
    --bg: #1a1d23;
    --panel-bg: #21252b;
    --text: #f8fafc;
    --text-secondary: #cbd5e1;
    --border: #333842;
    --btn-bg: #2a2d35;
    --btn-hover: #353a45;
    --btn-active: #3a4458;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    --header-height: 60px;
    --mobile-topbar-height: 44px;
    --mobile-nav-height: 64px;
    --ocean-color: #091520; /* exact terminal navy of the ocean gradient (see MAP_COLORS.oceanGradient in data.js) */
    --map-bg: var(--ocean-color);
    --panel-overlay: rgba(20, 24, 32, 0.95);
    --panel-overlay-97: rgba(20, 24, 32, 0.97);
    --panel-overlay-96: rgba(20, 24, 32, 0.96);
    --panel-overlay-92: rgba(20, 24, 32, 0.92);
    --panel-overlay-90: rgba(20, 24, 32, 0.9);
    --panel-overlay-85: rgba(20, 24, 32, 0.85);
    --tooltip-bg: rgba(20, 24, 32, 0.95);
    --tooltip-color: #fff;
    --tooltip-border: rgba(255, 255, 255, 0.2);
    --legend-bg: rgba(20, 24, 32, 0.96);
    --shortcuts-bg: #1e2330;
    --onboarding-bg: rgba(30,40,60,0.96);

    /* ── Design tokens ── */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-pill: 999px;

    /* ── Fluid dock tokens: clamp()/vw scaling from 720p to 4K/16K ── */
    --dock-radius: clamp(8px, 0.65vw, 14px);
    --dock-font-size: clamp(11.5px, 0.78vw, 18px);
    --dock-icon-size: clamp(14px, 1vw, 24px);
    --dock-pad-y-tall: clamp(8px, 0.6vw, 16px);
    --dock-pad-x-tall: clamp(12px, 0.9vw, 22px);
    --dock-pad-y-short: clamp(4px, 0.4vw, 10px);
    --dock-pad-x-short: clamp(8px, 0.7vw, 16px);
    --dock-gap: clamp(4px, 0.4vw, 10px);
    --dock-height-tall: clamp(44px, 3.2vw, 96px);
    --dock-height-short: clamp(32px, 2.35vw, 70px);
    --dock-cap-margin-top: clamp(6px, 0.5vw, 12px);
    --dock-outer-gap: clamp(10px, 0.8vw, 18px);
    --dock-pad-y-btn: clamp(4px, 0.32vw, 9px);
    --dock-pad-x-btn: clamp(4px, 0.4vw, 10px);
    --dock-btn-h-tall: clamp(26px, 1.9vw, 52px);
    --dock-btn-h-short: clamp(20px, 1.5vw, 42px);

    /* ── Semantic header text tokens ──
       The header keeps its dark slate background (--brand-primary) in
       BOTH themes, so the title/subtitle stay light in both. */
    --header-title-color: #f8fafc;
    --header-subtitle-color: #94a3b8;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

    --dur-fast: 0.15s;
    --dur-base: 0.2s;
    --dur-slow: 0.3s;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);

    --glass-blur-sm: 6px;
    --glass-blur-md: 10px;
    --glass-blur-lg: 16px;
    --glass-bg: rgba(17, 24, 32, 0.72);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);

    /* ── Z-index scale ──
       Named stacking tiers. Values are the pre-existing numbers,
       unchanged — this only names them. Lower tiers sit nearer the map,
       higher tiers cover the whole viewport. */
    --z-sticky-cell: 1;              /* sticky table headers inside scroll tables */
    --z-map-surface: 5;              /* decorative overlay directly above map canvases */
    --z-mobile-chrome: 15;           /* mobile top bar + bottom nav */
    --z-country-panel: 30;           /* desktop country side panel */
    --z-search-dropdown: 50;         /* search suggestions list */
    --z-tooltip: 100;                /* hover tooltip, mobile tools menu */
    --z-notification: 200;           /* copy notification toast */
    --z-measure-label: 500;          /* measure distance result label */
    --z-measure-toolbar: 900;        /* measure mode toolbar */
    --z-map-widget: 999;             /* legend, disputes counter, zoom controls */
    --z-controls-bar: 1000;          /* bottom controls bar, coordinates display */
    --z-bar-toggle: 1001;            /* menu/layers toggle buttons above controls bar */
    --z-layers-popover: 1050;        /* layers modal as anchored popover */
    --z-country-panel-mobile: 1100;  /* country panel on mobile widths */
    --z-onboarding-hint: 1500;       /* onboarding hint bubble */
    --z-fullscreen-panel: 2000;      /* header dock, mobile mode sheet, shortcuts, data table */
    --z-tools-dropdown: 2001;        /* header tools dropdown above header */
    --z-modal: 3000;                 /* layers modal, quiz overlays */
    --z-modal-alert: 3100;           /* quiz feedback/authoring banner above modal */
    --z-presentation-exit: 5000;     /* presentation mode exit button */
    --z-lang-overlay: 9998;          /* first-run language overlay */
    --z-topmost: 9999;               /* lang dropdown, title tooltips, onboard backdrop, export blocker */
    --z-topmost-card: 10000;         /* onboard/projection cards above their backdrop */
    --z-button-tooltip: 99999;       /* button tooltip, always on top */
}

path:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 1px;
}

.skip-link {
    position: absolute;
    top: -120px;
    left: 8px;
    background: #115e59;
    color: #fff;
    padding: 8px 18px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    z-index: 99999;
    text-decoration: none;
    font-weight: 600;
    transform: translateY(-100%);
    transition: top 0.2s ease, transform 0.2s ease;
}
.skip-link:focus,
.skip-link:focus-visible {
    top: 8px;
    transform: translateY(0);
}


.theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: inline; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Light theme via system preference (only when no manual choice) */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        --brand-primary: #1B3A5C;
        --brand-accent: #14B8A6;
        --focus-ring: #0d9488;
        --bg: #f0f2f5;
        --panel-bg: #ffffff;
        --text: #1a1d23;
        --text-secondary: #5a5d63;
        --border: #d0d3d8;
        --btn-bg: #e8eaed;
        --btn-hover: #dce0e5;
        --btn-active: #d0d5dd;
        --shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
        --ocean-color: #091520;
        --map-bg: var(--ocean-color);
        --panel-overlay: rgba(255, 255, 255, 0.95);
        --panel-overlay-97: rgba(255, 255, 255, 0.97);
        --panel-overlay-96: rgba(255, 255, 255, 0.96);
        --panel-overlay-92: rgba(255, 255, 255, 0.92);
        --panel-overlay-90: rgba(255, 255, 255, 0.9);
        --panel-overlay-85: rgba(255, 255, 255, 0.85);
        --tooltip-bg: rgba(255, 255, 255, 0.95);
        --tooltip-color: #1a1d23;
        --tooltip-border: rgba(0, 0, 0, 0.15);
        --legend-bg: rgba(255, 255, 255, 0.96);
        --shortcuts-bg: #ffffff;
        --onboarding-bg: rgba(240, 245, 255, 0.96);

        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
        --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.14);

        --glass-bg: rgba(255, 255, 255, 0.72);
        --glass-border: 1px solid rgba(0, 0, 0, 0.08);
    }
}

/* Manual light theme toggle */
[data-theme="light"] {
    --brand-primary: #1B3A5C;
    --brand-accent: #115e59;
    --focus-ring: #115e59;
    --bg: #f8fafc;
    --panel-bg: rgba(255, 255, 255, 0.92);
    --text: #0f172a;
    --text-secondary: #334155;
    --border: rgba(15, 23, 42, 0.09);
    --btn-bg: rgba(15, 23, 42, 0.04);
    --btn-hover: rgba(15, 23, 42, 0.08);
    --btn-active: rgba(15, 23, 42, 0.12);
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
    --ocean-color: #d0e3f4;
    --map-bg: var(--ocean-color);
    --panel-overlay: rgba(255, 255, 255, 0.92);
    --panel-overlay-97: rgba(255, 255, 255, 0.96);
    --panel-overlay-96: rgba(255, 255, 255, 0.94);
    --panel-overlay-92: rgba(255, 255, 255, 0.90);
    --panel-overlay-90: rgba(255, 255, 255, 0.88);
    --panel-overlay-85: rgba(255, 255, 255, 0.84);
    --tooltip-bg: rgba(255, 255, 255, 0.95);
    --tooltip-color: #0f172a;
    --tooltip-border: rgba(15, 23, 42, 0.1);
    --legend-bg: rgba(255, 255, 255, 0.94);
    --shortcuts-bg: rgba(255, 255, 255, 0.96);
    --onboarding-bg: rgba(248, 250, 252, 0.96);

    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 36px rgba(15, 23, 42, 0.1);

    --glass-bg: rgba(255, 255, 255, 0.88);
    --glass-border: 1px solid rgba(15, 23, 42, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    background: var(--bg);
    font-family: 'Inter', 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    user-select: none;
}
.header {
    position: relative ;
    z-index: var(--z-fullscreen-panel) ;
    display: flex ;
    align-items: center ;
    justify-content: space-between  ;
    padding: 0 16px  ;
    background: #111827  ;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08)  ;
    height: 56px  ;
    box-sizing: border-box ;
    overflow: visible ;
    gap: 16px;
    box-shadow: var(--shadow-md);
}
.header .title-group {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.header-right-group {
    display: flex ;
    align-items: center ;
    gap: 20px ;
    min-width: 0;
}
.header-center-group {
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    pointer-events: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.header-left-group {
    display: flex ;
    align-items: center ;
    gap: 10px !important;
    flex-shrink: 0;
}

/* Secondary floating bars must stay below the main header stacking context */
.sub-bar,
.secondary-toolbar,
.mode-bar,
.tabs-bar,
.controls-bar {
    z-index: var(--z-controls-bar) ;
}
#headerProjectionLabel {
    white-space: nowrap;
    /* Enlarged, high-visibility typography for the center header label:
       15px / weight 600 / 0.3px tracking, light-on-dark regardless of
       theme — the header stays on its dark slate in both themes. This
       beats the inline var(--text-secondary) (which turns dark in light
       mode and disappears on the navy bar). */
    font-size: 15px ;
    font-weight: 600 ;
    color: rgba(255, 255, 255, 0.85) ;
    letter-spacing: 0.3px !important;
}
.tools-row-start {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.tools-row-middle {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}
/* ── Header buttons: uniform utility look (tools / lang / theme) ── */
.header-btn,
.header-select,
.header-icon-btn {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #f3f4f6;
    border-radius: 8px ;
    padding: 6px 14px !important;
    min-height: 44px !important;
    font-size: 13px !important;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.header-btn:hover,
.header-select:hover,
.header-icon-btn:hover {
    background: rgba(255, 255, 255, 0.12) !important;
}
.header-btn.toggle-on,
.header-btn.active,
.header-btn[aria-pressed="true"],
.header-icon-btn.toggle-on,
.header-icon-btn.active,
.header-icon-btn[aria-pressed="true"] {
    background: var(--brand-accent, #14B8A6) !important;
    border-color: var(--brand-accent, #14B8A6) !important;
    color: #08202c !important;
    font-weight: 700 !important;
}
.header-btn.toggle-on .lucide-icon,
.header-btn[aria-pressed="true"] .lucide-icon,
.header-icon-btn.toggle-on .lucide-icon,
.header-icon-btn[aria-pressed="true"] .lucide-icon {
    stroke: #08202c !important;
}
.header-icon-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 6px 12px !important;
    min-width: 44px !important;
    min-height: 44px !important;
}
#themeToggleBtn {
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 16px !important;
}
.brand-logo {
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
}
.brand-title {
    margin: 0;
    font-size: 1.05em;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.1;
}
.header-search-input {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 8px !important;
    padding: 6px 14px !important;
    padding-inline-start: 36px !important;
    min-height: 44px !important;
    height: 44px !important;
    color: #fff !important;
    width: 220px !important;
    transition: all 0.2s ease;
    outline: none;
    font-family: inherit;
}
.header-search-input:focus {
    outline: none ;
    border-color: #3b82f6 ;
    background: rgba(255, 255, 255, 0.1) ;
    width: 260px ;
}

/* ── Light theme styles for top header, brand, buttons, and search ── */
[data-theme="light"] {
    --header-title-color: #0f172a !important;
}
[data-theme="light"] .header,
[data-theme="light"] .top-header {
    background: rgba(255, 255, 255, 0.88) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.03) !important;
}
[data-theme="light"] .header h1,
[data-theme="light"] .brand-logo,
[data-theme="light"] .brand-title {
    color: #0f172a !important;
    -webkit-text-fill-color: #0f172a !important;
}
[data-theme="light"] .brand-logo .logo-icon {
    color: #0d9488 !important;
}
[data-theme="light"] #headerProjectionLabel {
    color: #1e293b !important;
}
[data-theme="light"] .section-toggle {
    background: rgba(15, 23, 42, 0.04) !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    border-radius: 12px !important;
}
[data-theme="light"] .section-toggle-btn {
    color: #475569 !important;
    border-radius: 8px !important;
}
[data-theme="light"] .section-toggle-btn .lucide-icon {
    stroke: #475569 !important;
}
[data-theme="light"] .section-toggle-btn:hover {
    color: #0f172a !important;
    background: rgba(15, 23, 42, 0.06) !important;
}
[data-theme="light"] .section-toggle-btn:hover .lucide-icon {
    stroke: #0f172a !important;
}
[data-theme="light"] .section-toggle-btn.active {
    background: #0d9488 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.28) !important;
}
[data-theme="light"] .section-toggle-btn.active .lucide-icon {
    stroke: #ffffff !important;
}
[data-theme="light"] .header-btn,
[data-theme="light"] .header-select,
[data-theme="light"] .header-icon-btn {
    background: rgba(15, 23, 42, 0.04) !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    color: #1e293b !important;
    border-radius: 10px !important;
    transition: all 0.2s ease !important;
}
[data-theme="light"] .header-btn:hover,
[data-theme="light"] .header-select:hover,
[data-theme="light"] .header-icon-btn:hover {
    background: rgba(15, 23, 42, 0.08) !important;
    border-color: rgba(15, 23, 42, 0.14) !important;
    color: #0f172a !important;
}
[data-theme="light"] .header-btn.toggle-on,
[data-theme="light"] .header-btn.active,
[data-theme="light"] .header-btn[aria-pressed="true"],
[data-theme="light"] .header-icon-btn.toggle-on,
[data-theme="light"] .header-icon-btn.active,
[data-theme="light"] .header-icon-btn[aria-pressed="true"] {
    background: #0d9488 !important;
    border-color: #0d9488 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25) !important;
}
[data-theme="light"] .header-btn.toggle-on .lucide-icon,
[data-theme="light"] .header-btn[aria-pressed="true"] .lucide-icon,
[data-theme="light"] .header-icon-btn.toggle-on .lucide-icon,
[data-theme="light"] .header-icon-btn[aria-pressed="true"] .lucide-icon {
    stroke: #ffffff !important;
}
[data-theme="light"] .header-search-input {
    background: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid rgba(15, 23, 42, 0.1) !important;
    color: #0f172a !important;
    border-radius: 10px !important;
}
[data-theme="light"] .header-search-input::placeholder {
    color: #64748b !important;
}
[data-theme="light"] .header-search-input:focus {
    background: #ffffff !important;
    border-color: #0d9488 !important;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15) !important;
}
[data-theme="light"] .search-box-icon {
    color: #64748b !important;
    stroke: #64748b !important;
    z-index: 5 !important;
}
[data-theme="light"] .hist-opacity-control {
    background: rgba(15, 23, 42, 0.04) !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    color: #1e293b !important;
    border-radius: 10px !important;
}
[data-theme="light"] .hist-opacity-label,
[data-theme="light"] .hist-opacity-val {
    color: #1e293b !important;
}
.tools-wrapper,
.lang-selector-wrapper {
    position: relative ;
}
.tools-wrapper,
.lang-selector-wrapper,
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
}
#toolsRowStart .lucide-icon {
    width: 15px;
    height: 15px;
}
#toolsRowStart .search-box input {
    font-size: 0.85em;
}
/* ── Header Tools app-grid popover ── */
.tools-dropdown {
    position: relative ;
}

/* Header containers must never clip the dropdown */
header,
.header,
.top-bar,
.navbar,
.header-container,
.tools-wrapper,
.tools-dropdown,
.header-tools,
#toolsRowMiddle {
    overflow: visible ;
}

.tools-wrapper,
.header-tools-container {
    position: relative ;
}

.tools-dropdown-menu {
    --btn-bg: rgba(255, 255, 255, 0.06);
    --btn-bg-hover: rgba(255, 255, 255, 0.12);
    --btn-text: #f1f5f9;
    position: absolute ;
    top: calc(100% + 8px) ;
    inset-inline-start: 0 ;
    z-index: var(--z-tools-dropdown) ;
    width: 390px;
    max-width: 92vw;
    box-sizing: border-box;
    background: var(--dock-bg, var(--panel-overlay-96));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
}
.tools-dropdown-menu[hidden] {
    display: none ;
}
.tools-dropdown-menu.visible {
    display: block ;
    opacity: 1 ;
    visibility: visible ;
    animation: menu-popover-in 0.18s ease;
}
.tools-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}
.tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 56px;
    min-width: 0;
    width: 100%;
    padding: 10px 6px;
    border-radius: 8px;
    background: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-family: inherit;
    font-size: 11px;
    line-height: 1.25;
    box-sizing: border-box;
    overflow: hidden;
}
.tool-card:hover {
    background: var(--btn-bg-hover);
    transform: translateY(-2px);
}
.tool-card .tool-icon {
    font-size: 20px;
    flex-shrink: 0;
}
.tool-card .tool-label {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    width: 100%;
    display: block;
    box-sizing: border-box;
}
.tool-card.toggle-on {
    background: #1a3a38;
    border-color: var(--brand-accent);
    color: #80e0d0;
    box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.3);
}
.hist-opacity-tool-card {
    grid-column: span 3;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(20, 184, 166, 0.08);
    border: 1px solid rgba(20, 184, 166, 0.3);
    border-radius: 8px;
    cursor: default;
}
.hist-opacity-tool-card:hover {
    transform: none;
    background: rgba(20, 184, 166, 0.12);
}
.hist-opacity-tool-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.hist-opacity-tool-header .tool-icon {
    width: 16px;
    height: 16px;
    color: var(--brand-accent, #14b8a6);
}
.hist-opacity-tool-header .tool-label {
    flex: 1;
    text-align: start;
    font-size: 0.82rem;
    font-weight: 600;
}
.hist-opacity-val {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--brand-accent, #14b8a6);
    font-family: monospace, system-ui;
}
.hist-opacity-slider {
    width: 100%;
    height: 6px;
    accent-color: var(--brand-accent, #14b8a6);
    cursor: pointer;
    margin: 2px 0 0 0;
}
[data-theme="light"] .tools-dropdown-menu {
    --dock-bg: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(24px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
    border: 1px solid rgba(15, 23, 42, 0.09) !important;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.04) !important;
    --btn-bg: rgba(15, 23, 42, 0.03);
    --btn-bg-hover: rgba(13, 148, 136, 0.08);
    --btn-text: #1e293b;
}
[data-theme="light"] .tools-dropdown-menu .tool-card {
    background: rgba(15, 23, 42, 0.03) !important;
    border: 1px solid rgba(15, 23, 42, 0.07) !important;
    color: #1e293b !important;
}
[data-theme="light"] .tools-dropdown-menu .tool-card:hover {
    background: rgba(13, 148, 136, 0.08) !important;
    border-color: rgba(13, 148, 136, 0.3) !important;
    color: #0f766e !important;
}
[data-theme="light"] .tools-dropdown-menu .tool-card.toggle-on {
    background: rgba(13, 148, 136, 0.14) !important;
    border-color: #0d9488 !important;
    color: #0f766e !important;
    box-shadow: 0 0 0 1px rgba(13, 148, 136, 0.3) !important;
}
[data-theme="light"] .tools-dropdown-menu .hist-opacity-tool-card {
    background: rgba(13, 148, 136, 0.06) !important;
    border-color: rgba(13, 148, 136, 0.2) !important;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .tools-dropdown-menu {
        --btn-bg: rgba(15, 23, 42, 0.03);
        --btn-bg-hover: rgba(13, 148, 136, 0.08);
        --btn-text: #1e293b;
    }
}
.header .logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.brand-logo-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 0 6px rgba(20, 184, 166, 0.45));
    transition: transform var(--dur-fast, 0.15s) ease;
}
.title-group.brand-logo:hover .brand-logo-img {
    transform: scale(1.1);
}
.modal-logo-img {
    width: 76px;
    height: 76px;
    object-fit: contain;
    display: inline-block;
    filter: drop-shadow(0 0 16px rgba(20, 184, 166, 0.5));
    animation: logoFloat 3s ease-in-out infinite;
}
@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}
.header-line {
    height: 2px;
    width: 60%;
    background: linear-gradient(90deg, transparent, rgba(20, 184, 166, 0.5), transparent);
    border-radius: 1px;
    margin-top: 2px;
    display: none;
}
.header h1 {
    font-size: 0.9em;
    font-weight: 700;
    /* Semantic light-on-dark text: the header keeps its dark slate
       background in both themes, so the title is never allowed to pick
       up the theme's dark body text color. */
    color: var(--header-title-color);
    -webkit-text-fill-color: var(--header-title-color);
    white-space: nowrap;
}
.header .subtitle {
    display: none;
}
.map-container {
    flex: 1;
    position: relative;
    cursor: grab;
    overflow: hidden;
    background: var(--map-bg);
}
.map-container:active {
    cursor: grabbing;
}
.map-container svg {
    display: block;
    width: 100%;
    height: 100%;
}
.tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--tooltip-bg);
    border: 1px solid var(--tooltip-border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    color: var(--tooltip-color);
    font-size: 0.7em;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(var(--glass-blur-sm));
    z-index: var(--z-tooltip);
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease);
    will-change: left, top;
    max-width: 200px;
    text-align: center;
    line-height: 1.5;
}
.tooltip.visible {
    opacity: 1;
}
.legend {
    position: fixed;
    bottom: 80px;
    left: 16px;
    background: var(--legend-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    z-index: var(--z-map-widget);
    font-size: 0.7em;
    display: flex;
    flex-direction: column;
    gap: 4px;
    backdrop-filter: none;
    box-shadow: var(--shadow-md);
    max-height: 50vh;
    overflow-y: auto;
    transition: opacity var(--dur-slow) var(--ease);
}
[data-theme="light"] .legend {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(16px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(16px) saturate(180%) !important;
    border: 1px solid rgba(15, 23, 42, 0.09) !important;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08) !important;
    color: #1e293b !important;
}
[data-theme="light"] .legend-title {
    color: #0d9488 !important;
}
.border-disputes-counter {
    position: fixed;
    bottom: 16px;
    right: 16px;
    background: var(--legend-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px 10px;
    font-size: 0.75em;
    font-weight: bold;
    color: rgba(255,255,255,0.7);
    z-index: var(--z-map-widget);
    pointer-events: none;
}
[data-theme="light"] .border-disputes-counter {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(15, 23, 42, 0.09) !important;
    color: #1e293b !important;
}
.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.legend-title {
    font-weight: 700;
    font-size: 0.8em;
    margin-bottom: 2px;
    color: var(--brand-accent, #14B8A6);
}
.info-overlay {
    display: none;
}
.zoom-controls {
    position: fixed;
    bottom: 160px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: var(--z-map-widget);
    transition: opacity var(--dur-slow) var(--ease);
}
.zoom-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--panel-overlay-96);
    color: var(--text);
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
    backdrop-filter: none;
    box-shadow: var(--shadow-sm);
    position: relative;
}
.zoom-btn::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
}
.zoom-btn:hover {
    background: rgba(40, 46, 58, 0.95);
    transform: scale(1.08);
}
[data-theme="light"] .zoom-btn {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(15, 23, 42, 0.1) !important;
    color: #1e293b !important;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08) !important;
}
[data-theme="light"] .zoom-btn:hover {
    background: #ffffff !important;
    color: #0d9488 !important;
    border-color: #0d9488 !important;
    transform: scale(1.08) !important;
    box-shadow: 0 6px 16px rgba(13, 148, 136, 0.2) !important;
}
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}
.search-box-icon {
    position: absolute;
    inset-inline-start: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 5 !important;
}
.search-box input {
    width: 200px;
    padding: 6px 12px;
    padding-inline-start: 36px;
    border-radius: var(--radius-sm);
    background: var(--btn-bg);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 0.85em;
    outline: none;
    font-family: inherit;
}
.suggestions-list {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 150px;
    overflow-y: auto;
    z-index: var(--z-search-dropdown);
    list-style: none;
    display: none;
    width: 150px;
    font-size: 0.6em;
}
.suggestions-list li {
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}
.suggestions-list li:hover {
    background: var(--btn-hover);
}
.suggestions-list .flag-icon {
    font-size: 1.2em;
    line-height: 1;
}
.country-panel {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--panel-overlay-97);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    z-index: var(--z-country-panel);
    color: var(--text);
    font-size: 0.7em;
    backdrop-filter: blur(var(--glass-blur-md));
    box-shadow: var(--shadow-lg);
    display: none;
    text-align: center;
    max-width: 320px;
    min-width: 220px;
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
    contain: layout style;
}
.country-panel.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.country-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.country-panel .close-btn,
.country-panel .export-btn {
    font-size: 0.95em;
    padding: 2px 6px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--dur-fast) var(--ease);
}
.country-panel .close-btn:hover,
.country-panel .export-btn:hover {
    background: rgba(255,255,255,0.18);
}
.country-panel table {
    border-collapse: collapse;
    margin: 6px auto;
}
.country-panel table td,
.country-panel table th {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
}
.compare-bar {
    display: inline-block;
    height: 8px;
    border-radius: 4px;
    background: #ffd700;
    margin: 0 2px;
}
.coordinates-display {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 14, 20, 0.92);
    backdrop-filter: none;
    padding: 4px 16px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.6em;
    color: var(--text-secondary);
    z-index: var(--z-controls-bar);
    white-space: nowrap;
    font-family: monospace;
    letter-spacing: 0.3px;
    transition: opacity var(--dur-slow) var(--ease);
    pointer-events: none;
}
.coordinates-display.hidden {
    opacity: 0;
}
[data-theme="light"] .coordinates-display {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(15, 23, 42, 0.1) !important;
    color: #334155 !important;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06) !important;
}
.copy-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(46, 125, 50, 0.9);
    color: #fff;
    padding: 4px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.7em;
    z-index: var(--z-notification);
    opacity: 0;
    transition: opacity var(--dur-slow) var(--ease);
    pointer-events: none;
}
.copy-notification.show {
    opacity: 1;
}
.menu-toggle {
    position: fixed;
    bottom: 30px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--panel-bg);
    border: 2px solid var(--border);
    color: var(--text);
    font-size: 1.8em;
    font-weight: bold;
    cursor: pointer;
    z-index: var(--z-bar-toggle);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}
.menu-toggle:hover {
    background: var(--btn-hover);
    transform: scale(1.05);
}
.menu-toggle.active {
    background: var(--btn-active);
    border-color: var(--brand-accent);
}
.layers-toggle {
    position: fixed;
    bottom: 30px;
    right: 80px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--panel-bg);
    border: 2px solid var(--border);
    color: var(--text);
    font-size: 1.4em;
    cursor: pointer;
    z-index: var(--z-bar-toggle);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}
.layers-toggle:hover {
    background: var(--btn-hover);
    transform: scale(1.05);
}
.active-layer-counter {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff5722;
    color: #fff;
    font-size: 0.5em;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: var(--radius-pill);
    padding: 0 4px;
    pointer-events: none;
    box-shadow: 0 0 6px rgba(255,87,34,0.5);
}
.controls-bar {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    max-width: 92vw;
    background: var(--panel-overlay-96);
    backdrop-filter: none;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    z-index: var(--z-controls-bar);
    display: none;
    flex-direction: column;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-md);
    max-height: 60vh;
    overflow-y: auto;
}
.controls-bar.active {
    display: flex;
}
.controls-bar .row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}
.controls-bar .row-label {
    font-size: 0.6em;
    color: var(--text-secondary);
    font-weight: 600;
    margin-inline-end: 4px;
    white-space: nowrap;
}
/* One horizontal row holding the stepped dock group (Base Map card +
   utilities), the Layers capsule and the Division card side by side;
   wraps only when the viewport is too narrow. DOM order is
   [group][Layers][Division]; with the document's RTL direction the first
   item lands at the inline-START (rightmost in Arabic): the Base Map
   block is the most prominent/top-right unit, Division the least
   prominent/leftmost, matching the reference sketch. */
.controls-bar-toprow {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
}
.controls-bar-toprow .bar-layers-btn {
    padding: 6px 12px;
    font-size: 0.7em;
    border-radius: var(--radius-sm);
    min-height: 32px;
}
/* Layers capsule: same 10px radius as every top-nav container (unified
   dock bottom corners + fillet, Division capsule) — no pill shapes in
   the top navigation. */
#barLayersBtn {
    border-radius: var(--dock-radius) ;
    padding-inline: 14px ;
}
.layers-modal-body .control-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}
.controls-bar .btn {
    padding: 6px 10px;
    font-size: 0.7em;
    border-radius: var(--radius-sm);
    min-height: 32px;
}
.controls-bar .control-group {
    gap: 4px;
}
.controls-bar .search-box input {
    width: 180px;
    padding: 6px 12px;
    padding-inline-start: 32px;
    font-size: 0.8em;
}
.controls-bar .control-label {
    font-size: 0.65em;
    font-weight: 600;
    color: var(--ctl-label, var(--brand-accent));
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    padding: 0 2px;
}
.controls-bar .divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    border-radius: 1px;
    flex-shrink: 0;
}
.country-label {
    font-weight: 600;
    fill: var(--text);
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8), 0 0 8px rgba(0, 0, 0, 0.6);
}
.hist-era-label, .hist-war-label {
    font-weight: 700;
    fill: #ffffff;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    user-select: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 6px rgba(0, 0, 0, 0.85);
    letter-spacing: 0.3px;
}
.capital-label {
    fill: #fff;
    text-anchor: start;
    dominant-baseline: central;
    pointer-events: none;
    font-weight: 500;
}
.corridor-dot {
    fill: #ff9100;
    stroke: #fff;
    stroke-width: 0.5;
    vector-effect: non-scaling-stroke;
}
.capital-dot {
    fill: #ffd700;
    stroke: #000;
    stroke-width: 0.5;
    vector-effect: non-scaling-stroke;
}
.capital-halo {
    fill: #ffd700;
    opacity: 0.25;
    vector-effect: non-scaling-stroke;
}
.highlighted-country {
    filter: drop-shadow(0 0 8px #ffd700);
    stroke: #ffd700;
    stroke-width: 2;
}
.corridor-line {
    fill: none;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}
.corridor-glow {
    fill: none;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 0 6px currentColor);
}
#mapSvg {
    touch-action: none;
    isolation: isolate;
}
.map-transform-group {
    isolation: isolate;
}
.map-transform-group text {
    pointer-events: none;
    stroke: none !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 6px rgba(0, 0, 0, 0.85);
}
.map-transform-group text.hist-era-label,
.map-transform-group text.hist-war-label,
.map-transform-group text.country-label,
.map-transform-group text.hist-capital-label,
.map-transform-group text.hist-battle-label,
.map-transform-group text.hist-wonder-label,
.map-transform-group text.hist-wp-label,
.map-transform-group text.hist-route-label,
.hist-era-label,
.hist-war-label,
.hist-capital-label,
.hist-battle-label,
.hist-wonder-label,
.hist-wp-label,
.hist-route-label,
.country-label {
    stroke: none !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 6px rgba(0, 0, 0, 0.85);
}
.zooming-active text {
    display: none;
}
.zooming-active path,
.zooming-active circle {
    shape-rendering: optimizeSpeed;
}
.major-city-dot {
    stroke: #fff;
    stroke-width: 0.8;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}
.major-city-label {
    fill: #fff;
    text-anchor: start;
    dominant-baseline: central;
    pointer-events: none;
    stroke: none !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 4px rgba(0, 0, 0, 0.85);
    font-weight: 400;
}
/* ── Modern Mobile UI Architecture (Base styles: hidden by default) ── */
.mobile-drawer-btn,
.mobile-bottom-nav,
.mobile-search-bar,
.mobile-activities-sheet,
.mobile-mode-sheet,
.sheet-drag-handle {
    display: none;
}

.mobile-search-bar {
    position: fixed;
    top: calc(var(--header-height, 50px) + 8px);
    left: 12px;
    right: 12px;
    z-index: var(--z-mobile-chrome, 90);
}
.mobile-search-inner {
    display: flex;
    align-items: center;
    background: var(--panel-overlay-96, rgba(15, 23, 42, 0.94));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 0 14px;
    height: 44px;
    min-height: 44px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.mobile-search-inner .search-icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-inline-end: 8px;
}
.mobile-search-inner input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.88rem;
    font-family: inherit;
    height: 100%;
    min-height: 44px;
}
.mobile-search-inner:focus-within {
    border-color: var(--brand-accent, #38bdf8);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.4), 0 4px 18px rgba(0, 0, 0, 0.35);
}
.mobile-search-inner input:focus-visible {
    outline: none;
}
.mobile-search-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 0 8px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.mobile-search-bar .suggestions-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 12px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    max-height: 260px;
    overflow-y: auto;
    z-index: 100;
}

/* Adaptive Bottom Navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: var(--z-mobile-chrome, 90);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
}
.mobile-nav-group {
    display: flex;
    align-items: center;
    height: var(--mobile-nav-height, 58px);
    width: 100%;
    padding: 0 8px;
    box-sizing: border-box;
}
#mobileGeoNav {
    max-width: 320px;
    margin: 0 auto;
    justify-content: center;
    gap: 16px;
}
#mobileHistoryNav {
    max-width: 500px;
    margin: 0 auto;
    justify-content: space-around;
    gap: 2px;
}
.mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: #94a3b8;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 6px;
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    height: calc(var(--mobile-nav-height, 58px) - 10px);
    font-family: inherit;
    transition: color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
    position: relative;
    touch-action: manipulation;
    overflow: hidden;
}
#mobileGeoNav .mobile-nav-btn {
    flex: 0 1 140px;
    padding: 6px 14px;
}
.mobile-nav-btn .lucide-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}
.mobile-nav-btn .btn-text {
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.mobile-nav-btn:active {
    transform: scale(0.93);
    color: var(--brand-accent, #14b8a6);
}
.mobile-nav-btn.active {
    color: var(--brand-accent, #14b8a6);
    background: rgba(20, 184, 166, 0.12);
    font-weight: 700;
}
.mobile-layer-badge {
    position: absolute;
    top: 4px;
    right: 12px;
    background: var(--brand-accent, #14b8a6);
    color: #042f2e;
    font-size: 10px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Adaptive section switching */
body.section-history #mobileGeoNav {
    display: none !important;
}
body.section-history #mobileHistoryNav {
    display: flex !important;
}
body.section-geo #mobileGeoNav {
    display: flex !important;
}
body.section-geo #mobileHistoryNav {
    display: none !important;
}

/* Mobile Side Drawer */
.mobile-side-drawer {
    position: fixed;
    inset: 0;
    z-index: var(--z-fullscreen-panel, 200);
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--dur-base, 0.2s) ease;
}
.mobile-side-drawer.visible {
    pointer-events: auto;
    opacity: 1;
}
.mobile-side-drawer[hidden] {
    display: none;
}
.mobile-side-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.mobile-side-drawer-content {
    position: relative;
    width: min(320px, 84vw);
    background: var(--panel-bg, #0f172a);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.7);
    transform: translateX(100%);
    transition: transform var(--dur-base, 0.25s) var(--ease, ease);
    z-index: 1;
    overflow-y: auto;
}
[dir="ltr"] .mobile-side-drawer-content {
    transform: translateX(-100%);
}
.mobile-side-drawer.visible .mobile-side-drawer-content {
    transform: translateX(0);
}
.mobile-side-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.drawer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.drawer-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--brand-accent, #14b8a6);
}
.drawer-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}
.mobile-side-drawer-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.drawer-quick-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.04);
    padding: 10px 12px;
    border-radius: var(--radius-md, 12px);
    border: 1px solid var(--border);
}
.drawer-lang-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.drawer-field-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}
.drawer-field-label .lucide-icon { width: 13px; height: 13px; }
.drawer-select {
    background: var(--btn-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 0.85rem;
    font-family: inherit;
}
.drawer-theme-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 12px;
    font-size: 0.75rem;
}
.drawer-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.drawer-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.drawer-item-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    text-align: start;
    transition: background 0.15s ease;
}
.drawer-item-btn:hover,
.drawer-item-btn:active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--brand-accent);
}
.drawer-item-btn .lucide-icon {
    width: 18px;
    height: 18px;
    color: var(--brand-accent);
    flex-shrink: 0;
}

/* Light Theme Adaptations for Mobile Navigation and Drawer */
[data-theme="light"] .mobile-bottom-nav {
    background: rgba(255, 255, 255, 0.94) !important;
    backdrop-filter: blur(24px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
    border-top: 1px solid rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.06) !important;
}
[data-theme="light"] .mobile-nav-btn {
    color: #475569 !important;
}
[data-theme="light"] .mobile-nav-btn:hover {
    color: #0f172a !important;
}
[data-theme="light"] .mobile-nav-btn:active {
    color: #0d9488 !important;
    transform: scale(0.93) !important;
}
[data-theme="light"] .mobile-nav-btn.active {
    color: #0d9488 !important;
    background: rgba(13, 148, 136, 0.1) !important;
    font-weight: 700 !important;
}
[data-theme="light"] .mobile-layer-badge {
    background: #0d9488 !important;
    color: #ffffff !important;
}
[data-theme="light"] .mobile-search-inner {
    background: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid rgba(15, 23, 42, 0.1) !important;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08) !important;
}
[data-theme="light"] .mobile-search-inner input {
    color: #0f172a !important;
}
[data-theme="light"] .mobile-search-inner input::placeholder {
    color: #64748b !important;
}
[data-theme="light"] .mobile-side-drawer-content {
    background: rgba(255, 255, 255, 0.98) !important;
    border-inline-end: 1px solid rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 0 40px rgba(15, 23, 42, 0.15) !important;
}
[data-theme="light"] .mobile-side-drawer-header {
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
}
[data-theme="light"] .drawer-title {
    color: #0d9488 !important;
}
[data-theme="light"] .drawer-quick-row {
    background: rgba(15, 23, 42, 0.03) !important;
    border: 1px solid rgba(15, 23, 42, 0.07) !important;
}
[data-theme="light"] .drawer-select {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.12) !important;
    color: #0f172a !important;
}
[data-theme="light"] .drawer-item-btn {
    color: #1e293b !important;
}
[data-theme="light"] .drawer-item-btn:hover,
[data-theme="light"] .drawer-item-btn:active {
    background: rgba(13, 148, 136, 0.08) !important;
    color: #0d9488 !important;
}
[data-theme="light"] .drawer-item-btn .lucide-icon {
    color: #0d9488 !important;
}

/* Mobile Activities Sheet */
.mobile-activities-sheet {
    position: fixed;
    inset: 0;
    z-index: var(--z-fullscreen-panel, 200);
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.mobile-activities-sheet.visible {
    display: flex;
}
.mobile-activities-sheet[hidden] {
    display: none;
}
.mobile-activities-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}
.mobile-activity-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 12px);
    color: var(--text);
    cursor: pointer;
    text-align: start;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.mobile-activity-card:active {
    background: rgba(20, 184, 166, 0.15);
    border-color: var(--brand-accent);
}
.mobile-activity-card .act-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(20, 184, 166, 0.15);
    color: var(--brand-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.mobile-activity-card .act-icon .lucide-icon {
    width: 22px;
    height: 22px;
}
.mobile-activity-card .act-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.mobile-activity-card .act-info strong {
    font-size: 0.92rem;
    color: var(--text);
}
.mobile-activity-card .act-info span {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* Mobile Mode Sheet */
.mobile-mode-sheet {
    position: fixed;
    inset: 0;
    z-index: var(--z-fullscreen-panel, 200);
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.mobile-mode-sheet.visible {
    display: flex;
}
.mobile-mode-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.mobile-mode-sheet-content {
    position: relative;
    background: var(--panel-bg, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px 24px 0 0;
    padding: 16px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-width: 540px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.7);
    color: var(--text);
    transform: translateY(100%);
    transition: transform var(--dur-slow, 0.25s) var(--ease, ease);
}
.mobile-mode-sheet.visible .mobile-mode-sheet-content,
.mobile-activities-sheet.visible .mobile-mode-sheet-content,
.mobile-sheet-modal.visible .mobile-mode-sheet-content {
    transform: translateY(0);
}
.mobile-mode-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.mobile-mode-sheet-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--brand-accent, #14b8a6);
}
.mobile-mode-sheet-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5em;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.mobile-mode-sheet-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.mobile-mode-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.mobile-mode-group .btn {
    flex: 1 0 calc(50% - 6px);
    min-height: 42px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.mobile-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.mobile-filter-group .btn {
    flex: 1 0 auto;
    min-height: 36px;
    font-size: 0.78rem;
}
.mobile-filter-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    width: 100%;
}
.sheet-drag-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.28);
    border-radius: 2px;
    margin: 2px auto 12px auto;
    flex-shrink: 0;
}
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw;
        width: 100%;
        position: relative;
    }

    .sheet-drag-handle {
        display: block !important;
    }

    /* ── 1. Unified Sleek Top Header (54px for WCAG AAA 44px Touch Targets) ── */
    .header {
        height: 54px !important;
        min-height: 54px !important;
        max-height: 54px !important;
        padding: 0 10px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
        overflow: hidden !important;
        width: 100vw !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        flex-shrink: 0 !important;
    }
    .header-right-group {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        min-width: 0 !important;
        flex-shrink: 1 !important;
    }
    .mobile-drawer-btn,
    #mobileDrawerBtn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 0 !important;
        border-radius: 8px !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid var(--border) !important;
        color: var(--text) !important;
        flex-shrink: 0 !important;
        cursor: pointer;
    }
    .mobile-drawer-btn .lucide-icon {
        width: 20px !important;
        height: 20px !important;
    }
    .header .title-group.brand-logo {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        min-width: 0 !important;
    }
    .brand-logo-img {
        width: 24px !important;
        height: 24px !important;
        flex-shrink: 0 !important;
    }
    .brand-title {
        font-size: 0.92rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        margin: 0 !important;
        letter-spacing: -0.2px !important;
    }
    .header-line {
        display: none !important;
    }

    /* Desktop elements inside header that are moved to drawer or floating */
    .header-right-group .search-box-wrapper,
    #toolsRowStart,
    .header-center-group,
    #toolsDropdown,
    #colorblindToggle,
    #histOpacityControl,
    .lang-selector-wrapper,
    #langToggle,
    #themeToggleBtn,
    #shortcutsBtn,
    .menu-toggle,
    .layers-toggle,
    .controls-bar,
    #controlsBar,
    #historyModeDock,
    .mobile-topbar {
        display: none !important;
    }

    /* Header Left Group: Only Section Toggle pills remain */
    .header-left-group {
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
        flex-shrink: 0 !important;
        overflow: visible !important;
    }
    .section-toggle {
        display: inline-flex !important;
        align-items: center !important;
        padding: 2px !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid var(--border) !important;
        border-radius: 24px !important;
        gap: 2px !important;
    }
    .section-toggle-btn {
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
        height: 44px !important;
        min-height: 44px !important;
        min-width: 44px !important;
        border-radius: 22px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        line-height: 1 !important;
        border: none !important;
        position: relative !important;
    }
    .section-toggle-btn .lucide-icon {
        width: 18px !important;
        height: 18px !important;
    }

    /* ── 2. Floating Mobile Search Bar ── */
    .mobile-search-bar {
        display: block !important;
        position: fixed !important;
        top: 56px !important;
        left: 12px !important;
        right: 12px !important;
        max-width: 440px !important;
        margin: 0 auto !important;
        z-index: var(--z-header, 100) !important;
    }

    /* ── 3. Adaptive Bottom Navigation Dock ── */
    .mobile-bottom-nav {
        display: flex !important;
        z-index: var(--z-mobile-chrome, 90) !important;
    }
    body.section-history #mobileGeoNav {
        display: none !important;
    }
    body.section-history #mobileHistoryNav {
        display: flex !important;
    }
    body.section-geo #mobileHistoryNav {
        display: none !important;
    }
    body.section-geo #mobileGeoNav {
        display: flex !important;
    }
    body:not(.section-history) #mobileHistoryNav {
        display: none !important;
    }
    body:not(.section-history) #mobileGeoNav {
        display: flex !important;
    }

    /* ── 4. Native Bottom Sheets ── */
    /* Layers & Division Popovers */
    .layers-modal.menu-popover {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0, 0, 0, 0.6) !important;
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
        z-index: var(--z-tools-dropdown, 3000) !important;
        display: none !important;
        align-items: flex-end !important;
        justify-content: center !important;
        padding: 0 !important;
        overflow: hidden !important;
        overscroll-behavior: contain !important;
    }
    .layers-modal.menu-popover.visible {
        display: flex !important;
    }
    .layers-modal.menu-popover .layers-dropdown-container {
        position: relative !important;
        bottom: 0 !important;
        top: auto !important;
        align-self: flex-end !important;
        margin: 0 auto !important;
        width: 100% !important;
        max-width: 540px !important;
        background: var(--panel-bg, #0f172a) !important;
        border: 1px solid rgba(255, 255, 255, 0.12) !important;
        border-bottom: none !important;
        border-radius: 24px 24px 0 0 !important;
        max-height: 78vh !important;
        padding: 14px 18px !important;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.7) !important;
        animation: sheet-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
        overscroll-behavior: contain !important;
    }
    .layers-modal.menu-popover .layers-modal-body {
        max-height: calc(78vh - 80px) !important;
        overflow-y: auto !important;
        overscroll-behavior: contain !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* History Popover Menus (Wars, Eras, Faiths, Travelers, Compare) - Fullscreen Mobile Sheet */
    .hist-popover-menu {
        position: fixed !important;
        top: 10px !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        border: 1px solid rgba(255, 255, 255, 0.16) !important;
        border-bottom: none !important;
        height: calc(100vh - 10px) !important;
        height: calc(100dvh - 10px) !important;
        max-height: calc(100vh - 10px) !important;
        max-height: calc(100dvh - 10px) !important;
        padding: 10px 14px !important;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
        box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.85) !important;
        background: var(--panel-bg, #0f172a) !important;
        z-index: var(--z-tools-dropdown, 3000) !important;
        display: none;
        flex-direction: column !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        animation: sheet-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
    }
    .hist-popover-menu.visible {
        display: flex !important;
    }
    .hist-popover-header {
        flex-shrink: 0 !important;
        margin-bottom: 6px !important;
        padding-bottom: 6px !important;
    }
    .hist-popover-body {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: hidden !important;
        gap: 6px !important;
        padding: 0 !important;
    }

    /* Pinned top controls within history sheets (always visible) */
    .hist-selected-card {
        flex-shrink: 0 !important;
        max-height: 190px !important;
        overflow-y: auto !important;
        margin-bottom: 2px !important;
        padding: 8px 10px !important;
    }
    .hist-selected-card .history-empty-state {
        padding: 6px 8px !important;
    }
    .hist-selected-card .hist-empty-title {
        font-size: 0.88rem !important;
    }
    .hist-selected-card .hist-empty-cue {
        font-size: 0.76rem !important;
    }
    .history-epoch-tabs {
        flex-shrink: 0 !important;
        display: flex !important;
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        padding: 2px 0 4px !important;
        margin-bottom: 2px !important;
    }
    .history-epoch-tabs::-webkit-scrollbar {
        display: none !important;
    }
    .history-epoch-tabs .war-epoch-tab,
    .history-epoch-tabs .era-epoch-tab {
        flex: 0 0 auto !important;
        width: auto !important;
        padding: 5px 12px !important;
    }
    .history-filter-row,
    .history-era-pop-filter-row,
    .history-faiths-filter-row {
        flex-shrink: 0 !important;
        margin-bottom: 2px !important;
        gap: 6px !important;
    }

    /* Smoothly scrollable content lists inside history sheets */
    #histWarTabs,
    #historyEraGroup,
    #histFaithsList,
    .hist-travelers-list {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
        overscroll-behavior: contain !important;
        padding-bottom: 24px !important;
    }

    /* While searching, collapse empty cue so results get maximum vertical space */
    .hist-popover-menu:has(input[type="text"]:focus) .history-empty-state {
        display: none !important;
    }
    .hist-popover-menu:has(input[type="text"]:focus) .hist-selected-card {
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        background: transparent !important;
    }
    .hist-compare-modal.menu-popover {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 540px !important;
        margin: 0 auto !important;
        border-radius: 24px 24px 0 0 !important;
        border: 1px solid rgba(255, 255, 255, 0.14) !important;
        border-bottom: none !important;
        max-height: 82vh !important;
        padding: 14px 18px !important;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.7) !important;
        background: var(--panel-bg, #0f172a) !important;
        z-index: var(--z-tools-dropdown, 3000) !important;
        animation: sheet-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
    }

    /* Country / Entity Info Panel */
    .country-panel {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 540px !important;
        margin: 0 auto !important;
        border-radius: 24px 24px 0 0 !important;
        border: 1px solid rgba(255, 255, 255, 0.14) !important;
        border-bottom: none !important;
        padding: 14px 18px !important;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        font-size: 0.85rem !important;
        max-height: 75vh !important;
        overflow-y: auto !important;
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.7) !important;
        z-index: var(--z-country-panel-mobile, 2500) !important;
        transform: translateY(100%) !important;
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .country-panel.visible {
        transform: translateY(0) !important;
    }
    .country-panel:has(.hist-profile-card) {
        max-width: 540px !important;
        top: auto !important;
        bottom: 0 !important;
        max-height: 82vh !important;
    }

    /* ── 5. Canvas De-cluttering & Floating Widgets ── */
    .history-bottom-bar {
        bottom: calc(var(--mobile-nav-height, 58px) + env(safe-area-inset-bottom, 0px) + 8px) !important;
        width: calc(100vw - 16px) !important;
        max-width: 500px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        padding: 6px 10px !important;
        border-radius: 14px !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
        z-index: 85 !important;
    }
    .history-year-badge {
        font-size: 0.78rem !important;
        padding: 2px 6px !important;
        min-width: 54px !important;
    }
    .zoom-controls {
        bottom: calc(var(--mobile-nav-height, 58px) + env(safe-area-inset-bottom, 0px) + 76px) !important;
        right: 12px !important;
        left: auto !important;
        gap: 8px !important;
        z-index: 80 !important;
    }
    .zoom-btn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        font-size: 1.15rem !important;
        border-radius: 10px !important;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4) !important;
    }
    .legend {
        bottom: calc(var(--mobile-nav-height, 58px) + env(safe-area-inset-bottom, 0px) + 12px) !important;
        left: 10px !important;
        font-size: 0.7rem !important;
        padding: 8px 10px !important;
        max-height: 32vh !important;
        max-width: 170px !important;
        border-radius: 12px !important;
        z-index: 80 !important;
    }
    .legend-color {
        width: 8px !important;
        height: 8px !important;
    }
    .coordinates-display {
        font-size: 0.65rem !important;
        padding: 2px 8px !important;
        bottom: calc(var(--mobile-nav-height, 58px) + env(safe-area-inset-bottom, 0px) + 2px) !important;
        white-space: nowrap !important;
        max-width: 85vw !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        z-index: 70 !important;
    }
    .copy-notification {
        bottom: calc(var(--mobile-nav-height, 58px) + env(safe-area-inset-bottom, 0px) + 10px) !important;
    }
    .hist-traveler-card {
        top: auto !important;
        bottom: calc(var(--mobile-nav-height, 58px) + env(safe-area-inset-bottom, 0px) + 8px) !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: 500px !important;
        margin: 0 auto !important;
        max-height: 55vh !important;
        border-radius: 18px !important;
        z-index: 86 !important;
    }
    .tooltip {
        font-size: 0.72rem !important;
        max-width: 180px !important;
        padding: 5px 9px !important;
    }
}

@keyframes sheet-slide-up {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* ── Strict Desktop Isolation Guard: Ensure all mobile chrome is strictly hidden on desktop (> 768px) ── */
@media (min-width: 769px) {
    .mobile-drawer-btn,
    #mobileDrawerBtn,
    .mobile-search-bar,
    #mobileSearchBar,
    .mobile-bottom-nav,
    #mobileBottomNav,
    .mobile-side-drawer,
    #mobileSideDrawer,
    .mobile-activities-sheet,
    #mobileActivitiesSheet,
    .mobile-mode-sheet,
    #mobileModeSheet,
    .sheet-drag-handle,
    .menu-toggle,
    .layers-toggle {
        display: none !important;
    }
}
@media (min-width: 1024px) {
    .tools-row-start { flex-shrink: 0; }
    .header-left-group {
        flex-wrap: nowrap;
    }
    .header {
        padding: 0 16px ;
    }
    .header h1 {
        line-height: 1.1;
        font-size: 0.85em;
    }
    .header .logo-icon {
        line-height: 1;
        font-size: 18px;
    }
    /* ── Top navigation bar: floating dark islands over the map ──
       The wrapper is an invisible, pointer-transparent layer pinned to the
       top of the map container; all visuals live on the three islands
       inside .controls-bar-toprow: the Base Map card (rightmost in RTL),
       the Layers capsule, and the Division card (leftmost in RTL). */
    .controls-bar {
        position: absolute ;
        top: 0 ;
        inset-inline: 0 ;
        bottom: auto ;
        transform: none ;
        width: 100% ;
        max-width: 100% ;
        background: transparent ;
        backdrop-filter: none ;
        border-radius: 0 ;
        box-shadow: none ;
        border: none ;
        display: flex ;
        flex-direction: row ;
        flex-wrap: wrap ;
        justify-content: flex-start ;
        align-items: flex-start ;
        gap: 10px ;
        max-height: none ;
        overflow-y: visible ;
        z-index: var(--z-controls-bar) ;
        margin: 0 ;
        margin-top: 0 ;
        margin-inline-start: 0 ;
        /* Zero padding so the unified dock sticks flush to the top edge
           and the inline-start corner of the map container (top-right in
           RTL, top-left in LTR — driven by the CSS logical properties). */
        padding: 0 ;
        pointer-events: none; /* map drag works through the empty space */
    }
    /* DOM order is [stepped group][Layers][Division]; with
       justify-content: flex-start the CSS logical flow anchors the trio
       to the inline-START edge: top-right in RTL (Arabic), top-left in
       LTR (English). Only the floating units are interactive; the gaps
       pass clicks to the map. */
    .controls-bar-toprow {
        width: 100%;
        justify-content: flex-start;
        align-items: flex-start;
        flex-wrap: nowrap ;
        gap: var(--dock-outer-gap);
        margin-inline-start: 0;
        pointer-events: none;
    }
    .controls-bar-toprow > * {
        pointer-events: auto;
    }
    /* ONE unified dock container: both sections (Base Map 52px + 4-buttons
       38px) share a single slate background, single 1px outline and one
       drop-shadow that follows the stepped silhouette. The silhouette
       itself (step + concave fillet at the junction) is an SVG path mask
       generated in JS from the measured geometry — masks are the only
       clip mechanism this layout reliably supports for the dynamic
       junction position, and they must live on the container while the
       shadow sits on the wrapper above it (a filter on the same element
       would be clipped by the mask). */
    #controlsBar .dock-unified-wrap {
        filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.4)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
        pointer-events: none;
        margin-inline-start: 0;
        margin-top: 0;
    }
    /* ── Semantic dock tokens (floating dock only) ──
       Scoped to the ≥1024px floating docks so button text/icons are
       always bound to the theme surface (dark slate → light text;
       light surface → dark text). Below 1024 the card keeps the global
       --btn-bg / --text tokens unchanged. The names follow the shared
       [data-theme] switch; light overrides live in the theme blocks
       further down. */
    #controlsBar .stepped-dock-group,
    #controlsBar .floating-capsule {
        --dock-bg: rgba(18, 24, 36, 0.92);
        --dock-border: rgba(255, 255, 255, 0.14);
        --btn-bg: rgba(255, 255, 255, 0.06);
        --btn-bg-hover: rgba(255, 255, 255, 0.12);
        --btn-text: #f1f5f9;
        --btn-icon-color: #94a3b8;
        --accent-color: #14B8A6;
        --accent-color-rgb: 20, 184, 166;
        --accent-glow: rgba(20, 184, 166, 0.4);
        --active-bg: #1a3a38;
        --active-text: #80e0d0;
        --ctl-label: #14B8A6;
    }
    /* Light mode: docks switch to a light surface with high-contrast
       dark text (--btn-text #0f172a) so "التقسيم" / "طبقات" and every
       utility label stays fully visible; the accent deepens to #0d9488
       so it reads against light surfaces. The header KEEPS its dark
       slate, so its title tokens stay light. */
    [data-theme="light"] #controlsBar .stepped-dock-group,
    [data-theme="light"] #controlsBar .floating-capsule {
        --dock-bg: rgba(255, 255, 255, 0.90);
        --dock-border: rgba(15, 23, 42, 0.09);
        --btn-bg: rgba(15, 23, 42, 0.04);
        --btn-bg-hover: rgba(15, 23, 42, 0.08);
        --btn-text: #1e293b;
        --btn-icon-color: #475569;
        --accent-color: #0d9488;
        --accent-color-rgb: 13, 148, 136;
        --accent-glow: rgba(13, 148, 136, 0.25);
        --active-bg: #0d9488;
        --active-text: #ffffff;
        --ctl-label: #0d9488;
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
    }
    [data-theme="light"] #controlsBar .dock-unified-wrap {
        filter: drop-shadow(0 6px 20px rgba(15, 23, 42, 0.1)) drop-shadow(0 2px 6px rgba(15, 23, 42, 0.05));
    }
    @media (prefers-color-scheme: light) {
        :root:not([data-theme]) #controlsBar .stepped-dock-group,
        :root:not([data-theme]) #controlsBar .floating-capsule {
            --dock-bg: rgba(255, 255, 255, 0.90);
            --dock-border: rgba(15, 23, 42, 0.09);
            --btn-bg: rgba(15, 23, 42, 0.04);
            --btn-bg-hover: rgba(15, 23, 42, 0.08);
            --btn-text: #1e293b;
            --btn-icon-color: #475569;
            --accent-color: #0d9488;
            --accent-color-rgb: 13, 148, 136;
            --accent-glow: rgba(13, 148, 136, 0.25);
            --active-bg: #0d9488;
            --active-text: #ffffff;
            --ctl-label: #0d9488;
        }
    }
    #controlsBar .stepped-dock-group {
        align-items: flex-start;
        background: var(--dock-bg);
        backdrop-filter: blur(8px);
        border: 1px solid var(--dock-border);
        /* Top corners stay square (the dock is flush against the top
           edge); the bottom corners use the --dock-radius token that
           also drives the junction fillet and the two capsules. */
        border-radius: 0 0 var(--dock-radius) var(--dock-radius);
        padding: 0;
        box-shadow: none;
        -webkit-mask-size: 100% 100%;
        mask-size: 100% 100%;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: 0 0;
        mask-position: 0 0;
        pointer-events: none;
    }
    /* RTL: the dock anchors flush to the top-right viewport boundary, so
       the physical bottom-right corner is squared off — no curve against
       the screen edge; the rounded bottom-left stays for the inner side.
       The SVG silhouette mask mirrors this in syncDockMask(). */
    html[dir="rtl"] #controlsBar .stepped-dock-group,
    html[dir="rtl"] #controlsBar .row-unified {
        border-bottom-right-radius: 0 ;
    }
    /* Buttons: flex layout + line-height 1 keeps every island height
       driven by min-height/padding instead of font line boxes (Arabic
       metrics are taller, which would otherwise stretch the docks
       inconsistently). */
    #controlsBar .btn {
        display: inline-flex !important;
        align-items: center ;
        justify-content: center ;
        line-height: 1 ;
        color: var(--btn-text) !important;
        background: var(--btn-bg) ;
        border-color: var(--dock-border) ;
    }
    /* The container box includes the masked-out notch; make the box
       click-transparent and re-enable the two visible sections, so the
       notch and the strip below it pass clicks through to the map. */
    #controlsBar .stepped-dock-group {
        pointer-events: none;
    }
    #controlsBar .row-unified,
    #controlsBar #filterRow {
        pointer-events: auto;
    }
    /* Base Map section: no borders, no background of its own — the shared
       container paints everything. Height/padding are fluid
       (--dock-height-tall / --dock-pad-*-tall) and scale from 720p to
       4K; the bottom-inline-end corner is rounded by the silhouette
       mask. */
    #controlsBar .row-unified {
        border: none;
        border-radius: 0 0 var(--dock-radius) 0;
        background: none;
        padding: var(--dock-pad-y-tall) var(--dock-pad-x-tall);
        min-height: var(--dock-height-tall);
        flex-wrap: nowrap ;
    }
    /* 4-buttons section: shallower step, transparent, borderless,
       top-aligned beside the taller block; bottom-inline-start corner
       rounded by the silhouette mask. */
    #controlsBar #filterRow {
        border: none;
        border-radius: 0 0 0 var(--dock-radius);
        background: none;
        padding: var(--dock-pad-y-short) var(--dock-pad-x-short);
        height: var(--dock-height-short);
        margin-inline-start: 0;
    }
    /* Capsules: slate island with subtle outline, same fluid height as
       the 4-buttons dock, harmonized --dock-radius radius, and a fluid
       8px breathing gap below the flush top edge (they do NOT stick to
       the header). They sit on the SAME single line as the stepped
       group — never a second row. */
    #controlsBar .floating-capsule {
        background: var(--dock-bg) !important;
        backdrop-filter: blur(8px);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.25);
        border: 1px solid var(--dock-border);
        height: var(--dock-height-short);
        border-radius: var(--dock-radius) ;
        margin-top: var(--dock-cap-margin-top);
        margin-inline-start: 0;
        padding: var(--dock-pad-y-short) var(--dock-pad-x-short) !important;
        flex: 0 0 auto;
        white-space: nowrap;
    }
    #controlsBar #modeButtons {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center ;
    }
    /* The Base Map dock carries 8 buttons + label, so its internals stay
       fluid-compact to keep the trio on ONE line at every width. */
    #controlsBar #modeButtons .btn {
        padding: var(--dock-pad-y-btn) var(--dock-pad-x-btn) !important;
        min-height: var(--dock-btn-h-tall) !important;
        font-size: var(--dock-font-size) ;
        gap: var(--dock-gap) ;
        border-radius: var(--dock-radius) !important;
        flex-shrink: 0;
        white-space: nowrap;
    }
    #controlsBar #filterRow .btn {
        padding: var(--dock-pad-y-btn) var(--dock-pad-x-btn) !important;
        min-height: var(--dock-btn-h-short) !important;
        font-size: var(--dock-font-size) ;
        gap: var(--dock-gap) !important;
        border-radius: var(--dock-radius) !important;
        flex-shrink: 0;
        white-space: nowrap;
    }
    #controlsBar .row-unified {
        gap: var(--dock-gap) !important;
    }
    /* Semantic theme bindings for the floating docks: hover, icons and
       active states all follow the scoped --btn-* / --accent-* tokens,
       so every state stays legible on both the dark slate and the
       light surface. */
    #controlsBar .btn:hover {
        background: var(--btn-bg-hover) ;
        border-color: var(--dock-border) ;
        transform: none ;
        box-shadow: none ;
    }
    #controlsBar .btn.active,
    #controlsBar .mode-btn.active,
    #controlsBar .toggle-on {
        background: var(--active-bg) ;
        border-color: var(--accent-color) ;
        color: var(--active-text) !important;
    }
    #controlsBar .btn.active {
        box-shadow: 0 0 0 2px var(--accent-glow) ;
        font-weight: 700;
    }
    #controlsBar .mode-btn.active {
        box-shadow: 0 0 0 2px var(--accent-glow) ;
    }
/* English mode names are wide ("Explanation Mode", "Compare
       Projections"…); a consolidated EN-only fluid shave (88% font,
       ~28% tighter inline padding on the row buttons, slimmer row and
       capsule inline padding) keeps the trio on ONE line at every
       width while still scaling with vw. */
    html[lang="en"] #controlsBar #modeButtons .btn,
    html[lang="en"] #controlsBar #filterRow .btn {
        font-size: calc(var(--dock-font-size) * 0.88) ;
        padding-inline: calc(var(--dock-pad-x-btn) * 0.72) !important;
    }
    html[lang="en"] #controlsBar .row-unified {
        padding-inline: calc(var(--dock-pad-x-tall) * 0.8) !important;
    }
    html[lang="en"] #controlsBar #filterRow {
        padding-inline: calc(var(--dock-pad-x-short) * 0.85) ;
    }
    html[lang="en"] #controlsBar .floating-capsule {
        padding-inline: calc(var(--dock-pad-x-short) * 0.8) !important;
    }
    .controls-bar .row {
        flex-wrap: wrap ;
        gap: 6px 12px ;
    }
    .controls-bar .row-label {
        display: inline-block ;
        font-size: 0.7em ;
        color: var(--text-secondary) ;
        margin-inline-end: 4px;
    }
    .controls-bar .btn {
        font-size: var(--dock-font-size) ;
        padding: var(--dock-pad-y-btn) var(--dock-pad-x-btn) ;
        min-height: var(--dock-btn-h-short) ;
        border-radius: var(--dock-radius) ;
        white-space: nowrap;
    }
    #controlsBar .btn .lucide-icon {
        width: var(--dock-icon-size) ;
        height: var(--dock-icon-size) ;
        color: var(--btn-icon-color) ;
        stroke: currentColor ;
        fill: none ;
    }
    .controls-bar .search-box input {
        width: 160px ;
        font-size: 0.8em ;
        padding: 5px 10px ;
        padding-inline-start: 28px ;
    }
    .controls-bar .control-label {
        font-size: calc(var(--dock-font-size) * 0.72) ;
        font-weight: 600;
        color: var(--ctl-label, var(--accent-color));
        text-transform: uppercase;
        letter-spacing: 0.4px;
        white-space: nowrap;
        padding: 0 4px ;
    }
    .controls-bar .divider {
        width: 1px;
        height: 20px;
        background: var(--border);
        border-radius: 1px;
        flex-shrink: 0;
        display: inline-block;
    }
    .zoom-controls {
        bottom: 40px ;
        right: 30px ;
        gap: 10px ;
    }
    .zoom-btn {
        width: 44px ;
        height: 44px ;
        font-size: 1.6em ;
        border-radius: var(--radius-sm) ;
        background: var(--panel-overlay-96) ;
        backdrop-filter: none ;
        border: 1px solid rgba(255, 255, 255, 0.15) ;
    }
    .zoom-btn:hover {
        background: rgba(50, 56, 70, 0.95) ;
        transform: scale(1.08) ;
    }
    .legend {
        bottom: 40px ;
        left: 30px ;
        font-size: 0.85em ;
        padding: 14px 20px ;
        border-radius: var(--radius-md) ;
        min-width: 160px ;
        background: var(--legend-bg) ;
        backdrop-filter: none ;
    }
    .legend-color {
        width: 14px ;
        height: 14px ;
        border-radius: 4px ;
    }
    .legend-item {
        gap: 8px ;
        padding: 2px 0 ;
    }
    .header {
        padding: 6px 20px ;
    }
    .header h1 {
        font-size: 1.1em ;
    }
    .header-line {
        display: block ;
    }
    .country-panel {
        font-size: 0.9em ;
        max-width: 360px ;
        padding: 16px 20px ;
        top: 80px ;
    }
    .tooltip {
        font-size: 0.85em ;
        padding: 8px 14px ;
        max-width: 260px ;
    }
    .coordinates-display {
        font-size: 0.7em ;
        padding: 6px 20px ;
        bottom: 16px ;
    }
}
@media (min-width: 1024px) and (max-width: 1439px) {
    .controls-bar .btn .btn-text {
        display: none ;
    }
    .controls-bar {
        gap: 4px 8px ;
    }
}
@media (min-width: 769px) and (max-width: 1023px) {
    .zoom-btn {
        width: 36px;
        height: 36px;
        font-size: 1.2em;
    }
    .legend {
        font-size: 0.75em;
        padding: 10px 14px;
    }
}
.legend-gradient-bar {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    margin: 4px 0 2px;
    border: 1px solid rgba(255,255,255,0.15);
}
.legend-gradient-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.lang-dropdown {
    position: relative;
    display: inline-block;
}
.lang-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    z-index: var(--z-topmost);
    display: none;

    box-shadow: var(--shadow-md);
    margin-top: 2px;
}
.lang-dropdown-menu.visible {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.lang-option {
    background: none;
    border: none;
    color: var(--text);
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.75em;
    border-radius: var(--radius-sm);
    text-align: left;
    white-space: nowrap;
    font-family: inherit;
    transition: background var(--dur-fast) var(--ease);
}
.lang-option:hover {
    background: var(--btn-hover);
}
.lang-option.active {
    background: var(--btn-active);
    color: var(--brand-accent);
    font-weight: 600;
}
.mobile-lang-dropdown .lang-dropdown-menu {
    left: auto;
    right: 0;
}
.lang-dropdown .dropdown-arrow {
    transition: transform var(--dur-base) var(--ease);
    font-size: 0.7em;
    margin-left: 2px;
}
.lang-dropdown:has(.lang-dropdown-menu.visible) .dropdown-arrow {
    transform: rotate(180deg);
}
#langToggle, #mobileLangToggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
@media (max-width: 768px) {
    .mobile-lang-dropdown .lang-dropdown-menu {
        left: 0;
        right: auto;
    }
}
.btn {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--btn-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 0.6em;
    font-weight: 500;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
    white-space: nowrap;
    font-family: inherit;
    outline: none;
    position: relative;
}
.btn:hover {
    background: var(--btn-hover);
    border-color: #555;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn[title]:hover {
    z-index: var(--z-topmost);
}
.btn.active, .mode-btn.active, .toggle-on {
    background: #1a3a38;
    border-color: var(--brand-accent);
    color: #80e0d0;
}
.btn.active {
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.4);
    font-weight: 700;
}
.mode-btn.active {
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.35);
}
.toggle-on {
    box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.3);
}
.bloc-select {
    background: #1e2a36;
    color: #c0d0e0;
    border: 1px solid #3a4a5a;
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    max-width: 140px;
}
.bloc-select:focus {
    border-color: var(--brand-accent);
    outline: none;
}

/* Language selector overlay */
.lang-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-lang-overlay, 9998);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 1;
    transition: opacity var(--dur-base) var(--ease);
}
.has-map-lang .lang-overlay,
.lang-overlay.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    display: none !important;
}
.lang-overlay-content {
    text-align: center;
    color: #fff;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 28px;
    padding: 38px 32px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    max-width: 560px;
    width: 90vw;
    box-sizing: border-box;
    animation: langOverlayIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes langOverlayIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.lang-overlay-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.lang-overlay-title {
    font-size: 1.55em;
    font-weight: 800;
    margin: 0 0 6px;
    background: linear-gradient(135deg, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.3px;
}
.lang-overlay-subtitle {
    font-size: 0.92em;
    color: #94a3b8;
    margin: 0 0 26px;
    font-weight: 500;
}
.lang-overlay-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}
.lang-overlay-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 22px;
    border-radius: 16px;
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #f1f5f9;
    cursor: pointer;
    font-family: inherit;
    font-size: 1em;
    font-weight: 700;
    transition: background var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease), transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
    min-width: 110px;
}
.lang-overlay-btn:hover {
    background: rgba(20, 184, 166, 0.18);
    border-color: var(--brand-accent, #14b8a6);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(20, 184, 166, 0.3);
}
.lang-overlay-flag {
    font-size: 1.8em;
    line-height: 1;
}
.lang-overlay-name {
    font-size: 0.92em;
    font-weight: 700;
}
@media (max-width: 500px) {
    .lang-overlay-content { padding: 28px 18px; border-radius: 20px; }
    .lang-overlay-title { font-size: 1.25em; }
    .lang-overlay-subtitle { font-size: 0.82em; margin-bottom: 20px; }
    .lang-overlay-btn {
        min-width: 88px;
        padding: 12px 14px;
        font-size: 0.88em;
    }
    .lang-overlay-flag { font-size: 1.5em; }
}

/* ── Light Theme Adaptations for Language Overlay, Cards & Overlays ── */
[data-theme="light"] .lang-overlay {
    background: rgba(15, 23, 42, 0.42) !important;
    backdrop-filter: blur(20px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(160%) !important;
}
[data-theme="light"] .lang-overlay-content {
    background: #ffffff !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    color: #0f172a !important;
    box-shadow: 0 24px 64px -12px rgba(15, 23, 42, 0.2), 0 8px 24px -4px rgba(15, 23, 42, 0.06) !important;
}
[data-theme="light"] .lang-overlay-title {
    background: none !important;
    -webkit-text-fill-color: #0f172a !important;
    color: #0f172a !important;
    font-size: 1.55rem !important;
    font-weight: 800 !important;
}
[data-theme="light"] .lang-overlay-subtitle {
    color: #475569 !important;
    font-size: 0.92rem !important;
    font-weight: 500 !important;
}
[data-theme="light"] .lang-overlay-btn {
    background: #f8fafc !important;
    border: 1.5px solid rgba(15, 23, 42, 0.1) !important;
    border-radius: 16px !important;
    color: #1e293b !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04) !important;
}
[data-theme="light"] .lang-overlay-btn:hover {
    background: #f0fdfa !important;
    border-color: #0d9488 !important;
    color: #0d9488 !important;
    transform: translateY(-3px) !important;
    box-shadow: 0 10px 24px rgba(13, 148, 136, 0.16) !important;
}
[data-theme="light"] .lang-overlay-name {
    color: #0f172a !important;
    font-weight: 700 !important;
}
[data-theme="light"] .lang-overlay-btn:hover .lang-overlay-name {
    color: #0d9488 !important;
}

/* Light Theme: Section Picker Modal */
[data-theme="light"] .section-picker-overlay {
    background: rgba(15, 23, 42, 0.42) !important;
    backdrop-filter: blur(16px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(16px) saturate(160%) !important;
}
[data-theme="light"] .section-picker-content {
    background: #ffffff !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    color: #0f172a !important;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18) !important;
}
[data-theme="light"] .section-picker-title {
    color: #0d9488 !important;
    font-weight: 800 !important;
}
[data-theme="light"] .section-picker-subtitle {
    color: #475569 !important;
    opacity: 1 !important;
}
[data-theme="light"] .section-card {
    background: #f8fafc !important;
    border: 1.5px solid rgba(15, 23, 42, 0.1) !important;
    color: #0f172a !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04) !important;
}
[data-theme="light"] .section-card:hover {
    background: #f0fdfa !important;
    border-color: #0d9488 !important;
    box-shadow: 0 10px 24px rgba(13, 148, 136, 0.15) !important;
}
[data-theme="light"] .section-card strong {
    color: #0f172a !important;
}
[data-theme="light"] .section-card span {
    color: #475569 !important;
    opacity: 1 !important;
}
[data-theme="light"] .section-remember {
    color: #334155 !important;
}
[data-theme="light"] .section-picker-hint {
    color: #64748b !important;
    opacity: 1 !important;
}

/* Light Theme: Projection Explainer Card */
[data-theme="light"] .projection-card {
    background: #ffffff !important;
    border: 1.5px solid rgba(13, 148, 136, 0.25) !important;
    color: #0f172a !important;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18), 0 0 24px rgba(13, 148, 136, 0.12) !important;
}
[data-theme="light"] .projection-title {
    color: #0d9488 !important;
    font-weight: 800 !important;
}
[data-theme="light"] .projection-body {
    color: #334155 !important;
}
[data-theme="light"] .projection-body strong {
    color: #0f172a !important;
}

/* Light Theme: Onboarding Tutorial Card */
[data-theme="light"] .onboard-card {
    background: #ffffff !important;
    border: 1.5px solid rgba(13, 148, 136, 0.25) !important;
    color: #0f172a !important;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16) !important;
}
[data-theme="light"] .onboard-card-title {
    color: #0d9488 !important;
    font-weight: 800 !important;
}
[data-theme="light"] .onboard-card-text {
    color: #334155 !important;
}
[data-theme="light"] .onboard-dot {
    background: rgba(15, 23, 42, 0.18) !important;
}
[data-theme="light"] .onboard-dot.active {
    background: #0d9488 !important;
}
[data-theme="light"] .onboarding-hint {
    background: rgba(255, 255, 255, 0.95) !important;
    color: #0f172a !important;
    border: 1px solid rgba(15, 23, 42, 0.1) !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1) !important;
}

/* Light Theme: Country Info Panel */
[data-theme="light"] .country-panel {
    background: rgba(255, 255, 255, 0.96) !important;
    border: 1px solid rgba(15, 23, 42, 0.1) !important;
    color: #0f172a !important;
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.12) !important;
}
[data-theme="light"] .country-panel .close-btn,
[data-theme="light"] .country-panel .export-btn {
    background: #f1f5f9 !important;
    border: 1px solid rgba(15, 23, 42, 0.12) !important;
    color: #334155 !important;
}
[data-theme="light"] .country-panel .close-btn:hover,
[data-theme="light"] .country-panel .export-btn:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}
[data-theme="light"] .country-panel table td,
[data-theme="light"] .country-panel table th {
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
    color: #1e293b !important;
}

/* Light Theme: Search Suggestions List */
[data-theme="light"] .suggestions-list {
    background: #ffffff !important;
    border: 1px solid rgba(15, 23, 42, 0.1) !important;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12) !important;
}
[data-theme="light"] .suggestions-list li {
    color: #0f172a !important;
}
[data-theme="light"] .suggestions-list li:hover {
    background: #f0fdfa !important;
    color: #0d9488 !important;
}

/* Screen-reader-only utility class (WCAG AA accessible text) */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Keyboard focus visibility (accessibility) — restores a visible indicator
   for keyboard users only, without adding a ring on mouse/touch clicks. */
.btn:focus-visible,
.zoom-btn:focus-visible,
.bloc-select:focus-visible,
.search-box input:focus-visible,
.mobile-search-box input:focus-visible,
.mobile-topbar-btn:focus-visible,
.mobile-nav-btn:focus-visible,
.layers-toggle:focus-visible,
.menu-toggle:focus-visible,
.close-btn:focus-visible,
.export-btn:focus-visible,
.shortcuts-close:focus-visible,
.layers-modal-close:focus-visible,
.mobile-mode-sheet-close:focus-visible,
#searchInput:focus-visible,
#mobileSearchInput:focus-visible,
.history-timeline:focus-visible,
.religions-timeline:focus-visible,
.hist-traveler-timeline-track:focus-visible,
.history-play-btn:focus-visible,
.hist-traveler-step-btn:focus-visible,
.hist-drawer-close-btn:focus-visible,
.history-search-input:focus-visible,
.history-region-select:focus-visible,
.hist-traveler-item:focus-visible,
.hist-traveler-wp-node:focus-visible,
.hist-traveler-nav-arrow:focus-visible,
.hist-traveler-close-btn:focus-visible,
.hist-waypoint-popup-close:focus-visible,
.hist-phase-btn:focus-visible,
.history-war-tab:focus-visible,
.history-scenario-btn:focus-visible,
.faiths-popover-item:focus-visible,
.hist-epoch-col-items button:focus-visible,
.hist-action-btn:focus-visible,
.hist-station-pill:focus-visible,
.quiz-input:focus-visible,
.quiz-sidebar-close-btn:focus-visible,
.hist-landmark-pin:focus-visible,
.hist-polity-boundary:focus-visible,
[tabindex="0"]:focus-visible {
    outline: 2px solid var(--focus-ring, #60a5fa);
    outline-offset: 2px;
}
/* Tactical Battlefield & Operations Styling in Wars */
.hist-tactical-radius {
    transition: r 0.3s ease, fill-opacity 0.3s ease;
    animation: histTacticalPulse 2.8s ease-in-out infinite alternate;
}
@keyframes histTacticalPulse {
    0% { fill-opacity: 0.12; stroke-opacity: 0.7; }
    100% { fill-opacity: 0.28; stroke-opacity: 1; }
}
.hist-war-battle-pin circle {
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
    transition: transform 0.2s ease, r 0.2s ease;
}
.hist-war-battle-pin:hover circle,
.hist-war-battle-pin:focus-visible circle {
    stroke-width: 2.4px !important;
    stroke: #ffffff !important;
}
.layers-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
}
.layers-modal.visible {
    display: flex;
}
.layers-modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur-lg));
}
.layers-modal-content {
    position: relative;
    background: var(--panel-bg);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    max-width: 520px;
    width: 92vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    color: var(--text);
}
.layers-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.layers-modal-header h3 {
    margin: 0;
    font-size: 1em;
    font-weight: 700;
    color: var(--brand-accent);
}
.layers-modal-close {
    background: none;
    border: none;
    color: #cbd5e1;
    font-size: 1.4em;
    cursor: pointer;
    padding: 0 4px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.layers-modal-close:hover {
    color: #ffffff;
}
[data-theme="light"] .layers-modal-close {
    color: #334155 !important;
}
[data-theme="light"] .layers-modal-close:hover {
    color: #0f172a !important;
}
.layers-category {
    margin-bottom: 12px;
}
.layers-category h4 {
    margin: 0 0 6px 0;
    font-size: 0.75em;
    font-weight: 600;
    color: #8899aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.layers-category .layers-items {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.layers-category .btn {
    padding: 6px 10px;
    font-size: 0.7em;
    border-radius: var(--radius-pill);
    min-height: 32px;
}
.layers-modal-body .btn {
    padding: 6px 10px;
    font-size: 0.7em;
    border-radius: var(--radius-pill);
    min-height: 32px;
}
.layers-category .bloc-select {
    font-size: 0.7em;
    padding: 6px 8px;
    max-width: 160px;
}

/* ── Anchored menu popovers: Layers + Divisions ────────────────────────
   GNOME Shell-style app-grid menus that float directly beneath their
   toggle buttons. NO modal backdrop: the map stays fully visible and
   interactive underneath (pointer events are never blocked). The panel
   is positioned by JS (ui.js _positionPopover) in viewport coordinates
   and always clamped on screen; the inset defaults below are just the
   pre-position fallback. */
.layers-modal.menu-popover {
    position: fixed;
    inset: 0 auto auto 0;
    z-index: var(--z-layers-popover);
    display: none;
    align-items: stretch;
    justify-content: stretch;
}
.layers-modal.menu-popover.visible {
    display: block;
}
.layers-modal.menu-popover .layers-modal-backdrop {
    display: none;
}
.layers-modal.menu-popover .layers-dropdown-container {
    position: relative;
    width: clamp(320px, 90vw, 420px);
    max-width: none;
    max-height: 80vh;
    padding: 16px;
    box-sizing: border-box;
    overflow-x: hidden ;
    overflow-y: auto;
    background: var(--panel-overlay-96);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: menu-popover-in 0.18s ease;
}
@keyframes menu-popover-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to { opacity: 1; transform: none; }
}
.layers-modal.menu-popover .layers-modal-header {
    margin-bottom: 10px;
}
.layers-modal.menu-popover .layers-modal-header h3 {
    font-size: 0.85em;
}
/* GNOME Shell app-grid tiles: every layer is a uniform cell with the
   icon above the label; categories are grid sections. */
.layers-modal.menu-popover .layers-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.layers-modal.menu-popover .menu-popover-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.layers-modal.menu-popover .menu-popover-actions .btn {
    padding: 6px 12px;
    font-size: 0.72em;
    min-height: 32px;
    border-radius: var(--radius-pill);
}
/* GNOME Shell app-grid tiles: every layer is a uniform card with the
   icon above the label, all inside ONE flat grid — no category headers.
   The card uses the dock surface tokens (--btn-bg/--btn-text/
   --accent-color) so the popover matches the controls dock; the aliases
   below resolve them to the panel tokens since the popover lives outside
   the dock scope. */
.layers-modal.menu-popover {
    --btn-bg: var(--panel-bg);
    --btn-bg-hover: var(--btn-hover);
    --btn-text: var(--text);
    --accent-color: var(--brand-accent);
    --accent-color-rgb: 20, 184, 166;
    --dock-border: var(--border);
}
[data-theme="light"] .layers-modal.menu-popover {
    --accent-color: #0d9488;
    --accent-color-rgb: 13, 148, 136;
}
[data-theme="light"] .layers-modal.menu-popover .layers-dropdown-container {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(24px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
    border: 1px solid rgba(15, 23, 42, 0.09) !important;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.04) !important;
}
[data-theme="light"] .layers-modal.menu-popover .layers-modal-header {
    border-bottom: 1px solid rgba(15, 23, 42, 0.07) !important;
}
[data-theme="light"] .layers-modal.menu-popover .layers-modal-header h3 {
    color: #0f172a !important;
}
[data-theme="light"] .layers-modal.menu-popover .layers-modal-close {
    color: #0f172a !important;
}
[data-theme="light"] .layers-modal.menu-popover .layers-modal-close:hover {
    color: #000000 !important;
}
[data-theme="light"] .layers-modal.menu-popover .layer-card {
    background: rgba(15, 23, 42, 0.03) !important;
    border: 1px solid rgba(15, 23, 42, 0.07) !important;
    color: #1e293b !important;
}
[data-theme="light"] .layers-modal.menu-popover .layer-card:hover {
    background: rgba(13, 148, 136, 0.08) !important;
    border-color: rgba(13, 148, 136, 0.3) !important;
    color: #0f766e !important;
}
[data-theme="light"] .layers-modal.menu-popover .layer-card.active,
[data-theme="light"] .layers-modal.menu-popover .layer-card.toggle-on {
    background: rgba(13, 148, 136, 0.14) !important;
    border-color: #0d9488 !important;
    color: #0f766e !important;
    box-shadow: 0 0 0 1px rgba(13, 148, 136, 0.3) !important;
}
[data-theme="light"] .layers-modal.menu-popover .layer-card.active .layer-icon,
[data-theme="light"] .layers-modal.menu-popover .layer-card.toggle-on .layer-icon {
    color: #0d9488 !important;
}
[data-theme="light"] .layers-modal.menu-popover .blocs-compound-card {
    background: rgba(15, 23, 42, 0.03) !important;
    border: 1px solid rgba(15, 23, 42, 0.07) !important;
}
[data-theme="light"] .layers-modal.menu-popover .blocs-select {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.12) !important;
    color: #0f172a !important;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .layers-modal.menu-popover {
        --accent-color: #0d9488;
        --accent-color-rgb: 13, 148, 136;
    }
}
.layers-modal.menu-popover .layers-flat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden ;
}
@media (min-width: 480px) {
    .layers-modal.menu-popover .layers-flat-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
.layers-modal.menu-popover .layer-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto ;
    min-height: 75px;
    padding: 8px 6px;
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: var(--dock-radius, 10px);
    background: var(--btn-bg);
    color: var(--btn-text);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    text-align: center;
    overflow: visible;
}
.layers-modal.menu-popover .layer-card:hover {
    background: var(--btn-bg-hover);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}
.layers-modal.menu-popover .layer-card.active,
.layers-modal.menu-popover .layer-card.toggle-on {
    background: rgba(var(--accent-color-rgb), 0.15);
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 0 0 1px rgba(var(--accent-color-rgb), 0.35);
}
.layers-modal.menu-popover .layer-card .layer-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 4px;
    flex-shrink: 0;
    color: var(--btn-icon-color, var(--text-secondary));
}
.layers-modal.menu-popover .layer-card .layer-icon svg {
    width: 22px ;
    height: 22px ;
}
.layers-modal.menu-popover .layer-card.active .layer-icon,
.layers-modal.menu-popover .layer-card.toggle-on .layer-icon,
.layers-modal.menu-popover .blocs-toggle-btn.toggle-on .layer-icon {
    color: var(--accent-color);
}
.layers-modal.menu-popover .layer-card .layer-title,
.layers-modal.menu-popover .layer-card label,
.layers-modal.menu-popover .layer-card span:not(.layer-icon),
.layers-modal.menu-popover .blocs-toggle-btn .layer-title,
.layers-modal.menu-popover .blocs-toggle-btn label,
.layers-modal.menu-popover .blocs-toggle-btn span:not(.layer-icon) {
    font-size: 11.5px ;
    line-height: 1.25;
    color: var(--btn-text, #f1f5f9);
    white-space: normal ;
    word-break: break-word;
    max-width: 100%;
    overflow: visible;
    display: block;
}
/* Geopolitical Blocs compound card: the toggle button and its bloc
   selector form ONE connected control spanning 2 grid columns. */
body.history-mode .blocs-compound-card,
[data-section="history"] .blocs-compound-card,
.layers-modal.menu-popover .blocs-compound-card.geo-layer[style*="display: none"] {
    display: none !important;
}
.layers-modal.menu-popover .blocs-compound-card {
    grid-column: span 2;
    background: var(--btn-bg);
    border: 1px solid var(--dock-border);
    border-radius: var(--dock-radius, 10px);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.2s ease;
}
.layers-modal.menu-popover .blocs-compound-card:focus-within,
.layers-modal.menu-popover .blocs-compound-card.active {
    border-color: var(--accent-color, #0d9488);
    background: rgba(var(--accent-color-rgb, 13, 148, 136), 0.08);
}
.layers-modal.menu-popover .blocs-compound-card .blocs-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--btn-text);
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    padding: 2px 0;
}
.layers-modal.menu-popover .blocs-compound-card .blocs-toggle-btn .layer-icon {
    font-size: 20px;
    margin-bottom: 0;
    color: var(--btn-icon-color, var(--text-secondary));
}
.layers-modal.menu-popover .blocs-compound-card .blocs-toggle-btn .layer-icon svg {
    width: 20px ;
    height: 20px ;
}
.layers-modal.menu-popover .blocs-compound-card select {
    width: 100%;
    max-width: none;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--dock-border);
    color: var(--btn-text);
    font-size: 11px;
    cursor: pointer;
}
/* Divisions menu: the religion filter buttons become the same app-grid
   tiles (label-only cells). */
.layers-modal.menu-popover #religionButtons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
    width: 100%;
}
.layers-modal.menu-popover #religionButtons .religion-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 56px;
    padding: 10px 6px;
    font-size: 0.75em;
    text-align: center;
    white-space: normal;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel-bg);
    color: var(--text);
}
.layers-modal.menu-popover #religionButtons .religion-btn:hover {
    background: var(--btn-hover);
    border-color: var(--brand-accent);
    transform: translateY(-1px);
}
.layers-modal.menu-popover #religionButtons .religion-btn.active {
    background: rgba(20, 184, 166, 0.14);
    border-color: var(--brand-accent);
    color: var(--brand-accent);
    box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.35);
}
/* Slimmer tiles on small screens so the grid never overflows. */
@media (max-width: 600px) {
    .layers-modal.menu-popover #religionButtons {
        grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    }
}
.shortcuts-overlay {
    position: fixed;
    inset: 0;
    background: var(--glass-bg);
    z-index: var(--z-fullscreen-panel);
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(var(--glass-blur-lg));
}
.shortcuts-overlay.visible {
    display: flex;
}
.shortcuts-box {
    background: var(--shortcuts-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    color: var(--text);
    min-width: 280px;
    max-width: 90vw;
    font-size: 0.75em;
    box-shadow: var(--shadow-lg);
}
.shortcuts-box h3 {
    margin: 0 0 14px;
    font-size: 1.1em;
    color: var(--brand-accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}
.shortcut-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}
.shortcut-key {
    display: inline-block;
    background: #2e3545;
    border: 1px solid #4a5068;
    border-radius: var(--radius-sm);
    padding: 1px 7px;
    font-family: monospace;
    font-size: 1.05em;
    min-width: 28px;
    text-align: center;
    color: #d0e4ff;
    flex-shrink: 0;
}
.shortcut-desc {
    color: var(--text-secondary);
}
.shortcuts-close {
    margin-top: 16px;
    width: 100%;
    padding: 7px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--btn-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 1em;
}
.onboarding-hint {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + 30px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--onboarding-bg);
    border: 1px solid rgba(100,160,255,0.3);
    border-radius: var(--radius-md);
    padding: 10px 18px;
    color: var(--text);
    font-size: 0.7em;
    z-index: var(--z-onboarding-hint);
    text-align: center;
    pointer-events: none;
    opacity: 1;
    transition: opacity var(--dur-slow) var(--ease);
    box-shadow: var(--shadow-md);
    max-width: 90vw;
    line-height: 1.6;
}
.onboarding-hint.fade-out {
    opacity: 0;
}
.divider {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 2px;
    border-radius: 1px;
    flex-shrink: 0;
}
.lucide-icon {
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
    vertical-align: middle;
}
.zoom-btn .lucide-icon {
    margin-inline-end: 0;
}
.menu-toggle .lucide-icon,
.layers-toggle .lucide-icon {
    margin-inline-end: 0;
}
.logo-icon .lucide-icon {
    margin-inline-end: 0;
}
.mobile-nav-btn .lucide-icon {
    margin-inline-end: 0;
}
.control-label .lucide-icon {
    margin-inline-end: 3px;
    vertical-align: -1px;
}
.onboarding-hint .lucide-icon {
    vertical-align: -3px;
}
.btn .lucide-icon {
    margin-inline-end: 3px;
    vertical-align: -2px;
}
.btn-text {
    display: inline;
}
.mobile-nav-btn .btn-text {
    font-size: clamp(0.66rem, 2.7vw, 0.73rem) !important;
    font-weight: 700 !important;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    display: block;
}
/* ── Tooltip hardening: toolbar buttons must never clip their tooltips ──
   Dock buttons use native `title` tooltips (browser-rendered, never
   clipped); these rules cover custom tooltips ([data-tooltip]::after and
   .button-tooltip) and guarantee the button itself stays an open
   positioning context. The dock lives inside .map-container
   (overflow: hidden) so ABOVE-floating tooltips would be clipped at the
   map's top edge; tooltips therefore float ABOVE on mobile (dock at the
   bottom) and BELOW on desktop (dock pinned to the top), which the
   media query below handles. */
.map-mode-btn,
.layer-btn,
.split-btn,
.toolbar-btn,
.dock-btn,
[data-tooltip],
.mode-btn,
.bar-layers-btn,
.bloc-select,
.toolbar-controls .btn,
#controlsBar .btn {
    position: relative ;
    overflow: visible ;
}

[data-tooltip]::after,
.button-tooltip {
    position: absolute ;
    bottom: calc(100% + 8px) ;
    left: 50% ;
    transform: translateX(-50%) ;
    white-space: nowrap ;
    background: rgba(18, 24, 36, 0.95) ;
    color: #f1f5f9 ;
    font-size: 11px ;
    font-weight: 500 ;
    padding: 4px 8px ;
    border-radius: 6px ;
    border: 1px solid rgba(255, 255, 255, 0.15) ;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) ;
    z-index: var(--z-button-tooltip) ;
    pointer-events: none ;
}
/* Native `title` tooltips are browser-rendered and float above the page,
   so they can never be clipped or trapped inside the dock. The JS keeps
   `data-tooltip` attributes in sync with `title`, but they must NOT be
   rendered as pseudo-elements: the dock lives inside .map-container
   (overflow: hidden), so any in-page tooltip would be clipped inside the
   button/dock instead of floating outside. */
.tooltip-bottom::after {
    top: calc(100% + 8px) ;
    bottom: auto ;
}

@media (min-width: 1024px) {
    .btn[data-tooltip]:hover::after,
    [data-tooltip]::after {
        bottom: auto ;
        top: calc(100% + 8px) ;
    }
}

/* ── Onboarding Tutorial Overlay ── */
.onboard-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-topmost);
    display: none;
    pointer-events: none;
}
.onboard-overlay.active {
    display: block;
    pointer-events: auto;
}
.onboard-glow {
    position: fixed;
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.7);
    transition: all var(--dur-slow) var(--ease);
    pointer-events: none;
    z-index: var(--z-topmost);
}
.onboard-glow::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 16px;
    border: 2px solid rgba(20,184,166,0.7);
    animation: onboardPulse 2s ease-in-out infinite;
}
@keyframes onboardPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(20,184,166,0.4), inset 0 0 8px rgba(20,184,166,0.1); }
    50% { box-shadow: 0 0 20px rgba(20,184,166,0.8), inset 0 0 12px rgba(20,184,166,0.2); }
}
.onboard-card {
    position: fixed;
    z-index: var(--z-topmost-card);
    background: var(--panel-bg, #1a1d25);
    border: 1px solid rgba(20,184,166,0.4);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    max-width: 340px;
    min-width: 260px;
    color: var(--text, #e0e0e0);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(20,184,166,0.15);
    transition: all var(--dur-slow) var(--ease);
    animation: onboardCardIn 0.4s ease both;
}
@keyframes onboardCardIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes projectionCardIn {
    from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)) scale(0.96); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.onboard-card.onboard-pulse-hint {
    animation: onboardCardHint 0.35s ease !important;
}
@keyframes onboardCardHint {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); box-shadow: var(--shadow-lg), 0 0 32px rgba(20, 184, 166, 0.85); }
}
.onboard-card-icon {
    font-size: 2em;
    margin-bottom: 6px;
}
.onboard-card-title {
    margin: 0 0 6px;
    font-size: 1.05em;
    font-weight: 700;
    color: #14b8a6;
}
.onboard-card-text {
    margin: 0 0 14px;
    font-size: 0.85em;
    line-height: 1.6;
    color: var(--text-secondary, #a0b0c0);
}
.onboard-card-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 14px;
}
.onboard-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    transition: all var(--dur-base) var(--ease);
}
.onboard-dot.active {
    background: #14b8a6;
    box-shadow: 0 0 6px rgba(20,184,166,0.6);
    width: 20px;
    border-radius: var(--radius-sm);
}
.onboard-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.onboard-btn {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85em;
    font-weight: 600;
    transition: all var(--dur-fast) var(--ease);
}
.onboard-skip {
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary, #a0b0c0);
    border: 1px solid rgba(255,255,255,0.1);
}
.onboard-skip:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.onboard-next {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    color: #fff;
    box-shadow: 0 4px 12px rgba(20,184,166,0.3);
}
.onboard-next:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(20,184,166,0.4);
}
@media (max-width: 600px) {
    .onboard-card {
        max-width: 280px;
        min-width: 220px;
        padding: 16px 18px;
        font-size: 0.9em;
    }
    .onboard-card-title { font-size: 0.95em; }
    .onboard-card-text { font-size: 0.8em; }
}

/* ── Projection Explainer Card ── */
.projection-card {
    position: fixed;
    z-index: var(--z-topmost-card);
    background: var(--panel-bg, #1a1d25);
    border: 1px solid rgba(20,184,166,0.4);
    border-radius: var(--radius-md);
    padding: 24px 28px;
    width: 620px;
    max-width: 92vw;
    max-height: 80vh;
    color: var(--text, #e0e0e0);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(20,184,166,0.15);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    animation: projectionCardIn 0.4s ease both;
    display: flex;
    flex-direction: column;
}
.projection-title {
    margin: 0 0 12px;
    font-size: 1.25em;
    font-weight: 700;
    color: #14b8a6;
    text-align: center;
    flex-shrink: 0;
}
.projection-body {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
    font-size: 0.98em;
    line-height: 1.75;
    color: var(--text, #e0e0e0);
}
.projection-body strong {
    color: var(--text, #e0e0e0);
}
.projection-body p {
    margin: 0 0 10px;
}
@media (max-width: 600px) {
    .projection-card { padding: 18px 20px; max-height: 85vh; }
    .projection-body { font-size: 0.88em; }
}

/* ── Quiz Mode ── */
.quiz-overlay .quiz-btn {
    background: var(--brand-accent);
    color: #fff;
    border-color: var(--brand-accent);
    font-weight: 700;
}
.quiz-overlay .quiz-btn:hover {
    background: #0d9488;
    border-color: #0d9488;
}
.quiz-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur-lg));
}
.quiz-overlay[style*="display: none"],
.quiz-overlay[style*="display:none"] {
    display: none !important;
}
.quiz-panel {
    position: relative;
    background: var(--panel-bg, #1a2332);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-md);
    padding: 24px 28px;
    max-width: 460px;
    width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    color: var(--text, #e0e8f0);
    text-align: right;
}
.quiz-panel-title {
    margin: 0 0 16px 0;
    font-size: 1.15em;
    font-weight: 700;
    text-align: center;
}
.quiz-form-row {
    margin-bottom: 14px;
}
.quiz-label {
    display: block;
    font-size: 0.8em;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-secondary, #a0b0c0);
}
.quiz-select, .quiz-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.07);
    color: var(--text, #e0e8f0);
    font-size: 0.85em;
    font-family: inherit;
    outline: none;
}
.quiz-select:focus, .quiz-input:focus {
    border-color: var(--brand-accent);
}
.quiz-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
}
.quiz-checkbox-label {
    font-size: 0.8em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text, #e0e8f0);
}
.quiz-checkbox-label input[type="checkbox"] {
    accent-color: var(--brand-accent);
}
.quiz-radio-label {
    font-size: 0.8em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text, #e0e8f0);
}
.quiz-radio-label input[type="radio"] {
    accent-color: var(--brand-accent);
}
.quiz-scope-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 6px;
    min-height: 20px;
}
.quiz-scope-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: var(--radius-pill);
    padding: 2px 8px 2px 10px;
    font-size: 0.75em;
    font-weight: 600;
    color: var(--text, #e0e8f0);
    cursor: default;
}
.quiz-scope-chip-remove {
    cursor: pointer;
    opacity: 0.6;
    font-size: 1.1em;
    line-height: 1;
    padding: 0 1px;
    transition: opacity var(--dur-fast) var(--ease);
}
.quiz-scope-chip-remove:hover {
    opacity: 1;
}
.quiz-scope-add {
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.quiz-scope-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.quiz-scope-tab {
    flex: 1;
    padding: 6px 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary, #a0b0c0);
    font-size: 0.75em;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.quiz-scope-tab:hover {
    background: rgba(255,255,255,0.05);
}
.quiz-scope-tab.active {
    color: var(--brand-accent);
    background: rgba(255,255,255,0.05);
    border-bottom: 2px solid var(--brand-accent);
}
.quiz-scope-list {
    max-height: 160px;
    overflow-y: auto;
    padding: 6px 8px;
    background: rgba(0,0,0,0.15);
}
.quiz-scope-countries {
    display: flex;
    flex-direction: column;
    max-height: 200px;
    overflow: hidden;
}
.quiz-scope-countries .quiz-input {
    margin-bottom: 4px;
    flex-shrink: 0;
}
.quiz-country-checklist {
    overflow-y: auto;
    flex: 1;
}
.quiz-scope-list::-webkit-scrollbar {
    width: 5px;
}
.quiz-scope-list::-webkit-scrollbar-track {
    background: transparent;
}
.quiz-scope-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
}
.quiz-scope-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 0;
    font-size: 0.78em;
    color: var(--text, #e0e8f0);
    cursor: pointer;
}
.quiz-scope-item:hover {
    color: #fff;
}
.quiz-scope-item input[type="checkbox"],
.quiz-scope-item input[type="radio"] {
    accent-color: var(--brand-accent);
}
.quiz-time-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}
.quiz-time-input-wrap .quiz-input {
    width: 70px;
}
.quiz-time-input-wrap span {
    font-size: 0.8em;
    color: var(--text-secondary, #a0b0c0);
}
.quiz-form-actions {
    text-align: center;
    margin-top: 18px;
}
.quiz-overlay .quiz-start-btn {
    background: var(--brand-accent);
    color: #fff;
    border-color: var(--brand-accent);
    padding: 8px 28px;
    font-size: 0.9em;
    font-weight: 700;
    border-radius: var(--radius-sm);
}
.quiz-overlay .quiz-start-btn:hover {
    background: #0d9488;
    border-color: #0d9488;
}
.quiz-hud-overlay {
    background: none;
    backdrop-filter: none;
    pointer-events: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 24px;
    flex-direction: column;
    gap: 10px;
}
.quiz-hud-prompt-banner {
    pointer-events: auto;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur-sm));
    border: 2px solid var(--brand-accent);
    border-radius: var(--radius-md);
    padding: 16px 32px;
    box-shadow: var(--shadow-lg);
    font-size: 1.6em;
    font-weight: 800;
    color: var(--brand-accent);
    text-align: center;
    max-width: 90vw;
}
.quiz-hud-meta-row {
    pointer-events: auto;
    display: flex;
    gap: 16px;
    align-items: center;
    background: rgba(10, 20, 30, 0.85);
    border-radius: var(--radius-md);
    padding: 6px 16px;
    font-size: 0.75em;
    font-weight: 600;
    color: #e0e8f0;
}
.quiz-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: var(--z-modal-alert);
    padding: 14px 32px;
    border-radius: var(--radius-sm);
    font-size: 1.2em;
    font-weight: 700;
    color: #fff;
    text-align: center;
    pointer-events: none;
    animation: quizFeedbackPulse 1.2s ease-out forwards;
}
.quiz-feedback.correct {
    background: rgba(34, 197, 94, 0.92);
}
.quiz-feedback.incorrect {
    background: rgba(239, 68, 68, 0.92);
}
.quiz-feedback.pending {
    background: rgba(20, 184, 166, 0.92);
}
@keyframes quizFeedbackPulse {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    70% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}
.quiz-end-panel {
    text-align: center;
}
.quiz-final-score {
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--brand-accent);
}
.quiz-missed-wrap {
    text-align: right;
    margin-bottom: 16px;
}
.quiz-missed-wrap h4 {
    font-size: 0.9em;
    margin-bottom: 8px;
    color: var(--text-secondary, #a0b0c0);
}
.quiz-missed-list {
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.8em;
}
.quiz-missed-item {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.quiz-missed-item .quiz-missed-layer {
    font-size: 0.85em;
    color: var(--text-secondary, #a0b0c0);
}
.quiz-end-early-btn {
    pointer-events: auto;
    background: rgba(180, 60, 40, 0.85);
    border: 1px solid rgba(255,120,80,0.35);
    color: #ffe8e0;
    border-radius: var(--radius-sm);
    padding: 4px 12px;
    font-size: 0.82em;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    margin-left: 6px;
    transition: background var(--dur-fast) var(--ease);
}
.quiz-end-early-btn:hover {
    background: rgba(210, 70, 45, 0.95);
}
.quiz-hud-tf-row {
    pointer-events: auto;
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: center;
}
.quiz-tf-btn {
    padding: 12px 36px;
    border-radius: var(--radius-sm);
    font-size: 1.2em;
    font-weight: 800;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.quiz-tf-btn:hover {
    transform: scale(1.05);
}
.quiz-tf-true {
    background: rgba(34, 180, 80, 0.9);
    color: #fff;
    border-color: rgba(34, 180, 80, 1);
    box-shadow: 0 2px 12px rgba(34, 180, 80, 0.4);
}
.quiz-tf-false {
    background: rgba(210, 70, 45, 0.9);
    color: #fff;
    border-color: rgba(210, 70, 45, 1);
    box-shadow: 0 2px 12px rgba(210, 70, 45, 0.4);
}
.quiz-hud-written-row {
    pointer-events: auto;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}
.quiz-hud-written-row .quiz-input {
    max-width: 260px;
}
.quiz-hud-typed-row {
    pointer-events: auto;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}
.quiz-hud-typed-row .quiz-input {
    max-width: 260px;
}
.quiz-hud-mc-row {
    pointer-events: auto;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}
.quiz-mc-btn {
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid transparent;
    background: rgba(100, 140, 220, 0.85);
    color: #fff;
    box-shadow: 0 2px 10px rgba(100, 140, 220, 0.3);
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.quiz-mc-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 14px rgba(100, 140, 220, 0.5);
}
.quiz-choice-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
    border-left: 3px solid transparent;
    padding-left: 6px;
    border-radius: 4px;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.quiz-choice-row.correct-selected {
    border-left-color: var(--brand-accent, #14b8a6);
    background-color: rgba(20, 184, 166, 0.1);
}
.quiz-choices-instruction {
    font-size: 0.8em;
    font-weight: 600;
    color: var(--brand-accent, #14b8a6);
    margin-bottom: 8px;
    padding: 6px 10px;
    background: rgba(20, 184, 166, 0.08);
    border-radius: var(--radius-sm);
    line-height: 1.4;
}
.quiz-choice-input {
    flex: 1;
}
.quiz-choice-remove {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    cursor: pointer;
    background: rgba(210, 70, 45, 0.8);
    color: #fff;
    border: none;
}
.quiz-add-choice-btn {
    margin-top: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    cursor: pointer;
    background: rgba(100, 140, 220, 0.7);
    color: #fff;
    border: none;
}
.quiz-active .zooming-active text,
.quiz-active text {
    display: none ;
}
.quiz-active .controls-bar,
.quiz-active .legend-container,
.quiz-active .info-overlay,
.quiz-active #toolsRowStart,
.quiz-active #toolsDropdown,
.quiz-active #langToggle {
    display: none ;
}
.quiz-active #tooltip {
    display: none ;
}
.btn.quiz-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
@media (max-width: 500px) {
    .quiz-panel { padding: 16px 18px; }
    .quiz-hud-prompt-banner { font-size: 1.2em; padding: 12px 20px; }
    .quiz-hud-meta-row { font-size: 0.65em; gap: 10px; padding: 6px 12px; }
    .quiz-custom-panels { flex-direction: column ; gap: 10px; }
    .quiz-custom-main { width: 92vw; max-width: 92vw; max-height: 50vh; }
    .quiz-custom-sidebar { width: 92vw; max-width: 92vw; max-height: 40vh; }
}

/* ── Quiz Mode Choice Screen ── */
.quiz-choice-panel { max-width: 520px; }
.quiz-choice-cards {
    display: flex;
    gap: 16px;
    margin-top: 12px;
}
.quiz-choice-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 16px;
    border-radius: var(--radius-md);
    border: 2px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    color: var(--text, #e0e8f0);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--dur-base) var(--ease);
    text-align: center;
}
.quiz-choice-card:hover {
    border-color: var(--brand-accent);
    background: rgba(20,184,166,0.08);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(20,184,166,0.15);
}
.quiz-choice-icon { font-size: 2.2em; }
.quiz-choice-label { font-size: 0.95em; font-weight: 700; }
.quiz-choice-desc { font-size: 0.75em; color: var(--text-secondary, #a0b0c0); line-height: 1.4; }

.quiz-choice-teacher-banner {
    margin-top: 18px;
    padding: 12px 16px;
    background: rgba(20, 184, 166, 0.08);
    border: 1px solid rgba(20, 184, 166, 0.25);
    border-radius: var(--radius-md, 12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.quiz-choice-teacher-banner .teacher-banner-icon {
    width: 26px;
    height: 26px;
    color: var(--brand-accent, #14b8a6);
    flex-shrink: 0;
}
.teacher-hub-shortcut-btn {
    white-space: nowrap;
    font-size: 0.84rem;
    padding: 6px 14px;
    border-radius: 8px;
    background: var(--brand-accent, #14b8a6);
    color: #fff;
    border: 1px solid var(--brand-accent, #14b8a6);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}
.teacher-hub-shortcut-btn:hover {
    filter: brightness(1.15);
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.4);
}

/* ── Custom Questions: Two-Panel Layout ── */
.quiz-custom-panels {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur-md));
}
.quiz-custom-panels[style*="display: none"],
.quiz-custom-panels[style*="display:none"] {
    display: none ;
}
[dir="rtl"] .quiz-custom-panels {
    flex-direction: row;
}
[dir="ltr"] .quiz-custom-panels {
    flex-direction: row-reverse;
}

/* Main Panel */
.quiz-custom-main {
    width: 340px;
    max-width: 90vw;
    max-height: 80vh;
    background: var(--panel-bg, #1a2332);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--text, #e0e8f0);
    text-align: right;
}
.quiz-custom-main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.quiz-custom-main-title {
    margin: 0;
    font-size: 1em;
    font-weight: 700;
    text-align: center;
    flex: 1;
}
.quiz-custom-main-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
}
.quiz-custom-main-body .quiz-form-row {
    margin-bottom: 12px;
}
.quiz-custom-main-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.quiz-custom-main-footer .quiz-start-btn {
    width: 100%;
}

/* Selected Questions in Main Panel */
.quiz-selected-section {
    margin-top: 4px;
}
.quiz-custom-selected-empty {
    text-align: center;
    padding: 12px 8px;
    color: var(--text-secondary, #a0b0c0);
    font-size: 0.78em;
    font-style: italic;
    border: 1px dashed rgba(255,255,255,0.12);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.08);
}
.quiz-custom-selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
}
.quiz-selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(20,184,166,0.15);
    border: 1px solid rgba(20,184,166,0.35);
    border-radius: var(--radius-pill);
    padding: 3px 8px;
    font-size: 0.75em;
    font-weight: 600;
    color: var(--brand-accent, #14b8a6);
    max-width: 100%;
}
.quiz-selected-tag-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}
.quiz-selected-tag-remove {
    cursor: pointer;
    opacity: 0.6;
    font-size: 1.1em;
    line-height: 1;
    padding: 0 1px;
    transition: opacity var(--dur-fast) var(--ease);
    flex-shrink: 0;
}
.quiz-selected-tag-remove:hover { opacity: 1; }

/* Session New Questions */
.quiz-session-new-section {
    margin-top: 8px;
}
.quiz-session-new-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
}
.quiz-session-new-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(20,184,166,0.1);
    border: 1px solid rgba(20,184,166,0.25);
    border-left: 3px solid var(--brand-accent, #14b8a6);
    border-radius: var(--radius-pill);
    padding: 3px 8px;
    font-size: 0.75em;
    font-weight: 600;
    color: var(--text, #e0e8f0);
    max-width: 100%;
}
.quiz-session-new-item-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}
.quiz-session-new-item-remove {
    cursor: pointer;
    opacity: 0.6;
    font-size: 1.1em;
    line-height: 1;
    padding: 0 1px;
    transition: opacity var(--dur-fast) var(--ease);
    flex-shrink: 0;
}
.quiz-session-new-item-remove:hover { opacity: 1; }

/* Sidebar (Library) */
.quiz-custom-sidebar {
    width: 300px;
    max-width: 85vw;
    max-height: 70vh;
    background: var(--panel-bg, #1a2332);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--text, #e0e8f0);
    text-align: right;
}
.quiz-custom-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.quiz-custom-sidebar-title {
    margin: 0;
    font-size: 0.9em;
    font-weight: 700;
    color: var(--text-secondary, #a0b0c0);
}
.quiz-custom-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
}
.quiz-custom-sidebar-body .quiz-form-row {
    margin-bottom: 12px;
}

/* Close button */
.quiz-sidebar-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #a0b0c0);
    font-size: 1.4em;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color var(--dur-fast) var(--ease);
}
.quiz-sidebar-close-btn:hover { color: #fff; }
.quiz-custom-list-wrap {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    padding: 8px;
    background: rgba(0,0,0,0.12);
}
.quiz-custom-empty {
    text-align: center;
    padding: 20px 10px;
    color: var(--text-secondary, #a0b0c0);
    font-size: 0.8em;
}
.quiz-custom-list { display: flex; flex-direction: column; gap: 4px; }
.quiz-custom-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8em;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.quiz-custom-item:hover { background: rgba(255,255,255,0.05); }
.quiz-custom-item.quiz-custom-item-selected {
    background: rgba(20,184,166,0.12);
    border-color: rgba(20,184,166,0.35);
}
.quiz-custom-item-text { flex: 1; min-width: 0; }
.quiz-custom-item-type {
    font-size: 0.85em;
    color: var(--text-secondary, #a0b0c0);
    flex-shrink: 0;
}
.quiz-custom-item-delete {
    background: none;
    border: none;
    color: #e06060;
    cursor: pointer;
    font-size: 1.1em;
    padding: 0 4px;
    opacity: 0.5;
    transition: opacity var(--dur-fast) var(--ease);
    flex-shrink: 0;
}
.quiz-custom-item-delete:hover { opacity: 1; }
.quiz-custom-item-check {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.quiz-custom-item-selected .quiz-custom-item-check {
    background: var(--brand-accent, #14b8a6);
    border-color: var(--brand-accent, #14b8a6);
}
.quiz-custom-item-check-mark {
    color: #fff;
    font-size: 0.7em;
    font-weight: 700;
    line-height: 1;
}
.quiz-create-btn {
    width: 100%;
    padding: 10px;
    border: 2px dashed rgba(20,184,166,0.4);
    color: var(--brand-accent);
    background: rgba(20,184,166,0.06);
    font-weight: 600;
}
.quiz-create-btn:hover {
    background: rgba(20,184,166,0.12);
    border-color: var(--brand-accent);
}

/* ── Authoring Banner ── */
.quiz-authoring-banner {
    position: fixed;
    top: calc(var(--header-height) + 12px);
    bottom: auto !important;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-modal-alert);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    height: auto !important;
    max-height: 48px;
    white-space: nowrap;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur-sm));
    border: 2px solid var(--brand-accent);
    border-radius: var(--radius-md);
    padding: 8px 18px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 12px rgba(20, 184, 166, 0.3);
    color: var(--brand-accent);
    font-weight: 600;
    font-size: 0.85em;
    animation: quizFeedbackPulse 0.6s ease-out;
}
.quiz-cancel-authoring-btn {
    padding: 4px 12px;
    font-size: 0.85em;
    background: rgba(180,60,40,0.3);
    border-color: rgba(255,120,80,0.3);
    color: #ffe8e0;
}

/* ── Authoring Overlay (bottom form) ── */
.quiz-authoring-overlay {
    background: none ;
    backdrop-filter: none ;
    pointer-events: none ;
    align-items: flex-end ;
    justify-content: center !important;
    padding-bottom: 80px;
}
.quiz-authoring-overlay[style*="display: none"],
.quiz-authoring-overlay[style*="display:none"] {
    display: none !important;
}
.quiz-authoring-overlay .quiz-authoring-panel {
    pointer-events: auto;
}
.quiz-authoring-panel {
    max-width: 520px;
    width: 92vw;
}
.quiz-marker-type-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.quiz-authoring-status {
    font-size: 0.85em;
    color: var(--brand-accent);
    font-weight: 600;
    text-align: center;
    padding: 8px;
    background: rgba(20,184,166,0.08);
    border-radius: var(--radius-sm);
}
.quiz-cancel-btn {
    padding: 8px 20px;
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary, #a0b0c0);
}

/* ── Review Panel ── */
.quiz-review-panel { max-width: 520px; }
.quiz-review-disclaimer {
    font-size: 0.75em;
    color: #e08040;
    text-align: center;
    margin: 0 0 14px;
    padding: 6px 10px;
    background: rgba(224,128,64,0.08);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(224,128,64,0.2);
}
.quiz-review-progress {
    text-align: center;
    font-size: 0.8em;
    font-weight: 600;
    color: var(--text-secondary, #a0b0c0);
    margin-bottom: 10px;
}
.quiz-review-card {
    background: rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 14px;
    text-align: center;
}
.quiz-review-prompt {
    font-size: 1em;
    font-weight: 700;
    color: var(--text, #e0e8f0);
    margin-bottom: 8px;
}
.quiz-review-click-info {
    font-size: 0.8em;
    color: var(--text-secondary, #a0b0c0);
}
.quiz-review-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.quiz-review-btn {
    padding: 10px 24px;
    font-size: 0.9em;
    font-weight: 700;
    border-radius: var(--radius-sm);
}
.quiz-review-correct {
    background: rgba(34,197,94,0.2);
    border-color: rgba(34,197,94,0.4);
    color: #4ade80;
}
.quiz-review-correct:hover {
    background: rgba(34,197,94,0.35);
}
.quiz-review-incorrect {
    background: rgba(239,68,68,0.2);
    border-color: rgba(239,68,68,0.4);
    color: #f87171;
}
.quiz-review-incorrect:hover {
    background: rgba(239,68,68,0.35);
}
.quiz-review-done {
    text-align: center;
    padding: 16px 0;
}
.quiz-review-done p {
    font-size: 0.9em;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--brand-accent);
}

/* ── Quiz Session & Results ── */
.quiz-session-inputs {
    display: flex;
    gap: 8px;
}
.quiz-session-inputs .quiz-input {
    flex: 1;
}
.quiz-session-inputs .quiz-input:last-child {
    max-width: 120px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    text-align: center;
}
.quiz-session-created {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(20,184,166,0.15);
    border: 1px solid rgba(20,184,166,0.35);
    border-radius: var(--radius-sm);
    color: var(--brand-accent);
    font-weight: 700;
    font-size: 0.85em;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.quiz-results-panel {
    max-width: 560px;
}
.quiz-results-session-code {
    text-align: center;
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.quiz-results-session-code strong {
    color: var(--brand-accent);
    letter-spacing: 1px;
    font-size: 1.1em;
}
.quiz-results-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 12px;
}
.quiz-results-tab {
    flex: 1;
    padding: 8px 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-secondary);
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.quiz-results-tab:hover {
    color: var(--text);
}
.quiz-results-tab.active {
    color: var(--brand-accent);
    border-bottom-color: var(--brand-accent);
}
.quiz-results-body {
    max-height: 50vh;
    overflow-y: auto;
    font-size: 0.85em;
}
.quiz-results-table {
    width: 100%;
    border-collapse: collapse;
}
.quiz-results-table th,
.quiz-results-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.quiz-results-table th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
    background: var(--panel-bg);
    z-index: var(--z-sticky-cell);
}
.quiz-results-table td {
    color: var(--text);
}
.quiz-results-score {
    font-weight: 700;
    color: var(--brand-accent);
}
.quiz-results-time {
    color: var(--text-secondary);
    font-size: 0.9em;
}
.quiz-results-empty {
    text-align: center;
    padding: 30px 16px;
    color: var(--text-secondary);
    font-size: 0.9em;
}
.quiz-results-detail-card {
    background: rgba(0,0,0,0.12);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 10px;
}
.quiz-results-detail-name {
    font-weight: 700;
    font-size: 1em;
    margin-bottom: 6px;
    color: var(--text);
}
.quiz-results-detail-meta {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.quiz-results-detail-answers {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.quiz-results-detail-answer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9em;
}
.quiz-results-detail-answer.correct {
    background: rgba(34,197,94,0.1);
}
.quiz-results-detail-answer.incorrect {
    background: rgba(239,68,68,0.1);
}
.quiz-results-detail-answer.skipped {
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
}
.quiz-results-detail-prompt {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.quiz-results-detail-status {
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.85em;
}



/* ── Lucide icon sizing (overrides inline width/height attributes) ── */
svg[class*="lucide"] { width: 14px !important; height: 14px !important; }
.zoom-btn svg[class*="lucide"] { width: 16px !important; height: 16px !important; }
.logo-icon svg[class*="lucide"] { width: 20px !important; height: 20px !important; }
.menu-toggle svg[class*="lucide"], .layers-toggle svg[class*="lucide"] { width: 20px ; height: 20px !important; }
.mobile-nav-btn svg[class*="lucide"] { width: 20px !important; height: 20px !important; }
.onboarding-hint svg[class*="lucide"] { width: 14px ; height: 14px ; }

.measure-result-label {
    position: fixed;
    z-index: var(--z-measure-label);
    padding: 6px 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur-sm));
    border: var(--glass-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    color: var(--text);
    font-size: 0.85em;
    font-weight: 600;
    pointer-events: none;
    white-space: nowrap;
}
body.measure-active { cursor: crosshair; }
body.measure-active .map-container { cursor: crosshair; }

/* ── Presentation Mode ── */
body.presentation-mode .header,
body.presentation-mode .controls-bar,
body.presentation-mode .zoom-controls,
body.presentation-mode .coordinates-display,
body.presentation-mode .legend,
body.presentation-mode .country-panel,
body.presentation-mode .menu-toggle,
body.presentation-mode .layers-toggle,
body.presentation-mode .mobile-topbar,
body.presentation-mode .mobile-bottom-nav,
body.presentation-mode .onboarding-hint,
body.presentation-mode .measure-result-label,
body.presentation-mode .copy-notification {
    display: none ;
}
body.presentation-mode .map-container {
    position: fixed;
    inset: 0;
    cursor: default;
}
.presentation-exit-btn {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: var(--z-presentation-exit);
    display: none;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: rgba(10, 14, 20, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 0.75em;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    backdrop-filter: blur(var(--glass-blur-sm));
    box-shadow: var(--shadow-md);
    transition: opacity var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
    opacity: 0;
    pointer-events: none;
}
body.presentation-mode .presentation-exit-btn {
    display: inline-flex;
    pointer-events: auto;
    animation: presExitFadeIn 0.4s ease 0.8s forwards;
}
.presentation-exit-btn:hover {
    background: rgba(210, 70, 45, 0.9);
    border-color: rgba(255, 120, 80, 0.5);
}
@keyframes presExitFadeIn {
    to { opacity: 1; }
}
.export-blocking-overlay {
    position: absolute;
    inset: 0;
    z-index: var(--z-topmost);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--glass-bg, rgba(0,0,0,0.35));
    backdrop-filter: blur(var(--glass-blur-sm, 4px));
    color: #fff;
    font-size: 0.95rem;
    pointer-events: all;
}
.export-blocking-spinner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    animation: export-spin 0.8s linear infinite;
}
@keyframes export-spin {
    to { transform: rotate(360deg); }
}
.data-table-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-fullscreen-panel);
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg, rgba(0,0,0,0.5));
    backdrop-filter: blur(var(--glass-blur-sm, 6px));
}
.data-table-overlay.visible {
    display: flex;
}
.data-table-box {
    width: min(90vw, 900px);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.data-table-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.data-table-header h3 {
    margin: 0;
    flex-shrink: 0;
    color: var(--brand-accent);
}
#dataTableSearch {
    flex: 1;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 0.9em;
}
#dataTableSearch:focus {
    outline: 2px solid var(--focus-ring);
    border-color: var(--brand-accent);
}
.data-table-close {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 12px;
    font-size: 0.85em;
}
.data-table-close:hover {
    color: var(--text);
    border-color: var(--text-secondary);
}
.data-table-scroll {
    overflow: auto;
    padding: 0 16px 16px;
    flex: 1;
}
th[data-sort-key] {
    cursor: pointer;
    user-select: none;
}
th[data-sort-key]:hover {
    color: var(--brand-accent);
}
th[data-sort-key][aria-sort]::after {
    content: ' ▲';
    font-size: 0.7em;
}
th[data-sort-key][aria-sort="descending"]::after {
    content: ' ▼';
    font-size: 0.7em;
}

/* ── Projection Comparison Lens ─────────────────── */
.content-row {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-height: 0;
    overflow: hidden;
}
.content-row .map-container {
    flex: 1;
    min-width: 0;
}
.projection-compare-dock {
    display: none;
    flex: 0 0 42%;
    max-width: 640px;
    min-width: 320px;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--panel-bg, #1a2733);
    border-inline-start: 1px solid rgba(255,255,255,0.1);
    box-shadow: none;
    overflow: hidden;
}
.projection-compare-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.projection-compare-header .quiz-panel-title {
    margin: 0;
}
.projection-compare-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.projection-compare-header .close-btn {
    color: var(--text, #e0e8f0);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    line-height: 1;
}
.projection-compare-header .close-btn:hover { color: var(--brand-accent); }
.projection-compare-tabs {
    display: flex;
    gap: 4px;
}
.projection-compare-tab {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary, #8a9bb0);
    cursor: pointer;
    font-size: 0.9em;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.projection-compare-tab:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text, #e0e8f0);
}
.projection-compare-tab.active {
    background: var(--brand-accent);
    color: #fff;
    border-color: var(--brand-accent);
}
.projection-compare-svg-wrap {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: #0b1a27;
}
#projectionCompareSvg {
    width: 100%;
    height: 100%;
    display: block;
}
#projectionCompareSvg path {
    cursor: grab;
}
#projectionCompareSvg path:active {
    cursor: grabbing;
}
@media (max-width: 768px) {
    .content-row {
        flex-direction: column;
    }
    .projection-compare-dock {
        flex: 0 0 45vh;
        max-width: none;
        min-width: 0;
        border-inline-start: none;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
}

/* ── Annotation mode ────────────────────────────────────────────── */
body.annotate-active .annotation-toolbar,
body.measure-active .measure-toolbar {
    display: flex;
}
.measure-toolbar {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--panel-overlay-96);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: var(--z-measure-toolbar);
    flex-wrap: wrap;
    max-width: 92vw;
}
body.annotate-active .annotation-toolbar {
    box-shadow: 0 0 0 2px var(--brand-accent);
}
.measure-seg {
    display: flex;
    align-items: center;
    gap: 4px;
}
.measure-mode-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.72em;
    padding: 4px 8px;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.measure-mode-btn:hover {
    background: var(--btn-hover);
    color: var(--text);
}
.measure-mode-btn.toggle-on {
    background: #0f766e;
    border-color: #0f766e;
    color: #fff;
}
.annotation-color-seg {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 2px;
}
.annotation-color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border);
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.annotation-color-swatch:hover {
    transform: scale(1.15);
}
.annotation-color-swatch.toggle-on {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.5);
    transform: scale(1.2);
}
.annot-font-btn {
    font-weight: 700;
}
.annot-font-value {
    min-width: 22px;
    text-align: center;
    font-size: 0.72em;
    color: var(--text-secondary);
}
.annotation-draw-vertex {
    fill: #eab308;
    stroke: #fff;
    stroke-width: 1.5;
    pointer-events: none;
}
.annotation-draw-poly {
    fill: rgba(234, 179, 8, 0.12);
    stroke: #eab308;
    stroke-width: 2;
    stroke-dasharray: 4 3;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}
.annotation-arrow-line,
.annotation-freehand-path {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}
.annotation-freehand-path {
    stroke: var(--brand-accent, #3b82f6);
    stroke-linejoin: round;
}
.annotation-arrow-line {
    stroke: #eab308;
}
.annotation-arrow-head {
    fill: #eab308;
    stroke: none;
    pointer-events: none;
}
.annotation-pin-circle {
    fill: #eab308;
    stroke: #fff;
    stroke-width: 1.5;
}
.annotation-pin-label {
    fill: var(--text, #e0e8f0);
    font-size: 11px;
    font-weight: 600;
    stroke: none !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 4px rgba(0, 0, 0, 0.85);
    pointer-events: none;
}
.annotation-region-poly {
    fill: rgba(234, 179, 8, 0.15);
    stroke: #eab308;
    stroke-width: 2;
    stroke-dasharray: 6 4;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}
.annotation-region-vertex {
    fill: #eab308;
    stroke: #fff;
    stroke-width: 1;
}
.annotation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85em;
}
.annotation-item-type {
    font-size: 0.75em;
    font-weight: 700;
    color: var(--brand-accent);
    flex-shrink: 0;
    width: 42px;
}
.annotation-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text, #e0e8f0);
}
.annotation-item-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}
.annotation-del-btn,
.annotation-vis-btn {
    background: 0 0;
    border-radius: var(--radius-sm);
    font-size: 0.7em;
    padding: 3px 6px;
    cursor: pointer;
}
.annotation-vis-btn {
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.annotation-del-btn {
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #ef4444;
}
.annotation-hidden-label {
    font-size: 0.65em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.annotation-item-dist {
    color: var(--text-secondary);
    font-size: 0.85em;
    font-weight: 400;
}
.annotation-restore-btn {
    margin-top: 10px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}
.annotation-restore-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.annotation-help-card {
    padding: 18px 20px;
    max-height: 85vh;
}
.annotation-help-body {
    font-size: 0.88em;
}
.annotation-edit-btn {
    background: 0 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.7em;
    padding: 3px 6px;
    cursor: pointer;
}
.annotation-edit-btn:hover {
    background: var(--btn-hover);
    color: var(--text);
}

/* ── Controls bar: Base Map card + utility dock ─────────────────────── */
/* The stepped-dock-group is the single card containing two adjacent
   sub-blocks side by side: the wide Base-Map zone (#modeRow) and the
   narrow utilities zone (#filterRow), separated by a vertical divider.
   At >=1024px the card restyles into the two connected stepped docks. */
.stepped-dock-group {
    display: flex;
    align-items: center;
    background: var(--panel-overlay-96);
    border: 1.5px solid var(--brand-accent);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    box-shadow: var(--shadow-sm);
}
.row-unified {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}
#filterRow {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    border-inline-start: 2px solid var(--brand-accent);
    padding-inline-start: 12px;
    margin-inline-start: 4px;
}
/* In the light theme the teal accent sits on white at ~2.5:1 — too faint
   to read as an outline. Use the established darker teal (#0d9488, already
   used elsewhere in the UI) so the card edge and zone divider stay clearly
   visible in both themes. */
:root:not([data-theme]) .stepped-dock-group,
[data-theme="light"] .stepped-dock-group {
    border-color: #0d9488;
}
:root:not([data-theme]) #filterRow,
[data-theme="light"] #filterRow {
    border-inline-start-color: #0d9488;
}
#filterRow .btn {
    font-size: 0.62em;
    padding: 4px 8px;
    min-height: 26px;
}
/* Spec defense: the >=1024px media query compacts every .controls-bar .btn
   to 4px 10px / 28px and every .controls-bar .row to gap 6px 12px. The
   wide zone must keep the standard button sizing and the panel its uniform
   10px internal gap, so the narrow zone stays visibly smaller. */
.controls-bar-toprow .row-unified {
    gap: 10px ;
}
#modeButtons .btn {
    padding: 6px 10px ;
    min-height: 32px ;
}
@media (min-width: 1024px) {
    #filterRow .btn {
        font-size: 0.62em ;
        padding: 4px 8px ;
        min-height: 26px ;
    }
}

/* ── Cartographic unification: kill the "cropped image card" seam ──
   The ocean rect spans the full canvas filled with a radial gradient;
   its 100% stop (#091520) extends to every canvas edge. Unifying the
   viewport + map-container backgrounds to that exact stop makes the
   projection blend seamlessly into the page in BOTH themes (the ocean
   stays dark navy even in light mode, so the old light --map-bg
   gradient was the source of the rectangular contrast). */
html,
body,
.content-row,
#mapContainer {
    background-color: var(--ocean-color) ;
}

/* Map canvas bounds: no outline/border chrome on the container. */
.content-row,
.map-container {
    touch-action: none;
    outline: none ;
    border: none ;
}

/* Projection depth: this app renders the ocean as a full-bleed D3 SVG
   rect (no Leaflet panes, no silhouetted layer wrapper), so a
   drop-shadow has no visible boundary to cast from. A soft inner
   vignette on the container provides the cartographic depth instead;
   it sits under every UI island (dock z-index 2000+) and ignores
   pointer events, so map interaction is unaffected. */
.map-container::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.28) 100%);
    z-index: var(--z-map-surface);
}
[data-theme="light"] .map-container::after {
    background: radial-gradient(ellipse at center, transparent 65%, rgba(30, 58, 82, 0.07) 100%) !important;
}

/* Blend scrollbar gutters with the unified canvas tone. */
::-webkit-scrollbar {
    background: #121824;
}
[data-theme="light"] ::-webkit-scrollbar {
    background: #f1f5f9;
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── Arctic ice cap ──
   The polar region above the Arctic Circle (66.56°N) drawn as a solid
   ice-white region under the country layer, so it reads as a real map
   feature (like Antarctica) while coastlines stay crisp on top of it.
   Clickable: opens the Arctic feature panel. */
.arctic-ice,
.antarctica-path,
.history-antarctica-path {
    fill: #dceef8 !important;
    stroke: rgba(255, 255, 255, 0.65) !important;
    stroke-width: 0.7;
    pointer-events: none;
    transition: fill var(--dur-fast) var(--ease);
}
.arctic-ice:hover,
.antarctica-path:hover {
    fill: #eef7fc;
}
[data-theme="light"] .arctic-ice,
[data-theme="light"] .antarctica-path,
[data-theme="light"] .history-antarctica-path {
    fill: #e8f4fc !important;
    stroke: rgba(110, 155, 190, 0.6) !important;
}
[data-theme="light"] .arctic-ice:hover,
[data-theme="light"] .antarctica-path:hover {
    fill: #f4faff !important;
}

/* ── History Mode (WWI & WWII alignment scenarios) ── */
.history-bar {
    position: fixed;
    bottom: 168px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    max-width: min(760px, 94vw);
    background: var(--panel-overlay-92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    z-index: var(--z-controls-bar);
    display: none;
    flex-direction: column;
    gap: 8px;
    color: var(--text, #e0e8f0);
    box-shadow: var(--shadow-lg);
    max-height: 46vh;
    overflow-y: auto;
}
.history-bar.visible { display: flex; }
.history-bar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.history-bar-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--brand-accent, #14B8A6);
}
.history-bar-actions { display: flex; align-items: center; gap: 6px; }
.history-war-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.history-war-tab {
    border-radius: var(--dock-radius, clamp(8px, 0.65vw, 14px));
    padding: 5px 14px;
    font-size: 0.85rem;
}
.history-war-tab.active {
    background: var(--brand-accent, #14B8A6);
    color: #08202c;
    font-weight: 700;
}
.history-scenario-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.history-scenarios { display: flex; gap: 6px; flex-wrap: wrap; }
.history-scenario-btn {
    border-radius: var(--radius-md, 12px);
    padding: 4px 12px;
    font-size: 0.82rem;
}
.history-scenario-btn.active {
    outline: 2px solid var(--brand-accent, #14B8A6);
    font-weight: 700;
}
.history-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
}
.hist-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--dock-radius, clamp(8px, 0.65vw, 14px));
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    white-space: nowrap;
}
.hist-chip-swatch {
    width: 13px;
    height: 13px;
    border-radius: 4px;
    display: inline-block;
    flex: 0 0 auto;
}
.history-hint {
    margin: 0;
    font-size: 0.78rem;
    opacity: 0.75;
}
.history-sources-panel h4 { margin: 4px 0; font-size: 0.88rem; color: var(--brand-accent, #14B8A6); }
.history-sources-panel ul { margin: 4px 0; padding-inline-start: 20px; }
.history-sources-panel li { font-size: 0.78rem; line-height: 1.5; }

.hist-panel-context { margin: 2px 0 8px; opacity: 0.9; }
.hist-status-block {
    border-inline-start: 4px solid #888;
    padding: 6px 10px;
    margin: 8px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}
.hist-status-role { display: flex; align-items: center; gap: 8px; }
.hist-status-side { font-size: 0.82rem; opacity: 0.8; margin-top: 3px; }
.hist-note { line-height: 1.65; font-size: 0.92rem; margin: 8px 0; }
.hist-empire-box {
    background: rgba(255, 255, 255, 0.06);
    border: 1px dashed rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 8px 0;
    font-size: 0.9rem;
}
.hist-empire-members, .hist-empire-partial { font-size: 0.84rem; margin-top: 4px; opacity: 0.9; }
.hist-sources-mini summary { cursor: pointer; font-size: 0.84rem; color: var(--brand-accent, #14B8A6); }
.hist-sources-mini ul { padding-inline-start: 20px; }
.hist-sources-mini li { font-size: 0.76rem; line-height: 1.5; }
.hist-disclaimer-mini { font-size: 0.74rem; opacity: 0.65; line-height: 1.55; margin-top: 10px; }

html[dir="rtl"] .history-bar { text-align: right; }
html[dir="rtl"] .hist-status-block { text-align: right; }

@media (max-width: 768px) {
    .history-bar {
        bottom: 150px;
        width: 94vw;
        max-height: 42vh;
        padding: 10px 12px;
    }
}

/* ── Era Scenes timeline strip ── */
.history-timeline {
    position: relative;
    height: 26px;
    margin: 2px 6px 0;
}
.history-timeline::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
}
.history-tl-dot {
    position: absolute;
    top: 50%;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: var(--brand-accent, #14B8A6);
    border: 2px solid rgba(0, 0, 0, 0.55);
    cursor: pointer;
    padding: 0;
    z-index: 1;
}
.history-tl-dot:hover { transform: translate(-50%, -50%) scale(1.25); }
.history-tl-dot.active {
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.45);
}
.history-loading { font-size: 0.82rem; opacity: 0.8; }
.history-empty {
    font-size: 0.82rem;
    line-height: 1.4;
    opacity: 0.9;
    padding: 2px 4px;
    max-width: 46ch;
    display: block;
}
.history-empty-state-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border: 1px dashed var(--border, rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-md, 12px);
    background: rgba(255, 255, 255, 0.035);
    text-align: center;
    max-width: 100%;
}
.history-empty-msg {
    font-size: 0.85rem;
    line-height: 1.5;
    opacity: 0.9;
    margin: 0;
}
.btn-reset-hist-filters {
    flex: 0 0 auto;
}
.history-timeline-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin-top: 4px;
}
.history-timeline-row .history-timeline { flex: 1 1 auto; min-width: 160px; }
.history-timeline-row .history-play-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.18));
    background: var(--btn-bg, rgba(255, 255, 255, 0.06));
    color: var(--text, #f1f5f9);
    cursor: pointer;
    flex: 0 0 auto;
    transition: background var(--dur-fast, 0.15s) var(--ease, ease);
}
.history-timeline-row .history-play-btn:hover { background: var(--btn-hover, rgba(255, 255, 255, 0.14)); }
.history-timeline-row .history-play-btn[aria-pressed="true"] {
    background: var(--brand-accent, #14B8A6);
    color: #fff;
    border-color: var(--brand-accent, #14B8A6);
}
.history-timeline-row .history-play-btn .lucide-icon { width: 15px; height: 15px; }
.history-timeline-row:has(.history-timeline[style*="display: none"]) .history-play-btn { display: none; }

/* ── Faiths (religions through time) ── */
.history-faiths-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 0 2px;
}
.history-faiths-group .history-timeline-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.history-faiths-group .history-play-btn {
    flex-shrink: 0;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.14);
    color: var(--text, #e0e8f0);
    cursor: pointer;
    padding: 0;
}
.history-faiths-group .history-play-btn[aria-pressed="true"] {
    background: var(--brand-accent, #14B8A6);
    color: #fff;
    border-color: var(--brand-accent, #14B8A6);
}
.history-faiths-group .history-play-btn .lucide-icon { width: 14px; height: 14px; }
.history-year-label {
    color: var(--brand-accent, #14B8A6);
    font-size: 0.95rem;
    font-weight: 700;
}
.religions-timeline {
    position: relative;
    height: 22px;
    margin: 2px 0 0;
    flex: 1 1 auto;
    min-width: 160px;
}
.religions-timeline::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: 50%; height: 4px;
    border-radius: 4px;
    background: rgba(255,255,255,0.13);
    transform: translateY(-50%);
}
.religions-timeline::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: var(--religions-pct, 50%);
    height: 4px;
    border-radius: 4px;
    background: var(--brand-accent, #14B8A6);
    transform: translateY(-50%);
    pointer-events: none;
    transition: width 0.08s linear;
}
.religions-timeline-dot {
    position: absolute;
    top: 50%; left: var(--religions-pct, 50%);
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--brand-accent, #14B8A6);
    box-shadow: 0 0 0 3px rgba(20,184,166,0.3);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2;
}
.religions-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 2px;
}
.religions-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.religions-legend-swatch {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.3);
}
.religions-legend-name { opacity: 0.9; }
.religions-legend-empty {
    opacity: 0.7;
    font-style: italic;
}
.religions-caption {
    margin-top: 2px;
    opacity: 0.85;
    font-size: 0.78rem;
    min-height: 1em;
}

/* ── Phase 2: Dedicated Floating Bottom Timeline ── */
.history-bottom-bar {
    position: fixed;
    bottom: 38px;
    left: 50%;
    transform: translateX(-50%);
    width: min(720px, 92vw);
    background: var(--panel-overlay-96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 12px);
    padding: 8px 16px;
    z-index: var(--z-controls-bar);
    box-shadow: var(--shadow-lg, 0 8px 32px rgba(0, 0, 0, 0.45));
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: opacity var(--dur-base, 0.2s) ease, transform var(--dur-base, 0.2s) ease;
    contain: layout style;
}

.history-bottom-inner {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 12px;
}

.history-era-timeline-wrap,
.history-faiths-timeline-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.history-faiths-timeline-wrap {
    flex-wrap: wrap;
    justify-content: flex-start;
}

.history-year-badge {
    font-size: 0.9em;
    font-weight: 700;
    color: var(--brand-accent, #14B8A6);
    background: rgba(255, 255, 255, 0.08);
    padding: 3px 10px;
    border-radius: var(--radius-md, 12px);
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.12);
    min-width: 72px;
    text-align: center;
}

.history-timeline-caption {
    font-size: 0.78em;
    color: var(--text-secondary, #a0a0a0);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bottom-bar play buttons adopt the slim circular style */
.history-bottom-bar .history-play-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.18));
    background: var(--btn-bg, rgba(255, 255, 255, 0.06));
    color: var(--text, #f1f5f9);
    cursor: pointer;
    flex: 0 0 auto;
    transition: background var(--dur-fast, 0.15s) var(--ease, ease);
}
.history-bottom-bar .history-play-btn[aria-pressed="true"] {
    background: var(--brand-accent, #14B8A6);
    color: #fff;
    border-color: var(--brand-accent, #14B8A6);
}
.history-bottom-bar .history-play-btn .lucide-icon { width: 15px; height: 15px; }

/* The religions caption in the bottom bar wraps onto its own row */
.history-bottom-bar .religions-caption {
    width: 100%;
    text-align: center;
}

/* Light Theme Adaptations for Dedicated Bottom Timeline */
[data-theme="light"] .history-bottom-bar {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(15, 23, 42, 0.09) !important;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.1) !important;
    color: #0f172a !important;
}
[data-theme="light"] .history-year-badge {
    background: rgba(13, 148, 136, 0.08) !important;
    color: #0d9488 !important;
    border: 1px solid rgba(13, 148, 136, 0.22) !important;
}
[data-theme="light"] .history-timeline-caption {
    color: #475569 !important;
}
[data-theme="light"] .history-bottom-bar .history-play-btn {
    background: rgba(15, 23, 42, 0.04) !important;
    border: 1px solid rgba(15, 23, 42, 0.1) !important;
    color: #1e293b !important;
}
[data-theme="light"] .history-bottom-bar .history-play-btn:hover {
    background: rgba(15, 23, 42, 0.08) !important;
}
[data-theme="light"] .history-bottom-bar .history-play-btn[aria-pressed="true"] {
    background: #0d9488 !important;
    border-color: #0d9488 !important;
    color: #ffffff !important;
}
[data-theme="light"] .religions-timeline::before {
    background: rgba(15, 23, 42, 0.1) !important;
}
[data-theme="light"] .religions-legend-swatch {
    border-color: rgba(15, 23, 42, 0.15) !important;
}
[data-theme="light"] .religions-legend-name {
    color: #334155 !important;
}
[data-theme="light"] .religions-caption {
    color: #475569 !important;
}

/* Keep the top dock slim and single-tiered */
#historyModeDock {
    max-height: none;
    overflow: visible;
}

#historyModeDock .history-filter-row {
    flex-wrap: nowrap;
}

@media (max-width: 768px) {
    .history-bottom-bar {
        bottom: calc(var(--mobile-nav-height, 56px) + 12px);
        width: 95vw;
        padding: 6px 10px;
    }
    .history-year-badge {
        font-size: 0.78em;
        padding: 2px 6px;
        min-width: 58px;
    }
}


.religions-overlay-layer { pointer-events: none; }
.history-empty-state {
    margin-top: 12px;
    padding: 26px 20px;
    border: 1px solid var(--border-color, #4a5568);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--text-color, #d1d5db);
    font-size: 1rem;
    text-align: center;
}
.history-empty-state .hist-empty-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}
.history-empty-state .hist-empty-cue {
    font-size: 0.95rem;
    opacity: 0.85;
    line-height: 1.5;
    margin-top: 4px;
}
@keyframes hist-list-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.55); }
    70%  { box-shadow: 0 0 0 10px rgba(20, 184, 166, 0); }
    100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0); }
}
.history-era-group.hist-pulse,
.history-war-tabs.hist-pulse {
    animation: hist-list-pulse 1.8s ease-out 2;
    border-radius: 10px;
}

/* ── Phase 8: era education tools ── */
.history-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 4px;
}
.history-action-btn {
    font-size: 0.8rem;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.18));
    background: rgba(255, 255, 255, 0.06);
    color: var(--text, #e0e8f0);
    cursor: pointer;
}
.history-action-btn:hover { background: rgba(255, 255, 255, 0.14); }
.hist-quiz-q {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    margin: 4px 0 12px;
}
.hist-quiz-a {
    margin-top: 12px;
    padding: 10px 12px;
    border-left: 3px solid var(--brand-accent, #14B8A6);
    background: rgba(20, 184, 166, 0.08);
    border-radius: 8px;
    line-height: 1.5;
}
.hist-compare-pick {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.hist-compare-pick label { min-width: 52px; opacity: 0.85; font-size: 0.85rem; }
.hist-compare-pick select { flex: 1; }
.hist-compare-table {
    display: grid;
    grid-template-columns: 110px 1fr 1fr;
    gap: 6px;
    margin-top: 12px;
    align-items: start;
}
.hist-cmp-head {
    font-weight: 700;
    color: var(--brand-accent, #14B8A6);
    padding: 4px 6px;
    font-size: 0.8rem;
}
.hist-cmp-label {
    font-size: 0.8rem;
    opacity: 0.85;
    padding: 6px 4px;
    font-weight: 600;
}
.hist-cmp-cell {
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
    font-size: 0.82rem;
    line-height: 1.45;
    min-height: 120px;
}
.hist-cmp-cell strong { display: block; margin-bottom: 4px; }
.hist-cmp-polities { margin-top: 6px; opacity: 0.9; }

/* Academic source links */
.hist-compare-overlay-row {
    margin-top: 14px;
    display: flex;
    gap: 8px;
}
.hist-source-link {
    color: var(--brand-accent, #14B8A6);
    text-decoration: underline;
    text-underline-offset: 2px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.hist-source-link:hover {
    color: #fff;
}

/* Floating Comparison Banner */
.hist-compare-floating-banner {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-overlay-96);
    border: 1px solid var(--brand-accent, #14B8A6);
    border-radius: var(--radius-pill, 999px);
    padding: 6px 18px;
    z-index: var(--z-modal-alert, 3100);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    font-size: 0.85em;
    font-weight: 600;
}
.hist-compare-close-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid #ef4444;
    color: #ef4444;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}
.study-sheet-print {
    display: none;
}

@media print {
    body > *:not(.study-sheet-print) { display: none !important; }
    .study-sheet-print {
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 24px;
        color: #111;
        font-size: 13px;
    }
    .study-sheet-print h1 { font-size: 13px; text-transform: uppercase; color: #555; }
    .study-sheet-print h2 { font-size: 20px; margin: 2px 0 2px; }
    .study-sheet-print h3 { font-size: 14px; margin: 14px 0 4px; border-bottom: 1px solid #bbb; padding-bottom: 2px; }
    .study-sheet-print .ss-meta { color: #666; margin: 0 0 8px; }
    .study-sheet-print .ss-desc { line-height: 1.5; }
    .study-sheet-print ul, .study-sheet-print ol { margin: 4px 0 6px 20px; }
    .study-sheet-print .ss-disclaimer { font-size: 10px; color: #777; margin-top: 18px; border-top: 1px solid #ccc; padding-top: 6px; }
}

/* ── Section system: header toggle + first-run picker ── */
.section-toggle {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 2px;
}
.section-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    background: transparent;
    color: rgba(243, 244, 246, 0.9) !important;
    border-radius: 999px;
    padding: 8px 16px;
    min-height: 44px;
    height: 44px;
    font-size: 0.85rem;
    cursor: pointer;
    opacity: 0.9;
    position: relative;
}
.section-toggle-btn::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    width: 100%;
    height: 100%;
}
.section-toggle-btn:hover {
    color: #ffffff !important;
    opacity: 1;
}
.section-toggle-btn.active {
    background: var(--brand-accent, #2dd4bf) !important;
    color: #04201e !important;
    font-weight: 700 !important;
    opacity: 1;
}
.section-toggle-btn.active .btn-text,
.section-toggle-btn.active .lucide-icon {
    color: #04201e !important;
    stroke: #04201e !important;
}

.section-picker-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal-alert, 5000);
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(8, 12, 18, 0.88);
    backdrop-filter: blur(6px);
}
.section-picker-content {
    background: var(--panel-bg, #21252b);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 28px 30px;
    max-width: 560px;
    width: 92vw;
    text-align: center;
    color: var(--text, #e0e8f0);
    box-shadow: var(--shadow-lg);
}
.section-picker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}
.section-picker-title { margin: 0 0 6px; font-size: 1.3rem; color: var(--brand-accent, #14B8A6); }
.section-picker-subtitle { margin: 0 0 18px; opacity: 0.8; font-size: 0.9rem; }
.section-picker-cards {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}
.section-card {
    flex: 1 1 200px;
    max-width: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 20px 16px;
    cursor: pointer;
    color: var(--text, #e0e8f0);
    transition: transform var(--dur-fast, 0.15s) ease, border-color var(--dur-fast, 0.15s) ease;
}
.section-card:hover {
    transform: translateY(-3px);
    border-color: var(--brand-accent, #14B8A6);
}
.section-card .lucide-icon { width: 34px; height: 34px; color: var(--brand-accent, #14B8A6); }
.section-card strong { font-size: 1.05rem; }
.section-card span { font-size: 0.8rem; opacity: 0.75; line-height: 1.5; }
.section-remember {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 0.82rem;
    cursor: pointer;
    opacity: 0.9;
}
.section-picker-hint { margin: 12px 0 0; font-size: 0.78rem; opacity: 0.65; }
html[dir="rtl"] .section-picker-content { text-align: center; }
@media (max-width: 640px) {
    .section-toggle-btn .btn-text { display: none; }
    .section-toggle-btn { padding: 4px 8px; }
}

/* ── Section swap: history dock replaces geography controls ── */

.history-sources-toggle { border-radius: 999px; padding: 4px 12px; font-size: 0.8rem; }
.history-sources-panel {
    position: fixed;
    top: 60px;
    inset-inline-start: 20px;
    background: var(--panel-overlay-97, rgba(20,24,32,0.97));
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 12px;
    padding: 14px 18px;
    max-width: 440px;
    max-height: 70vh;
    overflow-y: auto;
    z-index: var(--z-tools-dropdown, 3000);
    box-shadow: var(--shadow-lg);
    color: var(--text, #e0e8f0);
}
.history-sources-panel h4 { margin: 2px 0 6px; font-size: 0.85rem; color: var(--brand-accent, #14B8A6); }
body.section-history .history-dock .history-scenario-row { flex-wrap: nowrap; }
body.section-history .history-dock .history-war-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
.history-region-select {
    background: var(--panel-bg, #21252b);
    color: var(--text, #e0e8f0);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.78rem;
    cursor: pointer;
}

/* In-place section swap: history dock occupies the geography button slots */
#historyModeDock {
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    height: 100%;
}
#historyModeDock .history-war-tabs { justify-content: flex-start; }
#historyModeDock .history-war-tabs { flex-wrap: wrap; }

body.section-history #modeRow {
    align-items: center;
}

/* Wars / Eras / Faiths primary buttons — visually distinct and prominent in the wide dock zone */
.history-mode-row {
    display: flex;
    align-items: center;
    gap: clamp(8px, 0.8vw, 14px);
    width: 100%;
    height: 100%;
}
.history-mode-spacer { flex: 1 1 auto; }
.history-mode-seg {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: var(--dock-radius, clamp(8px, 0.65vw, 14px));
    padding: 3px;
}
.history-mode-seg-btn {
    background: transparent;
    border: none;
    border-radius: var(--dock-radius, clamp(8px, 0.65vw, 14px));
    color: var(--text-secondary, #9aa5b1);
    font-size: 0.82em;
    font-weight: 700;
    min-height: 32px;
    padding: 6px 18px;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.history-mode-seg-btn:hover {
    color: var(--text, #e0e8f0);
    background: var(--btn-hover, rgba(255,255,255,0.08));
}
.history-mode-seg-btn.active {
    background: #0f766e;
    color: #fff;
    border-radius: var(--dock-radius, clamp(8px, 0.65vw, 14px));
}

/*
 * History sub-mode popovers (Wars / Eras / Faiths).
 * Floating dropdown menus anchored beneath their header trigger buttons,
 * mirroring the tools/layers menu-popover pattern. Positioned by JS via
 * positionPopover (viewport-coordinate px), so fixed positioning is used.
 */
.hist-popover-menu {
    position: fixed;
    z-index: var(--z-tools-dropdown, 3000);
    width: clamp(380px, 30vw, 480px);
    max-width: min(520px, calc(100vw - 20px));
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(17, 24, 39, 0.98) 100%);
    color: #f1f5f9;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 16px;
    padding: 12px 12px 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
#histFaithsPopoverMenu {
    width: clamp(380px, 30vw, 480px);
    max-width: min(520px, calc(100vw - 20px));
}
.hist-popover-menu[hidden] {
    display: none !important;
}
.hist-popover-menu.visible {
    display: flex !important;
    flex-direction: column;
    opacity: 1;
    visibility: visible;
    animation: hist-drawer-slide 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes hist-drawer-slide {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
.hist-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}
.hist-drawer-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 700;
    color: #2dd4bf;
}
.hist-drawer-title .lucide-icon {
    width: 17px;
    height: 17px;
    color: #2dd4bf;
}
.hist-drawer-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #94a3b8;
    border-radius: 8px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    transition: all 0.15s ease;
}
.hist-drawer-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}
.hist-popover-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
}
@media (max-width: 680px) {
    .hist-popover-menu {
        width: 100% !important;
        max-width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        top: 10px !important;
        bottom: 0 !important;
        height: calc(100vh - 10px) !important;
        height: calc(100dvh - 10px) !important;
        max-height: calc(100vh - 10px) !important;
        max-height: calc(100dvh - 10px) !important;
        border-radius: 20px 20px 0 0 !important;
        border-bottom: none !important;
    }
}
.hist-popover-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: clamp(6px, 0.5vw, 10px) !important;
    min-height: clamp(34px, 2.35vw, 42px) !important;
    padding: clamp(6px, 0.45vw, 9px) clamp(16px, 1.2vw, 24px) !important;
    font-size: clamp(0.86rem, 0.75vw + 0.25rem, 1.02rem) !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    color: #e2e8f0 !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: var(--dock-radius, clamp(10px, 0.8vw, 16px)) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: all var(--dur-fast, 0.15s) var(--ease, ease);
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
}
.hist-popover-btn i.lucide-icon,
.hist-popover-btn svg {
    width: clamp(17px, 1.1vw, 20px) !important;
    height: clamp(17px, 1.1vw, 20px) !important;
    stroke-width: 2.2px;
}
.hist-popover-btn .dropdown-arrow {
    width: 14px !important;
    height: 14px !important;
    margin-inline-start: 4px !important;
    opacity: 0.75;
    transition: transform var(--dur-fast, 0.15s) var(--ease, ease);
}
.hist-popover-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.32) !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}
.hist-popover-btn.active,
.hist-popover-btn[aria-expanded="true"] {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%) !important;
    border-color: #2dd4bf !important;
    color: #ffffff !important;
    box-shadow: 0 0 16px rgba(45, 212, 191, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}
.hist-popover-btn[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}
/* History filter rows */
.history-filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
    margin-bottom: 8px;
    flex-shrink: 0;
}
.history-filter-row .history-search-input {
    grid-column: 1 / -1;
    width: 100%;
    box-sizing: border-box;
}
.history-filter-row .history-region-select {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}
.history-era-pop-filter-row {
    display: flex;
    gap: 6px;
    width: 100%;
    margin-bottom: 8px;
    flex-shrink: 0;
}
.history-era-pop-filter-row .history-search-input {
    flex: 1 1 58%;
    min-width: 0;
    box-sizing: border-box;
}
.history-era-pop-filter-row .history-region-select {
    flex: 1 1 42%;
    min-width: 0;
    box-sizing: border-box;
}
.history-search-input {
    background: rgba(15, 23, 42, 0.7);
    color: var(--text, #e0e8f0);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.78rem;
    height: 30px;
}
.history-search-input:focus {
    outline: none;
    border-color: var(--brand-accent, #14B8A6);
}
.history-region-select {
    background: rgba(15, 23, 42, 0.7);
    color: var(--text, #e0e8f0);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 4px 6px;
    font-size: 0.75rem;
    height: 30px;
    min-width: 0;
}
/* Faiths list items in the Faiths popover. */
.history-faiths-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: min(65vh, 580px);
    flex: 1 1 auto;
    min-height: 280px;
    overflow-y: auto;
    padding: 2px 4px 14px 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(20, 184, 166, 0.6) rgba(255, 255, 255, 0.08);
}
.history-faiths-list::-webkit-scrollbar {
    width: 6px;
}
.history-faiths-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
}
.history-faiths-list::-webkit-scrollbar-thumb {
    background: rgba(20, 184, 166, 0.6);
    border-radius: 6px;
}
.history-faiths-list::-webkit-scrollbar-thumb:hover {
    background: rgba(20, 184, 166, 0.9);
}
.faiths-popover-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: start;
    background: var(--panel-bg, #21252b);
    color: var(--text, #e0e8f0);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-md, 12px);
    padding: 8px 10px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.faiths-popover-item:hover {
    background: var(--btn-hover, rgba(255,255,255,0.08));
}
.faiths-popover-item.active,
.faiths-popover-item.selected {
    background: rgba(20, 184, 166, 0.22) !important;
    border-color: var(--brand-accent, #14B8A6) !important;
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.4);
}
.faiths-selected-check {
    font-weight: 800;
    font-size: 0.95em;
    color: var(--brand-accent, #14B8A6);
    margin: 0 4px;
}
.hist-scroll-cue {
    position: sticky;
    bottom: -10px;
    margin-top: -22px;
    height: 26px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.95) 75%);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    color: var(--brand-accent, #14B8A6);
    opacity: 0.9;
    transition: opacity 0.25s ease;
    animation: hist-scroll-bounce 1.8s infinite ease-in-out;
    z-index: 5;
}
.hist-scroll-cue.hidden {
    opacity: 0;
    visibility: hidden;
}
@keyframes hist-scroll-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}
.faiths-popover-name {
    flex: 1 1 auto;
    font-weight: 700;
}
.faiths-popover-range {
    font-size: 0.72em;
    color: var(--text-secondary, #9aa5b1);
    white-space: nowrap;
}
.faiths-item-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary, #9aa5b1);
    font-size: 0.72rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--dur-fast), color var(--dur-fast);
}
.faiths-item-info-btn:hover {
    background: var(--brand-accent, #14B8A6);
    color: #ffffff;
}
.history-faiths-filter-row {
    display: flex !important;
    gap: 6px;
    width: 100%;
    margin-bottom: 8px;
    flex-shrink: 0;
    align-items: center;
}
.history-faiths-filter-row .history-search-input {
    flex: 1 1 120px;
    min-width: 120px;
}
.history-faiths-filter-row .btn {
    flex: 0 0 auto;
    font-size: 0.78rem;
    padding: 6px 10px;
}



/* Related-wars section in the geography country panel */
.panel-related-wars {
    margin-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 8px;
}
.panel-related-wars h4 {
    margin: 0 0 6px;
    font-size: 0.85rem;
    color: var(--brand-accent, #14B8A6);
}
.panel-related-war-btn {
    display: block;
    width: 100%;
    text-align: start;
    margin-bottom: 5px;
}

/* Era entity optional detail fields (rendered only when data present) */
.hist-entity-details {
    margin: 8px 0;
    padding: 6px 10px;
    border-inline-start: 3px solid var(--brand-accent, #14B8A6);
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
}
.hist-entity-details .hist-detail-row {
    display: flex;
    gap: 8px;
    font-size: 0.86em;
    padding: 2px 0;
}
.hist-entity-details dt { color: var(--text-secondary, #9aa5b1); white-space: nowrap; }
.hist-entity-details dd { margin: 0; color: var(--text, #e0e8f0); }

/* Eras sub-mode content lives entirely inside #historyEraGroup */
#historyEraGroup {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    min-width: 0;
}
#historyEraGroup .history-scenarios {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    width: 100%;
}
#historyEraGroup .history-scenario-btn { white-space: nowrap; }
#historyEraGroup .history-timeline { pointer-events: auto; }

#historyEraGroup .history-timeline { flex: 1 1 auto; min-width: 160px; }
#historyEraGroup .history-scenario-btn {
    padding: 3px 10px;
    font-size: 0.78rem;
}
#historyEraGroup .history-timeline { height: 28px; }

/* ── إلغاء الأشكال البيضاوية وتوحيد الزوايا على 8px ── */
.section-toggle {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-sm, 8px) !important;
    padding: 2px;
}
.section-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    background: transparent;
    color: rgba(243, 244, 246, 0.85) !important;
    border-radius: calc(var(--radius-sm, 8px) - 2px) !important;
    padding: 5px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    opacity: 0.85;
}
.section-toggle-btn:hover {
    color: #ffffff !important;
    opacity: 1;
}
.section-toggle-btn.active {
    background: var(--brand-accent, #14B8A6) !important;
    color: #08202c !important;
    font-weight: 700 !important;
    opacity: 1;
    border-radius: calc(var(--radius-sm, 8px) - 2px) !important;
}

/* أزرار وحقول التاريخ */
.history-war-tab,
.history-scenario-btn,
.history-mode-seg-btn,
.history-mode-seg,
.hist-chip,
.faiths-popover-item,
.history-action-btn {
    border-radius: var(--radius-sm, 8px) !important;
}

.history-search-input,
.history-region-select {
    border-radius: var(--radius-sm, 8px) !important;
    height: 30px;
    padding: 4px 10px;
    background: var(--panel-bg, #21252b);
    color: var(--text, #e0e8f0);
    border: 1px solid rgba(255,255,255,0.16);
    font-size: 0.78rem;
}

.history-year-badge {
    border-radius: var(--radius-sm, 8px) !important;
}

.hist-compare-floating-banner {
    border-radius: var(--radius-md, 12px) !important;
}

/* ── شريط شفافية الحدود التاريخية (Opacity Control) ── */
.hist-opacity-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-sm, 8px);
    padding: 2px 10px;
    height: 32px;
    box-sizing: border-box;
}
.hist-opacity-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    color: var(--text-secondary, #9aa5b1);
    cursor: pointer;
    white-space: nowrap;
}
.hist-opacity-slider {
    width: 65px;
    height: 4px;
    accent-color: var(--brand-accent, #14B8A6);
    cursor: pointer;
}
.hist-opacity-val {
    font-size: 0.75rem;
    color: var(--brand-accent, #14B8A6);
    font-weight: 700;
    min-width: 32px;
    text-align: center;
}
.history-epoch-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
    margin-bottom: 8px;
    padding: 0;
    flex-shrink: 0;
    box-sizing: border-box;
}
.war-epoch-tab,
.era-epoch-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    font-size: 0.76rem !important;
    font-weight: 500;
    padding: 5px 4px !important;
    min-height: 32px;
    border-radius: var(--radius-sm, 8px) !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: var(--text-secondary, #9aa5b1) !important;
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    transition: all 0.15s ease;
}
.war-epoch-tab:hover,
.era-epoch-tab:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.12) !important;
}
.war-epoch-tab.active,
.era-epoch-tab.active {
    background: var(--brand-accent, #14B8A6) !important;
    color: #08202c !important;
    font-weight: 700 !important;
    border-color: var(--brand-accent, #14B8A6) !important;
}

/* ── البطاقة المثبتة في أعلى قائمة الحروب والحقب ── */
.hist-selected-card {
    position: relative;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(20, 184, 166, 0.25);
    border-radius: var(--radius-md, 12px);
    padding: 10px 12px;
    margin-bottom: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    color: #f1f5f9;
    flex-shrink: 0;
}
.hist-selected-card .history-empty-state {
    margin: 0;
    padding: 10px 8px;
    background: transparent;
    border: none;
    text-align: center;
    color: #f1f5f9;
}
.hist-selected-card .hist-empty-title {
    font-size: 0.96rem;
    font-weight: 700;
    color: #ffffff !important;
}
.hist-selected-card .hist-empty-cue {
    font-size: 0.82rem;
    color: #94a3b8 !important;
}
.hist-card-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.hist-card-title {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    color: #ffffff !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.hist-card-badges {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.hist-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    line-height: 1.3;
}
.hist-badge-epoch {
    background: rgba(20, 184, 166, 0.2);
    color: #2dd4bf !important;
    border: 1px solid rgba(20, 184, 166, 0.4);
}
.hist-badge-years {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1 !important;
    border: 1px solid rgba(255, 255, 255, 0.18);
}
.hist-card-desc {
    margin: 6px 0 8px;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #e2e8f0 !important;
    max-height: 4.6em;
    overflow-y: auto;
}
.hist-card-scenarios-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.hist-card-label {
    font-size: 0.74rem;
    font-weight: 600;
    color: #94a3b8 !important;
    white-space: nowrap;
}
.hist-card-polities {
    display: none !important;
}
.hist-card-polity-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.74rem;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text, #e0e8f0);
}
.hist-card-polity-swatch {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── محدد المراحل الثلاث للحرب أو الحقبة (بدايتها، أكبر اتساع لها، نهايتها) ── */
.hist-phase-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 8px 0 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md, 10px);
}
.hist-phase-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.35);
    padding: 3px 4px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.hist-phase-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px !important;
    font-size: 0.76rem !important;
    font-weight: 600;
    border-radius: 999px;
    background: transparent;
    color: #cbd5e1 !important;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}
.hist-phase-btn:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}
.hist-phase-btn.active {
    background: rgba(20, 184, 166, 0.22) !important;
    color: #2dd4bf !important;
    border-color: rgba(45, 212, 191, 0.5) !important;
    font-weight: 700;
    box-shadow: 0 0 10px rgba(45, 212, 191, 0.25);
}
.hist-phase-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}
.hist-phase-dot.dot-start { background: #10b981; box-shadow: 0 0 6px #10b981; }
.hist-phase-dot.dot-peak { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
.hist-phase-dot.dot-end { background: #ef4444; box-shadow: 0 0 6px #ef4444; }

.country-panel:has(.hist-profile-card) {
    max-width: 580px !important;
    min-width: 320px !important;
    top: 36px !important;
    max-height: calc(100vh - 190px) !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
    padding-bottom: 16px !important;
}
@media (max-width: 768px) {
    .country-panel:has(.hist-profile-card) {
        width: 100% !important;
        max-width: 540px !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 auto !important;
        max-height: 82vh !important;
        border-radius: 24px 24px 0 0 !important;
    }
}
.hist-sacred-faiths-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 8px;
}
.hist-sacred-timeline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 6px;
}
#histModernLabelsToggle {
    border-inline-start: 3px solid #f59e0b !important;
    font-size: 0.85em;
    opacity: 0.92;
}
.hist-profile-card {
    text-align: start;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 0 8px;
    font-size: 0.84rem;
    color: var(--text, #0f172a);
}
.hist-profile-header {
    border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.1));
    padding-bottom: 8px;
    margin-bottom: 2px;
}
.hist-profile-title {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text, #0f172a);
    display: flex;
    align-items: center;
    gap: 8px;
}
.hist-profile-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    margin: 0;
}
.hist-profile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.hist-profile-item {
    background: var(--bg-hover, rgba(0, 0, 0, 0.04));
    border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
    border-radius: 8px;
    padding: 6px 8px;
}
.hist-profile-item.full-width {
    grid-column: span 2;
}
.hist-profile-item-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--teal-600, #0d9488);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 3px;
}
.hist-profile-item-val {
    font-size: 0.78rem;
    color: var(--text, #1e293b);
    line-height: 1.4;
}
.hist-narrative-box {
    border-radius: 10px;
    padding: 8px 10px;
    border-inline-start: 4px solid #14b8a6;
    background: rgba(20, 184, 166, 0.08);
    border: 1px solid rgba(20, 184, 166, 0.22);
    margin-top: 2px;
}
.hist-narrative-box.origin-box {
    border-inline-start-color: #10b981;
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.22);
}
.hist-narrative-box.fall-box {
    border-inline-start-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.22);
}
.hist-narrative-title {
    font-size: 0.76rem;
    font-weight: 700;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.hist-narrative-box.origin-box .hist-narrative-title { color: #059669; }
.hist-narrative-box.fall-box .hist-narrative-title { color: #dc2626; }
.hist-narrative-text {
    font-size: 0.78rem;
    color: var(--text, #1e293b);
    line-height: 1.45;
    margin: 0;
}

/* Dark mode theme overrides for historical profile card */
[data-theme="dark"] .hist-profile-card,
body.dark .hist-profile-card {
    color: #f1f5f9;
}
[data-theme="dark"] .hist-profile-title,
body.dark .hist-profile-title {
    color: #ffffff;
}
[data-theme="dark"] .hist-profile-subtitle,
body.dark .hist-profile-subtitle {
    color: #94a3b8;
}
[data-theme="dark"] .hist-profile-item,
body.dark .hist-profile-item {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .hist-profile-item-val,
body.dark .hist-profile-item-val {
    color: #e2e8f0;
}
[data-theme="dark"] .hist-narrative-text,
body.dark .hist-narrative-text {
    color: #e2e8f0;
}
[data-theme="dark"] .hist-narrative-box.origin-box .hist-narrative-title,
body.dark .hist-narrative-box.origin-box .hist-narrative-title {
    color: #34d399;
}
[data-theme="dark"] .hist-narrative-box.fall-box .hist-narrative-title,
body.dark .hist-narrative-box.fall-box .hist-narrative-title {
    color: #f87171;
}

/* ── قائمة العصور الرأسية المدمجة في اللوحة الجانبية ── */
.hist-epoch-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: 100% !important;
    overflow-x: hidden !important;
    padding: 2px 0 8px !important;
    box-sizing: border-box !important;
}
.hist-epoch-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    padding: 6px 8px;
    width: 100%;
    box-sizing: border-box;
    max-height: none;
    overflow: visible;
}
.hist-epoch-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 3px 4px 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 2px;
    position: static;
    background: transparent;
}
.hist-epoch-col-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #2dd4bf;
}
.hist-epoch-col-count {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    font-weight: 600;
}
.hist-epoch-col-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.hist-epoch-col-items .history-war-tab,
.hist-epoch-col-items .history-scenario-btn {
    width: 100%;
    min-width: 0;
    text-align: start;
    justify-content: space-between;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.35;
    padding: 7px 10px !important;
    font-size: 0.78rem !important;
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.035) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #cbd5e1 !important;
    cursor: pointer;
    transition: all 0.15s ease;
}
.hist-epoch-col-items .history-war-tab:hover,
.hist-epoch-col-items .history-scenario-btn:hover {
    background: rgba(20, 184, 166, 0.14) !important;
    border-color: rgba(20, 184, 166, 0.35) !important;
    color: #ffffff !important;
    transform: translateX(-2px);
}
.hist-epoch-col-items .history-war-tab.active,
.hist-epoch-col-items .history-scenario-btn.active {
    background: #0f766e !important;
    border-color: #2dd4bf !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 0 10px rgba(45, 212, 191, 0.25);
}
.hist-tab-title {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
    overflow-wrap: break-word;
    word-break: break-word;
}
.hist-tab-years {
    font-size: 0.68rem;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 5px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.hist-epoch-col-items .history-scenario-btn.active .hist-tab-years,
.hist-epoch-col-items .history-war-tab.active .hist-tab-years {
    color: #ccfbf1;
    background: rgba(0, 0, 0, 0.25);
}
.hist-col-empty-msg {
    font-size: 0.75rem;
    color: var(--text-secondary, #9aa5b1);
    text-align: center;
    padding: 12px 4px;
    opacity: 0.7;
}

/* ── الشريط الزمني التفاعلي للحقب في المستطيل السفلي ── */
.history-era-timeline-wrap .history-timeline {
    position: relative;
    height: 22px;
    margin: 2px 0 0;
    flex: 1 1 auto;
    min-width: 160px;
    cursor: pointer;
    touch-action: none;
    display: block !important;
}
.history-era-timeline-wrap .history-timeline::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.13);
    transform: translateY(-50%);
}
.history-era-timeline-wrap .history-timeline::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: var(--era-pct, 0%);
    height: 4px;
    border-radius: 4px;
    background: var(--brand-accent, #14B8A6);
    transform: translateY(-50%);
    pointer-events: none;
    transition: width 0.08s linear;
}
.history-era-timeline-thumb {
    position: absolute;
    top: 50%;
    left: var(--era-pct, 0%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--brand-accent, #14B8A6);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.35);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2;
    transition: left 0.08s linear;
}
.history-era-timeline-wrap .history-tl-dot {
    width: 7px;
    height: 7px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(0, 0, 0, 0.4);
    z-index: 1;
}
.history-era-timeline-wrap .history-tl-dot.active {
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.5);
}

/* ── الشريط الزمني لتضاريس التاريخ ── */
.history-terrain-timeline-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}
.hist-terrain-timeline-track {
    position: relative;
    height: 24px;
    margin: 2px 0 0;
    flex: 1 1 auto;
    min-width: 160px;
    cursor: pointer;
    touch-action: none;
    display: block !important;
}
.hist-terrain-timeline-track::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(-50%);
}
.hist-terrain-timeline-track::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: var(--terrain-pct, 0%);
    height: 4px;
    border-radius: 4px;
    background: linear-gradient(90deg, #0284c7, #38bdf8);
    transform: translateY(-50%);
    pointer-events: none;
    transition: width 0.08s linear;
}
.hist-terrain-timeline-thumb {
    position: absolute;
    top: 50%;
    left: var(--terrain-pct, 0%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.4);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2;
    transition: left 0.08s linear;
}
.hist-terrain-tl-dot {
    position: absolute;
    top: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(0, 0, 0, 0.4);
    transform: translate(-50%, -50%);
    z-index: 1;
    transition: transform 0.15s ease, background 0.15s ease;
}
.hist-terrain-tl-dot:hover {
    transform: translate(-50%, -50%) scale(1.4);
    background: #38bdf8;
}
.hist-terrain-tl-dot.active {
    background: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.6);
}

/* Historical Terrain SVG Layer Features */
.hist-river-group {
    cursor: pointer;
    transition: opacity 0.2s ease;
}
.hist-river-halo {
    pointer-events: none;
    stroke: rgba(56, 189, 248, 0.25);
    transition: stroke-width 0.15s ease, stroke 0.15s ease;
}
.hist-river-main {
    transition: stroke 0.15s ease, stroke-width 0.15s ease;
}
.hist-river-group:hover .hist-river-halo {
    stroke: rgba(56, 189, 248, 0.7);
    stroke-width: 6px;
}
.hist-river-group:hover .hist-river-main {
    stroke: #38bdf8 !important;
}

.hist-mountain-pass-marker {
    cursor: pointer;
    transition: transform 0.15s ease;
}
.hist-mountain-pass-marker:hover circle {
    stroke: #f59e0b !important;
    stroke-width: 2.2px !important;
    r: 7px;
}
.hist-mountain-pass-marker:hover text {
    fill: #f59e0b !important;
    font-weight: 800 !important;
}

/* ==========================================================================
   Historical Travelers, Contemporary Polity Compare, and Landmark Layers
   ========================================================================== */

/* Travelers popover list items */
.history-travelers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: min(65vh, 580px);
    flex: 1 1 auto;
    min-height: 280px;
    overflow-y: auto;
    padding: 4px 6px 16px 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(20, 184, 166, 0.6) rgba(255, 255, 255, 0.08);
}
.history-travelers-list::-webkit-scrollbar {
    width: 6px;
}
.history-travelers-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
}
.history-travelers-list::-webkit-scrollbar-thumb {
    background: rgba(20, 184, 166, 0.6);
    border-radius: 6px;
}
.history-travelers-list::-webkit-scrollbar-thumb:hover {
    background: rgba(20, 184, 166, 0.9);
}
.hist-traveler-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.hist-traveler-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
}
.hist-traveler-item.selected {
    background: rgba(20, 184, 166, 0.18);
    border-color: rgba(20, 184, 166, 0.6);
}
.hist-traveler-color-bar {
    width: 6px;
    height: 38px;
    border-radius: 4px;
    flex-shrink: 0;
}
.hist-traveler-info {
    flex: 1;
    min-width: 0;
}
.hist-traveler-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.hist-traveler-name {
    font-weight: 700;
    font-size: 14px;
    color: #f8fafc;
}
.hist-traveler-dates {
    font-size: 11px;
    color: #94a3b8;
    direction: ltr;
}
.hist-traveler-desc-line {
    font-size: 12px;
    color: #cbd5e1;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hist-traveler-checkbox {
    accent-color: #14b8a6;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ==========================================================================
   Light Theme Adaptations for Historical Popover Menus (Wars, Eras, Faiths, Travelers)
   ========================================================================== */
[data-theme="light"] #historyModeDock {
    background: rgba(255, 255, 255, 0.90) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border: 1px solid rgba(15, 23, 42, 0.09) !important;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08) !important;
}
[data-theme="light"] #historyModeDock .btn {
    background: rgba(15, 23, 42, 0.04) !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    color: #1e293b !important;
}
[data-theme="light"] #historyModeDock .btn:hover {
    background: rgba(15, 23, 42, 0.08) !important;
    color: #0f172a !important;
}
[data-theme="light"] #historyModeDock .btn.active {
    background: #0d9488 !important;
    color: #ffffff !important;
}
[data-theme="light"] .hist-popover-menu {
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(24px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
    color: #0f172a !important;
    border: 1px solid rgba(15, 23, 42, 0.09) !important;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.04) !important;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent !important;
}
[data-theme="light"] .hist-popover-header {
    border-bottom: 1px solid rgba(15, 23, 42, 0.07) !important;
}
[data-theme="light"] .hist-drawer-title {
    color: #0f766e !important;
}
[data-theme="light"] .hist-drawer-title .lucide-icon {
    color: #0f766e !important;
}
[data-theme="light"] .hist-drawer-close-btn {
    background: rgba(15, 23, 42, 0.04) !important;
    border-color: rgba(15, 23, 42, 0.1) !important;
    color: #475569 !important;
}
[data-theme="light"] .hist-drawer-close-btn:hover {
    background: #fee2e2 !important;
    border-color: #fca5a5 !important;
    color: #dc2626 !important;
}
[data-theme="light"] .hist-popover-btn {
    background: rgba(15, 23, 42, 0.04) !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    color: #1e293b !important;
    border-radius: 10px !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04) !important;
}
[data-theme="light"] .hist-popover-btn:hover {
    background: rgba(15, 23, 42, 0.08) !important;
    border-color: rgba(15, 23, 42, 0.14) !important;
    color: #0f172a !important;
}
[data-theme="light"] .hist-popover-btn.active,
[data-theme="light"] .hist-popover-btn[aria-expanded="true"] {
    background: #0d9488 !important;
    border-color: #0d9488 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 10px rgba(13, 148, 136, 0.3) !important;
}
[data-theme="light"] .hist-selected-card {
    background: #f8fafc !important;
    border-color: rgba(13, 148, 136, 0.3) !important;
    color: #0f172a !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06) !important;
}
[data-theme="light"] .hist-selected-card .history-empty-state {
    color: #0f172a !important;
}
[data-theme="light"] .hist-selected-card .hist-empty-title {
    color: #0f172a !important;
}
[data-theme="light"] .hist-selected-card .hist-empty-cue {
    color: #64748b !important;
}
[data-theme="light"] .hist-card-title {
    color: #0f172a !important;
}
[data-theme="light"] .hist-card-desc {
    color: #334155 !important;
}
[data-theme="light"] .hist-card-label {
    color: #64748b !important;
}
[data-theme="light"] .hist-badge-years {
    background: #e2e8f0 !important;
    color: #334155 !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .hist-phase-selector {
    background: #f1f5f9 !important;
    border-color: #e2e8f0 !important;
}
[data-theme="light"] .hist-phase-group {
    background: #e2e8f0 !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .hist-phase-btn {
    color: #475569 !important;
}
[data-theme="light"] .hist-phase-btn:hover {
    background: rgba(0, 0, 0, 0.05) !important;
    color: #0f172a !important;
}
[data-theme="light"] .hist-phase-btn.active {
    background: #0d9488 !important;
    color: #ffffff !important;
    border-color: #0d9488 !important;
    box-shadow: 0 1px 4px rgba(13, 148, 136, 0.3) !important;
}
[data-theme="light"] .war-epoch-tab,
[data-theme="light"] .era-epoch-tab {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #475569 !important;
}
[data-theme="light"] .war-epoch-tab:hover,
[data-theme="light"] .era-epoch-tab:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}
[data-theme="light"] .war-epoch-tab.active,
[data-theme="light"] .era-epoch-tab.active {
    background: #0d9488 !important;
    border-color: #0d9488 !important;
    color: #ffffff !important;
}
[data-theme="light"] .history-search-input,
[data-theme="light"] .history-region-select {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .history-search-input::placeholder {
    color: #94a3b8 !important;
}
[data-theme="light"] .history-search-input:focus,
[data-theme="light"] .history-region-select:focus {
    border-color: #0d9488 !important;
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.15) !important;
}
[data-theme="light"] .hist-epoch-col {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
}
[data-theme="light"] .hist-epoch-col-header {
    border-bottom-color: #e2e8f0 !important;
}
[data-theme="light"] .hist-epoch-col-title {
    color: #0f766e !important;
}
[data-theme="light"] .hist-epoch-col-count {
    background: #e2e8f0 !important;
    color: #475569 !important;
}
[data-theme="light"] .hist-epoch-col-items .history-war-tab,
[data-theme="light"] .hist-epoch-col-items .history-scenario-btn {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #1e293b !important;
}
[data-theme="light"] .hist-epoch-col-items .history-war-tab:hover,
[data-theme="light"] .hist-epoch-col-items .history-scenario-btn:hover {
    background: rgba(13, 148, 136, 0.08) !important;
    border-color: #0d9488 !important;
    color: #0f766e !important;
}
[data-theme="light"] .hist-epoch-col-items .history-war-tab.active,
[data-theme="light"] .hist-epoch-col-items .history-scenario-btn.active {
    background: #0d9488 !important;
    border-color: #0d9488 !important;
    color: #ffffff !important;
}
[data-theme="light"] .hist-tab-years {
    background: #f1f5f9 !important;
    color: #64748b !important;
}
[data-theme="light"] .hist-epoch-col-items .history-scenario-btn.active .hist-tab-years,
[data-theme="light"] .hist-epoch-col-items .history-war-tab.active .hist-tab-years {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}
[data-theme="light"] .faiths-popover-item {
    background: #ffffff !important;
    color: #1e293b !important;
    border-color: #e2e8f0 !important;
}
[data-theme="light"] .faiths-popover-item:hover {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .faiths-popover-item.active,
[data-theme="light"] .faiths-popover-item.selected {
    background: rgba(13, 148, 136, 0.1) !important;
    border-color: #0d9488 !important;
}
[data-theme="light"] .faiths-popover-range {
    color: #64748b !important;
}
[data-theme="light"] .faiths-item-info-btn {
    background: #e2e8f0 !important;
    color: #475569 !important;
}
[data-theme="light"] .hist-scroll-cue {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.95) 75%) !important;
}
[data-theme="light"] .hist-traveler-item {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
}
[data-theme="light"] .hist-traveler-item:hover {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .hist-traveler-item.selected {
    background: rgba(13, 148, 136, 0.1) !important;
    border-color: #0d9488 !important;
}
[data-theme="light"] .hist-traveler-name {
    color: #0f172a !important;
}
[data-theme="light"] .hist-traveler-dates {
    color: #64748b !important;
}
[data-theme="light"] .hist-traveler-desc-line {
    color: #334155 !important;
}
[data-theme="light"] .history-travelers-list::-webkit-scrollbar-track,
[data-theme="light"] .history-faiths-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05) !important;
}

/* Bottom Bar Travelers Chips */
.history-travelers-timeline-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    width: 100%;
    padding: 2px 4px;
}
.hist-travelers-chips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}
.hist-traveler-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    font-size: 12px;
    color: #e2e8f0;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}
.hist-traveler-chip:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.3);
}
.hist-traveler-chip.active {
    background: rgba(20, 184, 166, 0.25);
    border-color: #14b8a6;
    color: #fff;
    box-shadow: 0 0 10px rgba(20, 184, 166, 0.3);
}
.hist-traveler-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Floating Traveler Card on Map */
.hist-traveler-card {
    position: fixed;
    top: 76px;
    right: 20px;
    left: auto;
    width: clamp(320px, 26vw, 420px);
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    z-index: var(--z-panel, 1200);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.96) 0%, rgba(17, 24, 39, 0.98) 100%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px) saturate(180%);
    color: #f1f5f9;
    padding: 14px;
    display: flex;
    flex-direction: column;
    animation: hist-drawer-slide 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
[dir="rtl"] .hist-traveler-card {
    right: auto;
    left: 20px;
}
.hist-traveler-card-header {
    position: sticky;
    top: -14px;
    margin: -14px -14px 0 -14px;
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 5;
    flex-shrink: 0;
}
.hist-traveler-nav-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #f8fafc;
    cursor: pointer;
    transition: all 0.15s ease;
}
.hist-traveler-nav-arrow:hover:not(:disabled) {
    background: rgba(20, 184, 166, 0.3);
    border-color: #14b8a6;
}
.hist-traveler-nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.hist-traveler-nav-title-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
    min-width: 0;
}
.hist-traveler-nav-name {
    font-weight: 700;
    font-size: 15px;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.hist-traveler-nav-counter {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}
.hist-traveler-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #e2e8f0;
    font-size: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.hist-traveler-close-btn:hover {
    background: rgba(239, 68, 68, 0.35);
    border-color: #ef4444;
    color: #fff;
}
.hist-traveler-card-body {
    padding-top: 12px;
    font-size: 13px;
    line-height: 1.55;
    color: #cbd5e1;
}
.hist-traveler-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.hist-traveler-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}
.hist-traveler-badge.badge-dist {
    background: rgba(20, 184, 166, 0.15);
    color: #2dd4bf;
    border: 1px solid rgba(20, 184, 166, 0.3);
}
.hist-traveler-bio {
    margin-bottom: 12px;
    font-size: 13px;
    color: #e2e8f0;
}
.hist-traveler-source {
    margin-bottom: 12px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid #14b8a6;
    border-radius: 4px;
    font-size: 12px;
    color: #94a3b8;
}
[dir="rtl"] .hist-traveler-source {
    border-left: none;
    border-right: 3px solid #14b8a6;
}
.hist-traveler-section-title {
    font-weight: 700;
    font-size: 13px;
    color: #f8fafc;
    margin-top: 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.hist-traveler-stations-overview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.hist-traveler-station-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 11.5px;
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.15s ease;
}
.hist-traveler-station-pill:hover, .hist-traveler-station-pill.active {
    background: rgba(20, 184, 166, 0.22);
    border-color: #14b8a6;
    color: #5eead4;
}
.hist-traveler-station-pill .pill-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 8px;
    background: rgba(20, 184, 166, 0.25);
    color: #2dd4bf;
    font-size: 10px;
    font-weight: 700;
}
.hist-traveler-station-hint {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 10px;
    line-height: 1.45;
}
.hist-card-active-wp-context {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(20, 184, 166, 0.35);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    animation: hist-popup-fade 0.15s ease-out;
}
.hist-card-wp-ctx-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12.5px;
    color: #fff;
}
.hist-card-wp-ctx-row {
    font-size: 11.5px;
    color: #f1f5f9;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.hist-card-wp-ctx-row .ctx-lbl {
    color: #94a3b8;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.hist-card-wp-ctx-row .ctx-lbl .lucide-icon {
    width: 12px;
    height: 12px;
}
.hist-card-wp-ctx-desc {
    font-size: 11px;
    color: #cbd5e1;
    line-height: 1.4;
    margin-top: 2px;
}

/* Floating Waypoint Details Popup on Map */
.hist-waypoint-popup {
    position: fixed;
    z-index: var(--z-panel, 1200);
    width: clamp(320px, 28vw, 420px);
    max-width: calc(100vw - 30px);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.96) 0%, rgba(17, 24, 39, 0.98) 100%);
    border: 1px solid rgba(20, 184, 166, 0.4);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px) saturate(180%);
    color: #f1f5f9;
    padding: 12px 14px;
    animation: hist-popup-fade 0.18s ease-out forwards;
    pointer-events: auto;
}
@keyframes hist-popup-fade {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.hist-waypoint-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.hist-waypoint-popup-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.hist-waypoint-popup-step {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #0d9488;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.hist-waypoint-popup-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hist-waypoint-popup-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.hist-waypoint-popup-close:hover {
    color: #fff;
}
.hist-waypoint-popup-body {
    padding: 8px 0;
    font-size: 12.5px;
    line-height: 1.5;
    color: #cbd5e1;
    max-height: 380px;
    overflow-y: auto;
}
.hist-waypoint-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 11.5px;
}
.hist-waypoint-year {
    font-weight: 600;
    color: #94a3b8;
}
.hist-waypoint-duration {
    color: #2dd4bf;
    background: rgba(20, 184, 166, 0.12);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
}
.hist-waypoint-context-grid {
    margin: 8px 0;
    padding: 9px 11px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.hist-wp-context-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
@media (max-width: 480px) {
    .hist-wp-context-row {
        grid-template-columns: 1fr;
    }
}
.hist-wp-context-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.hist-wp-context-label {
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 4px;
}
.hist-wp-context-label .lucide-icon {
    width: 12px;
    height: 12px;
    opacity: 0.85;
}
.hist-wp-context-val {
    font-size: 11.5px;
    font-weight: 600;
    color: #f8fafc;
    line-height: 1.35;
}
.hist-wp-context-cond-item {
    margin-top: 2px;
    padding-top: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}
.hist-wp-context-cond-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 3px;
}
.hist-cond-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
}
.hist-cond-badge.cond-prosperity {
    background: rgba(16, 185, 129, 0.16);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.35);
}
.hist-cond-badge.cond-crisis {
    background: rgba(239, 68, 68, 0.16);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.35);
}
.hist-cond-badge.cond-stable {
    background: rgba(14, 165, 233, 0.16);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.35);
}
.hist-cond-badge.cond-transition {
    background: rgba(168, 85, 247, 0.16);
    color: #c084fc;
    border: 1px solid rgba(192, 132, 252, 0.35);
}
.hist-wp-cond-desc {
    font-size: 11px;
    line-height: 1.4;
    color: #cbd5e1;
}
.hist-waypoint-events {
    margin-bottom: 8px;
    color: #e2e8f0;
}
.hist-waypoint-quote-wrap {
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.35);
    border-left: 3px solid #f59e0b;
    border-radius: 6px;
}
[dir="rtl"] .hist-waypoint-quote-wrap {
    border-left: none;
    border-right: 3px solid #f59e0b;
}
.hist-waypoint-quote-label {
    font-size: 11px;
    font-weight: 600;
    color: #fbbf24;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}
.hist-waypoint-quote {
    margin: 0;
    padding: 0;
    font-style: italic;
    color: #fef3c7;
    font-size: 11.5px;
    line-height: 1.45;
    background: none;
    border: none;
}
.hist-waypoint-popup-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.hist-wp-nav-btn {
    padding: 4px 9px;
    font-size: 11px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}
.hist-wp-nav-btn:hover:not(:disabled) {
    background: rgba(20, 184, 166, 0.25);
    border-color: #14b8a6;
    color: #fff;
}
.hist-wp-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.hist-wp-stage-indicator {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
}

/* Travelers Journey Stepper in Bottom Bar */
.history-travelers-timeline-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.hist-traveler-step-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.14);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}
.hist-traveler-step-btn:hover:not(:disabled) {
    background: rgba(20, 184, 166, 0.25);
    border-color: #14b8a6;
    color: #fff;
}
.hist-traveler-step-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.hist-traveler-timeline-track {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    overflow-x: auto;
    padding: 2px 4px;
    scrollbar-width: none;
}
.hist-traveler-timeline-track::-webkit-scrollbar {
    display: none;
}
.hist-traveler-wp-node {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #cbd5e1;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.hist-traveler-wp-node:hover {
    background: rgba(20, 184, 166, 0.2);
    border-color: #14b8a6;
    color: #f1f5f9;
}
.hist-traveler-wp-node.active {
    background: #14b8a6;
    border-color: #2dd4bf;
    color: #042f2e;
    font-weight: 700;
    box-shadow: 0 0 12px rgba(20, 184, 166, 0.6);
}
.hist-traveler-wp-node .wp-node-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.25);
    font-size: 10px;
    font-weight: 700;
}
.hist-traveler-wp-node.active .wp-node-num {
    background: #042f2e;
    color: #2dd4bf;
}
.hist-traveler-stage-badge {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 11.5px;
}

/* Contemporary Polity Comparison Modal */
.hist-compare-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(520px, 58vw, 840px);
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    z-index: var(--z-modal, 4000);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(17, 24, 39, 0.99) 100%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(24px) saturate(190%);
    color: #f1f5f9;
    padding: 20px;
}
.hist-compare-modal[hidden] {
    display: none !important;
}
.hist-compare-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.hist-compare-modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #f8fafc;
}
.hist-compare-selectors {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 14px;
    margin: 16px 0;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
}
.hist-compare-col-select {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.hist-compare-col-select label {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
}
.hist-compare-vs-badge {
    font-weight: 900;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ef4444 0%, #f59e0b 100%);
    color: #fff;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
    user-select: none;
}
.hist-compare-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}
.hist-compare-row {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    padding: 10px 14px;
}
.hist-compare-row-title {
    font-size: 12px;
    font-weight: 700;
    color: #14b8a6;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.hist-compare-row-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.hist-compare-val {
    font-size: 13px;
    line-height: 1.5;
    color: #e2e8f0;
}
.hist-compare-val.val-a {
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding-right: 12px;
}
[dir="rtl"] .hist-compare-val.val-a {
    border-right: none;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    padding-right: 0;
    padding-left: 12px;
}
.hist-compare-relation-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 10px;
}
.hist-compare-relation-title {
    font-weight: 700;
    font-size: 13px;
    color: #60a5fa;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.hist-compare-relation-desc {
    font-size: 13px;
    line-height: 1.55;
    color: #e2e8f0;
}

@media (max-width: 640px) {
    .hist-compare-selectors {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .hist-compare-vs-badge {
        display: none;
    }
    .hist-compare-row-values {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .hist-compare-val.val-a {
        border: none;
        padding: 0 0 6px 0;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    }
    [dir="rtl"] .hist-compare-val.val-a {
        border: none;
        padding: 0 0 6px 0;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    }
    .hist-traveler-card {
        top: auto;
        bottom: 74px;
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        max-height: 50vh;
    }
    [dir="rtl"] .hist-traveler-card {
        left: 10px;
        right: 10px;
    }
}

/* ── Historical Travelers: Academic Reception & Critical Analysis ── */
.hist-reception-box {
    margin: 14px 0 10px 0;
    padding: 12px 14px;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.9));
    border: 1px solid rgba(217, 119, 6, 0.35);
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.hist-reception-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.reception-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: rgba(217, 119, 6, 0.2);
    border-radius: 6px;
    color: #f59e0b;
    font-size: 14px;
    flex-shrink: 0;
}
.reception-title-col {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.reception-title-col strong {
    font-size: 13px;
    font-weight: 700;
    color: #f8fafc;
}
.reception-status-badge {
    display: inline-block;
    font-size: 10.5px;
    padding: 2px 8px;
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 9999px;
    font-weight: 600;
    width: fit-content;
}
.reception-item {
    margin-bottom: 10px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    font-size: 11.5px;
    line-height: 1.55;
}
.reception-item:last-child {
    margin-bottom: 0;
}
.reception-verdict {
    border-right: 3px solid #38bdf8;
}
[dir="ltr"] .reception-verdict {
    border-right: none;
    border-left: 3px solid #38bdf8;
}
.reception-doubts {
    border-right: 3px solid #fbbf24;
}
[dir="ltr"] .reception-doubts {
    border-right: none;
    border-left: 3px solid #fbbf24;
}
.reception-arch {
    border-right: 3px solid #10b981;
}
[dir="ltr"] .reception-arch {
    border-right: none;
    border-left: 3px solid #10b981;
}
.reception-item-lbl {
    color: #cbd5e1;
    margin-bottom: 4px;
    font-size: 11.5px;
}
.reception-item-lbl strong {
    color: #f1f5f9;
}
.reception-item-desc {
    color: #94a3b8;
    text-align: justify;
}

/* ── Climate & Monsoon tag in Waypoint Popup ── */
.hist-waypoint-climate {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 8px 0;
    padding: 7px 10px;
    background: rgba(14, 165, 233, 0.12);
    border: 1px solid rgba(14, 165, 233, 0.3);
    border-radius: 6px;
    font-size: 11.5px;
    line-height: 1.45;
}
.hist-wp-climate-icon {
    font-size: 14px;
    flex-shrink: 0;
}
.hist-wp-climate-label {
    display: block;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 2px;
}
.hist-wp-climate-text {
    color: #e2e8f0;
}

/* ── Crossroads Multi-Perspective Button & Modal ── */
.hist-waypoint-crossroads-wrap {
    margin: 8px 0;
}
.hist-crossroads-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: center;
    background: linear-gradient(135deg, #d97706, #b45309);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid rgba(251, 191, 36, 0.4);
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
    cursor: pointer;
    transition: all 0.2s ease;
}
.hist-crossroads-btn:hover {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.45);
    transform: translateY(-1px);
}
.hist-crossroads-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10005;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.hist-crossroads-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(5px);
}
.hist-crossroads-modal-content {
    position: relative;
    z-index: 1;
    background: #0f172a;
    border: 1px solid rgba(217, 119, 6, 0.4);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65);
    border-radius: 12px;
    width: 100%;
    max-width: 760px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.hist-crossroads-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(90deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.crossroads-header-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.crossroads-header-icon {
    font-size: 22px;
}
.hist-crossroads-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #f8fafc;
}
.hist-crossroads-modal-subtitle {
    margin: 2px 0 0 0;
    font-size: 11.5px;
    color: #94a3b8;
}
.hist-crossroads-modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s ease;
}
.hist-crossroads-modal-close:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.1);
}
.hist-crossroads-modal-body {
    padding: 16px 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.crossroads-traveler-card {
    background: rgba(30, 41, 59, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 14px;
    transition: border-color 0.2s ease;
}
.crossroads-traveler-card:hover {
    border-color: rgba(217, 119, 6, 0.45);
}
.crossroads-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.crossroads-tr-name-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.crossroads-tr-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.crossroads-tr-name {
    font-size: 14px;
    font-weight: 700;
    color: #f1f5f9;
}
.crossroads-tr-role {
    font-size: 11px;
    color: #94a3b8;
    margin-inline-start: 4px;
}
.crossroads-year-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #38bdf8;
    border-radius: 4px;
}
.crossroads-ctx-row {
    font-size: 11.5px;
    color: #cbd5e1;
    margin-bottom: 6px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.crossroads-quote-box {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.6);
    border-right: 3px solid #f59e0b;
    border-radius: 4px;
    font-size: 12px;
    font-style: italic;
    color: #e2e8f0;
    line-height: 1.5;
}
[dir="ltr"] .crossroads-quote-box {
    border-right: none;
    border-left: 3px solid #f59e0b;
}
.crossroads-pedagogical-takeaway {
    margin-top: 6px;
    font-size: 11px;
    color: #fbbf24;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================================================
   ACADEMIC CITATIONS & BIBLIOGRAPHY MODAL
   ========================================================================== */
.academic-sources-overlay,
.class-worksheet-overlay,
.teacher-hub-overlay,
.student-assignment-overlay,
.terms-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 10, 18, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: fadeInModal 0.2s ease-out;
}

.terms-overlay {
    z-index: 10005 !important;
}

@keyframes fadeInModal {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.academic-sources-box,
.class-worksheet-box,
.teacher-hub-box,
.terms-box {
    background: var(--bg-panel, #0f1c2e);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    width: 980px;
    max-width: 96vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
    overflow: hidden;
    color: var(--text-color, #e2e8f0);
}
[data-theme="light"] .academic-sources-box,
[data-theme="light"] .class-worksheet-box,
[data-theme="light"] .teacher-hub-box {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.12) !important;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.15) !important;
    color: #1e293b !important;
}
[data-theme="light"] .academic-sources-header,
[data-theme="light"] .class-worksheet-header,
[data-theme="light"] .teacher-hub-header {
    background: #f8fafc !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
}
[data-theme="light"] .academic-header-titles h3 {
    color: #0f172a !important;
}

.academic-sources-header,
.class-worksheet-header,
.teacher-hub-header,
.terms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.sheet-drag-handle.academic-drag-handle {
    display: none;
}

.academic-header-titles {
    display: flex;
    align-items: center;
    gap: 14px;
}

.academic-header-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(20, 184, 166, 0.15);
    border: 1px solid rgba(20, 184, 166, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.academic-header-icon {
    width: 22px;
    height: 22px;
    color: var(--brand-accent, #14b8a6);
}

.academic-header-titles h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-accent, #14b8a6);
}

.academic-sources-subtitle {
    margin: 2px 0 0 0;
    font-size: 0.85rem;
    color: var(--text-muted, #94a3b8);
}

.modal-header-icon {
    width: 32px;
    height: 32px;
    color: var(--brand-accent, #14b8a6);
    flex-shrink: 0;
}

.cartographic-disclaimer-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(245, 158, 11, 0.12);
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
    color: #e2e8f0;
    font-size: 0.86rem;
    line-height: 1.6;
}

.cartographic-disclaimer-box .disclaimer-icon {
    width: 20px;
    height: 20px;
    color: #fbbf24;
    flex-shrink: 0;
    margin-top: 2px;
}

.cartographic-disclaimer-box strong {
    color: #fbbf24;
    margin-inline-end: 6px;
    font-weight: 700;
}

.cartographic-disclaimer-box .disclaimer-content {
    flex: 1;
    min-width: 0;
}

.disclaimer-link-btn {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fde68a;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    transition: all 0.15s ease;
    font-family: inherit;
}

.disclaimer-link-btn:hover {
    background: rgba(245, 158, 11, 0.25);
    color: #fff;
    border-color: rgba(245, 158, 11, 0.6);
}

.teacher-hub-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    overflow-x: auto;
}

.teacher-hub-tab-btn {
    padding: 8px 16px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted, #94a3b8);
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.18s;
    white-space: nowrap;
}

.teacher-hub-tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.teacher-hub-tab-btn.active {
    color: #fff;
    background: var(--brand-accent, #14b8a6);
    border-color: var(--brand-accent, #14b8a6);
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.35);
}

.academic-sources-tabs {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(15, 23, 42, 0.55);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
}

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

.academic-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 15px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    color: var(--text-muted, #94a3b8);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    flex-shrink: 0;
    font-family: inherit;
}

.academic-tab-btn .lucide-icon {
    width: 15px;
    height: 15px;
}

.academic-tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.academic-tab-btn.active {
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    border-color: #2dd4bf;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.35);
}

.academic-sources-search-wrap {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.academic-search-box-inner {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.academic-search-icon {
    position: absolute;
    inset-inline-start: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-muted, #94a3b8);
    pointer-events: none;
}

.academic-search-input {
    width: 100%;
    padding: 9px 38px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: #f1f5f9;
    font-size: 0.88rem;
    font-family: inherit;
    box-sizing: border-box;
    transition: all 0.18s ease;
}

.academic-search-input:focus {
    outline: none;
    border-color: var(--brand-accent, #14b8a6);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
    background: rgba(15, 23, 42, 0.85);
}

.academic-search-input::placeholder {
    color: #64748b;
}

.academic-search-clear-btn {
    position: absolute;
    inset-inline-end: 10px;
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 4px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.academic-search-clear-btn:hover {
    color: #f1f5f9;
}

.academic-search-clear-btn .lucide-icon {
    width: 14px;
    height: 14px;
}

.academic-sources-content {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.academic-source-card {
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 12px;
    padding: 14px 16px;
    transition: border-color 0.2s ease, transform 0.15s ease, background 0.15s ease;
}

.academic-source-card:hover {
    border-color: rgba(20, 184, 166, 0.4);
    background: rgba(255, 255, 255, 0.05);
}

.academic-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.academic-source-title {
    font-weight: 700;
    font-size: 1.02rem;
    color: #f1f5f9;
    line-height: 1.4;
    flex: 1;
}

.academic-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(20, 184, 166, 0.15);
    color: var(--brand-accent, #14b8a6);
    border: 1px solid rgba(20, 184, 166, 0.3);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.academic-source-meta {
    font-size: 0.84rem;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.academic-source-desc {
    font-size: 0.88rem;
    line-height: 1.6;
    color: #cbd5e1;
    margin-bottom: 10px;
}

.academic-citation-wrap {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-top: 8px;
}

.academic-source-citation {
    flex: 1;
    background: rgba(0, 0, 0, 0.35);
    border-inline-start: 3px solid var(--brand-accent, #14b8a6);
    padding: 8px 12px;
    font-size: 0.82rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: #a5f3fc;
    border-radius: 6px;
    user-select: all;
    line-height: 1.5;
    word-break: break-word;
}

.academic-copy-citation-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: inherit;
}

.academic-copy-citation-btn:hover {
    background: rgba(20, 184, 166, 0.2);
    border-color: var(--brand-accent, #14b8a6);
    color: #ffffff;
}

.academic-copy-citation-btn.copied {
    background: #0d9488 !important;
    border-color: #0d9488 !important;
    color: #ffffff !important;
}

.academic-copy-citation-btn .lucide-icon {
    width: 14px;
    height: 14px;
}

.academic-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 10px;
    gap: 8px;
}

.academic-source-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    color: var(--brand-accent, #14b8a6);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s;
}

.academic-source-link:hover {
    text-decoration: underline;
    color: #2dd4bf;
}

.academic-source-link .lucide-icon {
    width: 13px;
    height: 13px;
}

.academic-sources-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.7);
    gap: 16px;
    flex-shrink: 0;
}

.academic-footer-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 500;
    background: rgba(255, 255, 255, 0.04);
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.academic-footer-badge .lucide-icon {
    width: 15px;
    height: 15px;
    color: var(--brand-accent, #14b8a6);
}

.academic-footer-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

#academicFooterCloseBtn {
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: all 0.15s ease;
}

#academicFooterCloseBtn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

/* In-Card Citations Box for Eras & Wars */
.academic-citations-card-block {
    margin-top: 14px;
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(20, 184, 166, 0.25);
    border-radius: 8px;
}

.academic-citations-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--brand-accent, #14b8a6);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.academic-citations-list {
    margin: 0;
    padding-inline-start: 18px;
    font-size: 0.8rem;
    color: #cbd5e1;
    line-height: 1.5;
}

/* ==========================================================================
   SMARTBOARD MODE & LASER POINTER
   ========================================================================== */
body.smartboard-active {
    font-size: 110%;
}

body.smartboard-active .btn,
body.smartboard-active button {
    min-height: 48px;
    min-width: 48px;
    font-size: 1rem;
}

body.smartboard-active .country-panel,
body.smartboard-active .history-panel-overlay {
    font-size: 1.15rem;
    border-width: 2px;
}

.smartboard-laser-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99;
}

.smartboard-floating-bar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 28, 46, 0.95);
    border: 1.5px solid var(--brand-accent, #14b8a6);
    border-radius: 32px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: var(--z-presentation-exit, 5000);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 20px rgba(20, 184, 166, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: opacity 0.2s;
}

.smartboard-bar-drag {
    cursor: grab;
    color: var(--text-muted, #94a3b8);
    display: flex;
    align-items: center;
    padding: 2px 4px;
}

.smartboard-bar-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    padding-inline-end: 8px;
    border-inline-end: 1px solid rgba(255, 255, 255, 0.15);
}

.smartboard-bar-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.smartboard-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
}

.smartboard-tool-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.smartboard-tool-btn.active {
    background: var(--brand-accent, #14b8a6);
    color: #04141e;
    border-color: var(--brand-accent, #14b8a6);
    box-shadow: 0 0 12px rgba(20, 184, 166, 0.5);
}

.smartboard-color-picker {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 4px;
}

.laser-dot-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
}

button.laser-dot-swatch {
    padding: 0;
    margin: 0;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

button.laser-dot-swatch:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.laser-dot-swatch:hover {
    transform: scale(1.15);
}

.laser-dot-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 8px currentColor;
    transform: scale(1.2);
}

.smartboard-exit-btn {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.smartboard-exit-btn:hover {
    background: #ef4444;
    color: #fff;
}

/* ==========================================================================
   BLANK MAPS & PRINTABLE WORKSHEETS GENERATOR
   ========================================================================== */
.class-worksheet-body {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

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

.worksheet-settings-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.worksheet-form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.worksheet-form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
}

.worksheet-checkboxes {
    gap: 8px;
    margin-top: 4px;
}

.worksheet-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.worksheet-preview-container {
    background: #09111c;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow-x: auto;
}

.worksheet-preview-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brand-accent, #14b8a6);
    margin-bottom: 12px;
}

/* A4 Sheet Container for on-screen preview & printing */
.worksheet-a4-sheet {
    background: #ffffff;
    color: #1e293b;
    width: 100%;
    min-height: 480px;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 24px 28px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: system-ui, -apple-system, sans-serif;
}

.worksheet-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.worksheet-sheet-school {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
}

.worksheet-sheet-meta {
    font-size: 0.85rem;
    color: #334155;
    text-align: end;
    line-height: 1.6;
}

.worksheet-sheet-title {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    color: #0f172a;
    margin: 4px 0 6px 0;
}

.worksheet-sheet-instructions {
    font-size: 0.82rem;
    color: #475569;
    margin-bottom: 10px;
    background: #f8fafc;
    padding: 6px 12px;
    border-inline-start: 3px solid #0f172a;
    border-radius: 4px;
}

.worksheet-sheet-map-box {
    width: 100%;
    height: 250px;
    border: 1.5px solid #0f172a;
    border-radius: 4px;
    background: #fcfcfd;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.worksheet-sheet-map-box svg {
    width: 100%;
    height: 100%;
}

.worksheet-answers-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.worksheet-answers-table td {
    padding: 6px 10px;
    font-size: 0.82rem;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    font-weight: 500;
}

.worksheet-sheet-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
    padding-top: 8px;
    margin-top: 6px;
}

/* Eco-Print Styles for Clean Black & White Mode */
.worksheet-a4-sheet.eco-print {
    background: #ffffff !important;
    color: #000000 !important;
}

.worksheet-a4-sheet.eco-print svg path {
    fill: #ffffff !important;
    stroke: #000000 !important;
    stroke-width: 0.8px !important;
}

/* Pure Print Media Styles for Worksheets */
@media print {
    body * {
        visibility: hidden !important;
    }
    #worksheetA4Sheet, #worksheetA4Sheet * {
        visibility: visible !important;
    }
    #worksheetA4Sheet {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        margin: 0 !important;
        padding: 15mm 20mm !important;
        box-shadow: none !important;
        border: none !important;
        background: #ffffff !important;
        color: #000000 !important;
    }
    @page {
        size: A4 landscape;
        margin: 10mm;
    }
}

/* ==========================================================================
   TEACHER ASSIGNMENT HUB & LIVE GRADEBOOK
   ========================================================================== */
.teacher-hub-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.teacher-create-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .teacher-create-grid {
        grid-template-columns: 1fr;
    }
}

.teacher-create-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.teacher-share-card {
    background: rgba(20, 184, 166, 0.08);
    border: 1.5px solid rgba(20, 184, 166, 0.35);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.share-code-badge {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1rem;
}

.share-code-badge strong {
    font-size: 1.3rem;
    font-family: monospace, system-ui;
    color: var(--brand-accent, #14b8a6);
    letter-spacing: 2px;
}

.share-link-row {
    display: flex;
    gap: 8px;
}

.share-link-row input {
    flex: 1;
}

.teacher-share-notice {
    display: flex;
    gap: 10px;
    font-size: 0.82rem;
    color: #a7f3d0;
    line-height: 1.45;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 8px;
    padding: 10px;
}

.gradebook-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.gradebook-actions {
    display: flex;
    gap: 8px;
}

.gradebook-summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.grade-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.grade-card-val {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--brand-accent, #14b8a6);
}

.grade-card-label {
    font-size: 0.82rem;
    color: var(--text-muted, #94a3b8);
}

.gradebook-table-wrap {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
}

.gradebook-table {
    width: 100%;
    border-collapse: collapse;
}

.gradebook-table th {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.gradebook-table td {
    padding: 10px 14px;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.gradebook-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Student Assignment Welcome Modal */
.student-assignment-box {
    background: var(--bg-panel, #0f1c2e);
    border: 1.5px solid var(--brand-accent, #14b8a6);
    border-radius: 16px;
    width: 460px;
    max-width: 90vw;
    padding: 28px 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    text-align: center;
    color: #fff;
}

.student-box-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(20, 184, 166, 0.15);
    color: var(--brand-accent, #14b8a6);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.student-box-icon .lucide-icon {
    width: 32px;
    height: 32px;
}

/* ==========================================================================
   TERMS OF SERVICE & PRIVACY POLICY MODAL
   ========================================================================== */
.terms-header-titles {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.terms-header-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(20, 184, 166, 0.12);
    border: 1px solid rgba(20, 184, 166, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.terms-header-icon {
    width: 22px;
    height: 22px;
    color: var(--brand-accent, #14b8a6);
}

.terms-header-titles h3 {
    margin: 0;
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    font-weight: 700;
    color: #ffffff;
    line-height: 1.35;
}

.terms-subtitle {
    margin: 3px 0 0 0;
    font-size: 0.82rem;
    color: var(--text-muted, #94a3b8);
    line-height: 1.35;
}

.terms-close-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.terms-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.sheet-drag-handle.terms-drag-handle {
    display: none;
}

.terms-tabs {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(15, 23, 42, 0.55);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
}

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

.terms-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 15px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    color: var(--text-muted, #94a3b8);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.terms-tab-btn .lucide-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.terms-tab-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

.terms-tab-btn.active {
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    color: #ffffff;
    border-color: #2dd4bf;
    box-shadow: 0 2px 10px rgba(20, 184, 166, 0.35);
    font-weight: 700;
}

.terms-tab-btn.active .lucide-icon {
    color: #ffffff;
}

.terms-body {
    padding: 20px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 62vh;
}

.terms-section-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.terms-section-card:hover {
    border-color: rgba(20, 184, 166, 0.3);
    background: rgba(255, 255, 255, 0.038);
}

.terms-section-card h4 {
    margin: 0 0 10px 0;
    font-size: 1.02rem;
    color: #2dd4bf;
    font-weight: 700;
    line-height: 1.45;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 6px;
}

.terms-section-card p {
    margin: 0 0 10px 0;
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-color, #cbd5e1);
}

.terms-section-card p:last-child {
    margin-bottom: 0;
}

.terms-section-card strong {
    color: #ffffff;
    font-weight: 700;
}

.terms-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.7);
    gap: 16px;
    flex-shrink: 0;
}

.terms-update-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 500;
    background: rgba(255, 255, 255, 0.04);
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.terms-update-badge .lucide-icon {
    width: 15px;
    height: 15px;
    color: var(--brand-accent, #14b8a6);
}

.terms-footer-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

#termsCloseSecondaryBtn {
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: all 0.15s ease;
}

#termsCloseSecondaryBtn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

#termsAcceptBtn {
    padding: 8px 20px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 10px;
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    color: #ffffff;
    border: 1px solid #2dd4bf;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(20, 184, 166, 0.35);
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#termsAcceptBtn .lucide-icon {
    width: 16px;
    height: 16px;
}

#termsAcceptBtn:hover {
    box-shadow: 0 4px 14px rgba(20, 184, 166, 0.5);
    filter: brightness(1.08);
}

@media (max-width: 768px) {
    .terms-overlay {
        padding: 0 !important;
        align-items: flex-end !important;
    }
    .terms-box {
        width: 100% !important;
        max-width: 100% !important;
        height: calc(100vh - 12px) !important;
        height: calc(100dvh - 12px) !important;
        max-height: calc(100vh - 12px) !important;
        max-height: calc(100dvh - 12px) !important;
        border-radius: 20px 20px 0 0 !important;
        border-bottom: none !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.9) !important;
    }
    .sheet-drag-handle.terms-drag-handle {
        display: block !important;
        width: 42px !important;
        height: 5px !important;
        border-radius: 3px !important;
        background: rgba(255, 255, 255, 0.3) !important;
        margin: 8px auto 2px !important;
        flex-shrink: 0 !important;
    }
    .terms-header {
        display: flex !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        padding: 12px 16px 8px !important;
        gap: 12px !important;
    }
    .terms-header-titles {
        display: flex !important;
        align-items: flex-start !important;
        gap: 10px !important;
        flex: 1 !important;
        min-width: 0 !important;
    }
    .terms-header-icon-wrap {
        width: 32px !important;
        height: 32px !important;
        border-radius: 8px !important;
        margin-top: 2px !important;
    }
    .terms-header-icon {
        width: 18px !important;
        height: 18px !important;
    }
    .terms-close-btn {
        margin-top: 2px !important;
    }
    .terms-header-titles h3 {
        font-size: 0.96rem !important;
        line-height: 1.3 !important;
        white-space: normal !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }
    .terms-subtitle {
        font-size: 0.72rem !important;
        line-height: 1.25 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .terms-tabs {
        padding: 8px 12px !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
    }
    .terms-tab-btn {
        padding: 6px 12px !important;
        font-size: 0.78rem !important;
        border-radius: 999px !important;
        flex-shrink: 0 !important;
        gap: 5px !important;
    }
    .terms-tab-btn .lucide-icon {
        width: 13px !important;
        height: 13px !important;
    }
    .terms-body {
        padding: 14px 16px !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .terms-section-card {
        padding: 12px 14px !important;
        border-radius: 12px !important;
        margin-bottom: 10px !important;
    }
    .terms-section-card h4 {
        font-size: 0.92rem !important;
        margin-bottom: 6px !important;
        padding-bottom: 4px !important;
    }
    .terms-section-card p {
        font-size: 0.82rem !important;
        line-height: 1.6 !important;
        margin-bottom: 8px !important;
    }
    .terms-footer {
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)) 14px !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .terms-update-badge {
        font-size: 0.74rem !important;
        justify-content: center !important;
        padding: 3px 8px !important;
    }
    .terms-footer-actions {
        width: 100% !important;
        display: flex !important;
        gap: 8px !important;
    }
    #termsCloseSecondaryBtn,
    #termsAcceptBtn {
        flex: 1 1 0 !important;
        padding: 9px 8px !important;
        font-size: 0.8rem !important;
        text-align: center !important;
        justify-content: center !important;
    }

    /* Mobile Sheet for Academic Sources Modal */
    .academic-sources-overlay {
        padding: 0 !important;
        align-items: flex-end !important;
    }
    .academic-sources-box {
        width: 100% !important;
        max-width: 100% !important;
        height: calc(100vh - 12px) !important;
        height: calc(100dvh - 12px) !important;
        max-height: calc(100vh - 12px) !important;
        max-height: calc(100dvh - 12px) !important;
        border-radius: 20px 20px 0 0 !important;
        border-bottom: none !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.9) !important;
    }
    .sheet-drag-handle.academic-drag-handle {
        display: block !important;
        width: 42px !important;
        height: 5px !important;
        border-radius: 3px !important;
        background: rgba(255, 255, 255, 0.3) !important;
        margin: 8px auto 2px !important;
        flex-shrink: 0 !important;
    }
    .academic-sources-header {
        display: flex !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        padding: 10px 16px 8px !important;
        gap: 10px !important;
    }
    .academic-header-titles {
        display: flex !important;
        align-items: flex-start !important;
        gap: 10px !important;
        flex: 1 !important;
        min-width: 0 !important;
    }
    .academic-header-icon-wrap {
        width: 32px !important;
        height: 32px !important;
        border-radius: 8px !important;
        margin-top: 2px !important;
    }
    .academic-header-icon {
        width: 18px !important;
        height: 18px !important;
    }
    .academic-sources-close {
        margin-top: 2px !important;
    }
    .academic-header-titles h3 {
        font-size: 0.96rem !important;
        line-height: 1.3 !important;
        white-space: normal !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }
    .academic-sources-subtitle {
        font-size: 0.72rem !important;
        line-height: 1.25 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .cartographic-disclaimer-box {
        padding: 10px 14px !important;
        font-size: 0.78rem !important;
        gap: 8px !important;
        line-height: 1.5 !important;
    }
    .cartographic-disclaimer-box .disclaimer-icon {
        width: 18px !important;
        height: 18px !important;
    }
    .disclaimer-link-btn {
        font-size: 0.76rem !important;
        padding: 3px 8px !important;
    }
    .academic-sources-tabs {
        padding: 8px 12px !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
    }
    .academic-tab-btn {
        padding: 6px 12px !important;
        font-size: 0.78rem !important;
        border-radius: 999px !important;
        flex-shrink: 0 !important;
        gap: 5px !important;
    }
    .academic-tab-btn .lucide-icon {
        width: 13px !important;
        height: 13px !important;
    }
    .academic-sources-search-wrap {
        padding: 8px 12px !important;
    }
    .academic-search-input {
        padding: 7px 32px !important;
        font-size: 0.8rem !important;
    }
    .academic-search-icon {
        width: 14px !important;
        height: 14px !important;
        inset-inline-start: 10px !important;
    }
    .academic-sources-content {
        padding: 12px 14px !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .academic-source-card {
        padding: 12px 14px !important;
        border-radius: 12px !important;
        margin-bottom: 8px !important;
    }
    .academic-source-title {
        font-size: 0.92rem !important;
    }
    .academic-badge {
        font-size: 0.7rem !important;
        padding: 2px 7px !important;
    }
    .academic-source-meta {
        font-size: 0.78rem !important;
        gap: 4px !important;
        margin-bottom: 6px !important;
    }
    .academic-source-desc {
        font-size: 0.8rem !important;
        line-height: 1.55 !important;
        margin-bottom: 8px !important;
    }
    .academic-citation-wrap {
        flex-direction: column !important;
        gap: 6px !important;
    }
    .academic-source-citation {
        font-size: 0.76rem !important;
        padding: 6px 10px !important;
    }
    .academic-copy-citation-btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 7px 10px !important;
        font-size: 0.78rem !important;
    }
    .academic-sources-footer {
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)) 14px !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .academic-footer-badge {
        font-size: 0.74rem !important;
        justify-content: center !important;
        padding: 3px 8px !important;
    }
    .academic-footer-actions {
        width: 100% !important;
        display: flex !important;
    }
    #academicFooterCloseBtn {
        width: 100% !important;
        padding: 9px 8px !important;
        font-size: 0.82rem !important;
        text-align: center !important;
        justify-content: center !important;
    }
}

/* Light Theme Support for Terms Modal */
[data-theme="light"] .terms-box {
    background: #ffffff !important;
    border-color: #d0d3d8 !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18) !important;
    color: #1e293b !important;
}
[data-theme="light"] .terms-header {
    background: #f8fafc !important;
    border-bottom-color: #e2e8f0 !important;
}
[data-theme="light"] .terms-header-titles h3 {
    color: #0f172a !important;
}
[data-theme="light"] .terms-subtitle {
    color: #64748b !important;
}
[data-theme="light"] .terms-close-btn {
    background: #e2e8f0 !important;
    color: #475569 !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .terms-tabs {
    background: #f1f5f9 !important;
    border-bottom-color: #e2e8f0 !important;
}
[data-theme="light"] .terms-tab-btn {
    background: #ffffff !important;
    color: #1e293b !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .terms-tab-btn.active {
    background: #115e59 !important;
    color: #ffffff !important;
}
[data-theme="light"] .terms-section-card {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05) !important;
}
[data-theme="light"] .terms-section-card h4 {
    color: #042f2e !important;
    border-bottom-color: #e2e8f0 !important;
}
[data-theme="light"] .terms-section-card p {
    color: #1e293b !important;
}
[data-theme="light"] .terms-section-card strong {
    color: #0f172a !important;
}
[data-theme="light"] .terms-footer {
    background: #f8fafc !important;
    border-top-color: #e2e8f0 !important;
}
[data-theme="light"] .terms-update-badge {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #e2e8f0 !important;
}
[data-theme="light"] #termsCloseSecondaryBtn {
    background: #e2e8f0 !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

/* Light Theme Support for Academic Sources Modal */
[data-theme="light"] .academic-sources-box {
    background: #ffffff !important;
    border-color: #d0d3d8 !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18) !important;
    color: #1e293b !important;
}
[data-theme="light"] .sheet-drag-handle.academic-drag-handle {
    background: rgba(15, 23, 42, 0.25) !important;
}
[data-theme="light"] .academic-sources-header {
    background: #f8fafc !important;
    border-bottom-color: #e2e8f0 !important;
}
[data-theme="light"] .academic-header-icon-wrap {
    background: rgba(13, 148, 136, 0.1) !important;
    border-color: rgba(13, 148, 136, 0.25) !important;
}
[data-theme="light"] .academic-header-icon {
    color: #0d9488 !important;
}
[data-theme="light"] .academic-header-titles h3 {
    color: #0f172a !important;
}
[data-theme="light"] .academic-sources-subtitle {
    color: #64748b !important;
}
[data-theme="light"] .academic-sources-close {
    background: #e2e8f0 !important;
    color: #475569 !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .academic-sources-close:hover {
    background: #fee2e2 !important;
    color: #dc2626 !important;
}
[data-theme="light"] .cartographic-disclaimer-box {
    background: #fffbeb !important;
    border-bottom: 1px solid #fde68a !important;
    color: #92400e !important;
}
[data-theme="light"] .cartographic-disclaimer-box .disclaimer-icon {
    color: #d97706 !important;
}
[data-theme="light"] .cartographic-disclaimer-box strong {
    color: #b45309 !important;
}
[data-theme="light"] .disclaimer-link-btn {
    background: #fef3c7 !important;
    color: #92400e !important;
    border-color: #fcd34d !important;
}
[data-theme="light"] .disclaimer-link-btn:hover {
    background: #fde68a !important;
    color: #78350f !important;
}
[data-theme="light"] .academic-sources-tabs {
    background: #f1f5f9 !important;
    border-bottom-color: #e2e8f0 !important;
}
[data-theme="light"] .academic-tab-btn {
    background: #ffffff !important;
    color: #64748b !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .academic-tab-btn:hover {
    background: #f8fafc !important;
    color: #0f172a !important;
}
[data-theme="light"] .academic-tab-btn.active {
    background: #0d9488 !important;
    color: #ffffff !important;
    border-color: #0d9488 !important;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25) !important;
}
[data-theme="light"] .academic-sources-search-wrap {
    background: #f8fafc !important;
    border-bottom-color: #e2e8f0 !important;
}
[data-theme="light"] .academic-search-input {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}
[data-theme="light"] .academic-search-input:focus {
    border-color: #0d9488 !important;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15) !important;
}
[data-theme="light"] .academic-search-input::placeholder {
    color: #94a3b8 !important;
}
[data-theme="light"] .academic-search-icon {
    color: #64748b !important;
}
[data-theme="light"] .academic-search-clear-btn {
    color: #64748b !important;
}
[data-theme="light"] .academic-search-clear-btn:hover {
    color: #0f172a !important;
}
[data-theme="light"] .academic-sources-content {
    background: #ffffff !important;
}
[data-theme="light"] .academic-source-card {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05) !important;
}
[data-theme="light"] .academic-source-card:hover {
    border-color: #cbd5e1 !important;
    background: #f1f5f9 !important;
}
[data-theme="light"] .academic-source-title {
    color: #0f172a !important;
}
[data-theme="light"] .academic-badge {
    background: rgba(13, 148, 136, 0.1) !important;
    color: #0d9488 !important;
    border-color: rgba(13, 148, 136, 0.25) !important;
}
[data-theme="light"] .academic-source-meta {
    color: #64748b !important;
}
[data-theme="light"] .academic-source-meta strong {
    color: #334155 !important;
}
[data-theme="light"] .academic-source-desc {
    color: #334155 !important;
}
[data-theme="light"] .academic-source-citation {
    background: #eef2f6 !important;
    border-inline-start-color: #0d9488 !important;
    color: #0f172a !important;
}
[data-theme="light"] .academic-copy-citation-btn {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #475569 !important;
}
[data-theme="light"] .academic-copy-citation-btn:hover {
    background: #f1f5f9 !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
}
[data-theme="light"] .academic-source-link {
    color: #0d9488 !important;
}
[data-theme="light"] .academic-source-link:hover {
    color: #0f766e !important;
}
[data-theme="light"] .academic-sources-footer {
    background: #f8fafc !important;
    border-top-color: #e2e8f0 !important;
}
[data-theme="light"] .academic-footer-badge {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #64748b !important;
}
[data-theme="light"] .academic-footer-badge .lucide-icon {
    color: #0d9488 !important;
}
[data-theme="light"] #academicFooterCloseBtn {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #475569 !important;
}
[data-theme="light"] #academicFooterCloseBtn:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}

/* ── Global Colorblind Accessibility Mode (Menus, Buttons, Badges, Tabs) ── */
.colorblind-mode .btn.active,
.colorblind-mode .header-btn.active,
.colorblind-mode .header-btn.toggle-on,
.colorblind-mode .war-epoch-tab.active,
.colorblind-mode .era-epoch-tab.active,
.colorblind-mode .section-toggle-btn.active,
.colorblind-mode .history-war-tab.active,
.colorblind-mode .faiths-popover-item.active {
    outline: 2px solid #ffffff !important;
    box-shadow: 0 0 0 2px #0f172a, 0 0 8px rgba(0, 0, 0, 0.4) !important;
    text-decoration: underline !important;
    text-underline-offset: 3px !important;
}

[data-theme="light"] .colorblind-mode .btn.active,
[data-theme="light"] .colorblind-mode .header-btn.active,
[data-theme="light"] .colorblind-mode .header-btn.toggle-on,
[data-theme="light"] .colorblind-mode .war-epoch-tab.active,
[data-theme="light"] .colorblind-mode .era-epoch-tab.active,
[data-theme="light"] .colorblind-mode .section-toggle-btn.active,
[data-theme="light"] .colorblind-mode .history-war-tab.active,
[data-theme="light"] .colorblind-mode .faiths-popover-item.active {
    outline: 2px solid #0f172a !important;
    box-shadow: 0 0 0 2px #ffffff, 0 0 8px rgba(0, 0, 0, 0.25) !important;
}

.colorblind-mode .btn.active::after,
.colorblind-mode .war-epoch-tab.active::after,
.colorblind-mode .era-epoch-tab.active::after,
.colorblind-mode .section-toggle-btn.active::after {
    content: " ✓" !important;
    font-weight: 900 !important;
    display: inline-block !important;
    margin-inline-start: 4px !important;
}

/* Distinct visual glyphs for religion categories in colorblind mode */
.colorblind-mode .religion-btn[data-religion="muslim"]::before { content: "☪ "; font-weight: bold; }
.colorblind-mode .religion-btn[data-religion="christian"]::before { content: "✝ "; font-weight: bold; }
.colorblind-mode .religion-btn[data-religion="hindu"]::before { content: "🕉 "; font-weight: bold; }
.colorblind-mode .religion-btn[data-religion="buddhist"]::before { content: "☸ "; font-weight: bold; }
.colorblind-mode .religion-btn[data-religion="jewish"]::before { content: "✡ "; font-weight: bold; }
.colorblind-mode .religion-btn[data-religion="other"]::before { content: "✦ "; font-weight: bold; }
.colorblind-mode .religion-btn[data-religion="all"]::before { content: "🌐 "; font-weight: bold; }

/* Enhanced borders on menus, cards, and legend items */
.colorblind-mode .legend-color {
    border: 2px solid #ffffff !important;
    box-shadow: 0 0 0 1px #000000 !important;
}

.colorblind-mode .history-war-tab,
.colorblind-mode .faiths-popover-item,
.colorblind-mode .hist-traveler-item,
.colorblind-mode .tool-card {
    border-width: 2px !important;
}
/* Ensure all scrollable menus, modals, panels, and dropdowns contain scroll gestures */
.hist-popover-menu,
.hist-popover-body,
.country-panel,
#panelContent,
.layers-modal,
.layers-modal-body,
.history-sources-panel,
.menu-popover,
.modal-content,
.drawer-content,
.panel-content,
.hist-traveler-card-body,
.hist-waypoint-popup-body,
.hist-crossroads-modal-body,
.hist-compare-modal-body,
#dataTableOverlay,
#dataTableBody,
[data-scrollable],
.scrollable,
.academic-sources-content,
.academic-sources-tabs {
    overscroll-behavior: contain !important;
}

/* ══════════════════════════════════════════════════════════════════════════════
   WCAG 2.1 / 2.2 LEVEL AAA ACCESSIBILITY & CROSS-OS OPTIMIZATIONS
   Standard: Contrast >= 7:1 (SC 1.4.6), Target Size >= 44x44px (SC 2.5.5),
   Focus Ring >= 3:1 (SC 2.4.13), Windows Forced Colors, iOS/Android Touch
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── 1. Global Typography, Smooth Rendering & Touch Manipulation ── */
html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
}
button, input, select, a, [role="button"], [role="tab"], .mode-btn, .header-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ── 2. WCAG AAA Enhanced Focus Rings (SC 2.4.13) ── */
:focus-visible {
    outline: 3px solid #0f766e !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.35) !important;
}
[data-theme="light"] :focus-visible {
    outline: 3px solid #115e59 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(17, 94, 89, 0.35) !important;
}

/* ── 3. Windows High Contrast Mode (forced-colors: active) ── */
@media (forced-colors: active) {
    .btn,
    .header-btn,
    .header-select,
    .header-icon-btn,
    .zoom-btn,
    .section-toggle-btn,
    .tool-card,
    .lang-option,
    .academic-tab-btn,
    .teacher-hub-tab-btn,
    .quiz-tf-btn,
    .quiz-mode-card,
    .layers-modal-close,
    .mobile-nav-btn,
    .floating-capsule {
        forced-color-adjust: none;
        border: 2px solid ButtonText !important;
        color: ButtonText !important;
        background: ButtonFace !important;
    }
    .btn.active,
    .header-btn.active,
    .header-btn.toggle-on,
    .section-toggle-btn.active,
    .academic-tab-btn.active,
    .teacher-hub-tab-btn.active,
    .quiz-results-tab.active {
        background: Highlight !important;
        color: HighlightText !important;
        border-color: Highlight !important;
    }
    .btn:focus-visible,
    .header-btn:focus-visible,
    .section-toggle-btn:focus-visible,
    .zoom-btn:focus-visible,
    input:focus-visible,
    select:focus-visible {
        outline: 3px solid Highlight !important;
        outline-offset: 3px !important;
    }
}

/* ── 4. WCAG AAA SC 1.4.6 Contrast Enhancements: Light Theme ── */
[data-theme="light"] {
    --brand-accent: #115e59;
    --text-secondary: #334155;
    --focus-ring: #115e59;
}
[data-theme="light"] .section-toggle-btn.active {
    background: #115e59 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(17, 94, 89, 0.3) !important;
}
[data-theme="light"] .section-toggle-btn.active .btn-text,
[data-theme="light"] .section-toggle-btn.active .lucide-icon {
    color: #ffffff !important;
    stroke: #ffffff !important;
}
[data-theme="light"] .header-btn,
[data-theme="light"] .header-btn .btn-text,
[data-theme="light"] #toolsBtn,
[data-theme="light"] #toolsBtn .btn-text,
[data-theme="light"] #colorblindToggle,
[data-theme="light"] #colorblindToggle .btn-text,
[data-theme="light"] #langToggle,
[data-theme="light"] #langToggle .btn-text,
[data-theme="light"] #langToggleText,
[data-theme="light"] #headerProjectionLabel,
[data-theme="light"] #baseMapLabel,
[data-theme="light"] .base-map-label {
    color: #0f172a !important;
}
[data-theme="light"] .academic-tab-btn.active {
    background: #115e59 !important;
    color: #ffffff !important;
    border-color: #115e59 !important;
}
[data-theme="light"] .academic-tab-btn.active .btn-text {
    color: #ffffff !important;
}
[data-theme="light"] .academic-badge {
    background: #ccfbf1 !important;
    color: #042f2e !important;
    border: 1px solid #5eead4 !important;
}
[data-theme="light"] .academic-source-link {
    color: #115e59 !important;
    text-decoration: underline !important;
}
[data-theme="light"] .academic-source-link:hover {
    color: #042f2e !important;
}
[data-theme="light"] .academic-sources-subtitle,
[data-theme="light"] .terms-subtitle,
[data-theme="light"] .academic-source-meta,
[data-theme="light"] .academic-source-desc,
[data-theme="light"] .grade-card-label,
[data-theme="light"] label,
[data-theme="light"] .drawer-section-title,
[data-theme="light"] .academic-footer-badge {
    color: #334155 !important;
}
[data-theme="light"] .drawer-title {
    color: #042f2e !important;
}
[data-theme="light"] .cartographic-disclaimer-box {
    background: #fffbeb !important;
    border-bottom: 1px solid #fde68a !important;
    color: #78350f !important;
}
[data-theme="light"] .cartographic-disclaimer-box strong {
    color: #78350f !important;
}
[data-theme="light"] .disclaimer-link-btn {
    background: #fef3c7 !important;
    color: #78350f !important;
    border-color: #fcd34d !important;
}
[data-theme="light"] .disclaimer-link-btn:hover {
    background: #fde68a !important;
    color: #451a03 !important;
}
[data-theme="light"] .history-year-badge,
[data-theme="light"] #histTerrainYearBadge {
    background: #ccfbf1 !important;
    color: #042f2e !important;
    border: 1px solid #5eead4 !important;
}
[data-theme="light"] .history-timeline-caption {
    color: #1e293b !important;
}
[data-theme="light"] .lang-option.active {
    background: #115e59 !important;
    color: #ffffff !important;
}
[data-theme="light"] .lang-option.active .lang-name {
    color: #ffffff !important;
}
[data-theme="light"] .btn-primary,
[data-theme="light"] #studentStartAssignmentBtn,
[data-theme="light"] #quizCustomAssignBtn,
[data-theme="light"] #quizOpenTeacherHubBtn,
[data-theme="light"] #quizResultsCloseBtn,
[data-theme="light"] #termsAcceptBtn,
[data-theme="light"] #onboardNext {
    background-color: #115e59 !important;
    background: #115e59 !important;
    color: #ffffff !important;
    border-color: #0f766e !important;
}
[data-theme="light"] .teacher-hub-tab-btn.active {
    background: #115e59 !important;
    color: #ffffff !important;
}
[data-theme="light"] .teacher-hub-tab-btn {
    color: #1e293b !important;
}
[data-theme="light"] #teacherTabActiveBtn,
[data-theme="light"] #teacherTabInquiriesBtn,
[data-theme="light"] #teacherTabInquiriesBtn span,
[data-theme="light"] #teacherLogoutBtn,
[data-theme="light"] #teacherLogoutBtn span {
    color: #0f172a !important;
}
[data-theme="light"] .academic-tab-btn:not(.active),
[data-theme="light"] .history-war-tab:not(.active),
[data-theme="light"] .war-epoch-tab:not(.active),
[data-theme="light"] .era-epoch-tab:not(.active),
[data-theme="light"] .terms-tab-btn:not(.active) {
    color: #1e293b !important;
}
[data-theme="light"] .academic-tab-btn:not(.active) .btn-text,
[data-theme="light"] .teacher-hub-tab-btn:not(.active) .btn-text,
[data-theme="light"] .terms-tab-btn:not(.active) .btn-text {
    color: #1e293b !important;
}
[data-theme="light"] .terms-tab-btn.active {
    background: #115e59 !important;
    color: #ffffff !important;
}
[data-theme="light"] .terms-tab-btn.active .btn-text {
    color: #ffffff !important;
}
[data-theme="light"] .quiz-hud-prompt-banner,
[data-theme="light"] .quiz-final-score {
    color: #115e59 !important;
}
[data-theme="light"] .quiz-results-tab.active {
    color: #115e59 !important;
    border-bottom: 2px solid #115e59 !important;
}
[data-theme="light"] .hist-waypoint-popup {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.15) !important;
}
[data-theme="light"] .hist-waypoint-popup-header {
    border-bottom-color: #e2e8f0 !important;
}
[data-theme="light"] .hist-waypoint-popup-title {
    color: #0f172a !important;
}
[data-theme="light"] .hist-waypoint-popup-close,
[data-theme="light"] .quiz-sidebar-close-btn,
[data-theme="light"] .layers-modal-close {
    color: #334155 !important;
}
[data-theme="light"] .hist-waypoint-popup-close:hover,
[data-theme="light"] .quiz-sidebar-close-btn:hover,
[data-theme="light"] .layers-modal-close:hover {
    color: #0f172a !important;
    background: #f1f5f9 !important;
}
[data-theme="light"] .hist-waypoint-popup-step {
    background: #115e59 !important;
    color: #ffffff !important;
}
[data-theme="light"] .hist-waypoint-popup-body,
[data-theme="light"] .hist-waypoint-popup-body span,
[data-theme="light"] .hist-waypoint-popup-desc {
    color: #1e293b !important;
}
[data-theme="light"] .hist-wp-climate-label {
    color: #0369a1 !important;
}
[data-theme="light"] .hist-wp-crossroads-btn {
    background: #115e59 !important;
    color: #ffffff !important;
}
[data-theme="light"] .hist-wp-nav-btn {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
}
[data-theme="light"] .hist-compare-modal,
[data-theme="light"] #histCompareModal,
[data-theme="light"] .hist-crossroads-modal,
[data-theme="light"] #histCrossroadsModal {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .hist-crossroads-modal-header {
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
}
[data-theme="light"] .hist-crossroads-modal-title {
    color: #0f172a !important;
}
[data-theme="light"] .hist-crossroads-modal-subtitle {
    color: #334155 !important;
}
[data-theme="light"] .hist-crossroads-modal-close {
    color: #0f172a !important;
}
[data-theme="light"] .hist-crossroads-modal-body,
[data-theme="light"] .hist-crossroads-modal-body * {
    color: #1e293b !important;
}
[data-theme="light"] .hist-compare-modal span,
[data-theme="light"] .hist-crossroads-modal span,
[data-theme="light"] .hist-compare-modal h3,
[data-theme="light"] .hist-crossroads-modal h3 {
    color: #0f172a !important;
}
[data-theme="light"] .crossroads-header-icon {
    color: #d97706 !important;
}
[data-theme="light"] .hist-compare-vs-badge {
    background: #115e59 !important;
    color: #ffffff !important;
}
[data-theme="light"] .terms-content h4,
[data-theme="light"] .terms-card h4,
[data-theme="light"] .terms-section-card h4,
[data-theme="light"] .academic-sources-content h4,
[data-theme="light"] .layers-category h4,
[data-theme="light"] .worksheet-modal h4,
[data-theme="light"] .worksheet-settings-panel h4,
[data-theme="light"] #classWorksheetModalTitle,
[data-theme="light"] .annotation-modal-title,
[data-theme="light"] .layers-modal-header h3,
[data-theme="light"] #academicSourcesModalTitle,
[data-theme="light"] #teacherLoginTitle,
[data-theme="light"] #teacherHubModalTitle,
[data-theme="light"] h4 {
    color: #042f2e !important;
}
[data-theme="light"] th {
    color: #1e293b !important;
}
[data-theme="light"] .grade-card-val {
    color: #115e59 !important;
}
[data-theme="light"] #teacherTermsLink,
[data-theme="light"] #studentTermsLink,
[data-theme="light"] #teacherTermsLink a,
[data-theme="light"] #studentTermsLink a {
    color: #042f2e !important;
    text-decoration: underline !important;
}
[data-theme="light"] .measure-mode-btn {
    color: #1e293b !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .measure-mode-btn:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}
[data-theme="light"] .onboard-skip {
    color: #1e293b !important;
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
}
[data-theme="light"] .terms-effective-date,
[data-theme="light"] .academic-footer-desc,
[data-theme="light"] .academic-source-meta strong,
[data-theme="light"] .academic-footer-badge span,
[data-theme="light"] .terms-update-badge,
[data-theme="light"] .terms-update-badge span {
    color: #0f172a !important;
}
[data-theme="light"] .tool-card.toggle-on,
[data-theme="light"] .header-btn.toggle-on,
[data-theme="light"] .header-btn.active,
[data-theme="light"] .header-icon-btn.active {
    background: #115e59 !important;
    border-color: #115e59 !important;
    color: #ffffff !important;
}
[data-theme="light"] .tool-card.toggle-on .tool-title,
[data-theme="light"] .tool-card.toggle-on .tool-desc,
[data-theme="light"] .tool-card.toggle-on .btn-text,
[data-theme="light"] .tool-card.toggle-on *,
[data-theme="light"] .header-btn.toggle-on .btn-text,
[data-theme="light"] .header-btn.active .btn-text {
    color: #ffffff !important;
    stroke: #ffffff !important;
}
[data-theme="light"] .mobile-nav-btn .btn-text {
    color: #0f172a !important;
}
[data-theme="light"] .mobile-nav-btn.active .btn-text {
    color: #115e59 !important;
}
[data-theme="light"] .btn.religion-btn.active {
    background: #115e59 !important;
    color: #ffffff !important;
    border-color: #115e59 !important;
}
[data-theme="light"] #sectionBaseMapLabel,
[data-theme="light"] #sectionBaseMapLabel .btn-text,
[data-theme="light"] #sectionBaseMapLabel * {
    color: #042f2e !important;
}
[data-theme="light"] #drawerHistOpacityVal,
[data-theme="light"] #drawerHistOpacityVal strong {
    color: #042f2e !important;
}
[data-theme="light"] #teacherSignOutBtn,
[data-theme="light"] #teacherSignOutBtn span {
    color: #7f1d1d !important;
    background: #fee2e2 !important;
    border-color: #fca5a5 !important;
}
[data-theme="light"] .smartboard-tool-btn.active,
[data-theme="light"] .smartboard-tool-btn.active .btn-text {
    color: #ffffff !important;
}
[data-theme="light"] .smartboard-tool-btn.active .lucide-icon {
    stroke: #ffffff !important;
}
[data-theme="light"] #layersModalClose,
[data-theme="light"] #divisionPopoverClose,
[data-theme="light"] .layers-modal-close {
    color: #0f172a !important;
}

/* ── 5. WCAG AAA SC 1.4.6 Contrast Enhancements: Dark Theme ── */
.active-layer-counter {
    background: #9a3412 !important;
    color: #ffffff !important;
    border: 1px solid #7c2d12 !important;
}
.quiz-tf-btn.quiz-tf-true {
    background: #15803d !important;
    color: #ffffff !important;
}
.terms-subtitle,
.academic-sources-subtitle,
.lang-overlay-subtitle,
.hist-crossroads-modal-subtitle,
.drawer-section-title,
.drawer-section-header,
.drawer-section-header span {
    color: #cbd5e1 !important;
}
.terms-content h4,
.terms-card h4,
.terms-section-card h4,
.academic-sources-content h4,
.annotation-modal-title,
.layers-modal-header h3,
.class-worksheet-modal h3,
.worksheet-settings-panel h4,
#classWorksheetModalTitle,
#teacherLoginTitle,
#teacherHubModalTitle,
#academicSourcesModalTitle,
.drawer-title,
h4 {
    color: #2dd4bf !important;
}
label,
.grade-card-label,
.teacher-hub-tab-btn:not(.active),
.mobile-nav-btn .btn-text,
.history-war-tab:not(.active),
.war-epoch-tab:not(.active),
.era-epoch-tab:not(.active),
.academic-tab-btn:not(.active),
.terms-tab-btn:not(.active),
.terms-tab-btn:not(.active) .btn-text,
.terms-effective-date,
.academic-footer-badge,
.academic-footer-badge span,
.terms-update-badge,
.terms-update-badge span {
    color: #cbd5e1 !important;
}
.btn-primary,
#studentStartAssignmentBtn,
#quizCustomAssignBtn,
#quizOpenTeacherHubBtn,
#quizResultsCloseBtn,
#teacherTabCreateBtn.active,
#termsAcceptBtn,
#onboardNext {
    background-color: #0d5c56 !important;
    background: #0d5c56 !important;
    color: #ffffff !important;
    border-color: #14b8a6 !important;
}
.btn-primary:hover,
#studentStartAssignmentBtn:hover,
#quizCustomAssignBtn:hover,
#quizOpenTeacherHubBtn:hover,
#quizResultsCloseBtn:hover,
#termsAcceptBtn:hover,
#onboardNext:hover {
    background-color: #115e59 !important;
    background: #115e59 !important;
    color: #ffffff !important;
}
.quiz-sidebar-close-btn,
.onboard-skip,
.layers-modal-close {
    color: #cbd5e1 !important;
}
th {
    color: #cbd5e1 !important;
}
#teacherTermsLink,
#studentTermsLink,
#teacherTermsLink a,
#studentTermsLink a,
[data-theme="light"] #studentTermsLink,
[data-theme="light"] #studentTermsLink a {
    color: #2dd4bf !important;
    text-decoration: underline !important;
}
.measure-mode-btn {
    color: #cbd5e1 !important;
}
.worksheet-preview-title {
    color: #2dd4bf !important;
}
.lang-option.active {
    background: #0d5c56 !important;
    color: #ffffff !important;
}
.lang-option.active .lang-name {
    color: #ffffff !important;
}
.mobile-nav-btn.active .btn-text {
    color: #2dd4bf !important;
}
.btn.religion-btn.active {
    background: #0d5c56 !important;
    color: #ffffff !important;
    border-color: #14b8a6 !important;
}
#drawerHistOpacityVal,
#drawerHistOpacityVal strong {
    color: #2dd4bf !important;
}
.crossroads-header-icon {
    color: #f59e0b !important;
}
#sectionBaseMapLabel,
#sectionBaseMapLabel .btn-text {
    color: #2dd4bf !important;
}

/* Worksheet preview paper & classroom printing (strictly white canvas) */
.worksheet-sheet-footer,
.worksheet-sheet-footer span,
#previewTeacherSign,
#previewTeacherSign span,
.worksheet-paper,
.worksheet-paper span,
.worksheet-paper td,
.worksheet-paper th,
.worksheet-paper div,
.study-sheet-print span,
.study-sheet-print .ss-meta {
    color: #0f172a !important;
}

/* ── 6. Expanded Pointer Hit Targets (SC 2.5.5 >= 44x44px) ── */
#controlsBar .btn,
.mode-btn,
.hist-popover-item,
.tool-card {
    position: relative;
}
#controlsBar .btn::before,
.mode-btn::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

/* ══════════════════════════════════════════════════════════════════════════════
   7. ANNOTATION MODE UPGRADE: CLASSROOM COLLABORATION & STUDENT RESEARCH
   ══════════════════════════════════════════════════════════════════════════════ */

.annot-collab-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    background: rgba(45, 212, 191, 0.15) !important;
    color: #2dd4bf !important;
    border: 1px solid #2dd4bf !important;
    position: relative;
}
[data-theme="light"] .annot-collab-btn {
    background: #f0fdfa !important;
    color: #115e59 !important;
    border: 1px solid #115e59 !important;
}
.annot-collab-btn:hover,
.annot-collab-btn.active {
    background: #2dd4bf !important;
    color: #04201e !important;
}
[data-theme="light"] .annot-collab-btn:hover,
[data-theme="light"] .annot-collab-btn.active {
    background: #115e59 !important;
    color: #ffffff !important;
}
.annot-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* Floating Side Panel */
.annotation-side-panel {
    position: fixed;
    top: 74px;
    left: 20px;
    width: 360px;
    max-height: calc(100dvh - 100px);
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: var(--z-modal-alert, 5000);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #f8fafc;
    animation: sidePanelSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes sidePanelSlideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}
[data-theme="light"] .annotation-side-panel {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(15, 23, 42, 0.04);
    color: #0f172a;
}
[dir="rtl"] .annotation-side-panel {
    left: auto;
    right: 20px;
}
@keyframes sidePanelSlideInRtl {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}
[dir="rtl"] .annotation-side-panel {
    animation-name: sidePanelSlideInRtl;
}

.annotation-side-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
[data-theme="light"] .annotation-side-header {
    border-bottom: 1px solid #e2e8f0;
}
.annotation-side-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.annotation-side-title-wrap h3 {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 700;
    color: inherit;
}
.annotation-side-title-wrap .lucide-icon {
    width: 20px;
    height: 20px;
    color: #2dd4bf;
}
[data-theme="light"] .annotation-side-title-wrap .lucide-icon {
    color: #115e59;
}
.annotation-side-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    font-size: 22px;
    color: inherit;
    cursor: pointer;
    border-radius: 8px;
    opacity: 0.8;
    transition: opacity var(--dur-base) var(--ease), background var(--dur-base) var(--ease);
}
.annotation-side-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}
[data-theme="light"] .annotation-side-close:hover {
    background: rgba(15, 23, 42, 0.06);
}

/* Active Controller Status Banner */
.annotation-controller-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 18px;
    background: rgba(45, 212, 191, 0.1);
    border-bottom: 1px solid rgba(45, 212, 191, 0.25);
}
[data-theme="light"] .annotation-controller-banner {
    background: #f0fdf4;
    border-bottom: 1px solid #bbf7d0;
}
.controller-status-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
}
.controller-indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2dd4bf;
    box-shadow: 0 0 10px #2dd4bf;
    animation: pulseDot 2s infinite ease-in-out;
}
[data-theme="light"] .controller-indicator-dot {
    background: #16a34a;
    box-shadow: 0 0 8px #16a34a;
}
@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}
.controller-label {
    color: #cbd5e1;
    font-weight: 500;
}
[data-theme="light"] .controller-label {
    color: #475569;
}
.controller-name {
    color: #f8fafc;
    font-weight: 700;
}
[data-theme="light"] .controller-name {
    color: #0f172a;
}
.revoke-control-btn {
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    border-radius: 8px;
    background: #991b1b !important;
    color: #ffffff !important;
    border: 1px solid #b91c1c !important;
    cursor: pointer;
}
[data-theme="light"] .revoke-control-btn {
    background: #fee2e2 !important;
    color: #7f1d1d !important;
    border: 1px solid #fca5a5 !important;
}

/* Tabs */
.annotation-side-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .annotation-side-tabs {
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}
.annotation-side-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 14px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #e2e8f0;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--dur-base) var(--ease);
}
.annotation-side-tab:hover {
    color: #f8fafc;
}
[data-theme="light"] .annotation-side-tab:hover {
    color: #0f172a;
}
.annotation-side-tab.active {
    color: #2dd4bf;
    border-bottom-color: #2dd4bf;
    background: rgba(255, 255, 255, 0.04);
}
[data-theme="light"] .annotation-side-tab {
    color: #0f172a;
}
[data-theme="light"] .annotation-side-tab.active {
    color: #042f2e;
    border-bottom-color: #042f2e;
    background: #ffffff;
}

/* Sections Content */
.annotation-side-section {
    padding: 18px 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.annotation-field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.annotation-field-label {
    font-size: 0.86rem;
    font-weight: 600;
    color: #cbd5e1;
}
[data-theme="light"] .annotation-field-label {
    color: #0f172a;
}
.annotation-select-row {
    display: flex;
    gap: 8px;
}
.annotation-select,
.annotation-text-input {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.07);
    border: 1.5px solid rgba(255, 255, 255, 0.16);
    color: #f8fafc;
    font-family: inherit;
    font-size: 0.9rem;
    box-sizing: border-box;
}
[data-theme="light"] .annotation-select,
[data-theme="light"] .annotation-text-input {
    background: #ffffff;
    border: 1.5px solid #94a3b8;
    color: #0f172a;
}
.btn-primary-soft {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 10px;
    background: #064e3b !important;
    color: #ffffff !important;
    border: 1px solid #059669 !important;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
}
[data-theme="light"] .btn-primary-soft {
    background: #064e3b !important;
    border-color: #042f2e !important;
}

/* Queue Card */
.annotation-queue-card {
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
[data-theme="light"] .annotation-queue-card {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
}
.queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.queue-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 700;
}
.queue-badge {
    background: #f59e0b;
    color: #0f172a;
    font-size: 12px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
}
.queue-empty-state {
    font-size: 0.84rem;
    color: #cbd5e1;
    text-align: center;
    padding: 12px 6px;
    line-height: 1.4;
}
[data-theme="light"] .queue-empty-state {
    color: #0f172a;
}
.queue-student-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
}
.queue-student-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
[data-theme="light"] .queue-student-item {
    background: #ffffff;
    border: 1px solid #cbd5e1;
}
.queue-student-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
}
.queue-grant-btn {
    min-height: 38px;
    padding: 4px 14px;
    font-size: 0.84rem;
    font-weight: 700;
    border-radius: 6px;
    background: #064e3b !important;
    color: #ffffff !important;
    border: none;
    cursor: pointer;
}

/* Simulation / Hand Raise Button */
.annotation-student-sim-box {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px dashed rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
[data-theme="light"] .annotation-student-sim-box {
    border-top: 1px dashed #cbd5e1;
}
.sim-hint {
    font-size: 0.8rem;
    color: #cbd5e1;
}
[data-theme="light"] .sim-hint {
    color: #0f172a;
    font-weight: 600;
}
.btn-hand-raise {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    background: #f59e0b !important;
    color: #0f172a !important;
    font-weight: 800;
    font-size: 0.94rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
    transition: all var(--dur-base) var(--ease);
}
.btn-hand-raise:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}
.btn-hand-raise.active-raised {
    background: #b91c1c !important;
    color: #ffffff !important;
    box-shadow: 0 4px 16px rgba(185, 28, 28, 0.35);
}

/* Research Toggle & Cards */
.btn-research-toggle {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    border: 1.5px solid #2dd4bf;
    background: rgba(45, 212, 191, 0.15);
    color: #2dd4bf;
}
[data-theme="light"] .btn-research-toggle {
    border-color: #042f2e;
    background: #f0fdfa;
    color: #042f2e;
}
.btn-research-toggle.active {
    background: #064e3b !important;
    color: #ffffff !important;
    border-color: #059669 !important;
}
[data-theme="light"] .btn-research-toggle.active {
    background: #064e3b !important;
    color: #ffffff !important;
    border-color: #042f2e !important;
}
.research-results-summary {
    font-size: 0.84rem;
    color: #cbd5e1;
}
[data-theme="light"] .research-results-summary {
    color: #0f172a;
    font-weight: 600;
}
.research-cards-mini-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
}
.research-mini-card {
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all var(--dur-base) var(--ease);
}
.research-mini-card:hover {
    background: rgba(45, 212, 191, 0.12);
    border-color: #2dd4bf;
    transform: translateX(-3px);
}
[data-theme="light"] .research-mini-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
}
[data-theme="light"] .research-mini-card:hover {
    background: #f0fdfa;
    border-color: #042f2e;
}
.research-mini-title {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.research-mini-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #cbd5e1;
}
[data-theme="light"] .research-mini-meta {
    color: #0f172a;
    font-weight: 600;
}

/* Research Pins on SVG Map */
.student-research-pin-group {
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.student-research-pin-group:hover {
    transform: scale(1.25);
}
.research-pin-circle {
    fill: #f59e0b;
    stroke: #ffffff;
    stroke-width: 2px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}
.research-pin-icon {
    pointer-events: none;
}
.research-pin-label {
    font-weight: 800;
    fill: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    pointer-events: none;
}
[data-theme="light"] .research-pin-label {
    fill: #0f172a;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

/* Research Modal Details */
.research-modal-header-tag {
    display: flex;
    align-items: center;
    gap: 8px;
}
.research-grade-badge {
    background: #fef3c7;
    color: #713f12;
    font-size: 12px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #d97706;
}
.research-modal-title {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 8px 0 12px;
    color: inherit;
}
.research-meta-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.88rem;
    color: #cbd5e1;
}
[data-theme="light"] .research-meta-bar {
    border-bottom: 1px solid #e2e8f0;
    color: #475569;
}
.research-summary-content {
    font-size: 0.96rem;
    line-height: 1.7;
    margin: 16px 0;
    color: inherit;
}
.research-citation-box {
    border-radius: 12px;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
[data-theme="light"] .research-citation-box {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
}
.citation-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.84rem;
    font-weight: 700;
    color: #2dd4bf;
}
[data-theme="light"] .citation-header {
    color: #115e59;
}
.citation-text {
    margin: 0;
    font-family: monospace;
    font-size: 0.86rem;
    line-height: 1.5;
    color: #cbd5e1;
}
[data-theme="light"] .citation-text {
    color: #334155;
}

@media (max-width: 768px) {
    .annotation-side-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 75dvh;
        border-radius: 20px 20px 0 0;
        animation-name: mobileSlideUp;
    }
    @keyframes mobileSlideUp {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
}

/* ==========================================================================
   STUDENT HUB & UPGRADED TEACHER HUB (PHASE 1 EDUCATIONAL SUITE)
   ========================================================================== */

.student-hub-overlay,
.spatial-review-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 10, 18, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: fadeInModal 0.2s ease-out;
}

.spatial-review-overlay {
    z-index: 10004 !important;
}

.student-hub-box {
    background: var(--bg-panel, #0f1c2e);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    width: 980px;
    max-width: 96vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
    overflow: hidden;
    color: var(--text-color, #e2e8f0);
}

[data-theme="light"] .student-hub-box,
[data-theme="light"] .spatial-review-box {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.14) !important;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.15) !important;
    color: #0f172a !important;
}

.student-hub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .student-hub-header {
    background: #f8fafc !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.1) !important;
}

.student-hub-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    overflow-x: auto;
}

[data-theme="light"] .student-hub-tabs {
    background: #f1f5f9 !important;
    border-bottom: 1px solid #cbd5e1 !important;
}

.student-hub-tab-btn {
    padding: 8px 16px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: #cbd5e1;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.18s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
}

.student-hub-tab-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.student-hub-tab-btn.active {
    color: #ffffff !important;
    background: #042f2e !important;
    border-color: #14b8a6 !important;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.4);
}

[data-theme="light"] .student-hub-tab-btn {
    color: #0f172a !important;
}

[data-theme="light"] .student-hub-tab-btn:hover {
    background: rgba(15, 23, 42, 0.06) !important;
}

[data-theme="light"] .student-hub-tab-btn.active {
    background: #042f2e !important;
    border-color: #042f2e !important;
    color: #ffffff !important;
}

.student-hub-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.student-assignments-cards-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.student-assignment-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.student-assignment-card:hover {
    border-color: rgba(20, 184, 166, 0.5);
    transform: translateY(-1px);
}

[data-theme="light"] .student-assignment-card {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.student-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.student-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: inherit;
}

.student-card-desc {
    margin: 0;
    font-size: 0.92rem;
    color: #cbd5e1;
    line-height: 1.6;
}

[data-theme="light"] .student-card-desc {
    color: #334155 !important;
}

.student-card-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.84rem;
    color: #94a3b8;
}

[data-theme="light"] .student-card-meta {
    color: #475569 !important;
}

.student-badge-tag {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.student-badge-spatial {
    background: rgba(245, 158, 11, 0.16);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
}

[data-theme="light"] .student-badge-spatial {
    background: #fef3c7;
    border-color: #d97706;
    color: #92400e;
}

.student-badge-completed {
    background: rgba(16, 185, 129, 0.16);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #34d399;
}

[data-theme="light"] .student-badge-completed {
    background: #d1fae5;
    border-color: #059669;
    color: #065f46;
}

/* Question solver inside student hub */
.student-assignment-solve-wrap {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.student-question-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px 18px;
}

[data-theme="light"] .student-question-item {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.student-question-prompt {
    font-size: 1.02rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: inherit;
}

.student-options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.student-option-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    cursor: pointer;
    text-align: start;
    min-height: 44px;
    transition: all 0.15s;
    font-size: 0.95rem;
}

.student-option-btn:hover {
    background: rgba(20, 184, 166, 0.12);
    border-color: #14b8a6;
}

.student-option-btn.selected {
    background: rgba(20, 184, 166, 0.25);
    border-color: #14b8a6;
    font-weight: 700;
}

[data-theme="light"] .student-option-btn {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
}

[data-theme="light"] .student-option-btn.selected {
    background: rgba(17, 94, 89, 0.15);
    border-color: #042f2e;
    color: #042f2e;
}

/* Spatial Action Box */
.student-spatial-action-box {
    border: 1.5px dashed #f59e0b;
    border-radius: 12px;
    padding: 16px 18px;
    background: rgba(245, 158, 11, 0.08);
    margin: 16px 0;
}

[data-theme="light"] .student-spatial-action-box {
    background: #fffbeb;
    border-color: #d97706;
}

.spatial-action-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.05rem;
    color: #fbbf24;
    margin-bottom: 6px;
}

[data-theme="light"] .spatial-action-title {
    color: #92400e;
}

.spatial-solver-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

/* Map Floating Banners */
.map-floating-mode-banner,
#simDrawTerritoryBanner,
.sim-draw-territory-banner {
    position: fixed;
    top: 76px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10005 !important;
    pointer-events: auto !important;
    background: rgba(15, 28, 46, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid #2dd4bf;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
    border-radius: 12px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    color: #f8fafc;
    font-size: 0.92rem;
    font-weight: 600;
    max-width: 92vw;
    animation: bannerSlideDown 0.22s ease-out;
}

.map-floating-mode-banner *,
#simDrawTerritoryBanner *,
.sim-draw-territory-banner * {
    pointer-events: auto !important;
}

@keyframes bannerSlideDown {
    from { opacity: 0; transform: translate(-50%, -16px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

[data-theme="light"] .map-floating-mode-banner,
[data-theme="light"] #simDrawTerritoryBanner,
[data-theme="light"] .sim-draw-territory-banner {
    background: #ffffff !important;
    border-color: #0d9488 !important;
    color: #0f172a !important;
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.25) !important;
}

/* Inquiries Section */
.student-inquiry-composer {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 22px;
}

[data-theme="light"] .student-inquiry-composer {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.inquiry-item-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

[data-theme="light"] .inquiry-item-card {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
}

.inquiry-status-badge {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.inquiry-status-pending {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

[data-theme="light"] .inquiry-status-pending {
    color: #92400e;
    background: #fef3c7;
    border-color: #f59e0b;
}

.inquiry-status-answered {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

[data-theme="light"] .inquiry-status-answered {
    color: #065f46;
    background: #d1fae5;
    border-color: #10b981;
}

.inquiry-reply-box {
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(20, 184, 166, 0.12);
    border-inline-start: 4px solid #14b8a6;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #e2e8f0;
}

[data-theme="light"] .inquiry-reply-box {
    background: #ecfdf5;
    border-inline-start-color: #047857;
    color: #064e3b;
}

.spatial-status-bar {
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.88rem;
    color: #e2e8f0;
    margin-top: 8px;
}

[data-theme="light"] .spatial-status-bar {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

.location-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
}

[data-theme="light"] .location-badge {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

/* Spatial Review Modal */
.spatial-review-box {
    background: var(--bg-panel, #0f1c2e);
    border: 1.5px solid #f59e0b;
    border-radius: 16px;
    width: 720px;
    max-width: 95vw;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    color: #e2e8f0;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
}

#spatialStudentPreviewSvg {
    width: 100%;
    height: 240px;
    background: #071220;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}

[data-theme="light"] #spatialStudentPreviewSvg {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

@media (max-width: 768px) {
    .student-hub-box {
        top: auto;
        bottom: 0;
        width: 100%;
        max-height: 82dvh;
        border-radius: 20px 20px 0 0;
        animation-name: mobileSlideUp;
    }
    .student-hub-tabs {
        padding: 8px 12px;
        gap: 4px;
    }
    .student-hub-tab-btn {
        font-size: 0.82rem;
        padding: 6px 10px;
        min-height: 44px;
    }
    .map-floating-mode-banner {
        top: 64px;
        width: 94vw;
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    .map-floating-mode-banner .banner-actions {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   NATION HISTORICAL STRATEGY SIMULATION (محاكاة الأمم وصراع الحضارات)
   ========================================================================== */

.nation-sim-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Simulation Floating Pinned Exit Button --- */
.sim-floating-exit-btn {
    position: fixed;
    top: 62px;
    inset-inline-end: 14px;
    z-index: 10020;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    border-radius: 20px;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #ffffff !important;
    border: 1.5px solid #f87171;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 10px rgba(239, 68, 68, 0.35);
    pointer-events: auto;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.sim-floating-exit-btn:hover {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.6);
    transform: translateY(-1px);
}

[data-theme="light"] .sim-floating-exit-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff !important;
    border-color: #b91c1c;
}

/* --- Simulation Top HUD --- */
.sim-top-hud {
    pointer-events: auto;
    background: rgba(15, 28, 46, 0.96);
    backdrop-filter: blur(16px);
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.14);
    padding: 6px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    flex-wrap: nowrap;
    overflow: visible;
    color: #ffffff;
    min-height: 56px;
    box-sizing: border-box;
    width: 100%;
    position: relative;
    z-index: 10;
}

[data-theme="light"] .sim-top-hud {
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1.5px solid #cbd5e1;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    color: #0f172a;
}

.sim-hud-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sim-brand-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sim-swords-icon {
    width: 28px;
    height: 28px;
    color: #f59e0b;
}

.sim-title-text {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
    white-space: nowrap;
}

[data-theme="light"] .sim-title-text {
    color: #0f172a;
}

.sim-title-sub {
    font-size: 0.72rem;
    color: #cbd5e1;
    white-space: nowrap;
}

[data-theme="light"] .sim-title-sub {
    color: #334155;
}

.sim-calendar-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.84rem;
}

[data-theme="light"] .sim-calendar-badge {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
}

.sim-calendar-year {
    font-weight: 700;
    color: #fbbf24;
}

[data-theme="light"] .sim-calendar-year {
    color: #78350f !important;
}

.sim-calendar-season {
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

.sim-season-spring {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

[data-theme="light"] .sim-season-spring {
    background: #d1fae5;
    color: #022c22 !important;
    border-color: #10b981;
}

.sim-season-summer {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

[data-theme="light"] .sim-season-summer {
    background: #fef3c7;
    color: #78350f !important;
    border-color: #f59e0b;
}

.sim-season-autumn {
    background: rgba(234, 88, 12, 0.2);
    color: #fb923c;
    border: 1px solid rgba(234, 88, 12, 0.4);
}

[data-theme="light"] .sim-season-autumn {
    background: #ffedd5;
    color: #7c2d12 !important;
    border-color: #ea580c;
}

.sim-season-winter {
    background: rgba(56, 189, 248, 0.2);
    color: #7dd3fc;
    border: 1px solid rgba(56, 189, 248, 0.4);
}

[data-theme="light"] .sim-season-winter {
    background: #e0f2fe;
    color: #082f49 !important;
    border-color: #38bdf8;
}

.sim-calendar-pace {
    font-size: 0.74rem;
    color: #cbd5e1;
    border-inline-start: 1px solid rgba(255, 255, 255, 0.2);
    padding-inline-start: 8px;
}

[data-theme="light"] .sim-calendar-pace {
    color: #1e293b !important;
    border-inline-start-color: #cbd5e1;
}

.sim-hud-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: nowrap;
    flex: 1 1 auto;
    min-width: 0;
    padding: 2px 6px;
}

.sim-nation-picker-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.sim-hud-setup-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

@media (max-width: 1450px) {
    .sim-hud-setup-tools {
        display: none !important;
    }
    .sim-seasonal-cycle-box {
        display: none !important;
    }
}

.sim-picker-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #cbd5e1;
}

[data-theme="light"] .sim-picker-label {
    color: #0f172a;
}

.sim-select {
    padding: 7px 12px;
    background: #0f1c2e;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    min-height: 44px;
    cursor: pointer;
}

[data-theme="light"] .sim-select {
    background: #ffffff;
    color: #0f172a;
    border-color: #cbd5e1;
}

.sim-role-tabs-group {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

[data-theme="light"] .sim-role-tabs-group {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.sim-role-tab {
    padding: 6px 10px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: #cbd5e1;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 44px;
    transition: all 0.16s ease;
    white-space: nowrap;
}

.sim-role-tab:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.sim-role-tab.active {
    background: #042f2e !important;
    border-color: #14b8a6 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.35);
}

[data-theme="light"] .sim-role-tab {
    color: #0f172a;
}

[data-theme="light"] .sim-role-tab:hover {
    background: rgba(15, 23, 42, 0.08);
    color: #000000;
}

[data-theme="light"] .sim-role-tab.active {
    background: #042f2e !important;
    border-color: #042f2e !important;
    color: #ffffff !important;
}

.sim-hud-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-inline-start: auto;
}

.sim-next-turn-btn {
    background: #064e3b !important;
    color: #ffffff !important;
    border-color: #047857 !important;
    font-weight: 800 !important;
    font-size: 0.85rem !important;
    box-shadow: 0 2px 8px rgba(6, 78, 59, 0.35);
}

.sim-next-turn-btn:hover {
    background: #022c22 !important;
}

[data-theme="light"] .sim-next-turn-btn {
    background: #064e3b !important;
    color: #ffffff !important;
    border-color: #022c22 !important;
}

.sim-power-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(245, 158, 11, 0.15);
    border: 1.5px solid #f59e0b;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 0.86rem;
    color: #fbbf24;
}

[data-theme="light"] .sim-power-badge {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #78350f;
}

.sim-power-val {
    font-weight: 800;
}

.sim-power-rank {
    font-size: 0.74rem;
    padding: 1px 5px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
}

[data-theme="light"] .sim-power-rank {
    background: rgba(120, 53, 15, 0.15);
    color: #78350f;
}

.sim-hud-action-btn {
    min-height: 40px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sim-exit-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #ffffff !important;
    border: 1px solid #f87171 !important;
    font-weight: 800 !important;
    font-size: 0.85rem !important;
    padding: 6px 14px !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.45) !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    transition: all 0.18s ease !important;
}

.sim-exit-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.65) !important;
    transform: translateY(-1px);
}

[data-theme="light"] .sim-exit-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #ffffff !important;
    border-color: #b91c1c !important;
}

[data-theme="light"] .sim-exit-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    color: #ffffff !important;
}

/* --- Floating Nation Command Panel --- */
.sim-nation-panel {
    pointer-events: auto;
    position: absolute;
    top: 66px;
    bottom: 20px;
    inset-inline-end: 20px;
    width: 440px;
    max-width: 92vw;
    background: rgba(15, 28, 46, 0.95);
    backdrop-filter: blur(20px);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    z-index: 1550;
    overflow: hidden;
    color: #ffffff;
    animation: fadeIn 0.2s ease-out;
}

[data-theme="light"] .sim-nation-panel {
    background: rgba(255, 255, 255, 0.98);
    border-color: #cbd5e1;
    color: #0f172a;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}

.sim-nation-header {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .sim-nation-header {
    border-bottom-color: #e2e8f0;
    background: #f8fafc;
}

.sim-nation-emblem-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sim-nation-flag {
    font-size: 2.2rem;
    line-height: 1;
}

.sim-nation-name {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
}

[data-theme="light"] .sim-nation-name {
    color: #0f172a;
}

.sim-nation-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sim-tag {
    font-size: 0.74rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

[data-theme="light"] .sim-tag {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
}

.sim-tag-biome {
    background: rgba(20, 184, 166, 0.18);
    color: #2dd4bf;
    border-color: rgba(20, 184, 166, 0.35);
}

[data-theme="light"] .sim-tag-biome {
    background: #ccfbf1;
    color: #042f2e !important;
    border-color: #14b8a6;
}

.sim-tag-climate {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.35);
}

[data-theme="light"] .sim-tag-climate {
    background: #fef3c7;
    color: #78350f !important;
    border-color: #f59e0b;
}

/* Quick Stats Ticker */
.sim-quick-stats-ticker {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .sim-quick-stats-ticker {
    background: #f1f5f9;
    border-bottom-color: #cbd5e1;
}

.sim-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 6px 4px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .sim-stat-card {
    background: #ffffff;
    border-color: #e2e8f0;
}

.sim-stat-icon {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.sim-stat-val {
    font-size: 0.88rem;
    font-weight: 800;
    color: #ffffff;
}

[data-theme="light"] .sim-stat-val {
    color: #0f172a;
}

.sim-stat-lbl {
    font-size: 0.68rem;
    color: #cbd5e1;
    white-space: nowrap;
}

[data-theme="light"] .sim-stat-lbl {
    color: #475569;
}

/* Role Content Box */
.sim-role-content-box {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sim-view-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sim-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 8px;
}

[data-theme="light"] .sim-view-header {
    border-bottom-color: #e2e8f0;
}

.sim-view-header h4 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
}

[data-theme="light"] .sim-view-header h4 {
    color: #0f172a;
}

.sim-badge-role {
    font-size: 0.74rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

[data-theme="light"] .sim-badge-role {
    background: #fef3c7;
    color: #78350f !important;
    border-color: #f59e0b;
}

.sim-view-desc {
    font-size: 0.86rem;
    line-height: 1.5;
    color: #cbd5e1;
    margin: 0;
}

[data-theme="light"] .sim-view-desc {
    color: #0f172a;
}

.sim-sub-heading {
    margin: 0 0 8px;
    font-size: 0.92rem;
    font-weight: 800;
    color: #fbbf24;
}

[data-theme="light"] .sim-sub-heading {
    color: #78350f !important;
}

.sim-card-hint {
    font-size: 0.8rem;
    color: #cbd5e1;
    margin: 0 0 10px;
    line-height: 1.45;
}

[data-theme="light"] .sim-card-hint {
    color: #1e293b !important;
}

.sim-relations-list,
.sim-caravans-list,
.sim-choke-list,
.sim-scouts-feed,
.sim-captured-spies-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sim-item-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

[data-theme="light"] .sim-item-card {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
}

.sim-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sim-item-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #ffffff;
}

[data-theme="light"] .sim-item-title {
    color: #0f172a;
}

.sim-item-meta {
    font-size: 0.78rem;
    color: #cbd5e1;
}

[data-theme="light"] .sim-item-meta {
    color: #475569;
}

.sim-action-btn {
    min-height: 44px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    width: 100%;
}

.sim-leader-actions-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sim-decrees-feed,
.sim-battles-feed {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.82rem;
    line-height: 1.4;
    color: #cbd5e1;
}

[data-theme="light"] .sim-decrees-feed,
[data-theme="light"] .sim-battles-feed {
    background: #f1f5f9;
    color: #0f172a;
}

.sim-feed-item {
    padding-bottom: 6px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .sim-feed-item {
    border-bottom-color: #cbd5e1;
}

.sim-feed-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Granary Monitor */
.sim-granary-monitor-card {
    background: rgba(20, 184, 166, 0.1);
    border: 1px solid rgba(20, 184, 166, 0.3);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

[data-theme="light"] .sim-granary-monitor-card {
    background: #f0fdfa;
    border-color: #14b8a6;
    color: #0f172a;
}

.sim-granary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.86rem;
}

.sim-status-safe {
    color: #34d399;
    font-weight: 700;
}

[data-theme="light"] .sim-status-safe {
    color: #022c22 !important;
}

/* Military Roster Grid */
.sim-military-roster-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.sim-roster-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
}

[data-theme="light"] .sim-roster-card {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
}

.sim-roster-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #cbd5e1;
    margin-bottom: 4px;
}

[data-theme="light"] .sim-roster-title {
    color: #0f172a;
}

.sim-roster-count {
    font-size: 1.05rem;
    font-weight: 800;
    color: #fbbf24;
    margin-bottom: 2px;
}

[data-theme="light"] .sim-roster-count {
    color: #78350f !important;
}

.sim-roster-sub {
    font-size: 0.72rem;
    color: #cbd5e1;
}

[data-theme="light"] .sim-roster-sub {
    color: #1e293b !important;
}

/* Distance Calculator */
.sim-calc-results {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

[data-theme="light"] .sim-calc-results {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

.sim-calc-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.sim-calc-metric strong {
    color: #2dd4bf;
}

[data-theme="light"] .sim-calc-metric strong {
    color: #042f2e !important;
}

.sim-seasonal-advisory-card {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 10px;
    padding: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
}

[data-theme="light"] .sim-seasonal-advisory-card {
    background: #f0f9ff;
    border-color: #38bdf8;
    color: #0f172a;
}

/* Scouting Rings */
.sim-scout-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 6px;
}

.sim-rings-legend-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.sim-ring-item {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.78rem;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sim-ring-outer {
    background: rgba(14, 165, 233, 0.12);
    border-inline-start: 4px solid #0ea5e9;
    color: #e0f2fe;
}

[data-theme="light"] .sim-ring-outer {
    background: #e0f2fe;
    border-inline-start-color: #0284c7;
    color: #082f49 !important;
}

.sim-ring-mid {
    background: rgba(245, 158, 11, 0.12);
    border-inline-start: 4px solid #f59e0b;
    color: #fef3c7;
}

[data-theme="light"] .sim-ring-mid {
    background: #fef3c7;
    border-inline-start-color: #d97706;
    color: #78350f !important;
}

.sim-ring-inner {
    background: rgba(239, 68, 68, 0.14);
    border-inline-start: 4px solid #ef4444;
    color: #fee2e2;
}

[data-theme="light"] .sim-ring-inner {
    background: #fee2e2;
    border-inline-start-color: #dc2626;
    color: #7f1d1d !important;
}

/* Teacher GM Modal */
.sim-teacher-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: auto;
}

.sim-teacher-modal-box {
    background: var(--bg-panel, #0f1c2e);
    border: 1.5px solid #f59e0b;
    border-radius: 18px;
    width: 780px;
    max-width: 95vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    color: #ffffff;
}

[data-theme="light"] .sim-teacher-modal-box {
    background: #ffffff;
    border-color: #f59e0b;
    color: #0f172a;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
}

.sim-modal-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

[data-theme="light"] .sim-modal-header {
    border-bottom-color: #e2e8f0;
}

.sim-modal-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sim-modal-header-title h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
}

.sim-teacher-modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sim-teacher-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sim-teacher-events-log {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 12px;
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.84rem;
}

[data-theme="light"] .sim-teacher-events-log {
    background: #f1f5f9;
    color: #0f172a;
}

.sim-crisis-buttons-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.sim-crisis-btn {
    min-height: 44px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.sim-reward-controls-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- D3 Simulation Map Layers Styling --- */
.sim-territory-poly {
    fill-opacity: 0.18;
    stroke-dasharray: 4, 3;
    pointer-events: none;
    transition: fill-opacity 0.3s ease;
}

.sim-capital-marker {
    cursor: pointer;
    pointer-events: auto;
}

.sim-capital-circle {
    fill: #f59e0b;
    stroke: #ffffff;
}

.sim-capital-label {
    fill: #ffffff;
    font-weight: 800;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
    pointer-events: none;
}

.sim-caravan-group {
    pointer-events: auto;
    cursor: pointer;
}

.sim-caravan-path {
    stroke: #f59e0b;
    stroke-dasharray: 6, 4;
    fill: none;
    pointer-events: none;
    animation: dashMove 20s linear infinite;
}

@keyframes dashMove {
    to { stroke-dashoffset: -100; }
}

.sim-scout-group {
    pointer-events: auto;
    cursor: pointer;
}

.scout-ring-outer {
    fill: rgba(14, 165, 233, 0.06);
    stroke: rgba(14, 165, 233, 0.5);
    stroke-dasharray: 4, 4;
    pointer-events: none;
}

.scout-ring-mid {
    fill: rgba(245, 158, 11, 0.08);
    stroke: rgba(245, 158, 11, 0.6);
    pointer-events: none;
}

.scout-ring-inner {
    fill: rgba(239, 68, 68, 0.16);
    stroke: rgba(239, 68, 68, 0.8);
    pointer-events: none;
}

.sim-choke-point-group {
    pointer-events: auto;
    cursor: pointer;
}

/* Mobile Responsiveness for Sim */
@media (max-width: 768px) {
    .sim-floating-exit-btn {
        top: 56px;
        inset-inline-end: 8px;
        padding: 4px 10px;
        font-size: 0.78rem;
    }
    .sim-top-hud {
        padding: 6px 10px;
        gap: 6px;
        flex-wrap: wrap;
    }
    .sim-hud-left {
        flex: 1 1 auto;
        gap: 6px;
        width: auto;
    }
    .sim-hud-right {
        margin-inline-start: auto;
        flex-shrink: 0;
        width: auto;
        gap: 6px;
    }
    .sim-hud-center {
        width: 100%;
        order: 3;
        flex-direction: row;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 2px;
    }
    .sim-brand-title {
        width: auto;
    }
    .sim-calendar-badge {
        font-size: 0.74rem;
        padding: 3px 6px;
    }
    .sim-role-tabs-group {
        overflow-x: auto;
        padding: 3px;
        width: auto;
        flex-shrink: 0;
    }
    .sim-role-tab {
        font-size: 0.76rem;
        padding: 4px 6px;
        min-height: 38px;
    }
    .sim-nation-panel {
        top: auto;
        bottom: 0;
        inset-inline-end: 0;
        width: 100%;
        max-height: 75dvh;
        border-radius: 20px 20px 0 0;
        animation-name: mobileSlideUp;
    }
    .sim-military-roster-grid,
    .sim-crisis-buttons-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Universal Strategic Visual Transformation Styles
   ========================================================================== */

/* 1. Visual Capacity Gauges */
.sim-stat-gauge {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    margin-top: 6px;
    overflow: hidden;
    position: relative;
}

[data-theme="light"] .sim-stat-gauge {
    background: rgba(0, 0, 0, 0.08);
}

.sim-stat-gauge-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s ease;
}

.sim-gauge-food {
    background: linear-gradient(90deg, #10b981, #34d399);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.sim-gauge-metals {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.sim-gauge-livestock {
    background: linear-gradient(90deg, #06b6d4, #22d3ee);
    box-shadow: 0 0 6px rgba(6, 182, 212, 0.5);
}

.sim-gauge-gold {
    background: linear-gradient(90deg, #eab308, #facc15);
    box-shadow: 0 0 6px rgba(234, 179, 8, 0.5);
}

.sim-gauge-troops {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
    box-shadow: 0 0 6px rgba(139, 92, 246, 0.5);
}

.sim-stat-gauge-fill.gauge-critical {
    background: linear-gradient(90deg, #ef4444, #f87171) !important;
    animation: gaugePulse 1.5s infinite;
}

@keyframes gaugePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* 2. Imperial Council Advisor Banner */
.sim-council-advisor-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(15, 23, 42, 0.85);
    border: 1.5px solid rgba(245, 158, 11, 0.4);
    border-radius: 14px;
    padding: 10px 14px;
    margin: 12px 14px 4px 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
}

[data-theme="light"] .sim-council-advisor-banner {
    background: #ffffff;
    border-color: #f59e0b;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.sim-council-medallion {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #b45309);
    border: 2px solid #fde68a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.sim-council-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.sim-council-title {
    font-size: 0.82rem;
    font-weight: 800;
    color: #fbbf24;
}

[data-theme="light"] .sim-council-title {
    color: #78350f !important;
}

.sim-council-text {
    margin: 0;
    font-size: 0.84rem;
    line-height: 1.45;
    color: #f1f5f9;
}

[data-theme="light"] .sim-council-text {
    color: #0f172a !important;
}

/* 3. Quick Point-and-Click Map Trade Modal */
.sim-quick-trade-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    z-index: 3100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.sim-quick-trade-box {
    background: var(--bg-panel, #0f1c2e);
    border: 1.5px solid #10b981;
    border-radius: 18px;
    width: 620px;
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    color: #ffffff;
}

[data-theme="light"] .sim-quick-trade-box {
    background: #ffffff;
    border-color: #059669;
    color: #0f172a;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
}

.sim-trade-modal-icon {
    font-size: 22px;
}

.sim-quick-trade-body {
    padding: 18px 22px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sim-trade-route-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.95rem;
    font-weight: 700;
}

[data-theme="light"] .sim-trade-route-summary {
    background: #ecfdf5;
    border-color: #059669;
    color: #064e3b !important;
}

.sim-route-arrow {
    color: #6ee7b7;
    font-weight: 900;
}

[data-theme="light"] .sim-route-arrow {
    color: #065f46 !important;
}

.sim-trade-section-title {
    margin: 4px 0 0 0;
    font-size: 0.88rem;
    font-weight: 700;
    color: #cbd5e1;
}

[data-theme="light"] .sim-trade-section-title {
    color: #1e293b !important;
}

.sim-trade-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

@media (max-width: 600px) {
    .sim-trade-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.sim-trade-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: inherit;
    min-height: 44px;
}

[data-theme="light"] .sim-trade-card {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

.sim-trade-card:hover {
    transform: translateY(-2px);
    border-color: #10b981;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.sim-trade-card.active {
    background: rgba(16, 185, 129, 0.18) !important;
    border-color: #10b981 !important;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

[data-theme="light"] .sim-trade-card.active {
    background: #d1fae5 !important;
    border-color: #059669 !important;
}

.sim-card-emoji {
    font-size: 24px;
}

.sim-card-title {
    font-size: 0.8rem;
    font-weight: 800;
    text-align: center;
}

.sim-card-sub {
    font-size: 0.7rem;
    color: #cbd5e1;
    text-align: center;
}

[data-theme="light"] .sim-card-sub {
    color: #334155 !important;
}

.sim-launch-caravan-btn {
    width: 100%;
    min-height: 46px;
    font-size: 0.95rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #064e3b !important;
    color: #ffffff !important;
    border-color: #047857 !important;
    box-shadow: 0 4px 14px rgba(6, 78, 59, 0.4);
    margin-top: 6px;
}

.sim-launch-caravan-btn:hover {
    background: #022c22 !important;
}

/* 4. Diplomatic Silk Treaty Ribbons & Animated Effects */
.sim-silk-ribbon {
    stroke: #10b981;
    stroke-dasharray: 6, 4;
    animation: silkPulse 2.5s linear infinite;
    opacity: 0.85;
}

@keyframes silkPulse {
    from { stroke-dashoffset: 20; }
    to { stroke-dashoffset: 0; }
}

.sim-floating-popups-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 2800;
}

.sim-floating-delta-tag {
    position: absolute;
    font-size: 13px;
    font-weight: 900;
    pointer-events: none;
    z-index: 2800;
    padding: 3px 8px;
    border-radius: 12px;
    animation: floatResourceDelta 2s ease-out forwards;
}

.sim-delta-positive {
    background: rgba(6, 95, 70, 0.95);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(6, 95, 70, 0.4);
}

.sim-delta-negative {
    background: rgba(185, 28, 28, 0.95);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(185, 28, 28, 0.4);
}

.sim-delta-gold {
    background: #fef3c7;
    color: #78350f;
    border: 1px solid #f59e0b;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

@keyframes floatResourceDelta {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.85);
    }
    15% {
        opacity: 1;
        transform: translateY(-8px) scale(1.05);
    }
    80% {
        opacity: 1;
        transform: translateY(-24px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-38px) scale(0.9);
    }
}

/* 5. Partner Capitals (Subtle Clickable Trade Anchors) */
.sim-partner-capital-marker {
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.sim-partner-capital-marker:hover {
    transform: scale(1.18);
}

.sim-partner-capital-marker circle {
    transition: stroke-width 0.2s ease;
}

.sim-partner-capital-marker:hover circle {
    stroke-width: 2.5px;
}

.sim-treaty-seal:hover {
    transform: scale(1.25);
}

/* ==========================================================================
   Automated Seasonal Cycle & Sovereign Governance Styles
   ========================================================================== */

/* 1. Automated Seasonal Cycle Box */
.sim-seasonal-cycle-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    padding: 6px 12px;
    min-width: 170px;
}

[data-theme="light"] .sim-seasonal-cycle-box {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

.sim-cycle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 600;
}

.sim-cycle-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    display: inline-block;
    animation: simCyclePulse 2s infinite ease-in-out;
}

@keyframes simCyclePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.sim-cycle-label {
    color: #cbd5e1;
    font-size: 0.76rem;
}

[data-theme="light"] .sim-cycle-label {
    color: #1e293b;
}

.sim-cycle-countdown {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 700;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
    padding: 1px 6px;
    border-radius: 6px;
}

[data-theme="light"] .sim-cycle-countdown {
    color: #0369a1 !important;
    background: #e0f2fe;
}

.sim-cycle-track {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    overflow: hidden;
}

[data-theme="light"] .sim-cycle-track {
    background: #e2e8f0;
}

.sim-cycle-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #38bdf8);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* 2. Sovereign Budget Allocation Panel */
.sim-budget-allocation-panel,
.sim-allied-garrison-panel {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 12px;
    margin-top: 12px;
}

[data-theme="light"] .sim-budget-allocation-panel,
[data-theme="light"] .sim-allied-garrison-panel {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.sim-budget-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

@media (max-width: 640px) {
    .sim-budget-grid {
        grid-template-columns: 1fr;
    }
}

.sim-budget-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

[data-theme="light"] .sim-budget-card {
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.sim-budget-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.sim-budget-icon {
    font-size: 1.25rem;
}

.sim-budget-need {
    font-size: 0.72rem;
    color: #fbbf24;
}

[data-theme="light"] .sim-budget-need {
    color: #b45309;
}

.sim-select-sm {
    min-height: 36px;
    padding: 4px 8px;
    font-size: 0.8rem;
    width: 100%;
}

.sim-budget-impact {
    font-size: 0.76rem;
    color: #94a3b8;
    line-height: 1.35;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px 6px;
    border-radius: 6px;
}

[data-theme="light"] .sim-budget-impact {
    color: #334155;
    background: #f1f5f9;
}

/* 3. Allied Garrison Panel */
.sim-dispatched-forces-status {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    padding: 6px 10px;
    border-inline-start: 3px solid #38bdf8;
    font-size: 0.82rem;
    margin-top: 6px;
    color: #cbd5e1;
}

[data-theme="light"] .sim-dispatched-forces-status {
    background: #f1f5f9;
    color: #1e293b;
    border-inline-start-color: #0284c7;
}

/* 4. Tax Policy Card */
.sim-tax-policy-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

[data-theme="light"] .sim-tax-policy-card {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.sim-tax-policy-hint {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 4px;
}

[data-theme="light"] .sim-tax-policy-hint {
    color: #475569;
}

/* 5. Sandbox World Architect & Drawing Mode */
.sim-sandbox-btn {
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    padding: 6px 12px;
}

.sim-drawn-nation-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 0.8rem;
    color: #f8fafc;
}

[data-theme="light"] .sim-drawn-nation-pill {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #0f172a;
}

.sim-drawn-nation-pill .sim-pill-remove {
    cursor: pointer;
    color: #f87171;
    font-weight: bold;
    margin-inline-start: 4px;
}

.sim-drawing-polygon {
    fill: rgba(59, 130, 246, 0.25);
    stroke: #3b82f6;
    stroke-width: 2px;
    stroke-dasharray: 4, 3;
    pointer-events: none !important;
}

.sim-drawing-vertex {
    fill: #3b82f6;
    stroke: #ffffff;
    stroke-width: 2px;
    pointer-events: none !important;
}

.sim-drawing-line {
    stroke: #3b82f6;
    stroke-width: 2px;
    stroke-dasharray: 4, 3;
    pointer-events: none !important;
}

/* Territory Drawing Mode Active State (Disable Country Clicks, Highlights and Tooltips) */
body.sim-drawing-mode-active #mapSvg {
    cursor: crosshair !important;
}

body.sim-drawing-mode-active .country-path,
body.sim-drawing-mode-active .country-label,
body.sim-drawing-mode-active .city-label,
body.sim-drawing-mode-active .major-city-marker,
body.sim-drawing-mode-active .capital-marker,
body.sim-drawing-mode-active .hist-landmark-pin,
body.sim-drawing-mode-active .hist-river-group,
body.sim-drawing-mode-active .hist-mountain-pass-marker,
body.sim-drawing-mode-active .terrain-feature,
body.sim-drawing-mode-active .sim-drawing-vertex,
body.sim-drawing-mode-active .sim-drawing-vertex-label,
body.sim-drawing-mode-active .sim-drawing-polygon {
    pointer-events: none !important;
    cursor: crosshair !important;
}

body.sim-drawing-mode-active #countryPanel,
body.sim-drawing-mode-active #tooltip {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* 6. Country Dossier Modal */
.sim-dossier-box {
    animation: simModalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] .sim-dossier-card {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

[data-theme="light"] #simDossierClimateDesc,
[data-theme="light"] #simDossierDefenseDesc,
[data-theme="light"] #simDossierSeasonsList {
    color: #334155 !important;
}

.sim-dossier-res-badge {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #f8fafc;
}

[data-theme="light"] .sim-dossier-res-badge {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
}

