:root {
    --primary: #FF6B35;
    --primary-dark: #E55A2B;
    --primary-gradient: linear-gradient(135deg, #FF6B35, #F7931E);
    --accent: #2D3047;
    --text-dark: #333;
    --text-muted: #666;
    --climb-green: #4CAF50;
    --bg-light: #f5f5f7;
}
* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px;
    background: #f5f5f7;
    overflow-x: hidden;
}
body.collection-mode {
    padding: 6px;
}
@media (min-width: 1200px) {
    body { max-width: 1300px; }
    body.collection-mode { max-width: 98%; padding: 6px; }
}
@media (max-width: 480px) {
    body { padding: 6px; }
    body.collection-mode { padding: 4px; }
}
h1 { color: var(--accent); font-size: 1.5em; }
form {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
label:not(.toggle-label) {
    display: block;
    margin-top: 15px;
    font-weight: 600;
    color: #555;
}
label:not(.toggle-label):first-child { margin-top: 0; }
input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 12px;
    margin-top: 5px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}
.param-row {
    display: flex;
    gap: 15px;
}
form > .param-row { margin-top: 8px; }
.param-row > div { flex: 1; }
form > button[type="submit"],
.analyze-btn {
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
form > button[type="submit"]:hover,
.analyze-btn:hover { background: #0056b3; }
form > button[type="submit"]:disabled,
.analyze-btn:disabled { background: #999; cursor: not-allowed; }
.results {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;  /* Allow horizontal scroll for wide tables */
}
.results.route-results {
    border-left: 4px solid #4CAF50;
}
.results.trip-results {
    border-left: 4px solid #2196F3;
}
.result-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: 28px;
    box-sizing: border-box;
}
.route-badge {
    background: #E8F5E9;
    color: #2E7D32;
}
.trip-badge {
    background: #E3F2FD;
    color: #1565C0;
}
.offline-badge {
    background: #FFF3E0;
    color: #E65100;
}
.results h2 { margin-top: 0; font-size: 1.2em; color: #333; }
.results h2 a { color: inherit; text-decoration: none; }
.results h2 a:hover { color: var(--primary); }
.results-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
#chartToggleContainer {
    margin-left: auto;
}
.results-header h2 {
    margin: 0;
}
.share-btn {
    padding: 4px 10px;
    background: white;
    border: 1.5px solid var(--primary);
    color: var(--primary);
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
    width: auto;
    height: 28px;
    box-sizing: border-box;
    margin: 0;
}
.share-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}
.share-btn:hover {
    background: var(--primary);
    color: white;
}
.share-btn.copied {
    background: #28a745;
    border-color: #28a745;
    color: white;
}
.result-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}
.result-row:last-child { border-bottom: none; }
#collectionResults .result-row {
    max-width: 350px;
}
.result-label { color: #666; }
.result-value { font-weight: 600; color: #333; }
.result-row.primary {
    background: #f0f7ff;
}
.result-row.primary .result-value {
    font-weight: 700;
}
.unit-select {
    padding: 1px 2px;
    font-size: 0.75em;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    max-width: 70px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 2px center;
    background-size: 12px;
    padding-right: 16px;
}
.unit-select:hover {
    border-color: #4CAF50;
}
.result-row .unit-select {
    margin-left: 4px;
}
.result-row .result-label {
    flex-shrink: 0;
}
.result-row .result-value {
    text-align: right;
    margin-left: auto;
}
.climate-waypoints .result-value {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 4px;
    align-items: baseline;
}
.climate-waypoint-link {
    color: #f59e0b;
    text-decoration: none;
    font-size: 0.9em;
}
.climate-waypoint-link:hover {
    text-decoration: underline;
}
.climate-elev {
    font-size: 0.85em;
    color: #999;
}
.primary-results {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #ccc;
}
.steepness-results {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #ccc;
}
.steepness-results .result-row {
    background: #fff8f0;
}
.steepness-results .result-row .result-value {
    font-weight: 600;
}
.results-stats {
    max-width: 350px;
}
@media (min-width: 900px) {
    .results-body {
        display: grid;
        grid-template-columns: 350px 1fr;
        gap: 24px;
        align-items: start;
    }
    .results-body .result-row,
    .results-body .primary-results {
        max-width: none;
    }
    .results-visuals .histogram-bar .bar-container {
        height: 120px;
    }
}
.error {
    background: #fee;
    color: #c00;
    padding: 15px;
    border-radius: 6px;
    margin-top: 20px;
}
.note {
    font-size: 0.85em;
    color: #888;
    margin-top: 10px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
}
.anomaly-note {
    background: #FFF3E0;
    border-left: 3px solid #FF9800;
    color: #5D4037;
}
.anomaly-note strong {
    color: #E65100;
}
.anomaly-item {
    display: inline-block;
    background: #FFE0B2;
    padding: 2px 6px;
    border-radius: 3px;
    margin: 2px 0;
}
.noise-note {
    background: #E3F2FD;
    border-left: 3px solid #2196F3;
    color: #1565C0;
    white-space: nowrap;
    padding: 4px 8px;
}
.noise-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    line-height: 1;
}
.noise-badge .info-btn {
    vertical-align: middle;
}
.histograms-container {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}
@media (max-width: 600px) {
    .histograms-container {
        flex-direction: column;
    }
}
.grade-histogram {
    flex: 1;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
}
.grade-histogram h4 {
    margin: 0 0 10px 0;
    font-size: 0.9em;
    color: #555;
}
.steep-section {
    margin-top: 20px;
    padding: 15px;
    background: #fff5f0;
    border-radius: 6px;
    border-left: 3px solid #ff6600;
}
.steep-section > h4 {
    margin: 0 0 12px 0;
    font-size: 1em;
    color: #e55a00;
}
.steep-chart-link {
    font-size: 0.85em;
    font-weight: 400;
    color: #e55a00;
    text-decoration: underline;
    margin-left: 6px;
}
.steep-stats {
    display: flex;
    gap: 15px 25px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.steep-stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.steep-label {
    font-size: 0.85em;
    color: #666;
    white-space: nowrap;
}
.steep-value {
    font-weight: 600;
    color: #e55a00;
}
.steep-section .histograms-container {
    margin-top: 10px;
}
.steep-section .grade-histogram {
    background: white;
}
.histogram-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
}
.histogram-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    min-height: 80px;
}
.histogram-bar .bar-container {
    width: 100%;
    height: 60px;
    display: flex;
    align-items: flex-end;
    cursor: pointer;
    /* Extend touch target area */
    padding: 10px 2px 0 2px;
    margin: -10px -2px 0 -2px;
}
.histogram-bar .bar {
    width: 100%;
    border-radius: 2px 2px 0 0;
    min-height: 4px;  /* Larger minimum for touch */
}
/* Make entire histogram-bar touchable on mobile */
@media (pointer: coarse) {
    .histogram-bar {
        cursor: pointer;
    }
    .histogram-bar .bar {
        min-height: 8px;  /* Even larger on touch devices */
    }
}
.histogram-bar .label {
    font-size: 0.6em;
    color: #888;
    margin-top: 4px;
    white-space: nowrap;
}
.histogram-bar .pct {
    font-size: 0.6em;
    color: #666;
}
.elevation-profile {
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.elevation-profile h4 {
    margin: 0 0 10px 0;
    font-size: 0.95em;
    color: #333;
}
.elevation-profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.elevation-profile-header h4 {
    margin: 0;
}
.elevation-profile-header h4 a {
    color: #333;
    text-decoration: none;
}
.elevation-profile-header h4 a:hover {
    color: #1a73e8;
    text-decoration: underline;
}
.ride-link {
    white-space: nowrap;
}
@media (max-width: 600px) {
    .elevation-profile-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .elevation-profile-header h4 {
        width: 100%;
    }
    .ride-link {
        order: 3;
        margin-left: auto;
    }
}
.elevation-profile-toggles {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 0.85em;
}
.collapse-stops-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    vertical-align: middle;
}
.collapse-stops-toggle input {
    margin: 0;
    cursor: pointer;
    vertical-align: middle;
}
.collapse-stops-toggle label {
    cursor: pointer;
    color: #666;
    font-weight: normal;
    line-height: 1;
    vertical-align: middle;
    margin-top: 0;
}
.elevation-profile-container {
    position: relative;
    width: 100%;
}
.elevation-profile img {
    width: 100%;
    height: auto;
    display: block;
    /* Prevent Safari long-press context menu */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.elevation-canvas {
    width: 100%;
    height: 200px;
    display: block;
    /* Prevent Safari long-press context menu */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.elevation-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
    z-index: 100;
    transform: translateX(-50%);
}
.elevation-tooltip.visible {
    opacity: 1;
}
.elevation-tooltip .grade {
    font-weight: bold;
    font-size: 14px;
}
.elevation-tooltip .elev {
    color: #ccc;
    margin-top: 2px;
}
.elevation-tooltip .poi-name {
    font-weight: bold;
    font-size: 11px;
    color: #8bc34a;
    margin-bottom: 2px;
}
.elevation-cursor {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(0, 0, 0, 0.5);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}
.elevation-cursor.visible {
    opacity: 1;
}
.elevation-selection {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(59, 130, 246, 0.2);
    border-left: 2px solid rgba(59, 130, 246, 0.6);
    border-right: 2px solid rgba(59, 130, 246, 0.6);
    pointer-events: none;
    opacity: 0;
    z-index: 50;
}
.elevation-selection.visible {
    opacity: 1;
}
.elevation-selection-popup {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 200;
    white-space: nowrap;
    transform: translateX(-50%);
    pointer-events: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.elevation-selection-popup .selection-close {
    position: absolute;
    top: 2px;
    right: 6px;
    cursor: pointer;
    color: #888;
    font-size: 14px;
    line-height: 1;
}
.elevation-selection-popup .selection-close:hover {
    color: white;
}
.elevation-selection-popup .selection-stat {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.elevation-selection-popup .stat-label {
    color: #aaa;
}
.elevation-selection-popup .stat-value {
    font-weight: bold;
}
.selection-zoom-btn {
    margin-top: 8px;
    padding: 6px 12px;
    background: #3b82f6;
    color: white;
    border-radius: 4px;
    text-align: center;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}
.selection-zoom-btn:hover {
    background: #2563eb;
}
.selection-climate-btn {
    margin-top: 4px;
    padding: 6px 12px;
    background: #f59e0b;
    color: white;
    border-radius: 4px;
    text-align: center;
    cursor: pointer;
    font-size: 12px;
}
.selection-climate-btn:hover {
    background: #d97706;
}
.zoom-out-link {
    position: absolute;
    bottom: 2px;
    right: 10%;
    z-index: 100;
}
.zoom-out-link a {
    color: #3b82f6;
    font-size: 12px;
    text-decoration: none;
}
.zoom-out-link a:hover {
    text-decoration: underline;
}
.profile-climate-link {
    position: absolute;
    bottom: 2px;
    left: 10%;
    z-index: 100;
}
.profile-climate-link a {
    color: #f59e0b;
    font-size: 12px;
    text-decoration: none;
}
.profile-climate-link a:hover {
    text-decoration: underline;
}

/* Long-press indicator for touch selection */
.long-press-indicator {
    position: absolute;
    width: 60px;
    height: 60px;
    margin-left: -30px;
    margin-top: -30px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease-out;
    z-index: 100;
}
.long-press-indicator.active {
    opacity: 1;
}
.long-press-ring {
    width: 100%;
    height: 100%;
    border: 3px solid #2196F3;
    border-radius: 50%;
    animation: long-press-pulse 0.4s ease-out forwards;
    box-sizing: border-box;
}
@keyframes long-press-pulse {
    0% {
        transform: scale(0.3);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 0;
        border-width: 2px;
    }
}

.elevation-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    background: #f8f8f8;
    border-radius: 4px;
}
.elevation-loading.hidden {
    display: none;
}
.elevation-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #666;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.elevation-profile img.loading {
    display: none;
}
.route-map {
    margin-top: 20px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    width: 100%;
    /* Tall ratio on mobile to show both map and elevation */
    padding-bottom: 120%;
}
.route-map iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}
@media (min-width: 500px) {
    .route-map {
        /* Square-ish on medium screens */
        padding-bottom: 90%;
    }
}
@media (min-width: 768px) {
    .route-map {
        /* 16:10 aspect ratio on larger screens */
        padding-bottom: 62.5%;
    }
}
/* Progress bar styles */
.progress-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.progress-bar {
    width: 100%;
    height: 24px;
    background: #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 10px;
}
.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 12px;
    transition: width 0.3s ease;
    width: 0%;
}
.progress-text {
    font-size: 0.9em;
    color: #666;
}
.progress-route {
    font-size: 0.85em;
    color: #888;
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Collection table styles */
.collection-rwgps-link {
    margin-top: 10px;
    font-size: 0.85em;
}
.collection-rwgps-link a {
    color: var(--primary);
    text-decoration: none;
}
.collection-rwgps-link a:hover {
    text-decoration: underline;
}
.collection-table {
    width: 100%;
    min-width: 600px;  /* Prevent excessive squishing on mobile */
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 0.85em;
}
.collection-table th {
    background: #f5f5f5;
    padding: 6px 3px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #ddd;
    white-space: nowrap;
}
.collection-table td {
    padding: 5px 3px;
    border-bottom: 1px solid #eee;
}
.collection-table tr:last-child td {
    border-bottom: none;
}
.collection-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.collection-table .u {
    font-size: 0.8em;
    color: #888;
}
.totals-row {
    font-weight: 600;
    background: #f9f9f9;
}
.totals-row td {
    border-top: 2px solid #ddd;
}
.collection-table .primary {
    background: #f0f7ff;
    font-weight: 600;
}
.collection-table th.primary {
    background: #e3effa;
}
.collection-table .separator {
    border-right: 2px solid #ccc;
}
/* Steepness columns: tan treatment matching analysis summary */
.collection-table .steepness {
    background: #fff8f0;
}
.collection-table th.steepness {
    background: #fff0e0;
}
.collection-table th.steepness.sortable:hover {
    background: #f5e6d0;
}
.totals-row .steepness {
    background: #fff3e6;
}
/* Route selection in collections table */
.route-select-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #3b82f6;
    margin: 0;
}
.collection-table .cmp-col {
    padding: 2px 2px 2px 4px;
    text-align: center;
    width: 1%;
    white-space: nowrap;
}
.collection-table .cmp-col input[type="checkbox"] {
    margin: 0;
    vertical-align: middle;
}
.collection-table .type-col {
    padding: 2px 2px;
    text-align: center;
    width: 1%;
    white-space: nowrap;
}
.type-badge {
    display: inline-block;
    width: 15px;
    height: 15px;
    line-height: 15px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    text-align: center;
    color: white;
    vertical-align: middle;
    position: relative;
    cursor: default;
}
.type-badge:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 4px;
    background: rgba(45,48,71,0.92);
    color: white;
    font-size: 11px;
    font-weight: 400;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
}
.type-trip { background: #3b82f6; }
.type-route { background: #f59e0b; }
.collection-table .date-col {
    white-space: nowrap;
}
.collection-table tr.selected-route {
    background-color: #dbeafe !important;
}
.collection-table tr.selected-route:hover {
    background-color: #bfdbfe !important;
}
.collection-table tr.route-saved {
    border-left: 3px solid #2e7d32;
}
.saved-badge {
    color: #2e7d32;
    font-weight: bold;
    flex-shrink: 0;
    cursor: default;
    position: relative;
}
.saved-badge:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    margin-top: 4px;
    background: rgba(45,48,71,0.92);
    color: white;
    font-size: 11px;
    font-weight: 400;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
}
.collection-action-bar {
    display: none;
    padding: 8px 12px;
    background: #f0f9ff;
    border: 1px solid #3b82f6;
    border-radius: 8px;
    margin-bottom: 12px;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
}
.collection-action-bar.visible {
    display: flex;
}
.action-btn {
    padding: 4px 10px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    text-decoration: none;
    display: inline-block;
}
.compare-btn {
    background: #3b82f6;
}
.compare-btn:hover {
    background: #2563eb;
}
.save-btn {
    background: #0d9488;
}
.save-btn:hover {
    background: #0f766e;
}
.save-btn:disabled {
    background: #99d5cf;
    cursor: not-allowed;
}
.delete-action-btn { background: #dc2626; }
.delete-action-btn:hover { background: #b91c1c; }
.action-selection-info {
    color: #1e40af;
    font-size: 13px;
    white-space: nowrap;
}
.save-progress {
    color: #0d9488;
    font-size: 13px;
    white-space: nowrap;
}
.route-name {
    max-width: 280px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.route-name a:first-of-type {
    color: var(--primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.route-name a:first-of-type:hover {
    text-decoration: underline;
}
.route-name .rwgps-link {
    flex-shrink: 0;
    display: inline-block;
    background: #FA6400;
    color: white;
    padding: 1px 4px;
    font-size: 0.65em;
    font-weight: 600;
    text-decoration: none;
    border-radius: 3px;
}
.route-name .rwgps-link:hover {
    background: #e55a00;
}
.route-name .climate-link {
    flex-shrink: 0;
    display: inline-block;
    background: #f59e0b;
    color: white;
    padding: 1px 4px;
    font-size: 0.65em;
    font-weight: 600;
    text-decoration: none;
    border-radius: 3px;
    margin-left: 2px;
    vertical-align: middle;
    position: relative;
}
.route-name .climate-link:hover {
    background: #d97706;
}
.route-name .climate-link:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    margin-top: 4px;
    background: rgba(45,48,71,0.92);
    color: white;
    font-size: 11px;
    font-weight: 400;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
}
/* Sortable table headers */
.collection-table th.sortable {
    cursor: pointer;
    user-select: none;
}
.collection-table th.sortable:hover {
    background: rgba(0,0,0,0.05);
}
.collection-table th .sort-indicator {
    font-size: 0.7em;
    margin-left: 2px;
    opacity: 0.4;
}
.collection-table th.sorted .sort-indicator {
    opacity: 1;
}
@media (min-width: 1200px) {
    .route-name { max-width: 400px; }
    .collection-table { font-size: 0.9em; }
}
@media (max-width: 768px) {
    .route-name { max-width: 200px; }
}
@media (max-width: 600px) {
    .collection-table { font-size: 0.75em; }
    .collection-table th, .collection-table td { padding: 4px 2px; }
    .collection-table .cmp-col { padding: 1px 1px 1px 2px; }
    .collection-table .type-col { padding: 1px 1px; }
    .route-name { max-width: 140px; }
    /* Compact mobile form layout */
    form { padding: 12px; }
    .param-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .param-row > div {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }
    .param-row .label-row {
        flex-shrink: 0;
        min-width: 0;
    }
    .param-row .label-row label {
        font-size: 0.75em;
        margin-top: 0;
        white-space: nowrap;
    }
    .param-row .label-row .info-btn {
        display: none;
    }
    .param-row input[type="number"] {
        width: 70px;
        min-width: 60px;
        padding: 6px 4px;
        font-size: 14px;
        margin-top: 0;
        flex-shrink: 0;
    }
    /* Shorter labels on mobile */
    .param-row label[for="climbing_power"] { font-size: 0; }
    .param-row label[for="climbing_power"]::before { content: "Climb (W)"; font-size: 11px; }
    .param-row label[for="flat_power"] { font-size: 0; }
    .param-row label[for="flat_power"]::before { content: "Flat (W)"; font-size: 11px; }
    .param-row label[for="mass"] { font-size: 0; }
    .param-row label[for="mass"]::before { content: "Mass (kg)"; font-size: 11px; }
    .param-row label[for="headwind"] { font-size: 0; }
    .param-row label[for="headwind"]::before { content: "Wind (km/h)"; font-size: 11px; }
    /* Reduce button margin */
    form > button[type="submit"],
    .analyze-btn { margin-top: 12px; padding: 10px; }
    /* Compact results */
    .results { padding: 12px; margin-top: 12px; }
    /* Compact URL input */
    input[type="text"] { padding: 10px; font-size: 14px; }
    /* Compact file upload */
    .file-drop-zone { padding: 16px; }
    .mode-tab { padding: 5px 12px; font-size: 0.85em; }
    /* Compact compare and advanced rows */
    .compare-toggle { margin-top: 6px; margin-bottom: 4px; }
    .advanced-row { margin-top: 8px; }
    .advanced-toggle { font-size: 0.85em; }
    /* Compact labels */
    label:not(.toggle-label) { margin-top: 8px; font-size: 0.85em; }
    .label-row label { font-size: 0.85em; }
    /* Compact units row */
    .units-row { margin-top: 6px; }
    .units-row span { font-size: 0.85em; }
    /* Compact advanced options */
    .advanced-options { padding: 10px; margin-top: 8px; }
    .advanced-options .param-row label[for="descending_power"] { font-size: 0; }
    .advanced-options .param-row label[for="descending_power"]::before { content: "Desc (W)"; font-size: 11px; }
    .advanced-options .param-row label[for="descent_braking_factor"] { font-size: 0; }
    .advanced-options .param-row label[for="descent_braking_factor"]::before { content: "Braking"; font-size: 11px; }
    .advanced-options .param-row label[for="gravel_grade"] { font-size: 0; }
    .advanced-options .param-row label[for="gravel_grade"]::before { content: "Gravel"; font-size: 11px; }
    .advanced-options .param-row label[for="smoothing"] { font-size: 0; }
    .advanced-options .param-row label[for="smoothing"]::before { content: "Smooth (m)"; font-size: 11px; }
}
.hidden { display: none; }
.back-link {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}
.back-link:hover { text-decoration: underline; }
/* Header styles */
.header-section {
    margin-bottom: 20px;
    text-align: center;
}
.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}
.logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}
.logo {
    width: 48px;
    height: 48px;
}
.header-section h1 {
    margin: 0;
    font-size: 1.4em;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
@media (max-width: 480px) {
    .logo { width: 36px; height: 36px; }
    .header-section { margin-bottom: 10px; }
    .header-section h1 { font-size: 1.1em; }
    .logo-container { margin-bottom: 4px; }
    .logo-link { gap: 8px; }
    .tagline { font-size: 0.75em; }
    .how-link { margin-top: 4px; font-size: 0.8em; }
}
.tagline {
    color: var(--text-muted);
    font-size: 0.9em;
    margin: 0;
    line-height: 1.4;
    text-align: center;
}
.how-link {
    display: inline-block;
    color: var(--primary);
    font-size: 0.85em;
    text-decoration: none;
}
.how-link:hover {
    text-decoration: underline;
}
/* Info button styles */
.label-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.info-btn {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--primary);
    background: white;
    color: var(--primary);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    vertical-align: middle;
}
.info-btn:hover {
    background: var(--primary);
    color: white;
}
.th-with-info, .label-with-info {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    vertical-align: middle;
}
.th-with-info .info-btn, .label-with-info .info-btn {
    margin: 0;
    top: 0;
}
@media (max-width: 600px) {
    .info-btn {
        width: 18px;
        height: 18px;
        min-width: 18px;
        min-height: 18px;
        font-size: 11px;
    }
}
/* Inline tooltip for input fields */
.input-with-tooltip {
    display: flex;
    align-items: center;
    gap: 4px;
}
.input-with-tooltip input {
    flex: 1;
    min-width: 0;
}
.noise-warning-btn {
    background: none;
    border: none;
    color: #F57C00;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    width: 20px;
}
.noise-warning-btn:hover {
    color: #E65100;
}
/* Modal styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active {
    display: flex;
}
.modal {
    background: white;
    border-radius: 12px;
    max-width: 400px;
    width: 100%;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.modal.modal-large {
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}
@media (min-width: 900px) {
    .modal.modal-large {
        max-width: 800px;
    }
}
.modal h4 {
    margin: 16px 0 8px 0;
    font-size: 1em;
    color: #444;
}
.modal h4:first-of-type {
    margin-top: 0;
}
.modal .param-list {
    margin: 0 0 12px 0;
    padding-left: 0;
    list-style: none;
}
.modal .param-list li {
    margin-bottom: 8px;
    padding-left: 16px;
    position: relative;
}
.modal .param-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary);
}
.modal .param-name {
    font-weight: 600;
    color: #333;
}
.modal h3 {
    margin: 0 0 12px 0;
    font-size: 1.1em;
    color: #333;
}
.modal p {
    margin: 0 0 16px 0;
    color: #555;
    font-size: 0.95em;
    line-height: 1.5;
}
.modal-close {
    width: 100%;
    padding: 12px;
    background: #f0f0f0;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    color: #333;
}
.modal-close:hover {
    background: #e0e0e0;
}
/* Units toggle */
.units-row {
    margin-top: 15px;
}
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: normal;
    color: #555;
    margin: 0;
}
.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}
/* Advanced options */
.advanced-row {
    margin-top: 15px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.advanced-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #666;
    font-size: 0.9em;
    user-select: none;
}
.advanced-toggle:hover {
    color: var(--primary);
}
.advanced-toggle .chevron {
    transition: transform 0.2s ease;
    font-size: 0.8em;
}
.advanced-toggle.expanded .chevron {
    transform: rotate(90deg);
}
.advanced-options {
    display: none;
    margin-top: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}
.advanced-options.visible {
    display: block;
}
.advanced-options .param-row {
    margin-top: 0;
}
.advanced-options label {
    font-size: 0.85em;
    margin-top: 10px;
}
.advanced-options label:first-child {
    margin-top: 0;
}
.advanced-options input[type="number"] {
    padding: 8px 10px;
    font-size: 14px;
}
.advanced-options select {
    padding: 8px 10px;
    font-size: 14px;
}
.advanced-reset {
    margin-top: 12px;
    text-align: right;
}
.reset-btn {
    background: none;
    border: 1px solid #ccc;
    color: #666;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    cursor: pointer;
}
.reset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.custom-settings {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid #ccc;
    font-size: 0.85em;
    color: #555;
}
.custom-settings .setting {
    white-space: nowrap;
}
.custom-settings .setting-label {
    color: #888;
}
.custom-settings .setting-value {
    font-weight: 500;
}
.custom-settings .setting.modified .setting-value {
    color: var(--primary);
    font-weight: 600;
}
@media (max-width: 600px) {
    .custom-settings {
        margin-left: 0;
        margin-top: 4px;
        padding-left: 0;
        border-left: none;
        font-size: 0.8em;
        flex-basis: 100%;
        flex-wrap: wrap;
        row-gap: 2px;
    }
    .units-row {
        flex-wrap: wrap;
    }
}
.footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    text-align: center;
    font-size: 0.85em;
    color: #888;
}
.footer a {
    color: var(--primary);
    text-decoration: none;
}
.footer a:hover {
    text-decoration: underline;
}
.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.footer-links {
    display: flex;
    gap: 20px;
}
.footer-version {
    color: #aaa;
    font-size: 0.9em;
}
.footer-copyright {
    color: #aaa;
    font-size: 0.9em;
}
/* Input mode toggle (URL vs Upload) */
.input-mode-toggle {
    display: flex;
    margin-bottom: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    width: fit-content;
}
.mode-tab {
    padding: 6px 16px;
    border: none;
    background: #f5f5f5;
    color: #666;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}
.mode-tab:hover { background: #eee; }
.mode-tab.active {
    background: var(--primary, #FF6B35);
    color: white;
}

/* File drop zone */
.file-drop-zone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.file-drop-zone:hover,
.file-drop-zone.drag-over {
    border-color: var(--primary, #FF6B35);
    background: rgba(255, 107, 53, 0.05);
}
.drop-zone-content { color: #777; }
.drop-zone-content p { margin: 6px 0; }
.drop-zone-content strong { color: var(--primary, #FF6B35); }
.drop-zone-hint { font-size: 0.85em; color: #aaa; }

/* File selected state */
.file-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.file-name {
    font-weight: 500;
    color: #333;
    font-size: 1em;
}
.clear-file-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 1.4em;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.clear-file-btn:hover { color: #c00; }
.file-input-hidden { display: none; }
.file-analyzing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    color: #666;
    font-size: 0.95em;
}

/* File drop zone 2 (compare mode) — smaller variant */
.file-drop-zone-2 {
    padding: 16px;
    margin-top: 4px;
}
.file-drop-zone-2 svg { width: 20px; height: 20px; }
.file-drop-zone-2 p { font-size: 0.9em; margin: 4px 0; }

/* Saved routes picker */
.saved-routes-picker {
    margin-top: 8px;
}
.saved-routes-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #999;
    font-size: 0.85em;
    margin: 8px 0 6px;
}
.saved-routes-divider::before,
.saved-routes-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid #ddd;
}
.saved-routes-picker select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9em;
    background: #fff;
    color: #333;
    cursor: pointer;
}
.saved-routes-picker select:focus {
    border-color: var(--primary, #FF6B35);
    outline: none;
}

.upload-save-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 16px 0;
    font-size: 0.9em;
    color: #2e7d32;
}
.upload-save-banner span { flex: 1; }
.banner-save-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
}
.banner-save-btn:hover { opacity: 0.9; }
.banner-dismiss-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 1.3em;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.banner-dismiss-btn:hover { color: #333; }

.url-input-wrapper {
    position: relative;
    margin-top: 5px;
}
.url-input-wrapper input[type="text"] {
    margin-top: 0;
}
.url-name-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    color: #333;
    cursor: text;
    display: none;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.url-name-overlay.visible {
    display: flex;
}
.url-name-overlay .route-name {
    font-size: 16px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
    max-width: none;
}
.url-name-overlay .route-type {
    color: #888;
    font-size: 13px;
    margin-left: 8px;
    flex-shrink: 0;
}
.recent-urls-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
}
.recent-urls-dropdown.hidden {
    display: none;
}
.recent-url-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.recent-url-item:last-child {
    border-bottom: none;
}
.recent-url-item:hover,
.recent-url-item.highlighted {
    background: #f0f7ff;
}
.recent-urls-header {
    padding: 8px 12px;
    font-size: 12px;
    color: #888;
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
}
.recent-url-name {
    font-weight: 500;
    color: #333;
}
.recent-url-path {
    font-size: 12px;
    color: #888;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Compare mode styles */
.compare-toggle {
    margin-top: 8px;
    margin-bottom: 5px;
}
.compare-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: normal;
    color: #555;
}
.compare-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}
#compareUrlWrapper {
    margin-top: 10px;
}
#compareUrlWrapper.hidden {
    display: none;
}
.compare-label {
    display: block;
    font-size: 0.9em;
    color: #555;
    margin-bottom: 4px;
}
/* Comparison table styles */
.comparison-table-wrapper {
    margin: 20px 0;
    overflow-x: auto;
    max-width: 800px;
}
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}
.comparison-table th,
.comparison-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
.comparison-table th {
    background: #f5f5f5;
    font-weight: 600;
    border-bottom: 8px solid white;
}
.comparison-table td:first-child {
    white-space: nowrap;
    padding-right: 3%;
}
@media (max-width: 700px) {
    .comparison-table td:first-child {
        white-space: normal;
    }
}
.comparison-table .route-col {
    text-align: right;
    min-width: 100px;
}
.comparison-table .diff-col {
    text-align: right;
    color: #666;
    font-size: 0.9em;
    min-width: 80px;
}
.comparison-table tr.primary {
    background: #f0f7ff;
}
.comparison-table tr.primary td {
    font-weight: 600;
}
.comparison-table tr.steepness {
    background: #fff8f0;
}
.comparison-table tr.steepness td {
    font-weight: 600;
}
.comparison-table tr.group-spacer td {
    padding: 6px 0;
    border-bottom: none;
    background: transparent;
}
.comparison-table tr.group-spacer td hr {
    border: none;
    border-top: 2px solid #ccc;
    margin: 0;
}
.est-marker {
    color: #999;
    font-size: 0.85em;
    font-weight: normal;
    cursor: help;
}
.comparison-footnote {
    font-size: 0.8em;
    color: #888;
    margin-top: 8px;
    font-style: italic;
}
/* Steep comparison table - match steep-section background, grey separator */
.steep-comparison-table th {
    background: transparent;
    border-bottom: 2px solid #ccc;
}
.steep-comparison-table th:not(:first-child) {
    min-width: 120px;
}
.steep-comparison-table th:first-child,
.steep-comparison-table td:first-child {
    white-space: nowrap;
}
@media (max-width: 600px) {
    .steep-comparison-table th:not(:first-child) {
        min-width: auto;
    }
    .steep-comparison-table th:first-child {
        width: auto;
    }
    .steep-comparison-table th .result-badge {
        display: block;
        margin-top: 4px;
    }
}
/* Comparison histograms */
.histogram-bars.comparison-mode {
    gap: 12px;  /* spacing between grade bins */
}
.histogram-bars.comparison-mode .histogram-bar {
    flex: 1;
    min-width: 0;
}
.histogram-bars.comparison-mode .bar-container {
    display: flex;
    gap: 2px;
    align-items: flex-end;
}
.histogram-bars.comparison-mode .bar {
    flex: 1;
}
.histogram-bars.comparison-mode .bar.route2 {
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        rgba(255,255,255,0.4) 2px,
        rgba(255,255,255,0.4) 4px
    ) !important;
}
/* Histogram tooltip */
.bar-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.bar-tooltip .tooltip-title {
    font-weight: 600;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.3);
    padding-bottom: 4px;
}
.bar-tooltip .tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.bar-tooltip .tooltip-label {
    color: #aaa;
}
.histogram-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    font-size: 0.8em;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}
.legend-color.striped {
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        rgba(255,255,255,0.4) 2px,
        rgba(255,255,255,0.4) 4px
    );
}
/* Chart type toggle (Bars / Donut) */
.chart-toggle-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 2px;
}
.chart-type-toggle {
    display: flex;
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    width: fit-content;
}
.chart-toggle-btn {
    padding: 5px 14px;
    border: none;
    background: #f5f5f5;
    color: #666;
    cursor: pointer;
    font-size: 0.82em;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}
.chart-toggle-btn:hover { background: #eee; }
.chart-toggle-btn.active {
    background: var(--primary);
    color: white;
}
/* Donut chart styles */
.grade-donut {
    flex: 1;
    padding: 4px 4px 2px 4px;
    background: #f9f9f9;
    border-radius: 6px;
    text-align: center;
    overflow: visible;
}
.grade-donut h4 {
    margin: 0 0 2px 0;
    font-size: 0.9em;
    color: #555;
}
.donut-svg {
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    overflow: visible;
}
.donut-slice {
    transition: opacity 0.15s;
}
.donut-slice:hover {
    opacity: 0.8;
}
.donut-slice-clickable {
    cursor: pointer;
    stroke-dasharray: 4 2;
}
.donut-slice-clickable:hover {
    opacity: 0.75;
    filter: brightness(1.1);
}
.donut-label {
    font-size: 11px;
    fill: #444;
    pointer-events: none;
}
.donut-pct {
    font-size: 10px;
    fill: #fff;
    pointer-events: none;
    font-weight: 600;
}
.donut-center-name {
    font-size: 12px;
    fill: #555;
    font-weight: 600;
}
.donut-center-value {
    font-size: 11px;
    fill: #888;
}
.donut-hint {
    font-size: 0.75em;
    font-style: italic;
    color: #999;
    margin-top: 6px;
}
.donut-legend {
    font-size: 0.8em;
    color: #666;
    margin-top: 2px;
    text-align: center;
}
.donut-legend-item {
    display: inline-block;
    margin: 0 8px;
}
.donut-legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.donut-range-label {
    font-size: 8px;
    fill: #333;
    stroke: white;
    stroke-width: 2px;
    paint-order: stroke fill;
    pointer-events: none;
}
.donut-leader {
    stroke: #999;
    stroke-width: 0.7;
}
.donut-nested-name {
    font-size: 9px;
    fill: #666;
}
@media (max-width: 600px) {
    .donut-label { font-size: 9px; }
    .donut-pct { font-size: 8px; }
    .donut-center-name { font-size: 10px; }
    .donut-center-value { font-size: 9px; }
    .donut-range-label { font-size: 7px; }
    .donut-nested-name { font-size: 6px; }
}
/* Stacked elevation profiles (comparison mode) */
.elevation-profiles-stacked .elevation-profile {
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 10px;
}
.elevation-profiles-stacked .elevation-profile:last-child {
    margin-bottom: 0;
}
.elevation-profiles-stacked .elevation-canvas {
    height: 300px;
}
.elevation-profiles-stacked .elevation-profile-header {
    margin-bottom: 6px;
}
/* Side-by-side RWGPS embeds */
.route-maps-comparison {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}
.route-maps-comparison .route-map {
    flex: 1;
}
.route-maps-comparison .route-map h4 {
    margin: 0 0 10px 0;
    font-size: 0.9em;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 768px) {
    .route-maps-comparison {
        flex-direction: column;
    }
}

/* PWA - Service Worker Update Notification */
.sw-update-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    font-size: 0.9em;
}
.sw-update-notification button {
    background: white;
    color: var(--accent);
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}
.sw-update-notification button:hover {
    background: #f0f0f0;
}

/* PWA - Offline Banner */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff9800;
    color: white;
    text-align: center;
    padding: 8px 12px;
    font-size: 0.85em;
    z-index: 10001;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}
.offline-banner-link {
    color: white;
    text-decoration: underline;
    font-weight: 500;
}
body.offline {
    padding-top: 40px;
}

/* PWA - Save for Offline Button */
.save-offline-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f0f0f0;
    border: 1.5px solid #ddd;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    transition: all 0.2s;
    height: 28px;
    box-sizing: border-box;
    width: auto;
    margin: 0;
}
.save-offline-btn:hover {
    background: #e8e8e8;
    border-color: #ccc;
}
.save-offline-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}
.save-offline-btn.saved {
    background: #e8f5e9;
    border-color: #a5d6a7;
    color: #2e7d32;
}
.save-offline-btn.saved .save-icon,
.save-offline-btn.saved .save-text {
    display: none;
}
.save-offline-btn.saved .saved-icon,
.save-offline-btn.saved .saved-text {
    display: inline !important;
}
.save-offline-btn.saving {
    opacity: 0.7;
    cursor: wait;
}
.save-offline-btn.saving .save-text::after {
    content: '...';
}

/* Header Links Container */
.header-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Saved Routes Link in Header */
.saved-routes-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85em;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}
.saved-routes-link:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-dark);
}
.saved-routes-link svg {
    opacity: 0.7;
}
.saved-routes-link .count-badge {
    background: var(--primary);
    color: white;
    font-size: 0.75em;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}
/* Saved Routes Page Styles */
.saved-routes-page {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.saved-routes-page h2 {
    margin-top: 0;
    color: var(--accent);
}
.storage-stats {
    background: #f5f5f7;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.storage-stats p {
    margin: 0 0 8px 0;
    font-size: 0.9em;
    color: var(--text-muted);
}
.storage-bar {
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    overflow: hidden;
}
.storage-used {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
}
.storage-used.has-usage {
    min-width: 6px;
}
.storage-used.warning {
    background: #ff9800;
}
.storage-used.critical {
    background: #f44336;
}
.saved-routes-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.saved-route-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}
.saved-route-item:last-child {
    border-bottom: none;
}
.saved-routes-page .route-info {
    flex: 1;
    min-width: 0;
}
.saved-routes-page .route-name a:first-of-type {
    color: var(--primary);
    text-decoration: none;
}
.saved-routes-page .route-name a:first-of-type:hover {
    text-decoration: underline;
}
.route-meta {
    display: block;
    font-size: 0.8em;
    color: var(--text-muted);
    white-space: nowrap;
}
.delete-btn {
    width: auto !important;
    padding: 8px 16px !important;
    margin: 0 !important;
    margin-left: 16px !important;
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    color: #666 !important;
    border-radius: 4px !important;
    cursor: pointer;
    font-size: 0.85em !important;
    flex-shrink: 0;
}
.delete-btn:hover {
    background: #fee !important;
    border-color: #f99 !important;
    color: #c00 !important;
}
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state p {
    margin: 8px 0;
}
.empty-state a {
    color: var(--primary);
}
.clear-all-btn {
    width: auto !important;
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    color: #666 !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    cursor: pointer;
    font-size: 0.85em !important;
    margin-top: 16px !important;
}
.clear-all-btn:hover {
    background: #fee !important;
    border-color: #f99;
    color: #c00;
}
.saved-routes-page .loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}