@font-face {
    font-family: 'Union Gothic';
    src: url('../fonts/union_gothic-variable.ttf') format('truetype');
    font-weight: 100 1000; 
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Mort';
    src: url('../fonts/mort-variable.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Folsom';
    src: url('../fonts/folsom-black-web.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}



:root {
    /* Custom Font - Falls back to system fonts */
    --font-sans: 'Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Roboto', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;

    /*padding */
    --side-bar-padding: 6px;

    /* Primary Colours */
    --bg-dark: #222327;
    --bg-panel: #222327;
    --bg-elevated: #5454cb;
    --bg-active: #383975;
    --bg-ticker: #0a0c10;
    --bg-footer: #664cc4;
    --border: #5d5cf5;
    --bg-alt: #6e3e9b;

    --text-primary: #ffff;
    --text-secondary: #f3f3f6;
    --text-tertiary: #c9d1d9;
    --text-quaternary: #bea0d9;
    --text-heading: #e7e7eb;
    --text-muted: #bea0d9;
    --text-really-muted: #8b949e;
    --link: var(--text-quaternary);
    --accent: #5958e5;
    --accent-alt: #2155ff;
    --accent-alt-muted: #7780d7;
    --strike: #e74c3c;
    --lockout: #e67e22;
    --protest: #f1c40f;
    --planned: #3498db;
    --resolved: #2ecc71;
    --other: #95a5a6;
    --glow: rgba(231, 76, 60, 0.4);
    --sidebar-width: 500px;
    --topbar-height: 52px;
    --ticker-height: 32px;
    --selected: #383975;

    /* supporters-wanted highlight */
    --supporters-bg: rgba(255, 209, 102, 0.14);
    --supporters-bg-hover: rgba(255, 209, 102, 0.24);
    --supporters-accent: #ffd166;

    /* Stale badge palette */
    --stale-text: #ffd98a;
    --stale-bg: #3a2d10;
    --stale-border: #7a5c1e;
    --stale-bg-hover: #4a3a15;
    --stale-notice-bg: #2a2110;
    --stale-notice-text: #ffd98a;
    --stale-notice-border: #7a5c1e;

    /* Event type colours */
    --type-strike-color: #ff0011;
    --type-stoppage-color: #ff0011;
    --type-action-color: #c1474f;
    --type-lockout-color: #e67e22;
    --type-protest-color: #f1c40f;
    --type-planned-color: #3498db;
    --type-update-color: #d5d81e;
    --type-resolved-color: #2ecc71;
    --type-ballot-color: #acbfa4;
    --type-scab-color: #804f00;
    --type-ballotpass-color: #b4dea3;
    --type-ballotfail-color: #bfaea4;
    --type-default-color: #95a5a6;
    --type-unkown-color: #95a5a6;

    /* Map Colours */
    --map-background: rgba(30,35,45,0.9);
    --map-border: #3a3f4a;
    --map-centre: #e6edf3;
}

/* ─── Light theme overrides ─── */
html[data-theme="light"] {
    color-scheme: light;

    /* ── Surfaces ─────────────────────────────────────────── */
    --bg-dark: #d2cbcc;
    --bg-panel: #ffffff;
    --bg-elevated: #e7ecf2;
    --bg-active: #d8e0f5;            
    --bg-ticker: #e3e7ee;
    --bg-footer: rgba(255, 255, 255, 0.96);
    --border: #ccd3db;
    --bg-alt: #e5e5e5;

    /* ── Text ─────────────────────────────────────────────── */
    --text-primary: #000000;
    --text-secondary: #333d47;
    --text-tertiary: #232426;
    --text-quaternary: #4b4e52;
    --text-heading: #222222;
    --text-muted: #3f4144;
    --text-really-muted: #6a727a;    
    --link: #5b3fa8;                 

    /* ── Accents & status ─────────────────────────────────── */
    --accent: #db222a;
    --accent-alt: #1a4fd6;           
    --accent-alt-muted: #4f5ab8;     
    --strike: #c0392b;
    --lockout: #b85c00;              
    --protest: #8a7400;             
    --planned: #1f6fa8;              
    --resolved: #1e8449;            
    --other: #5f6b6c;                
    --glow: rgba(231, 76, 60, 0.22);
    --selected: #fcd5d5;

    /* ── Stale badge ──────────────────────────────────────── */
    --stale-text: #7a4a00;
    --stale-bg: #fff3d6;
    --stale-border: #e6c069;
    --stale-bg-hover: #ffe9b3;
    --stale-notice-bg: #fffaf0;
    --stale-notice-text: #6b4a00;
    --stale-notice-border: #e6c069;

    /* ── Event type colours ───────────────────────────────── */
    --type-strike-color: #d40010;    /* was #ff0011 – now ~5.5:1 */
    --type-stoppage-color: #d40010;  /* was #ff0011 – now ~5.5:1 */
    --type-action-color: #a83238;    /* was #c1474f – now ~6.6:1 */
    --type-lockout-color: #b85c00;   /* was #e67e22 – now ~4.5:1 */
    --type-protest-color: #7a6b00;   /* was #b6a200 – now ~5.4:1 */
    --type-planned-color: #1f6fa8;   /* was #3498db – now ~4.7:1 */
    --type-update-color: #7a6b00;    /* was #b6a200 – now ~5.4:1 */
    --type-resolved-color: #1e8449;  /* was #2ecc71 – now ~4.4:1 */
    --type-ballot-color: #5d6e56;    /* was #acbfa4 – now ~5.5:1 */
    --type-scab-color: #804f00;      /* unchanged – already ~6.9:1 */
    --type-ballotpass-color: #3d7a2a;/* was #b4dea3 – now ~5.3:1 */
    --type-ballotfail-color: #7a5f4a;/* was #bfaea4 – now ~5.9:1 */
    --type-default-color: #5f6b6c;   /* was #95a5a6 – now ~4.6:1 */
    --type-unkown-color: #5f6b6c;    /* was #95a5a6 – now ~4.6:1 */

    /* ── Supporters-wanted highlight ──────────────────────── */
    --supporters-bg: rgba(255, 176, 32, 0.16);
    --supporters-bg-hover: rgba(255, 176, 32, 0.28);
    --supporters-accent: #9a6a00;    /* was #c98a00 – now ~4.7:1 */

    /* ── Map ──────────────────────────────────────────────── */
    --map-background: rgba(248, 250, 252, 0.92); /* ADDED */
    --map-border: #b8c0c8;                       /* ADDED */
    --map-centre: #2a3038;                       /* ADDED – dark dot on light map */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

a { color: var(--link); }

/* ─── Main Layout ─── */
#main {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Mobile safe */
    overflow: hidden;
}

#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-panel);
    border-right: 5px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Contain children */
    transition: margin-left 0.3s ease, width 0.3s ease;
    z-index: 900;
    height: 100%;
}

#sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
    min-width: 0;
    width: 0;
    border-right: none;
}

.sidebar-top {
    flex: 0 0 auto; /* Never shrink */
}

.sidebar-scroll {
    flex: 1 1 auto;
    min-height: 120px;              
    overflow-y: auto;
    overscroll-behavior: none;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-scroll::-webkit-scrollbar { width: 5px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Notice Bar */
.notice-bar {
    flex: 0 0 auto;
    position: relative;
    padding: 12px 14px;
    background: linear-gradient(180deg,#2a1f4a,#1e1736);
    border-top: 1px solid rgba(139,92,246,.35);
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary);
}
.notice-bar[hidden] { display: none; }
.notice-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 6px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    line-height: 1;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notice-close:hover{
    background-color: var(--accent);
}

/* Header / Stats / Buttons */
.header {
    display: flex;
    margin-left: auto;
    font-size: 8px;
    padding-left: var(--side-bar-padding);
    padding-top: 10px;
    padding-bottom: 10px;
    border-width: 5px;
    border-color: var(--border);
}

.minor {
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 10px;
    line-height: 1;
    overflow-wrap: anywhere;
    padding:6px;
}
.minor.alt {
    background: var(--bg-alt);
    color: var(--text-secondary);
    border-color: var(--bg-alt);
}
.minor h1 { font-family: "Folsom"; font-size: 12px; text-transform: uppercase; padding-bottom: 3px;}
.minor strong { color: var(--text-primary); }
.minor div {font-family:"Mort"; font-weight: 400;line-height: 1.15;}

.chipcontainer {
    min-width: 100px;
    margin-left: 10px;
    margin-right: var(--side-bar-padding);
    line-height: 2;
    display:grid;
}
.chip {
    background-color: var(--text-heading);
    color: var(--accent);
    border-radius: 10px;
    border-color: var(--accent);
    text-decoration: none;
    padding: 3px 5px;
    margin: 2px;
    text-align: center;
}
.header .chip {
    font-size: 14px;
    display: block;
    font-weight: bold;
    padding: 3px 10px;
}
.header .chip:hover {
    background-color: var(--accent);
    color: var(--text-muted);
}

.tag {
    background-color: var(--text-heading);
    color: var(--accent);
    border-radius: 10px;
    border-color: var(--accent);
    text-decoration: none;
    padding: 0px 5px;
    margin: 2px;
    text-align: center;
}

.buttonsContainer {
    background-color: var(--bg-active);
    border-color: var(--border);
    display: flex;
    gap: 6px;
    width: 100%;
    flex: 3;
    padding: 6px 6px 6px 6px;
    border-width: 5px;
    border-right-style: solid;
}

/* ─── Icon Buttons ─── */

.icon-btn {
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--bg-dark);
  color: var(--text-heading);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;

}
.icon-btn:hover {
  background: var(--accent-alt);
  color: var(--text-primary);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.icon-btn svg { display: block; fill:var(--text-heading)}
.row{
    border-top: solid;
    border-bottom: solid;
    border-right: none;
    border-color: var(--border);
    border-width: 5px;
}

/* ─── Stats Bar ─── */
.stats-bar {
    display: flex;
    gap: 20px;
    padding-left: var(--side-bar-padding);
    font-size: 12px;
    padding: 6px;
    color: var(--text-secondary);
    flex: 1;

}
.stats-bar .stat { text-align: center; white-space: nowrap; }
.stats-bar .stat .number { font-weight: 700; font-size: 20px; font-family:'Mort';color: var(--text-primary); display: block; }
.stats-bar .stat .label { font-size: 8px; font-family:'Union Gothic';text-transform: uppercase; letter-spacing: 0; color: var(--text-muted); line-height: 1; }

/* ─── Sidebar Headers & Search ─── */
.sidebar-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-header h2 {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.search-box {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-active);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family:"Folsom";
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.search-box:focus { border-color: var(--accent); }
.search-box::placeholder { color: var(--text-muted); }

/* ─── Filters ─── */
.filter-section { border-bottom: 1px solid var(--border); flex-shrink: 0; }
.filter-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 4px;
    background: var(--bg-panel);
    border: 0;
    color: var(--text-muted);
    font-family: "Folsom";
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    text-align: left;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s, background 0.15s;
}
.filter-header:hover { color: var(--text-primary); background: var(--bg-elevated); }
.filter-header:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }
.filter-header .filter-label { margin: 0; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; }
.filter-header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.filter-summary {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: none;
    color: var(--accent);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.filter-summary:empty { display: none; }
.chevron {
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.filter-section.collapsed .chevron { transform: rotate(-45deg); }
.filter-panel {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.22s ease;
    overflow: clip;
}
.filter-section.collapsed .filter-panel {     grid-template-rows: 0fr;
    visibility: hidden;}
.filter-section.collapsed .filter-panel-inner {
    overflow: clip;}
.filter-panel-inner { overflow: hidden; min-height: 0; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 14px 12px; }
.filter-chip {
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    white-space: nowrap;
}
.filter-chip:hover { border-color: var(--text-muted); color: var(--text-primary); }
.filter-chip.active { background: var(--accent); color: white; border-color: var(--accent); }

.date-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px 10px; }
.date-enable { padding: 0 14px 10px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.date-field { min-width: 0; }
.date-field label { display: block; color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.date-field input[type="date"] {
    width: 100%;
    min-width: 0;
    height: 30px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font: 11px var(--font-mono);
    color-scheme: dark;
}
.date-field input[type="date"]:focus { border-color: var(--accent); outline: none; }
.date-field input[type="date"]:disabled { opacity: 0.45; cursor: not-allowed; }
.date-options { display: grid; gap: 7px; padding: 0 14px 12px; }
.date-options.is-disabled { opacity: 0.42; }
.checkbox-label { display: flex; align-items: center; gap: 7px; min-width: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.35; cursor: pointer; }
.checkbox-label input { flex: 0 0 auto; width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }

/* Tag filters */
.tag-filters { align-items: flex-start; }
.filter-chips .filter-chip[hidden] { display: none; }
.tag-toggle { display: block; margin: 0 14px 12px; padding: 3px 0; border: 0; background: transparent; color: var(--accent); font: 600 10px var(--font-sans); cursor: pointer; }
.tag-toggle[hidden] { display: none; }
.tag-toggle:hover { text-decoration: underline; }

/* ─── Event List ─── */
#event-list { padding: 0; }
.event-list-empty { padding: 10px; color: var(--text-quaternary); text-align: center; }
.event-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.event-item:hover { background: var(--bg-elevated); }
.event-item.selected { background: var(--selected); border-left: 3px solid var(--accent); }
.event-item .event-heading { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: start; column-gap: 8px; min-width: 0; }
.event-item .event-type-icon { grid-column: 1; grid-row: 1; }
.event-item .event-title {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
    font-family: inherit;
    text-align: left;
    margin-bottom: 2px;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
    line-height: 1.1;
}
.event-item .event-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.event-item .event-meta { font-size: 11px; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 6px; }
.event-item .event-meta .meta-tag { background: var(--bg-dark); padding: 1px 6px; border-radius: 3px; font-size: 10px; white-space: wrap; line-height: 1.1;}
.event-link { display: inline-block; margin-left: 6px; color: var(--text-muted); font-weight: 700; text-decoration: none; }
.event-link:hover, .event-link:focus-visible { color: var(--accent); text-decoration: underline; }
.event-item .event-date { grid-column: 3; grid-row: 1; font-family: var(--font-mono); font-size: 10px; color: var(--text-primary); white-space: nowrap; }

.meta-tag.updates { background: rgba(88, 166, 255, 0.20); color: #58a6ff; }
.meta-tag.hash { background: var(--bg-elevated); color: var(--text-muted); }

/* ─── Map Container ─── */
#map-container {
    position: relative;
    isolation: isolate;
    flex: 1;
    min-width: 0;
    height: 100%;
    background: var(--bg-dark);
}
#map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
}

.map-legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 800;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 11px;
    color: var(--text-secondary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    user-select: none;
}
.map-legend .legend-title { font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 6px; }
.map-legend .legend-row { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.legend-emoji { display: inline-block; width: 20px; text-align: center; }

/* ─── Modals ─── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.0);
    z-index: 890;
    justify-content: left;
    align-items: center;
}
.modal-overlay.visible { display: flex; }
.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    border-top-left-radius: 0px;
    border-bottom-left-radius: 0px;
    padding: 20px 24px;
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.modal .modal-subtitle { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.modal .form-group { margin-bottom: 12px; }
.modal label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.modal input, .modal select, .modal textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    font-family: var(--font-sans);
}
.modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--accent); }
.modal textarea { min-height: 80px; resize: vertical; }
.modal .form-actions { display: flex; gap: 8px; margin-top: 16px; }

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.15s;
    font-family: var(--font-sans);
}
.btn:hover { background: var(--border); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { background: #4c8fd0; }

.detail-section { margin-bottom: 12px; }
.detail-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; font-family:"Union Gothic";color: var(--text-muted); font-weight: 600; }
.detail-value { font-size: 14px; color: var(--text-primary); }
.detail-value.alt { line-height: 2; }
.source-link { color: var(--accent); text-decoration: none; font-size: 12px; word-break: break-all; }
.source-link:hover { text-decoration: underline; }

/* ─── Leaflet Theming ─── */
.leaflet-container { background: var(--bg-dark); font-family: var(--font-sans); }
.leaflet-popup-content-wrapper { background: var(--bg-panel); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); }
.leaflet-popup-tip { background: var(--bg-panel); border: 1px solid var(--border); }
.leaflet-popup-close-button { color: var(--text-muted) !important; }
.leaflet-bar { border: 1px solid var(--border) !important; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important; }
.leaflet-bar a, .leaflet-bar a:hover { background: var(--bg-panel); color: var(--text-primary); border-bottom: 1px solid var(--border); }
.leaflet-bar a:hover { background: var(--bg-elevated); }
.leaflet-bar a:last-child { border-bottom: none; }
.leaflet-control-attribution { background: rgba(22, 27, 34, 0.8) !important; color: var(--text-muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--accent) !important; }

.custom-emoji-marker { display: flex; align-items: center; justify-content: center; }
.custom-emoji-marker.related-location-marker::before {
    content: '';
    position: absolute;
    inset: 1px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(219, 34, 42, 0.2);
    pointer-events: none;
    animation: related-location-pulse 1.5s ease-out infinite;
}
@keyframes related-location-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.65; }
}

/* ─── Stale Entries & Tags ─── */
.stale-badge {
    display: inline-flex;
    align-items: center;
    gap: .35em;
    padding: .1em .6em;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.6;
    font-family: inherit;
    color: var(--stale-text);
    background: var(--stale-bg);
    border: 1px solid var(--stale-border);
    border-radius: 999px;
    cursor: pointer;
    vertical-align: middle;
    transition: background .15s, border-color .15s;
}
.stale-badge:hover { background: var(--stale-bg-hover); }
.stale-badge[aria-expanded="true"] { background: var(--stale-bg-hover); border-color: var(--stale-border); }
.stale-notice {
    margin-top: 6px;
    padding: 6px 10px;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--stale-notice-text);
    background: var(--stale-notice-bg);
    border-left: 3px solid var(--stale-notice-border);
    border-radius: 4px;
    animation: stale-in .2s ease-out;
}
.stale-notice[hidden] { display: none; }
@keyframes stale-in {
    from { opacity: 0; transform: translateY(-.25rem); }
    to { opacity: 1; transform: none; }
}

.meta-tag.upcoming {
    background: rgba(52, 152, 219, 0.18);
    color: #ffef03;
    border: 1px solid rgba(52, 152, 219, 0.45);
    font-weight: 600;
}
.event-item.supporters-wanted { background: var(--supporters-bg); }
.event-item.supporters-wanted:hover { background: var(--supporters-bg-hover); }
.event-item.supporters-wanted.selected { box-shadow: inset 0 0 0 2px var(--supporters-accent); }
.meta-tag.tag-supporters { background: var(--supporters-bg); color: var(--supporters-accent); border: 1px solid var(--supporters-accent); }

/* Details/Summary Animation */
:root { interpolate-size: allow-keywords; }
details::details-content {
    block-size: 0;
    overflow: hidden;
    transition: block-size 0.3s ease, content-visibility 0.3s allow-discrete;
}
details[open]::details-content { block-size: auto; }
details .chevron { transform: rotate(-45deg); transition: transform 0.2s ease; }
details[open] .chevron { transform: rotate(45deg); }

/* ─── Mobile Responsive ─── */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 400px;
        --topbar-height: 48px;
        --ticker-height: 28px;
    }
    #ticker { display: none; }
    #topbar { padding: 0 8px; gap: 8px; }
    .logo { font-size: 16px; }
    .logo span { display: none; }
    .stats-bar { gap: 8px; font-size: 10px; display: none; }
    #sidebar-toggle { display: block; font-size: 18px; padding: 4px 8px; }
    #sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 950;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
    }
    #sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
    .map-legend { bottom: 38px; right: 10px; padding: 6px 8px; font-size: 9px; }
    .filter-chip { padding: 2px 8px; font-size: 10px; }
    .modal-overlay { left: 0; justify-content: right; }
    .modal { width: 95%; padding: 15px; }
    .btn { padding: 8px 12px; font-size: 12px; }
    .filter-header {padding:14px 10px}
}

@media (max-width: 480px) {
    :root { --sidebar-width: 350px; --topbar-height: 44px; --ticker-height: 24px; }
    .modal-overlay { left: 0; }
    .stats-bar .stat .number { font-size: 11px; }
}

/* ─── Animated Search Dropdown ─── */
.search-dropdown {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-panel);
}

.search-dropdown.open {
    grid-template-rows: 1fr;
    border-bottom-color: var(--border);
}

.search-dropdown-inner {
    overflow: hidden;
    min-height: 0;
    background-color: var(--accent);
}

/* The search box's existing `.sidebar-header` styles still apply —
   we only strip the border-bottom so the wrapper owns the edge. */
.search-dropdown .sidebar-header {
    border-bottom: 0;
    border-top: 1px solid var(--border);
}

/* Active state on the search button */
.icon-btn[aria-expanded="true"] {
    background: var(--accent);
    color: #ffffff;
}

.icon-btn[aria-expanded="true"]:hover {
    background: var(--accent);
    color: #ffffff;
    filter: brightness(1.1);
}

/* Red dot indicator when a query is active but the dropdown is closed */
.icon-btn.has-query {
    position: relative;
}

.icon-btn.has-query::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 7px;
    height: 7px;
    background: var(--strike);
    border-radius: 50%;
    border: 1.5px solid var(--bg-active);
    pointer-events: none;
}

/* ─── Animated Filter Dropdown ─── */
.filter-dropdown {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-panel);
}

.filter-dropdown.open {
    grid-template-rows: 1fr;
    border-bottom-color: var(--border);
}

.filter-dropdown-inner {
    overflow: hidden;
    min-height: 0;
}

/* Internal scroll so tall filter lists (many unions/tags) don't push the
   event list off screen entirely. Capped at 55% of viewport height. */
.filter-dropdown-scroll {
    max-height: min(40vh, 340px); ;
    overflow-y: auto;
    border-top: 1px solid var(--border);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    overscroll-behavior: contain;
}

.filter-dropdown-scroll::-webkit-scrollbar {
    width: 5px;
}
.filter-dropdown-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.filter-dropdown-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* The very last filter section shouldn't have a trailing border inside
   the scrollable area — cleaner edge against the scroll boundary. */
.filter-dropdown-scroll > .filter-section:last-child {
    border-bottom: none;
}

/* ─── Lit-up state for toggle buttons ─── */
.icon-btn[aria-pressed="true"],
.icon-btn[aria-expanded="true"] {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 0 0 1px var(--accent),
                0 0 12px color-mix(in srgb, var(--accent) 55%, transparent);
}

.icon-btn[aria-pressed="true"]:hover,
.icon-btn[aria-expanded="true"]:hover {
    background: var(--accent);
    color: #ffffff;
    filter: brightness(1.12);
}

/* When the button is already lit, the "has query" red dot is redundant */
.icon-btn[aria-pressed="true"].has-query::after,
.icon-btn[aria-expanded="true"].has-query::after {
    display: none;
}

/* ─── Reopen sidebar tab ─── */
/* Hidden by default. Only shown when the sidebar is collapsed,
   via sibling selector — no JS body class required. */
#map-chrome-toggle {
    display: none;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 1000;
    width: 36px;
    height: 76px;
    padding: 0;
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 10px 10px 0;
    background: var(--bg-panel);
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
    transition: width 0.15s ease, background 0.15s ease;
}

#map-chrome-toggle:hover {
    background: var(--bg-elevated);
    width: 44px;
}

#map-chrome-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

#map-chrome-toggle svg {
    display: block;
    flex-shrink: 0;
    stroke: currentColor;
}


#sidebar.collapsed ~ #map-container #map-chrome-toggle {
    display: flex;
}

/* Mobile tuning */
@media (max-width: 768px) {
    #map-chrome-toggle {
        width: 32px;
        height: 64px;
        border-radius: 0 8px 8px 0;
    }
    #map-chrome-toggle:hover {
        width: 38px;
    }
}

/* ─── Filter status header (window-title style) ─── */
.sidebar-list-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 1.2;
    color: var(--text-muted);
    min-height: 24px;
    user-select: none;
    overflow: hidden;
}

/* Status dot */
.list-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-really-muted);
    flex-shrink: 0;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.list-indicator.active {
    background: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent),
                0 0 6px var(--accent);
}

/* Chip container */
.list-filter-summary {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    min-width: 0;
    white-space: nowrap;
}

.list-filter-none {
    color: var(--text-really-muted);
    font-style: italic;
    font-size: 10px;
    letter-spacing: 0.2px;
}

/* Individual filter chip */
.list-filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    background: var(--accent);
    color: var(--text-secondary);
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.2px;
    flex-shrink: 0;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Different chip tints per filter kind */
.list-filter-chip[data-kind="search"] {
    background: var(--accent-alt);
}
.list-filter-chip[data-kind="tag"] {
    background: var(--supporters-accent);
    color: #1e1736;
}
.list-filter-chip[data-kind="date"] {
    background: var(--bg-alt);
}
.list-filter-chip[data-kind="overflow"] {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0 5px;
    font-weight: 600;
}

/* Count badge on the right */
.list-count {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 1px 7px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 3px;
    min-width: 26px;
    text-align: center;
    letter-spacing: 0.2px;
}

/* Light theme — keep the strip readable but softer */
html[data-theme="light"] .sidebar-list-header {
    background: var(--bg-elevated);
}
html[data-theme="light"] .list-count {
    background: var(--bg-panel);
}

/* Mobile: trim padding so it doesn't steal vertical space */
@media (max-width: 768px) {
    .sidebar-list-header {
        padding: 3px 8px;
        min-height: 22px;
        font-size: 9px;
    }
    .list-filter-chip {
        font-size: 8px;
        padding: 1px 5px;
    }
    .list-count {
        font-size: 9px;
        padding: 1px 5px;
        min-width: 22px;
    }
}

/* ─── Map title overlay (top-left) ─── */
.map-title {
    position: absolute;
    top: 12px;
    left: 16px;
    z-index: 500;
    font-family: 'Folsom', 'Union Gothic', var(--font-sans);
    font-size: clamp(28px, 4vw, 56px);
    font-weight: 900;
    line-height: 0.88;
    letter-spacing: -0.03em;
    color: #ffffff;
    text-transform: uppercase;
    text-shadow:
        0 2px 6px rgba(0, 0, 0, 0.85),
        0 0 24px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    user-select: none;
}

.map-title span {
    display: block;
}

/* Push Leaflet's zoom controls down so they clear the title */
.leaflet-top.leaflet-left {
    top: 110px;
}

/* Mobile tuning */
@media (max-width: 768px) {
    .map-title {
        top: 8px;
        left: 10px;
        font-size: clamp(22px, 6vw, 32px);
    }
    .leaflet-top.leaflet-left {
        top: 72px;
    }
}