/* Color Palette inspired by Coolors and modern UI
Light: Background #f0f4f8, Surface rgba(255,255,255,0.7), Accent #4361EE
Dark: Background #0f172a, Surface rgba(30,41,59,0.7), Accent #4CC9F0
*/

:root {
    /* UI Variables - Fluid Typography & Spacing */
    --font-family: 'Inter', sans-serif;
    --transition-speed: 0.3s;
    --border-radius: clamp(8px, 1.5vw, 12px);
    --navbar-height: clamp(60px, 8vh, 70px);
    --font-size-base: clamp(14px, 1.5vw, 16px);

    /* Fluid Spacing tokens */
    --pad-sm: clamp(8px, 1vw, 12px);
    --pad-md: clamp(12px, 2vw, 16px);
    --pad-lg: clamp(16px, 3vw, 24px);

    /* Light Theme (Default) */
    --bg-primary: #f0f4f8;
    --bg-secondary: rgba(255, 255, 255, 0.75);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent: #4361EE;
    --accent-hover: #3b52d9;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
    --canvas-bg: #e2e8f0;
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-primary: #0f172a;
    --bg-secondary: rgba(30, 41, 59, 0.75);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #4CC9F0;
    --accent-hover: #3db8de;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    --canvas-bg: #1e293b;
}

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

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    transition: background-color var(--transition-speed) ease;
}

/* Glassmorphism utility */
.glass {
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.icon-button {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 50%;
    /* Optimized touch targets */
    width: clamp(44px, 5vw, 48px);
    height: clamp(44px, 5vw, 48px);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
    /* Ensure taps work on mobile even inside touch-action:none containers */
    touch-action: manipulation;
}

.icon-button:hover {
    background-color: var(--border-color);
    color: var(--accent);
}

.app-container {
    display: flex;
    height: 100dvh;
    width: 100vw;
}

/* --- Main Content --- */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    /* Respect iPhone notch / Android nav bar */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Navbar --- */
.navbar {
    height: var(--navbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    z-index: 50;
    border-right: none;
}

.nav-left,
.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toggle-sidebar-btn {
    display: none;
}

.page-title {
    font-size: clamp(1.1rem, 2vw, 1.25rem);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.navbar-logo {
    height: clamp(52px, 7vh, 72px);
    width: auto;
    object-fit: contain;
    display: block;
}

.nav-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    height: 42px;
}

.nav-action-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.nav-action-btn .material-symbols-rounded {
    font-size: 20px;
}

[data-theme="dark"] .nav-action-btn {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
}

@media (max-width: 600px) {
    .nav-action-btn .btn-text {
        display: none;
    }

    .nav-action-btn {
        padding: 8px 12px;
        border-radius: 50%;
    }
}

/* Light mode: show dark logo. Dark mode: show light logo */
.logo-dark-mode {
    display: none;
}

[data-theme="dark"] .logo-light-mode {
    display: none;
}

[data-theme="dark"] .logo-dark-mode {
    display: block;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: border-color 0.2s;
}

.avatar:hover {
    border-color: var(--accent);
}

.theme-icon-dark {
    display: none !important;
}

[data-theme="dark"] .theme-icon-light {
    display: none !important;
}

[data-theme="dark"] .theme-icon-dark {
    display: block !important;
}

[data-theme="dark"] .glass {
    background: rgba(15, 23, 42, 0.75);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

/* User Explicit Request: White Borders in Dark Mode for Gallery Button & Zoom */
[data-theme="dark"] .zoom-controls,
[data-theme="dark"] .image-circle-button {
    border-color: white !important;
}
#mapWrapper {
    position: absolute;
    inset: 0;
    top: var(--navbar-height);
    z-index: 80;
    /* Behind Floorplan (z-index 200) */
    opacity: 1;
    /* Always rendering to pre-load tiles */
    pointer-events: none;
    visibility: visible;
    background-color: #000;
    width: 100%;
    height: calc(100dvh - var(--navbar-height));
}

#mapWrapper.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    z-index: 300;
    /* Moves to top when active */
}

#mapContainer {
    width: 100%;
    height: 100%;
    background: #e2e8f0;
}

.svg-viewport {
    flex-grow: 1;
    min-height: 0;
    position: relative;
    z-index: 200;
    /* Above Map (z-index 80) but below Map-Active (z-index 300) */
    background-color: var(--canvas-bg);
    overflow: hidden;
    cursor: grab;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    will-change: opacity, visibility;
    display: block;
    /* Restored: Interactive 2D Viewport */
    pointer-events: all;
}

/* Map Overlay Styling */
.floorplan-overlay.no-pointer {
    pointer-events: none !important;
}

/* Map Pin Premium Label Styling */
.pin-label-tooltip {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    color: #333 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
    font-family: 'Outfit', sans-serif !important;
    border-bottom: 2px solid #FFD600 !important;
    /* Matches yellow pin */
}

/* Remove default Leaflet tooltip arrow */
.pin-label-tooltip::before {
    display: none !important;
}

/* Ultra-Minimal Map Attribution */
.leaflet-control-attribution {
    font-size: 9px !important;
    opacity: 0.35;
    background: transparent !important;
    border: none !important;
    transition: opacity 0.3s ease;
    filter: grayscale(1);
}

.leaflet-control-attribution:hover {
    opacity: 1;
    filter: none;
}

.svg-viewport.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.svg-viewport:active {
    cursor: grabbing;
}

/* The div we apply CSS transform to for pan/zoom.
   NO will-change:transform — that causes the browser to rasterize the
   SVG at a fixed bitmap resolution, making it blur on zoom-in.
   Without it, the browser re-renders vector paths at every scale level. */
/* The div we apply CSS transform to for pan/zoom.
   Force hardware acceleration without permanent will-change rasterization. */
.svg-pan-layer {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    user-select: none;
    /* Hardware acceleration hints */
    backface-visibility: hidden;
    transform-style: preserve-3d;
    perspective: 1000px;
    /* Block browser gestures ONLY on the floorplan canvas, not overlay buttons */
    touch-action: none;
}

/* Smooth zoom-to-room: added temporarily by JS, removed after 700ms */
.svg-pan-layer.zooming {
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

/* The injected SVG element */
.svg-pan-layer svg {
    display: block;
    shape-rendering: geometricPrecision;
}

.svg-pan-layer svg path {
    shape-rendering: geometricPrecision;
    vector-effect: non-scaling-stroke;
}

.svg-pan-layer svg text {
    shape-rendering: geometricPrecision;
}

/* SVG paths — no hover, cursor shows intent */
.svg-pan-layer svg path {
    cursor: default;
    transition: fill 0.2s ease, stroke 0.2s ease;
}

/* ─── Room-cell outlines: click-to-select, NO hover effect ─── */
.svg-pan-layer svg path.room-cell {
    cursor: cell;
    /* crosshair/cell cursor signals selectability */
    transition: fill 0.2s ease, stroke 0.2s ease;
}

/* Non-whitelisted cells: no cursor change, no hover styling */
.svg-pan-layer svg path.room-cell:not(.selectable) {
    cursor: default;
    pointer-events: none;
    /* completely ignores mouse events */
}

/* Selectable room-cells: smooth color transition when style.fill changes via JS */
.svg-pan-layer svg path.room-cell.selectable {
    cursor: pointer;
    transition: fill 0.4s ease, stroke 0.4s ease, stroke-width 0.3s ease;
}


/* Overlay Controls - positioned relative to .main-content */
.zoom-controls {
    position: absolute;
    bottom: calc(var(--pad-lg) + env(safe-area-inset-bottom, 0px));
    right: var(--pad-lg);
    display: flex;
    flex-direction: column;
    gap: var(--pad-sm);
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    padding: var(--pad-sm);
    border-radius: 50px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease;
    touch-action: manipulation;
    z-index: 200;
}

/* --- Premium Circle Image Button --- */
.image-circle-button {
    position: absolute;
    bottom: calc(var(--pad-lg) + env(safe-area-inset-bottom, 0px));
    left: var(--pad-lg);
    width: clamp(48px, 8vw, 60px);
    height: clamp(48px, 8vw, 60px);
    border-radius: 50%;
    padding: 0;
    margin: 0;
    border: 3px solid var(--bg-secondary);
    background: var(--bg-secondary);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    overflow: hidden;
    z-index: 200;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    touch-action: manipulation;
}

.image-circle-button:hover {
    transform: scale(1.1);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.3);
    border-color: var(--accent);
}

.button-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.button-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.image-circle-button:hover .button-overlay {
    opacity: 1;
}

/* --- Gallery Modal (Vertical List) --- */
.gallery-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.gallery-modal.active {
    display: flex;
}

.gallery-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.5);
    color: white;
}

.gallery-close {
    background: none;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.gallery-close:hover {
    color: var(--accent);
}

.gallery-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 5%;
    display: flex;
    flex-direction: column;
    gap: 3rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.gallery-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    align-items: start;
}

.gallery-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    animation: slideUp 0.5s ease backwards;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.gallery-category {
    color: var(--accent);
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    width: 100%;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
    margin: 0;
}

.gallery-item h3 {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: left;
    padding-left: 0.5rem;
    border-left: 3px solid var(--accent);
}

.gallery-item img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* =============================================
   RESPONSIVE LAYOUT BREAKPOINTS
   Mobile-first scaling: 320px → 1440px+
   ============================================= */

/* --- Tablet & Mobile Unified (≤ 1024px) --- */
@media (max-width: 1024px) {
    :root {
        --navbar-height: 56px;
        --border-radius: 10px;
    }

    /* Navbar: compact, icons only, no title */
    .navbar {
        padding: 0 0.5rem;
    }

    .page-title {
        display: none;
    }

    .nav-right {
        gap: 0.25rem;
    }

    .nav-right .btn-text {
        display: none;
    }

    .nav-right .icon-button {
        min-width: 40px;
        min-height: 40px;
        width: 40px;
        height: 40px;
    }

    /* Restore zoom buttons on mobile per user request */
    .zoom-controls {
        display: flex;
        flex-direction: row;
        bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
        right: 50%;
        transform: translateX(50%);
        padding: 6px 12px;
        gap: 8px;
        z-index: 200 !important;
        /* Ensure it's not hidden */
        display: flex !important;
    }

    .zoom-controls .zoom-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    /* Image circle button: safe above bottom edge */
    .image-circle-button {
        width: 52px !important;
        height: 52px !important;
        bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)) !important;
        left: 0.75rem !important;
        z-index: 200 !important;
    }

    /* Status Legend: below navbar, collapsible wrapper */
    .status-legend {
        top: calc(var(--navbar-height) + 0.5rem);
        left: 0.5rem;
        padding: 6px 10px;
        min-width: 120px;
    }

    .legend-chevron {
        display: block !important;
        font-size: 18px;
        color: var(--text-secondary);
        transition: transform 0.2s ease;
    }

    .status-legend.expanded .legend-chevron {
        transform: rotate(180deg);
    }

    .legend-header {
        cursor: pointer;
    }

    /* Gallery: fullscreen takeover */
    .gallery-modal {
        padding: 0;
    }

    .gallery-header {
        border-radius: 0;
        height: var(--navbar-height);
        padding: 0 1rem;
    }

    .gallery-list-content {
        padding: 1rem;
        gap: 2rem;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .gallery-category {
        font-size: 1.15rem;
    }

    .gallery-item img {
        border-radius: 8px;
    }
}

/* --- Cinematic Photorealistic Loader --- */
.app-loader.cinematic-theme {
    background: #000;
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Cinematic Overlays (Keeping for subtle texture) */

/* Cinematic Overlays */
.loader-bg-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.6) 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1;
}

/* Subtile Film Grain / Noise Overlay */
.film-grain {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
    opacity: 0.15;
    pointer-events: none;
    z-index: 2;
    mix-blend-mode: overlay;
}

.loader-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    justify-content: center;
}

/* 2. Metallic Branding with Light Shimmer */
.metallic-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    animation: cinematicFadeIn 2.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.logo-wrapper {
    position: relative;
    overflow: hidden;
    padding: 10px;
}

.metallic-logo {
    width: clamp(100px, 15vw, 150px);
    height: clamp(100px, 15vw, 150px);
    object-fit: contain;
    transform-origin: bottom center;
    animation: logoGrowUp 4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes logoGrowUp {
    0% {
        transform: translateY(20px) scale(0.85);
        opacity: 0;
    }
    100% {
        transform: translateY(-10px) scale(1.05);
        opacity: 1;
    }
}

.brand-text-cinematic {
    font-family: 'Inter', sans-serif;
    font-size: clamp(2.2rem, 10vw, 4rem);
    font-weight: 200;
    letter-spacing: 0.7em;
    color: #FFFFFF;
    margin-right: -0.7em;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    animation: textExpand 15s linear infinite alternate;
}

@keyframes textExpand {
    from {
        letter-spacing: 0.6em;
    }

    to {
        letter-spacing: 0.8em;
    }
}

/* 3. Central Ultra-Thin Progress with Laser Spark */
.central-progress-wrapper {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    z-index: 5;
}

.full-width-track {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.05);
}
/* --- WhatsApp Floating Action Button (FAB) --- */
.whatsapp-fab {
    position: fixed;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    right: 1.5rem;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    border-radius: 50px;
    background: rgba(37, 211, 102, 0.15); /* WhatsApp Green Tint */
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    transform: translateY(30px) scale(0.9);
    pointer-events: none;
    box-shadow: 0 12px 40px rgba(37, 211, 102, 0.3);
}

.whatsapp-fab.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    animation: wa-pulse 3s infinite;
}

.whatsapp-fab:hover {
    background: rgba(37, 211, 102, 0.3);
    border-color: rgba(37, 211, 102, 0.6);
    transform: translateY(-5px) scale(1.05);
}

.wa-icon {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.whatsapp-fab .btn-text {
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

@keyframes wa-pulse {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

@media (max-width: 600px) {
    .whatsapp-fab {
        bottom: calc(1rem + 60px + env(safe-area-inset-bottom, 0px)); /* Safe above zoom controls */
        right: 1rem;
        padding: 10px 20px;
    }
    
    .whatsapp-fab .btn-text {
        font-size: 0.85rem;
    }
}

.active-progress-line {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #FFFFFF 0%, #E0E7FF 50%, #FFFFFF 100%);
    background-size: 200% 100%;
    position: relative;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.6);
    animation: barShimmer 2s linear infinite;
}

@keyframes barShimmer {
    0% {
        background-position: 200% 0;
    }

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

.progress-spark {
    position: absolute;
    right: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background: #FFFFFF;
    border-radius: 50%;
    box-shadow: 0 0 20px 6px rgba(255, 255, 255, 1);
    animation: sparkPulse 1.5s ease-in-out infinite;
}

@keyframes sparkPulse {

    0%,
    100% {
        transform: translateY(-50%) scale(1);
        opacity: 0.8;
    }

    50% {
        transform: translateY(-50%) scale(1.2);
        opacity: 1;
        box-shadow: 0 0 25px 8px rgba(255, 255, 255, 1);
    }
}

/* 4. Status & Trivia - Smooth Blur-In Transition */
.loader-status-container {
    position: absolute;
    bottom: 8%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.percentage-count {
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    font-weight: 200;
    color: rgba(255, 255, 255, 1);
    letter-spacing: 0.3em;
    animation: cinematicFadeIn 3s ease;
}

.trivia-text {
    font-size: clamp(0.65rem, 2vw, 0.75rem);
    font-weight: 400;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    text-align: center;
    max-width: 85vw;
    transition: opacity 0.4s ease-in-out;
}

.trivia-text.transitioning {
    opacity: 0;
}

@keyframes cinematicFadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulseFade {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

/* App Transition Logic */
.app-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Responsive Cinematic Adjustments */
@media (max-width: 600px) {
    .metallic-brand {
        gap: 0.8rem;
        margin-bottom: 2rem;
    }

    .metallic-logo {
        width: 70px;
        height: 70px;
    }

    .brand-text-cinematic {
        font-size: clamp(1.4rem, 7vw, 1.8rem);
        letter-spacing: 0.35em;
        margin-right: -0.35em;
    }

    .loader-status-container {
        bottom: 12%;
    }

    .percentage-count {
        font-size: 1rem;
    }

    .trivia-text {
        font-size: 0.55rem;
        max-width: 85vw;
        line-height: 1.4;
    }
}

/* Vertical Responsiveness for short devices */
@media (max-height: 500px) {
    .metallic-brand {
        margin-bottom: 1rem;
    }

    .loader-status-container {
        bottom: 5%;
    }
}

/* --- Main Content --- */

/* --- Status Button Active State --- */
.status-btn.active {
    background-color: var(--accent);
    color: #fff;
}

.status-btn.active:hover {
    background-color: var(--accent-hover);
    color: #fff;
}

/* --- Status Legend Overlay --- */
.status-legend {
    position: absolute;
    top: calc(var(--navbar-height) + var(--pad-md));
    left: var(--pad-md);
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: var(--pad-sm) var(--pad-md);
    display: none;
    flex-direction: column;
    z-index: 200;
    min-width: clamp(140px, 15vw, 160px);
    animation: fadeIn 0.25s ease;
    transition: all 0.3s ease;
    touch-action: manipulation;
}

.status-legend.active {
    display: flex;
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.legend-content {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
    animation: fadeIn 0.2s ease;
}

/* Desktop open by default, handled by JS toggle via .expanded */
.status-legend.expanded .legend-content {
    display: flex;
}

.legend-title {
    font-size: clamp(0.65rem, 1vw, 0.7rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: clamp(0.75rem, 1.2vw, 0.82rem);
    font-weight: 500;
    color: var(--text-primary);
}


.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* --- Leaflet Map Styles --- */
.leaflet-container {
    width: 100%;
    height: 100%;
    background: #e2e8f0;
    z-index: 1;
}

.leaflet-pane {
    z-index: 2 !important;
}

.leaflet-tile-pane {
    z-index: 2 !important;
}

.leaflet-overlay-pane {
    z-index: 3 !important;
}

.leaflet-shadow-pane {
    z-index: 4 !important;
}

.leaflet-marker-pane {
    z-index: 5 !important;
}

.leaflet-tooltip-pane {
    z-index: 6 !important;
}

.leaflet-popup-pane {
    z-index: 7 !important;
}

.leaflet-control-zoom {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    box-shadow: var(--shadow);
    z-index: 10 !important;
}

.leaflet-control-zoom a {
    background: transparent;
    color: var(--text-primary);
    border: none;
    width: 40px;
    height: 40px;
    line-height: 40px;
    font-size: 18px;
    transition: background-color 0.2s;
}

.leaflet-control-zoom a:hover {
    background-color: var(--border-color);
    color: var(--accent);
}

.leaflet-control-zoom a:first-child {
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.leaflet-control-zoom a:last-child {
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.leaflet-tile {
    opacity: 1 !important;
    visibility: visible !important;
}

.leaflet-image-layer {
    opacity: 1 !important;
    visibility: visible !important;
}

/* --- Labeling Studio HUD --- */
.labeling-hud {
    position: fixed;
    top: 100px;
    left: 20px;
    width: 280px;
    z-index: 10000;
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
}

.hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    color: var(--accent);
}

.hud-header button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.hud-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.hud-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.hud-group label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.6;
}

.hud-group input[type="text"],
.hud-group input[type="number"] {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    font-size: 0.9rem;
    width: 100%;
}

.hud-footer {
    font-size: 0.65rem;
    opacity: 0.5;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.hud-group input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
}

.hud-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-small-input {
    width: 65px !important;
    text-align: center;
    padding: 4px !important;
    background: rgba(255, 255, 255, 0.05) !important;
}

.hud-btn {
    padding: 12px;
    border-radius: 10px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.hud-btn.primary {
    background: var(--accent);
    color: white;
}

.hud-actions {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.step-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--accent);
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 800;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.step-btn:hover {
    background: var(--accent);
    color: white;
}

.hud-group input[type="number"] {
    flex: 1;
    text-align: center;
}

/* --- Premium Gallery Styles --- */
.gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.gallery-modal.active {
    opacity: 1;
    visibility: visible;
}

.gallery-header {
    padding: 1.5rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
}

.gallery-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: white;
    letter-spacing: 0.02em;
    font-weight: 500;
}

.gallery-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-close .material-symbols-rounded {
    font-size: 24px;
}

.gallery-close:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: rotate(90deg);
}

.gallery-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 3rem 5%;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.gallery-section {
    margin-bottom: 4rem;
}

.gallery-category {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    color: var(--accent);
    margin-bottom: 2rem;
    font-weight: 600;
    opacity: 0.8;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

.gallery-item {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    aspect-ratio: 16/10;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    animation: slideInUp 0.6s ease backwards;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.gallery-item h3 {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 2rem 1.5rem 1rem;
    margin: 0;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    z-index: 2;
    transition: transform 0.4s ease;
}

.gallery-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.gallery-item:hover img {
    transform: scale(1.08);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .gallery-header h2 {
        font-size: 1.5rem;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .gallery-item {
        aspect-ratio: 16/11;
    }
}

/* Active Highlight */
.movable-label.active-edit rect {
    stroke: var(--accent);
    stroke-width: 50;
    stroke-dasharray: 100, 50;
}