:root{
    --bg:#fbfcff;
    --surface:#ffffff;
    --ink:#0f172a;
    --muted:#6b7280;
    --line:#e9eef5;
    --line-strong:#dfe6f1;
    --brand:#4f8cff;
    --brand-ink:#ffffff;

    --r-2xl:20px; --r-xl:16px; --r-lg:12px; --r:10px;
    --space-1: .25rem; --space-2:.5rem; --space-3:.75rem; --space-4:1rem; --space-5:1.25rem; --space-6:1.5rem;

    --shadow-1:0 6px 20px rgba(15,23,42,.06);
    --shadow-2:0 12px 32px rgba(15,23,42,.10);
    --ring:0 0 0 3px rgba(79,140,255,.20);

    --mk-base:#6fa1ff;
    --mk-ring:#dce8ff;
    --mk-glow:rgba(111,161,255,.40);
}
html,body{ background:var(--bg); color:var(--ink); }

/* Smooth-ish but respectful motion */
@media (prefers-reduced-motion:no-preference){
    *{ scroll-behavior:smooth; }
}
*{ box-sizing:border-box; }


.map-grid{
    display:grid;
    grid-template-columns:minmax(300px,360px) minmax(0,1fr);
    gap:var(--space-4);
    align-items:start;
}
.sidebar{ order:1; display:flex; flex-direction:column; gap:var(--space-4); }
.content-pane{ order:2; position:relative; min-width:0; }

@media (max-width:1023px){
    .map-grid{ grid-template-columns:1fr; gap:var(--space-4); }
    .content-pane{ order:1; }
    .sidebar{ order:2; }
}


.dashboard-header{
    display:flex; justify-content:space-between; align-items:center; gap:var(--space-3);
    margin-bottom:var(--space-3);
}
.header-actions{
    display:flex; gap:var(--space-2); flex-wrap:wrap;
    padding:.2rem .25rem; border-radius:14px;
    background:linear-gradient(180deg, rgba(0,0,0,.02), rgba(0,0,0,0));
}

.btn{
    padding:.6rem .9rem; border:1px solid var(--line);
    border-radius:12px; background:#fff; color:#334155;
    font-weight:600; cursor:pointer;
    transition:border-color .15s, box-shadow .15s, transform .06s, background .15s, color .15s;
}
.btn:hover{ transform:translateY(-1px); border-color:var(--line-strong); box-shadow:var(--shadow-2); }
.btn:focus-visible{ outline:none; box-shadow:var(--ring); }
.btn-outline{ background:#fff; }

/* Tabs (buttons with .view-tab) */
.view-tab{
    background:#fff; border:1px solid var(--line); color:#334155;
    border-radius:12px;
    transition:background-color .15s ease, color .15s ease, box-shadow .15s ease, border-color .15s ease, transform .06s ease;
}
.view-tab:hover{ background:rgba(79,140,255,.08); transform:translateY(-1px); }
.view-tab.is-active, .view-tab[aria-pressed="true"]{
    background:var(--brand); color:var(--brand-ink); border-color:var(--brand);
    box-shadow:0 8px 24px rgba(79,140,255,.24);
}

#map-btn{ position:relative; padding-left:2.1rem; }
#map-btn::before{
    content:""; position:absolute; left:.6rem; top:50%; transform:translateY(-50%);
    width:18px; height:18px; background-repeat:no-repeat; background-size:18px 18px;
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23334155' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 1 1 18 0z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E");
}
#map-btn.is-active::before, #map-btn[aria-pressed="true"]::before{
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 1 1 18 0z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E");
}

/* Pretty primary tabs for Cards/Calendar/Map */
#cards-btn,#calendar-btn,#map-btn{
    --tab-bg:#fff; --tab-ink:#4b5563; --tab-line:#e7ecf5; --tab-hover:#f7faff;
    --tab-active:var(--brand); --tab-active-ink:#fff;
    display:inline-flex; align-items:center; gap:.55rem;
    padding:.6rem .95rem .6rem 2.1rem; border:1px solid var(--tab-line);
    border-radius:14px; background:var(--tab-bg); color:var(--tab-ink);
    font-weight:700; letter-spacing:.15px; line-height:1;
    transition:transform .06s, border-color .18s, box-shadow .18s, background .18s, color .18s;
    position:relative;
}
#cards-btn:hover,#calendar-btn:hover,#map-btn:hover{
    transform:translateY(-1px); border-color:#dfe6f1; background:var(--tab-hover);
    box-shadow:0 8px 22px rgba(15,23,42,.07);
}
#cards-btn:focus-visible,#calendar-btn:focus-visible,#map-btn:focus-visible{
    outline:none; box-shadow:0 0 0 3px rgba(79,140,255,.22);
}
#cards-btn.is-active,#calendar-btn.is-active,#map-btn.is-active,
#cards-btn[aria-pressed="true"],#calendar-btn[aria-pressed="true"],#map-btn[aria-pressed="true"]{
    background:var(--tab-active); color:var(--tab-active-ink);
    border-color:var(--tab-active);
    box-shadow:0 10px 26px rgba(79,140,255,.26);
}
#calendar-btn{ padding-left:1.1rem; }
#calendar-btn svg{ flex:0 0 18px; height:18px; width:18px; stroke:currentColor; margin-left:-.35rem; }
#calendar-btn.is-active svg,#calendar-btn[aria-pressed="true"] svg{ color:#fff; }
#cards-btn::before{
    content:""; position:absolute; left:.7rem; top:50%; transform:translateY(-50%);
    width:18px; height:18px; background-repeat:no-repeat; background-size:18px 18px;
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
}
#cards-btn.is-active::before,#cards-btn[aria-pressed='true']::before{
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
}
@media (max-width:520px){
    #cards-btn,#calendar-btn,#map-btn{ padding:.55rem .8rem .55rem 2rem; font-weight:600; }
}

/* =========================================================
   VIEW VISIBILITY HELPERS
   ========================================================= */
.view-content{ display:none; }
.view-content.is-visible{ display:block !important; }
.view-content.is-hidden{ display:none !important; }
#cards-view:not(.is-hidden){ display:block; }

/* =========================================================
   CARDS / BASICS
   ========================================================= */
.card{
    border:1px solid var(--line);
    border-radius:var(--r-2xl);
    background:var(--surface);
    box-shadow:var(--shadow-1);
    overflow:hidden;
}
.card-header{ padding:var(--space-4) var(--space-4) var(--space-3); }
.card-title{ margin:0; font-size:1.08rem; font-weight:700; letter-spacing:.2px; }
.card-description{ margin:.25rem 0 0; color:var(--muted); }
.card-content{ padding:var(--space-4); }
.card-content--flush{ padding:0; }

/* Map containers */
#gmaps-container,#discover-map,.map-hero{
    width:100%; height:clamp(460px, 68vh, 760px); min-height:420px;
    border-radius:var(--r-xl); box-shadow:var(--shadow-1);
    background:#f1f5fb;
}

/* Full-bleed helper (global) */
.full-bleed{
    position:relative; width:100vw; left:50%; right:50%;
    margin-left:-50vw; margin-right:-50vw;
}

/* Google/Leaflet tile safety */
.gm-style img { max-width:none !important; max-height:none !important; }
.leaflet-pane img, .leaflet-pane svg { max-width:none !important; max-height:none !important; }

/* =========================================================
   FILTERS — MODERN/COMPACT & MOBILE-FRIENDLY
   ========================================================= */
.filter-shell{ display:flex; flex-direction:column; gap:var(--space-4); }
.filters--sidebar .cardish{
    background:var(--surface); border:1px solid var(--line);
    border-radius:var(--r-2xl); box-shadow:var(--shadow-1); overflow:hidden;
}
.filters--sidebar .cardish-h{
    display:flex; align-items:center; justify-content:space-between; gap:var(--space-2);
    padding: .75rem .9rem; border-bottom:1px solid var(--line);
    background:linear-gradient(180deg, rgba(0,0,0,.00), rgba(0,0,0,.03));
}
.filters--sidebar .cardish-title{ font-weight:800; letter-spacing:.2px; }
.linklike{ background:transparent; border:0; color:var(--brand); cursor:pointer; font-weight:600; }
.linklike:hover{ text-decoration:underline; }
.grid-basic,.grid-adv{ display:grid; grid-template-columns:1fr; gap:var(--space-3); padding:var(--space-3); }
.fgroup{ display:flex; flex-direction:column; gap:.5rem; }
.label{ color:var(--muted); font-size:.92rem; font-weight:600; }
.label.center{ text-align:center; }
.hint{ color:var(--muted); font-size:.85rem; }

.input{
    width:100%; min-height:44px; padding:.7rem .9rem .7rem 2.4rem;
    border:1px solid var(--line); background:var(--surface); color:var(--ink);
    border-radius:12px; box-shadow:inset 0 1px 0 rgba(15,23,42,.03);
    transition:border-color .15s, box-shadow .15s, background .15s, transform .06s;
}
.input:hover{ border-color:var(--line-strong); }
.input:focus{ outline:none; border-color:var(--brand); box-shadow:var(--ring), inset 0 1px 0 rgba(15,23,42,.04); }
.input[type="date"]{ padding-left:.9rem; }
.input[type="range"]{ padding:0; min-height:auto; background:transparent; }

/* Input icons */
#filter-query,#filter-location{ background-repeat:no-repeat; background-position:10px 50%; }
#filter-query{
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%237a869a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
}
#filter-location{
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%237a869a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 1 1 18 0z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E");
}

/* Location row buttons */
.loc-row{ display:flex; flex-direction:column; gap:.5rem; }
@media (min-width:680px){ .loc-row{ flex-direction:row; align-items:center; } }
#btn-use-location{ width:100%; }
@media (min-width:680px){ #btn-use-location{ width:auto; } }

/* Autocomplete dropdown (polished) */
.autocomplete-dropdown{
    position:relative; display:block; margin-top:.35rem;
    border:1px solid var(--line); border-radius:12px; background:#fff; box-shadow:var(--shadow-2);
    overflow:hidden; max-height:300px; overflow-y:auto; z-index:20;
}
.autocomplete-dropdown .item{
    padding:.65rem .85rem; cursor:pointer; display:flex; align-items:center; gap:.5rem;
}
.autocomplete-dropdown .item:hover{ background:#f8fbff; }

/* Radius row */
.radius-row{ display:flex; gap:.75rem; align-items:center; }
#radius-range{
    -webkit-appearance:none; appearance:none; width:100%; height:8px;
    border-radius:999px; background:#f2f5fb; border:1px solid var(--line);
}
#radius-range::-webkit-slider-thumb{
    -webkit-appearance:none; appearance:none; width:18px; height:18px; border-radius:50%;
    background:var(--brand); border:2px solid #fff; box-shadow:0 2px 6px rgba(79,140,255,.35);
}
.radius-val{ color:var(--ink); font-weight:700; min-width:64px; text-align:right; }

/* Dates row: neat two-column on larger screens */
.dates{ display:grid; gap:.5rem; grid-template-columns:1fr; }
@media (min-width:560px){ .dates{ grid-template-columns:1fr 1fr; } }

/* Chips grid */
.framed{
    background:#f9fafb; border:1px solid #e5e7eb; border-radius:14px; padding:12px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.6);
}
.grid-checks{
    display:grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap:.6rem .6rem; padding:4px;
}
.check.chip{ position:relative; display:inline-flex; width:100%; user-select:none; justify-content:center; }
.check.chip input[type="checkbox"]{
    position:absolute; inset:0; opacity:0; cursor:pointer; margin:0;
}
.checks-modern .chip .chip-box{
    display:inline-flex; align-items:center; justify-content:center; gap:.55rem; width:100%;
    border:1px solid #e5e7eb; background:#fff; color:#111827;
    border-radius:9999px; padding:.6rem .9rem; line-height:1.1; min-height:42px;
    transition:background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .12s ease;
    pointer-events:none; font-size:.95rem; font-weight:500;
}
.check.chip:hover .chip-box{ background:#f3f4f6; border-color:#d1d5db; transform:translateY(-1px); }
.check.chip input[type="checkbox"]:focus-visible + .chip-box{
    outline:2px solid transparent; box-shadow:0 0 0 3px rgba(37,99,235,.35);
}
.check.chip input[type="checkbox"]:checked + .chip-box{
    background:#ffa707; color:#fff; border-color:#ffa707; transform:translateY(-1px) scale(1.02);
    box-shadow:0 2px 10px rgba(255,167,7,.35);
}
.checks-modern .chip .chip-icon{ font-size:1rem; opacity:0; transform:scale(.85); transition:opacity .15s ease, transform .15s ease; }
.check.chip input[type="checkbox"]:checked + .chip-box .chip-icon{ opacity:1; transform:scale(1); }
.checks-modern .chip .chip-text{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Ticketmaster chips */
.search-card-badge{
    padding:.45rem .7rem; border:1px solid var(--line); border-radius:999px;
    background:#f9fbff; color:#374151; font-size:.86rem; cursor:pointer; user-select:none;
    transition:border-color .15s, box-shadow .15s, transform .05s, background .15s, color .15s;
}
.search-card-badge:hover{ transform:translateY(-1px); border-color:var(--line-strong); box-shadow:var(--shadow-1); }
.search-card-badge-active{
    background:var(--brand); color:var(--brand-ink); border-color:var(--brand);
    box-shadow:0 6px 18px rgba(79,140,255,.20);
}

/* =========================================================
   RAIL / LISTS
   ========================================================= */
.rail-toolbar{ display:flex; align-items:center; justify-content:space-between; gap:.75rem; margin:.5rem 0 .75rem; }
.rail-count{ color:#3b495c; }
.rail-grid{ display:grid; gap:.9rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (min-width:1280px){ .rail-grid{ grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); } }
.rail-empty{
    text-align:center; padding:1.25rem; border:1px dashed var(--line);
    border-radius:12px; background:#f6f9fe; margin-top:.75rem; color:#4b5563;
}
.rail-empty .emoji{ font-size:1.75rem; }

/* =========================================================
   MAP & CALENDAR VIEWS (UNIFIED RULES)
   ========================================================= */
.map-grid:has(#map-view.is-visible),
.map-grid:has(#calendar-view.is-visible){
    grid-template-columns: 1fr !important;
}
.map-grid:has(#map-view.is-visible) .sidebar,
.map-grid:has(#calendar-view.is-visible) .sidebar{
    display: none !important;
}

/* Map card polish */
#map-view .card-header{
    padding:.75rem 1rem; border-bottom:1px solid var(--line);
    background:linear-gradient(180deg, rgba(0,0,0,.02), rgba(0,0,0,0));
}
#map-view .card-title{ display:flex; align-items:center; gap:.5rem; }
#map-view .card-content{ padding:0; }

/* Map canvas */
#discover-map{
    width:100%; height:clamp(520px, 70vh, 80vh); min-height: 460px;
    border-radius: var(--r-xl); overflow:hidden; box-shadow: var(--shadow-1); background:#f1f6ff;
}
@media (max-width:768px){
    #discover-map{ height:calc(100vh - 140px) !important; min-height:420px !important; }
}
#discover-map:focus{ outline:none; box-shadow:var(--ring); }

/* Neutralise full-bleed only for map when used inside card */
#map-view.full-bleed{
    position:relative !important; left:auto !important; right:auto !important;
    width:100% !important; margin-left:0 !important; margin-right:0 !important;
}

/* Calendar tweaks (stack legend nicely on mobile) */
@media (max-width:1023px){
    .calendar-legend-flex-container{
        display:flex; flex-direction:column; gap:1rem; align-items:stretch !important;
    }
    .calendar-legend-flex-container > *{ width:100% !important; max-width:none !important; flex:none !important; }
    #calendarLegendCard, .calendarLegendCard{ order:1; margin-bottom:.5rem; }
    #discoverCalendarWrapper{ order:2; }
    #ResultsCalendar{ width:100% !important; max-width:none !important; min-width:0; }
}


.flex{ display:flex; }
.flex-wrap{ flex-wrap:wrap; }
.gap-2{ gap:.5rem; }
.gap-3{ gap:.75rem; }
.font-medium{ font-weight:600; }
.cursor-pointer{ cursor:pointer; }
.space-y-2 > * + * { margin-top:.5rem; }

/* Misc */
.leaflet-popup-content svg{ max-height:20px; height:20px; }
.event-card{ max-height:700px; }
