@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg-color: #0F1014;
    /* Deep black for OLED */
    --surface-glass: rgba(22, 22, 24, 0.85);
    --surface-glass-border: rgba(255, 255, 255, 0.1);

    --l1-color: #FFC425;
    --l2-color: #009639;
    --l4-color: #B11D8C;
    --l5-color: #F37021;
    --l6-color: #9ca3af;
    /* Line 6 - Finch West LRT - Grey */

    --alert-color: #ef4444;
    --delay-color: #f59e0b;
    --shuttle-color: #3b82f6;

    --text-main: #ffffff;
    --text-muted: #a1a1aa;

    --nav-height: 80px;
    /* Taller for mobile touch targets */
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
}

/* Light Mode Overrides */
body.light-mode {
    --bg-color: #d4d4d8;
    /* Softer grey, less bright */
    --surface-glass: rgba(220, 220, 220, 0.9);
    --surface-glass-border: rgba(0, 0, 0, 0.1);
    --text-main: #1f2937;
    --text-muted: #4b5563;
    --alert-color: #dc2626;
    /* Slightly darker red for contrast */
}

/* High Contrast Mode Overrides — improves visibility of alerts on Lines 1 & 5 */
body.high-contrast {
    --delay-color: #00e5ff;
    /* Cyan for delays — stands out on yellow/orange tracks */
    --alert-color: #ff00ff;
    /* Magenta for suspensions — stands out on yellow/orange tracks */
}

body.high-contrast .alert-base.delay {
    stroke-width: 26px;
    filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.7));
}

body.high-contrast .alert-base:not(.delay) {
    stroke-width: 26px;
    filter: drop-shadow(0 0 8px rgba(255, 0, 255, 0.7));
}

/* High contrast info popup indicators */
body.high-contrast .orange-indicator {
    background: linear-gradient(90deg, #00e5ff, #40efff) !important;
    box-shadow: 0 0 6px rgba(0, 229, 255, 0.6) !important;
}

body.high-contrast .red-indicator {
    background: linear-gradient(90deg, #ff00ff, #ff66ff) !important;
    box-shadow: 0 0 6px rgba(255, 0, 255, 0.6) !important;
}

/* High contrast overrides for hardcoded alert pulse colors */
body.high-contrast .svg-alert-pulse.red {
    fill: #ff00ff;
}

body.high-contrast .svg-alert-pulse.yellow {
    fill: #00e5ff;
}

body.high-contrast .alert-marker-pulse.red,
body.high-contrast .alert-marker-pulse.red::before {
    color: #ff00ff;
    background: #ff00ff;
}

body.high-contrast .alert-marker-pulse.yellow,
body.high-contrast .alert-marker-pulse.yellow::before {
    color: #00e5ff;
    background: #00e5ff;
}

/* Light mode footer - solid color, no gradient */
body.light-mode .bottom-nav {
    background: #c4c4c8;
    border: 1px solid rgba(0, 0, 0, 0.08);
    /* Full border override */
}

/* Light mode disclaimer banner */
body.light-mode .disclaimer-banner {
    background: rgba(200, 200, 205, 0.98);
    color: #000000;
    border: 1px solid rgba(0, 0, 0, 0.1);
    /* Full border override */
}

body.light-mode .disclaimer-banner .disclaimer-content {
    color: #000000;
}

/* Light mode FAB shadows */
body.light-mode .fab {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Ensure Info and Layers buttons get shadows (they have 3D animation spans) */
body.light-mode #btn-info,
body.light-mode #btn-legend {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

/* Line 5 Opening Soon label - light mode */
body.light-mode #line5-label rect {
    fill: #d4d4d8;
}

body.light-mode #line5-label text {
    fill: #1f2937;
}

/* Light mode sheet container */
body.light-mode .sheet-container {
    background: #d4d4d8;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
}

body.light-mode .sheet-handle {
    background: rgba(0, 0, 0, 0.2);
}

body.light-mode .sheet-title {
    color: #1f2937;
}

body.light-mode .sheet-subtitle {
    color: #4b5563;
}

/* Light mode alert cards */
body.light-mode .alert-card {
    background: rgba(0, 0, 0, 0.05);
}

body.light-mode .alert-title {
    color: #1f2937;
}

body.light-mode .alert-desc {
    color: #4b5563;
}

body.light-mode .alert-header {
    color: #1f2937;
}

body.light-mode .alert-body {
    color: #374151;
}

body.light-mode .alert-body div {
    color: #374151 !important;
}

/* Light mode station label styling */
body.light-mode .station-label {
    fill: #4b5563;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

body.light-mode .terminal-label {
    fill: #1f2937;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

body.light-mode .header-clock {
    text-shadow: none;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100dvh;
    position: fixed;
    /* Lock viewport */
}

/* --- Map Container --- */
#map-viewport {
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: 10;
}

canvas.vanta-canvas {
    z-index: -1 !important;
    position: absolute;
    left: 0;
    top: 0;
}

#map-root {
    transform-origin: center;
    /* Removed will-change to prevent blurry rasterization during scale */
    shape-rendering: geometricPrecision;
    /* Force crisp edges */
}

/* SVG Elements */
.track {
    fill: none;
    stroke-width: 18px;
    stroke-linecap: round;
    stroke-linejoin: round;
    /* Generic shadow removed, specific colored glows added to line classes below */
}

.line-1 {
    stroke: var(--l1-color);
    stroke: var(--l1-color);
}

.line-2 {
    stroke: var(--l2-color);
    stroke: var(--l2-color);
}

.line-4 {
    stroke: var(--l4-color);
    stroke: var(--l4-color);
}

.line-5 {
    stroke: var(--l5-color);
    /* Line 5 is now open - solid stroke like other lines */
}

.line-6 {
    stroke: var(--l6-color);
    stroke: var(--l6-color);
}

/* Line 5 Hollow Effect (Inner Line) */
.line-5-inner {
    stroke: var(--bg-color);
    stroke-width: 10px;
    fill: none;
    pointer-events: none;
}

/* Line Filter Buttons */
.line-filter {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.filter-btn {
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.filter-btn:hover {
    transform: scale(1.05);
}

.filter-btn.active {
    box-shadow: 0 0 0 2px white;
}

.filter-btn.bg-l1 {
    background: var(--l1-color);
    color: black;
}

.filter-btn.bg-l2 {
    background: var(--l2-color);
    color: white;
}

.filter-btn.bg-l4 {
    background: var(--l4-color);
    color: white;
}

.filter-btn.bg-l5 {
    background: var(--l5-color);
    color: white;
}

.filter-btn.bg-l6 {
    background: var(--l6-color);
    color: white;
}


.station-label {
    font-family: 'Inter';
    font-weight: 700;
    font-size: 12px;
    fill: var(--text-main);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
    pointer-events: none;
}

.terminal-label {
    font-size: 14px;
    font-weight: 800;
    fill: white;
}

.terminal-text {
    font-family: 'Inter';
    font-weight: 800;
    font-size: 14px;
    text-anchor: middle;
    dominant-baseline: middle;
    /* fill is set inline: black for Line 1, white for others */
}

/* Alert Styling on Map */
.alert-base {
    fill: none;
    stroke: var(--alert-color);
    stroke-width: 22px;
    stroke-linecap: round;
    pointer-events: none;
    opacity: 0.9;
}

.alert-base.delay {
    stroke: var(--delay-color);
}

/* Shuttle outline glow */
.shuttle-outline {
    fill: none;
    stroke: var(--shuttle-color);
    stroke-width: 30px;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 1;
}

/* Shuttle outline with directional flow - same dash pattern as alert, wider stroke for border effect */
.shuttle-outline.flow-forward {
    stroke-width: 28px;
    stroke-dasharray: 20, 45;
    animation: flowDash 1s linear infinite;
}

.shuttle-outline.flow-reverse {
    stroke-width: 28px;
    stroke-dasharray: 20, 45;
    animation: flowDashReverse 1s linear infinite;
}

.shuttle-outline.pulse-solid {
    stroke-dasharray: none;
    animation: pulseSolid 2s ease-in-out infinite;
}



.shuttle-mask {
    stroke: var(--bg-color) !important;
    opacity: 1 !important;
    animation: none !important;
    /* No pulse for the mask */
    stroke-dasharray: none;
    /* Ensure mask is solid */
}

.station-alert-glow {
    fill: var(--alert-color);
    stroke: none;
    animation: stationPulse 2s ease-in-out infinite;
}

.station-alert-dot {
    fill: var(--alert-color);
    fill-opacity: 0.5;
    stroke: none;
}

@keyframes stationPulse {

    0%,
    100% {
        r: 8;
        fill-opacity: 0.6;
    }

    50% {
        r: 16;
        fill-opacity: 0;
    }
}

/* Flow Animations */
.flow-forward {
    stroke-dasharray: 20, 45;
    /* 20px dash, 45px gap (More spaced) */
    stroke-width: 22px;
    animation: flowDash 1s linear infinite;
    /* Faster (1s) */
}

.flow-reverse {
    stroke-dasharray: 20, 45;
    stroke-width: 22px;
    animation: flowDashReverse 1s linear infinite;
}

.pulse-solid {
    animation: pulseSolid 2s ease-in-out infinite;
}

@keyframes flowDash {
    to {
        stroke-dashoffset: -65;
        /* Must match total length (20+45) */
    }
}

@keyframes flowDashReverse {
    to {
        stroke-dashoffset: 65;
    }
}

@keyframes pulseSolid {

    0%,
    100% {
        stroke-opacity: 0.6;
        stroke-width: 22px;
    }

    50% {
        stroke-opacity: 1;
        stroke-width: 26px;
    }
}

/* --- UI Overlays --- */
.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    /* Let touches pass to map */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Top Bar (Search / Status) */
/* Bar itself is pass-through so Ko-fi / other layers below .ui-layer can receive taps in gaps. */
.top-bar {
    padding: max(16px, env(safe-area-inset-top)) 16px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
}

.top-bar .fab-stack,
.top-bar .status-indicator {
    pointer-events: auto;
}

.top-bar .header-clock {
    pointer-events: none;
}

.search-pill {
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--surface-glass-border);
    border-radius: 50px;
    height: 48px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    width: 60px;
    /* Expands on focus */
    transition: width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    color: var(--text-main);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.search-pill.expanded {
    width: 100%;
}

.search-input {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 100%;
    margin-left: 12px;
    outline: none;
    font-size: 16px;
    display: none;
}

.search-pill.expanded .search-input {
    display: block;
}

/* FABs */
.fab-stack {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.fab {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--surface-glass-border);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

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

.fab i {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 3D Layer Button Animation */
#btn-legend {
    position: relative;
    /* Fix: Establish stacking context for absolute children */
    /* Removed skew/rotate to keep perfect circle */
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    transition: transform 0.5s;
    overflow: visible;
}

#btn-legend span {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface-glass);
    border: 1px solid var(--surface-glass-border);
    border-radius: 50%;
    transition: 0.5s;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(20px);
}

/* Top layer with icon */
#btn-legend .fab-icon {
    z-index: 5;
    background: var(--surface-glass);
    color: var(--text-main);
    font-size: 18px;
}

/* Active Effects (Menu Open) */
#btn-legend.active span:nth-child(5) {
    transform: translate(-12px, 0);
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

#btn-legend.active span:nth-child(4) {
    transform: translate(-9px, 0);
    opacity: 0.8;
    background: rgba(255, 255, 255, 0.1);
}

#btn-legend.active span:nth-child(3) {
    transform: translate(-6px, 0);
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.05);
}

#btn-legend.active span:nth-child(2) {
    transform: translate(-3px, 0);
    opacity: 0.4;
}

#btn-legend:hover span:nth-child(1),
#btn-legend.active span:nth-child(1) {
    transform: translate(0, 0);
    opacity: 0.2;
}

/* No icon rotation needed */
#btn-legend .fab-icon i {
    transform: none;
}

/* Layer Popup */
.layer-popup {
    position: absolute;
    top: 130px;
    right: 60px;
    width: 220px;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--surface-glass-border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 100;
    transition: opacity 0.5s ease-out, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), backdrop-filter 0.5s ease;
    transform-origin: top right;
    pointer-events: auto;
    max-height: 80vh;
    overflow-y: auto;
}

.layer-popup.hidden {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
    display: block;
    /* Override generic .hidden display: none */
}

/* Info Popup specific override */
#info-popup {
    transform-origin: top left;
    top: 70px !important;
    /* Move down below button */
}

/* 3D Info Button Animation (Reversed Direction) */
#btn-info {
    position: relative;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    transition: transform 0.5s;
    overflow: visible;
}

#btn-info span:not(.info-notif-dot) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface-glass);
    border: 1px solid var(--surface-glass-border);
    border-radius: 50%;
    transition: 0.5s;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(20px);
}

/* Top layer with icon */
#btn-info .fab-icon {
    z-index: 5;
    background: var(--surface-glass);
    color: var(--text-main);
    font-size: 18px;
}

/* Active Effects (Menu Open) - Translate RIGHT (Positive) */
#btn-info.active span:nth-child(5) {
    transform: translate(12px, 0);
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

#btn-info.active span:nth-child(4) {
    transform: translate(9px, 0);
    opacity: 0.8;
    background: rgba(255, 255, 255, 0.1);
}

#btn-info.active span:nth-child(3) {
    transform: translate(6px, 0);
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.05);
}

#btn-info.active span:nth-child(2) {
    transform: translate(3px, 0);
    opacity: 0.4;
}

#btn-info:hover span:nth-child(1),
#btn-info.active span:nth-child(1) {
    transform: translate(0, 0);
    opacity: 0.2;
}

#btn-info .fab-icon i {
    transform: none;
}

/* Header Clock */
.header-clock {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: var(--text-main);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-top: 4px;
    /* Slight adjustment */
    pointer-events: none;

    /* Box Styling */
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--surface-glass-border);
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.clock-time {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.clock-date {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 2px;
    font-weight: 500;
}

/* Disclaimer Banner */
/* Disclaimer Banner */
.disclaimer-banner {
    position: fixed;
    bottom: 30px;
    /* Cover floating footer */
    left: 20px;
    right: 20px;
    width: auto;
    border-radius: 20px;
    /* Floating Pill */
    background: rgba(22, 25, 31, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--surface-glass-border);
    padding: 16px 20px;
    /* Compact padding */
    z-index: 9999;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transform: translateY(150%);
    /* Start lower */
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    /* Strong lift */
}

.disclaimer-banner.visible {
    transform: translateY(0);
}

.disclaimer-content {
    display: flex;
    align-items: flex-start;
    color: #eee;
    font-size: 13px;
    line-height: 1.5;
}

#btn-accept-disclaimer {
    width: 100%;
    background: white;
    color: black;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.1s;
}

#btn-accept-disclaimer:active {
    transform: scale(0.98);
}

.layer-popup-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-main);
}

.info-popup-content {
    font-size: 13px;
    color: #ccc;
    margin-bottom: 15px;
    line-height: 1.4;
}

@media (prefers-color-scheme: light) {
    .layer-popup-title {
        color: #1f2937;
    }

    .info-popup-content {
        color: #4b5563;
    }

    .info-popup-footer {
        color: #000000;
        border-top-color: rgba(0, 0, 0, 0.1);
    }
}

/* Explicit Light Mode Class Override (for Toggle Button) */
.light-mode .layer-popup-title {
    color: #1f2937;
}

.light-mode .info-popup-content {
    color: #4b5563;
}

.light-mode .info-popup-footer {
    color: #000000;
    border-top-color: rgba(0, 0, 0, 0.1);
}

.info-popup-footer {
    font-size: 11px;
    color: var(--l1-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 10px;
    margin-top: 12px;
}

/* Walkthrough Sections for Info Popup */
.walkthrough-section {
    margin-bottom: 12px;
}

.walkthrough-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.walkthrough-text {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.walkthrough-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}

.walkthrough-list li {
    margin-bottom: 4px;
    padding-left: 12px;
    position: relative;
}

.walkthrough-list li::before {
    content: "•";
    color: var(--l1-color);
    position: absolute;
    left: 0;
}

.walkthrough-list li strong {
    color: var(--text-main);
}

/* Light mode walkthrough */
.light-mode .walkthrough-title {
    color: #1f2937;
}

.light-mode .walkthrough-text,
.light-mode .walkthrough-list {
    color: #4b5563;
}

.light-mode .walkthrough-list li strong {
    color: #1f2937;
}

/* Visual indicator items (with SVG previews) */
.walkthrough-visual-item {
    display: flex !important;
    align-items: center;
    padding-left: 0 !important;
}

.walkthrough-visual-item::before {
    display: none !important;
}

/* Colored bar indicators */
.visual-indicator {
    display: inline-block;
    width: 24px;
    height: 4px;
    border-radius: 2px;
    margin-right: 8px;
    flex-shrink: 0;
}

.red-indicator {
    background: linear-gradient(90deg, #FF3B30, #FF6B6B);
    box-shadow: 0 0 6px rgba(255, 59, 48, 0.6);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

.orange-indicator {
    background: linear-gradient(90deg, #FF9500, #FFB340);
    box-shadow: 0 0 6px rgba(255, 149, 0, 0.5);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

.blue-indicator {
    background: linear-gradient(90deg, #3478F6, #5A9CFF);
    box-shadow: 0 0 6px rgba(52, 120, 246, 0.5);
}

@keyframes pulse-glow {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
}

.layer-toggle input[type="checkbox"] {
    display: none;
}

.toggle-indicator {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid var(--surface-glass-border);
    transition: all 0.2s;
}

.toggle-indicator.outage {
    background: var(--alert-color);
}

.toggle-indicator.delay {
    background: var(--delay-color);
}

.layer-toggle input:not(:checked)+.toggle-indicator {
    opacity: 0.3;
}

.toggle-indicator.theme-toggle {
    border: 2px solid var(--text-muted);
    background: transparent;
}

.layer-toggle input:checked+.toggle-indicator.theme-toggle {
    background: var(--text-main);
    border-color: var(--text-main);
    opacity: 1;
}

/* --- Bottom Sheets --- */
/* The interactive area for sheets and nav */
.bottom-ui {
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.sheet-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 85vh;
    /* Max height */
    background: #16191f;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
    /* Hidden by default */
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 50;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    border-top: 1px solid var(--surface-glass-border);
}

.sheet-container.active {
    transform: translateY(0);
    /* Anchor to bottom of screen */
}

/* Inactive sheets still span most of the viewport; without this, descendants default to
   pointer-events: auto and steal taps meant for Ko-fi (z-index below .ui-layer). */
.sheet-container:not(.active),
.sheet-container.hidden {
    pointer-events: none !important;
}

.sheet-container:not(.active) *,
.sheet-container.hidden * {
    pointer-events: none !important;
}

.sheet-handle-area {
    width: 100%;
    padding: 16px;
    display: flex;
    justify-content: center;
    cursor: grab;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.sheet-header {
    padding: 0 24px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sheet-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.sheet-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 120px;
    /* Clear floating footer */
}

/* --- Bottom Navigation --- */
.bottom-nav {
    position: relative;
    /* Enable Z-Index */
    height: 70px;
    /* Fixed height for floating bar */
    flex-shrink: 0;
    margin: 0 20px 30px 20px;
    /* Floating margins */
    border-radius: 35px;
    /* Full pill shape */
    background: rgba(15, 16, 20, 0.85);
    /* Slightly transparent */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--surface-glass-border);
    display: flex;
    align-items: center;
    /* Vertically center items */
    justify-content: space-evenly;
    /* Even spacing */
    z-index: 100;
    pointer-events: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    /* Lift effect */
    padding: 0 6px;
    /* Inner padding for pills */
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    /* Animate hide/show */
}

/* Ensure padding for safe area logic is handled by margin on container if needed, 
   but bottom-ui handles layout. We just add margin-bottom. */

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 58px;
    /* Fit inside bar */
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Bouncy spring */
    cursor: pointer;
    border-radius: 30px;
    /* Pill shape for items */
    max-width: 100px;
    /* Prevent wide spread */
}

.nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
    transition: transform 0.2s;
}

.nav-item span {
    font-size: 10px;
    font-weight: 600;
    opacity: 0.7;
    transition: opacity 0.2s;
}

/* Active "Bubble" Selection */
.nav-item.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
    /* Light pill background */
    transform: scale(1.05);
    /* Pop effect */
}

.nav-item.active i {
    transform: translateY(0);
    /* No shift needed */
    color: var(--l1-color);
}

.nav-item.active span {
    opacity: 1;
}

/* Light Mode - Navigation and UI Elements */
.light-mode .nav-item {
    color: #4b5563;
}

.light-mode .nav-item.active {
    color: #1f2937;
    background: rgba(0, 0, 0, 0.08);
}

.light-mode .nav-item.active i {
    color: #1f2937;
}

.light-mode .layer-toggle {
    color: #4b5563;
}

.light-mode .layer-toggle span {
    color: #374151;
}

.light-mode .clock-time,
.light-mode .clock-date {
    color: #1f2937;
}

.light-mode .nav-badge {
    border-color: #d4d4d8;
}

.light-mode .layer-popup {
    background: rgba(230, 230, 235, 0.95);
}


/* Badges */
.nav-badge {
    position: absolute;
    opacity: 1 !important;
    /* Force solid */
    z-index: 10;
    top: -5px;
    /* Adjusted for relative container */
    right: -8px;
    /* Adjusted for relative container */
    background: var(--alert-color);
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #1a1d24;
}

.hidden {
    display: none;
}

/* Alert Cards */
.alert-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--alert-color);
    transition: transform 0.15s ease, background 0.15s ease;
}

.alert-card:hover {
    transform: scale(1.015);
    background: rgba(255, 255, 255, 0.06);
}

.alert-card:active {
    transform: scale(0.98);
}

.alert-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 10px;
}

.line-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    color: black;
}

.bg-l1 {
    background: var(--l1-color);
}

.bg-l2 {
    background: var(--l2-color);
    color: white;
}

.bg-l4 {
    background: var(--l4-color);
    color: white;
}

.alert-body {
    font-size: 14px;
    line-height: 1.4;
    color: #ddd;
}

.shuttle-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 6px 12px;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.line-5-inner {
    stroke: var(--bg-color);
    stroke-width: 10px;
    fill: none;
    pointer-events: none;
    stroke-dasharray: 15, 15;
    animation: dashFlow 1s linear infinite;
    opacity: 0.8;
}

@keyframes dashFlow {
    to {
        stroke-dashoffset: -30;
    }
}

/* --- Status Indicator (Loading/Live) --- */
.status-indicator {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%) translateY(70px);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--surface-glass-border);
    padding: 6px 14px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-main);
    transition: all 0.3s ease;
    pointer-events: none;
}

/* Loading State */
.status-indicator.loading .status-spinner {
    display: block;
}

.status-indicator.loading .live-dot {
    display: none;
}

.status-indicator.loading .status-text {
    color: var(--text-muted);
}

/* Live State */
.status-indicator.live .status-spinner {
    display: none;
}

.status-indicator.live .live-dot {
    display: block;
}

.status-indicator.live .status-text {
    color: #22c55e;
}

.status-indicator.live {
    border-color: rgba(34, 197, 94, 0.3);
}

.status-indicator.error .status-spinner,
.status-indicator.error .live-dot {
    display: none;
}

.status-indicator.error .status-text {
    color: #ef4444;
}

.status-indicator.error {
    border-color: rgba(239, 68, 68, 0.3);
}

.status-indicator.error::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #ef4444;
    border-radius: 50%;
    margin-right: 6px;
}

/* Spinner Animation */
.status-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--l1-color);
    border-radius: 50%;
    animation: spinnerRotate 0.8s linear infinite;
}

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

/* Live Dot with Pulse Animation */
.live-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    min-height: 8px;
    flex-shrink: 0;
    background: #22c55e;
    border-radius: 50%;
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
    }
}

/* Light Mode Overrides for Status Indicator */
body.light-mode .status-indicator {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.light-mode .status-indicator.live {
    border-color: rgba(34, 197, 94, 0.4);
}

/* Special Opening Alert Effect */
.special-opening-card {
    background: linear-gradient(135deg,
            rgba(243, 112, 33, 0.05) 0%,
            rgba(243, 112, 33, 0.15) 50%,
            rgba(243, 112, 33, 0.05) 100%);
    background-size: 200% 200%;
    animation: shimmerEffect 3s ease infinite;
    position: relative;
    overflow: hidden;
    border-left: 4px solid var(--l5-color) !important;
}

@keyframes shimmerEffect {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.special-opening-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: skewX(-20deg) translateX(-150%);
    animation: lightSweep 3s infinite;
    pointer-events: none;
}

@keyframes lightSweep {
    0% {
        transform: skewX(-20deg) translateX(-150%);
    }

    50% {
        transform: skewX(-20deg) translateX(150%);
    }

    100% {
        transform: skewX(-20deg) translateX(150%);
    }
}

/* Battery saver mode: roughly half-rate effects without killing the UI */
body.battery-saver #vanta-bg {
    display: none;
}

body.battery-saver .flow-forward,
body.battery-saver .flow-reverse,
body.battery-saver .shuttle-outline.flow-forward,
body.battery-saver .shuttle-outline.flow-reverse {
    animation-duration: 2s !important;
}

body.battery-saver .pulse-solid,
body.battery-saver .svg-alert-pulse.red,
body.battery-saver .svg-alert-pulse.yellow,
body.battery-saver .live-dot,
body.battery-saver .special-opening-card,
body.battery-saver .special-opening-card::after {
    animation-duration: 4s !important;
}

body.battery-saver .status-spinner {
    animation-duration: 1.6s !important;
}

/* Disable frosted-glass backdrop blur everywhere (mobile + shared UI when battery saver is on) */
body.battery-saver *,
body.battery-saver *::before,
body.battery-saver *::after {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}