/* ── CSS custom properties — dark theme (default) ──────────────────────── */
:root {
    /* Backgrounds */
    --bg-body:                  #000510;
    --bg-panel:                 rgba(7, 15, 42, 0.90);
    --bg-panel-hover:           rgba(30, 60, 120, 0.25);
    --bg-panel-hover-strong:    rgba(30, 60, 120, 0.35);
    --bg-dropdown:              rgba(7, 15, 42, 0.97);
    --bg-input:                 rgba(7, 15, 42, 0.90);
    --bg-input-focus:           rgba(7, 15, 42, 0.97);
    --bg-hover-info:            rgba(7, 15, 42, 0.88);
    --bg-attribution:           rgba(5, 12, 40, 0.88);
    --bg-attribution-btn:       rgba(10, 20, 60, 0.75);
    --bg-btn-primary:           rgba(20, 60, 200, 0.28);
    --bg-btn-primary-hover:     rgba(20, 60, 200, 0.45);
    --bg-btn-float:             rgba(20, 60, 200, 0.30);
    --bg-btn-float-hover:       rgba(20, 60, 200, 0.50);
    --bg-btn-secondary:         rgba(255, 255, 255, 0.05);
    --bg-btn-secondary-hover:   rgba(255, 255, 255, 0.10);
    --bg-btn-back:              rgba(255, 255, 255, 0.04);
    --bg-close-btn:             rgba(255, 255, 255, 0.07);
    --bg-handle:                rgba(255, 255, 255, 0.12);
    --bg-card-btn:              rgba(20, 60, 200, 0.22);
    --bg-card-btn-hover:        rgba(20, 60, 200, 0.35);
    --bg-divider:               rgba(60, 100, 200, 0.12);
    --bg-scrollbar:             #1a3060;

    /* Text */
    --text-primary:             #e8f0ff;
    --text-secondary:           #8aabdc;
    --text-muted:               #4a6090;
    --text-label:               #3a5880;
    --text-dim:                 #3a5070;
    --text-dimmer:              #2e4a6a;
    --text-disabled:            #2a3e60;
    --text-placeholder:         #4a6090;
    --text-search-main:         #c8d8f8;
    --text-search-sub:          #3a5880;
    --text-hover-info:          #c8d8ff;
    --text-attribution:         #8898cc;
    --text-attribution-panel:   #9aaad8;
    --text-btn-primary:         #a0bfff;
    --text-btn-primary-hover:   #ccdaff;
    --text-btn-secondary:       #6080a8;
    --text-btn-secondary-hover: #88aad0;
    --text-card-btn:            #6888e0;
    --text-btn-back:            #3a5070;
    --text-nav-item-hover:      #d0deff;

    /* Borders */
    --border-panel:             rgba(70, 110, 210, 0.32);
    --border-panel-focus:       rgba(70, 110, 210, 0.65);
    --border-divider:           rgba(60, 100, 200, 0.15);
    --border-row:               rgba(60, 100, 200, 0.10);
    --border-btn-primary:       rgba(60, 110, 240, 0.45);
    --border-btn-float:         rgba(60, 110, 240, 0.50);
    --border-btn-secondary:     rgba(255, 255, 255, 0.11);
    --border-btn-back:          rgba(255, 255, 255, 0.09);
    --border-card-btn:          rgba(40, 80, 220, 0.38);
    --border-close-btn:         rgba(255, 255, 255, 0.10);

    /* Shadows */
    --shadow-panel:             0 8px 32px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05);
    --shadow-input:             0 8px 32px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
    --shadow-hover-info:        0 2px 8px rgba(0,0,0,0.5);
    --shadow-float:             0 2px 10px rgba(0, 0, 0, 0.45);
    --shadow-float-secondary:   0 2px 10px rgba(0, 0, 0, 0.35);

    /* Chip colors */
    --chip-grey-bg:             rgba(255,255,255,0.05);
    --chip-grey-text:           #6080a8;
    --chip-grey-border:         rgba(255,255,255,0.10);

    /* Search badges */
    --badge-id-bg:              #1e3a80;
    --badge-id-text:            #7090e0;
    --badge-place-bg:           #1a4030;
    --badge-place-text:         #50c080;
    --badge-country-bg:         #3a1a60;
    --badge-country-text:       #b060e0;
    --badge-state-bg:           #3a2a10;
    --badge-state-text:         #d09030;

    /* Landing card (tour.css references these) */
    --bg-landing-blur:          rgba(0, 5, 16, 0.25);
    --bg-landing-card:          rgba(7, 15, 42, 0.93);
    --bg-landing-input:         rgba(255, 255, 255, 0.05);
    --bg-landing-input-focus:   rgba(255, 255, 255, 0.07);
    --border-landing-card:      rgba(70, 110, 210, 0.35);
    --shadow-landing-card:      0 16px 48px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.06);

    /* Tour card gradient stops */
    --bg-tour-opaque:           rgba(8, 16, 48, 0.96);
    --bg-tour-mid:              rgba(8, 16, 48, 0.60);

    /* Mapbox ctrl icon filter (dark bg needs inversion) */
    --ctrl-icon-filter:         invert(1) opacity(0.65);
}

/* ── Light theme overrides ───────────────────────────────────────────────── */
[data-theme="light"] {
    --bg-body:                  #eef2fb;
    --bg-panel:                 rgba(255, 255, 255, 0.93);
    --bg-panel-hover:           rgba(30, 80, 200, 0.08);
    --bg-panel-hover-strong:    rgba(30, 80, 200, 0.13);
    --bg-dropdown:              rgba(255, 255, 255, 0.98);
    --bg-input:                 rgba(255, 255, 255, 0.90);
    --bg-input-focus:           rgba(255, 255, 255, 1);
    --bg-hover-info:            rgba(255, 255, 255, 0.94);
    --bg-attribution:           rgba(255, 255, 255, 0.92);
    --bg-attribution-btn:       rgba(240, 244, 255, 0.90);
    --bg-btn-primary:           rgba(20, 60, 200, 0.10);
    --bg-btn-primary-hover:     rgba(20, 60, 200, 0.22);
    --bg-btn-float:             rgba(20, 60, 200, 0.12);
    --bg-btn-float-hover:       rgba(20, 60, 200, 0.26);
    --bg-btn-secondary:         rgba(0, 0, 0, 0.04);
    --bg-btn-secondary-hover:   rgba(0, 0, 0, 0.08);
    --bg-btn-back:              rgba(0, 0, 0, 0.04);
    --bg-close-btn:             rgba(0, 0, 0, 0.06);
    --bg-handle:                rgba(0, 0, 0, 0.18);
    --bg-card-btn:              rgba(20, 60, 200, 0.10);
    --bg-card-btn-hover:        rgba(20, 60, 200, 0.20);
    --bg-divider:               rgba(60, 100, 200, 0.10);
    --bg-scrollbar:             #bcc8e0;

    --text-primary:             #1a2040;
    --text-secondary:           #2a4a88;
    --text-muted:               #4a5c90;
    --text-label:               #5868a0;
    --text-dim:                 #4a5880;
    --text-dimmer:              #3a4c70;
    --text-disabled:            #8898c0;
    --text-placeholder:         #8090b8;
    --text-search-main:         #1a2040;
    --text-search-sub:          #5060a0;
    --text-hover-info:          #1a2040;
    --text-attribution:         #4a5880;
    --text-attribution-panel:   #4a5880;
    --text-btn-primary:         #1040c0;
    --text-btn-primary-hover:   #0830a0;
    --text-btn-secondary:       #4a5880;
    --text-btn-secondary-hover: #3a4870;
    --text-card-btn:            #1946cc;
    --text-btn-back:            #4a5880;
    --text-nav-item-hover:      #1a2040;

    --border-panel:             rgba(70, 110, 210, 0.22);
    --border-panel-focus:       rgba(70, 110, 210, 0.55);
    --border-divider:           rgba(60, 100, 200, 0.12);
    --border-row:               rgba(60, 100, 200, 0.08);
    --border-btn-primary:       rgba(40, 80, 220, 0.35);
    --border-btn-float:         rgba(40, 80, 220, 0.38);
    --border-btn-secondary:     rgba(0, 0, 0, 0.12);
    --border-btn-back:          rgba(0, 0, 0, 0.10);
    --border-card-btn:          rgba(40, 80, 220, 0.28);
    --border-close-btn:         rgba(0, 0, 0, 0.10);

    --shadow-panel:             0 4px 20px rgba(0,0,0,0.10), inset 0 1px 0 rgba(255,255,255,0.80);
    --shadow-input:             0 4px 16px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.80);
    --shadow-hover-info:        0 2px 8px rgba(0,0,0,0.15);
    --shadow-float:             0 2px 10px rgba(0, 0, 0, 0.15);
    --shadow-float-secondary:   0 2px 10px rgba(0, 0, 0, 0.10);

    --chip-grey-bg:             rgba(0,0,0,0.05);
    --chip-grey-text:           #505870;
    --chip-grey-border:         rgba(0,0,0,0.12);

    --badge-id-bg:              #dce6ff;
    --badge-id-text:            #1540a0;
    --badge-place-bg:           #d4f0e4;
    --badge-place-text:         #1a6040;
    --badge-country-bg:         #eeddff;
    --badge-country-text:       #6020a0;
    --badge-state-bg:           #fff0d4;
    --badge-state-text:         #7a4800;

    --bg-landing-blur:          rgba(255, 255, 255, 0.20);
    --bg-landing-card:          rgba(255, 255, 255, 0.96);
    --bg-landing-input:         rgba(0, 0, 0, 0.04);
    --bg-landing-input-focus:   rgba(0, 0, 0, 0.06);
    --border-landing-card:      rgba(70, 110, 210, 0.25);
    --shadow-landing-card:      0 8px 32px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.80);

    --bg-tour-opaque:           rgba(248, 250, 255, 0.96);
    --bg-tour-mid:              rgba(248, 250, 255, 0.60);

    --ctrl-icon-filter:         none;
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
body { margin: 0; padding: 0; background: var(--bg-body); }
#map { position: absolute; top: 0; width: 100vw; height: 100vh; background: var(--bg-body); }

/* ── Hide Mapbox logo + default attribution; replaced by #attribution-toggle ── */
.mapboxgl-ctrl-logo,
.mapboxgl-ctrl-attrib { display: none !important; }

/* ── Custom attribution ⓘ button ─────────────────────────────────────────── */
#attribution-toggle {
    position: fixed;
    bottom: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--bg-attribution-btn);
    color: var(--text-attribution);
    font-size: 13px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    z-index: 200;
    padding: 0;
    transition: color 0.15s, background 0.15s;
}
#attribution-toggle:hover,
#attribution-toggle.active { color: #fff; background: rgba(25, 70, 255, 0.55); }

#attribution-panel {
    position: fixed;
    bottom: 36px;
    right: 8px;
    background: var(--bg-attribution);
    color: var(--text-attribution-panel);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 11px;
    white-space: nowrap;
    display: none;
    z-index: 200;
    backdrop-filter: blur(4px);
    border: 1px solid var(--border-panel);
}
#attribution-panel.open { display: block; }
#attribution-panel a { color: var(--text-attribution); text-decoration: none; }
#attribution-panel a:hover { color: var(--text-primary); text-decoration: underline; }

/* ── Theme toggle button ──────────────────────────────────────────────────── */
#theme-toggle {
    position: fixed;
    bottom: 36px;
    right: 8px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--bg-attribution-btn);
    color: var(--text-attribution);
    font-size: 12px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    z-index: 200;
    padding: 0;
    transition: color 0.15s, background 0.15s;
}
#theme-toggle:hover { color: var(--text-primary); background: rgba(25, 70, 255, 0.55); }

/* shift attribution panel up past the theme + layers buttons */
#attribution-panel { bottom: 90px; }

/* ── View layers ◧ button + panel (pin-coloring mode) ─────────────────────── */
/* Corner column reads ◧ / ☀ / ⓘ top-to-bottom. */
#layers-toggle {
    position: fixed;
    bottom: 64px;
    right: 8px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--bg-attribution-btn);
    color: var(--text-attribution);
    font-size: 12px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    z-index: 200;
    padding: 0;
    transition: color 0.15s, background 0.15s;
}
#layers-toggle:hover,
#layers-toggle.active { color: var(--text-primary); background: rgba(25, 70, 255, 0.55); }

#layers-panel {
    position: fixed;
    bottom: 92px;
    right: 8px;
    background: var(--bg-attribution);
    color: var(--text-attribution-panel);
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 12px;
    z-index: 200;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid var(--border-panel);
}
.layers-panel-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-label);
    margin-bottom: 4px;
}
.layers-radio {
    display: block;
    padding: 2px 0;
    cursor: pointer;
    white-space: nowrap;
}
.layers-radio input { margin-right: 6px; }

.layers-legend {
    list-style: none;
    margin: 6px 0 0;
    padding: 6px 0 0;
    border-top: 1px solid var(--border-panel);
    font-size: 11px;
    color: var(--text-attribution);
}
.layers-legend li {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 1px 0;
    white-space: nowrap;
}
.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.home-control {
    cursor: pointer;
    position: absolute;
    top: 0.5em;
    left: 0.5em;
    border: 1px solid #0e2894;
    border-radius: 5px;
    background-color: #ffffff;
    width: 1.95em;
    height: 1.95em;
    z-index: 999;
    text-align: center;
}
.back-control {
    left: 3em;
    cursor: pointer;
    position: absolute;
    top: 0.5em;
    border: 1px solid #0e2894;
    border-radius: 5px;
    background-color: #ffffff;
    width: 1.95em;
    height: 1.95em;
    z-index: 999;
    text-align: center;
}
.back-control i { margin-top: 0.1em; }

.list-points {
    position: absolute;
    bottom: 3.5em;
    font-family: roboto;
    font-size: 14px;
    overflow-wrap: break-word;
    padding: 5px;
    opacity: 0.6;
    right: 0.5em;
    overflow-y: auto;
    scrollbar-width: thin;
    border: 1px solid #2d56ff;
    border-radius: 5px;
    background-color: #ffffff;
    width: auto;
    min-width: 300px;
    min-height: 25vh;
    max-height: 75vh;
    z-index: 999;
}
.list-points::-webkit-scrollbar { width: 8px; }
.list-points::-webkit-scrollbar-thumb {
    border-radius: 5px;
    -webkit-box-shadow: inset 0 0 7px rgb(0 40 114);
}
#list-points { font-size: 12px; }

.hover-info {
    display: none;
    position: fixed;
    pointer-events: none;
    z-index: 20;
    font-family: sans-serif;
    padding: 4px 8px;
    width: fit-content;
    border: 1.5px solid rgba(25, 70, 255, 0.55);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-hover-info);
    background: var(--bg-hover-info);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 5px;
    box-shadow: var(--shadow-hover-info);
    white-space: nowrap;
    transform: translate(14px, 14px);
}

/* ── Sidebar card ────────────────────────────────────────────────────────── */
.section-aside {
    position: absolute;
    top: 14px;
    left: 14px;
    width: 240px;
    max-height: calc(100vh - 28px);
    background: var(--bg-panel);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-panel);
    border-radius: 10px;
    box-shadow: var(--shadow-panel);
    overflow: hidden;
    z-index: 2;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.history-section {
    position: absolute;
    z-index: 2;
    right: 0px;
    top: 10px;
    display: flex;
    flex-direction: column;
    margin-right: 10px;
    background: var(--bg-panel);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-panel);
    border-radius: 10px;
    box-shadow: var(--shadow-panel);
    overflow: hidden;
}

.history-section button {
    background-color: transparent;
    border: 0;
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    height: 29px;
    outline: none;
    overflow: hidden;
    padding: 0;
    width: 29px;
    color: var(--text-secondary);
}

.history-section button:hover { background: var(--bg-panel-hover-strong); }

.mapboxgl-popup-content {
    min-width: 60px;
    padding: 0.25rem 1rem;
    text-align: center;
    text-transform: uppercase;
    font-weight: 600;
    color: #555;
}

.history-section button > * { pointer-events: none; }

.history-section .disabled-btn {
    pointer-events: none;
    color: var(--text-disabled);
}

.history-section button+button {
    border-top: 1px solid var(--border-divider);
}

/* Visually separate the zoom pair from the globe/back/forward group with a
   small band of the panel background, so the combined toolbar still reads as
   two logical groups. */
.history-section .hist-group-sep {
    border-top: 0;
    margin-top: 6px;
}

/* ── Mapbox built-in controls ────────────────────────────────────────────── */
.mapboxgl-ctrl-group {
    background: var(--bg-panel) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-panel) !important;
    border-radius: 10px !important;
    box-shadow: var(--shadow-panel) !important;
    overflow: hidden;
}

.mapboxgl-ctrl-group button {
    background-color: transparent !important;
    width: 29px !important;
    height: 29px !important;
}

.mapboxgl-ctrl-group button:hover {
    background-color: var(--bg-panel-hover-strong) !important;
}

.mapboxgl-ctrl-group button+button {
    border-top: 1px solid var(--border-divider) !important;
}

.mapboxgl-ctrl button .mapboxgl-ctrl-icon {
    filter: var(--ctrl-icon-filter);
}

.d-none { display: none !important; }

/* ── Sign-in gate ─────────────────────────────────────────────────────────
   Shared by the landing card's Explore/Tour sign-in step (index.html, swaps
   in place of #landing-main-view inside #landing-card — already blurred by
   #landing-blur) and the standalone overlay on nearest.html (#gate-overlay /
   #gate-blur / #gate-card, styled the same as #landing-overlay / -blur /
   -card in tour.css since this file loads on both pages). */
.gate-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.gate-subtitle {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 18px;
    line-height: 1.45;
}

/* Mount point for Google's own rendered button (auth.js renderSignInButton) —
   sized/styled by Google, this just centers it. */
.gate-signin-btn {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
    min-height: 40px;
}

.gate-status {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
}

.gate-denied {
    color: #e05c5c;
    margin-bottom: 10px;
}

.gate-back {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: var(--text-dim);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    padding: 2px 0;
}
.gate-back:hover { color: var(--text-secondary); }

/* Signed-in line atop the landing card's permission-gated buttons
   (#landing-actions in index.html) — email + a way to sign in as someone else
   without waiting for a denial. */
.landing-session-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 12px;
    color: var(--text-dim);
}
#landing-session-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.landing-session-switch {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}
.landing-session-switch:hover { color: var(--text-secondary); }

/* Standalone gate overlay for pages with no landing card of their own
   (nearest.html). Mirrors #landing-overlay/-blur/-card in tour.css. */
#gate-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
#gate-blur {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    background: var(--bg-landing-blur);
}
#gate-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 360px;
    margin: 0 20px;
    background: var(--bg-landing-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-landing-card, var(--border-panel));
    border-radius: 14px;
    box-shadow: var(--shadow-landing-card, var(--shadow-panel));
    padding: 28px 26px 24px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    text-align: center;
}

.mapboxgl-marker { cursor: pointer; }
.mapboxgl-marker svg { pointer-events: none; }

.mapboxgl-marker.active {
    background-color: #dfdfdf47;
    border-radius: 50%;
    padding: 3px;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Card components ─────────────────────────────────────────────────────── */

.card-stripe { height: 3px; flex-shrink: 0; }

.card-handle {
    display: none;
    width: 28px;
    height: 3px;
    background: var(--bg-handle);
    border-radius: 2px;
    margin: 7px auto 0;
    flex-shrink: 0;
}

/* Tappable grab-handle for the mobile bottom sheets (nav panel + card).
   Hidden on desktop; shown in the mobile media query below.  The visible
   grabber pill is drawn with ::before so the whole bar is an easy tap target. */
.sheet-handle {
    display: none;
    position: relative;
    height: 20px;
    flex-shrink: 0;
    cursor: pointer;
}
.sheet-handle::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 34px;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-handle);
}

.card-header {
    padding: 11px 14px 9px;
    border-bottom: 1px solid var(--border-divider);
    position: relative;
    flex-shrink: 0;
}

.card-header-flex {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-close {
    position: absolute;
    top: 10px; right: 11px;
    width: 18px; height: 18px;
    background: var(--bg-close-btn);
    border-radius: 50%;
    border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: var(--text-dim);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.card-close-inline { position: static; flex-shrink: 0; }

.card-city {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    line-height: 1.1;
    padding-right: 24px;
}

.card-city-inline { flex: 1; font-size: 14px; padding-right: 0; }

.card-heb {
    font-size: 10px;
    color: var(--text-dimmer);
    margin-top: 2px;
    direction: rtl;
    text-align: left;
}

.card-sub { font-size: 10.5px; color: var(--text-label); margin-top: 3px; }

.card-ids {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 14px 0;
    flex-shrink: 0;
}

.card-id-latin {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2px;
}

.card-id-sep { font-size: 12px; color: var(--text-disabled); }

.card-id-heb { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

.card-chips {
    display: flex;
    gap: 6px;
    padding: 8px 14px 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 600;
    border: 1px solid;
    white-space: nowrap;
}

.chip-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
    flex-shrink: 0;
}

.chip-orange { background: rgba(255,160,0,0.13);  color: #ffa822; border-color: rgba(255,160,0,0.28); }
.chip-red    { background: rgba(230,57,57,0.13);   color: #f07070; border-color: rgba(230,57,57,0.28); }
.chip-yellow { background: rgba(245,216,0,0.13);   color: #e8cc20; border-color: rgba(245,216,0,0.28); }
.chip-green  { background: rgba(45,179,74,0.13);   color: #50cc70; border-color: rgba(45,179,74,0.28); }
.chip-blue   { background: rgba(60,110,255,0.13);  color: #7090ff; border-color: rgba(60,110,255,0.28); }
.chip-grey   { background: var(--chip-grey-bg);    color: var(--chip-grey-text); border-color: var(--chip-grey-border); }

/* Unrated: 96% of records carry no accuracy code.  Dashed border so it reads as
   a gap in the data rather than a value on the accuracy scale, and the label is
   long enough that it wraps to its own row in .card-chips — deliberately. */
.chip-unverified {
    background: transparent;
    color: var(--chip-grey-text);
    border-color: var(--chip-grey-border);
    border-style: dashed;
    font-weight: 500;
}
.chip-unverified .chip-dot { opacity: 0.5; }

/* Light-mode chip text adjustments for readability */
[data-theme="light"] .chip-orange { color: #b06800; }
[data-theme="light"] .chip-red    { color: #b02020; }
[data-theme="light"] .chip-yellow { color: #8a7000; }
[data-theme="light"] .chip-green  { color: #1a7030; }
[data-theme="light"] .chip-blue   { color: #1040c0; }

.card-divider {
    height: 1px;
    background: var(--bg-divider);
    margin: 0 14px;
    flex-shrink: 0;
}

.card-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.card-body::-webkit-scrollbar { width: 4px; }
.card-body::-webkit-scrollbar-thumb { background: var(--bg-scrollbar); border-radius: 4px; }

.card-story {
    padding: 9px 14px 8px;
    font-size: 10.5px;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.55;
    flex-shrink: 0;
}

/* Empty-state variant: no description on record — muted, non-italic so it
   reads as a system note rather than a quote. */
.card-story-empty {
    font-style: normal;
    opacity: 0.7;
}

/* The correction row at the foot of every card (B20): "know more" + "this
   looks wrong", both deep-linking into the submit form.  Underlined-on-hover
   links rather than buttons — they sit at the bottom of the card body and must
   not compete with "See full record →" in the footer. */
.card-ask-row {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
    padding: 2px 14px 10px;
    flex-shrink: 0;
}

.card-ask {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
}
.card-ask:hover { color: var(--text-primary); text-decoration: underline; }

/* "This looks wrong" is the secondary of the two — same size, lighter weight,
   so the row reads as one invitation with a fallback, not two competing CTAs. */
.card-ask-wrong { font-weight: 500; opacity: 0.85; }

.card-footer {
    padding: 8px 14px 12px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.card-btn-main {
    flex: 1;
    padding: 7px;
    background: var(--bg-card-btn);
    border: 1px solid var(--border-card-btn);
    border-radius: 6px;
    color: var(--text-card-btn);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    letter-spacing: 0.2px;
}

.card-btn-main:hover { background: var(--bg-card-btn-hover); }

.card-btn-back {
    display: none;
    padding: 7px 13px;
    background: var(--bg-btn-back);
    border: 1px solid var(--border-btn-back);
    border-radius: 7px;
    color: var(--text-btn-back);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.card-field {
    display: flex;
    gap: 0.5rem;
    padding: 6px 14px;
    border-bottom: 1px solid var(--border-row);
    font-size: 11px;
}

.card-field-label {
    font-weight: 600;
    color: var(--text-label);
    min-width: 90px;
    flex-shrink: 0;
}

.card-field-value {
    color: var(--text-secondary);
    word-break: break-word;
}

.card-group-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 7px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-row);
    font-size: 12px;
    color: var(--text-secondary);
}

.card-group-item:hover { background: var(--bg-panel-hover); }

.card-back-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    white-space: nowrap;
}

/* ── Nav panel ───────────────────────────────────────────────────────────── */
.nav-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 210px;
    max-height: 55vh;
    background: var(--bg-panel);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-panel);
    border-radius: 10px;
    box-shadow: var(--shadow-panel);
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
}

.nav-panel-header {
    padding: 11px 14px 9px;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-divider);
    min-height: 18px;
    flex-shrink: 0;
    letter-spacing: -0.2px;
}

.nav-panel-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.nav-panel-body::-webkit-scrollbar { width: 4px; }
.nav-panel-body::-webkit-scrollbar-thumb { border-radius: 4px; background: var(--bg-scrollbar); }

.nav-panel-section-label {
    padding: 6px 14px 2px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-label);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.nav-panel-item {
    padding: 7px 14px;
    cursor: pointer;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-row);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
}

.nav-panel-item:hover {
    background: var(--bg-panel-hover);
    color: var(--text-nav-item-hover);
}

.nav-panel-footer {
    display: none;
    gap: 8px;
    padding: 8px 14px 12px;
    flex-shrink: 0;
    border-top: 1px solid var(--border-divider);
}

.nav-panel-action-btn {
    display: block;
    flex: 1;
    padding: 8px 6px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    box-sizing: border-box;
}

.nav-panel-action-primary {
    background: var(--bg-btn-primary);
    border: 1px solid var(--border-btn-primary);
    color: var(--text-btn-primary);
}
.nav-panel-action-primary:hover {
    background: var(--bg-btn-primary-hover);
    color: var(--text-btn-primary-hover);
}

.nav-panel-action-secondary {
    background: var(--bg-btn-secondary);
    border: 1px solid var(--border-btn-secondary);
    color: var(--text-btn-secondary);
}
.nav-panel-action-secondary:hover {
    background: var(--bg-btn-secondary-hover);
    color: var(--text-btn-secondary-hover);
}

/* ── Nav panel breadcrumb ─────────────────────────────────────────────────── */
.nav-crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1px 3px;
    font-size: 12px;
    line-height: 1.3;
}
.nav-crumb {
    color: var(--text-secondary);
    font-weight: 600;
    border-radius: 4px;
}
.nav-crumb[role="button"] { cursor: pointer; }
.nav-crumb[role="button"]:hover { color: var(--text-nav-item-hover); text-decoration: underline; }
.nav-crumb[role="button"]:focus-visible { outline: 1px solid var(--border-btn-primary); outline-offset: 1px; }
.nav-crumb-current {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.2px;
}
.nav-crumb-sep {
    color: var(--text-label);
    font-weight: 400;
}
.nav-hint {
    margin-top: 6px;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-label);
    letter-spacing: 0;
}

/* ── Nav panel split layout (sub-areas | places, side by side) ────────────── */
#nav-panel:has(.nav-panel-body.split) { width: 320px; }
.nav-panel-body.split {
    display: flex;
    flex-direction: row;
    overflow: hidden;
}
.nav-panel-body.split .nav-panel-section {
    flex: 1 1 50%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.nav-panel-body.split #nav-panel-polygons {
    border-right: 1px solid var(--border-divider);
}
.nav-panel-body.split .nav-panel-section-label { flex-shrink: 0; }
.nav-panel-body.split #nav-panel-polygon-list,
.nav-panel-body.split #nav-panel-point-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    scrollbar-width: thin;
}
.nav-panel-body.split #nav-panel-polygon-list::-webkit-scrollbar,
.nav-panel-body.split #nav-panel-point-list::-webkit-scrollbar { width: 4px; }
.nav-panel-body.split #nav-panel-polygon-list::-webkit-scrollbar-thumb,
.nav-panel-body.split #nav-panel-point-list::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background: var(--bg-scrollbar);
}

/* ── Map loading spinner (destination tiles painting after a far jump) ─────── */
#map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 38px;
    height: 38px;
    margin: -19px 0 0 -19px;
    border-radius: 50%;
    border: 3px solid var(--border-panel, rgba(255, 255, 255, 0.25));
    border-top-color: var(--text-primary, #fff);
    z-index: 998;
    pointer-events: none;
    display: none;
    animation: map-loading-spin 0.8s linear infinite;
}
#map-loading.show { display: block; }
@keyframes map-loading-spin { to { transform: rotate(360deg); } }

/* ── Search bar ──────────────────────────────────────────────────────────── */
#search-container {
    position: absolute;
    top: 10px;
    right: 50px;
    width: 270px;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#search-input {
    width: 100%;
    padding: 8px 12px;
    box-sizing: border-box;
    border: 1px solid var(--border-panel);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-search-main);
    font-size: 13px;
    outline: none;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--shadow-input);
}

#search-input::placeholder { color: var(--text-placeholder); }
#search-input:focus {
    border-color: var(--border-panel-focus);
    background: var(--bg-input-focus);
}

#search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    background: var(--bg-dropdown);
    border: 1px solid var(--border-panel);
    border-radius: 10px;
    max-height: 340px;
    overflow-y: auto;
    box-shadow: var(--shadow-panel);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    scrollbar-width: thin;
}

#search-results::-webkit-scrollbar { width: 4px; }
#search-results::-webkit-scrollbar-thumb { background: var(--bg-scrollbar); border-radius: 4px; }

.search-result-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-row);
    color: var(--text-secondary);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.search-result-active { background: var(--bg-panel-hover); }

.search-badge {
    flex-shrink: 0;
    margin-top: 2px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 2px 5px;
    border-radius: 3px;
    text-transform: uppercase;
}
.search-badge-id      { background: var(--badge-id-bg);      color: var(--badge-id-text); }
.search-badge-place   { background: var(--badge-place-bg);   color: var(--badge-place-text); }
.search-badge-country { background: var(--badge-country-bg); color: var(--badge-country-text); }
.search-badge-state   { background: var(--badge-state-bg);   color: var(--badge-state-text); }

.search-result-body { flex: 1; min-width: 0; }

.search-result-main {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-search-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-sub {
    font-size: 11px;
    color: var(--text-search-sub);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Discovery buttons (Tanya of the Week + I'm Feeling Lucky) ────────────── */
/* Sit just below the search input, inside #search-container so they inherit its
   explore-only show/hide.  #search-results is absolute, so it floats over these
   when a search is active. */
#discover-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

#discover-actions button {
    flex: 1;
    padding: 7px 8px;
    border: 1px solid var(--border-panel);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-search-main);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--shadow-input);
    transition: background 0.15s, border-color 0.15s;
}

#discover-actions button:hover:not(:disabled) {
    background: var(--bg-input-focus);
    border-color: var(--border-panel-focus);
}

#discover-actions button:disabled {
    opacity: 0.45;
    cursor: default;
}

/* Tanya-of-the-Week badge injected into the card header by discover.js */
.card-totw-badge {
    display: inline-block;
    margin-bottom: 8px;
    padding: 3px 9px;
    border-radius: 999px;
    background: linear-gradient(90deg, #f5d800, #ffb300);
    color: #3a2c00;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* ── Float action buttons ────────────────────────────────────────────────── */
#float-actions {
    position: fixed;
    bottom: 1.25rem;
    /* Clear of the ⓘ / theme-toggle column (fixed at right 8px, 22px wide) —
       at 1.25rem the Contact pill sat on top of both toggles. */
    right: 2.75rem;
    z-index: 1000;
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
}

#submit-btn-float,
#nearest-link-float,
#contact-link-float {
    padding: 0.55rem 1.05rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 999px;
    white-space: nowrap;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

#submit-btn-float {
    background: var(--bg-btn-float);
    border: 1px solid var(--border-btn-float);
    color: var(--text-btn-primary);
    box-shadow: var(--shadow-float);
}
#submit-btn-float:hover {
    background: var(--bg-btn-float-hover);
    color: var(--text-btn-primary-hover);
    transform: translateY(-1px);
}

#nearest-link-float,
#contact-link-float {
    background: var(--bg-btn-secondary);
    border: 1px solid var(--border-btn-secondary);
    color: var(--text-btn-secondary);
    box-shadow: var(--shadow-float-secondary);
}
#nearest-link-float:hover,
#contact-link-float:hover {
    background: var(--bg-btn-secondary-hover);
    color: var(--text-btn-secondary-hover);
    transform: translateY(-1px);
}

/* ── App-menu drawer + burger (mobile) ────────────────────────────────────────
   Reuses the panel tokens (--bg-panel/--shadow-panel/--border-panel) so it reads
   as the same surface as the nav sheet. The burger is display:none on desktop
   (shown only in the ≤640px block), and the drawer stays off-canvas +
   visibility:hidden until opened — so it's inert and out of the tab order on
   desktop even though the markup is always present. */
#menu-toggle { display: none; }

#drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
}
#drawer-scrim.open { opacity: 1; }

#app-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    z-index: 1600;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    box-shadow: var(--shadow-panel);
    border-right: 1px solid var(--border-panel);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.28s;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app-drawer.open { transform: translateX(0); visibility: visible; }

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px 12px 16px;
    border-bottom: 1px solid var(--border-divider);
}
.drawer-title { font-weight: 600; color: var(--text-primary); font-size: 15px; }
.drawer-close {
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    border-radius: 10px;
}
.drawer-close:hover { background: var(--bg-panel-hover-strong); color: var(--text-primary); }

.drawer-body {
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 2px;
    overflow-y: auto;
}

.drawer-row {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    text-decoration: none;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
}
.drawer-link:hover { background: var(--bg-panel-hover); color: var(--text-primary); }
.drawer-switch-row { justify-content: space-between; cursor: default; }
/* Switch rows can carry a second-line hint (Lite mode), so the label stacks. */
.drawer-switch-row > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.drawer-row-hint { font-size: 11px; font-weight: 400; color: var(--text-label); }

.drawer-section-label {
    padding: 14px 12px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-search-sub);
}

/* Pin-colors radio rows + mini legend (viewLayers.js drawer surface). */
.drawer-radio-row { min-height: 36px; gap: 8px; }
.drawer-radio-row input { margin: 0; flex: 0 0 auto; }
.drawer-layers-legend {
    border-top: 0;
    margin: 0;
    padding: 2px 12px 8px 34px;
    font-size: 11px;
}
.drawer-about { display: flex; flex-direction: column; padding: 0 12px 12px; }
.drawer-about a {
    color: var(--text-attribution);
    text-decoration: none;
    font-size: 12px;
    padding: 6px 0;
}
.drawer-about a:hover { color: var(--text-primary); text-decoration: underline; }

/* Night-mode toggle switch — built from panel/handle tokens (no new colors). */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 28px;
    flex: 0 0 auto;
}
.switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}
.switch-track {
    position: absolute;
    inset: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-panel);
    border-radius: 999px;
    transition: background 0.2s;
}
.switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: var(--bg-handle);
    border-radius: 50%;
    transition: transform 0.2s;
}
.switch input:checked + .switch-track { background: var(--border-panel-focus); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }

/* ── Mobile layout ───────────────────────────────────────────────────────── */
@media (max-width: 640px) {

    .section-aside {
        top: auto;
        left: 10px;
        right: 10px;
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        width: auto;
        height: auto;
        max-height: 40vh;
        border-radius: 11px;
        overflow-y: auto;
    }

    .card-handle { display: block; }
    .sheet-handle { display: block; }
    .card-btn-back { display: flex; }
    .card-city { font-size: 17px; }

    /* ── Draggable bottom sheet (Phase 3) ─────────────────────────────────────
       Both mobile sheets (#nav-panel, #section-aside) become one tall (88vh),
       edge-to-edge, bottom-anchored surface revealed by a translateY set per
       detent by bottomSheet.js (--sheet-y). id selectors intentionally override
       the .nav-panel / .section-aside class rules below (higher specificity), so
       those blocks keep desktop untouched while these win on mobile. The inner
       .nav-panel-body / .card-body / .story-scroll stay the scroll containers;
       the sheet itself clips. `.dragging` drops the transition for finger-follow. */
    #nav-panel,
    #section-aside {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 88vh;
        max-height: 88vh;
        border-radius: 16px 16px 0 0;
        overflow: hidden;
        z-index: 1000;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        transform: translateY(var(--sheet-y, 100%));
        transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1);
        will-change: transform;
    }
    #nav-panel.dragging,
    #section-aside.dragging { transition: none; }
    /* The nav panel's own tap-handle is the drag grabber; block text-selection /
       native scroll-gestures on the drag zones so the sheet follows cleanly. */
    #nav-panel .sheet-handle,
    #nav-panel-header,
    #section-aside .sheet-handle,
    #section-aside .card-handle,
    #section-aside .card-header,
    #section-aside .story-header { touch-action: none; }
    /* Below FULL the inner list/story must not scroll natively — a body drag then
       unambiguously moves the sheet (no scroll to compete during arbitration).
       At FULL the scroller is restored and bottomSheet.js hands off to it. */
    #nav-panel:not([data-detent="full"]) .nav-panel-body,
    #section-aside:not([data-detent="full"]) .card-body,
    #section-aside:not([data-detent="full"]) .story-scroll {
        overflow: hidden;
        touch-action: none;
    }

    /* Full-width search pill: the history toolbar now sits below it (not to its
       right), so the pill spans the row. Burger + input share the row. */
    #search-container {
        left: calc(10px + env(safe-area-inset-left, 0px));
        right: calc(10px + env(safe-area-inset-right, 0px));
        width: auto;
        top: calc(10px + env(safe-area-inset-top, 0px));
    }

    .search-row {
        display: flex;
        gap: 8px;
        align-items: center;
    }
    .search-row #search-input { flex: 1 1 auto; min-width: 0; }

    /* Burger — opens the app-menu drawer; sits at the left of the search row. */
    #menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 1px solid var(--border-panel);
        border-radius: 12px;
        background: var(--bg-input);
        color: var(--text-search-main);
        font-size: 18px;
        line-height: 1;
        cursor: pointer;
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        box-shadow: var(--shadow-input);
    }

    /* Discover buttons → horizontal swipeable chip row. */
    #discover-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #discover-actions::-webkit-scrollbar { display: none; }
    #discover-actions button {
        flex: 0 0 auto;
        border-radius: 999px;
        white-space: nowrap;
    }

    #float-actions { display: none; }

    /* Desktop floating chrome folds into the drawer on mobile. */
    #theme-toggle,
    #attribution-toggle,
    #attribution-panel,
    #layers-toggle,
    #layers-panel { display: none; }

    /* History → horizontal ‹ 🌐 › cluster, top-right below the search pill.
       Zoom ± removed (pinch covers it); back/globe/forward reordered so the
       cluster reads back-home-forward left-to-right regardless of DOM order. */
    #zoom-in-button,
    #zoom-out-button { display: none; }

    .history-section {
        flex-direction: row;
        /* Sit below the whole search-container, not just the pill: #discover-actions
           stacks ABOVE the search row, so the container runs ~92px tall (10px top +
           discover chips + 44px search row). The old 66px landed the cluster on top
           of the search input's right end ("collisions" report). 102px clears it. */
        top: calc(102px + env(safe-area-inset-top, 0px));
        right: calc(10px + env(safe-area-inset-right, 0px));
        margin-right: 0;
    }
    .history-section button + button { border-top: 0; }
    .history-section .hist-group-sep { border-top: 0; margin-top: 0; }
    #back-button  { order: 1; }
    #globe-button { order: 2; }
    #next-button  { order: 3; }

    .nav-panel {
        top: auto;
        left: 10px;
        right: 10px;
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        width: auto;
        height: auto;
        max-height: 40vh;
        border-radius: 11px;
        font-size: 12px;
    }

    /* 16px inputs stop iOS from focus-zooming the page (desktop keeps 13px). */
    #search-input { font-size: 16px; }

    /* Submit / Contact now live in the app-menu drawer on mobile. */
    .nav-panel-footer { display: none; }

    /* Keep the split panel full-width as a bottom sheet on mobile (overrides the
       desktop :has() width bump). The two columns still sit side by side. */
    #nav-panel:has(.nav-panel-body.split) { width: auto; }
}

/* ── Touch targets ───────────────────────────────────────────────────────────
   On coarse pointers (phones/tablets) bump the interactive toolbar buttons to
   the 44px minimum. Desktop-only chrome (#theme-toggle/#attribution-toggle,
   already hidden on mobile) is untouched. */
@media (pointer: coarse) {
    .history-section button {
        width: 44px;
        height: 44px;
    }

    .mapboxgl-ctrl-group button {
        width: 44px !important;
        height: 44px !important;
    }
}

/* ── Record cards: cover thumbnail + story view ─────────────────────────────
   Summary card grows a vertical Tanya-cover thumbnail when the record has one
   (details.json / picture-index).  The story view is the tour-style immersive
   record: full-height gradient side panel, panorama pin re-centred in the
   remaining space (computePinPadding measures the panel's right edge). */

.card-body-with-thumb {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.card-body-text { flex: 1; min-width: 0; }
.card-cover-thumb {
    width: 64px;
    aspect-ratio: 2 / 3;          /* vertical sefer cover */
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-panel);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

.section-aside.story-mode {
    top: 0;
    left: 0;
    bottom: 0;
    height: 100%;
    max-height: none;
    width: min(420px, 88vw);
    border: none;
    border-radius: 0;
    box-shadow: none;
    /* Opaque at the screen edge, fading toward the map — same stops the tour
       cards use, so the two immersive modes read as one visual language. */
    background: linear-gradient(90deg,
        var(--bg-tour-opaque) 0%,
        var(--bg-tour-opaque) 58%,
        var(--bg-tour-mid)   80%,
        rgba(8, 16, 48, 0)  100%);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.story-scroll {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    /* Keep content inside the opaque zone; the right ~120px is the fade. */
    padding: 14px 130px 20px 18px;
    scrollbar-width: thin;
}

.story-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.story-hero {
    width: 100%;
    height: 170px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border-panel);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    margin: 4px 0 10px;
    display: block;
}

.story-title {
    font-size: 19px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
}
.story-heb {
    direction: rtl;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.story-sub {
    font-size: 11.5px;
    color: var(--text-muted);
    margin: 4px 0 10px;
}

.story-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    margin-bottom: 12px;
}

.story-section-title {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-label);
    margin: 14px 0 6px;
}

.story-links a {
    display: block;
    font-size: 12px;
    color: #7ba7ff;
    text-decoration: none;
    margin: 4px 0;
    word-break: break-all;
}
.story-links a:hover { text-decoration: underline; }

.story-pics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.story-pic img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-panel);
    display: block;
}
.story-pic-label {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 3px;
    text-align: center;
}

.story-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-panel);
}

/* The story panel pads itself (.story-scroll), so the ask row drops the
   card-body inset it uses on the summary card. */
.story-scroll > .card-ask-row {
    padding: 10px 0 0;
    font-size: 11px;
}

/* Mobile: story view becomes a tall bottom sheet (no side gradient). */
@media (max-width: 640px) {
    .section-aside.story-mode {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        height: auto;
        max-height: 75vh;
        width: auto;
        border-radius: 14px 14px 0 0;
        background: var(--bg-tour-opaque);
    }
    .story-scroll {
        position: relative;
        inset: auto;
        max-height: 75vh;
        padding: 12px 16px 18px;
    }
}

/* Record focus mode (story + technical views): the immersive record reading
   experience hides the explore chrome — search, Tanya-of-the-Week / I'm
   Feeling Lucky, and the floating submit/contact links.  Keyed off :has() so
   the chrome returns automatically when the card closes (d-none) or drops
   back to the summary (class removed). */
body:has(.section-aside.record-focus:not(.d-none)) #search-container,
body:has(.section-aside.record-focus:not(.d-none)) #submit-btn-float,
body:has(.section-aside.record-focus:not(.d-none)) #nearest-link-float,
body:has(.section-aside.record-focus:not(.d-none)) #contact-link-float {
    display: none;
}

/* Blackbox bug-report button — appears after an uncaught error, or transiently
   as the "copied" confirmation for the Ctrl/Cmd+Shift+B hotkey. */
#bug-report-btn {
    position: fixed;
    right: 14px;
    bottom: 64px;
    z-index: 30;
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #b3261e, #7a1712);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 9px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
    cursor: pointer;
}
#bug-report-btn:hover { filter: brightness(1.15); }
