/* ==========================================================================
   Trail PWA - Styles
   Mobile-first responsive design for offline bikepacking navigation
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables / Theme
   -------------------------------------------------------------------------- */
:root {
    /* Colors */
    --primary: #1a5f2a;
    --primary-light: #2d8a3e;
    --primary-dark: #0f3d1a;
    --secondary: #3498db;
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #27ae60;

    /* POI Colors */
    --poi-water: #3498db;
    --poi-camp: #27ae60;
    --poi-store: #9b59b6;
    --poi-resupply: #e67e22;
    --poi-other: #7f8c8d;

    /* Neutrals */
    --bg-dark: #1a1a2e;
    --bg-panel: #16213e;
    --bg-card: #0f3460;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #718096;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Layout */
    --nav-height: 60px;
    --hud-top-height: 56px;
    --panel-max-height: 60vh;
    --border-radius: 12px;
    --border-radius-sm: 8px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Safe areas for notched devices */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

/* Prevent pull-to-refresh and overscroll */
body {
    overscroll-behavior: none;
}

/* --------------------------------------------------------------------------
   Map Container
   -------------------------------------------------------------------------- */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-color: #2d3436;
}

/* Leaflet customizations */
.leaflet-container {
    background-color: #2d3436;
    font-family: inherit;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
    z-index: 1002 !important;
}

/* Ensure Leaflet control containers are above UI overlays */
.leaflet-top,
.leaflet-bottom {
    z-index: 1002 !important;
}

.leaflet-control-zoom a {
    background-color: var(--bg-panel) !important;
    color: var(--text-primary) !important;
    border: none !important;
}

.leaflet-control-zoom a:hover {
    background-color: var(--bg-card) !important;
}

.leaflet-control-attribution {
    background-color: rgba(22, 33, 62, 0.8) !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
}

.leaflet-control-attribution a {
    color: var(--text-secondary) !important;
}

/* Custom location marker */
.location-marker {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary);
    border: 3px solid #fff;
    box-shadow: var(--shadow-md);
}

.location-marker.stale {
    background: var(--text-muted);
}

/* Accuracy circle */
.accuracy-circle {
    fill: rgba(52, 152, 219, 0.15);
    stroke: rgba(52, 152, 219, 0.5);
    stroke-width: 2;
}

/* POI Markers */
.poi-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 16px;
    box-shadow: var(--shadow-sm);
    border: 2px solid #fff;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.poi-marker:hover {
    transform: scale(1.1);
}

.poi-marker.selected {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.5), var(--shadow-md);
}

.poi-marker.water { background-color: var(--poi-water); }
.poi-marker.camp { background-color: var(--poi-camp); }
.poi-marker.store { background-color: var(--poi-store); }
.poi-marker.resupply { background-color: var(--poi-resupply); }
.poi-marker.other { background-color: var(--poi-other); }

/* User waypoint markers */
.waypoint-marker {
    width: 28px;
    height: 28px;
    border-radius: 50% 50% 50% 0;
    background: var(--warning);
    border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
    transform: rotate(-45deg);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.waypoint-marker:hover {
    transform: rotate(-45deg) scale(1.1);
}

.waypoint-marker.selected {
    background: var(--danger);
    transform: rotate(-45deg) scale(1.2);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.5), var(--shadow-md);
}

/* --------------------------------------------------------------------------
   HUD Overlay
   -------------------------------------------------------------------------- */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    pointer-events: none;
    padding: var(--safe-top) var(--safe-right) 0 var(--safe-left);
}

#hud > * {
    pointer-events: auto;
}

/* Top HUD Bar */
.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: linear-gradient(to bottom, rgba(26, 26, 46, 0.95), rgba(26, 26, 46, 0));
    padding-top: calc(var(--space-sm) + var(--safe-top));
}

.status-indicators {
    display: flex;
    gap: var(--space-sm);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: rgba(15, 52, 96, 0.9);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-badge.online .status-dot { background: var(--success); }
.status-badge.offline .status-dot { background: var(--danger); }
.status-badge.gps-on .status-dot { background: var(--success); }
.status-badge.gps-off .status-dot { background: var(--text-muted); }
.status-badge.gps-searching .status-dot {
    background: var(--warning);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.hud-buttons {
    display: flex;
    gap: var(--space-sm);
}

.hud-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(15, 52, 96, 0.9);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.hud-btn:hover {
    background: var(--bg-card);
}

.hud-btn:active {
    transform: scale(0.95);
}

.hud-btn.active {
    background: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 95, 42, 0.5);
}

.hud-btn#btn-follow.active {
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.5);
    animation: follow-pulse 2s infinite;
}

@keyframes follow-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.5); }
    50% { box-shadow: 0 0 0 5px rgba(39, 174, 96, 0.3); }
}

.hud-btn svg {
    width: 24px;
    height: 24px;
}

/* HUD Panels */
.hud-panel {
    margin: var(--space-sm) var(--space-md);
    padding: var(--space-md);
    background: rgba(15, 52, 96, 0.95);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

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

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.panel-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Route Progress */
#route-progress #active-route-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-stats {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.stat {
    flex: 1;
    text-align: center;
}

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

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: var(--space-xs);
}

.progress-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-light), var(--success));
    border-radius: 3px;
    transition: width var(--transition-normal);
}

/* Selected Waypoint Info */
.waypoint-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.wp-type-badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    background: var(--poi-other);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    align-self: flex-start;
}

.wp-type-badge.water { background: var(--poi-water); }
.wp-type-badge.camp { background: var(--poi-camp); }
.wp-type-badge.store { background: var(--poi-store); }
.wp-type-badge.resupply { background: var(--poi-resupply); }
.wp-type-badge.user { background: var(--warning); }

.wp-notes {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.wp-distance {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--space-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.distance-label {
    font-size: 12px;
    color: var(--text-muted);
}

.distance-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--secondary);
}

/* Ride Tracking Panel */
.ride-panel {
    background: rgba(15, 52, 96, 0.95);
}

.ride-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.ride-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.ride-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.ride-status {
    padding: var(--space-xs) var(--space-sm);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.ride-status.ready {
    background: var(--bg-card);
    color: var(--text-muted);
}

.ride-status.recording {
    background: var(--success);
    color: white;
    animation: pulse-status 2s infinite;
}

.ride-status.paused {
    background: var(--warning);
    color: white;
}

@keyframes pulse-status {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.ride-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.ride-stat {
    text-align: center;
    padding: var(--space-sm);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-sm);
}

.ride-stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ride-stat-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: var(--space-xs);
}

.ride-controls {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.ride-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ride-btn.start {
    background: var(--success);
    color: white;
}

.ride-btn.start:hover {
    background: #219a52;
}

.ride-btn.pause {
    background: var(--warning);
    color: white;
}

.ride-btn.pause:hover {
    background: #d68910;
}

.ride-btn.resume {
    background: var(--success);
    color: white;
}

.ride-btn.resume:hover {
    background: #219a52;
}

.ride-btn.stop {
    background: var(--danger);
    color: white;
}

.ride-btn.stop:hover {
    background: #c0392b;
}

.ride-reset-controls {
    display: flex;
    gap: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ride-reset-btn {
    flex: 1;
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ride-reset-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Bottom Navigation
   -------------------------------------------------------------------------- */
#bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    padding: var(--space-sm) var(--space-md);
    padding-bottom: calc(var(--space-sm) + var(--safe-bottom));
    background: var(--bg-panel);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1001;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.nav-btn svg {
    width: 24px;
    height: 24px;
}

.nav-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    color: var(--primary-light);
}

/* --------------------------------------------------------------------------
   Sliding Panels
   -------------------------------------------------------------------------- */
.slide-panel {
    position: absolute;
    bottom: var(--nav-height);
    left: 0;
    right: 0;
    max-height: var(--panel-max-height);
    background: var(--bg-panel);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform var(--transition-normal);
    display: flex;
    flex-direction: column;
    padding-bottom: var(--safe-bottom);
}

.slide-panel.open {
    transform: translateY(0);
}

.slide-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.slide-panel .panel-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: normal;
}

.panel-collapse {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.panel-collapse:hover {
    background: rgba(255, 255, 255, 0.1);
}

.slide-panel.open .panel-collapse svg {
    transform: rotate(180deg);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    -webkit-overflow-scrolling: touch;
}

.panel-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
    text-align: center;
}

/* --------------------------------------------------------------------------
   List Containers
   -------------------------------------------------------------------------- */
.list-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.empty-state {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: var(--space-md);
}

/* Route Items */
.route-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.route-item:hover {
    background: rgba(15, 52, 96, 0.8);
}

.route-item.active {
    border-left: 3px solid var(--primary-light);
}

.route-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.route-info {
    flex: 1;
    min-width: 0;
}

.route-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.route-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.route-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.route-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.route-toggle .toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.route-toggle .toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.route-toggle input:checked + .toggle-slider {
    background: var(--primary-light);
}

.route-toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.route-actions {
    display: flex;
    gap: var(--space-xs);
}

.route-action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.route-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.route-action-btn.delete:hover {
    color: var(--danger);
}

/* POI Items */
.poi-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.poi-item:hover {
    background: rgba(15, 52, 96, 0.8);
}

.poi-item.selected {
    border-left: 3px solid var(--secondary);
}

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

.poi-icon.water { background: var(--poi-water); }
.poi-icon.camp { background: var(--poi-camp); }
.poi-icon.store { background: var(--poi-store); }
.poi-icon.resupply { background: var(--poi-resupply); }
.poi-icon.other { background: var(--poi-other); }

.poi-info {
    flex: 1;
    min-width: 0;
}

.poi-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.poi-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.poi-distance {
    font-size: 14px;
    font-weight: 600;
    color: var(--secondary);
    flex-shrink: 0;
}

/* Waypoint Items */
.waypoint-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.waypoint-item:hover {
    background: rgba(15, 52, 96, 0.8);
}

.waypoint-item.selected {
    border-left: 3px solid var(--warning);
}

.waypoint-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--warning);
    border-radius: 50%;
    font-size: 18px;
    flex-shrink: 0;
}

.waypoint-info {
    flex: 1;
    min-width: 0;
}

.waypoint-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.waypoint-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: var(--space-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.waypoint-distance {
    font-size: 14px;
    font-weight: 600;
    color: var(--warning);
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Filter Section
   -------------------------------------------------------------------------- */
.filter-section {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-sm);
}

.filter-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.filter-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-toggle:hover {
    background: rgba(15, 52, 96, 0.8);
}

.filter-toggle input {
    display: none;
}

.filter-toggle input:not(:checked) + .filter-icon {
    opacity: 0.4;
}

.filter-toggle input:not(:checked) ~ span:last-child {
    color: var(--text-muted);
}

.filter-icon {
    font-size: 14px;
}

/* --------------------------------------------------------------------------
   Settings Panel
   -------------------------------------------------------------------------- */
.settings-section {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.settings-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-md);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
}

.setting-item span:first-child {
    font-size: 14px;
    color: var(--text-primary);
}

.setting-item select {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.setting-item select:focus {
    outline: none;
    border-color: var(--primary-light);
}

/* Toggle Switch */
.setting-item.toggle {
    cursor: pointer;
}

.setting-item.toggle .toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    transition: background var(--transition-fast);
}

.setting-item.toggle .toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.setting-item.toggle input {
    display: none;
}

.setting-item.toggle input:checked + .toggle-slider,
.setting-item.toggle input:checked ~ .toggle-slider {
    background: var(--primary-light);
}

.setting-item.toggle input:checked + .toggle-slider::before,
.setting-item.toggle input:checked ~ .toggle-slider::before {
    transform: translateX(20px);
}

.about-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn-primary,
.btn-secondary,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    margin-bottom: var(--space-sm);
}

.btn-primary {
    background: var(--primary);
    color: var(--text-primary);
}

.btn-primary:hover {
    background: var(--primary-light);
}

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

.btn-secondary:hover {
    background: rgba(15, 52, 96, 0.8);
}

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

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

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    opacity: 1;
    transition: opacity var(--transition-normal);
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 100%;
    max-width: 400px;
    background: var(--bg-panel);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    transform: translateY(0);
    transition: transform var(--transition-normal);
}

.modal.hidden .modal-content {
    transform: translateY(20px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
}

.form-group {
    margin-bottom: var(--space-md);
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-xs);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

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

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

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

.modal-footer {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-footer .btn-primary,
.modal-footer .btn-secondary,
.modal-footer .btn-danger {
    flex: 1;
    margin-bottom: 0;
}

.modal-footer .btn-danger.hidden {
    display: none;
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   Media Queries
   -------------------------------------------------------------------------- */

/* Tablets and larger */
@media (min-width: 768px) {
    .slide-panel {
        max-width: 400px;
        left: auto;
        right: var(--space-md);
        bottom: calc(var(--nav-height) + var(--space-md));
        border-radius: var(--border-radius);
        max-height: 70vh;
    }

    #bottom-nav {
        max-width: 400px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--border-radius) var(--border-radius) 0 0;
    }

    .hud-panel {
        max-width: 350px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) {
    .slide-panel {
        max-height: 50vh;
    }

    #bottom-nav {
        padding: var(--space-xs) var(--space-md);
    }

    .nav-btn {
        padding: var(--space-xs) var(--space-sm);
    }

    .nav-btn span {
        display: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --bg-dark: #000000;
        --bg-panel: #111111;
        --bg-card: #222222;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --------------------------------------------------------------------------
   Install Banner
   -------------------------------------------------------------------------- */
.install-banner {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--space-md));
    left: var(--space-md);
    right: var(--space-md);
    background: var(--bg-panel);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: var(--space-md);
    z-index: 1500;
    animation: slideUp 0.3s ease;
}

.install-banner.hidden {
    display: none;
}

.install-content {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.install-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-sm);
    flex-shrink: 0;
}

.install-text {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.install-text strong {
    font-size: 16px;
    color: var(--text-primary);
}

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

.install-actions {
    display: flex;
    gap: var(--space-sm);
}

.install-btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.install-btn.dismiss {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.install-btn.dismiss:hover {
    color: var(--text-secondary);
    border-color: var(--text-secondary);
}

.install-btn.install {
    background: var(--primary);
    color: var(--text-primary);
}

.install-btn.install:hover {
    background: var(--primary-light);
}

@media (min-width: 768px) {
    .install-banner {
        max-width: 400px;
        left: auto;
        right: var(--space-md);
    }
}

/* --------------------------------------------------------------------------
   Elevation Monitor Bar
   -------------------------------------------------------------------------- */
.elevation-monitor {
    position: fixed;
    bottom: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg-panel);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: var(--space-sm) var(--space-md);
    padding-bottom: calc(var(--space-sm) + var(--safe-bottom));
    z-index: 1000;
    transition: transform var(--transition-normal);
}

.elevation-monitor.hidden {
    transform: translateY(100%);
    display: block !important;
    pointer-events: none;
}

.elevation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xs);
}

.elevation-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.current-elevation {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.elevation-profile-container {
    position: relative;
    height: 60px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

#elevation-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.elevation-position-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--secondary);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transform: translate(-50%, -50%);
    transition: left 0.3s ease, top 0.3s ease;
    z-index: 10;
    display: none;
}

.elevation-position-dot.visible {
    display: block;
}

.elevation-stats {
    display: flex;
    justify-content: space-between;
    gap: var(--space-sm);
}

.elevation-stat {
    flex: 1;
    text-align: center;
    padding: var(--space-xs);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-sm);
}

.elevation-stat .stat-label {
    display: block;
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.elevation-stat .stat-value {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 2px;
}

/* Adjust slide panels to account for elevation monitor */
.slide-panel {
    bottom: calc(var(--nav-height) + 130px);
}

/* When elevation monitor is hidden, reset panel position */
body:has(.elevation-monitor.hidden) .slide-panel {
    bottom: var(--nav-height);
}

@media (min-width: 768px) {
    .elevation-monitor {
        max-width: 400px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--border-radius) var(--border-radius) 0 0;
    }

    .elevation-monitor.hidden {
        transform: translateX(-50%) translateY(100%);
    }
}
