html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#app {
    position: relative;
    height: 100vh;
}

#sidebar h2 {
    margin: 0 0 10px 0;
    font-size: 18px;
}

#sidebar h3 {
    margin: 10px 0 4px 0;
    font-size: 14px;
}

/* MAP (desktop) */
#map {
    position: absolute;
    top: 0;
    left: 540px;
    right: 0;
    bottom: 200px;
}

.route-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    flex-shrink: 0;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* DOWNLOAD BUTTON */
.download-btn {
    margin-left: auto;
    font-size: 18px;
    text-decoration: none;
    color: #333;
}

/* ELEVATION (desktop) */
#elevation {
    position: absolute;
    left: 540px;
    right: 0;
    bottom: 0;
    height: 200px;
    background: #f7f7f7;
    border-top: 1px solid #ccc;
}

/* ----------------------------- */
/* TOGGLES                       */
/* ----------------------------- */

.toggle-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.toggle-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Slider switch */
.switch {
    display: flex;
    align-items: center;
    position: relative;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #4CAF50;
    transition: .4s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2E8B57;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.toggle-text {
    white-space: nowrap;
    font-size: 12px;
    line-height: 1;
}

/* ----------------------------- */
/* MOBILE LAYOUT (iPhone fix)   */
/* ----------------------------- */

@media (max-width: 900px) {

    #map {
        position: relative !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 55vh !important;
        bottom: 0 !important;
    }

    #elevation {
        position: relative !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 25vh !important;
        margin-top: 10px;
    }

    .route-item {
        padding: 4px 2px;
        gap: 8px;
        min-height: 30px;
        font-size: 13px;
        min-width: 0;
    }

}
/* Allow vertical page scrolling while keeping map gestures */
.leaflet-container {
  touch-action: pan-y !important;
  -webkit-user-drag: none !important;
}

/* Elevation panel fully visible on iPhone */
#elevation {
  z-index: 999 !important;
  height: 45vh !important;
  min-height: 260px !important;
  overflow-y: scroll !important;
  -webkit-overflow-scrolling: touch !important;
}

/* Make elevation summary text visible */
#elevation .elevation-summary {
  display: block !important;
  padding: 8px 10px !important;
  font-size: 13px !important;
  line-height: 1.3 !important;
  color: #333 !important;
  min-height: 40px !important;
}

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

/* --- CLEAN 2 LINE ROUTE LIST LAYOUT --- */

.route-text {
    display: flex;
    flex-direction: column;
    margin-left: 6px;
    width: 100%;
    min-width: 0;
}

.route-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    font-size: 14px;
    text-align: left;
}

.stats {
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    margin-top: 2px;
    text-align: left;
}

/* Force route item text to normal, keep only route-name bold */
#sidebar .route-item {
    font-weight: normal !important;
}

#sidebar .route-item * {
    font-weight: normal !important;
}

.route-name {
    font-weight: 600 !important;
}

#sort-bar {
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 0;
}

#sort-bar button {
    flex: 1;
    padding: 6px 0;
    border: 1px solid #ccc;
    background: #eee;              /* light grey */
    border-radius: 6px;
    font-size: 14px;
    color: #333 !important;        /* force dark text */
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
}

#sort-bar button.active {
    background: #333 !important;   /* dark background */
    color: #fff !important;        /* white text */
}

#sort-bar button {
    appearance: none;
    color: #333 !important;
    -webkit-appearance: none;
}

.sort-label {
    font-size: 13px;
    margin-bottom: 1px;
    color: #444;
}

.bss-badge {
    display: inline-block !important;
    width: 70px !important;
    text-align: center !important;
    padding: 2px 0 !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    margin-right: 6px !important;
    white-space: nowrap !important;
    color: #fff !important;
}

.bss-none   { background-color: #ccc !important; color:#000 !important; }
.bss-easy   { background-color: #2ecc71 !important; }
.bss-medium { background-color: #f1c40f !important; color:#000 !important; }
.bss-hard   { background-color: #e67e22 !important; }
.bss-epic   { background-color: #c0392b !important; }
.bss-insane { background-color: #000 !important; color:#fff !important; }

.version {
    font-size: 0.75rem;
    opacity: 0.55;
    margin-top: -6px;
    margin-bottom: 12px;
}
/* === CLEAN SIDEBAR STRUCTURE (DESKTOP) === */

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 4px;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.sidebar-section:last-child {
    border-bottom: none;
}

/* === MOBILE SIDEBAR TWEAKS === */
@media (max-width: 900px) {

    .sidebar-header h2 {
        font-size: 18px;
    }

    .sidebar-section {
        padding-bottom: 8px;
        gap: 6px;
    }

    #sort-bar button {
        font-size: 13px;
        padding: 5px 0;
    }
}
/* tighten space between version and Sort By */
.sidebar-header {
    margin-bottom: 0 !important;
}

.version {
    margin-bottom: 4px !important;   /* was 12px */
}
.sidebar-section:first-of-type {
    padding-top: 0 !important;
    margin-top: -6px !important;   /* pulls Sort By closer to version */
}

/* reduce space under title and version */
#sidebar h2 {
    margin: 0 0 4px 0 !important;
}

.version {
    margin-top: -2px !important;
    margin-bottom: 4px !important;
}
/* pull first section (Sort By) closer to version */
.sidebar-section:first-of-type {
    padding-top: 0 !important;
    margin-top: -4px !important;
}
/* version inline next to title */
.version-inline {
    font-size: 0.75em;        /* keeps existing size relative to title */
    opacity: 0.55;
    margin-left: 8px;         /* small gap between title and version */
    font-weight: normal;
    vertical-align: middle;
}

/* remove old version block spacing */
.version {
    display: none !important;
}
/* toggle button styled like sort buttons */
#toggle-all-btn {
    flex: 1;
    padding: 6px 0;
    border: 1px solid #ccc;
    background: #eee;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

#toggle-all-btn.active {
    background: #333;
    color: #fff;
}
#sort-bar {
    display: flex;
    gap: 6px;
}

#sort-bar button,
#toggle-all-btn {
    flex: 1 1 0;
    z-index: 10;
}

#map {
    z-index: 1;
}

#sort-bar {
    display: flex;
    gap: 6px;
}

#sort-bar button {
    flex: 1 1 0;
}
/* === WEATHER BADGES (SAFE, NON‑DESTRUCTIVE) === */

.weather-header {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 48px;
}

.weather-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 70px;
    padding: 4px 0;
    border-radius: 4px;
    font-size: 11px;
    color: #fff;
    text-align: center;
}

.wb-label {
    font-size: 10px;
    opacity: 0.85;
    margin-bottom: 2px;
}

.wb-value {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* Wind colours */
.wind-calm    { background:#2ecc71; }
.wind-breezy  { background:#f1c40f; color:#000; }
.wind-strong  { background:#e67e22; }
.wind-warning { background:#c0392b; }
.wind-insane  { background:#000; }

/* UV colours */
.uv-low       { background:#2ecc71; }
.uv-moderate  { background:#f1c40f; color:#000; }
.uv-high      { background:#e67e22; }
.uv-veryhigh  { background:#c0392b; }
.uv-extreme   { background:#8e44ad; }

/* Gust colours */
.gust-light   { background:#2ecc71; }
.gust-medium  { background:#f1c40f; color:#000; }
.gust-strong  { background:#e67e22; }
.gust-danger  { background:#c0392b; }
.gust-insane  { background:#000; }

/* Reduce internal badge padding */
.weather-badge {
    padding: 2px 0 !important;
}

/* Tighten mobile even more */
@media (max-width: 900px) {
    .weather-header {
        margin-top: 0 !important;
        margin-bottom: 2px !important;
        gap: 4px !important;
    }
    .weather-badge {
        padding: 1px 0 !important;
    }
}
.temp-badge { background:#ff7f50; }
.weather-header {
    opacity: 0;
    transition: opacity 0.25s ease;
    will-change: opacity;
}

.weather-header.loaded {
    opacity: 1;
}

.weather-label {
    width: 100%;
    text-align: center;
    font-size: 11px;
    opacity: 0.7;
    margin-bottom: 2px;
    transition: opacity 0.25s ease;
}

/*
#elevation .elevation-summary {
    display: none !important;
}
*/

/* === HIDE ONLY TOT TIME + AVG ELEVATION IN ELEVATION SUMMARY === */
#elevation .elevation-summary .tottime,
#elevation .elevation-summary .avgele {
    display: none !important;
}


/* === FINAL SIDEBAR LAYOUT (DESKTOP) === */
#sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 540px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* prevents pushing map down */
    background: #f7f7f7;
    box-sizing: border-box;
}

/* Only the route list scrolls */
.route-lists {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* === MOBILE SIDEBAR (iPhone) === */
@media (max-width: 900px) {
    #sidebar {
        position: relative;
        width: 100%;
        height: 45vh !important;
        overflow: hidden;
    }

    .route-lists {
        flex: 1;
        overflow-y: auto;
    }
        .download-btn {
        padding-right: 12px !important;   /* space from right edge */
        padding-left: 6px !important;     /* keeps icon centered */
    }
}

/* === FIX 4‑LINE ROUTE ITEM ISSUE === */

.route-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    min-height: 32px !important;
}

.route-left {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

.route-text {
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
}

/* === FIX EDGE: restore vertical spacing between route-items === */
@media (min-width: 901px) {
    .route-item {
        padding-top: 4px !important;
        padding-bottom: 4px !important;
    }
}

.sidebar-section {
    justify-content: center;
}

#sort-bar {
    display: flex;
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
}

#sort-bar button {
    flex: 1 1 0;
}

.bss-info {
    font-size: 13px;
    color: #666;
    text-align: center;
    margin-top: 2px;
    opacity: 0.75;
    line-height: 1.3;
    padding-top: 2px;
    padding-bottom: 2px;
}

.sidebar-header h2 {
    text-align: center;
    white-space: normal;
    word-break: break-word;
}

#bikeride-list {
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    height: 100% !important;
    transform: none !important;
    direction: ltr !important;
    scroll-behavior: auto !important;
}

#bikeride-list > * {
    order: 0 !important;
    -webkit-order: 0 !important;
    transform: none !important;
}
.route-lists { overflow: hidden !important; height: auto !important; }

.badge {
  appearance: none;
  -webkit-appearance: none;
  background: #444;
  color: #fff;
  border: none;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 16px;
  height: 20px;
  margin-right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: background-color 0.15s, transform 0.1s;
  cursor: pointer;
}

/* same dynamic colors as BSS */
.bss-easy    { background: #4caf50; }
.bss-medium  { background: #8bc34a; }
.bss-hard    { background: #ff9800; }
.bss-epic    { background: #f44336; }
.bss-insane  { background: #000; }
.bss-none    { background: #777; }

.stats-text {
    margin-left: 8px;
    font-size: 12px;
    vertical-align: middle;
}

/* Hover feedback */
.badge:hover {
  background-color: #555;      /* slightly lighter */
}

/* Touch/active feedback */
.badge:active {
  background-color: #333;      /* slightly darker */
  transform: scale(0.96);      /* tiny press animation */


