/* =========================================================================
   Pace Calculator — Custom theme
   Overrides Bootstrap defaults for a quietly technical, runner-focused look
   ========================================================================= */

:root {
    /* ----- Color tokens ----- */
    --bg-base:      #0f1419;
    --bg-surface:   #1a2026;
    --bg-elevated:  #232a31;
    --bg-hover:     #2a323a;

    --border-subtle: #2a323a;
    --border-default: #3a434c;
    --border-strong: #4a5460;

    --text-high:    #e8eaed;
    --text-mid:     #c4c8cc;
    --text-muted:   #9aa0a6;
    --text-disabled: #5f6368;

    --accent-warm:  #ff7849;   /* effort/uphill — brand --pv-flare */
    --accent-cool:  #4dd0c1;   /* recovery/downhill — brand --pv-tide */
    --accent-info:  #6ba3ff;   /* informational */
    --accent-warn:  #ffb454;
    --accent-error: #ff5e6c;

    /* ----- Brand tokens (Tempo logo system) ----- */
    --pv-flare: #ff7849;
    --pv-tide:  #4dd0c1;
    --pv-ink:   #14151a;
    --pv-gradient: linear-gradient(145deg, var(--pv-flare), var(--pv-tide));
    --pv-gradient-text: linear-gradient(100deg, var(--pv-flare), var(--pv-tide));

    /* ----- Typography ----- */
    --font-display: 'Sora', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, Consolas, monospace;

    /* ----- Spacing scale ----- */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;
    --space-2xl: 4rem;

    /* ----- Bootstrap dark-theme overrides ----- */
    --bs-body-bg: var(--bg-base);
    --bs-body-color: var(--text-high);
    --bs-body-font-family: var(--font-sans);
    --bs-body-font-size: 1rem;
    --bs-body-line-height: 1.6;
    --bs-link-color: var(--accent-cool);
    --bs-link-hover-color: var(--accent-warm);
    --bs-border-color: var(--border-default);
}

/* =========================================================================
   Base
   ========================================================================= */

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-base);
    color: var(--text-high);
    font-family: var(--font-sans);
    font-feature-settings: "ss01", "cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 0 auto;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--text-high);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.1; }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); line-height: 1.2; }
h3 { font-size: 1.5rem; }

.text-mono,
.numeric,
.font-mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}


/* =========================================================================
   Navbar
   ========================================================================= */

.navbar {
    background-color: rgba(15, 20, 25, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 0;
}

/* Brand lockup — Sora Bold wordmark beside the Tempo mark.
   Spacing per handoff: gap ≈ 0.4× mark height. Casing is locked as "PaceVance". */
.navbar-brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-high) !important;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 0.7em;
}

/* No drop-shadow or outline on the mark itself — brand usage rule. */
.brand-logo {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.navbar-brand:hover .brand-logo {
    transform: translateY(-2px);
}


/* "Pace" is white on dark surfaces (Ink #14151a on light). */
.brand-text {
    color: #fff;
}

/* "Vance" carries the 100deg gradient via background-clip, per handoff. */
.brand-text .accent {
    background: var(--pv-gradient-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-link {
    color: var(--text-mid) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    transition: color 0.15s ease;
}

.nav-link:hover {
    color: var(--text-high) !important;
}

.nav-link.active {
    color: var(--accent-warm) !important;
}

.navbar-toggler {
    border-color: var(--border-default);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23e8eaed' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.lang-switcher {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    padding: 2px;
}

.lang-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.15s ease;
    letter-spacing: 0.05em;
}

.lang-btn:hover {
    color: var(--text-high);
    background-color: var(--bg-hover);
}

.lang-btn.active {
    color: var(--bg-base);
    background-color: var(--accent-warm);
}

/* =========================================================================
   Hero
   ========================================================================= */

.hero {
    padding: 5rem 0 4rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 200%;
    background: radial-gradient(ellipse at center, rgba(255, 120, 73, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.hero > .container {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-size: clamp(2.25rem, 5vw, 3.75rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.03em;
    margin-bottom: 1.5rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.hero-title .highlight {
    background: linear-gradient(135deg, var(--accent-warm), var(--accent-cool));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-mid);
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.55;
}

/* =========================================================================
   Cards (entry points)
   ========================================================================= */

.entry-cards {
    padding: 2rem 0 4rem;
}

.entry-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 2.25rem;
    height: 100%;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: var(--text-high);
}

.entry-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-warm), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.entry-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    background: var(--bg-elevated);
    color: var(--text-high);
}

.entry-card:hover::before {
    opacity: 1;
}

.entry-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: rgba(255, 120, 73, 0.1);
    color: var(--accent-warm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
}

.entry-card.cool .entry-card-icon {
    background: rgba(77, 208, 193, 0.1);
    color: var(--accent-cool);
}

.entry-card-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-high);
}

.entry-card-desc {
    color: var(--text-mid);
    line-height: 1.55;
    flex: 1;
    margin-bottom: 1.5rem;
}

.entry-card-cta {
    color: var(--accent-warm);
    font-weight: 500;
    font-size: 0.95rem;
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: gap 0.2s ease;
}

.entry-card.cool .entry-card-cta {
    color: var(--accent-cool);
}

.entry-card:hover .entry-card-cta {
    gap: 0.85rem;
}

/* =========================================================================
   Features section
   ========================================================================= */

.features-section {
    padding: 5rem 0;
    border-top: 1px solid var(--border-subtle);
}

.section-title {
    text-align: center;
    margin-bottom: 3rem;
    font-size: 2rem;
    color: var(--text-mid);
    font-weight: 500;
}

.feature {
    text-align: center;
    padding: 1.5rem 1rem;
}

.feature-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    color: var(--accent-cool);
    font-size: 1.5rem;
}

.feature-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feature-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.55;
}

/* =========================================================================
   Generic page header (basic.php, advanced.php, about.php)
   ========================================================================= */

.page-header {
    padding: 4rem 0 2rem;
    text-align: center;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 3rem;
}

.page-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    margin-bottom: 0.75rem;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}


/* =========================================================================
   Footer
   ========================================================================= */

.site-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    padding: 2rem 0;
    margin-top: 4rem;
    flex-shrink: 0;
}

.footer-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* =========================================================================
   Buttons (Bootstrap overrides)
   ========================================================================= */

.btn-primary {
    background-color: var(--accent-warm);
    border-color: var(--accent-warm);
    color: var(--bg-base);
    font-weight: 500;
    padding: 0.65rem 1.5rem;
    transition: all 0.15s ease;
}

.btn-primary:hover {
    background-color: #ff8a5e;
    border-color: #ff8a5e;
    color: var(--bg-base);
    transform: translateY(-1px);
}

.btn-outline-primary {
    border-color: var(--border-default);
    color: var(--text-high);
}

.btn-outline-primary:hover {
    background-color: var(--bg-elevated);
    border-color: var(--border-strong);
    color: var(--text-high);
}

/* =========================================================================
   Form controls (Bootstrap overrides)
   ========================================================================= */

.form-control,
.form-select {
    background-color: var(--bg-surface);
    border-color: var(--border-default);
    color: var(--text-high);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-elevated);
    border-color: var(--accent-warm);
    color: var(--text-high);
    box-shadow: 0 0 0 0.2rem rgba(255, 120, 73, 0.15);
}

.form-label {
    color: var(--text-mid);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

/* =========================================================================
   Basic Calculator
   ========================================================================= */

.calc-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.unit-toggle {
    display: flex;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.unit-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.03em;
}

.unit-btn:hover {
    color: var(--text-high);
    background: var(--bg-hover);
}

.unit-btn.active {
    background: var(--accent-warm);
    color: var(--bg-base);
}

.preset-btns {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.preset-btn {
    background: none;
    border: 1px solid var(--border-default);
    border-radius: 5px;
    color: var(--text-mid);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.02em;
}

.preset-btn:hover {
    border-color: var(--accent-warm);
    color: var(--accent-warm);
    background: rgba(255, 120, 73, 0.06);
}

.preset-btn--time:hover {
    border-color: var(--accent-cool);
    color: var(--accent-cool);
    background: rgba(77, 208, 193, 0.06);
}


.calc-field .preset-btns {
    margin-top: 0.4rem;
}

/* Nudge buttons */
.nudge-row {
    display: none;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.45rem;
}

.nudge-row.visible {
    display: flex;
}

.nudge-btn {
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.18rem 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 36px;
    text-align: center;
    line-height: 1.4;
}

.nudge-btn:hover {
    border-color: var(--accent-cool);
    color: var(--accent-cool);
    background: rgba(77, 208, 193, 0.06);
}

/* Segment pace popup adjustor */
.seg-pace-popup {
    position: fixed;
    display: none;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    padding: 0.25rem 0.35rem;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.seg-pace-popup.visible {
    display: flex;
}

/* Input fields grid */
.calc-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.calc-inputs--2 {
    grid-template-columns: repeat(2, 1fr);
}

.calc-field {
    display: flex;
    flex-direction: column;
}

.calc-label {
    color: var(--text-mid);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}

.calc-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.calc-input {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    color: var(--text-high);
    font-family: var(--font-mono);
    font-size: 1.15rem;
    padding: 0.6rem 0.85rem;
    padding-right: 2.8rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    touch-action: manipulation;
}

.calc-input:focus {
    border-color: var(--accent-warm);
    box-shadow: 0 0 0 3px rgba(255, 120, 73, 0.12);
}

.calc-input::placeholder {
    color: var(--text-disabled);
    font-family: var(--font-mono);
}

.calc-unit {
    position: absolute;
    right: 0.7rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Action buttons */
.calc-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.remember-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    margin-left: auto;
}

.remember-toggle input[type="checkbox"] {
    accent-color: var(--accent-warm);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.btn-ghost {
    background: none;
    border: 1px solid var(--border-default);
    color: var(--text-mid);
    font-weight: 500;
    padding: 0.65rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-ghost:hover {
    border-color: var(--border-strong);
    color: var(--text-high);
    background: var(--bg-hover);
}

.btn-ghost.btn-sm {
    font-size: 0.85rem;
    padding: 0.35rem 0.85rem;
}

/* Error message */
.calc-error {
    margin-top: 1rem;
    padding: 0.65rem 0.9rem;
    background: rgba(255, 94, 108, 0.1);
    border: 1px solid rgba(255, 94, 108, 0.25);
    border-radius: 6px;
    color: var(--accent-error);
    font-size: 0.9rem;
}

/* ── Results ──────────────────────────────────────────────────────────── */

.results-section {
    margin-bottom: 1.5rem;
}

.result-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.result-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 1.1rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    transition: border-color 0.2s;
}

.result-card.solved {
    border-color: var(--accent-warm);
    background: rgba(255, 120, 73, 0.06);
}

.result-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-high);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.result-unit {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.result-actions {
    display: flex;
    justify-content: flex-end;
}

/* ── Tables (splits, alt paces, zones) ───────────────────────────────── */

.table-section {
    margin-bottom: 2rem;
}

.section-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-mid);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.section-header-row .section-heading {
    margin-bottom: 0;
}

.split-tabs {
    display: flex;
    gap: 0.25rem;
}

.split-tab {
    padding: 0.2rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid var(--border-default);
    border-radius: 4px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.split-tab:hover {
    border-color: var(--accent-warm);
    color: var(--accent-warm);
}

.split-tab.active {
    background: var(--accent-warm);
    border-color: var(--accent-warm);
    color: #fff;
}

.pc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.pc-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
}

.pc-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid rgba(42, 50, 58, 0.6);
    color: var(--text-mid);
    vertical-align: middle;
}

.pc-table td.numeric {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--text-high);
}

.pc-table tbody tr:hover td {
    background: var(--bg-hover);
}

.pc-table .row-faster td { color: var(--accent-cool); }
.pc-table .row-faster td.numeric { color: var(--accent-cool); }
.pc-table .row-slower td { color: var(--accent-warn); }
.pc-table .row-slower td.numeric { color: var(--accent-warn); }

/* =========================================================================
   Advanced Calculator
   ========================================================================= */

.adv-container {
    padding-bottom: 4rem;
}

/* ── Two-column dashboard layout (≥993px) ──────────────────────────────────
   Left rail holds the controls; the right column holds the route, segments
   table, summary and result tables. Collapses to a single column ≤992px. */
.adv-layout {
    display: grid;
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
    margin-top: 1rem;
}

/* Left rail: settings panel stays in view while the right column scrolls */
.adv-rail {
    position: sticky;
    top: 5rem; /* clear the sticky navbar */
}

/* Right column: stacked panels with uniform spacing (gap replaces mt-3) */
.adv-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0; /* let the table scroll instead of stretching the grid track */
}
.adv-main > .results-section,
.adv-main > .table-section {
    margin-bottom: 0;
}

/* In the narrow rail, stack the pace + time inputs vertically */
.adv-layout .calc-inputs--2 {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 0;
}

/* GPS panel */





/* Race presets */
.preset-btns--race {
    gap: 0.4rem;
}

/* Leaflet map */
.route-map {
    height: 280px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    margin-bottom: 0.75rem;
}

/* Elevation chart */



/* Route name bar */
.route-name-bar {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-high);
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.rn-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Settings panel */
.adv-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
}

.adv-top-row {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

/* Keep the Surface / Pace algorithm / Terrain factor controls the same height */
.adv-top-row .unit-toggle,
.adv-top-row .adv-select,
.adv-top-row #inp-terrain {
    height: 38px;
    box-sizing: border-box;
}

.adv-top-row #inp-terrain {
    font-size: 0.9rem;
    padding: 0 0.75rem;
}

/* Elevation chart: break out of panel horizontal padding for full-width feel */
.elevation-wrap-full {
    position: relative;
    height: 200px;
    margin: 0 -1.5rem;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.elevation-wrap-full canvas {
    cursor: default;
    -webkit-user-select: none;
    user-select: none;
}

.elevation-wrap-full .drag-hint {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 0.7rem;
    color: var(--text-disabled);
    pointer-events: none;
}


.adv-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}


.adv-select {
    background: var(--bg-elevated);
    border-color: var(--border-default);
    color: var(--text-high);
    font-size: 0.9rem;
    padding: 0.45rem 0.75rem;
}

.adv-select:focus {
    background: var(--bg-elevated);
    border-color: var(--accent-warm);
    color: var(--text-high);
    box-shadow: 0 0 0 3px rgba(255, 120, 73, 0.12);
}

/* Segments table.
   Fixed layout so spare width spreads proportionally across every column
   instead of piling into the flexible name column (which left a dead gap). */
.pc-table-adv {
    table-layout: fixed;
    width: 100%;
}

.pc-table-adv .col-drag {
    width: 28px;
    cursor: grab;
    color: var(--text-disabled);
}

.pc-table-adv .col-num   { width: 32px; color: var(--text-muted); }
.pc-table-adv .col-name  { width: 150px; }
.pc-table-adv .col-dist  { width: 90px; }
.pc-table-adv .col-gain  { width: 80px; }
.pc-table-adv .col-loss  { width: 80px; }
.pc-table-adv .col-grade { width: 70px; }
.pc-table-adv .col-pace  { width: 90px; }
.pc-table-adv .col-time  { width: 80px; }
.pc-table-adv .col-actions { width: 100px; }

.seg-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.drag-handle {
    cursor: grab;
    opacity: 0.4;
    transition: opacity 0.15s;
}

tr:hover .drag-handle {
    opacity: 0.8;
}

/* Inline segment inputs */
.seg-inp {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-high);
    font-family: inherit;
    font-size: 0.875rem;
    padding: 0.2rem 0.3rem;
    width: 100%;
    transition: border-color 0.15s, background 0.15s;
    touch-action: manipulation;
}

.seg-inp:hover {
    border-color: var(--border-default);
    background: var(--bg-elevated);
}

.seg-inp:focus {
    outline: none;
    border-color: var(--accent-warm);
    background: var(--bg-elevated);
}

.seg-inp.numeric {
    font-family: var(--font-mono);
    text-align: right;
    padding-right: 1.8rem;
}

.seg-inp.seg-pace-inp {
    text-align: right;
    font-family: var(--font-mono);
    /* Pace inputs have no unit suffix, so the .numeric right-padding (reserved
       for a "km"/"m" label) would push the text out of a narrow column. */
    padding-right: 0.3rem;
}

.seg-inp.seg-pace-auto {
    color: var(--text-muted);
}

.seg-num-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.seg-unit {
    position: absolute;
    right: 0.3rem;
    font-size: 0.7rem;
    color: var(--text-disabled);
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
}

.seg-name-inp {
    min-width: 100px;
}

.grade-cell {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Action dropdown */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
}

.btn-icon:hover {
    color: var(--text-high);
    background: var(--bg-hover);
}

.adv-dropdown {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    min-width: 180px;
    padding: 0.25rem 0;
}

.adv-dropdown .dropdown-item {
    color: var(--text-mid);
    font-size: 0.875rem;
    padding: 0.45rem 1rem;
}

.adv-dropdown .dropdown-item:hover,
.adv-dropdown .dropdown-item:focus {
    background: var(--bg-hover);
    color: var(--text-high);
}

.adv-dropdown .dropdown-item:disabled {
    color: var(--text-disabled);
}

.adv-dropdown .dropdown-item.text-danger {
    color: var(--accent-error);
}

.adv-dropdown .dropdown-item.text-danger:hover {
    background: rgba(255, 94, 108, 0.1);
    color: var(--accent-error);
}

.adv-dropdown .dropdown-divider {
    border-color: var(--border-subtle);
    margin: 0.2rem 0;
}

/* Total row */
.total-row td {
    border-top: 2px solid var(--border-default);
    background: var(--bg-elevated);
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

.fw-600 {
    font-weight: 600;
}

/* Table footer */
.adv-table-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: 0.5rem;
}

/* Modal */
.adv-modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    color: var(--text-high);
}

.adv-modal .modal-header {
    border-bottom: 1px solid var(--border-subtle);
    padding: 1rem 1.25rem;
}

.adv-modal .modal-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 0.75rem 1.25rem;
}

.adv-modal .modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.seg-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-mid);
}

.seg-option label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.seg-interval-input {
    width: 60px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    color: var(--text-high);
    padding: 0.2rem 0.4rem;
    font-size: 0.9rem;
    text-align: center;
}

/* =========================================================================
   About Page
   ========================================================================= */

.about-section {
    margin-bottom: 3rem;
}

.about-section p {
    color: var(--text-mid);
    line-height: 1.7;
    margin-bottom: 0.9rem;
}

.about-heading {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-high);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.algo-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.algo-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.algo-badge {
    background: rgba(255, 120, 73, 0.15);
    color: var(--accent-warm);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.algo-name {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
}

.algo-desc {
    color: var(--text-mid);
    font-size: 0.93rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.algo-formula {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-cool);
    background: var(--bg-elevated);
    border-left: 3px solid var(--accent-cool);
    padding: 0.6rem 0.9rem;
    border-radius: 0 6px 6px 0;
    margin-bottom: 0.75rem;
}

.algo-note {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.55;
    margin: 0;
}

.tech-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tech-item {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.tech-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    width: 160px;
    flex-shrink: 0;
}

.tech-val {
    color: var(--text-mid);
    font-size: 0.9rem;
}

.ref-list {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.7;
    padding-left: 1.25rem;
}

.ref-list li {
    margin-bottom: 0.5rem;
}

.ref-list em {
    color: var(--text-mid);
}

/* =========================================================================
   Help Page (how-to-use.php)
   ========================================================================= */

.about-heading .bi {
    color: var(--accent-warm);
    margin-right: 0.4rem;
}

.help-list {
    color: var(--text-mid);
    line-height: 1.7;
    padding-left: 1.25rem;
    margin-bottom: 1rem;
}

.help-list li {
    margin-bottom: 0.4rem;
}

.help-step {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-high);
    margin: 1.5rem 0 0.6rem;
}

.help-step-num {
    flex: 0 0 auto;
    width: 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 120, 73, 0.15);
    color: var(--accent-warm);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.help-cta {
    color: var(--accent-cool);
    text-decoration: none;
    font-weight: 500;
}

.help-cta:hover {
    text-decoration: underline;
}

/* =========================================================================
   Segment cards + bottom sheet (mobile, advanced calculator)
   ========================================================================= */

.seg-cards {
    display: none; /* shown ≤768px, replaces the table */
}

.seg-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.65rem 0.8rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.seg-card:active {
    background: var(--bg-hover);
}

.seg-card--total {
    background: transparent;
    border-style: dashed;
    cursor: default;
}

.seg-card-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.seg-card-num {
    flex: 0 0 auto;
    width: 1.4rem;
    height: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

.seg-card-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.seg-card-pace {
    color: var(--text-high);
}

.seg-card-pace.seg-pace-auto {
    color: var(--text-muted);
}

.seg-card-meta {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-mid);
}

.seg-meta-gain { color: var(--accent-warm); }
.seg-meta-loss { color: var(--accent-cool); }

.seg-card-chev {
    color: var(--text-disabled);
    font-size: 0.75rem;
}

.seg-cards-empty {
    text-align: center;
    padding: 1rem 0;
    font-size: 0.9rem;
}

/* ── Bottom sheet editor ── */

.seg-sheet {
    position: fixed;
    inset: 0;
    z-index: 8900; /* below the drum picker (9000) so it can stack on top */
    display: flex;
    align-items: flex-end;
    visibility: hidden;
    pointer-events: none;
}

.seg-sheet.open {
    visibility: visible;
    pointer-events: auto;
}

.seg-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.seg-sheet.open .seg-sheet-backdrop {
    opacity: 1;
}

.seg-sheet-panel {
    position: relative;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-default);
    border-radius: 16px 16px 0 0;
    padding: 0.9rem 1rem calc(1.1rem + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.25s ease;
}

.seg-sheet.open .seg-sheet-panel {
    transform: translateY(0);
}

.seg-sheet-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.8rem;
}

.seg-sheet-title {
    flex: 1;
    font-weight: 600;
    color: var(--text-high);
}

.seg-sheet-header .btn-icon {
    font-size: 1.05rem;
    padding: 0.35rem 0.55rem;
}

.seg-sheet-header .btn-icon:disabled {
    opacity: 0.35;
    pointer-events: none;
}

.seg-sheet-fields {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 0.9rem;
}

.seg-sheet-field--wide {
    grid-column: 1 / -1;
}

.seg-sheet-field .calc-input {
    width: 100%;
}

.seg-sheet-time {
    display: flex;
    align-items: center;
    min-height: 2.4rem;
    font-family: var(--font-mono);
    color: var(--text-high);
}

.seg-sheet-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.seg-sheet-actions .btn {
    text-align: left;
}

.seg-sheet-delete {
    grid-column: 1 / -1;
    color: var(--accent-error);
}

/* =========================================================================
   Responsive
   ========================================================================= */

/* Below xl the rail would squeeze the segments table, so stay single-column.
   Two-column dashboard only engages ≥1200px where the container is wide enough. */
@media (max-width: 1199.98px) {
    .adv-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .adv-rail {
        position: static;
    }
    /* Full-width panel again: pace + time can sit side by side */
    .adv-layout .calc-inputs--2 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 992px) {
    .route-map {
        height: 220px;
    }
}

@media (max-width: 768px) {
    .hero {
        padding: 3rem 0;
    }
    .entry-card {
        padding: 1.75rem;
    }
    .features-section {
        padding: 3rem 0;
    }
    .calc-inputs {
        grid-template-columns: 1fr;
    }
    /* Advanced pace + time: the `.adv-layout .calc-inputs--2` rule in the
       ≤1199.98px query forces two columns; on a phone the time field's nudge
       row (6 buttons) can't fit half the width and overflows the page. Stack
       them here — same specificity, later in source, so it wins. */
    .adv-layout .calc-inputs--2 {
        grid-template-columns: 1fr;
    }
    .result-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .calc-card {
        padding: 1.25rem;
    }
    .adv-settings-row {
        flex-direction: column;
        align-items: flex-start;
    }
    /* Segments: swap the table for tappable cards + bottom-sheet editor */
    .seg-table-wrap { display: none; }
    .seg-cards { display: block; }
    .tech-item {
        flex-direction: column;
        gap: 0.2rem;
    }
    .tech-label {
        width: auto;
    }
}

/* ── Drum picker (mobile bottom sheet) ─────────────────────────────────────── */

/* Sheet is always display:flex so scrollTop can be written at any time.
   Hidden state uses visibility + pointer-events, not display:none,
   which would wipe scroll positions on every open. */
.drum-sheet {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: flex-end;
    visibility: hidden;
    pointer-events: none;
}
.drum-sheet.open {
    visibility: visible;
    pointer-events: auto;
}
.drum-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.drum-sheet.open .drum-backdrop {
    opacity: 1;
}
.drum-panel {
    position: relative;
    width: 100%;
    max-height: 72vh;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-default);
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
.drum-sheet.open .drum-panel {
    transform: translateY(0);
}

.drum-toolbar {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}
.drum-btn {
    background: none;
    border: none;
    font-size: 1rem;
    font-family: var(--font-sans);
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    touch-action: manipulation;
}
.drum-cancel { color: var(--text-muted); }
.drum-done   { color: var(--accent-cool); font-weight: 600; }

.drum-stage {
    position: relative;
    height: 220px;
    overflow: hidden;
}
.drum-highlight {
    position: absolute;
    left: 0; right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 44px;
    background: rgba(255, 255, 255, 0.06);
    border-top: 1px solid var(--border-default);
    border-bottom: 1px solid var(--border-default);
    pointer-events: none;
    z-index: 1;
}
.drum-cols {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    gap: 0.1rem;
}
.drum-col {
    flex: 0 0 80px;
    height: 100%;
    overflow: hidden;
}
.drum-scroll {
    height: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: pan-y;
}
.drum-scroll::-webkit-scrollbar { display: none; }
.drum-item {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--text-high);
    scroll-snap-align: center;
    -webkit-user-select: none;
    user-select: none;
}
.drum-sep {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--text-muted);
    align-self: center;
    padding: 0 0.15rem;
    pointer-events: none;
}
