/**
 * Total Scotland — Scottish Light Cartography Design System
 * 
 * Aesthetics: Light, bright, welcoming, and friendly Scottish portal.
 * Palette: Royal Heather Purple, Highland Glen Green, Saltire Azure, Gorse Gold,
 * and handcrafted Scottish Tartan ribbons with humanist editorial typography.
 */

:root {
    /* Base & Surface */
    --bg-base: #f4f6f8;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #ffffff;
    --bg-surface-glass: rgba(255, 255, 255, 0.95);
    --bg-surface-hover: #f8fafc;
    
    /* Borders */
    --border-subtle: #e5e7eb;
    --border-warm: #e8e2d8;
    --border-strong: #cbd5e1;
    --border-heather: #d8b8d5;
    
    /* Typography */
    --text-primary: #1c222b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-inverse: #ffffff;
    
    /* Scottish Heather & Thistle Palette */
    --heather: #752d70;
    --heather-hover: #8e3988;
    --heather-dark: #561d52;
    --heather-light: #fbf2fa;
    --heather-border: #ebd3e9;
    --heather-glow: rgba(117, 45, 112, 0.15);
    
    /* Highland Glen & Thistle Green */
    --glen-green: #23683f;
    --glen-green-hover: #2d7e4d;
    --glen-green-light: #edf8f1;
    --glen-green-border: #c8e6d2;
    
    /* Scottish Saltire Azure */
    --saltire-blue: #0065bf;
    --saltire-blue-hover: #0077dd;
    --saltire-blue-light: #edf5fd;
    --saltire-blue-border: #cde4fb;
    
    /* Highland Gorse Gold */
    --gorse-gold: #b47814;
    --gorse-gold-hover: #cb8919;
    --gorse-gold-light: #fef8ec;
    --gorse-gold-border: #f7e0be;
    
    /* Heather Crimson (Alerts & Mountain Safety) */
    --crimson: #a61e38;
    --crimson-hover: #be2241;
    --crimson-light: #fdf0f2;
    --crimson-border: #f9cbd3;
    
    /* Fonts */
    --font-brand: 'Fraunces', Georgia, serif;
    --font-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Subtle Scottish Tartan Weave Ribbon */
    --tartan-ribbon: linear-gradient(90deg, 
        #0065bf 0%, #0065bf 22%, 
        #1e4620 22%, #1e4620 44%, 
        #a6192e 44%, #a6192e 66%, 
        #d4af37 66%, #d4af37 78%,
        #752d70 78%, #752d70 100%);

    /* Soft Natural Lighting Shadows */
    --shadow-sm: 0 1px 3px rgba(28, 34, 43, 0.05);
    --shadow-md: 0 4px 14px -2px rgba(28, 34, 43, 0.08);
    --shadow-lg: 0 12px 30px -4px rgba(28, 34, 43, 0.12);
    --shadow-drawer: 0 20px 45px -8px rgba(28, 34, 43, 0.16);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 14px;
}

/* Fullscreen Map Canvas */
#map {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-color: #e5e9ec;
}

/* Top App Header with Handcrafted Tartan Ribbon */
.app-header {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    height: 60px;
    background: var(--bg-surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 50;
    pointer-events: auto;
    overflow: hidden;
}

/* Authentic Tartan Accent Stripe on Header */
.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3.5px;
    background: var(--tartan-ribbon);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-brand);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.brand-logo .scot-flag {
    font-size: 1.4rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.brand-logo strong {
    color: var(--heather);
    font-weight: 700;
}

/* Warm Friendly Status Pill */
.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--glen-green-light);
    border: 1px solid var(--glen-green-border);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--glen-green);
}

.pulse-dot {
    width: 7px;
    height: 7px;
    background: var(--glen-green);
    border-radius: 50%;
    animation: gentle-pulse 2.2s infinite;
}

@keyframes gentle-pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(35, 104, 63, 0.4); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(35, 104, 63, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(35, 104, 63, 0); }
}

/* Header Action Controls */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.search-box {
    position: relative;
    width: 280px;
}

.search-box input {
    width: 100%;
    padding: 0.48rem 1rem 0.48rem 2.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font-ui);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

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

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.45rem 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.header-btn:hover {
    background: var(--heather-light);
    border-color: var(--heather-border);
    color: var(--heather);
    transform: translateY(-1px);
}

.header-btn.active {
    background: var(--heather);
    color: var(--text-inverse);
    border-color: var(--heather-hover);
    font-weight: 600;
    box-shadow: 0 2px 8px var(--heather-glow);
}

.drawer-count-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--heather);
    background: var(--heather-light);
    border: 1px solid var(--heather-border);
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.header-btn.active .drawer-count-badge {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-color: transparent;
}

/* Friendly Warning & Hazard Alert Banner */
.alert-bar {
    position: absolute;
    top: 86px;
    left: 16px;
    right: 16px;
    background: var(--crimson-light);
    border: 1px solid var(--crimson-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    z-index: 45;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.alert-bar.hidden {
    display: none;
}

.alert-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-badge {
    background: var(--crimson);
    color: #fff;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    letter-spacing: 0.04em;
}

.alert-text {
    color: #881337;
    font-weight: 500;
}

.alert-text strong {
    color: var(--crimson);
}

.alert-close {
    background: transparent;
    border: none;
    color: #9f1239;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    transition: var(--transition);
}

.alert-close:hover {
    color: var(--crimson);
    transform: scale(1.1);
}

/* ==========================================================================
   THE SCOTTISH WAYFARER SIDEBAR
   ========================================================================== */
.sidebar {
    position: absolute;
    top: 86px;
    left: 16px;
    bottom: 24px;
    width: 400px;
    max-width: calc(100vw - 32px);
    background: var(--bg-surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-drawer);
    z-index: 40;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3.5px;
    background: var(--tartan-ribbon);
    z-index: 2;
}

.sidebar.hidden {
    transform: translateX(calc(-100% - 24px));
    opacity: 0;
    pointer-events: none;
}

#sidebar-overview {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    overflow-y: auto;
}

/* Custom Elegant Scrollbar for Webkit */
#sidebar-overview::-webkit-scrollbar,
.briefing-content::-webkit-scrollbar,
.accordion-content::-webkit-scrollbar {
    width: 6px;
}
#sidebar-overview::-webkit-scrollbar-track,
.briefing-content::-webkit-scrollbar-track,
.accordion-content::-webkit-scrollbar-track {
    background: transparent;
}
#sidebar-overview::-webkit-scrollbar-thumb,
.briefing-content::-webkit-scrollbar-thumb,
.accordion-content::-webkit-scrollbar-thumb {
    background-color: var(--border-strong);
    border-radius: 10px;
}

.sidebar-header {
    padding: 1.25rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h2 {
    font-family: var(--font-brand);
    font-size: 1.35rem;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.sidebar-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.scotland-pulse {
    background: #fdfbfd;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 1.25rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.scotland-pulse strong {
    color: var(--heather);
}

/* Curated Journeys */
.curated-journeys {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.curated-journeys h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.journey-btn {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    box-shadow: var(--shadow-sm);
}

.journey-btn:hover {
    background: var(--heather-light);
    border-color: var(--heather-border);
    transform: translateY(-1px);
}

.journey-btn.active {
    background: var(--heather);
    color: white;
    border-color: var(--heather-hover);
    box-shadow: 0 4px 12px var(--heather-glow);
}

.journey-btn .icon {
    font-size: 1.25rem;
    margin-top: 2px;
}

.journey-btn .text strong {
    display: block;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.journey-btn.active .text strong {
    color: white;
}

.journey-btn .text span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.journey-btn.active .text span {
    color: rgba(255,255,255,0.85);
}

/* Advanced Explorer Accordion */
.advanced-explorer {
    margin: 0.5rem 1.25rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    overflow: hidden;
}

.accordion-toggle {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border: none;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}

.accordion-toggle:hover {
    background: #f1f5f9;
}

.accordion-content {
    max-height: 0;
    overflow-y: auto;
    transition: max-height 0.3s ease-out;
}

.advanced-category-header {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--heather);
    padding: 0.75rem 1rem 0.25rem;
    border-bottom: 1px solid #f1f5f9;
    background: #fefefe;
}

.advanced-layer-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f8fafc;
    transition: background 0.2s;
}

.advanced-layer-item:hover {
    background: #f1f5f9;
}

.layer-info .layer-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.layer-info .layer-source {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Custom CSS Toggle Switch */
.custom-toggle {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
}

.custom-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-strong);
    transition: .3s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.custom-toggle input:checked + .toggle-slider {
    background-color: var(--heather);
}

.custom-toggle input:checked + .toggle-slider:before {
    transform: translateX(14px);
}

/* Layer Loading States */
.advanced-layer-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.advanced-layer-item.loading .layer-name::after {
    content: '...';
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0% { opacity: .2; }
    20% { opacity: 1; }
    100% { opacity: .2; }
}

/* Live Badge & Category Count */
.live-badge {
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: 700;
    vertical-align: middle;
    margin-right: 4px;
}

.cat-count {
    background: var(--border-subtle);
    color: var(--text-muted);
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: auto;
}

.advanced-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-actions {
    margin-top: auto;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
}

.clear-btn {
    width: 100%;
    padding: 0.6rem;
    background: #fdf2f8;
    color: #db2777;
    border: 1px solid #fbcfe8;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.clear-btn:hover {
    background: #fce7f3;
    border-color: #f9a8d4;
}

/* Briefing Mode */
#sidebar-briefing {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-surface-glass);
}

#sidebar-briefing.hidden {
    display: none;
}

.back-btn {
    background: none;
    border: none;
    color: var(--saltire-blue);
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.back-btn:hover {
    text-decoration: underline;
}

.coords {
    font-family: var(--font-mono);
    color: var(--saltire-blue);
    font-size: 0.75rem;
    margin-top: 2px;
}

.briefing-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.briefing-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    box-shadow: var(--shadow-sm);
}

.briefing-card h4 {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.briefing-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.loader {
    text-align: center;
    color: var(--heather);
    font-style: italic;
    font-size: 0.85rem;
}

/* Floating Bottom Controls: Deep-Time Historical Slider & Quick-Jumps */
.bottom-controls {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    z-index: 40;
    pointer-events: auto;
}

.time-machine-card {
    background: var(--bg-surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 0.65rem 1.15rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 360px;
}

.time-machine-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.time-machine-title {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-brand);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--heather-dark);
    white-space: nowrap;
}

.era-selector-tabs {
    display: flex;
    gap: 3px;
    background: #f1f5f9;
    padding: 2px;
    border-radius: var(--radius-full);
}

.era-tab {
    background: transparent;
    border: none;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.era-tab:hover {
    color: var(--heather);
}

.era-tab.active {
    background: var(--heather);
    color: #ffffff;
    box-shadow: 0 1px 4px var(--heather-glow);
}

.time-slider-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.slider-end-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.slider-end-label.active-era {
    color: var(--heather);
    font-weight: 700;
    background: var(--heather-light);
    border: 1px solid var(--heather-border);
    padding: 2px 7px;
    border-radius: var(--radius-full);
    cursor: pointer;
}

.slider-input {
    flex: 1;
    accent-color: var(--heather);
    cursor: pointer;
}

/* Preset Locations Floating Pill Bar */
.location-pills {
    background: var(--bg-surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 4px 6px;
    display: flex;
    gap: 4px;
    box-shadow: var(--shadow-md);
}

.loc-pill {
    padding: 0.45rem 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.loc-pill:hover {
    background: var(--heather-light);
    border-color: var(--heather-border);
    color: var(--heather);
    transform: translateY(-1px);
}

/* Leaflet & MapLibre Controls Positioning & Light Styling */
.maplibregl-ctrl-top-right,
.leaflet-top.leaflet-right {
    top: 86px !important;
    right: 16px !important;
}

.maplibregl-ctrl-bottom-right,
.leaflet-bottom.leaflet-right {
    bottom: 16px !important;
    right: 16px !important;
}

.leaflet-top.leaflet-left {
    top: 86px !important;
    left: 16px !important;
}

.maplibregl-ctrl-group,
.leaflet-bar {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
    box-shadow: var(--shadow-md) !important;
}

.maplibregl-ctrl-group button,
.leaflet-bar a {
    background-color: var(--bg-surface) !important;
    color: var(--text-secondary) !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    transition: var(--transition);
}

.maplibregl-ctrl-group button:last-child,
.leaflet-bar a:last-child {
    border-bottom: none !important;
}

.maplibregl-ctrl-group button:hover,
.leaflet-bar a:hover {
    background-color: var(--heather-light) !important;
    color: var(--heather) !important;
}

.maplibregl-ctrl-icon {
    filter: none !important;
}

.maplibregl-ctrl-attrib,
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(8px) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
    padding: 2px 6px !important;
}

.maplibregl-ctrl-attrib a,
.leaflet-control-attribution a {
    color: var(--heather) !important;
    text-decoration: none !important;
    font-weight: 600;
}

/* Light, Friendly Scottish Feature Popups */
.maplibregl-popup-content,
.leaflet-popup-content-wrapper {
    background: #ffffff !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-lg) !important;
    font-family: var(--font-ui) !important;
    padding: 0 !important;
    overflow: hidden;
    min-width: 280px;
    max-width: 360px;
}

.leaflet-popup-content {
    margin: 0 !important;
    line-height: normal !important;
}

.leaflet-popup-tip {
    background: #ffffff !important;
}

.leaflet-popup-close-button {
    color: var(--text-muted) !important;
    padding: 8px !important;
}

.popup-container {
    display: flex;
    flex-direction: column;
}

.popup-header-banner {
    background: var(--heather-light);
    border-bottom: 1px solid var(--heather-border);
    padding: 0.75rem 1rem;
    position: relative;
}

.popup-header-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--tartan-ribbon);
}

.popup-title {
    font-family: var(--font-brand);
    font-size: 1rem;
    font-weight: 600;
    color: var(--heather-dark);
    margin-top: 2px;
}

.popup-body {
    padding: 0.85rem 1rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.popup-prop-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 2px 0;
    border-bottom: 1px dotted #f1f5f9;
}

.popup-prop-key {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: capitalize;
}

.popup-prop-val {
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}

.popup-footer {
    padding: 0.65rem 1rem;
    background: #fafbfc;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-link {
    color: var(--saltire-blue);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.popup-link:hover {
    color: var(--saltire-blue-hover);
    text-decoration: underline;
}

/* River Station Gauge Hero Card */
.popup-river-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.4rem;
}

.river-level-box {
    display: flex;
    flex-direction: column;
}

.river-val {
    font-size: 1.35rem;
    font-weight: 800;
    font-family: var(--font-brand);
    color: var(--azure);
    line-height: 1.1;
}

.river-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.river-badge-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.river-state {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.river-state.normal {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.river-state.high {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.river-trend {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Great Trails Hero Card */
.popup-trail-hero {
    display: flex;
    justify-content: space-between;
    background: #fdf2fa;
    border: 1px solid #f3d1f0;
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.4rem;
}

.trail-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.trail-val {
    font-size: 1.05rem;
    font-weight: 700;
    font-family: var(--font-brand);
    color: var(--heather-dark);
}

.trail-lbl {
    font-size: 0.66rem;
    color: var(--text-muted);
}

.popup-props-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.3rem;
}

.popup-prop {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    padding: 2px 0;
    border-bottom: 1px dotted #f1f5f9;
}

/* Responsive Mobile Rules */
@media (max-width: 768px) {
    .app-header {
        top: 8px;
        left: 8px;
        right: 8px;
        padding: 0 0.75rem;
    }
    
    .search-box {
        display: none;
    }

    .drawer {
        top: 76px;
        left: 8px;
        right: 8px;
        width: auto;
        bottom: 80px;
    }

    .bottom-controls {
        bottom: 12px;
        flex-direction: column;
        width: calc(100% - 16px);
    }

    .time-slider-card {
        width: 100%;
        min-width: 0;
    }

    .location-pills {
        overflow-x: auto;
        max-width: 100%;
    }
}
