/* =========================================================================
   Galleries — app.css
   One stylesheet, token-driven. Sections:
   1. Tokens (per city)          6. Panel head: search, chips, summary
   2. Base + utilities           7. Cards + results states
   3. Backdrop                   8. Detail (desktop panel + mobile dialog)
   4. App shell layout           9. Map: chrome, pins, popup, user
   5. Controls (buttons, etc.)  10. Sheets, dialogs, toast, motion
   Mobile layout = (max-width: 768px), (max-height: 520px) and (pointer: coarse)
   — keep in sync with MQ_MOBILE in js/lib/util.js.
   ========================================================================= */

/* ---------- 1. Tokens ---------- */
:root {
    --font-ui: 'Exo 2', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Orbitron', var(--font-ui);

    --fs-12: 0.75rem;
    --fs-13: 0.8125rem;
    --fs-14: 0.875rem;
    --fs-16: 1rem;
    --fs-18: 1.125rem;
    --fs-20: 1.25rem;
    --fs-24: 1.5rem;
    --fs-28: 1.75rem;
    --lh-tight: 1.15;
    --lh-snug: 1.3;
    --lh-body: 1.6;

    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;

    --r-xs: 6px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-pill: 999px;

    --hit: 44px;
    --chip-h: 36px;
    --header-h: 64px;
    --tabbar-h: 60px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    --shadow-1: 0 1px 2px rgb(0 0 0 / .45), 0 2px 8px rgb(0 0 0 / .25);
    --shadow-2: 0 6px 20px rgb(0 0 0 / .45);
    --shadow-3: 0 18px 48px rgb(0 0 0 / .55);
    --glow-sm: 0 0 0 1px color-mix(in srgb, var(--primary) 45%, transparent), 0 4px 18px color-mix(in srgb, var(--primary) 28%, transparent);
    --glow-md: 0 0 0 1px color-mix(in srgb, var(--primary) 60%, transparent), 0 8px 32px color-mix(in srgb, var(--primary) 40%, transparent);

    --dur-1: 120ms;
    --dur-2: 200ms;
    --dur-3: 320ms;
    --ease-out: cubic-bezier(.2, .8, .2, 1);
    --ease-in: cubic-bezier(.4, 0, 1, 1);
    --ease-sheet: cubic-bezier(.32, .72, 0, 1);

    --z-panel: 10;
    --z-detail: 15;
    --z-map-chrome: 20;
    --z-tabbar: 45;
    --z-sheet-backdrop: 39;
    --z-sheet: 40;
}

:root,
:root[data-city="london"] {
    --bg: #0E0718;
    --surface-1: #160C25;
    --surface-2: #201435;
    --surface-3: #2B1C45;
    --border: rgb(255 255 255 / .09);
    --border-strong: rgb(255 255 255 / .18);
    --text: #F5F0FF;
    --text-2: #CFC3E6;
    --text-3: #A495C2;
    --primary: #FF71CE;
    --primary-ink: #FF71CE;
    --on-primary: #1A0A2E;
    --secondary: #01CDFE;
    --accent: #05FFA1;
    --tertiary: #B967FF;
    --focus: #01CDFE;
    --st-urgent: #FF7A66;
    --st-new: #01CDFE;
    --st-free: #05FFA1;
    --st-soon: #C49BFF;
    --st-gem: #FFD166;
    --cta: linear-gradient(135deg, #FF71CE, #B967FF 55%, #01CDFE);
    --on-cta: #1A0A2E;
    --pin: linear-gradient(180deg, #FF71CE, #B967FF);
    --pin-solid: #E36BE0;
    --on-pin: #1A0A2E;
    --cluster-ring: #01CDFE;
    --sky: linear-gradient(180deg, #0E0718 0%, #1A0A2E 45%, #3B1260 78%, #6B1F7A 100%);
    --sun: linear-gradient(180deg, #FFE36E 0%, #FF9A62 38%, #FF4FA3 70%, #B13BFF 100%);
    --grid-line: rgb(1 205 254 / .28);
    --grid-line-2: rgb(255 113 206 / .2);
}

:root[data-city="geneva"] {
    --bg: #0B0606;
    --surface-1: #150B0A;
    --surface-2: #1F1110;
    --surface-3: #2B1817;
    --text: #FFF4EE;
    --text-2: #E6D2C9;
    --text-3: #B9A097;
    --primary: #DA291C;
    --primary-ink: #FF6B6B;
    --on-primary: #FFFFFF;
    --secondary: #FFC300;
    --accent: #F2C879;
    --tertiary: #8E1B24;
    --focus: #FFC300;
    --st-urgent: #FF8F6B;
    --st-new: #FFC300;
    --st-free: #7FD8A6;
    --st-soon: #E9B8A8;
    --st-gem: #F2C879;
    --cta: linear-gradient(135deg, #DA291C, #A3161F);
    --on-cta: #FFFFFF;
    --pin: linear-gradient(180deg, #DA291C, #A3161F);
    --pin-solid: #C8241A;
    --on-pin: #FFFFFF;
    --cluster-ring: #FFC300;
    --sky: linear-gradient(180deg, #050505 0%, #1A0505 45%, #4A0A0A 78%, #8E1B24 100%);
    --sun: linear-gradient(180deg, #FFD54A 0%, #FFC300 40%, #FF8C00 100%);
    --grid-line: rgb(255 195 0 / .26);
    --grid-line-2: rgb(230 57 70 / .2);
}

/* ---------- 2. Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font-ui);
    font-size: var(--fs-16);
    line-height: var(--lh-snug);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}

h1, h2, h3, h4, p, ul, ol, figure {
    margin: 0;
}

ul, ol {
    padding: 0;
    list-style: none;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    touch-action: manipulation;
}

button:disabled {
    cursor: default;
}

[hidden] {
    display: none !important;
}

::selection {
    background: color-mix(in srgb, var(--primary) 45%, transparent);
    color: var(--text);
}

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

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.icon {
    width: 20px;
    height: 20px;
    flex: none;
}

.icon-sm {
    width: 16px;
    height: 16px;
}

.noscript {
    position: fixed;
    inset: auto 16px 16px;
    padding: var(--sp-4);
    background: var(--surface-2);
    border-radius: var(--r-md);
}

/* Thin, themed scrollbars on desktop */
@media (hover: hover) and (pointer: fine) {
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--surface-3) transparent;
    }
}

/* ---------- 3. Backdrop (static vaporwave) ---------- */
.backdrop {
    position: fixed;
    inset: 0;
    z-index: -1; /* behind everything without making .app a stacking context */
    background: var(--sky);
    overflow: hidden;
    pointer-events: none;
}

.backdrop-sun {
    display: none;
    position: absolute;
    left: 50%;
    bottom: 28%;
    width: min(46vw, 560px);
    aspect-ratio: 1;
    translate: -50% 0;
    border-radius: 50%;
    background: var(--sun);
    opacity: .55;
    filter: drop-shadow(0 0 60px color-mix(in srgb, var(--primary) 45%, transparent));
    /* Retro horizontal slits */
    -webkit-mask: linear-gradient(180deg, #000 0 52%, transparent 52% 55%, #000 55% 63%, transparent 63% 67%, #000 67% 74%, transparent 74% 79%, #000 79% 85%, transparent 85% 91%, #000 91%);
    mask: linear-gradient(180deg, #000 0 52%, transparent 52% 55%, #000 55% 63%, transparent 63% 67%, #000 67% 74%, transparent 74% 79%, #000 79% 85%, transparent 85% 91%, #000 91%);
}

:root[data-city="geneva"] .backdrop-sun {
    /* Golden peak instead of a sun */
    border-radius: 0;
    width: min(54vw, 640px);
    aspect-ratio: 1.6;
    clip-path: polygon(50% 4%, 63% 30%, 70% 24%, 100% 100%, 0 100%, 34% 36%, 41% 44%);
    -webkit-mask: none;
    mask: none;
    opacity: .4;
}

.backdrop-grid {
    position: absolute;
    left: -50%;
    right: -50%;
    bottom: 0;
    height: 30%;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line-2) 1px, transparent 1px);
    background-size: 64px 40px;
    transform: perspective(380px) rotateX(58deg);
    transform-origin: 50% 0;
    -webkit-mask: linear-gradient(180deg, transparent, #000 35%);
    mask: linear-gradient(180deg, transparent, #000 35%);
}

/* ---------- 4. App shell ---------- */
.app {
    position: relative;
    height: 100dvh;
    display: grid;
    grid-template-rows: var(--header-h) minmax(0, 1fr);
}

.topbar {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: 0 var(--sp-6);
    min-width: 0;
}

.wordmark {
    display: inline-flex;
    align-items: baseline;
    gap: .4em;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--fs-20);
    letter-spacing: .1em;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 14px color-mix(in srgb, var(--primary) 35%, transparent));
}

.wordmark-sm {
    font-size: var(--fs-16);
}

.tagline {
    color: var(--text-3);
    font-size: var(--fs-13);
    letter-spacing: .04em;
    white-space: nowrap;
}

.topbar-end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    min-width: 0;
}

.status-line {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    color: var(--text-3);
    font-size: var(--fs-12);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--st-free);
    box-shadow: 0 0 8px var(--st-free);
    flex: none;
}

.status-dot.is-stale {
    background: var(--st-gem);
    box-shadow: 0 0 8px var(--st-gem);
}

.main {
    display: grid;
    grid-template-columns: clamp(380px, 40vw, 700px) minmax(0, 1fr);
    gap: var(--sp-4);
    padding: 0 var(--sp-6) var(--sp-6);
    min-height: 0;
}

.panel {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: color-mix(in srgb, var(--surface-1) 96%, transparent);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    container: panel / inline-size;
    box-shadow: var(--shadow-2);
}

.panel-head {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-4) var(--sp-3);
    border-bottom: 1px solid var(--border);
}

.mobile-brand {
    display: none;
}

.results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-top: var(--sp-3);
}

.mapwrap {
    position: relative;
    min-height: 0;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    isolation: isolate;
    background: #18171c;
    box-shadow: var(--shadow-2);
}

.map {
    position: absolute;
    inset: 0;
}

.tabbar {
    display: none;
}

.mobile-only {
    display: none;
}

/* Compact desktop */
@media (min-width: 769px) and (max-width: 1099px) {
    :root {
        --header-h: 56px;
    }

    .topbar {
        padding: 0 var(--sp-3);
        gap: var(--sp-3);
    }

    .main {
        gap: var(--sp-3);
        padding: 0 var(--sp-3) var(--sp-3);
    }

    .tagline,
    .topbar .status-line {
        display: none;
    }

    .btn-cta span {
        display: none;
    }
}

@media (min-width: 1100px) and (max-width: 1279px) {
    .tagline {
        display: none;
    }
}

/* ---------- Mobile shell ---------- */
@media (max-width: 768px), (max-height: 520px) and (pointer: coarse) {
    .app {
        display: block;
    }

    .topbar {
        display: none;
    }

    .backdrop {
        display: none;
    }

    .mapwrap {
        position: fixed;
        inset: 0 0 calc(var(--tabbar-h) + var(--safe-bottom)) 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .panel {
        position: fixed;
        inset: 0 0 calc(var(--tabbar-h) + var(--safe-bottom)) 0;
        z-index: var(--z-panel);
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        pointer-events: none;
    }

    .panel-head {
        pointer-events: auto;
        padding: calc(var(--safe-top) + var(--sp-2)) var(--sp-3) var(--sp-2);
        border-bottom: 0;
        gap: var(--sp-2);
    }

    .sort {
        display: none;
    }

    /* Map view: only the floating search + chips are visible */
    .app[data-view="map"] .panel-head {
        background: linear-gradient(180deg, rgb(8 4 14 / .55), rgb(8 4 14 / 0));
        padding-bottom: var(--sp-4);
    }

    .app[data-view="map"] .mobile-brand,
    .app[data-view="map"] .summary,
    .app[data-view="map"] .result-count,
    .app[data-view="map"] .notice {
        display: none;
    }

    .app[data-view="map"] .results {
        visibility: hidden;
    }

    .app[data-view="map"] .chips-wrap {
        margin-inline: calc(-1 * var(--sp-3));
    }

    .app[data-view="map"] .chips {
        padding-inline: var(--sp-3);
    }

    .app[data-view="map"] .search,
    .app[data-view="map"] .city-btn-compact,
    .app[data-view="map"] .chip {
        background: color-mix(in srgb, var(--surface-1) 94%, transparent);
        box-shadow: var(--shadow-2);
    }

    /* List view: an opaque page over the map */
    .app[data-view="list"] .panel {
        background: var(--bg);
        pointer-events: auto;
    }

    .app[data-view="list"] .panel-head {
        background: var(--bg);
        border-bottom: 1px solid var(--border);
    }

    .app[data-view="list"] .mapwrap {
        visibility: hidden;
    }

    .mobile-brand {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--sp-3);
        min-height: 28px;
    }

    .mobile-brand .status-line {
        flex: 1;
        justify-content: flex-end;
    }

    .results {
        pointer-events: auto;
    }

    .tabbar {
        position: fixed;
        inset: auto 0 0 0;
        z-index: var(--z-tabbar);
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        height: calc(var(--tabbar-h) + var(--safe-bottom));
        padding: 0 var(--sp-6) var(--safe-bottom);
        background: var(--surface-1);
        border-top: 1px solid var(--border);
    }

    .mobile-only {
        display: revert;
    }

    .desktop-only {
        display: none !important;
    }
}

/* ---------- 5. Controls ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: var(--hit);
    padding: 0 var(--sp-5);
    border-radius: var(--r-pill);
    border: 1px solid transparent;
    font-size: var(--fs-14);
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: transform var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), background-color var(--dur-2), border-color var(--dur-2);
}

.btn:active {
    transform: scale(.97);
}

.btn-cta {
    background: var(--cta);
    color: var(--on-cta);
    font-weight: 700;
    box-shadow: var(--glow-sm);
}

.btn-primary {
    background: var(--cta);
    color: var(--on-cta);
    font-weight: 700;
}

.btn-secondary {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    padding-inline: var(--sp-3);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    min-height: 36px;
    padding: 0 var(--sp-4);
    font-size: var(--fs-13);
}

@media (hover: hover) {
    .btn-cta:hover {
        box-shadow: var(--glow-md);
    }

    .btn-secondary:hover {
        border-color: color-mix(in srgb, var(--primary) 50%, transparent);
    }

    .btn-ghost:hover {
        color: var(--text);
        background: var(--surface-2);
    }
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: var(--hit);
    height: var(--hit);
    flex: none;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    transition: background-color var(--dur-2), transform var(--dur-1);
}

.icon-btn:active {
    transform: scale(.94);
}

@media (hover: hover) {
    .icon-btn:hover {
        background: var(--surface-3);
    }
}

.city-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    height: 40px;
    padding: 0 var(--sp-3) 0 var(--sp-3);
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: var(--fs-14);
    font-weight: 600;
}

.city-flag {
    font-size: 1.1rem;
    line-height: 1;
}

.city-btn-compact {
    display: none;
    width: var(--hit);
    height: var(--hit);
    padding: 0;
    justify-content: center;
    flex: none;
}

@media (max-width: 768px), (max-height: 520px) and (pointer: coarse) {
    .city-btn-compact {
        display: inline-flex;
    }
}

.menu {
    margin: 0;
    inset: auto;
    padding: var(--sp-1);
    min-width: 180px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    box-shadow: var(--shadow-3);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: var(--hit);
    padding: 0 var(--sp-3);
    border-radius: var(--r-sm);
    text-decoration: none;
    font-weight: 600;
}

.menu-item[aria-checked="true"] {
    color: var(--primary-ink);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.menu-item:hover,
.menu-item:focus-visible {
    background: var(--surface-3);
}

.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.segmented button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 var(--sp-3);
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--text-2);
    font-size: var(--fs-13);
    font-weight: 600;
    white-space: nowrap;
    transition: background-color var(--dur-2), color var(--dur-2);
}

.segmented button[aria-checked="true"] {
    background: var(--surface-3);
    color: var(--text);
    box-shadow: var(--shadow-1);
}

.seg-count {
    color: var(--text-3);
    font-weight: 500;
}

.segmented-sm button {
    min-height: 32px;
    padding: 0 var(--sp-3);
}

.select {
    appearance: none;
    min-height: var(--hit);
    padding: 0 36px 0 var(--sp-3);
    border-radius: var(--r-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%23A495C2' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
    font-size: var(--fs-16);
    max-width: 100%;
}

.select-sm {
    min-height: 34px;
    border-radius: var(--r-pill);
    font-size: var(--fs-13);
    font-weight: 600;
    color: var(--text-2);
    border-color: var(--border);
}

.select option,
.select optgroup {
    background: var(--surface-2);
    color: var(--text);
}

/* ---------- 6. Panel head ---------- */
.search-row {
    display: flex;
    gap: var(--sp-2);
}

.search {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    height: var(--hit);
    border-radius: var(--r-pill);
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: border-color var(--dur-2), box-shadow var(--dur-2);
}

.search:focus-within {
    border-color: color-mix(in srgb, var(--primary) 60%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-3);
    pointer-events: none;
}

.search-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 44px 0 42px;
    border: 0;
    background: transparent;
    font-size: var(--fs-16);
    outline: none;
}

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

.search-input::-webkit-search-cancel-button {
    display: none;
}

.search-clear {
    position: absolute;
    right: 4px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-2);
}

.search-clear:hover {
    background: var(--surface-3);
}

.chips-wrap {
    position: relative;
}

.chips {
    display: flex;
    gap: var(--sp-2);
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    -webkit-mask: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    padding-right: 28px;
}

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

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: none;
    height: var(--chip-h);
    padding: 0 var(--sp-3);
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: var(--surface-3);
    color: var(--text-2);
    font-size: var(--fs-14);
    font-weight: 600;
    white-space: nowrap;
    scroll-snap-align: start;
    transition: background-color var(--dur-2), border-color var(--dur-2), color var(--dur-2), opacity var(--dur-2);
}

.chip .icon {
    width: 16px;
    height: 16px;
}

.chip-count {
    color: var(--text-3);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.chip[aria-pressed="true"],
.chip[role="radio"][aria-checked="true"] {
    background: color-mix(in srgb, var(--primary) 18%, var(--surface-2));
    border-color: var(--primary);
    color: var(--text);
}

.chip[aria-pressed="true"] .chip-count {
    color: var(--text-2);
}

.chip:disabled {
    opacity: .45;
}

.chip-badge {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: var(--r-pill);
    background: var(--primary);
    color: var(--on-primary);
    font-size: var(--fs-12);
    font-weight: 700;
}

.chip-scope {
    background: color-mix(in srgb, var(--secondary) 16%, var(--surface-2));
    border-color: color-mix(in srgb, var(--secondary) 70%, transparent);
    color: var(--text);
    max-width: 220px;
}

.chip-scope span {
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (hover: hover) {
    .chip:not(:disabled):hover {
        border-color: color-mix(in srgb, var(--primary) 45%, transparent);
        color: var(--text);
    }
}

@media (pointer: coarse) {
    .chip {
        position: relative;
    }

    .chip::after {
        content: '';
        position: absolute;
        inset: -4px 0;
    }
}

.summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.result-count {
    color: var(--text-3);
    font-size: var(--fs-13);
    min-height: 1em;
}

.result-count strong {
    color: var(--text-2);
    font-weight: 600;
}

.notice {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: var(--fs-13);
}

.notice-text {
    flex: 1;
}

.notice-warn {
    border-color: color-mix(in srgb, var(--st-gem) 50%, transparent);
    background: color-mix(in srgb, var(--st-gem) 10%, var(--surface-2));
}

.notice .btn-ghost {
    min-height: 32px;
    padding: 0 var(--sp-2);
    font-size: var(--fs-13);
}

/* ---------- 7. Cards ---------- */
.results-list {
    display: grid;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-3) var(--sp-6);
}

.card {
    position: relative;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: var(--sp-3);
    padding: 10px;
    border-radius: var(--r-md);
    background: var(--surface-1);
    border: 1px solid var(--border);
    transition: transform var(--dur-2) var(--ease-out), border-color var(--dur-2), box-shadow var(--dur-2), background-color var(--dur-2);
}

.card:active {
    background: var(--surface-2);
}

.card.is-linked {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.card:has(.card-link:focus-visible) {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.card-link {
    text-decoration: none;
    outline: none;
}

.card-link::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

.media {
    position: relative;
    overflow: hidden;
    border-radius: var(--r-sm);
    background: linear-gradient(135deg, hsl(var(--h, 290) 45% 24%), hsl(calc(var(--h, 290) + 50) 50% 12%));
}

.media-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 240ms ease, transform 300ms var(--ease-out);
}

.media.is-loaded .media-img {
    opacity: 1;
}

.media-fallback {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: .08em;
    color: rgb(255 255 255 / .55);
}

.media.is-empty .media-fallback {
    display: grid;
}

.media.is-empty .media-img {
    display: none;
}

.card-media {
    width: 96px;
    height: 96px;
}

.card-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
}

.card-venue {
    font-size: var(--fs-12);
    font-weight: 600;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-title {
    font-size: var(--fs-16);
    font-weight: 600;
    line-height: var(--lh-snug);
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 6px;
    font-size: var(--fs-13);
    color: var(--text-3);
}

.card-meta>span+span::before {
    content: '·';
    margin-right: 6px;
    color: var(--text-3);
}

.meta-free {
    color: var(--st-free);
    font-weight: 600;
}

.meta-urgent {
    color: var(--st-urgent);
    font-weight: 600;
}

.meta-soon {
    color: var(--st-soon);
    font-weight: 600;
}

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

.card .card-tags {
    margin-top: 2px;
}

.tag {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--r-pill);
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
    border: 1px solid var(--border-strong);
    color: var(--text-2);
    background: color-mix(in srgb, var(--bg) 70%, transparent);
}

.tag-urgent {
    color: var(--st-urgent);
    border-color: color-mix(in srgb, var(--st-urgent) 55%, transparent);
}

.tag-new {
    color: var(--st-new);
    border-color: color-mix(in srgb, var(--st-new) 55%, transparent);
}

.tag-soon {
    color: var(--st-soon);
    border-color: color-mix(in srgb, var(--st-soon) 55%, transparent);
}

.tag-gem {
    color: var(--st-gem);
    border-color: color-mix(in srgb, var(--st-gem) 55%, transparent);
}

.tag-free {
    color: var(--st-free);
    border-color: color-mix(in srgb, var(--st-free) 55%, transparent);
}

/* Media overlays (grid cards) */
.media-tags {
    position: absolute;
    left: 8px;
    top: 8px;
    display: none;
    gap: 6px;
}

.media-tags .tag {
    background: rgb(10 5 18 / .78);
}

.media-distance {
    position: absolute;
    right: 8px;
    top: 8px;
    display: none;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 8px;
    border-radius: var(--r-pill);
    background: rgb(10 5 18 / .78);
    color: var(--text);
    font-size: var(--fs-12);
    font-weight: 700;
}

.media-distance .icon {
    width: 14px;
    height: 14px;
}

/* Wide panel → image-led grid */
@container panel (min-width: 520px) {
    .results-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--sp-4);
        padding: var(--sp-4) var(--sp-4) var(--sp-8);
    }

    .card {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        gap: 0;
        padding: 0;
        overflow: hidden;
        content-visibility: auto;
        contain-intrinsic-size: auto 330px;
    }

    .card-media {
        width: 100%;
        height: auto;
        aspect-ratio: 4 / 3;
        border-radius: 0;
    }

    .card-body {
        justify-content: flex-start;
        padding: var(--sp-3) 14px 14px;
        gap: var(--sp-1);
    }

    .card-title {
        font-size: var(--fs-18);
    }

    .card .card-tags {
        display: none;
    }

    .media-tags,
    .media-distance {
        display: flex;
    }

    @media (hover: hover) {
        .card:hover {
            transform: translateY(-2px);
            border-color: color-mix(in srgb, var(--primary) 35%, transparent);
            box-shadow: var(--shadow-2);
        }

        .card:hover .media-img {
            transform: scale(1.03);
        }
    }
}

@container panel (min-width: 900px) {
    .results-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Skeletons */
.skeleton .media,
.skeleton-line {
    background: var(--surface-2);
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
}

.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-70 { width: 70%; }
.skeleton-line.w-90 { width: 90%; }

.skeleton {
    animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
    50% {
        opacity: .55;
    }
}

/* Empty / error states */
.state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-8) var(--sp-5);
    text-align: center;
    color: var(--text-2);
}

.state-glyph {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--sun);
    -webkit-mask: linear-gradient(180deg, #000 0 55%, transparent 55% 62%, #000 62% 72%, transparent 72% 80%, #000 80%);
    mask: linear-gradient(180deg, #000 0 55%, transparent 55% 62%, #000 62% 72%, transparent 72% 80%, #000 80%);
    opacity: .85;
}

.state-title {
    font-size: var(--fs-18);
    font-weight: 700;
    color: var(--text);
}

.state-text {
    max-width: 36ch;
    font-size: var(--fs-14);
    line-height: var(--lh-body);
}

.state-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--sp-2);
}

.state-suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--sp-2);
    margin-top: var(--sp-2);
}

/* ---------- 8. Detail ---------- */
.detail-panel {
    position: absolute;
    inset: 0;
    z-index: var(--z-detail);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--surface-1);
    animation: detail-in var(--dur-3) var(--ease-out);
}

@keyframes detail-in {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
}

.detail-bar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 56px;
    padding: var(--sp-2) var(--sp-3);
    background: color-mix(in srgb, var(--surface-1) 94%, transparent);
    border-bottom: 1px solid var(--border);
}

.detail-bar .btn-ghost {
    margin-right: auto;
    padding-inline: var(--sp-2);
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-bar .btn-ghost span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-bar .icon-btn {
    width: 40px;
    height: 40px;
}

.detail-hero {
    border-radius: 0;
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    max-height: 52vh;
    width: 100%;
    overflow: hidden;
    background: var(--surface-2);
}

.detail-hero .hero-blur {
    position: absolute;
    inset: -40px;
    width: calc(100% + 80px);
    height: calc(100% + 80px);
    object-fit: cover;
    filter: blur(28px) brightness(.45) saturate(1.2);
    opacity: 0;
    transition: opacity 300ms;
}

.detail-hero .media-img {
    position: relative;
    object-fit: contain;
}

.detail-hero.is-loaded .hero-blur {
    opacity: 1;
}

.detail-hero.media.is-empty {
    aspect-ratio: auto;
    height: 180px;
}

.detail-body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    padding: var(--sp-6);
    max-width: 72ch;
}

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

.detail-title {
    font-size: var(--fs-28);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.005em;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.detail-title:focus {
    outline: none;
}

.detail-venue {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 8px;
    color: var(--text-2);
    font-size: var(--fs-16);
}

.detail-venue .venue-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--primary) 60%, transparent);
    text-underline-offset: 3px;
}

.detail-venue .venue-link:hover {
    text-decoration-color: var(--primary);
}

.facts {
    display: grid;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.fact {
    display: grid;
    grid-template-columns: 20px 1fr;
    gap: var(--sp-3);
    align-items: start;
    font-size: var(--fs-14);
    color: var(--text-2);
}

.fact .icon {
    margin-top: 1px;
    color: var(--text-3);
}

.fact strong {
    display: block;
    color: var(--text);
    font-weight: 600;
    font-size: var(--fs-16);
}

.detail-desc {
    font-size: var(--fs-16);
    line-height: var(--lh-body);
    color: var(--text-2);
    white-space: pre-line;
}

.detail-desc.is-clamped {
    display: -webkit-box;
    -webkit-line-clamp: 8;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.read-more {
    align-self: flex-start;
    margin-top: calc(-1 * var(--sp-2));
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary-ink);
    font-weight: 600;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.detail-actions .btn {
    flex: 1 1 auto;
}

.detail-section {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding-top: var(--sp-2);
}

.section-title {
    font-size: var(--fs-13);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.mini-list {
    display: grid;
    gap: var(--sp-2);
}

.mini {
    position: relative;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: var(--sp-3);
    align-items: center;
    padding: 6px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface-1);
    text-align: left;
    width: 100%;
    transition: background-color var(--dur-2), border-color var(--dur-2);
}

.mini .media {
    width: 56px;
    height: 56px;
    border-radius: 8px;
}

.mini .media-fallback {
    font-size: var(--fs-13);
}

.mini-title {
    font-size: var(--fs-14);
    font-weight: 600;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mini-meta {
    font-size: var(--fs-12);
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (hover: hover) {
    .mini:hover {
        background: var(--surface-2);
        border-color: var(--border-strong);
    }
}

.surprise-note {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-sm);
    background: color-mix(in srgb, var(--primary) 12%, var(--surface-2));
    color: var(--text-2);
    font-size: var(--fs-13);
}

.surprise-note .icon {
    color: var(--primary-ink);
}

/* Mobile detail: full-screen dialog */
.detail-dialog {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--surface-1);
    color: var(--text);
    overflow: hidden;
}

.detail-dialog::backdrop {
    background: rgb(0 0 0 / .6);
}

.detail-dialog[open] {
    display: flex;
    flex-direction: column;
    animation: sheet-up var(--dur-3) var(--ease-sheet);
}

.detail-dialog.is-closing {
    animation: sheet-down 220ms var(--ease-in) forwards;
}

.detail-dialog.is-fading {
    animation: fade-out 120ms linear forwards;
}

@keyframes sheet-up {
    from {
        transform: translateY(100%);
    }
}

@keyframes sheet-down {
    to {
        transform: translateY(100%);
    }
}

@keyframes fade-out {
    to {
        opacity: 0;
    }
}

.detail-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.detail-dialog .detail-bar {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    z-index: 3;
    padding-top: calc(var(--safe-top) + var(--sp-2));
    background: transparent;
    border-bottom-color: transparent;
    transition: background-color var(--dur-2), border-color var(--dur-2);
}

.detail-dialog .detail-bar .icon-btn {
    background: rgb(10 5 18 / .6);
    border-color: rgb(255 255 255 / .14);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.detail-dialog .detail-bar-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity var(--dur-2);
}

.detail-dialog.is-scrolled .detail-bar {
    background: color-mix(in srgb, var(--surface-1) 96%, transparent);
    border-bottom-color: var(--border);
}

.detail-dialog.is-scrolled .detail-bar-title {
    opacity: 1;
}

.detail-dialog .detail-hero {
    max-height: 56dvh;
}

.detail-dialog .detail-hero.media.is-empty {
    height: calc(140px + var(--safe-top));
}

.detail-dialog .detail-body {
    padding: var(--sp-5) var(--sp-5) var(--sp-8);
}

.detail-dialog .detail-title {
    font-size: var(--fs-24);
}

.detail-dialog .detail-actions {
    display: none;
}

.action-bar {
    display: flex;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + var(--safe-bottom));
    background: color-mix(in srgb, var(--surface-1) 97%, transparent);
    border-top: 1px solid var(--border);
}

.action-bar .btn {
    flex: 1;
}

.action-bar .icon-btn {
    width: var(--hit);
}

/* ---------- 9. Map ---------- */
.map-tools {
    position: absolute;
    right: var(--sp-3);
    bottom: var(--sp-3);
    z-index: var(--z-map-chrome);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.fab {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: color-mix(in srgb, var(--surface-1) 94%, transparent);
    color: var(--text);
    box-shadow: var(--shadow-2);
    transition: background-color var(--dur-2), color var(--dur-2), transform var(--dur-1);
}

.fab:active {
    transform: scale(.94);
}

.fab[aria-pressed="true"] {
    background: var(--secondary);
    border-color: var(--secondary);
    color: var(--bg);
}

.fab.is-busy .icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.map-tools .segmented {
    background: color-mix(in srgb, var(--surface-1) 94%, transparent);
    box-shadow: var(--shadow-2);
}

.results-pill {
    position: absolute;
    left: 50%;
    bottom: var(--sp-3);
    z-index: var(--z-map-chrome);
    translate: -50% 0;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    height: 40px;
    padding: 0 var(--sp-4);
    border-radius: var(--r-pill);
    border: 1px solid var(--border-strong);
    background: color-mix(in srgb, var(--surface-1) 96%, transparent);
    color: var(--text);
    font-size: var(--fs-14);
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow-2);
}

.map-fallback {
    position: absolute;
    inset: 0;
    z-index: var(--z-map-chrome);
    display: grid;
    place-content: center;
    gap: var(--sp-3);
    justify-items: center;
    color: var(--text-2);
    background: var(--surface-1);
}

/* Leaflet theming */
.leaflet-container {
    background: #18171c;
    font-family: var(--font-ui);
}

.leaflet-control-zoom {
    border: 0 !important;
    box-shadow: var(--shadow-2) !important;
    border-radius: var(--r-sm) !important;
    overflow: hidden;
}

.leaflet-bar a,
.leaflet-bar button {
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    display: grid !important;
    place-items: center;
    border: 0 !important;
    border-bottom: 1px solid var(--border) !important;
    background: color-mix(in srgb, var(--surface-1) 94%, transparent) !important;
    color: var(--text) !important;
}

.leaflet-bar a:hover,
.leaflet-bar button:hover {
    background: var(--surface-2) !important;
}

.leaflet-bar a.leaflet-disabled {
    color: var(--text-3) !important;
}

.map-reset {
    margin-top: var(--sp-2) !important;
    border-radius: var(--r-sm) !important;
}

.map-reset button {
    cursor: pointer;
    border-bottom: 0 !important;
}

.leaflet-control-attribution {
    background: rgb(10 5 18 / .7) !important;
    color: var(--text-3) !important;
    font-size: 11px;
    border-top-left-radius: 6px;
}

.leaflet-control-attribution a {
    color: var(--text-2) !important;
}

@media (max-width: 768px), (max-height: 520px) and (pointer: coarse) {
    .leaflet-control-zoom,
    .map-reset {
        display: none;
    }

    .leaflet-control-attribution {
        font-size: 10px;
        max-width: 70vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Pins */
.pin-icon,
.cluster-icon {
    background: none;
    border: 0;
}

.pin {
    position: relative;
    width: 32px;
    height: 40px;
    transform-origin: 50% 100%;
    transition: transform var(--dur-2) var(--ease-out);
    filter: drop-shadow(0 3px 4px rgb(0 0 0 / .5));
}

.pin svg {
    width: 32px;
    height: 40px;
    display: block;
}

.pin-shape {
    fill: var(--pin-solid);
    stroke: var(--bg);
    stroke-width: 2;
}

.pin-count {
    position: absolute;
    left: 0;
    right: 0;
    top: 7px;
    text-align: center;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--on-pin);
    line-height: 16px;
}

.pin.is-soon .pin-shape {
    fill: var(--surface-1);
    stroke: var(--pin-solid);
    stroke-width: 2.5;
}

.pin.is-soon .pin-count {
    color: var(--text);
}

.leaflet-marker-icon:hover .pin,
.pin.is-linked {
    transform: scale(1.15);
}

.pin.is-selected {
    transform: scale(1.25);
}

.pin.is-selected .pin-shape {
    stroke: #fff;
    stroke-width: 2.5;
}

.pin.is-selected::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -6px;
    width: 26px;
    height: 10px;
    translate: -50% 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 45%, transparent);
    filter: blur(3px);
}

.pin.is-linked::after,
.cluster.is-linked::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 14px;
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    animation: ring 900ms var(--ease-out) 1;
    opacity: 0;
}

.cluster.is-linked::after {
    top: 50%;
    width: 100%;
    height: 100%;
    margin: 0;
    translate: -50% -50%;
}

@keyframes ring {
    from {
        transform: scale(.6);
        opacity: .9;
    }

    to {
        transform: scale(1.6);
        opacity: 0;
    }
}

.cluster {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: color-mix(in srgb, var(--surface-2) 92%, transparent);
    border: 2px solid var(--cluster-ring);
    color: var(--text);
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--cluster-ring) 16%, transparent), var(--shadow-1);
    transition: transform var(--dur-2) var(--ease-out);
}

.leaflet-marker-icon:hover .cluster,
.cluster.is-linked {
    transform: scale(1.08);
}

/* Visitor */
.user-dot {
    position: relative;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--secondary);
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px rgb(0 0 0 / .3), 0 2px 6px rgb(0 0 0 / .4);
}

.user-dot::after {
    content: '';
    position: absolute;
    inset: -9px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--secondary) 35%, transparent);
    animation: halo 2s ease-out 3;
    opacity: 0;
}

@keyframes halo {
    from {
        transform: scale(.5);
        opacity: 1;
    }

    to {
        transform: scale(1.8);
        opacity: 0;
    }
}

.ring-label {
    background: none;
    border: 0;
}

.ring-label span {
    display: inline-block;
    translate: -50% -50%;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    background: rgb(10 5 18 / .85);
    border: 1px solid color-mix(in srgb, var(--secondary) 55%, transparent);
    color: var(--text);
    font-size: var(--fs-12);
    font-weight: 700;
    white-space: nowrap;
}

/* Venue name tooltip (desktop hover) */
.leaflet-tooltip.pin-tooltip {
    padding: 4px 10px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: var(--fs-13);
    font-weight: 600;
    box-shadow: var(--shadow-2);
}

.leaflet-tooltip.pin-tooltip::before {
    display: none;
}

/* Desktop venue popup */
.venue-popup .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: var(--r-md);
    background: var(--surface-1);
    color: var(--text);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-3);
}

.venue-popup .leaflet-popup-content {
    width: 320px !important;
    margin: 0;
    font-size: var(--fs-14);
    line-height: var(--lh-snug);
}

.venue-popup .leaflet-popup-tip {
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
}

.venue-popup a.leaflet-popup-close-button {
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font: 400 22px/1 var(--font-ui);
    color: var(--text-2);
}

.venue-popup a.leaflet-popup-close-button:hover {
    background: var(--surface-3);
    color: var(--text);
}

.venue-popup .leaflet-popup-content p {
    margin: 0;
}

.leaflet-container a.btn-secondary,
.leaflet-container a.btn-ghost {
    color: var(--text);
}

.leaflet-container a.btn-primary {
    color: var(--on-cta);
}

.venue-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-4);
}

.venue-head {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 32px;
}

.venue-name {
    font-size: var(--fs-18);
    font-weight: 700;
    line-height: 1.2;
}

.venue-meta {
    color: var(--text-2);
    font-size: var(--fs-13);
}

.venue-meta+.venue-meta {
    color: var(--text-3);
}

.venue-more {
    color: var(--text-3);
    font-size: var(--fs-13);
}

.venue-actions {
    display: flex;
    gap: var(--sp-2);
}

.venue-actions .btn {
    flex: 1;
    padding: 0 var(--sp-2);
}

.venue-popup .mini-list {
    max-height: 260px;
    overflow-y: auto;
}

/* ---------- 10. Sheets, dialogs, toast ---------- */
.venue-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom));
    z-index: var(--z-sheet);
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - var(--tabbar-h) - var(--safe-bottom) - var(--safe-top) - 48px);
    background: var(--surface-1);
    border-top: 1px solid var(--border-strong);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: 0 -10px 40px rgb(0 0 0 / .5);
    transform: translateY(100%);
    touch-action: none;
}

.sheet-handle {
    flex: none;
    display: grid;
    place-items: center;
    height: 24px;
    cursor: grab;
}

.sheet-handle::before {
    content: '';
    width: 36px;
    height: 5px;
    border-radius: 3px;
    background: var(--border-strong);
}

.sheet-peek {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: 0 var(--sp-4) var(--sp-4);
}

.sheet-peek .venue-head {
    padding-right: 48px;
}

.sheet-close {
    position: absolute;
    top: 18px;
    right: var(--sp-3);
    width: 40px;
    height: 40px;
}

.sheet-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 0 var(--sp-4) var(--sp-6);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-sheet-backdrop);
    background: rgb(0 0 0 / .4);
    opacity: 0;
    transition: opacity var(--dur-3);
}

.sheet-backdrop.is-visible {
    opacity: 1;
}

/* Filter dialog */
.filter-dialog {
    width: min(440px, 100vw);
    max-width: 100vw;
    max-height: min(88dvh, 860px);
    margin: auto;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    background: var(--surface-1);
    color: var(--text);
    box-shadow: var(--shadow-3);
    overflow: hidden;
}

.filter-dialog[open] {
    display: flex;
    flex-direction: column;
    animation: pop-in var(--dur-3) var(--ease-out);
}

.filter-dialog::backdrop,
.surprise-dialog::backdrop {
    background: rgb(5 2 10 / .7);
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.98);
    }
}

.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    min-height: 60px;
    padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-5);
    border-bottom: 1px solid var(--border);
}

.dialog-title {
    font-size: var(--fs-20);
    font-weight: 700;
}

.dialog-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--sp-4) var(--sp-5) var(--sp-6);
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
}

.dialog-foot {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-5) calc(var(--sp-3) + var(--safe-bottom));
    border-top: 1px solid var(--border);
}

.dialog-foot .btn-primary {
    flex: 1;
}

.fgroup {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    border: 0;
    margin: 0;
    padding: 0;
}

.fgroup-title {
    padding: 0;
    font-size: var(--fs-13);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.fgroup .segmented {
    align-self: flex-start;
}

.fgroup-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.fgroup .chip {
    background: var(--surface-2);
}

.fgroup .chip[aria-pressed="true"],
.fgroup .chip[role="radio"][aria-checked="true"] {
    background: color-mix(in srgb, var(--primary) 18%, var(--surface-2));
}

.more-btn {
    align-self: flex-start;
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary-ink);
    font-weight: 600;
    font-size: var(--fs-14);
}

@media (max-width: 768px), (max-height: 520px) and (pointer: coarse) {
    .filter-dialog {
        width: 100%;
        max-height: 88dvh;
        margin: auto 0 0;
        border-radius: var(--r-lg) var(--r-lg) 0 0;
        border-bottom: 0;
    }

    .filter-dialog[open] {
        animation: sheet-up var(--dur-3) var(--ease-sheet);
    }
}

/* Surprise reveal */
.surprise-dialog {
    width: min(420px, 86vw);
    margin: auto;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    overflow: visible;
}

.surprise-dialog[open] {
    animation: pop-in 240ms var(--ease-out);
}

.reveal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-4);
    cursor: pointer;
}

.reveal-eyebrow {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--fs-14);
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--primary-ink);
    text-shadow: 0 0 18px color-mix(in srgb, var(--primary) 60%, transparent);
}

.reveal-card {
    width: 100%;
    border-radius: var(--r-lg);
    overflow: hidden;
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-3);
    transition: box-shadow var(--dur-3), transform var(--dur-3) var(--ease-out);
}

.reveal-card .media {
    aspect-ratio: 4 / 3;
    border-radius: 0;
}

.reveal-card .media-img {
    opacity: 1;
}

.reveal-text {
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 86px;
}

.reveal-title {
    font-size: var(--fs-20);
    font-weight: 700;
    line-height: 1.2;
}

.reveal-venue {
    color: var(--text-2);
    font-size: var(--fs-14);
}

.reveal.is-cycling .reveal-text {
    filter: blur(3px);
    opacity: .7;
}

.reveal.is-settled .reveal-card {
    box-shadow: 0 0 0 2px var(--primary), 0 0 48px color-mix(in srgb, var(--primary) 45%, transparent), var(--shadow-3);
    transform: scale(1.02);
}

.reveal-hint {
    color: var(--text-3);
    font-size: var(--fs-13);
}

/* Toast */
.toast {
    position: fixed;
    inset: auto 0 calc(var(--sp-6) + var(--safe-bottom)) 0;
    margin: 0 auto;
    width: max-content;
    max-width: min(92vw, 440px);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: var(--fs-14);
    line-height: var(--lh-snug);
    box-shadow: var(--shadow-3);
    display: none;
    align-items: center;
    gap: var(--sp-3);
}

.toast:popover-open {
    display: flex;
    animation: toast-in 180ms var(--ease-out);
}

.toast-action {
    flex: none;
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--primary-ink);
    font-weight: 700;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@media (max-width: 768px), (max-height: 520px) and (pointer: coarse) {
    .toast {
        bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--sp-4));
    }
}

/* Tab bar items */
.tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 100%;
    min-height: var(--hit);
    border: 0;
    background: none;
    color: var(--text-3);
    font-size: var(--fs-12);
    font-weight: 600;
    letter-spacing: .03em;
    transition: color var(--dur-2);
}

.tab[aria-pressed="true"] {
    color: var(--primary-ink);
}

.tab-surprise {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin-top: -22px;
    border-radius: 50%;
    border: 3px solid var(--bg);
    background: var(--cta);
    color: var(--on-cta);
    box-shadow: var(--glow-sm);
    transition: transform var(--dur-1);
}

.tab-surprise .icon {
    width: 26px;
    height: 26px;
}

.tab-surprise:active {
    transform: scale(.94);
}

/* Map/list chrome placement on mobile */
@media (max-width: 768px), (max-height: 520px) and (pointer: coarse) {
    .map-tools {
        bottom: var(--sp-4);
    }

    .results-pill {
        bottom: var(--sp-4);
    }

    .app.has-sheet .map-tools,
    .app.has-sheet .results-pill {
        opacity: 0;
        pointer-events: none;
    }
}

/* Loading */
.app[data-status="loading"] .chips,
.app[data-status="loading"] .summary {
    opacity: .5;
    pointer-events: none;
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
