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

body {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    line-height: 1.6;
    color: #EEF2FF;
    background-color: #020C1B;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* AwareAI dot-grid texture */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background-image: radial-gradient(circle, #ffffff 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.03;
}

/* AwareAI ambient orbs */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 55% 55% at 95% 5%, rgba(196,38,31,0.09) 0%, transparent 70%),
        radial-gradient(ellipse 60% 60% at 5% 95%, rgba(22,35,66,0.65) 0%, transparent 70%);
}

/* Remove topo pattern — use container z-index only */
.container::before {
    content: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Global typography: all headings use Plus Jakarta Sans by default */
h2, h3, h4, h5, h6 {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
}

/* Panel/section headings — AwareAI overline style */
.rainfall-data h3,
.trail-conditions h3,
.recommendations h3,
.forecast-section h3,
.cycling-types h3,
.nearby-trails-section h3,
.condition-detail h3 {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: #C4261F;
    text-transform: uppercase;
    margin-bottom: 18px;
}

header {
    padding-bottom: 22px;
    margin-bottom: 28px;
    border-bottom: 1px solid rgba(22, 35, 66, 0.7);
    color: #ffffff;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left {
    text-align: left;
    flex-shrink: 0;
    margin-right: auto;
}

.header-nav-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

header h1 {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
    color: #EEF2FF;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
}

.logo-image {
    height: 56px;
    width: auto;
    flex-shrink: 0;
}

header p {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: #94AABF;
}

.title-with-beta {
    display: flex;
    align-items: center;
    gap: 9px;
}

.beta-badge {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.14em;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 4px;
    text-transform: uppercase;
}

.header-strava-btn {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
}

.header-strava-btn:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.header-strava-btn:active {
    transform: scale(0.98);
}

.strava-btn-image {
    height: 40px;
    width: auto;
    display: block;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.7));
}

.header-strava-btn.connected .strava-btn-image {
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.7)) hue-rotate(90deg) brightness(1.1);
}

.header-strava-btn.connected:hover .strava-btn-image {
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.7)) hue-rotate(90deg) brightness(1.2);
}

/* Settings Panel — fixed cog in top-right corner */
.settings-panel {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.settings-header {
    display: flex;
    align-items: center;
    padding: 0;
    background: none;
    border-bottom: none;
}

.settings-header h3 {
    display: none;
}

.toggle-btn {
    background: rgba(22, 35, 66, 0.5);
    border: 1px solid rgba(22, 35, 66, 0.8);
    font-size: 0.9rem;
    color: #3D5070;
    cursor: pointer;
    padding: 6px 9px;
    border-radius: 8px;
    line-height: 1;
    transition: color 0.2s, background 0.2s;
}

.toggle-btn:hover {
    background: rgba(22, 35, 66, 0.8);
    color: #94AABF;
}

.settings-content {
    padding: 20px 24px;
    display: none;
    background: rgba(10, 22, 40, 0.98);
    border: 1px solid rgba(22, 35, 66, 0.8);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    margin-top: 6px;
    min-width: 340px;
}

.api-key-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #ffffff;
    font-size: 14px;
}

.api-key-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

#api-key {
    flex: 1;
    padding: 14px 16px;
    background: rgba(22, 35, 66, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    font-size: 14px;
    color: #ffffff;
    transition: all 0.3s ease;
}

#api-key::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#api-key:focus {
    outline: none;
    border-color: #60A5FA;
    background: rgba(22, 35, 66, 0.7);
    box-shadow: 0 0 0 3px rgba(36, 56, 96, 0.7);
}

.save-btn {
    padding: 14px 24px;
    background: linear-gradient(135deg, #00c851 0%, #007e33 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 200, 81, 0.3);
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 200, 81, 0.4);
}

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

.status-message {
    font-size: 12px;
    margin-top: 8px;
    font-weight: 500;
}

.status-message.success {
    color: #00c851;
}

.status-message.error {
    color: #ff4444;
}

.api-key-section small {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.api-key-section small a {
    color: #60A5FA;
    text-decoration: none;
    transition: color 0.3s ease;
}

.api-key-section small a:hover {
    color: #60A5FA;
}

/* Location Selection */
.location-selection {
    background: rgba(10, 22, 40, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(22, 35, 66, 0.7);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
    overflow: visible;
}

.location-tabs {
    display: flex;
    gap: 2px;
    background: rgba(22, 35, 66, 0.5);
    padding: 3px;
    border-radius: 10px;
    border: 1px solid rgba(22, 35, 66, 0.8);
    overflow-x: auto;
    scrollbar-width: none;
}

.location-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    min-width: 52px;
    padding: 9px 10px;
    background: none;
    border: none;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
    border-radius: 7px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
}

.tab-btn svg { opacity: 0.5; transition: opacity 0.15s; }

.tab-btn:hover {
    background: rgba(22, 35, 66, 0.6);
    color: rgba(255, 255, 255, 0.65);
}

.tab-btn:hover svg { opacity: 0.75; }

.tab-btn.active {
    background: rgba(10, 22, 40, 0.95);
    color: #EEF2FF;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.tab-btn.active svg { opacity: 1; }

.tab-content {
    display: none;
    padding: 24px 28px 28px;
    overflow: visible;
    position: relative;
}

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

/* Trail Finder overline on search tab */
#search-tab::before {
    content: 'Trail Finder';
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #C4261F;
    margin-bottom: 16px;
}

/* Search Tab */
.search-container {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.search-input-wrapper {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    z-index: 100;
}

.location-nudge {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(22, 35, 66, 0.35);
    border: 1px solid rgba(22, 35, 66, 0.6);
    border-radius: 8px;
    font-size: 13px;
    color: rgba(148, 170, 191, 0.9);
    line-height: 1.4;
}

.location-nudge-icon {
    font-size: 15px;
    flex-shrink: 0;
    color: #60A5FA;
}

.location-nudge-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #60A5FA;
    font-size: 13px;
    font-family: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.location-nudge-btn:hover { color: #93C5FD; }

#unified-search {
    width: 100%;
    padding: 14px 18px;
    background: rgba(2, 12, 27, 0.8);
    border: 1px solid rgba(22, 35, 66, 0.7);
    border-radius: 10px;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 15px;
    color: #EEF2FF;
    transition: border-color 0.2s;
    margin-bottom: 0;
}

#unified-search::placeholder { color: #3D5070; }

#unified-search:focus {
    outline: none;
    border-color: #60A5FA;
    background: rgba(22, 35, 66, 0.7);
    box-shadow: 0 0 0 3px rgba(36, 56, 96, 0.7);
}

.trail-grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.trail-grade.grade-white  { color: rgba(255,255,255,0.5); }
.trail-grade.grade-green  { color: #4ADE80; }
.trail-grade.grade-blue   { color: #60A5FA; }
.trail-grade.grade-red    { color: #EF4444; }
.trail-grade.grade-black  {
    color: #1a1a1a;
    -webkit-text-stroke: 0.5px rgba(255, 255, 255, 0.85);
}
.trail-grade.grade-double-black {
    color: #1a1a1a;
    letter-spacing: -3px;
    -webkit-text-stroke: 0.5px rgba(255, 255, 255, 0.85);
}

.suggestions-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: rgba(7, 15, 28, 0.98);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(36, 56, 96, 0.9);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: none;
    max-height: 400px;
    overflow-y: auto;
}

.suggestion-group-label {
    padding: 6px 14px 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(61, 80, 112, 0.9);
    border-bottom: 1px solid rgba(22, 35, 66, 0.5);
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(22, 35, 66, 0.5);
    transition: background 0.15s;
}

.suggestion-item:hover { background: rgba(22, 35, 66, 0.6); }
.suggestion-item:last-child { border-bottom: none; }

.sugg-grade {
    font-size: 13px;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.sugg-loc-icon {
    flex-shrink: 0;
    color: #3D5070;
    width: 18px;
}

.suggestion-area {
    border-bottom: 1px solid rgba(96, 165, 250, 0.15);
    background: rgba(96, 165, 250, 0.04);
}

.suggestion-area:hover {
    background: rgba(96, 165, 250, 0.1);
}

.sugg-area-icon {
    flex-shrink: 0;
    color: #60A5FA;
    width: 18px;
}

.sugg-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #EEF2FF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sugg-meta {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #3D5070;
    white-space: nowrap;
    flex-shrink: 0;
}

.check-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 14px 24px;
    background: #C4261F;
    color: white;
    border: none;
    border-radius: 10px;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    box-shadow: 0 10px 24px -8px rgba(120, 15, 10, 0.50);
}

.check-btn:hover,  {
    background: #E53535;
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -8px rgba(120, 15, 10, 0.65);
}

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

/* Map Tab */
.map-container {
    text-align: center;
}

#map {
    height: 65vh;
    min-height: 450px;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    /* Terrain testing: try removing this filter to see tiles at full contrast */
    filter: brightness(0.9) contrast(1.15);
}

/* Dark theme for Leaflet map controls */
#map .leaflet-control-zoom {
    border: none !important;
    border-radius: 8px !important;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

#map .leaflet-control-zoom a {
    background: rgba(7, 15, 28, 0.97) !important;
    color: #EEF2FF !important;
    border: none !important;
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    font-size: 18px !important;
    font-weight: bold !important;
    border-radius: 0 !important;
    transition: all 0.2s ease !important;
}

#map .leaflet-control-zoom a:hover {
    background: rgba(60, 165, 250, 0.9) !important;
    color: white !important;
}

#map .leaflet-control-zoom a:first-child {
    border-radius: 8px 8px 0 0 !important;
}

#map .leaflet-control-zoom a:last-child {
    border-radius: 0 0 8px 8px !important;
}

/* Style attribution control */
#map .leaflet-control-attribution {
    background: rgba(30, 41, 59, 0.9) !important;
    color: rgba(255, 255, 255, 0.8) !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    border: 1px solid rgba(22, 35, 66, 0.7) !important;
}

#map .leaflet-control-attribution a {
    color: #60A5FA !important;
}

/* Basemap switcher control */
.map-basemap-switcher {
    background: rgba(7, 15, 28, 0.95);
    border: 1px solid rgba(22, 35, 66, 0.8);
    border-radius: 10px;
    padding: 8px 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    user-select: none;
    width: 92px;
}

.map-basemap-label {
    display: block;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(148, 170, 191, 0.7);
    margin-bottom: 6px;
}

.map-basemap-btns {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.map-basemap-btn {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: rgba(200, 216, 232, 0.75);
    background: rgba(22, 35, 66, 0.5);
    border: 1px solid rgba(22, 35, 66, 0.8);
    border-radius: 6px;
    padding: 5px 0;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
    line-height: 1.4;
    width: 100%;
    text-align: center;
}

.map-basemap-btn:hover {
    background: rgba(60, 90, 140, 0.6);
    color: #EEF2FF;
    border-color: rgba(96, 165, 250, 0.4);
}

.map-basemap-btn.active {
    background: rgba(10, 22, 40, 0.95) !important;
    color: #EEF2FF !important;
    border-color: rgba(22, 35, 66, 0.8) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) !important;
    font-weight: 700;
}

.map-instruction {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin: 0;
}

/* Trail Map Popup Styling */
/* ── Leaflet popup chrome ─────────────────────────────── */
#map .leaflet-popup-content-wrapper {
    background: rgba(16, 36, 68, 0.97) !important;
    border-radius: 12px !important;
    border: 1px solid rgba(60, 90, 140, 0.5) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.05) !important;
    padding: 0 !important;
    overflow: hidden !important;
    backdrop-filter: blur(20px) !important;
}

#map .leaflet-popup-content {
    margin: 0 !important;
    line-height: 1 !important;
}

#map .leaflet-popup-tip-container {
    margin-top: -1px !important;
}

#map .leaflet-popup-tip {
    background: rgba(16, 36, 68, 0.97) !important;
    box-shadow: none !important;
    border: none !important;
}

#map .leaflet-popup-close-button { display: none !important; }

/* ── Popup inner content ──────────────────────────────── */
.trail-popup {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    min-width: 210px;
    max-width: 260px;
}

/* Grade accent bar */
.trail-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 10px;
    border-bottom: 1px solid rgba(60, 90, 140, 0.4);
    position: relative;
}

/* Left accent stripe — colour set per grade via :has() */
.trail-popup-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 12px 0 0 0;
    background: #60A5FA;
}
.trail-popup-header:has(.grade-white)::before        { background: #C8D8E8; }
.trail-popup-header:has(.grade-green)::before        { background: #4ADE80; }
.trail-popup-header:has(.grade-blue)::before         { background: #60A5FA; }
.trail-popup-header:has(.grade-red)::before          { background: #EF4444; }
.trail-popup-header:has(.grade-black)::before        { background: #94AABF; }
.trail-popup-header:has(.grade-double-black)::before { background: #1A1A1A; }

.trail-popup-header .trail-grade {
    font-size: 15px;
    flex-shrink: 0;
    line-height: 1;
}

.trail-popup-header h4 {
    margin: 0;
    flex: 1;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #F0F6FF;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.trail-popup-body {
    padding: 8px 14px 0;
}

.trail-popup .tc-pills {
    margin-bottom: 6px;
}

.trail-popup .tc-stats {
    margin-bottom: 4px;
}

.trail-popup .tc-stat {
    font-size: 10px;
}

.popup-rating {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #FBBF24;
    letter-spacing: 0.04em;
    padding: 0 14px 6px;
}

.trail-popup-btn {
    display: block;
    width: 100%;
    background: rgba(196, 38, 31, 0.12);
    color: #F87171;
    border: none;
    border-top: 1px solid rgba(196, 38, 31, 0.25);
    padding: 10px 14px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.trail-popup-btn:hover {
    background: rgba(196, 38, 31, 0.22);
    color: #FCA5A5;
}

/* Legacy selectors no longer used but kept for safety */
.trail-popup-info { display: none; }
.trail-popup-details { display: none; }
.trail-popup-elevation { display: none; }
.elev-label { display: none; }

/* ── Trail markers ────────────────────────────────────── */
.trail-marker-icon {
    background: none !important;
    border: none !important;
    overflow: visible !important;
}

.trail-marker {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

.trail-marker-symbol {
    font-size: 34px;
    line-height: 1;
    color: var(--c, #1D6EF5);
    font-weight: 900;
    letter-spacing: -2px;
    -webkit-text-stroke: 2.5px rgba(255, 255, 255, 0.95);
    paint-order: stroke fill;
    filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.55))
            drop-shadow(0 0 2px rgba(0, 0, 0, 0.35));
    pointer-events: none;
}

.trail-marker-icon:hover .trail-marker {
    transform: scale(1.2);
}

/* Trail name label — shown only when map is zoomed in */
.trail-name-label {
    position: absolute;
    top: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #F0F6FF;
    background: rgba(2, 10, 24, 0.82);
    border: 1px solid rgba(60, 90, 140, 0.5);
    border-radius: 3px;
    padding: 1px 5px;
    pointer-events: none;
    display: none;
}
#map.show-trail-names .trail-name-label {
    display: block;
}

/* Saved Locations Tab */
/* ── Saved tab ─────────────────────────────────────────── */

.saved-locations { min-height: 200px; }

.locations-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.saved-locations-placeholder,
.comparison-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 180px;
    padding: 40px 20px;
    border: 1px dashed rgba(22, 35, 66, 0.9);
    border-radius: 12px;
}

.saved-locations-placeholder p,
.comparison-placeholder p {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: rgba(238, 242, 255, 0.5);
    margin: 0;
}

.saved-locations-placeholder small,
.comparison-placeholder small {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: rgba(148, 170, 191, 0.4);
    text-align: center;
    line-height: 1.5;
}

.saved-location-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    animation: fadeSlideIn 0.2s ease both;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.saved-location-card:hover {
    background: rgba(22, 35, 66, 0.5);
    border-color: rgba(22, 35, 66, 0.9);
}

.saved-card-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.saved-card-label {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #EEF2FF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-card-meta {
    font-size: 12px;
    color: rgba(148, 170, 191, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-card-coords {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(148, 170, 191, 0.4);
    letter-spacing: 0.02em;
}

.delete-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(148, 170, 191, 0.3);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.delete-btn:hover {
    color: #F87171;
    background: rgba(248, 113, 113, 0.1);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    background: rgba(10, 22, 40, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(22, 35, 66, 0.7);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.loading p {
    color: #ffffff;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(22, 35, 66, 0.7);
    border-top: 4px solid #60A5FA;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results — no outer card; individual sections are their own cards */
.results {
    scroll-margin-top: 80px;
    position: relative;
    z-index: 10;
}

.trail-detail-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 0 20px 0;
    margin-bottom: 4px;
}

.save-trail-btn {
    margin-left: auto;
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(148, 170, 191, 0.6);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s, transform 0.15s;
}
.save-trail-btn:hover { color: #EEF2FF; transform: scale(1.15); }
.save-trail-btn.is-saved { color: #FBBF24; }
.save-trail-btn.is-saved:hover { color: #FDE68A; }

.show-map-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #3D5070;
    transition: color 0.15s, transform 0.15s;
    flex-shrink: 0;
}
.show-map-btn:hover { color: #60A5FA; transform: scale(1.15); }

.trail-card-bookmark {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: rgba(61, 80, 112, 0.8);
    transition: color 0.15s, transform 0.15s;
    flex-shrink: 0;
    line-height: 1;
}
.trail-card-bookmark:hover { color: #EEF2FF; transform: scale(1.2); }
.trail-card-bookmark.is-saved { color: #FBBF24; }
.trail-card-bookmark.is-saved:hover { color: #FDE68A; }

.trail-name-row {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    flex-wrap: nowrap;
    width: 100%;
}
.trail-name-row .trail-name-cell { flex: 1; margin-bottom: 0; }
.trail-name-row .trail-card-bookmark { margin-top: 1px; flex-shrink: 0; margin-left: auto; }

.back-to-trails-btn {
    background: none;
    border: none;
    color: #C4261F;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 0;
    flex-shrink: 0;
    letter-spacing: 0.01em;
    transition: opacity 0.15s;
}

.back-to-trails-btn:hover {
    opacity: 0.75;
}

.trail-detail-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.trail-detail-title h2 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    color: #EEF2FF;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trail-unsanctioned-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(251, 146, 60, 0.15);
    border: 1px solid rgba(251, 146, 60, 0.4);
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #FB923C;
    white-space: nowrap;
    flex-shrink: 0;
}

.results-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}

.results-left {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.results-right {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.location-info {
    padding: 0 0 26px;
}

.location-info::before {
    content: 'Trail Assessment';
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #C4261F;
    margin-bottom: 10px;
}

.location-info-main {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}


.location-info h2 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: #EEF2FF;
}

.location-info p {
    font-size: 12px;
    font-weight: 500;
    color: #94AABF;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.trail-description {
    width: 100%;
}

.trail-description-text {
    color: #94AABF;
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

.save-location-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #00c851 0%, #007e33 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 200, 81, 0.3);
}

.save-location-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 200, 81, 0.4);
}

.rainfall-data {
    padding: 24px;
    background: rgba(10, 22, 40, 0.95);
    border: 1px solid rgba(22, 35, 66, 0.7);
    border-radius: 16px;
}

.rainfall-data h3 {
    margin-bottom: 20px;
}

.time-periods {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.period-card {
    text-align: center;
    padding: 18px 10px;
    background: rgba(2, 12, 27, 0.8);
    border-radius: 12px;
    border: 1px solid rgba(22, 35, 66, 0.7);
    transition: border-color 0.2s;
}

.period-card:hover {
    border-color: rgba(22, 35, 66, 1);
}

.period-card h4 {
    margin-bottom: 10px;
    color: #94AABF;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 700;
}

.rainfall-amount {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #60A5FA;
    line-height: 1;
    margin-bottom: 4px;
}

.rainfall-unit {
    color: #94AABF;
    font-size: 11px;
    font-weight: 500;
}

.trail-conditions {
    padding: 24px;
    background: rgba(10, 22, 40, 0.95);
    border: 1px solid rgba(22, 35, 66, 0.7);
    border-radius: 16px;
}

.trail-conditions h3 {
    margin-bottom: 20px;
}

.condition-card {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 22px 24px;
    border-radius: 12px;
    background: rgba(10, 22, 40, 0.95);
    border: 1px solid rgba(22, 35, 66, 0.75);
    position: relative;
    overflow: hidden;
}

.condition-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.condition-card.excellent { --cc: #4ADE80; }
.condition-card.good      { --cc: #FBBF24; }
.condition-card.caution   { --cc: #FB923C; }
.condition-card.poor      { --cc: #F87171; }

.condition-card.excellent::before { background: rgba(52,208,88,0.08);  opacity: 1; }
.condition-card.good::before      { background: rgba(201,168,64,0.1);  opacity: 1; }
.condition-card.caution::before   { background: rgba(249,115,22,0.09); opacity: 1; }
.condition-card.poor::before      { background: rgba(239,68,68,0.09);  opacity: 1; }

/* ====================================================================
   Conditions detail (Phase A — transparency panel)
   ==================================================================== */
.condition-detail {
    margin-top: 16px;
    padding: 20px 24px;
    background: rgba(10, 22, 40, 0.95);
    border: 1px solid rgba(22, 35, 66, 0.7);
    border-radius: 12px;
}
/* h3 inherits from the shared selector above (red, 10px, 0.2em tracking) */
.condition-detail .cd-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.condition-detail .cd-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.condition-detail .cd-row:last-child {
    border-bottom: none;
}
.condition-detail .cd-row.cd-sub {
    padding: 2px 0 6px;
    border-bottom: none;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.65);
}
.condition-detail .cd-row.cd-warn {
    color: #FBBF24;
    font-size: 0.9rem;
    border-bottom: none;
    padding-top: 8px;
}
.condition-detail .cd-label {
    color: rgba(255,255,255,0.6);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}
.condition-detail .cd-value {
    color: rgba(255,255,255,0.95);
    font-size: 0.95rem;
    text-align: right;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.condition-detail .cd-state {
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.cd-state.cd-dry  { background: rgba(74,222,128,0.18); color: #86EFAC; }
.cd-state.cd-good { background: rgba(251,191,36,0.18); color: #FCD34D; }
.cd-state.cd-damp { background: rgba(251,146,60,0.20); color: #FDBA74; }
.cd-state.cd-wet  { background: rgba(239,68,68,0.20);  color: #FCA5A5; }
.cd-state.cd-sat  { background: rgba(196,38,31,0.25);  color: #FCA5A5; }
.cd-state.cd-unknown { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.55); }
.condition-detail .cd-bar {
    display: inline-block;
    width: 90px;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
}
.condition-detail .cd-bar-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #4ADE80 0%, #FBBF24 50%, #F87171 100%);
}
.condition-detail .cd-num {
    font-variant-numeric: tabular-nums;
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    min-width: 36px;
    text-align: right;
}
.condition-detail .cd-source {
    margin-top: 12px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    text-align: right;
}
.condition-detail .cd-source a {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
}
.condition-detail .cd-source a:hover {
    color: rgba(255,255,255,0.9);
    text-decoration: underline;
}

/* Rules engine output severity badges */
#recommendations-list li.rec-hazard,
#recommendations-list li.rec-warning {
    border-left: 3px solid #F87171;
    padding-left: 12px;
}
#recommendations-list li.rec-caution {
    border-left: 3px solid #FB923C;
    padding-left: 12px;
}
#recommendations-list li.rec-info {
    border-left: 3px solid rgba(255,255,255,0.15);
    padding-left: 12px;
}

/* Gauge */
.condition-gauge {
    position: relative;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.gauge-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.gauge-track {
    fill: none;
    stroke: rgba(22, 35, 66, 0.85);
    stroke-width: 9;
}

.gauge-fill {
    fill: none;
    stroke: var(--cc, #60A5FA);
    stroke-width: 9;
    stroke-linecap: round;
    stroke-dasharray: 0 339;
    transition: stroke-dasharray 1.2s cubic-bezier(0.34, 1.2, 0.64, 1);
    filter: drop-shadow(0 0 6px var(--cc, #60A5FA));
}

.gauge-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gauge-score {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.6rem;
    line-height: 1;
    color: var(--cc, #60A5FA);
    letter-spacing: 0.02em;
    text-shadow: 0 0 16px var(--cc, #60A5FA);
}

.gauge-denom {
    font-size: 11px;
    color: #3D5070;
    font-weight: 500;
    letter-spacing: 0.04em;
    margin-top: -2px;
}

/* Text side */
.condition-text {
    position: relative;
    flex: 1;
}

.condition-text h4 {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 10px;
    color: var(--cc, #EEF2FF);
}

.condition-text p {
    color: #94AABF;
    line-height: 1.55;
    font-size: 13px;
}

.recommendations {
    padding: 24px;
    background: rgba(10, 22, 40, 0.95);
    border: 1px solid rgba(22, 35, 66, 0.7);
    border-radius: 16px;
}

.recommendations h3 {
    margin-bottom: 20px;
}

.recommendations ul {
    list-style: none;
}

.recommendations li {
    padding: 12px 0;
    padding-left: 25px;
    position: relative;
    border-bottom: 1px solid rgba(22, 35, 66, 0.7);
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
}

.recommendations li:before {
    content: "•";
    color: #60A5FA;
    font-weight: bold;
    position: absolute;
    left: 8px;
}

.recommendations li:last-child {
    border-bottom: none;
}

/* Cycling Types Section */
.cycling-types {
    padding: 24px;
    background: rgba(10, 22, 40, 0.95);
    border: 1px solid rgba(22, 35, 66, 0.7);
    border-radius: 16px;
}

.cycling-types h3 {
    margin-bottom: 20px;
}

.cycling-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.cycling-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(22, 35, 66, 0.25);
    border-radius: 12px;
    border: 1px solid rgba(22, 35, 66, 0.7);
}

.cycling-type-card {
    background: rgba(2, 12, 27, 0.8);
    border-radius: 12px;
    padding: 16px 12px;
    border: 1px solid rgba(22, 35, 66, 0.7);
    transition: border-color 0.2s;
    text-align: center;
    position: relative;
}

.cycling-type-card.suitable     { border-color: rgba(74, 222, 128, 0.25); }
.cycling-type-card.caution      { border-color: rgba(251, 146, 60, 0.25); }
.cycling-type-card.not-suitable { border-color: rgba(248, 113, 113, 0.25); }

.cycling-type-card:hover { border-color: rgba(22, 35, 66, 1); }

.cycling-icon {
    width: 30px;
    height: 30px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(63, 143, 196, 0.45);
}

.cycling-icon svg { width: 100%; height: 100%; }

.cycling-type-card.suitable     .cycling-icon { color: rgba(74, 222, 128, 0.80); }
.cycling-type-card.caution      .cycling-icon { color: rgba(251, 146, 60, 0.80); }
.cycling-type-card.not-suitable .cycling-icon { color: rgba(248, 113, 113, 0.70); }

.cycling-name {
    color: #ffffff;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
}

.cycling-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.cycling-status.suitable {
    color: #4caf50;
}

.cycling-status.caution {
    color: #ff9800;
}

.cycling-status.not-suitable {
    color: #f44336;
}

.cycling-description {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 6px;
    line-height: 1.3;
}

/* Forecast Section */
.forecast-section {
    padding: 24px;
    background: rgba(10, 22, 40, 0.95);
    border: 1px solid rgba(22, 35, 66, 0.7);
    border-radius: 16px;
}

.forecast-section h3 {
    margin-bottom: 20px;
}

.forecast-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.forecast-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(22, 35, 66, 0.25);
    border-radius: 12px;
    border: 1px solid rgba(22, 35, 66, 0.7);
}

.forecast-day {
    background: rgba(2, 12, 27, 0.8);
    border-radius: 12px;
    padding: 14px 12px;
    border: 1px solid rgba(22, 35, 66, 0.7);
    transition: border-color 0.2s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    opacity: 0;
    transform: translateY(12px);
    animation: fc-slide-in 0.45s ease forwards;
}

@keyframes fc-slide-in {
    to { opacity: 1; transform: translateY(0); }
}

#forecast-container .forecast-day:nth-child(1) { animation-delay: 0.05s; }
#forecast-container .forecast-day:nth-child(2) { animation-delay: 0.13s; }
#forecast-container .forecast-day:nth-child(3) { animation-delay: 0.21s; }
#forecast-container .forecast-day:nth-child(4) { animation-delay: 0.29s; }
#forecast-container .forecast-day:nth-child(5) { animation-delay: 0.37s; }

.forecast-day::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: rgba(22, 35, 66, 0.7);
}

.forecast-day.excellent::before { background: #4ADE80; }
.forecast-day.good::before      { background: #FBBF24; }
.forecast-day.caution::before   { background: #FB923C; }
.forecast-day.poor::before      { background: #F87171; }

.forecast-day:hover {
    border-color: rgba(22, 35, 66, 1);
}

.forecast-header {
    margin-bottom: 12px;
}

.forecast-day-info {
    text-align: center;
}

.forecast-header h4 {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #EEF2FF;
    margin: 0 0 4px 0;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.forecast-date {
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    display: block;
    font-weight: 500;
}

.forecast-weather {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-grow: 1;
}

.weather-icon {
    font-size: 2rem;
}

.weather-temp {
    text-align: right;
}

.temp-high {
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 600;
    margin-right: 4px;
}

.temp-low {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
}

.forecast-details {
    margin-bottom: 12px;
    flex-grow: 1;
}

.detail-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 11px;
}

.detail-item:last-child {
    margin-bottom: 0;
}

.detail-icon {
    margin-right: 8px;
    width: 16px;
    text-align: center;
}

.ride-score {
    text-align: center;
    border-top: 1px solid rgba(22, 35, 66, 0.7);
    padding-top: 12px;
}

.score-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.score-value {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    font-weight: 400;
    letter-spacing: 0.03em;
}

.score-value.excellent {
    color: #4caf50;
}

.score-value.good {
    color: #ffc107;
}

.score-value.caution {
    color: #ff9800;
}

.score-value.poor {
    color: #f44336;
}

.estimate-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Best Day Recommendation */
.best-day-card {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 193, 7, 0.1) 100%);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 12px;
    padding: 20px;
    display: none;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

.best-day-icon {
    font-size: 2rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.best-day-content h4 {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: #FBBF24;
    margin-bottom: 4px;
    line-height: 1.2;
}

.best-day-content p {
    color: rgba(207, 224, 240, 0.85);
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: rgba(4, 11, 22, 0.97);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 1px solid rgba(22, 35, 66, 0.7);
}

.modal-header h3 {
    color: #ffffff;
    margin: 0;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    color: #ffffff;
    background: rgba(22, 35, 66, 0.7);
}

.modal-body {
    padding: 30px;
}

.modal-body label {
    display: block;
    color: #ffffff;
    font-weight: 600;
    margin-bottom: 8px;
}

#location-label {
    width: 100%;
    padding: 14px 16px;
    background: rgba(22, 35, 66, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: #ffffff;
    font-size: 16px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

#location-label::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#location-label:focus {
    outline: none;
    border-color: #60A5FA;
    background: rgba(22, 35, 66, 0.7);
    box-shadow: 0 0 0 3px rgba(36, 56, 96, 0.7);
}

.location-preview {
    background: rgba(10, 22, 40, 0.95);
    border-radius: 10px;
    padding: 16px;
    border: 1px solid rgba(22, 35, 66, 0.7);
}

.location-preview h4 {
    color: #ffffff;
    margin-bottom: 4px;
    font-weight: 600;
}

.location-preview p {
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    font-size: 14px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 30px;
    border-top: 1px solid rgba(22, 35, 66, 0.7);
}

.cancel-btn {
    padding: 12px 24px;
    background: rgba(22, 35, 66, 0.7);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: rgba(22, 35, 66, 0.75);
    color: #ffffff;
}

.confirm-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #00c851 0%, #007e33 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 200, 81, 0.3);
}

.confirm-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 200, 81, 0.4);
}

/* Matrix page — full-width section shown when Matrix tab is active */
.matrix-results {
    position: relative;
    z-index: 10;
}

/* Collapse matrix tab padding when placeholder is hidden and results are showing */
#matrix-tab:not(:has(.matrix-placeholder:not([style*="none"]))) {
    padding: 0;
}

/* Matrix tab placeholder (shown before data is loaded) */
.matrix-placeholder {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(22, 35, 66, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(22, 35, 66, 0.6);
}

.matrix-placeholder p {
    font-size: 15px;
    font-weight: 600;
    color: #EEF2FF;
    margin-bottom: 8px;
}

.matrix-placeholder small {
    font-size: 13px;
    color: #94AABF;
    line-height: 1.5;
}

/* Trail Comparison Section */
.trail-comparison-section {
    background: rgba(10, 22, 40, 0.95);
    border: 1px solid rgba(22, 35, 66, 0.7);
    border-radius: 16px;
    margin-top: 20px;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

/* Fade hint on right edge — shows there's more to scroll */
.trail-comparison-section::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 32px;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(10, 22, 40, 0.85));
    pointer-events: none;
    border-radius: 0 16px 16px 0;
    z-index: 20;
}

.comparison-header {
    padding: 24px 28px 20px;
    border-bottom: 1px solid rgba(22, 35, 66, 0.7);
    background: none;
}

.comparison-header h3 {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: #C4261F;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.comparison-header p {
    font-size: 13px;
    color: #94AABF;
    margin: 0;
    font-weight: 500;
}

.refresh-btn {
    margin-top: 12px;
    background: rgba(22, 35, 66, 0.4);
    border: 1px solid rgba(22, 35, 66, 0.8);
    color: #94AABF;
    padding: 6px 14px;
    border-radius: 7px;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: rgba(22, 35, 66, 0.7);
    color: #EEF2FF;
}

/* Scrollable table wrapper */
.trail-comparison-grid {
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(22, 35, 66, 0.8) transparent;
}

.trail-comparison-grid::-webkit-scrollbar {
    height: 3px;
}

.trail-comparison-grid::-webkit-scrollbar-track { background: transparent; }

.trail-comparison-grid::-webkit-scrollbar-thumb {
    background: rgba(22, 35, 66, 0.9);
    border-radius: 2px;
}

.trail-comparison-table {
    width: 100%;
    min-width: 580px;
    border-collapse: collapse;
    border-spacing: 0;
}

/* Column headers */
.trail-comparison-table th {
    padding: 11px 10px;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #3D5070;
    text-align: left;
    background: rgba(2, 12, 27, 0.7);
    border-bottom: 1px solid rgba(22, 35, 66, 0.7);
    white-space: nowrap;
}

.trail-comparison-table th.day-header {
    text-align: center;
    min-width: 68px;
}

.trail-comparison-table th:nth-child(2) {
    width: 42px;
    text-align: center;
}

/* Sticky trail name column — stays visible while scrolling */
.trail-comparison-table th:first-child,
.trail-comparison-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
    min-width: 150px;
    max-width: 200px;
}

.trail-comparison-table th:first-child {
    background: #020C1B;
}

.trail-comparison-table td:first-child {
    background: #0A1628;
}

/* Subtle right-border separator on sticky column */
.trail-comparison-table th:first-child,
.trail-comparison-table td:first-child {
    border-right: 1px solid rgba(22, 35, 66, 0.7);
}

/* Cells */
.trail-comparison-table td {
    padding: 13px 10px;
    border-bottom: 1px solid rgba(22, 35, 66, 0.3);
    vertical-align: middle;
}

.trail-comparison-table tr:last-child td {
    border-bottom: none;
}

.trail-comparison-table tr:hover td {
    background: rgba(22, 35, 66, 0.12);
}

.trail-comparison-table tr:hover td:first-child {
    background: #101f3a;
}

.trail-info-cell {
    display: block;
    width: 100%;
}

.grade-column {
    text-align: center !important;
    vertical-align: middle !important;
    padding: 13px 6px !important;
}

.trail-mini-grade {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: -1px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}
.trail-mini-grade.grade-white        { color: #A0AEC0; }
.trail-mini-grade.grade-green        { color: #4ADE80; }
.trail-mini-grade.grade-blue         { color: #60A5FA; }
.trail-mini-grade.grade-red          { color: #EF4444; }
.trail-mini-grade.grade-black        { color: #CBD5E1; }
.trail-mini-grade.grade-double-black { color: #F87171; }

.trail-name-cell {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
    color: #EEF2FF;
    font-size: 13px;
    line-height: 1.2;
    margin-bottom: 3px;
}
.trail-name-link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
    text-decoration: underline;
    text-decoration-color: rgba(96, 165, 250, 0.4);
    text-underline-offset: 2px;
    transition: color 0.15s;
}
.trail-name-link:hover { color: #93C5FD; }

.trail-surface-cell {
    font-size: 10px;
    color: #3D5070;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-top: 2px;
}

.trail-last-ridden-small {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 9px;
    color: #C4261F;
    margin-top: 4px;
    letter-spacing: 0.03em;
}

.trail-description-small {
    font-size: 10px;
    color: rgba(148, 170, 191, 0.6);
    margin-top: 3px;
    line-height: 1.3;
    font-style: italic;
}

.day-condition-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-align: center;
    position: relative;
}

.day-rain {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: #3D5070;
    letter-spacing: -0.02em;
}

.day-score {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
}

.day-score.excellent { color: #4ADE80; }
.day-score.good      { color: #FBBF24; }
.day-score.caution   { color: #FB923C; }
.day-score.poor      { color: #F87171; }

.best-trail-indicator {
    position: absolute;
    top: -3px;
    right: 2px;
    font-size: 9px;
    color: #FBBF24;
    line-height: 1;
}

/* Location Comparison Styles */
/* ── Compare tab ────────────────────────────────────────── */

.location-comparison { min-height: 400px; }

.comparison-col-headers {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    padding: 4px 14px 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(61, 80, 112, 0.9);
}
.comparison-col-headers span:nth-child(2),
.comparison-col-headers span:nth-child(3) {
    min-width: 48px;
    text-align: right;
}

.comparison-grid {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.comparison-day {
    border-radius: 8px;
    overflow: hidden;
}

.comparison-day-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 10px 14px 8px;
    background: rgba(22, 35, 66, 0.6);
    border-bottom: 1px solid rgba(22, 35, 66, 0.9);
}

.comparison-day-name {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #EEF2FF;
}

.comparison-day-date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(148, 170, 191, 0.5);
    letter-spacing: 0.04em;
}

.best-location-badge {
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #4ADE80;
    padding: 2px 7px;
    border: 1px solid rgba(74, 222, 128, 0.3);
    border-radius: 3px;
    background: rgba(74, 222, 128, 0.07);
}

.location-comparison-cards {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: rgba(22, 35, 66, 0.25);
}

.location-compare-card {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    background: rgba(10, 22, 40, 0.6);
    border-left: 2px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}

.location-compare-card.best {
    border-left-color: #4ADE80;
    background: rgba(74, 222, 128, 0.04);
}

.compare-name {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: rgba(238, 242, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-compare-card.best .compare-name {
    color: #EEF2FF;
}

.compare-rain {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: rgba(148, 170, 191, 0.5);
    white-space: nowrap;
}

.compare-rain em {
    font-style: normal;
    font-size: 9px;
    opacity: 0.7;
}

.compare-rating {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    min-width: 48px;
    text-align: right;
}

.compare-rating em {
    font-style: normal;
    font-size: 10px;
    opacity: 0.5;
}

.compare-rating.excellent { color: #4ADE80; }
.compare-rating.good      { color: #FBBF24; }
.compare-rating.caution   { color: #FB923C; }
.compare-rating.poor      { color: #F87171; }

/* Desktop optimizations */
@media (min-width: 1200px) {
    .container {
        padding: 30px;
    }
}

/* ── Full-screen map on desktop ─────────────────────────────────────────── */
@media (min-width: 769px) {
    body:has(.tab-btn[data-tab="map"].active) {
        overflow: hidden;
    }

    /* Map fills the entire viewport */
    body:has(.tab-btn[data-tab="map"].active) #map-tab,
    body:has(.tab-btn[data-tab="map"].active) #map-tab .map-container {
        position: fixed;
        inset: 0;
        padding: 0;
        margin: 0;
        width: 100%;
        height: 100%;
    }

    body:has(.tab-btn[data-tab="map"].active) #map {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        margin: 0;
        border: none;
        z-index: 1;
        filter: none; /* filter on a fixed element breaks marker compositing */
    }

    body:has(.tab-btn[data-tab="map"].active) .header-content {
        flex-wrap: nowrap;
    }

    body:has(.tab-btn[data-tab="map"].active) .header-left {
        flex: 0 0 auto;
        margin-right: 0;
    }

    body:has(.tab-btn[data-tab="map"].active) .header-nav-group {
        width: auto;
    }

    /* Floating glass header over the map — centred, not full-width */
    body:has(.tab-btn[data-tab="map"].active) header {
        position: fixed;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: max-content;
        max-width: calc(100vw - 220px);
        overflow: hidden; /* prevent content spilling at high browser zoom */
        z-index: 1000;
        background: rgba(2, 12, 27, 0.72);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(96, 165, 250, 0.18);
        border-bottom: 1px solid rgba(96, 165, 250, 0.18);
        border-radius: 14px;
        padding: 10px 20px;
        margin: 0;
        box-shadow: 0 4px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.04) inset;
    }

    /* Match zoom controls to glass style */
    body:has(.tab-btn[data-tab="map"].active) #map .leaflet-control-zoom {
        background: rgba(2, 12, 27, 0.72) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border: 1px solid rgba(96, 165, 250, 0.18) !important;
        border-radius: 10px !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
        overflow: hidden;
    }

    body:has(.tab-btn[data-tab="map"].active) #map .leaflet-control-zoom a {
        background: transparent !important;
        color: rgba(238, 242, 255, 0.85) !important;
        border-bottom: 1px solid rgba(96, 165, 250, 0.12) !important;
    }

    body:has(.tab-btn[data-tab="map"].active) #map .leaflet-control-zoom a:last-child {
        border-bottom: none !important;
    }

    body:has(.tab-btn[data-tab="map"].active) #map .leaflet-control-zoom a:hover {
        background: rgba(96, 165, 250, 0.2) !important;
        color: #EEF2FF !important;
    }

    body:has(.tab-btn[data-tab="map"].active) .map-basemap-switcher {
        background: rgba(2, 12, 27, 0.72);
        border: 1px solid rgba(96, 165, 250, 0.18);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    body:has(.tab-btn[data-tab="map"].active) .map-basemap-btn {
        background: rgba(96, 165, 250, 0.06);
        border-color: rgba(96, 165, 250, 0.12);
    }

    body:has(.tab-btn[data-tab="map"].active) .map-basemap-btn:hover {
        background: rgba(60, 90, 140, 0.6);
        border-color: rgba(96, 165, 250, 0.4);
    }

    /* Collapse main so the fixed map doesn't create scroll */
    body:has(.tab-btn[data-tab="map"].active) main,
    body:has(.tab-btn[data-tab="map"].active) .container {
        padding: 0;
        margin: 0;
    }

    body:has(.tab-btn[data-tab="map"].active) .location-selection {
        margin: 0;
        padding: 0;
    }
}

/* Error */
.error {
    background: rgba(10, 22, 40, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 68, 68, 0.3);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 30px;
    text-align: center;
}

.error-message h3 {
    color: #ff4444;
    margin-bottom: 15px;
    font-weight: 600;
}

.error-message p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: rgba(255, 255, 255, 0.6);
}

footer a {
    color: #60A5FA;
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: #60A5FA;
}

.github-link {
    margin-top: 15px !important;
}

.github-link a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #8b949e;
    transition: color 0.2s ease;
    font-weight: 500;
}

.github-link a:hover {
    color: #f0f6fc;
    text-decoration: none;
}

.github-link svg {
    transition: transform 0.2s ease;
}

.github-link a:hover svg {
    transform: scale(1.1);
}

/* About Page Styles */
.about-content {
    max-width: 720px;
    margin: 0 auto;
    padding: 30px;
    color: #EEF2FF;
    line-height: 1.7;
}

.about-hero {
    margin-bottom: 48px;
}

.about-hero h2 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    font-size: 2rem;
    letter-spacing: -0.03em;
    color: #EEF2FF;
    margin: 6px 0 14px;
}

.about-lead {
    font-size: 1.05rem;
    color: rgba(238, 242, 255, 0.65);
    line-height: 1.75;
    max-width: 600px;
}

.about-overline {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #C4261F;
    margin-bottom: 6px;
}

.about-section {
    margin-bottom: 32px;
    background: rgba(10, 22, 40, 0.95);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid rgba(22, 35, 66, 0.7);
}

.about-section h3 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: #EEF2FF;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.about-section p {
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: rgba(238, 242, 255, 0.75);
}

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

.about-section ul {
    margin: 12px 0;
    padding-left: 0;
    list-style: none;
}

.about-section li {
    margin-bottom: 8px;
    color: rgba(238, 242, 255, 0.7);
    font-size: 0.93rem;
    padding-left: 16px;
    position: relative;
}

.about-section li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    width: 6px;
    height: 1px;
    background: #C4261F;
}

.about-section li strong {
    color: #EEF2FF;
    font-weight: 600;
}

.about-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.7);
}

.about-placeholder p {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: #60A5FA;
}

.about-placeholder small {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
}

/* GPS and Nearby Trails Styles */
.location-buttons-container {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.use-location-btn {
    background: rgba(22, 35, 66, 0.4);
    border: 1px solid rgba(22, 35, 66, 0.8);
    color: #94AABF;
    padding: 14px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-shrink: 0;
    white-space: nowrap;
}

.use-location-btn:hover {
    background: rgba(96, 165, 250, 0.3);
    transform: translateY(-1px);
}

.trail-matrix-btn {
    background: rgba(22, 35, 66, 0.4);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #FBBF24;
    padding: 14px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-shrink: 0;
    white-space: nowrap;
}

.trail-matrix-btn:hover {
    background: rgba(255, 215, 0, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.2);
}

.nearby-trails-toggle-btn {
    background: rgba(22, 35, 66, 0.4);
    border: 1px solid rgba(22, 35, 66, 0.8);
    color: #94AABF;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-top: 15px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nearby-trails-toggle-btn:hover {
    background: rgba(22, 35, 66, 0.7);
    color: #EEF2FF;
}

.nearby-trails-section {
    margin-top: 24px;
}

.nearby-trails-section p {
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 10px;
    font-size: 12px;
}

.trail-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0 12px;
    align-items: center;
}

.trail-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.trail-sort-select {
    background: rgba(10, 22, 40, 0.8);
    border: 1px solid rgba(22, 35, 66, 0.9);
    border-radius: 6px;
    color: rgba(238, 242, 255, 0.75);
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    padding: 5px 8px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s, color 0.15s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7db3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 22px;
}

.trail-sort-select:hover,
.trail-sort-select:focus {
    border-color: rgba(196, 38, 31, 0.6);
    color: #EEF2FF;
}

.trail-sort-select option {
    background: #0a1628;
    color: #EEF2FF;
}

.trail-filter-btn {
    background: rgba(10, 22, 40, 0.6);
    border: 1px solid rgba(22, 35, 66, 0.9);
    border-radius: 5px;
    color: rgba(238, 242, 255, 0.55);
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.trail-filter-btn:hover {
    border-color: rgba(196, 38, 31, 0.5);
    color: rgba(238, 242, 255, 0.85);
}

.trail-filter-btn.active {
    background: rgba(196, 38, 31, 0.15);
    border-color: rgba(196, 38, 31, 0.7);
    color: #EEF2FF;
}
.trail-filter-btn.grade-empty {
    opacity: 0.35;
    cursor: default;
}
.trail-filter-btn.grade-empty:hover {
    background: none;
    border-color: rgba(22, 35, 66, 0.7);
    color: #94AABF;
}

.no-trails-msg {
    text-align: center;
    padding: 24px 16px;
    color: rgba(238, 242, 255, 0.35);
    font-size: 12px;
    font-style: italic;
}

.nearby-trails-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid rgba(22, 35, 66, 0.7);
    border-radius: 10px;
    overflow: hidden;
}

.nearby-trail-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(22, 35, 66, 0.6);
    cursor: pointer;
    transition: background 0.15s ease;
}

.nearby-trail-card:last-child {
    border-bottom: none;
}

.nearby-trail-card:hover {
    background: rgba(22, 35, 66, 0.45);
}

/* Shared trail card / popup layout primitives */

.tc-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tc-name-group {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tc-name {
    min-width: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #EEF2FF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s;
}

.nearby-trail-card:hover .tc-name {
    color: #ffffff;
}

.nearby-trail-card:hover .tc-name-group .tc-name {
    color: #ffffff;
}

.tc-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.tc-footer .tc-dist {
    margin-left: auto;
}

.tc-dist {
    color: rgba(238, 242, 255, 0.35);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    flex-shrink: 0;
}

.tc-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tc-pill {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(22, 35, 66, 0.7);
    color: rgba(238, 242, 255, 0.6);
    white-space: nowrap;
}

.tc-pill--type                   { background: rgba(96, 165, 250, 0.12); color: #60A5FA; } /* default: blue */
.tc-pill--type.type-singletrack  { background: rgba(20, 184, 166, 0.12); color: #5eead4; } /* teal */
.tc-pill--type.type-doubletrack  { background: rgba(148, 170, 191, 0.12); color: #94AABF; } /* grey */
.tc-pill--type.type-fireroad     { background: rgba(74, 222, 128, 0.10); color: #4ADE80;  } /* green */
.tc-pill--type.type-paved        { background: rgba(148, 170, 191, 0.10); color: #7A8FA0; } /* muted grey */
.tc-pill--type.type-bikepark     { background: rgba(196, 38, 31, 0.12);  color: #f87171;  } /* red — bike parks are burly */

.tc-pill--dir {
    background: rgba(74, 222, 128, 0.1);
    color: #4ade80;
}

.tc-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tc-stat {
    display: flex;
    align-items: baseline;
    gap: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: rgba(238, 242, 255, 0.75);
}

.tc-stat-lbl {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(196, 38, 31, 0.9);
}

.popup-rating {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #fbbf24;
    letter-spacing: 0.04em;
    padding: 0 14px 6px;
}

.trail-surface {
    display: none;
}

.trail-card-header { display: contents; }
.trail-card-info   { display: contents; }
.trail-select-btn  { display: none; }

/* Medium screens — wrap nav below logo to prevent header overflow */
@media (max-width: 1050px) {
    .header-content {
        flex-wrap: wrap;
        gap: 10px;
    }

    .header-left {
        flex: 1;
        margin-right: 0;
    }

    .header-nav-group {
        width: 100%;
        justify-content: space-between;
    }
}

/* Tablet Responsive — match demo's 900px breakpoint */
@media (max-width: 900px) {
    .results-content {
        grid-template-columns: 1fr;
    }

    .results-left {
        border-right: none;
    }

    .forecast-container {
        grid-template-columns: repeat(5, 1fr);
    }

    .cycling-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
        max-width: 100%;
    }
    
    .header-content {
        gap: 10px;
    }

    .header-left {
        text-align: left;
    }
    
    header h1 {
        font-size: 2rem;
        gap: 10px;
    }
    
    .logo-image {
        height: 46px;
    }

    .header-strava-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .settings-content,
    .tab-content {
        padding: 16px;
    }
    
    .api-key-input-group {
        flex-direction: column;
    }
    
    .time-periods {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .period-card {
        padding: 12px 6px;
    }

    .rainfall-amount {
        font-size: 1.8rem;
    }
    
    .condition-card {
        flex-direction: column;
        text-align: center;
        padding: 24px 20px;
        gap: 20px;
    }

    .condition-gauge {
        width: 120px;
        height: 120px;
        margin: 0 auto;
    }

    .gauge-score { font-size: 2.6rem; }

    .condition-text h4 { font-size: 2rem; }
    .condition-text p { max-width: 100%; }
    
    .location-info {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .locations-grid {
        grid-template-columns: 1fr;
    }
    
    .forecast-container {
        grid-template-columns: 1fr;
        gap: 1px;
        background: rgba(22, 35, 66, 0.7);
        border: 1px solid rgba(22, 35, 66, 0.7);
        border-radius: 12px;
        overflow: hidden;
    }

    .forecast-day {
        flex-direction: row;
        align-items: center;
        text-align: left;
        padding: 10px 14px;
        gap: 0;
        border-radius: 0;
        border: none;
        background: rgba(2, 12, 27, 0.85);
    }

    .forecast-day::before {
        top: 0; bottom: 0; left: 0; right: auto;
        width: 3px;
        height: auto;
        border-radius: 0;
    }

    .forecast-header {
        flex: 0 0 46px;
        margin-bottom: 0;
    }

    .forecast-day-info {
        text-align: left;
    }

    .forecast-header h4 {
        font-size: 0.78rem;
        margin-bottom: 2px;
    }

    .forecast-date {
        font-size: 10px;
    }

    .forecast-weather {
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        margin-bottom: 0;
        margin: 0 12px;
    }

    .weather-icon {
        font-size: 1.2rem;
    }

    .weather-temp {
        text-align: left;
        white-space: nowrap;
    }

    .temp-high {
        font-size: 0.9rem;
    }

    .temp-low {
        font-size: 0.8rem;
    }

    .forecast-details {
        display: flex;
        flex: 1;
        flex-direction: row;
        gap: 8px;
        margin-bottom: 0;
        align-items: center;
    }

    .detail-item {
        margin-bottom: 0;
        font-size: 10px;
        gap: 2px;
    }

    .detail-item:nth-child(2),
    .detail-item:nth-child(3) {
        display: none;
    }

    .detail-icon {
        margin-right: 2px;
    }

    .ride-score {
        flex: 0 0 auto;
        border-top: none;
        padding-top: 0;
        padding-left: 12px;
        margin-left: auto;
        border-left: 1px solid rgba(22, 35, 66, 0.7);
        text-align: center;
    }

    .score-label {
        display: none;
    }

    .score-value {
        font-size: 1rem;
    }
    
    .best-day-card {
        flex-direction: column;
        text-align: center;
    }
    
    .results-content {
        grid-template-columns: 1fr;
    }
    
    .results-left {
        border-right: none;
        border-bottom: 1px solid rgba(22, 35, 66, 0.7);
    }
    
    .cycling-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 8px;
    }
    
    .location-comparison-cards {
        grid-template-columns: 1fr;
    }
    
    /* Search row: input full-width, secondary buttons share a row, check btn full-width */
    #unified-search {
        flex: 1 1 100%;
    }

    .location-buttons-container {
        flex: 1 1 100%;
    }

    .use-location-btn,
    .trail-matrix-btn {
        flex: 1;
        padding: 12px 10px;
        font-size: 12px;
        justify-content: center;
    }

    .search-container {
        flex-direction: column;
    }

    .search-input-wrapper {
        width: 100%;
        flex: none;
    }

    .check-btn {
        width: 100%;
        flex: none;
        text-align: center;
    }

    /* AI Trail Matrix button row — breathing room so it doesn't crowd the input/check-btn */
    .location-buttons-container {
        margin-top: 4px;
        margin-bottom: 4px;
    }

    /* Map tab full-screen below header — strip card chrome, fill viewport */
    body:has(.tab-btn[data-tab="map"].active) .location-selection {
        background: none;
        border: none;
        border-radius: 0;
        box-shadow: none;
        margin-left: -15px;
        margin-right: -15px;
        margin-bottom: 0;
    }

    body:has(.tab-btn[data-tab="map"].active) #map-tab {
        padding: 0;
    }

    body:has(.tab-btn[data-tab="map"].active) #map {
        min-height: 0;
        border-radius: 0;
        margin: 0;
        border-left: none;
        border-right: none;
    }
}

/* Nearby Trails Pagination */
.nearby-trails-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
    padding: 8px 14px;
    border-top: 1px solid rgba(22, 35, 66, 0.6);
}

.pagination-btn {
    background: none;
    border: none;
    color: rgba(238, 242, 255, 0.5);
    font-size: 18px;
    line-height: 1;
    padding: 4px 10px;
    cursor: pointer;
    transition: color 0.15s;
    font-family: sans-serif;
}

.pagination-btn:hover:not(:disabled) {
    color: #EEF2FF;
}

.pagination-btn:disabled {
    color: rgba(238, 242, 255, 0.15);
    cursor: default;
}

.pagination-info {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: rgba(238, 242, 255, 0.45);
    padding: 0 8px;
    min-width: 48px;
    text-align: center;
}

/* Strava Integration Styles */
.strava-integration {
    max-width: 600px;
    margin: 0 auto;
}

.strava-header {
    text-align: center;
    margin-bottom: 30px;
}

.strava-header h3 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -0.02em;
    color: #EEF2FF;
    margin-bottom: 8px;
}

.strava-benefits {
    margin-bottom: 25px;
}

.strava-benefits h4 {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #C4261F;
    margin-bottom: 14px;
}

.strava-benefits ul {
    list-style: none;
    padding: 0;
}

.strava-benefits li {
    padding: 8px 0 8px 14px;
    color: #94AABF;
    border-bottom: 1px solid rgba(22, 35, 66, 0.7);
    position: relative;
    font-size: 0.93rem;
}

.strava-benefits li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 16px;
    width: 6px;
    height: 1px;
    background: #C4261F;
}

.strava-benefits li:last-child {
    border-bottom: none;
}

.connect-strava-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #FC4C02 0%, #FF6B35 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.connect-strava-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(252, 76, 2, 0.3);
}

.strava-logo {
    font-size: 20px;
}

.strava-permissions {
    text-align: center;
    color: #94a3b8;
}

.connection-success {
    text-align: center;
    margin-bottom: 25px;
}

.connection-success h4 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: #4ADE80;
    margin-bottom: 8px;
}

.strava-status {
    background: rgba(10, 22, 40, 0.95);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(22, 35, 66, 0.7);
}

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

.status-label {
    color: #94a3b8;
    font-weight: 500;
}

.status-value {
    color: #e2e8f0;
    font-weight: 600;
}

.status-active {
    color: #10b981;
}

.strava-example {
    margin-bottom: 25px;
}

.strava-example h5 {
    margin-bottom: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #C4261F;
}

.example-summary {
    background: rgba(2, 12, 27, 0.8);
    border-radius: 8px;
    padding: 16px 18px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    line-height: 1.8;
    color: rgba(238, 242, 255, 0.55);
    border-left: 3px solid #C4261F;
}

.disconnect-strava-btn {
    width: 100%;
    padding: 12px 24px;
    background: transparent;
    color: #F87171;
    border: 1px solid #F87171;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.disconnect-strava-btn:hover {
    background: #F87171;
    color: white;
}

/* Trail Information Styles */
/* Trail data chips */
.trail-detail-section {
    margin: 10px 0;
}

.trail-detail-section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #C4261F;
    margin-bottom: 6px;
}

.trail-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
}

.trail-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(22, 35, 66, 0.4);
    border: 1px solid rgba(22, 35, 66, 0.85);
    border-radius: 6px;
}

.trail-chip-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #3D5070;
}

.trail-chip-value {
    font-size: 12px;
    font-weight: 600;
    color: #EEF2FF;
}

.trail-links {
    margin: 12px 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.trail-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: rgba(22, 35, 66, 0.7);
    color: #60A5FA;
    text-decoration: none;
    border-radius: 6px;
    font-size: 12px;
    transition: all 0.3s ease;
}

.trail-link:hover {
    background: rgba(96, 165, 250, 0.2);
    color: #93c5fd;
    transform: translateY(-1px);
}

.trail-link--strava {
    background: #FC4C02;
    color: #fff;
    font-weight: 600;
    gap: 5px;
}

.trail-link--strava::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23fff' d='M15.387 17.944l-2.089-4.116h-3.065L15.387 24l5.15-10.172h-3.066m-7.008-5.599l2.836 5.598h4.172L10.463 0l-7 13.828h4.169'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    flex-shrink: 0;
}

.trail-link--strava:hover {
    background: #e8430a;
    color: #fff;
    transform: translateY(-1px);
}

/* ── Glass controls on mobile map ───────────────────────────────────────── */
@media (max-width: 768px) {
    #map .leaflet-control-zoom {
        background: rgba(2, 12, 27, 0.72) !important;
        backdrop-filter: blur(16px) !important;
        -webkit-backdrop-filter: blur(16px) !important;
        border: 1px solid rgba(96, 165, 250, 0.18) !important;
        border-radius: 10px !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
        overflow: hidden;
    }

    #map .leaflet-control-zoom a {
        background: transparent !important;
        color: rgba(238, 242, 255, 0.85) !important;
        border-bottom: 1px solid rgba(96, 165, 250, 0.12) !important;
    }

    #map .leaflet-control-zoom a:last-child {
        border-bottom: none !important;
    }

    #map .leaflet-control-zoom a:hover {
        background: rgba(96, 165, 250, 0.2) !important;
    }

    .map-basemap-switcher {
        background: rgba(2, 12, 27, 0.72);
        border: 1px solid rgba(96, 165, 250, 0.18);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }

    .map-basemap-btn {
        background: rgba(96, 165, 250, 0.06);
        border-color: rgba(96, 165, 250, 0.12);
    }
}

