/* Base reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0a0a0c;
    --surface: #141418;
    --surface-hover: #1a1a1f;
    --border: #2a2a30;
    --text: #e8e8ec;
    --text-muted: #888890;
    --accent: #c41e3a;
    --accent-glow: rgba(196, 30, 58, 0.4);
    --accent-light: #e63950;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Courier New', monospace;
    background: var(--bg);
    color: var(--text);
    overflow: auto;
}

body {
    padding-top: 28px; /* Offset for fixed menu bar */
}

/* List items */
li {
    margin-top: 5px;
    margin-bottom: 5px;
}

/* Strong elements */
strong {
    margin-top: 3px;
    margin-bottom: 3px;
}

/* Map Container - covers viewport, scrollable */
.map-container {
    position: relative;
    line-height: 0;
    display: inline-block;
    transition: transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1),
                transform-origin 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}


.map-container.zoomed {
    transform: scale(1.8);
}

.map-image {
    display: block;
}

#markersLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Markers - 5x5px visual with 6px touch target */
.marker {
    position: absolute;
    width: 6px;
    height: 6px;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 10;
    transition: left 1s cubic-bezier(0.22, 1, 0.36, 1),
                top 1s cubic-bezier(0.22, 1, 0.36, 1);
    /* Touch target is 6px, visual dot is centered via ::before */
}

/* Reduced motion: skip entrance animation */
@media (prefers-reduced-motion: reduce) {
    .marker {
        transition: none;
    }
}

.marker::before {
    content: '';
    position: absolute;
    width: 5px;
    height: 5px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 3px rgba(255,255,255,0.4), 0 0 6px rgba(255,255,255,0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.marker:hover::before,
.marker.touched::before {
    background: var(--marker-color, var(--accent));
    transform: translate(-50%, -50%) scale(1.6);
    box-shadow: 0 0 6px color-mix(in srgb, var(--marker-color, var(--accent)) 40%, transparent),
                0 0 12px color-mix(in srgb, var(--marker-color, var(--accent)) 40%, transparent);
}

/* Marker Label Tooltip */
.marker-label {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 4px 8px;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s ease;
    color: var(--text);
}

.marker:hover .marker-label,
.marker.touched .marker-label {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    color: var(--marker-color, var(--text));
}

.marker-label::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border);
}

/* Admin specific */
.admin-header {
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header h1 {
    font-size: 14px;
    font-weight: normal;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.admin-map-container {
    cursor: crosshair;
}

.admin-map-container .marker {
    cursor: pointer;
}

.admin-map-container .marker.selected::before {
    background: var(--accent-light);
    transform: scale(1.4);
}

/* Admin Tabs */
.admin-tabs {
    display: flex;
    gap: 4px;
}

.admin-tab {
    padding: 6px 16px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-tab:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.admin-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text);
}

/* Admin Dashboard */
.admin-dashboard {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 20px;
    text-align: center;
}

.stat-card--accent {
    border-color: var(--accent);
    background: rgba(196, 30, 58, 0.1);
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--text);
    line-height: 1;
    margin-bottom: 8px;
}

.stat-card--accent .stat-value {
    color: var(--accent);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.dashboard-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 20px;
}

.dashboard-panel--full {
    grid-column: 1 / -1;
}

.dashboard-panel h3 {
    font-size: 12px;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

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

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-size: 11px;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.data-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-scroll {
    max-height: 400px;
    overflow-y: auto;
}

/* Event Type Badges */
.event-type {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 2px;
    background: var(--border);
    color: var(--text);
}

.event-type--page_view { background: #1a4d1a; }
.event-type--marker_click { background: #4d1a4d; }
.event-type--content_view { background: #1a3d4d; }
.event-type--video_play { background: #4d3d1a; }
.event-type--chat_open { background: #4d1a1a; }

/* Chat Log Viewer */
.chat-log-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
}

.log-select {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.log-select:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-small {
    padding: 6px 12px;
    font-size: 11px;
}

.log-viewer {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-muted);
}

/* Mobile Dashboard */
@media (max-width: 768px) {
    .admin-dashboard {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px 12px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .admin-header {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .admin-tabs {
        order: 3;
        width: 100%;
    }
    
    .admin-tab {
        flex: 1;
        text-align: center;
    }
}

/* Forms */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 40px;
    width: 100%;
    max-width: 320px;
}

.login-box h1 {
    font-size: 12px;
    font-weight: normal;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 32px;
    text-align: center;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 10px 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.15s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

button, .btn {
    background: var(--accent);
    border: none;
    color: var(--text);
    padding: 10px 20px;
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s ease;
}

button:hover, .btn:hover {
    background: var(--accent-light);
}

.btn-secondary {
    background: var(--surface);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}

.btn-danger:hover {
    background: var(--accent);
    color: var(--text);
}

/* Marker Edit Panel */
.edit-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: var(--surface);
    border-left: 1px solid var(--border);
    padding: 24px;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 100;
    overflow-y: auto;
}

.edit-panel.open {
    transform: translateX(0);
}

.edit-panel h2 {
    font-size: 11px;
    font-weight: normal;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.edit-panel .btn-group {
    display: flex;
    gap: 8px;
    margin-top: 24px;
}

.edit-panel .btn-group button {
    flex: 1;
}

.close-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.close-panel:hover {
    color: var(--text);
    background: none;
}

/* Screenshot preview in admin */
.screenshot-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screenshot-preview img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.screenshot-preview.has-image img {
    display: block;
}

.screenshot-preview.has-image .screenshot-placeholder {
    display: none;
}

.screenshot-placeholder {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Video preview in admin */
.video-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-preview video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-placeholder {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.video-source-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    border-radius: 3px;
}

/* Error message */
.error {
    background: rgba(196, 30, 58, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent-light);
    padding: 10px 14px;
    font-size: 12px;
    margin-bottom: 16px;
}

/* Menu text abbreviations - default to full labels */
.menu-text-full {
    display: inline;
}

.menu-text-short,
.menu-text-abbrev {
    display: none;
}

.menu-text-circle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
}

/* Mobile view: show abbreviated menu */
@media (max-width: 1024px) {
    .lab-menubar .menu-text-full {
        display: none !important;
    }

    .lab-menubar .menu-text-abbrev {
        display: inline !important;
    }

    .lab-menubar .menu-text-circle {
        display: inline-flex !important;
    }
}

/* Desktop view: enforce full labels only */
@media (min-width: 1025px) {
    .lab-menubar .menu-text-full {
        display: inline !important;
    }

    .lab-menubar .menu-text-short,
    .lab-menubar .menu-text-abbrev,
    .lab-menubar .menu-text-circle {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .edit-panel {
        width: 100%;
    }
    
    .admin-header {
        padding: 12px 16px;
    }
    
    .admin-header h1 {
        font-size: 12px;
    }
    
    .popup-window {
        min-width: 260px;
        left: 50% !important;
        transform: translateX(-50%);
    }
    
    .popup-window:not(.maximized) {
        top: 35px !important;
    }
    
    .popup-window.maximized {
        left: 0 !important;
        transform: none;
        top: 28px !important;
        max-width: 100vw;
        height: calc(100vh - 28px) !important;
        max-height: calc(100vh - 28px);
    }
    
    .popup-window.auto-height {
        max-height: calc(100vh - 35px);
    }
}

/* macOS-style Popup Window */
.popup-window {
    position: fixed;
    width: 336px;
    height: 252px;
    min-width: 280px;
    min-height: 150px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    z-index: 500;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.popup-window.minimized {
    height: auto !important;
    min-height: 0;
}

.popup-window.minimized .popup-content,
.popup-window.minimized .popup-resize-handle {
    display: none;
}

.popup-window.auto-height {
    height: auto;
    max-height: calc(100vh - 40px);
}

.popup-window.auto-height .popup-content {
    flex: none;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.popup-window.auto-height .popup-embed {
    height: auto;
    min-height: 300px;
}

.popup-window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0;
    z-index: 9999 !important;
}

.popup-window.maximized .popup-titlebar {
    position: relative;
    z-index: 10;
}

.popup-titlebar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px;
    background: linear-gradient(180deg, rgba(60, 60, 68, 0.9) 0%, rgba(40, 40, 48, 0.95) 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.3);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.popup-titlebar:active {
    cursor: grabbing;
}

.popup-controls {
    display: flex;
    gap: 8px;
}

.popup-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    position: relative;
    transition: filter 0.15s ease;
    z-index: 10;
}

.popup-btn:hover {
    filter: brightness(1.1);
}

.popup-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.popup-controls:hover .popup-btn::before {
    opacity: 1;
}

.popup-close {
    background: #ff5f57;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15) inset;
}

.popup-close::before {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3.5 3.5l5 5M8.5 3.5l-5 5' stroke='%234a0002' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E") center/8px no-repeat;
}

.popup-minimize {
    background: #febc2e;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15) inset;
}

.popup-minimize::before {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6h7' stroke='%239a6600' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") center/8px no-repeat;
}

.popup-maximize {
    background: #28c840;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15) inset;
}

.popup-maximize::before {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 3.5h2.5V6M9 8.5H6.5V6M3 3.5L9 8.5' stroke='%230b6a18' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/8px no-repeat;
}

.popup-title {
    flex: 1;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.popup-external {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.popup-external:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.popup-external svg {
    width: 14px;
    height: 14px;
}

.popup-content {
    flex: 1;
    overflow: hidden;
    background: #fff;
    position: relative;
}

.popup-content.has-embed {
    background: var(--bg);
}

.popup-content.has-video {
    background: #000;
}

.popup-video {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.popup-video video,
.popup-video iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.popup-video video {
    object-fit: contain;
}

/* Hide blocked overlay when has video */
.popup-content.has-video .popup-blocked {
    display: none !important;
}

.popup-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.popup-embed {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: var(--bg);
    overflow: auto;
    padding: 8px;
}

.popup-embed iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Twitter/X embed specific styles */
.popup-embed .twitter-tweet {
    margin: 0 auto !important;
}

.popup-embed .twitter-tweet-rendered {
    margin: 0 auto !important;
}

/* Instagram embed - direct iframe approach */
.popup-instagram {
    padding: 0 !important;
    overflow: hidden !important;
}

.popup-instagram iframe {
    width: 100% !important;
    height: 100% !important;
    min-height: 500px;
    border: none !important;
    background: var(--bg);
}

/* Instagram content area needs full height */
.popup-content.has-instagram {
    display: flex;
    flex-direction: column;
}

.popup-content.has-instagram .popup-instagram {
    flex: 1;
    min-height: 0;
}

/* Fallback: Instagram SDK blockquote styles */
.popup-embed .instagram-media {
    margin: 0 auto !important;
    background: transparent !important;
    min-width: 300px !important;
    max-width: 100% !important;
}

.popup-embed .instagram-media-rendered {
    margin: 0 auto !important;
    max-width: 100% !important;
}

/* Instagram iframe wrapper - rendered by Instagram SDK */
.popup-embed .instagram-media-rendered iframe,
.popup-embed iframe[src*="instagram.com"] {
    background: var(--bg) !important;
    color-scheme: dark !important;
    min-height: 500px;
}

/* When has embed, don't show blocked overlay */
.popup-content.has-embed .popup-blocked {
    display: none !important;
}

.popup-blocked {
    position: absolute;
    inset: 0;
    background-color: var(--bg);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    display: none;
    align-items: center;
    justify-content: center;
}

.popup-content.blocked .popup-blocked {
    display: flex;
}

.popup-content.blocked iframe {
    visibility: hidden;
}

.popup-blocked-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    padding: 20px 24px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    border-radius: 8px;
}

.popup-blocked-overlay p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    margin: 0;
    letter-spacing: 0.5px;
}

.popup-blocked-link {
    color: #fff;
    text-decoration: none;
    font-size: 11px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    transition: background 0.15s;
}

.popup-blocked-link:hover {
    background: rgba(255, 255, 255, 0.25);
}

.popup-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.1) 50%);
}

/* macOS-style Laboratory Menu Bar */
.lab-menubar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: linear-gradient(180deg, #2d2d32 0%, #1d1d22 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
    z-index: 1000;
    display: flex;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

.lab-menubar__nav {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 8px;
    gap: 0;
}

.lab-menubar__symbol {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 100%;
    font-size: 16px;
    color: var(--text);
    opacity: 0.9;
    cursor: default;
    transition: background 0.1s ease;
}

.lab-menubar__symbol:hover {
    background: rgba(255, 255, 255, 0.1);
}

.lab-menubar__item {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 12px;
    min-height: 44px; /* Touch target improvement */
    min-width: 44px;
    color: var(--text);
    cursor: default;
    transition: background 0.1s ease;
    white-space: nowrap;
}

.lab-menubar__item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.lab-menubar__item:active {
    background: rgba(255, 255, 255, 0.15);
}

.lab-menubar__item--app {
    font-weight: 600;
    letter-spacing: -0.2px;
}

/* Dropdown menus */
.lab-menubar__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: linear-gradient(180deg, rgba(50, 50, 56, 0.98) 0%, rgba(38, 38, 44, 0.98) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.3);
    padding: 4px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.lab-menubar__item:hover > .lab-menubar__dropdown,
.lab-menubar__symbol:hover > .lab-menubar__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Mobile: use focus-based dropdown instead of hover */
@media (max-width: 1024px) {
    /* Hide hover-triggered dropdowns on mobile */
    .lab-menubar__item:hover > .lab-menubar__dropdown {
        opacity: 0;
        visibility: hidden;
    }
    
    /* Show dropdown when item has focus (tap = focus on mobile) */
    .lab-menubar__item:focus > .lab-menubar__dropdown,
    .lab-menubar__item.menu-open > .lab-menubar__dropdown {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: translateY(0) !important;
        display: block !important;
    }
    
    /* Ensure menubar fills viewport */
    .lab-menubar {
        min-width: 100vw;
        width: 100vw;
    }
    
    /* Hide rhombus symbol on mobile */
    .lab-menubar__symbol {
        display: none !important;
    }
    
    /* Move Info/? menu to the start on mobile */
    .lab-menubar__nav {
        display: flex;
    }
    
    .lab-menubar__item--info {
        order: -1 !important;
    }
}

.lab-menubar__dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    min-height: 44px; /* Touch target improvement */
    color: var(--text);
    font-size: 13px;
    cursor: default;
    transition: background 0.08s ease;
}

.lab-menubar__dropdown-item:hover {
    background: rgba(59, 130, 246, 0.85);
}

.lab-menubar__dropdown-item--disabled {
    color: var(--text-muted);
    pointer-events: none;
}

.lab-menubar__dropdown-item--disabled:hover {
    background: none;
}

.lab-menubar__dropdown-sep {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 12px;
}

.lab-menubar__shortcut {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: 24px;
}

.lab-menubar__dropdown-item:hover .lab-menubar__shortcut {
    color: rgba(255, 255, 255, 0.7);
}

.lab-menubar__arrow {
    color: var(--text-muted);
    font-size: 14px;
}

.lab-menubar__dropdown-item:hover .lab-menubar__arrow {
    color: rgba(255, 255, 255, 0.7);
}

/* Magnetic radial cursor tracker */
.magnetic-radial {
    --ring-size: 72px;
    --dot-size: 10px;
    --trap-padding: 2;
    --magnetic-color: var(--accent);
    --magnetic-glow: var(--accent-glow);

    position: fixed;
    left: 0;
    top: 0;
    width: var(--ring-size);
    height: var(--ring-size);
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(20, 20, 24, 0.35);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35) inset;
    z-index: 200;
    pointer-events: none;
    transform: translate3d(calc(var(--x, 50vw) - 50%), calc(var(--y, 50vh) - 50%), 0);
    opacity: 0;
    transition: opacity 150ms ease;
}

@supports (color: color-mix(in srgb, white 50%, black)) {
    .magnetic-radial {
        border-color: color-mix(in srgb, var(--magnetic-color) 55%, var(--border));
        background: color-mix(in srgb, var(--surface) 45%, transparent);
    }
}

.magnetic-radial::before {
    content: '';
    position: absolute;
    inset: -14px;
    border-radius: inherit;
    background: radial-gradient(circle, var(--magnetic-glow), transparent 60%);
    opacity: 0;
    transition: opacity 180ms ease;
}

.magnetic-radial.is-active {
    opacity: 0.92;
    border-color: var(--magnetic-color);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35) inset, 0 0 14px var(--magnetic-glow);
}

.magnetic-radial.is-active::before {
    opacity: 1;
}

.magnetic-radial__dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--dot-size);
    height: var(--dot-size);
    border-radius: 999px;
    background: var(--magnetic-color);
    box-shadow: 0 0 10px var(--magnetic-glow), 0 0 20px color-mix(in srgb, var(--magnetic-color) 25%, transparent);
    will-change: transform;
    transform: translate3d(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px)), 0);
}

/* ==============================
   ACCESSIBILITY UTILITIES
   ============================== */

/* Skip navigation link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent);
    color: var(--text);
    padding: 8px 16px;
    z-index: 9999;
    text-decoration: none;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==============================
   MOBILE MARKER DISAMBIGUATION MENU
   ============================== */

.marker-sheet {
    display: none;
    position: fixed;
    z-index: 250;
    pointer-events: none;
}

.marker-sheet.open {
    pointer-events: auto;
}

/* Backdrop covers full screen */
.marker-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 249;
}

.marker-sheet.open .marker-sheet-backdrop {
    opacity: 1;
}

/* Floating context menu near tap point */
.marker-sheet-content {
    position: relative;
    z-index: 251;
    min-width: 180px;
    max-width: 280px;
    max-height: 50vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.marker-sheet.open .marker-sheet-content {
    transform: scale(1);
    opacity: 1;
}

.marker-sheet-handle {
    display: none;
}

.marker-sheet-title {
    padding: 10px 14px;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.marker-sheet-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.marker-sheet-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    min-height: 44px;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s ease;
}

.marker-sheet-item:last-child {
    border-bottom: none;
}

.marker-sheet-item:active {
    background: var(--surface-hover);
}

.marker-sheet-item::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--marker-color, var(--accent));
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
}

/* Only show on mobile */
@media (max-width: 600px) {
    .marker-sheet {
        display: block;
    }
}

/* ==============================
   ABOUT PAGE STYLES
   ============================== */

.about-page {
    padding-top: 0;
    overflow-x: hidden;
}

.about-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: linear-gradient(180deg, #2d2d32 0%, #1d1d22 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 24px;
}

.about-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.about-nav__back {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    font-size: 13px;
    transition: opacity 0.15s ease;
}

.about-nav__back:hover {
    opacity: 0.8;
}

.about-nav__symbol {
    font-size: 18px;
    opacity: 0.9;
}

.about-nav__title {
    font-weight: 500;
    letter-spacing: -0.2px;
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    gap: 4px;
}

.lang-switcher__item {
    padding: 6px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.lang-switcher__item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.lang-switcher__item.active {
    color: var(--text);
    border-color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

/* About Content Container */
.about-content {
    padding: 80px 24px 64px;
    max-width: 800px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
}

/* Article Header */
.about-article__header {
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.about-article h1 {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    font-size: 28px;
    font-weight: 500;
    letter-spacing: -0.3px;
    line-height: 1.3;
    margin-bottom: 12px;
    color: var(--text);
}

.about-article__subtitle {
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* Introduction */
.about-intro {
    font-size: 15px;
    line-height: 1.9;
    margin-bottom: 40px;
    color: var(--text);
}

.about-intro p {
    margin-bottom: 20px;
}

.about-intro u {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.5);
    text-underline-offset: 3px;
}

.about-intro em {
    font-style: italic;
    color: var(--text);
}

/* Table of Contents */
.about-toc {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 20px 28px;
    margin: 32px 0 48px;
}

.about-toc h2 {
    font-size: 10px;
    font-weight: normal;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 16px;
    padding: 0;
    border: none;
}

.about-toc ol {
    list-style-position: inside;
    counter-reset: toc-counter;
    padding: 0;
    margin: 0;
}

.about-toc li {
    counter-increment: toc-counter;
    list-style: none;
    margin-bottom: 8px;
}

.about-toc li::before {
    content: counter(toc-counter) ".";
    color: var(--text-muted);
    margin-right: 8px;
    font-size: 12px;
}

.about-toc a {
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.15s ease;
}

.about-toc a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Sections */
.about-section {
    margin-bottom: 56px;
}

.about-section h2 {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin: 0 0 24px;
    padding-bottom: 12px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.about-section p {
    font-size: 14px;
    line-height: 1.85;
    color: var(--text);
    margin-bottom: 20px;
}

.about-section p:last-child {
    margin-bottom: 0;
}

.about-section li {
    font-size: 14px;
}

.about-section u {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.5);
    text-underline-offset: 3px;
}

.about-section em {
    font-style: italic;
}

/* FAQ Section */
.about-faq {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 28px 32px;
    margin-top: 64px;
}

.about-faq h2 {
    margin-top: 0;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.faq-list {
    margin: 0;
}

.faq-list dt {
    font-size: 13px;
    font-weight: normal;
    color: var(--text);
    margin: 24px 0 8px;
    padding-left: 0;
}

.faq-list dt:first-child {
    margin-top: 0;
}

.faq-list dt::before {
    content: "Q: ";
    color: var(--text);
}

.faq-list dd {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-muted);
    margin: 0 0 0 0;
    padding-left: 0;
}

.faq-list dd::before {
    content: "A: ";
    color: var(--text-muted);
}

/* Footer */
.about-footer {
    padding: 32px 24px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 48px;
}

.about-footer p {
    margin: 4px 0;
}

/* About Page Responsive */
@media (max-width: 600px) {
    .about-header {
        padding: 0 16px;
        height: 52px;
    }

    .about-nav__title {
        display: none;
    }

    .about-content {
        padding: 72px 16px 48px;
    }

    .about-article h1 {
        font-size: 22px;
        letter-spacing: 1px;
    }

    .about-article__subtitle {
        font-size: 12px;
    }

    .about-intro {
        font-size: 14px;
    }

    .about-toc {
        padding: 16px 20px;
    }

    .about-section h2 {
        font-size: 11px;
    }

    .about-section p {
        font-size: 13px;
    }

    .about-faq {
        padding: 20px 16px;
    }

    .lang-switcher__item {
        padding: 6px 10px;
        font-size: 10px;
    }
}

/* Dropdown menu item as anchor (for About Leschnitz link) */
a.lab-menubar__dropdown-item {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============================================
   TOPONYMY PAGE STYLES
   ============================================ */

/* Etymology highlight box */
.etymology-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    padding: 20px 24px;
    margin: 24px 0;
}

.etymology-table {
    width: 100%;
    border-collapse: collapse;
}

.etymology-table th {
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    padding: 8px 16px 8px 0;
    width: 180px;
    font-size: 13px;
}

.etymology-table td {
    padding: 8px 0;
    font-size: 14px;
    color: var(--text);
}

/* Suffix reference table */
.suffix-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 13px;
}

.suffix-table thead th {
    background: var(--surface);
    padding: 12px 16px;
    text-align: left;
    font-weight: 500;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.suffix-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.suffix-table tbody tr:last-child td {
    border-bottom: none;
}

/* Historical image gallery */
.toponymy-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-top: 32px;
}

.toponymy-gallery__item {
    margin: 0;
}

.toponymy-gallery__item a {
    display: block;
    border: 1px solid var(--border);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.toponymy-gallery__item a:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(196, 30, 58, 0.15);
}

.toponymy-gallery__item img {
    width: 100%;
    height: auto;
    display: block;
    background: var(--surface);
}

.toponymy-gallery__caption {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 12px;
    line-height: 1.5;
    padding: 0 4px;
}

/* Blockquote styling for preface quotes */
.about-section blockquote {
    background: var(--surface);
    border-left: 3px solid var(--accent);
    padding: 20px 24px;
    margin: 24px 0;
    font-style: italic;
}

.about-section blockquote p {
    margin-bottom: 12px;
}

.about-section blockquote p:last-of-type {
    margin-bottom: 0;
}

.about-section blockquote cite {
    display: block;
    margin-top: 16px;
    font-style: normal;
    font-size: 12px;
    color: var(--text-muted);
}

/* Toponymy page responsive */
@media (max-width: 600px) {
    .toponymy-gallery {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .etymology-table th {
        width: 120px;
        font-size: 12px;
    }

    .etymology-table td {
        font-size: 13px;
    }

    .suffix-table {
        font-size: 12px;
    }

    .suffix-table thead th,
    .suffix-table tbody td {
        padding: 10px 12px;
    }
}

/* ============================================
   LABORATORY CHATBOT INTERFACE
   ============================================ */

.lab-chat {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 420px;
    background: rgba(10, 10, 12, 0.95);
    border: 1px solid var(--border);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8), 0 0 40px rgba(196, 30, 58, 0.1);
    z-index: 2000;
    font-family: 'Courier New', monospace;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.lab-chat.collapsed {
    bottom: 0;
    transform: translateX(-50%) translateY(calc(100% - 32px));
    opacity: 0.7;
}

.lab-chat.collapsed:hover {
    opacity: 1;
}

.lab-chat-header {
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.lab-chat-header:hover {
    background: var(--surface-hover);
}

.lab-chat-status {
    color: var(--accent);
    font-size: 8px;
    animation: chat-pulse 2s infinite;
}

.lab-chat-title {
    flex: 1;
    color: var(--text-muted);
}

.lab-chat-toggle {
    color: var(--text-muted);
    font-size: 10px;
}

.lab-chat.collapsed .lab-chat-toggle::after { content: '▲'; }
.lab-chat:not(.collapsed) .lab-chat-toggle::after { content: '▼'; }

.lab-chat-body {
    padding: 0;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.lab-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    min-height: 120px;
    max-height: 220px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-muted);
}

.lab-chat-log::-webkit-scrollbar {
    width: 4px;
}

.lab-chat-log::-webkit-scrollbar-track {
    background: transparent;
}

.lab-chat-log::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.chat-msg {
    margin-bottom: 10px;
    word-wrap: break-word;
}

.chat-msg.user {
    color: var(--text);
}

.chat-msg.user::before {
    content: '> ';
    color: var(--accent);
}

.chat-msg.bot {
    color: #9a9aa0;
    border-left: 2px solid var(--border);
    padding-left: 10px;
    margin-left: 2px;
}

.chat-msg.bot.thinking {
    color: var(--text-muted);
    font-style: italic;
}

.lab-chat-input-wrapper {
    border-top: 1px solid var(--border);
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.lab-chat-input-wrapper::before {
    content: '>';
    color: var(--accent);
    font-weight: bold;
}

#lab-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: 'Courier New', monospace;
    font-size: 12px;
    outline: none;
    padding: 0;
}

#lab-chat-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

@keyframes chat-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .lab-chat {
        width: 95%;
        max-width: none;
        bottom: 10px;
    }
    
    .lab-chat.collapsed {
        transform: translateX(-50%) translateY(calc(100% - 28px));
    }
    
    .lab-chat-log {
        min-height: 100px;
        max-height: 180px;
    }
}


/* ============================================
   CHAT-TO-MAP MARKER HIGHLIGHTING
   ============================================ */

/* Interactive Chat Links - using span to avoid button styling issues */
.chat-link {
    cursor: pointer;
    text-decoration: underline;
    font: inherit;
    /* Default fallback, overridden by inline style */
    color: var(--accent);
}

.chat-link:hover {
    filter: brightness(1.3);
}

/* Marker Highlight Animation */
@keyframes marker-pulse-ring {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        box-shadow: 0 0 0 0 var(--marker-color, var(--accent));
    }
    70% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0.5;
        box-shadow: 0 0 15px 8px var(--marker-color, var(--accent));
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
        box-shadow: 0 0 20px 12px transparent;
    }
}

.marker.highlight-active {
    z-index: 200 !important;
}

/* Highlighted marker: colored circle with glow */
.marker.highlight-active::before {
    width: 14px;
    height: 14px;
    background: var(--marker-color, var(--accent));
    box-shadow: 0 0 15px var(--marker-color, var(--accent)),
                0 0 30px var(--marker-color, var(--accent));
    animation: marker-pulse-ring 1.5s cubic-bezier(0.2, 0.6, 0.35, 1) infinite;
}

/* Show label when marker is highlighted (same as hover) */
.marker.highlight-active .marker-label {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    color: var(--marker-color, var(--text));
}

/* Reduced motion override for marker highlight */
@media (prefers-reduced-motion: reduce) {
    .marker.highlight-active::before {
        animation: none;
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0.5;
        box-shadow: 0 0 15px 8px var(--marker-color, var(--accent));
    }
}

/* ============================================
   LABORATORY CHATBOT INTERFACE
   ============================================ */

.lab-chat {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 420px;
    background: rgba(10, 10, 12, 0.95);
    border: 1px solid var(--border);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8), 0 0 40px rgba(196, 30, 58, 0.1);
    z-index: 2000;
    font-family: 'Courier New', monospace;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.lab-chat.collapsed {
    bottom: 0;
    transform: translateX(-50%) translateY(calc(100% - 32px));
    opacity: 0.7;
}

.lab-chat.collapsed:hover {
    opacity: 1;
}

.lab-chat-header {
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.lab-chat-header:hover {
    background: var(--surface-hover);
}

.lab-chat-status {
    color: var(--accent);
    font-size: 8px;
    animation: chat-pulse 2s infinite;
}

.lab-chat-title {
    flex: 1;
    color: var(--text-muted);
}

.lab-chat-toggle {
    color: var(--text-muted);
    font-size: 10px;
}

.lab-chat.collapsed .lab-chat-toggle::after { content: '▲'; }
.lab-chat:not(.collapsed) .lab-chat-toggle::after { content: '▼'; }

.lab-chat-body {
    padding: 0;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.lab-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    min-height: 120px;
    max-height: 220px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-muted);
}

.lab-chat-log::-webkit-scrollbar {
    width: 4px;
}

.lab-chat-log::-webkit-scrollbar-track {
    background: transparent;
}

.lab-chat-log::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.chat-msg {
    margin-bottom: 10px;
    word-wrap: break-word;
}

.chat-msg.user {
    color: var(--text);
}

.chat-msg.user::before {
    content: '> ';
    color: var(--accent);
}

.chat-msg.bot {
    color: #9a9aa0;
    border-left: 2px solid var(--border);
    padding-left: 10px;
    margin-left: 2px;
}

.chat-msg.bot.thinking {
    color: var(--text-muted);
    font-style: italic;
}

.lab-chat-input-wrapper {
    border-top: 1px solid var(--border);
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.lab-chat-input-wrapper::before {
    content: '>';
    color: var(--accent);
    font-weight: bold;
}

#lab-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: 'Courier New', monospace;
    font-size: 12px;
    outline: none;
    padding: 0;
}

#lab-chat-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

@keyframes chat-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .lab-chat {
        width: 95%;
        max-width: none;
        bottom: 10px;
    }
    
    .lab-chat.collapsed {
        transform: translateX(-50%) translateY(calc(100% - 28px));
    }
    
    .lab-chat-log {
        min-height: 100px;
        max-height: 180px;
    }
}

/* ============================================
   MARKER DETAIL PAGE STYLES
   ============================================ */

.marker-page {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
}

.marker-page__header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: linear-gradient(180deg, #2d2d32 0%, #1d1d22 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 24px;
}

.marker-page__nav {
    width: 100%;
}

.marker-page__back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    transition: opacity 0.15s ease;
}

.marker-page__back:hover {
    opacity: 0.8;
}

.marker-page__back-arrow {
    font-size: 16px;
}

.marker-page__content {
    max-width: 800px;
    margin: 0 auto;
    padding: 80px 24px 64px;
}

.marker-page__header-content {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.marker-page__content h1 {
    font-size: 28px;
    font-weight: 500;
    letter-spacing: -0.3px;
    line-height: 1.3;
    margin: 0 0 8px;
    color: var(--text);
}

.marker-page__subtitle {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 0;
}

.marker-page__media {
    margin: 0 0 32px;
}

.marker-page__media img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.marker-page__media figcaption {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
}

.marker-page__description {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text);
    margin-bottom: 32px;
}

.marker-page__meta {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 20px 24px;
    margin-bottom: 32px;
    border-radius: 6px;
}

.marker-page__meta dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    margin: 0;
}

.marker-page__meta dt {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.marker-page__meta dd {
    font-size: 13px;
    color: var(--text);
    margin: 0;
}

.marker-page__meta a {
    color: var(--accent);
    text-decoration: none;
}

.marker-page__meta a:hover {
    text-decoration: underline;
}

.marker-page__source {
    margin-bottom: 48px;
}

.marker-page__source a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
    padding: 10px 20px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
}

.marker-page__source a:hover {
    background: var(--accent);
    color: var(--text);
}

.marker-page__atlas-cta {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 32px;
    text-align: center;
    border-radius: 8px;
}

.marker-page__atlas-cta p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 16px;
}

.marker-page__cta-button {
    display: inline-block;
    background: var(--accent);
    color: var(--text);
    text-decoration: none;
    padding: 12px 28px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.marker-page__cta-button:hover {
    background: var(--accent-light);
}

.marker-page__footer {
    text-align: center;
    padding: 32px 24px;
    border-top: 1px solid var(--border);
    margin-top: 64px;
    font-size: 12px;
    color: var(--text-muted);
}

.marker-page__footer p {
    margin: 4px 0;
}

.marker-page__footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.marker-page__footer a:hover {
    color: var(--text);
    text-decoration: underline;
}

/* Marker page responsive */
@media (max-width: 600px) {
    .marker-page__header {
        padding: 0 16px;
    }

    .marker-page__content {
        padding: 72px 16px 48px;
    }

    .marker-page__content h1 {
        font-size: 22px;
    }

    .marker-page__description {
        font-size: 14px;
    }

    .marker-page__meta {
        padding: 16px;
    }

    .marker-page__meta dl {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .marker-page__atlas-cta {
        padding: 24px 16px;
    }
}

/* ============================================
   WORDCLOUD OVERLAY
   ============================================ */

.wordcloud-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 5; /* Above map image, below markers (z-index: 10) */
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.wordcloud-layer.visible {
    opacity: 1;
}

.wordcloud-item {
    position: absolute;
    font-family: 'Courier New', monospace;
    color: var(--text-muted);
    white-space: nowrap;
    transform: translate(-50%, -50%);
    user-select: none;
    mix-blend-mode: screen;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Clickable wordcloud links */
.wordcloud-layer a {
    color: var(--text-muted);
    text-decoration: none;
    pointer-events: auto;
    cursor: pointer;
    transition: opacity 0.2s ease, color 0.2s ease, text-shadow 0.2s ease;
}

.wordcloud-layer a:hover {
    opacity: 1 !important;
    color: var(--accent);
    text-shadow: 0 0 8px var(--accent-glow);
}
