/* =============================================================================
   VertHurt — App Page Styles (app.html)
   Requires: verthurt.css, components.css loaded first
============================================================================= */

  /* App container overrides */
  .container {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--space-5) var(--space-5);
    transition: max-width 0.3s ease;
  }
  .container.has-sidebar {
    max-width: 1240px;
  }

  .logo-container {
    margin-bottom: var(--space-2);
  }
  .site-logo {
    height: 72px;
    width: auto;
  }

  h1 {
    font-size: var(--text-h1);
    font-weight: 800;
    color: var(--color-forest-text);
    margin-bottom: var(--space-2);
  }

  .subtitle {
    display: none; /* moved into dropzone */
  }

  /* Drop zone — app-specific overrides */
  .dropzone {
    border: 2px dashed var(--color-border-medium);
    border-radius: var(--radius-md);
    padding: var(--space-7) var(--space-5);
    text-align: center;
    cursor: pointer;
    transition: all 0.8s ease;
    background: var(--color-white);
    margin-bottom: var(--space-4);
    overflow: hidden;
  }
  .dropzone.compact {
    padding: var(--space-4) var(--space-5);
    transition: all 0.8s ease;
  }
  .dropzone.compact .dropzone-icon {
    opacity: 0;
    max-height: 0;
    margin: 0;
    transition: all 0.5s ease;
    overflow: hidden;
  }
  .dropzone.compact .dropzone-subtitle {
    opacity: 0;
    max-height: 0;
    transition: all 0.5s ease;
    overflow: hidden;
  }
  .dropzone:hover, .dropzone.dragover {
    border-color: var(--color-forest);
    background: #F0F7F0;
  }
  .dropzone-icon {
    font-size: 2rem;
    margin-bottom: var(--space-2);
    color: var(--color-green-500);
    transition: all 0.4s ease;
  }
  .dropzone-text {
    font-size: var(--text-body);
    color: var(--color-green-500);
    transition: all 0.4s ease;
  }
  .dropzone-text strong {
    color: var(--color-forest);
  }
  .dropzone-subtitle {
    font-size: var(--text-body-sm);
    color: var(--color-green-500);
    margin-top: var(--space-1);
    transition: all 0.4s ease;
  }

  /* Loaded files */
  .loaded-files {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
  }
  .file-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-body-sm);
    color: var(--color-forest-text);
    font-weight: 600;
  }
  .file-chip .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--color-flat);
  }
  .file-chip .remove {
    cursor: pointer;
    color: var(--color-green-500);
    font-size: 16px;
    line-height: 1;
    margin-left: var(--space-1);
  }
  .file-chip .remove:hover { color: var(--color-danger); }

  /* Results section */
  .results-section { display: none; }
  .results-section.visible {
    display: block;
    animation: slideUp 0.5s ease;
  }

  /* Comparison layout */
  .comparison {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
  }
  @media (min-width: 640px) {
    .comparison {
      grid-template-columns: 1fr 1fr;
    }
    .comparison.single {
      grid-template-columns: 1fr;
    }
  }

  /* Score card */
  .score-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
    position: relative;
  }
  .score-card-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: var(--color-green-500);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    transition: opacity var(--transition-base), background var(--transition-base);
  }
  .score-card-close:hover {
    opacity: 1;
    background: var(--color-border-light);
  }
  .score-card:hover {
    box-shadow: var(--shadow-md);
  }
  .score-card-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
  }
  .score-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-3);
  }
  .route-name {
    font-size: var(--text-h4);
    font-weight: 700;
    color: var(--color-forest-text);
  }
  .route-meta {
    font-size: var(--text-caption);
    color: var(--color-green-500);
    margin-top: 2px;
  }

  .big-score {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: var(--space-1);
  }
  .score-label {
    font-size: var(--text-caption);
    font-weight: 800;
    color: var(--color-green-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .score-descriptor {
    font-size: var(--text-body-sm);
    font-weight: 600;
    margin-top: 2px;
  }

  /* Component scores */
  .component-scores {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: var(--space-4);
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border-light);
  }
  .component {
    text-align: center;
  }
  .component-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-forest-text);
  }
  .component-label {
    font-size: var(--text-label);
    color: var(--color-green-500);
    margin-top: 2px;
  }

  /* Stats grid */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-light);
  }
  .stat-item {
    display: flex;
    flex-direction: column;
  }
  .stat-value {
    font-size: var(--text-body);
    font-weight: 700;
    color: var(--color-forest-text);
  }
  .stat-label {
    font-size: var(--text-label);
    color: var(--color-green-500);
  }

  /* Gradient distribution bar */
  .gradient-bar-container {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-light);
  }
  .gradient-bar-label {
    font-size: var(--text-label);
    font-weight: 600;
    color: var(--color-green-500);
    margin-bottom: var(--space-2);
  }
  .gradient-bar {
    display: flex;
    height: 24px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--color-card-bg);
  }
  .gradient-bar .segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: white;
    min-width: 0;
    transition: width 0.4s ease;
  }
  .gradient-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-2);
  }
  .legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-label);
    color: var(--color-green-500);
  }
  .legend-dot {
    width: 10px; height: 10px;
    border-radius: 3px;
  }

  /* Elevation profile */
  .profile-section {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-5);
  }
  .profile-title {
    font-size: var(--text-body);
    font-weight: 700;
    color: var(--color-forest-text);
    margin-bottom: var(--space-4);
  }
  .profile-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 220px;
  }
  .profile-canvas-wrapper canvas {
    width: 100%;
    height: 100%;
  }

  /* Methodology section */
  .methodology {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    margin-top: var(--space-6);
  }
  .methodology summary {
    font-size: var(--text-body);
    font-weight: 700;
    color: var(--color-forest-text);
    cursor: pointer;
    padding: var(--space-1) 0;
  }
  .methodology-content {
    margin-top: var(--space-4);
    font-size: var(--text-body-sm);
    color: var(--color-green-500);
    line-height: 1.7;
  }
  .methodology-content h4 {
    font-size: var(--text-body-sm);
    font-weight: 700;
    color: var(--color-forest-text);
    margin-top: var(--space-4);
    margin-bottom: var(--space-1);
  }
  .formula {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: var(--space-3) var(--space-4);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: var(--text-caption);
    color: var(--color-forest-text);
    margin: var(--space-2) 0;
    overflow-x: auto;
  }

  /* ── Explainer (scoped under .explainer-wrap) ── */
  .explainer-wrap {
    overflow: hidden;
  }
  .explainer-wrap .hero {
    background: linear-gradient(180deg, #c9e8f7 0%, #ddf0e8 60%, #b8d9a0 100%);
    padding: var(--space-6) var(--space-5) 0;
    text-align: center;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .explainer-wrap .hero-tag {
    display: inline-block;
    background: var(--color-accent-blue);
    color: white;
    font-size: var(--text-caption);
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 5px 14px;
    border-radius: var(--radius-pill);
    margin-bottom: var(--space-4);
  }
  .explainer-wrap .hero h1 {
    font-size: clamp(32px, 6vw, 56px);
    font-weight: 800;
    color: var(--color-forest-text);
    line-height: 1.05;
  }
  .explainer-wrap .hero h1 em {
    color: var(--color-hilly);
    font-style: normal;
  }
  .explainer-wrap .hero-sub {
    max-width: 520px;
    margin: var(--space-3) auto 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-green-500);
    line-height: 1.6;
  }
  .explainer-wrap .scene-wrap {
    margin-top: var(--space-5);
    position: relative;
    height: 140px;
  }
  .explainer-wrap .scene-wrap svg { width: 100%; height: 100%; }

  .explainer-wrap details > summary {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-forest-text);
    cursor: pointer;
    padding: 14px var(--space-5);
    background: #f0f7ff;
    border-top: 1px solid var(--color-border-light);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
  }
  .explainer-wrap details > summary::-webkit-details-marker { display: none; }
  .explainer-wrap details > summary::after {
    content: '\25BC';
    font-size: 0.7em;
    transition: transform var(--transition-base);
  }
  .explainer-wrap details[open] > summary::after {
    transform: rotate(180deg);
  }

  .explainer-wrap .explainer-body {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 var(--space-5) 40px;
    background: var(--color-page-bg);
  }

  .explainer-wrap .question-block {
    background: var(--color-forest-text);
    color: white;
    border-radius: var(--radius-xl);
    padding: 28px var(--space-6);
    margin-top: var(--space-6);
    text-align: center;
    position: relative;
    overflow: hidden;
  }
  .explainer-wrap .question-block::before {
    content: '?';
    position: absolute;
    right: -20px; top: -30px;
    font-size: 200px;
    font-weight: 800;
    color: rgba(255,255,255,0.04);
    line-height: 1;
    pointer-events: none;
  }
  .explainer-wrap .question-block h2 {
    font-size: 26px;
    font-weight: 800;
    color: white;
    margin-bottom: var(--space-2);
  }
  .explainer-wrap .question-block p {
    font-size: 15px;
    color: rgba(255,255,255,0.7);
    font-weight: 600;
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.6;
  }

  .explainer-wrap .factors-label {
    text-align: center;
    margin-top: 40px;
    margin-bottom: var(--space-2);
    font-size: var(--text-label);
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--color-green-500);
  }
  .explainer-wrap .factors-title {
    text-align: center;
    font-size: var(--text-h2);
    font-weight: 800;
    color: var(--color-forest-text);
    margin-bottom: var(--space-5);
  }
  .explainer-wrap .factors-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
  }
  .explainer-wrap .factor-card {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    padding: var(--space-5) 20px;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
  }
  .explainer-wrap .factor-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
  }
  .explainer-wrap .factor-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
    font-size: 30px;
  }
  .explainer-wrap .factor-card:nth-child(1) .factor-icon { background: #e8f5e9; }
  .explainer-wrap .factor-card:nth-child(2) .factor-icon { background: #fff3e0; }
  .explainer-wrap .factor-card:nth-child(3) .factor-icon { background: #fce4ec; }
  .explainer-wrap .factor-name {
    font-size: var(--text-h4);
    font-weight: 800;
    color: var(--color-forest-text);
    margin-bottom: 6px;
    display: block;
  }
  .explainer-wrap .factor-desc {
    font-size: var(--text-caption);
    font-weight: 600;
    color: var(--color-green-500);
    line-height: 1.65;
  }
  .explainer-wrap .factor-illustration {
    margin-top: var(--space-4);
    width: 100%;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--color-card-bg);
  }
  .explainer-wrap .factor-illustration svg { width: 100%; height: 100%; }

  .explainer-wrap .cleanup-block {
    margin-top: 36px;
    background: #f0f7ff;
    border-radius: var(--radius-xl);
    padding: 28px var(--space-6);
    display: flex;
    align-items: flex-start;
    gap: 20px;
    box-shadow: 0 2px 12px rgba(58,134,255,0.08);
  }
  .explainer-wrap .cleanup-icon { font-size: 40px; flex-shrink: 0; line-height: 1; }
  .explainer-wrap .cleanup-text h3 {
    font-size: 20px;
    font-weight: 800;
    color: var(--color-accent-blue);
    margin-bottom: 6px;
  }
  .explainer-wrap .cleanup-text p {
    font-size: var(--text-caption);
    font-weight: 600;
    color: #4a6080;
    line-height: 1.7;
  }
  .explainer-wrap .cleanup-pills {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-top: var(--space-3);
  }
  .explainer-wrap .pill {
    background: white;
    border: 2px solid #c8ddf7;
    color: var(--color-accent-blue);
    font-size: var(--text-label);
    font-weight: 800;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
  }

  .explainer-wrap .spectrum-section { margin-top: 40px; }
  .explainer-wrap .spectrum-section .factors-label { margin-top: 0; }
  .explainer-wrap .spectrum-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
  }
  .explainer-wrap .scard {
    border-radius: var(--radius-lg);
    padding: 18px 14px;
    color: white;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-base);
  }
  .explainer-wrap .scard:hover { transform: scale(1.03); }
  .explainer-wrap .scard::after {
    content: '';
    position: absolute;
    bottom: -20px; right: -20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    pointer-events: none;
  }
  .explainer-wrap .scard-range {
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
    display: block;
    margin-bottom: var(--space-1);
  }
  .explainer-wrap .scard-name {
    font-size: var(--text-label);
    font-weight: 800;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: var(--space-2);
    opacity: 0.9;
  }
  .explainer-wrap .scard-desc {
    font-size: var(--text-caption);
    font-weight: 600;
    opacity: 0.8;
    line-height: 1.5;
  }
  .explainer-wrap .scard-emoji { font-size: 24px; display: block; margin-bottom: 6px; }
  .explainer-wrap .scard:nth-child(1) { background: linear-gradient(135deg, var(--color-flat), #40916c); }
  .explainer-wrap .scard:nth-child(2) { background: linear-gradient(135deg, var(--color-rolling), var(--color-hilly)); }
  .explainer-wrap .scard:nth-child(3) { background: linear-gradient(135deg, var(--color-hilly), var(--color-mountainous)); }
  .explainer-wrap .scard:nth-child(4) { background: linear-gradient(135deg, var(--color-mountainous), #7b0000); }

  .explainer-wrap .bottom-callout {
    margin-top: 36px;
    background: linear-gradient(135deg, var(--color-forest-text), #3d5c3a);
    border-radius: var(--radius-xl);
    padding: var(--space-6) 36px;
    text-align: center;
    color: white;
  }
  .explainer-wrap .bottom-callout .big-num {
    font-size: 56px;
    font-weight: 800;
    line-height: 1;
    color: var(--color-sun-gold);
  }
  .explainer-wrap .bottom-callout p {
    font-size: 15px;
    font-weight: 700;
    color: rgba(255,255,255,0.75);
    max-width: 420px;
    margin: 10px auto 0;
    line-height: 1.6;
  }
  .explainer-wrap .score-bar-outer {
    max-width: 500px;
    margin: 20px auto 0;
    height: 18px;
    border-radius: 10px;
    background: rgba(255,255,255,0.15);
    overflow: hidden;
  }
  .explainer-wrap .score-bar-inner {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(to right, var(--color-flat), var(--color-rolling), var(--color-hilly), var(--color-mountainous));
    width: 100%;
  }
  .explainer-wrap .score-bar-labels {
    max-width: 500px;
    margin: 6px auto 0;
    display: flex;
    justify-content: space-between;
    font-size: var(--text-caption);
    font-weight: 800;
    color: rgba(255,255,255,0.5);
  }

  @media (max-width: 680px) {
    .explainer-wrap .factors-grid { grid-template-columns: 1fr; }
    .explainer-wrap .spectrum-cards { grid-template-columns: 1fr 1fr; }
    .explainer-wrap .cleanup-block { flex-direction: column; }
    .explainer-wrap .hero h1 { font-size: 32px; }
  }

  /* ── Explainer dark mode overrides ── */
  [data-theme="dark"] .explainer-wrap .hero {
    background: linear-gradient(180deg, #1a3a2a 0%, #1e3320 60%, #243625 100%);
  }
  [data-theme="dark"] .explainer-wrap .hero h1 {
    color: #E8EDE5;
  }
  [data-theme="dark"] .explainer-wrap .hero-sub {
    color: #9AB494;
  }
  [data-theme="dark"] .explainer-wrap .explainer-body {
    background: var(--color-page-bg);
  }
  [data-theme="dark"] .explainer-wrap .factor-card {
    background: var(--color-card-bg);
  }
  [data-theme="dark"] .explainer-wrap .factor-card:nth-child(1) .factor-icon { background: #1a3a2a; }
  [data-theme="dark"] .explainer-wrap .factor-card:nth-child(2) .factor-icon { background: #3a2a1a; }
  [data-theme="dark"] .explainer-wrap .factor-card:nth-child(3) .factor-icon { background: #3a1a2a; }
  [data-theme="dark"] .explainer-wrap .factors-title {
    color: #E8EDE5;
  }
  [data-theme="dark"] .explainer-wrap .factor-name {
    color: #E8EDE5;
  }
  [data-theme="dark"] .explainer-wrap .question-block {
    background: #1C5C1E;
  }
  [data-theme="dark"] .explainer-wrap .question-block h2 {
    color: white;
  }
  [data-theme="dark"] .explainer-wrap .question-block p {
    color: rgba(255,255,255,0.7);
  }
  [data-theme="dark"] .explainer-wrap .factors-label {
    color: #9AB494;
  }
  [data-theme="dark"] .explainer-wrap .factor-desc {
    color: #9AB494;
  }
  [data-theme="dark"] .explainer-wrap .factor-illustration {
    background: #1a3a2a;
  }
  [data-theme="dark"] .explainer-wrap .cleanup-block {
    background: #1a2a3a;
  }
  [data-theme="dark"] .explainer-wrap .cleanup-text p {
    color: #9AB494;
  }
  [data-theme="dark"] .explainer-wrap .pill {
    background: var(--color-card-bg);
    border-color: #3D5C3A;
    color: var(--color-accent-blue);
  }
  [data-theme="dark"] .explainer-wrap details > summary {
    color: #E8EDE5;
    background: var(--color-card-bg);
  }
  [data-theme="dark"] .explainer-wrap .bottom-callout {
    background: linear-gradient(135deg, #1C5C1E, #3d5c3a);
  }

  /* Color scale for scores — brand hilliness spectrum */
  .score-flat { color: var(--color-flat); }
  .score-rolling { color: var(--color-rolling); }
  .score-hilly { color: var(--color-hilly); }
  .score-mountainous { color: var(--color-mountainous); }

  /* Thumbnail elevation profile in card */
  .thumb-profile {
    height: 48px;
    position: relative;
  }
  .thumb-profile canvas {
    width: 100%;
    height: 100%;
    display: block;
  }

  /* Navigation bar — app-specific */
  .navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
  }
  .nav-auth {
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }
  .strava-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--color-strava);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-body-sm);
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-base);
  }
  .strava-btn:hover { background: #E34402; }
  .strava-btn svg { width: 18px; height: 18px; }
  .signin-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-sun-gold);
    color: var(--color-forest-text);
    border: none;
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-body-sm);
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-base);
  }
  .signin-btn:hover { background: #E5B83D; }
  .dark-mode-toggle {
    font-size: 18px;
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    line-height: 1;
  }
  /* Magic link email form */
  .magic-link-form {
    display: flex;
    gap: var(--space-2);
    width: 100%;
  }
  .magic-link-form input[type="email"] {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--color-border-medium);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: var(--font-family);
    outline: none;
    transition: border-color var(--transition-base);
  }
  .magic-link-form input[type="email"]:focus {
    border-color: var(--color-forest);
    box-shadow: 0 0 0 3px rgba(28,92,30,0.1);
  }
  .magic-link-form button {
    padding: 10px 20px;
    background: var(--color-sun-gold);
    color: var(--color-forest-text);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: var(--font-family);
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition-base);
  }
  .magic-link-form button:hover { background: #E5B83D; }
  .magic-link-form button:disabled { background: var(--color-disabled-bg); color: var(--color-disabled-text); cursor: not-allowed; }
  .magic-link-sent {
    color: var(--color-flat);
    font-size: var(--text-body-sm);
    font-weight: 600;
    padding: var(--space-2) 0;
  }
  .user-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-body-sm);
    color: var(--color-forest-text);
  }
  .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
  }
  .user-name { font-weight: 600; }
  .logout-btn {
    background: none;
    border: 1px solid var(--color-border-medium);
    border-radius: var(--radius-sm);
    padding: var(--space-1) 10px;
    font-size: var(--text-label);
    font-family: var(--font-family);
    color: var(--color-green-500);
    cursor: pointer;
  }
  .logout-btn:hover { background: var(--color-card-bg); }

  /* Gate modal — app-specific */
  .modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--color-overlay);
    z-index: 100;
    justify-content: center;
    align-items: center;
  }
  .modal-overlay.visible {
    display: flex;
  }
  .modal {
    background: #FFFFFF;
    color: #1B4332;
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-xl);
  }
  .modal h2 {
    font-size: var(--text-h2);
    font-weight: 800;
    color: #1B4332;
    margin-bottom: var(--space-2);
  }
  .modal p {
    font-size: 0.9375rem;
    color: #4A6B48;
    margin-bottom: var(--space-5);
    line-height: 1.5;
  }
  .modal .strava-btn {
    font-size: var(--text-body);
    padding: var(--space-3) var(--space-6);
    width: 100%;
    justify-content: center;
  }
  .modal .magic-link-form {
    flex-direction: column;
    gap: 10px;
  }
  .modal .magic-link-form input[type="email"] {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-body);
  }
  .modal .magic-link-form button {
    width: 100%;
    padding: var(--space-3);
    font-size: var(--text-body);
  }
  .modal .value-props {
    text-align: left;
    margin-bottom: var(--space-5);
  }
  .modal .value-props li {
    font-size: var(--text-body-sm);
    color: var(--color-forest-text);
    margin-bottom: var(--space-2);
    list-style: none;
    padding-left: var(--space-5);
    position: relative;
  }
  .modal .value-props li::before {
    content: '\2713';
    position: absolute;
    left: 0;
    color: var(--color-flat);
    font-weight: 700;
  }
  .modal-close {
    display: block;
    margin-top: var(--space-4);
    font-size: var(--text-caption);
    color: var(--color-green-500);
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font-family);
  }
  .modal-close:hover { color: #1B4332; }
  .modal .value-props li { color: #1B4332; }
  .modal .input,
  .modal input[type="text"],
  .modal input[type="email"] {
    background: #FFFFFF;
    color: #1B4332;
    border-color: #C8D0C4;
  }
  .modal .modal-header { border-bottom-color: #E0E0E0; }
  .modal .modal-header h2 { color: #1B4332; font-size: var(--text-h4); }
  .modal .modal-footer { background: #F3F4F1; border-top-color: #E0E0E0; }
  .modal .btn-close { color: #1B4332; }

  /* Loading overlay */
  .loading-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(232,244,253,0.7);
    z-index: 200;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
  }
  .loading-overlay.visible { display: flex; }
  .loading-content {
    text-align: center;
    animation: slideUp 0.3s ease;
  }
  .loading-mountain {
    margin-bottom: var(--space-5);
  }
  .mountain-path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: drawMountain 2s ease forwards;
  }
  @keyframes drawMountain {
    to { stroke-dashoffset: 0; }
  }
  .mountain-fill {
    animation: fillMountain 1s ease 1.5s forwards;
  }
  @keyframes fillMountain {
    to { opacity: 1; }
  }
  .loading-text {
    font-size: var(--text-h3);
    font-weight: 800;
    color: var(--color-forest-text);
    margin-bottom: var(--space-2);
  }
  .loading-subtext {
    font-size: var(--text-body-sm);
    color: var(--color-green-500);
    animation: pulse 2s ease-in-out infinite;
  }
  @keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
  }

  /* Save/Share buttons on score card */
  .card-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-light);
  }
  .btn-save, .btn-share {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    font-size: var(--text-caption);
    font-weight: 700;
    cursor: pointer;
    border: none;
    font-family: var(--font-family);
    transition: all var(--transition-base);
  }
  .btn-save { background: var(--color-forest); color: white; }
  .btn-save:hover { background: #165018; }
  .btn-save.saved { background: var(--color-disabled-bg); color: var(--color-green-500); cursor: default; }
  .btn-delete-saved {
    background: none; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    padding: 6px var(--space-2); cursor: pointer; color: var(--color-green-500); display: inline-flex;
    align-items: center; justify-content: center; transition: all var(--transition-fast);
  }
  .btn-delete-saved:hover { color: var(--color-danger); border-color: #FCA5A5; background: #FEF2F2; }
  .btn-share { background: var(--color-sun-gold); color: var(--color-forest-text); }
  .btn-share:hover { background: #E5B83D; }

  /* Tabs */
  .tabs-row {
    display: flex;
    align-items: center;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: var(--space-4);
  }
  .tabs {
    display: flex;
    gap: 0;
  }
  .tab {
    padding: 10px 20px;
    font-size: var(--text-body);
    font-weight: 700;
    color: var(--color-green-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    background: none;
    border-top: none; border-left: none; border-right: none;
    font-family: var(--font-family);
  }
  .tab.active { color: var(--color-forest); border-bottom-color: var(--color-sun-gold); }
  .tab:hover:not(.active) { color: var(--color-forest-text); }

  /* My Routes */
  .my-routes-section { display: none; }
  .my-routes-section.visible { display: block; }
  .routes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
  }
  .route-card {
    background: var(--color-white);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: box-shadow var(--transition-base), transform var(--transition-base);
  }
  .route-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
  }
  .route-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }
  .route-card .route-name { font-size: 0.9375rem; font-weight: 700; }
  .route-card .route-meta { font-size: var(--text-label); color: var(--color-green-500); }
  .route-card .mini-score { font-size: 1.75rem; font-weight: 800; line-height: 1; }
  .route-card .mini-descriptor { font-size: var(--text-caption); font-weight: 600; }
  .route-card-stats {
    display: flex;
    gap: var(--space-4);
    font-size: var(--text-label);
    color: var(--color-green-500);
    margin-top: var(--space-2);
  }
  .route-card-stats span { font-weight: 700; color: var(--color-forest-text); }
  .route-card .delete-btn {
    background: none; border: none; color: var(--color-green-500);
    cursor: pointer; padding: var(--space-1); border-radius: var(--space-1);
    position: absolute; bottom: 10px; right: 10px;
    display: flex; align-items: center; justify-content: center;
  }
  .route-card .delete-btn:hover { color: var(--color-danger); background: #FEE2E2; }
  .route-card { position: relative; }
  .edit-name-btn {
    background: none; border: none; color: var(--color-green-500);
    cursor: pointer; padding: var(--space-1); border-radius: var(--space-1);
    display: flex; align-items: center; justify-content: center;
    opacity: 0.5; transition: opacity 0.15s;
  }
  .edit-name-btn:hover { opacity: 1; color: var(--color-forest-text); }
  .sidebar-route-item .edit-name-btn { margin-left: auto; flex-shrink: 0; }
  .route-card .card-edit-btn { position: absolute; bottom: 10px; right: 36px; }
  .empty-routes {
    text-align: center; padding: var(--space-7) var(--space-5); color: var(--color-green-500);
  }

  /* Sort controls */
  .sort-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
  }
  .sort-bar label {
    font-size: var(--text-label);
    font-weight: 700;
    color: var(--color-green-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .sort-bar select,
  .sidebar-sort {
    appearance: none;
    -webkit-appearance: none;
    background: var(--color-white);
    color: var(--color-forest-text);
    border: 1px solid var(--color-green-200, #C6D9C7);
    border-radius: var(--radius-sm);
    padding: var(--space-1) var(--space-5) var(--space-1) var(--space-2);
    font-size: var(--text-label);
    font-family: inherit;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236B7280'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
  }
  [data-theme="dark"] .sort-bar select,
  [data-theme="dark"] .sidebar-sort {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23E8EDE5'/%3E%3C/svg%3E");
  }
  .sort-bar select:focus,
  .sidebar-sort:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--color-forest);
  }
  .sidebar-sort {
    width: 100%;
    margin-bottom: var(--space-2);
    font-size: var(--text-caption);
    padding: 4px var(--space-5) 4px var(--space-2);
  }

  /* Score tab layout with sidebar */
  .score-tab-layout {
    display: flex;
    gap: var(--space-5);
    align-items: flex-start;
  }
  .score-tab-main {
    flex: 1;
    min-width: 0;
  }
  .saved-routes-sidebar {
    display: none;
  }
  .saved-routes-sidebar.visible {
    display: block;
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: var(--space-5);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-header {
    font-size: var(--text-h4);
    font-weight: 800;
    color: var(--color-green-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 var(--space-1) var(--space-2);
  }
  .sidebar-route-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .sidebar-route-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px var(--space-3);
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
  }
  .sidebar-route-item:hover {
    background: var(--color-card-bg);
  }
  .sidebar-route-item.active {
    border-left-color: var(--color-sun-gold);
    background: #FFFCF0;
  }
  .sidebar-route-item.loading {
    opacity: 0.6;
    pointer-events: none;
  }
  .sidebar-score-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-label);
    font-weight: 800;
    color: var(--color-white);
    flex-shrink: 0;
  }
  .sidebar-route-info {
    min-width: 0;
    flex: 1;
  }
  .sidebar-route-name {
    font-size: var(--text-caption);
    font-weight: 700;
    color: var(--color-forest-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sidebar-route-meta {
    font-size: var(--text-caption);
    color: var(--color-green-500);
  }
  .sidebar-empty {
    text-align: center;
    padding: var(--space-5) var(--space-3);
    color: var(--color-green-500);
    font-size: var(--text-caption);
    line-height: 1.5;
  }

  /* Mobile: sidebar becomes horizontal scroll row */
  @media (max-width: 899px) {
    .score-tab-layout {
      flex-direction: column;
      gap: var(--space-3);
    }
    .saved-routes-sidebar.visible {
      width: 100%;
      position: static;
      max-height: none;
      overflow-y: visible;
    }
    .sidebar-header {
      padding: 0 0 6px;
    }
    .sidebar-route-list {
      flex-direction: row;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      gap: var(--space-2);
      padding-bottom: var(--space-1);
    }
    .sidebar-route-item {
      flex-shrink: 0;
      min-width: 160px;
      max-width: 200px;
    }
  }

  /* Tooltip on component scores */
  .component {
    position: relative;
  }
  .component .tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-forest-text);
    color: var(--color-card-bg);
    font-size: 0.7rem;
    font-weight: 400;
    line-height: 1.4;
    padding: var(--space-2) var(--space-3);
    border-radius: 6px;
    width: 200px;
    text-align: left;
    z-index: 10;
    pointer-events: none;
    transition: opacity var(--transition-fast);
  }
  .component .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--color-forest-text);
  }
  .component:hover .tooltip {
    visibility: visible;
    opacity: 1;
  }

  /* GPX Help link */
  .gpx-help-link {
    margin-left: auto;
    font-size: var(--text-body);
    color: var(--color-green-500);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    padding: 10px 0;
  }
  .gpx-help-link:hover { color: var(--color-forest-text); text-decoration: underline; }

  /* GPX Help Modal */
  .gpx-help-modal {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
  }
  .gpx-help-header {
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
  }
  .gpx-help-header h2 { font-size: 1.1rem; font-weight: 700; color: var(--color-forest-text); line-height: 1.3; }
  .strava-badge {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--color-strava-light); border: 1px solid var(--color-strava-border); border-radius: 6px;
    padding: 3px var(--space-2); margin-bottom: 6px;
  }
  .strava-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-strava); }
  .strava-badge span { font-size: var(--text-caption); font-weight: 700; color: var(--color-strava-dark); letter-spacing: 0.04em; }
  .gpx-help-close {
    background: var(--color-card-bg); border: none; border-radius: var(--radius-sm);
    width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--color-green-500); font-size: 18px; transition: background var(--transition-fast);
  }
  .gpx-help-close:hover { background: var(--color-border); color: var(--color-forest-text); }
  .gpx-help-body { overflow-y: auto; padding: 18px 20px; flex: 1; }
  .gpx-help-intro { font-size: var(--text-body-sm); color: var(--color-green-500); line-height: 1.55; margin-bottom: 18px; }
  .gpx-steps { display: flex; flex-direction: column; }
  .gpx-step { display: flex; gap: var(--space-3); padding-bottom: 18px; position: relative; }
  .gpx-step:not(:last-child)::before {
    content: ''; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--color-border);
  }
  .gpx-step-num {
    flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
    background: var(--color-forest-text); color: var(--color-white); font-size: var(--text-label); font-weight: 800;
    display: flex; align-items: center; justify-content: center; position: relative; z-index: 1;
  }
  .gpx-step-body { flex: 1; padding-top: var(--space-1); }
  .gpx-step-title { font-size: 0.9rem; font-weight: 700; color: var(--color-forest-text); margin-bottom: 3px; }
  .gpx-step-desc { font-size: var(--text-body-sm); color: var(--color-green-500); line-height: 1.5; margin-bottom: 10px; }
  .gpx-mockup { border-radius: var(--radius-sm); border: 1px solid var(--color-border); overflow: hidden; margin-bottom: var(--space-1); }
  .gpx-strava-toolbar {
    padding: 10px 14px; display: flex; align-items: center; gap: 6px; background: var(--color-white);
  }
  .gpx-toolbar-label { font-size: 10px; color: var(--color-green-500); margin-right: auto; text-transform: uppercase; font-weight: 600; }
  .gpx-tb-btn {
    border: 1px solid var(--color-border); background: var(--color-white); border-radius: 6px;
    padding: 5px 10px; font-size: var(--text-label); color: var(--color-forest-text);
  }
  .gpx-tb-highlighted {
    background: var(--color-forest-text); color: var(--color-white); border-color: var(--color-forest-text);
    font-weight: 800; box-shadow: 0 0 0 3px rgba(44,62,45,0.15);
  }
  .gpx-dropdown { background: var(--color-white); }
  .gpx-dd-item {
    padding: 10px 14px; font-size: var(--text-body-sm); color: var(--color-forest-text);
    border-bottom: 1px solid var(--color-card-bg); display: flex; align-items: center; gap: var(--space-2);
  }
  .gpx-dd-item:last-child { border-bottom: none; }
  .gpx-dd-muted { color: var(--color-green-500); font-size: 0.78rem; }
  .gpx-dd-export {
    background: #f0fdf4; color: #15803d; font-weight: 700;
    border-left: 3px solid var(--color-flat); border-bottom: 1px solid #dcfce7;
  }
  .gpx-dd-icon {
    width: 18px; height: 18px; background: var(--color-flat); border-radius: var(--space-1);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: var(--text-caption); color: var(--color-white);
  }
  .gpx-dd-tag {
    margin-left: auto; background: #dcfce7; color: #15803d;
    font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: var(--space-1);
  }
  .gpx-help-footer {
    padding: var(--space-3) 20px; border-top: 1px solid var(--color-border-light);
    display: flex; align-items: center; justify-content: space-between; background: var(--color-card-bg);
  }
  .gpx-help-hint { font-size: var(--text-label); color: var(--color-green-500); }
  .gpx-help-got-it {
    padding: var(--space-2) 20px; background: var(--color-forest-text); color: var(--color-white); border: none;
    border-radius: var(--radius-sm); font-size: var(--text-body-sm); font-weight: 600; cursor: pointer;
    font-family: var(--font-family);
  }
  .gpx-help-got-it:hover { background: var(--color-green-700); }

  /* Profile Completion Modal */
  .profile-modal {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
  }
  .profile-modal-header {
    padding: var(--space-5) var(--space-5) var(--space-2);
  }
  .profile-modal-header h2 {
    font-size: var(--text-h3); font-weight: 800; color: var(--color-forest-text); margin-bottom: var(--space-1);
  }
  .profile-modal-header p {
    font-size: var(--text-body-sm); color: var(--color-green-500); line-height: 1.5;
  }
  .profile-form {
    padding: var(--space-4) var(--space-5) var(--space-5);
  }
  .profile-form .form-row {
    display: flex; gap: var(--space-3);
  }
  .profile-form .form-group {
    display: flex; flex-direction: column; margin-bottom: 14px; flex: 1;
  }
  .profile-form label {
    font-size: 0.8rem; font-weight: 700; color: var(--color-forest-text); margin-bottom: var(--space-1);
  }
  .profile-form input {
    padding: 9px var(--space-3); border: 1px solid var(--color-border-medium); border-radius: var(--radius-sm);
    font-size: 0.9rem; font-family: var(--font-family); color: var(--color-forest-text); outline: none; transition: border-color var(--transition-fast);
  }
  .profile-form input:focus {
    border-color: var(--color-forest); box-shadow: 0 0 0 3px rgba(28,92,30,0.1);
  }
  .profile-form-hint {
    font-size: var(--text-label); color: var(--color-green-500); margin-bottom: var(--space-4);
  }
  .profile-submit-btn {
    width: 100%; padding: 10px; background: var(--color-sun-gold); color: var(--color-forest-text); border: none;
    border-radius: var(--radius-sm); font-size: 0.9rem; font-family: var(--font-family); font-weight: 700; cursor: pointer;
    transition: background var(--transition-fast);
  }
  .profile-submit-btn:hover { background: #E5B83D; }
  .profile-submit-btn:disabled { background: var(--color-disabled-bg); color: var(--color-disabled-text); cursor: not-allowed; }
  .profile-danger-zone {
    padding: var(--space-4) var(--space-5) var(--space-5);
    border-top: 1px solid var(--color-border-light);
    display: flex; align-items: center; gap: var(--space-3);
  }
  .delete-account-btn {
    padding: 7px 14px; background: var(--color-white); color: var(--color-danger); border: 1px solid #FCA5A5;
    border-radius: var(--radius-sm); font-size: 0.8rem; font-family: var(--font-family); font-weight: 700; cursor: pointer;
    white-space: nowrap; transition: all var(--transition-fast);
  }
  .delete-account-btn:hover { background: #FEF2F2; border-color: var(--color-danger); }


/* =============================================================================
   DARK MODE OVERRIDES
============================================================================= */

/* Dropzone: strong "Drop GPX files here" text was --color-forest (#1C5C1E, dark
   green) on a dark green background — override to gold for legibility */
[data-theme="dark"] .dropzone-text strong {
  color: var(--color-sun-gold);
}

/* Dropzone hover/dragover: hardcoded #F0F7F0 (light) doesn't work on dark bg */
[data-theme="dark"] .dropzone:hover,
[data-theme="dark"] .dropzone.dragover {
  background: rgba(255, 255, 255, 0.06);
}

/* Sidebar active card: hardcoded #FFFCF0 (pale yellow) — light text on pale bg */
[data-theme="dark"] .sidebar-route-item.active {
  background: rgba(247, 201, 72, 0.12);
}
  .danger-hint { font-size: 0.72rem; color: var(--color-green-500); }
