/* DataAcuity Maps - Unified Design System */

/* ========================================
   CSS Variables - Matching DataAcuity Theme
   ======================================== */
:root {
    /* Primary Colors */
    --primary: #007AFF;
    --primary-hover: #0056CC;
    --primary-light: rgba(0, 122, 255, 0.12);
    --primary-gradient: linear-gradient(180deg, #007AFF 0%, #0056CC 100%);

    /* System Colors */
    --success: #34C759;
    --success-light: rgba(52, 199, 89, 0.12);
    --warning: #FF9500;
    --warning-light: rgba(255, 149, 0, 0.12);
    --danger: #FF3B30;
    --danger-light: rgba(255, 59, 48, 0.12);
    --secondary: #8E8E93;

    /* Light Theme (default) */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F2F2F7;
    --bg-tertiary: #E5E5EA;
    --bg-card: #FFFFFF;
    --bg-hover: rgba(0, 0, 0, 0.04);
    --bg-glass: rgba(255, 255, 255, 0.72);

    --text-primary: #000000;
    --text-secondary: #3C3C43;
    --text-tertiary: #8E8E93;
    --text-muted: #AEAEB2;

    --border: rgba(0, 0, 0, 0.08);
    --separator: rgba(60, 60, 67, 0.12);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04), 0 0 1px rgba(0, 0, 0, 0.08);

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', system-ui, sans-serif;
    --font-mono: 'SF Mono', Monaco, monospace;

    /* Border Radius */
    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);

    /* Layout */
    --header-height: 56px;
}

/* Dark Theme */
[data-theme="dark"],
.dark-theme {
    --bg-primary: #000000;
    --bg-secondary: #1C1C1E;
    --bg-tertiary: #2C2C2E;
    --bg-card: #1C1C1E;
    --bg-hover: rgba(255, 255, 255, 0.08);
    --bg-glass: rgba(28, 28, 30, 0.72);

    --text-primary: #FFFFFF;
    --text-secondary: #EBEBF5;
    --text-tertiary: #8E8E93;
    --text-muted: #636366;

    --border: rgba(255, 255, 255, 0.08);
    --separator: rgba(84, 84, 88, 0.65);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 1px rgba(0, 0, 0, 0.3);
}

/* System preference dark mode */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #000000;
        --bg-secondary: #1C1C1E;
        --bg-tertiary: #2C2C2E;
        --bg-card: #1C1C1E;
        --bg-hover: rgba(255, 255, 255, 0.08);
        --bg-glass: rgba(28, 28, 30, 0.72);

        --text-primary: #FFFFFF;
        --text-secondary: #EBEBF5;
        --text-tertiary: #8E8E93;
        --text-muted: #636366;

        --border: rgba(255, 255, 255, 0.08);
        --separator: rgba(84, 84, 88, 0.65);

        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
        --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
        --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 1px rgba(0, 0, 0, 0.3);
    }
}

/* ========================================
   Base Styles
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Header
   ======================================== */
.maps-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
    transition: opacity var(--transition-fast);
}

.logo:hover {
    opacity: 0.8;
}

.logo-icon {
    font-size: 1.25rem;
}

.tagline {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    font-weight: 400;
}

.header-center {
    flex: 1;
    max-width: 480px;
    margin: 0 1.5rem;
}

.search-container {
    position: relative;
}

#search-input {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: var(--font-family);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

#search-input::placeholder {
    color: var(--text-muted);
}

#search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--separator);
    transition: background var(--transition-fast);
}

.search-result-item:hover,
.search-result-item.highlighted {
    background: var(--bg-hover);
}

.search-result-item.highlighted {
    background: var(--primary-light);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-name {
    font-weight: 500;
    color: var(--text-primary);
}

.search-result-location {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.search-result-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.125rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-family);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-icon {
    padding: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ========================================
   Map Container
   ======================================== */
#map-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
}

#map {
    width: 100%;
    height: 100%;
}

/* ========================================
   Timeline Slider
   ======================================== */
.timeline-container {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    min-width: 560px;
    z-index: 50;
    overflow: hidden;
}

.timeline-drag-handle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--separator);
    cursor: grab;
}

.timeline-drag-handle:active {
    cursor: grabbing;
}

.timeline-drag-handle h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.timeline-content {
    padding: 1rem 1.5rem;
}

.year-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 120px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.timeline-slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem 0;
}

.timeline-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    min-width: 60px;
    font-weight: 500;
}

#timeline-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    cursor: pointer;
}

#timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
    transition: transform var(--transition-spring);
}

#timeline-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

#timeline-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(0.95);
}

#timeline-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: grab;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
}

.timeline-presets {
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    margin-top: 0.75rem;
    padding: 0 1.5rem 1rem;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.preset-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.preset-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ========================================
   Place Panel
   ======================================== */
.place-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 340px;
    max-height: calc(100% - 2rem);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 50;
}

.place-panel.hidden {
    display: none;
}

.place-panel #place-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--separator);
    cursor: grab;
}

.place-panel #place-panel-header:active {
    cursor: grabbing;
}

.place-panel #place-panel-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
    line-height: 1;
}

.close-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

#panel-content {
    padding: 1.25rem;
    overflow-y: auto;
    max-height: calc(100vh - 150px);
}

.panel-header {
    margin-bottom: 1rem;
}

.panel-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.panel-subtitle {
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

.panel-section {
    margin-bottom: 1.25rem;
}

.panel-section h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.name-timeline {
    position: relative;
    padding-left: 1rem;
    border-left: 2px solid var(--bg-tertiary);
}

.name-entry {
    position: relative;
    padding: 0.625rem 0;
    padding-left: 1rem;
}

.name-entry::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0.875rem;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    margin-left: -3px;
}

.name-entry.current::before {
    background: var(--success);
}

.name-text {
    font-weight: 500;
    margin-bottom: 0.125rem;
    color: var(--text-primary);
}

.name-native {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.name-meta {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
}

.name-years {
    display: inline-block;
    background: var(--bg-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-xs);
    margin-right: 0.5rem;
    font-weight: 500;
}

/* ========================================
   Layers Panel
   ======================================== */
.layers-panel {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 240px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    z-index: 50;
}

.layers-panel.hidden {
    display: none;
}

.layers-panel h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--separator);
}

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

.layer-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.layer-item label {
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-secondary);
}

/* Collapsible Sections */
.collapsible-section {
    border-bottom: 1px solid var(--separator);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
}

.collapsible-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem 0;
    user-select: none;
}

.section-header:hover {
    opacity: 0.8;
}

.section-header h4 {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.section-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
}

.section-toggle.collapsed {
    transform: rotate(-90deg);
}

.section-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 500px;
    opacity: 1;
}

.section-content.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Draggable Panel */
.layers-panel.draggable {
    cursor: default;
}

.panel-drag-handle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--separator);
}

.panel-drag-handle:active {
    cursor: grabbing;
}

.panel-drag-handle h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.drag-icon {
    color: var(--text-tertiary);
    font-size: 0.7rem;
    letter-spacing: 2px;
}

.panel-close-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition-fast);
}

.panel-close-btn:hover {
    color: var(--text-primary);
}

/* ========================================
   Stats Badge
   ======================================== */
.stats-badge {
    position: absolute;
    bottom: 7rem;
    left: 1rem;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    color: var(--text-tertiary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

/* ========================================
   Modal
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.modal-content h2 {
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-content p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.modal-content ul, .modal-content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.modal-content li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.credits {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--separator);
}

/* ========================================
   Tabs
   ======================================== */
.contribute-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.tab-btn {
    flex: 1;
    padding: 0.625rem;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    background: var(--bg-tertiary);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ========================================
   Forms
   ======================================== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.875rem;
    font-family: var(--font-family);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
}

/* ========================================
   MapLibre Popup Override
   ======================================== */
.maplibregl-popup-content {
    padding: 1rem;
    border-radius: var(--radius-sm);
    min-width: 200px;
    background: var(--bg-card);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.popup-title {
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 0.375rem;
    color: var(--text-primary);
}

.popup-historical {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.popup-type {
    font-size: 0.7rem;
    background: var(--bg-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-xs);
    display: inline-block;
    margin-top: 0.5rem;
    color: var(--text-tertiary);
}

/* ========================================
   Orientation Controls
   ======================================== */
.orientation-section {
    border-top: 1px solid var(--separator);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

.orientation-options {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.orientation-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.orientation-option:hover {
    background: var(--bg-hover);
}

.orientation-option input[type="radio"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

.orientation-option input[type="radio"]:checked + span {
    font-weight: 500;
    color: var(--primary);
}

#orientation-indicator {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-xs);
    color: var(--text-tertiary);
}

/* ========================================
   Theme Toggle (optional)
   ======================================== */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle button {
    padding: 0.375rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.theme-toggle button:hover {
    background: var(--bg-tertiary);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .maps-header {
        padding: 0 0.75rem;
    }

    .timeline-container {
        min-width: auto;
        width: calc(100% - 2rem);
        padding: 0.75rem 1rem;
        bottom: 1rem;
    }

    .tagline {
        display: none;
    }

    .place-panel {
        width: calc(100% - 2rem);
        left: 1rem;
        right: 1rem;
    }

    .header-center {
        margin: 0 0.5rem;
    }

    .timeline-presets {
        gap: 0.25rem;
    }

    .preset-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.65rem;
    }

    .stats-badge {
        bottom: 6.5rem;
        font-size: 0.65rem;
    }
}

@media (max-width: 480px) {
    .header-right .btn-primary span:last-child {
        display: none;
    }

    .btn-primary {
        padding: 0.5rem;
    }
}

/* ========================================
   Map Style Options
   ======================================== */
.style-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--separator);
}

.style-options {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.style-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: background var(--transition-fast);
    font-size: 0.8rem;
}

.style-option:hover {
    background: var(--bg-hover);
}

.style-option input[type="radio"] {
    accent-color: var(--primary);
}

/* ========================================
   Routing Panel
   ======================================== */
.routing-panel {
    position: absolute;
    top: 1rem;
    left: 50px;
    width: 320px;
    max-height: calc(100% - 2rem);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    overflow: hidden;
}

.routing-panel.hidden {
    display: none;
}

.routing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--separator);
    cursor: grab;
}

.routing-header:active {
    cursor: grabbing;
}

.routing-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.routing-content {
    padding: 1rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

#waypoints-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.waypoint-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.waypoint-label {
    width: 24px;
    height: 24px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.waypoint-search {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.waypoint-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-remove-waypoint {
    width: 24px;
    height: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.btn-remove-waypoint:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}

.btn-remove-waypoint.hidden {
    display: none;
}

.waypoint-dropdown {
    position: absolute;
    top: 100%;
    left: 32px;
    right: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    box-shadow: var(--shadow-md);
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
}

.waypoint-option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition-fast);
}

.waypoint-option:hover {
    background: var(--bg-hover);
}

.waypoint-option-type {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-xs);
}

.routing-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.routing-actions .btn {
    flex: 1;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

/* Route Info */
.route-info {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--separator);
}

.route-info.hidden {
    display: none;
}

.route-summary {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--primary-light);
    border-radius: var(--radius-xs);
    text-align: center;
}

.route-steps {
    max-height: 200px;
    overflow-y: auto;
}

.route-step {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--separator);
    font-size: 0.8rem;
}

.route-step:last-child {
    border-bottom: none;
}

.step-number {
    width: 20px;
    height: 20px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}

.step-instruction {
    flex: 1;
    color: var(--text-secondary);
}

.step-distance {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* ========================================
   Legend Panel
   ======================================== */
.map-legend {
    position: absolute;
    bottom: 7rem;
    right: 1rem;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    z-index: 50;
    min-width: 160px;
    overflow: hidden;
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--separator);
    background: var(--bg-secondary);
    cursor: grab;
}

.legend-header:active {
    cursor: grabbing;
}

.legend-header h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-toggle {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legend-toggle:hover {
    color: var(--text-primary);
}

.legend-content {
    padding: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.25rem;
    font-size: 0.75rem;
}

.legend-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    border: 1px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    color: var(--text-secondary);
}

.legend-count {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-xs);
}

/* ========================================
   Category Filters
   ======================================== */
.filter-section {
    border-top: 1px solid var(--separator);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 200px;
    overflow-y: auto;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.375rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 0.8rem;
}

.filter-option:hover {
    background: var(--bg-hover);
}

.filter-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

.filter-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    border: 1px solid white;
    flex-shrink: 0;
}

.filter-label {
    color: var(--text-secondary);
    flex: 1;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--separator);
}

.filter-actions .btn {
    flex: 1;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
}

/* ========================================
   Hover Label Popup
   ======================================== */
.hover-label-popup .maplibregl-popup-content {
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-xs);
    background: var(--bg-primary);
    box-shadow: var(--shadow-md);
    min-width: auto;
}

.hover-label-popup .maplibregl-popup-tip {
    display: none;
}

.hover-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

/* ========================================
   Responsive Legend
   ======================================== */
@media (max-width: 768px) {
    .map-legend {
        bottom: 6.5rem;
        right: 0.5rem;
        min-width: 140px;
    }

    .legend-item {
        font-size: 0.7rem;
    }

    .legend-icon {
        width: 18px;
        height: 18px;
        font-size: 9px;
    }
}

/* ========================================
   Signal-style Toast Notifications
   ======================================== */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 1rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 400px;
    width: 90%;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toast-slide-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: top center;
}

.toast.toast-exit {
    animation: toast-slide-out 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-slide-out {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
}

.toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.toast-success .toast-icon {
    background: var(--success-light);
    color: var(--success);
}

.toast-error .toast-icon {
    background: var(--danger-light);
    color: var(--danger);
}

.toast-warning .toast-icon {
    background: var(--warning-light);
    color: var(--warning);
}

.toast-info .toast-icon {
    background: var(--primary-light);
    color: var(--primary);
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

.toast-message {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    line-height: 1;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    transform-origin: left;
    animation: toast-progress 4s linear forwards;
}

.toast-success .toast-progress {
    background: var(--success);
}

.toast-error .toast-progress {
    background: var(--danger);
}

.toast-warning .toast-progress {
    background: var(--warning);
}

@keyframes toast-progress {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* Responsive toast */
@media (max-width: 480px) {
    .toast-container {
        top: calc(var(--header-height) + 0.5rem);
        width: calc(100% - 1rem);
        max-width: none;
    }

    .toast {
        padding: 0.75rem;
    }

    .toast-icon {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}
