* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; width: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0f1117; }
#map { height: 100%; width: 100%; }

/* Header bar */
#header {
    position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
    background: rgba(15, 17, 28, 0.95); height: 56px; padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
#header h1 { font-size: 18px; font-weight: 700; color: #e8e8e8; }
#header h1 span { color: #ff4444; }
#header-actions { display: flex; align-items: center; gap: 8px; }
#last-updated-text { display: none; font-size: 12px; color: #777888; white-space: nowrap; }
@media (min-width: 640px) { #last-updated-text { display: inline-flex; align-items: center; } }
.header-spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(168,168,184,0.25); border-top-color: #a8a8b8; border-radius: 50%; animation: spin 0.6s linear infinite; }

/* Settings button base */
#settings-btn {
    border-radius: 4px; padding: 8px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background 0.2s, border-color 0.2s; display: inline-flex; align-items: center; gap: 6px;
    font-family: inherit; white-space: nowrap;
}
#settings-btn .material-icons { font-size: 18px; line-height: 1; flex-shrink: 0; }

/* Refresh — exact copy of .closure-popup-cal + button resets */
#refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #B91C1C;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
#refresh-btn .spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; flex-shrink: 0; }
#refresh-btn .spinner[hidden] { display: none; }
#refresh-btn:hover { background: #941515; }
#refresh-btn:disabled { background: #555; cursor: not-allowed; opacity: 0.8; }

/* Settings gear — secondary (no fill, grey border) */
#settings-btn { background: transparent; color: #b0b0c0; border: 1px solid rgba(200,200,210,0.3); }
#settings-btn:hover { background: rgba(255,255,255,0.06); border-color: rgba(200,200,210,0.5); color: #e8e8e8; }
#settings-btn.edit-active { background: rgba(185,28,28,0.2); border-color: rgba(185,28,28,0.7); color: #ff8888; }

/* Settings dropdown */
#settings-wrapper { position: relative; }
#settings-dropdown {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 1100;
    background: rgba(20, 22, 35, 0.98); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px; min-width: 200px; width: max-content; box-shadow: 0 4px 20px rgba(0,0,0,0.7);
    backdrop-filter: blur(8px); overflow: hidden;
}
.settings-menu-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 10px 14px; background: none; border: none; color: #e8e8e8;
    font-size: 14px; font-weight: 600; cursor: pointer; text-align: left;
    transition: background 0.15s; font-family: inherit;
}
.settings-menu-item:hover { background: rgba(255,255,255,0.08); }
.settings-menu-item.active { color: #ff6b6b; }
.settings-menu-item .material-icons { font-size: 18px; opacity: 0.8; }
.settings-divider { border: none; border-top: 1px solid rgba(255,255,255,0.08); margin: 0; }
/* Settings toggle switch */
.settings-toggle-item {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 14px; cursor: pointer; user-select: none;
    transition: background 0.15s;
}
.settings-toggle-item:hover { background: rgba(255,255,255,0.08); }
.settings-toggle-label {
    display: flex; align-items: center; gap: 8px;
    color: #e8e8e8; font-size: 14px; font-weight: 600; white-space: nowrap;
}
.settings-toggle-label .material-icons { font-size: 18px; opacity: 0.8; }
.settings-toggle-item input[type="checkbox"] { display: none; }
.settings-toggle-switch {
    position: relative; width: 36px; height: 20px; flex-shrink: 0;
    background: rgba(255,255,255,0.15); border-radius: 10px;
    transition: background 0.2s;
}
.settings-toggle-switch::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #888; transition: transform 0.2s, background 0.2s;
}
.settings-toggle-item input:checked ~ .settings-toggle-switch {
    background: rgba(185,28,28,0.5);
}
.settings-toggle-item input:checked ~ .settings-toggle-switch::after {
    transform: translateX(16px); background: #ff4444;
}
.settings-refresh-info {
    padding: 8px 14px 12px; font-size: 12px; color: #777888; line-height: 1.5;
}
.settings-version-info {
    padding: 6px 14px 10px; font-size: 11px; color: #555666; text-align: center; letter-spacing: 0.03em;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Live closure flicker — colour pulses between bright red and planned-closure crimson;
   stroke-width widens at peak so the ring is more visible at maximum red.
   Minimum state exactly matches the planned closure colour — never darker. */
@keyframes liveFlicker {
    0%   { stroke: #ff3333; stroke-width: 26px; }
    50%  { stroke: #8B1A1A; stroke-width: 22px; }
    100% { stroke: #ff3333; stroke-width: 26px; }
}
.live-closure-flash {
    animation: liveFlicker 2.6s ease-in-out infinite;
}

/* Status bar below header */
#status-bar {
    position: absolute; top: 56px; left: 0; right: 0; z-index: 999;
    background: rgba(15, 17, 28, 0.92); padding: 4px 16px; font-size: 12px;
    color: #a8a8b8; text-align: center; display: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
#status-bar.visible { display: block; }
#status-bar.error { color: #ff6b6b; }

/* Legend panel */
/* Hidden — keep for potential re-enable */
#legend { display: none !important; }
#legend-hidden {
    position: absolute; bottom: 20px; left: 10px; z-index: 1000;
    background: rgba(15, 17, 28, 0.95); border-radius: 8px;
    padding: 10px 14px; box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    font-size: 13px; line-height: 1.6; backdrop-filter: blur(4px);
    max-width: 220px; border: 1px solid rgba(255,255,255,0.08);
}
#legend h3 { font-size: 14px; margin-bottom: 0; color: #e8e8e8; }

/* Collapsible legend */
#legend-header {
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; user-select: none;
}
#legend-toggle {
    background: none; border: none; color: #a8a8b8;
    cursor: pointer; padding: 0 0 0 6px; line-height: 1;
    flex-shrink: 0; display: flex; align-items: center;
}
#legend-toggle .material-icons { font-size: 18px; }
#legend-body { margin-top: 6px; }
#legend.collapsed #legend-body { display: none; }
.legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.legend-line { width: 24px; height: 4px; border-radius: 2px; flex-shrink: 0; }
.legend-line-outline { background: transparent !important; border: 2.5px solid; height: 0; border-radius: 2px; }
.legend-label { color: #a8a8b8; }
.legend-count { font-weight: 700; color: #ff4444; margin-left: auto; }
.legend-divider { border-top: 1px solid rgba(255,255,255,0.08); margin: 5px 0; }

/* Version stamp */
.legend-version { font-size: 10px; color: #666; margin-top: 6px; text-align: center; }

/* Correction modal */
#correction-modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7); z-index: 2000;
    align-items: center; justify-content: center; padding: 20px;
}
#correction-modal {
    background: rgba(15, 17, 28, 0.96); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px; padding: 20px 24px; max-width: 460px; width: 100%;
    max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.8);
    z-index: 2001; color: #e8e8e8;
}
#correction-modal h3 { font-size: 16px; font-weight: 700; color: #fff; margin-bottom: 8px; }
#correction-modal p { font-size: 13px; color: #a8a8b8; margin-bottom: 16px; line-height: 1.5; }
.correction-row {
    margin-bottom: 12px; padding: 10px 12px;
    background: rgba(255,255,255,0.04); border-radius: 6px; border: 1px solid rgba(255,255,255,0.06);
}
.correction-label { font-size: 13px; margin-bottom: 6px; }
.correction-original { color: #ff6b6b; font-weight: 600; }
.correction-line { color: #888; font-size: 12px; }
.correction-select {
    width: 100%; padding: 6px 8px; background: rgba(15, 17, 28, 0.9);
    color: #e8e8e8; border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px; font-size: 13px; font-family: inherit;
}
.correction-select:focus { outline: none; border-color: #DA291C; }
.correction-actions { display: flex; gap: 10px; margin-top: 16px; }
.correction-btn {
    flex: 1; padding: 8px 16px; border: none; border-radius: 6px;
    font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: background 0.2s;
}
.correction-btn-primary { background: #B91C1C; color: #fff; }
.correction-btn-primary:hover { background: #941515; }
.correction-btn-secondary { background: rgba(255,255,255,0.1); color: #ccc; }
.correction-btn-secondary:hover { background: rgba(255,255,255,0.15); }
.correction-footer { margin-top: 12px; text-align: center; }
.correction-footer a { color: #6b9fff; font-size: 12px; text-decoration: none; }
.correction-footer a:hover { text-decoration: underline; }


/* Edit panel */
#edit-panel {
    position: fixed; top: 66px; right: 10px; z-index: 1500;
    background: rgba(15, 17, 28, 0.96); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px; padding: 12px 14px; min-width: 260px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6); color: #e8e8e8; font-size: 13px;
}
#edit-panel-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
#edit-station-name { font-weight: 700; color: #fff; font-size: 14px; }
#edit-station-lines { color: #a8a8b8; font-size: 12px; }
#edit-panel-close {
    margin-left: auto; background: none; border: none; color: #a8a8b8;
    font-size: 20px; cursor: pointer; line-height: 1; padding: 0 4px;
}
#edit-panel-close:hover { color: #fff; }
.edit-row {
    display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
}
.edit-row > label:first-child { width: 32px; color: #a8a8b8; font-size: 12px; flex-shrink: 0; }
.edit-row input[type="number"] {
    flex: 1; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px; color: #e8e8e8; padding: 4px 6px; font-size: 13px; font-family: monospace;
}
.edit-row input[type="number"]:focus { outline: none; border-color: #DA291C; }
.edit-dpad {
    display: grid; grid-template-columns: repeat(3, 32px); grid-template-rows: repeat(3, 32px);
    gap: 3px; justify-content: center; margin: 8px 0;
}
.edit-dpad-n { grid-column: 2; grid-row: 1; }
.edit-dpad-w { grid-column: 1; grid-row: 2; }
.edit-dpad-e { grid-column: 3; grid-row: 2; }
.edit-dpad-s { grid-column: 2; grid-row: 3; }
.edit-arrow {
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px; color: #e8e8e8; width: 32px; height: 32px; cursor: pointer;
    font-size: 13px; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.edit-arrow:hover { background: rgba(255,255,255,0.18); }
.edit-arrow:active { background: #DA291C; }
.edit-row input[type="radio"] { margin: 0 2px 0 0; accent-color: #DA291C; }
.edit-row label { color: #a8a8b8; font-size: 12px; cursor: pointer; white-space: nowrap; }
#edit-save-btn {
    width: 100%; margin-top: 4px; padding: 8px 0; background: #B91C1C;
    border: none; border-radius: 6px; color: #fff;
    font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s;
}
#edit-save-btn:hover { background: #941515; }
#edit-save-btn:disabled { background: #555; cursor: not-allowed; opacity: 0.7; }
.edit-btn-row { display: flex; gap: 6px; margin-top: 6px; }
#edit-copy-btn, #edit-reset-btn {
    flex: 1; padding: 6px 0; background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15); border-radius: 6px; color: #e8e8e8;
    font-size: 12px; font-weight: 600; cursor: pointer; transition: background 0.15s;
}
#edit-copy-btn:hover, #edit-reset-btn:hover { background: rgba(255,255,255,0.15); }
#edit-reset-btn { border-color: rgba(255,68,68,0.3); color: #ff6b6b; }
#edit-reset-btn:hover { background: rgba(255,68,68,0.15); }

/* Edit mode cursor */
body.edit-mode #map { cursor: crosshair; }

/* Station markers stay interactive in normal mode so hover tooltips work.
   Clicks on stations inside a closure area are handled by JS — the station
   click handler checks closureStationPopups and opens the closure popup. */

/* Mobile adjustments (mobile + tablet ≤ 768px) */
@media (max-width: 768px) {
    #header { padding: 0 16px; }
    #legend { position: fixed; bottom: 28px; left: 10px; padding: 8px 10px; font-size: 12px; max-width: 180px; z-index: 1100; }
    #correction-modal { padding: 16px; max-width: 100%; }
    #edit-panel { right: 6px; min-width: 240px; }
}

/* Tooltip styling */
.station-tooltip {
    background: rgba(15, 17, 28, 0.96);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    color: #e8e8e8;
}
.station-tooltip strong { color: #ffffff; }
.station-tooltip .leaflet-tooltip-tip { display: none; }

/* Zoom control: position above legend */
.leaflet-bottom.leaflet-left .leaflet-control-zoom {
    margin-left: 10px;
    margin-bottom: 175px;
}

/* Zoom control: dark theme */
.leaflet-control-zoom {
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-radius: 6px !important;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5) !important;
}
.leaflet-control-zoom a {
    background: rgba(15, 17, 28, 0.95) !important;
    color: #e8e8e8 !important;
    border-bottom-color: rgba(255,255,255,0.12) !important;
}
.leaflet-control-zoom a:hover {
    background: rgba(40, 42, 60, 0.95) !important;
    color: #ffffff !important;
}

/* Popup styling — dark theme */
.leaflet-popup-content-wrapper {
    background: rgba(15, 17, 28, 0.96) !important;
    color: #e8e8e8 !important;
    border-radius: 8px !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6) !important;
    padding: 0 !important;
}
.leaflet-popup-tip {
    background: rgba(15, 17, 28, 0.96) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-top: none !important;
    border-left: none !important;
}
.leaflet-popup-content {
    margin: 16px !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    min-width: 300px !important;
    max-width: 320px !important;
}
.leaflet-popup-close-button {
    color: #a8a8b8 !important;
    font-size: 0 !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    top: 0 !important;
    right: 0 !important;
}
.leaflet-popup-close-button::after {
    font-family: 'Material Icons';
    content: 'close';
    font-size: 18px;
    line-height: 1;
}
.leaflet-popup-close-button:hover {
    color: #ffffff !important;
}
.closure-popup-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
    margin-top: 5px;
    margin-bottom: 6px;
}
.leaflet-popup-content .closure-popup-title {
    padding-right: 14px;
}
.line-chip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1.5px solid;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    vertical-align: middle;
    margin-right: 3px;
    position: relative;
    top: -1px;
}
.closure-popup-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
}
.closure-popup-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-closure { background: rgba(255, 68, 68, 0.25); color: #ff6b6b; }
.badge-speed { background: rgba(255, 170, 0, 0.25); color: #ffcc44; }
.badge-live { background: rgba(255, 68, 68, 0.25); color: #ff6b6b; }
.badge-planned { background: rgba(255, 119, 221, 0.2); color: #ff99ee; }
.badge-shuttle { background: rgba(100, 220, 140, 0.15); color: #88ddaa; }
.badge-no-shuttle { background: rgba(255, 255, 255, 0.07); color: #999; }
.closure-popup-time {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #a8a8b8;
    font-size: 13px;
    margin-bottom: 6px;
}
.closure-popup-detail {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #a8a8b8;
    font-size: 13px;
    margin-bottom: 6px;
}
.closure-detail-icon {
    font-size: 16px;
    color: #ff6b6b;
    flex-shrink: 0;
    margin-top: 1px;
    line-height: 1;
}
.material-symbols-outlined.closure-detail-icon {
    font-size: 16px;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}
.time-icon {
    font-size: 16px;
    color: #a8a8b8;
    flex-shrink: 0;
    line-height: 1;
}
.closure-popup-desc {
    color: #b0b0c0;
    font-size: 12px;
    margin-bottom: 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 8px;
}
.closure-popup-desc p { margin: 0 0 4px 0; }
.closure-popup-desc a,
.leaflet-popup-content .closure-popup-desc a { color: #6b9fff; }
.closure-popup-image-wrap {
    display: block;
    margin: 8px 0 0;
    max-width: 220px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    text-decoration: none;
}
.closure-popup-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 5px;
    transition: opacity 0.2s;
}
.closure-popup-image-wrap:hover .closure-popup-image { opacity: 0.85; }
.closure-popup-info-link {
    color: #6b9fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: color 0.2s;
}
.closure-popup-info-link:hover { color: #8cb4ff; text-decoration: underline; }
.leaflet-popup-content .closure-popup-info-link { color: #6b9fff; }
.leaflet-popup-content .closure-popup-info-link:hover { color: #8cb4ff; }
.closure-popup-cal {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    background: #B91C1C;
    color: #fff;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
}
.closure-popup-cal,
.leaflet-popup-content .closure-popup-cal { color: #fff !important; text-decoration: none; }
.closure-popup-cal:hover,
.leaflet-popup-content .closure-popup-cal:hover { background: #941515; color: #fff !important; }
.cal-icon { font-size: 14px; flex-shrink: 0; }
.closure-popup-live {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    color: #ff4444;
    font-size: 11px;
    font-weight: 700;
    vertical-align: middle;
    border: 1.5px solid #ff4444;
    border-radius: 4px;
    padding: 1px 6px;
    letter-spacing: 0.3px;
}
.closure-popup-live-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #ff4444;
    flex-shrink: 0;
    animation: live-pulse 1.2s ease-in-out infinite;
}
@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}
.closure-popup-upcoming {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    color: #888899;
    font-size: 11px;
    font-weight: 700;
    vertical-align: middle;
    border: 1.5px solid #555566;
    border-radius: 4px;
    padding: 1px 6px;
    letter-spacing: 0.3px;
}

/* ---- [New] / [Updated] history tags ---- */
.closure-new-tag,
.closure-updated-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1.5px solid #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    vertical-align: middle;
    margin-left: 3px;
    position: relative;
    top: -1px;
    background: #fff;
    color: #111;
    cursor: help;
}

/* ---- Closure popup pagination (multi-closure cycling) ---- */
.closure-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.closure-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    color: #a8a8b8;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.closure-nav-btn:hover:not(:disabled) { background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.3); }
.closure-nav-btn:disabled { opacity: 0.3; cursor: default; }
.closure-nav-btn .material-icons { font-size: 18px; }
.closure-nav-label {
    font-size: 12px;
    color: #888899;
    font-weight: 600;
    min-width: 48px;
    text-align: center;
    letter-spacing: 0.3px;
}

/* ---- Fullscreen image gallery overlay ---- */
.image-gallery-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(4px);
}
.image-gallery-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
.image-gallery-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 90vw;
    max-height: 90vh;
}
.image-gallery-img {
    max-width: 100%;
    max-height: calc(90vh - 60px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}
.image-gallery-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
.gallery-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
    cursor: pointer;
}
.gallery-btn .material-icons { font-size: 16px; }
.gallery-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.18);
}
.gallery-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}
.gallery-btn-primary {
    background: #B91C1C;
    color: #fff;
    border: 1px solid #B91C1C;
}
.gallery-btn-primary:hover { background: #941515; }
.image-gallery-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.image-gallery-close:hover { background: rgba(255, 255, 255, 0.25); }
.image-gallery-close .material-icons { font-size: 22px; }

/* ============================================================
   Closures panel (desktop sidebar)
   ============================================================ */
.closures-panel {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 400px;
    z-index: 1200;
    background: rgba(15, 17, 28, 0.96);
    border-right: 1px solid rgba(255,255,255,0.08);
    box-shadow: 2px 0 16px rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.25s ease;
}
.closures-panel.hidden {
    transform: translateX(-100%);
    pointer-events: none;
}
.closures-panel-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    position: relative;
}
.closures-header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}
.closures-header-title h3 {
    font-size: 15px;
    font-weight: 700;
    color: #e8e8e8;
    margin: 0;
    white-space: nowrap;
}
.closures-panel-sources {
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.closures-panel-source-link {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    transition: color 0.15s;
}
.closures-panel-source-link:hover { color: rgba(255,255,255,0.85); }
.closures-panel-sources-sep {
    font-size: 11px;
    color: rgba(255,255,255,0.18);
    user-select: none;
}
.closures-panel-sources-label {
    font-size: 11px;
    color: rgba(255,255,255,0.3);
    user-select: none;
    margin-right: 2px;
}
.closures-panel-count {
    font-size: 12px;
    font-weight: 600;
    color: #ff6b6b;
    background: rgba(255, 68, 68, 0.15);
    padding: 1px 7px;
    border-radius: 10px;
}
.closures-panel-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #a8a8b8;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}
.closures-panel-close:hover { background: rgba(255,255,255,0.08); color: #fff; }
.closures-panel-close .material-icons { font-size: 18px; }

/* Gear (tune) button in header */
.closures-panel-gear {
    background: none;
    border: none;
    color: #a8a8b8;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}
.closures-panel-gear:hover { background: rgba(255,255,255,0.08); color: #fff; }
.closures-panel-gear .material-icons { font-size: 18px; }
.closures-panel-gear.active { color: #6b8aff; }

/* Sort bar */
.closures-sort-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

/* Base select — shared sizing, colour, and interaction */
.closures-sort-select {
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    color: #c8c8d8;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    padding: 7px 10px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.closures-sort-select:hover {
    border-color: rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.11);
}
.closures-sort-select:focus {
    border-color: rgba(100,140,255,0.55);
    background: rgba(255,255,255,0.09);
}


/* Collapsible sort bar */
.closures-sort-bar-hidden {
    display: none;
}

/* ---- Custom dropdown (desktop panel only) ---- */
.custom-select-wrapper {
    position: relative;
    display: inline-block;
    width: 120px;
}
.custom-select-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    color: #c8c8d8;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    padding: 7px 10px;
    cursor: pointer;
    outline: none;
    white-space: nowrap;
    transition: border-color 0.15s, background 0.15s;
}
.custom-select-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.custom-select-trigger:hover {
    border-color: rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.11);
}
.custom-select-wrapper.open .custom-select-trigger {
    border-color: rgba(100,140,255,0.55);
    background: rgba(255,255,255,0.09);
}
.custom-select-chevron {
    flex-shrink: 0;
    transition: transform 0.18s;
}
.custom-select-wrapper.open .custom-select-chevron {
    transform: rotate(180deg);
}
.custom-select-options {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    background: #17172a;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.55);
    z-index: 1100;
    overflow: hidden;
}
.custom-select-wrapper.open .custom-select-options {
    display: block;
}
.custom-select-option {
    padding: 9px 14px;
    font-size: 13px;
    font-family: inherit;
    color: #b8b8cc;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    user-select: none;
    white-space: nowrap;
}
.custom-select-option:hover {
    background: rgba(255,255,255,0.07);
    color: #e0e0f0;
}
.custom-select-option.active {
    color: #fff;
    background: rgba(107,138,255,0.18);
}
.custom-select-option.active:hover {
    background: rgba(107,138,255,0.26);
}

/* Scrollable list (shared desktop + mobile) */
.closures-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

/* Group headings */
.closures-group-heading {
    padding: 16px 16px 8px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #777888;
    border-top: 1px solid rgba(255,255,255,0.10);
}
.closures-group-heading:first-child { border-top: none; }
.closures-group-past { color: rgba(255,255,255,0.30); }

/* Past closure items — dimmed to indicate they have ended */
.closures-item-past { opacity: 0.45; }
.closures-item-past:hover { opacity: 0.65; }

/* Individual closure item — horizontal layout: body left, actions right */
.closures-item {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    padding: 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.closures-item:hover { background: rgba(255,255,255,0.05); }
.closures-item:active { background: rgba(255,255,255,0.08); }

/* Left content body — children use shared .closure-popup-* classes */
.closures-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Calendar button — right side of item */
.closures-item-actions {
    display: flex;
    flex-shrink: 0;
    align-self: center;
}
.closures-item-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    color: #b0b0c0;
    background: transparent;
    border: 1px solid rgba(200,200,210,0.3);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.closures-item-action:hover { background: rgba(255,255,255,0.06); border-color: rgba(200,200,210,0.5); color: #e8e8e8; }
.closures-item-action .material-icons { font-size: 16px; }
.closures-item-cal:hover { color: #ff6b6b; border-color: rgba(255,107,107,0.4); }

/* Inline image icon (next to title) */
.closures-item-img {
    position: relative;
    cursor: pointer;
    color: #888899;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.15s;
}
.closures-item-img:hover { color: #e8e8e8; }
.closures-item-img > .material-icons { font-size: 18px; vertical-align: middle; }

/* Image preview tooltip on hover */
.closures-item-img-preview {
    display: none;
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    margin-top: 8px;
    width: 160px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
    pointer-events: none;
    z-index: 10;
}
.closures-item-img:hover .closures-item-img-preview { display: block; }
.closures-item-img-preview img {
    display: block;
    width: 100%;
    height: auto;
}

/* ---- Inline expand (mobile) + active state ---- */
.closures-item.expanded,
.closures-item.active {
    background: rgba(255,255,255,0.06);
}
.closures-item.expanded > .closures-item-body,
.closures-item.expanded > .closures-item-actions {
    display: none;
}
.closures-item-expand {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.closures-expand-popup {
}
.closures-expand-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.closures-expand-action {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: #b0b0c0;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(200,200,210,0.2);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.closures-expand-action:hover {
    background: rgba(255,255,255,0.10);
    color: #e8e8e8;
}
.closures-expand-action .material-icons { font-size: 16px; }
.closures-expand-cal {
    background: #B91C1C;
    color: #fff;
    border-color: #B91C1C;
}
.closures-expand-cal:hover {
    background: #941515;
    color: #fff;
}
.closures-expand-popup .closure-popup-cal {
    display: none;
}

/* Empty state */
.closures-empty {
    padding: 32px 14px;
    text-align: center;
    color: #555566;
    font-size: 13px;
    line-height: 1.6;
}
.closures-empty .material-icons {
    display: block;
    font-size: 36px;
    margin: 0 auto 8px;
    opacity: 0.4;
}

/* ---- Desktop toggle button (reopen) ---- */
.closures-panel-toggle {
    position: fixed;
    top: 66px;
    left: 10px;
    z-index: 1200;
    background: rgba(15, 17, 28, 0.96);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 8px 12px;
    color: #e8e8e8;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    transition: background 0.15s, border-color 0.15s;
    font-family: inherit;
}
.closures-panel-toggle:hover {
    background: rgba(40, 42, 60, 0.95);
    border-color: rgba(255,255,255,0.2);
}
.closures-panel-toggle .material-icons { font-size: 18px; }
.closures-panel-toggle.visible { display: inline-flex; }

/* ---- Legend shift when panel is open (desktop only) ---- */
@media (min-width: 769px) {
    body.closures-panel-open #legend {
        left: 410px;
        transition: left 0.25s ease;
    }
}

/* ---- Closures FAB (mobile pill) ---- */
.closures-fab {
    display: none;
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    background: rgba(15, 17, 28, 0.96);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 24px;
    padding: 10px 18px;
    color: #e8e8e8;
    cursor: pointer;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
    font-family: inherit;
    transition: background 0.15s, transform 0.15s;
}
.closures-fab:not([hidden]) { display: inline-flex; }
.closures-fab:hover { background: rgba(40, 42, 60, 0.95); }
.closures-fab:active { transform: translateX(-50%) scale(0.97); }
.closures-fab-icon { font-size: 18px; color: #ff6b6b; }

/* ---- Closures bottom sheet (mobile) ---- */
.closures-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 1800;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}
.closures-sheet-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
.closures-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1801;
    background: rgba(15, 17, 28, 0.98);
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    border-top: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
    max-height: calc(100dvh - 64px);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}
.closures-sheet-overlay.visible .closures-sheet {
    transform: translateY(0);
}
.closures-sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.2);
    margin: 10px auto 4px;
    flex-shrink: 0;
}
.closures-sheet-header {
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    position: relative;
}
.closures-sheet-header .closures-panel-close {
    margin-left: auto;
}

/* ---- Responsive: hide desktop on mobile/tablet, hide mobile on desktop ---- */
@media (max-width: 768px) {
    .closures-panel { display: none !important; }
    .closures-panel-toggle { display: none !important; }
}
@media (min-width: 769px) {
    .closures-fab { display: none !important; }
    .closures-sheet-overlay { display: none !important; }
}

/* ============================================================
   Mock Data Toolbar & Edit Modal
   ============================================================ */

/* Mock toolbar — secondary bar below header */
#mock-toolbar {
    position: absolute; top: 56px; left: 0; right: 0; z-index: 999;
    background: rgba(15, 17, 28, 0.95); height: 44px; padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
}
#mock-toolbar[hidden] { display: none; }
.mock-toolbar-left, .mock-toolbar-right {
    display: flex; align-items: center; gap: 10px;
}
.mock-toolbar-label {
    font-size: 13px; font-weight: 700; color: #ff6b6b;
    letter-spacing: 0.3px; text-transform: uppercase;
}
.mock-toggle-item { padding: 0; }
.mock-count-badge {
    font-size: 11px; font-weight: 600; color: #ff6b6b;
    background: rgba(255, 68, 68, 0.15);
    padding: 1px 7px; border-radius: 10px;
}
.mock-toolbar-btn {
    display: inline-flex; align-items: center; gap: 4px;
    background: #B91C1C; color: #fff; border: none;
    padding: 6px 12px; border-radius: 4px;
    font-size: 12px; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: background 0.2s;
    white-space: nowrap;
}
.mock-toolbar-btn:hover { background: #941515; }
.mock-toolbar-btn:disabled { background: #555; cursor: not-allowed; opacity: 0.6; }
.mock-toolbar-btn .material-icons { font-size: 16px; }
.mock-toolbar-btn-secondary {
    background: rgba(255,255,255,0.08); color: #ccc;
    border: 1px solid rgba(255,255,255,0.15);
}
.mock-toolbar-btn-secondary:hover { background: rgba(255,255,255,0.15); color: #fff; }
.mock-toolbar-btn-secondary:disabled { background: rgba(255,255,255,0.04); color: #666; border-color: rgba(255,255,255,0.08); }

/* Shift elements down when mock toolbar is visible */
body.mock-mode-active #status-bar { top: 100px; }
body.mock-mode-active .closures-panel { top: 100px; }
body.mock-mode-active .closures-panel-toggle { top: 110px; }
body.mock-mode-active #edit-panel { top: 110px; }

/* Mock edit modal */
#mock-edit-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    z-index: 2000; display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
#mock-edit-modal {
    background: rgba(15, 17, 28, 0.96); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px; padding: 20px 24px; max-width: 500px; width: 100%;
    max-height: 85vh; overflow-y: auto; color: #e8e8e8;
    box-shadow: 0 8px 32px rgba(0,0,0,0.8);
}
#mock-edit-modal h3 {
    font-size: 16px; font-weight: 700; color: #fff; margin-bottom: 16px;
}
.mock-form-group { margin-bottom: 12px; }
.mock-form-label {
    display: block; font-size: 12px; color: #a8a8b8;
    margin-bottom: 4px; font-weight: 600;
}
.mock-form-select, .mock-form-input, .mock-form-textarea {
    width: 100%; padding: 6px 8px;
    background: rgba(15, 17, 28, 0.9); color: #e8e8e8;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px; font-size: 13px; font-family: inherit;
}
.mock-form-select:focus, .mock-form-input:focus, .mock-form-textarea:focus {
    outline: none; border-color: #DA291C;
}
.mock-form-textarea { resize: vertical; min-height: 40px; }
.mock-form-row { display: flex; gap: 12px; }
.mock-form-row > .mock-form-group { flex: 1; min-width: 0; }
.mock-edit-actions { display: flex; gap: 10px; margin-top: 16px; }

/* Mock edit/delete buttons in closures panel items */
.mock-edit-btn:hover { color: #60a5fa !important; border-color: rgba(96,165,250,0.4) !important; }
.mock-delete-btn:hover { color: #ff6b6b !important; border-color: rgba(255,107,107,0.4) !important; }

/* Mobile adjustments for mock toolbar (mobile + tablet ≤ 768px) */
@media (max-width: 768px) {
    #mock-toolbar { padding: 0 10px; gap: 6px; }
    .mock-toolbar-label { font-size: 11px; }
    .mock-toolbar-btn { font-size: 11px; padding: 5px 8px; }
    .mock-toolbar-btn .material-icons { font-size: 14px; }
    #mock-edit-modal { padding: 16px; max-width: 100%; }
    .mock-form-row { flex-direction: column; gap: 0; }
}
