/* ── Reset & Base ───────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Warm earthy palette — inspired by the LongRoutes icon */
    --color-cream: #f6ebd7;
    --color-cream-light: #faf5eb;
    --color-cream-dark: #ede0c8;

    --color-bg: #f8f3ea;
    --color-surface: #ffffff;
    --color-text: #2a3428;
    --color-text-muted: #5a6858;
    --color-text-light: #8a9586;
    --color-border: #ddd5c5;
    --color-border-light: #eee8da;

    --color-nav: #1e3329;
    --color-nav-light: #2a4538;

    --color-strava: #fc4c02;
    --color-strava-hover: #e04400;

    /* Forest green — the dominant hill color from the icon */
    --color-trail: #3a6b4e;
    --color-trail-light: #4a8c5e;
    --color-trail-bg: #eef5ee;
    --color-trail-glow: rgba(58,107,78,0.2);

    /* Sky blue accent from the icon */
    --color-sky: #7ec8d9;
    --color-sky-light: #b5e0ea;

    --color-danger: #c7453b;

    --shadow-xs: 0 1px 2px rgba(42,52,40,0.04);
    --shadow-sm: 0 1px 3px rgba(42,52,40,0.06), 0 1px 2px rgba(42,52,40,0.04);
    --shadow-md: 0 4px 12px rgba(42,52,40,0.07), 0 2px 4px rgba(42,52,40,0.04);
    --shadow-lg: 0 12px 24px rgba(42,52,40,0.09), 0 4px 8px rgba(42,52,40,0.04);
    --shadow-xl: 0 24px 48px rgba(42,52,40,0.1), 0 8px 16px rgba(42,52,40,0.05);

    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    background-image:
        radial-gradient(ellipse at 10% 0%, rgba(58,107,78,0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 100%, rgba(126,200,217,0.04) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--color-trail); }

/* ── Navbar ────────────────────────────────────────── */
.navbar {
    background: linear-gradient(180deg, var(--color-nav) 0%, #162b22 100%);
    color: white;
    padding: 0 2rem;
    height: 58px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 1px 3px rgba(0,0,0,0.25), 0 4px 16px rgba(0,0,0,0.12);
}

.nav-brand {
    color: white;
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: opacity 0.2s;
}
.nav-brand:hover { opacity: 0.85; }

.beta-badge {
    position: fixed;
    top: 68px;
    right: 1.25rem;
    z-index: 999;
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    background: #b85450;
    border-radius: 20px;
    padding: 0.3rem 0.8rem;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    transition: background 0.2s;
}
.beta-badge:hover {
    background: #a04845;
}

.nav-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.nav-links { display: flex; gap: 0.25rem; align-items: center; }
.nav-links a {
    color: rgba(246,235,215,0.7);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
}
.nav-links a:hover { color: var(--color-cream); background: rgba(255,255,255,0.08); }

.nav-user-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem 0.25rem 0.25rem;
    border-radius: 20px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
}

.nav-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--color-trail);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.nav-user-name {
    color: var(--color-cream);
    font-size: 0.85rem;
    font-weight: 500;
}

/* ── Layout ────────────────────────────────────────── */
.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
    flex: 1;
    position: relative;
}

/* Trails background watermark — fits between navbar and footer */
.trails-bg-wrap {
    position: fixed;
    top: 58px;
    left: -12%;
    right: -12%;
    bottom: 60px;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(181, 224, 234, 0.2);
    transition: opacity 0.4s ease;
    cursor: zoom-in;
}
.trails-bg-wrap object {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Modal overlay for expanded SVG map */
.bg-map-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.bg-map-modal.visible { display: flex; }
.bg-map-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 860px;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.bg-map-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.bg-map-card-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}
.bg-map-card-body {
    flex: 1;
    overflow: hidden;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bg-map-card-body object {
    width: 100%;
    height: 100%;
    max-height: calc(90dvh - 80px);
    object-fit: contain;
}
.bg-map-card-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.6rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background: linear-gradient(180deg, var(--color-nav) 0%, #162b22 100%);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    flex-shrink: 0;
}
.bg-map-brand-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    object-fit: cover;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.bg-map-brand-text {
    color: white;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Hide background on trail detail pages */
.page-login .trails-bg-wrap { display: none; }

.page-trail-detail .trails-bg-wrap {
    opacity: 0;
    pointer-events: none;
}

/* ── Footer ────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--color-text-light);
    font-size: 0.8rem;
    border-top: 1px solid var(--color-border);
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    background: rgba(246,235,215,0.3);
}
.footer-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.footer a { color: var(--color-text-muted); text-decoration: none; }
.footer a:hover { text-decoration: underline; color: var(--color-text); }
.footer-sep { color: var(--color-border); }

/* ── Back Link ────────────────────────────────────── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.88rem;
    color: var(--color-text-muted);
    text-decoration: none;
    margin-bottom: 0.75rem;
    font-weight: 500;
    transition: color 0.2s;
}
.back-link:hover { color: var(--color-trail); }

/* ── Buttons ───────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.75rem;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.btn:active { transform: scale(0.97); }

.btn-strava {
    background: linear-gradient(135deg, #fc4c02 0%, #e04400 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(252,76,2,0.25);
}
.btn-strava:hover {
    box-shadow: 0 6px 20px rgba(252,76,2,0.35);
    transform: translateY(-1px);
}

.btn-outline {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1.5px solid var(--color-border);
    box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
    border-color: var(--color-trail);
    box-shadow: var(--shadow-sm);
    background: var(--color-cream-light);
}

.btn-trail {
    background: linear-gradient(135deg, var(--color-trail) 0%, var(--color-trail-light) 100%);
    color: white;
    box-shadow: 0 2px 8px var(--color-trail-glow);
}
.btn-trail:hover {
    box-shadow: 0 6px 20px var(--color-trail-glow);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border: 1.5px solid var(--color-border);
    font-weight: 500;
}
.btn-ghost:hover {
    background: var(--color-cream-light);
    color: var(--color-text);
    border-color: var(--color-cream-dark);
}

/* ── Hero / Login ──────────────────────────────────── */
.hero {
    position: relative;
    text-align: center;
    overflow: hidden;
    background: linear-gradient(180deg, var(--color-cream-light) 0%, var(--color-bg) 100%);
}

.hero-topo {
    position: absolute;
    inset: 0;
    background: rgba(181, 224, 234, 0.2) url('/static/img/trails-bg.svg?v=21') center center / contain no-repeat;
    pointer-events: none;
}

.hero-inner {
    position: relative;
    padding: 4rem 1rem 3.5rem;
}

.hero-logo {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(255,255,255,0.8);
    margin-bottom: 1.5rem;
    display: inline-block;
}

.hero-icon { font-size: 3.5rem; margin-bottom: 1rem; display: block; }

.hero h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--color-nav) 0%, var(--color-trail) 60%, var(--color-trail-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-tagline {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.hero-desc {
    color: var(--color-text-light);
    margin-bottom: 0.75rem;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    font-size: 1rem;
    line-height: 1.7;
}

.btn-hero {
    margin-top: 1.5rem;
    padding: 0.9rem 2.75rem;
    font-size: 1.05rem;
    border-radius: 12px;
}

.hero-features {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-top: 3.5rem;
    flex-wrap: wrap;
}

.hero-feature {
    text-align: center;
    max-width: 200px;
    animation: fadeInUp 0.5s ease-out both;
}
.hero-feature:nth-child(1) { animation-delay: 0.1s; }
.hero-feature:nth-child(2) { animation-delay: 0.2s; }
.hero-feature:nth-child(3) { animation-delay: 0.3s; }

.hero-feature-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--color-trail-bg) 0%, rgba(58,107,78,0.1) 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 8px rgba(58,107,78,0.08);
}

.hero-feature-icon { font-size: 1.5rem; line-height: 1; }
.hero-feature h3 { font-size: 0.92rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--color-text); }
.hero-feature p { font-size: 0.82rem; color: var(--color-text-light); line-height: 1.5; }

/* ── Page Headers ──────────────────────────────────── */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}
h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 2.5rem 0 1rem;
    color: var(--color-text);
}

.page-subtitle { color: var(--color-text-muted); font-size: 0.95rem; margin-bottom: 1.5rem; }
.btn-view-map {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0.15rem 0.65rem;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    cursor: pointer;
    vertical-align: middle;
    transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn-view-map:hover { border-color: var(--color-trail); color: var(--color-trail); box-shadow: var(--shadow-xs); }

/* ── Dashboard Header ─────────────────────────────── */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 1;
}
.dashboard-header h1 { margin-bottom: 0.25rem; }
.dashboard-header .page-subtitle { margin-bottom: 0; }

/* Add trail dropdown */
.add-trail-wrap {
    position: relative;
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.add-trail-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 340px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    z-index: 100;
    overflow: hidden;
}
.add-trail-dropdown.open {
    display: flex;
    flex-direction: column;
    animation: dropdownIn 0.2s ease-out;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.add-trail-search-wrap {
    padding: 0.6rem;
    border-bottom: 1px solid var(--color-border-light);
}
.add-trail-search {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--color-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--color-cream-light);
}
.add-trail-search:focus {
    border-color: var(--color-trail);
    box-shadow: 0 0 0 3px rgba(58,107,78,0.1);
    background: white;
}
.add-trail-search::placeholder { color: var(--color-text-light); }

.add-trail-list {
    max-height: 300px;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.add-trail-list::-webkit-scrollbar { width: 6px; }
.add-trail-list::-webkit-scrollbar-track { background: transparent; }
.add-trail-list::-webkit-scrollbar-thumb { background: var(--color-cream-dark); border-radius: 3px; }
.add-trail-list::-webkit-scrollbar-thumb:hover { background: var(--color-text-light); }

.add-trail-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.7rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    color: var(--color-text);
    text-align: left;
    transition: background 0.15s;
}
.add-trail-option:hover { background: var(--color-trail-bg); }
.add-trail-option:not(:last-child) { border-bottom: 1px solid var(--color-border-light); }
.add-trail-name { font-weight: 500; }
.add-trail-length {
    font-size: 0.78rem;
    color: var(--color-text-light);
    flex-shrink: 0;
    margin-left: 0.75rem;
    background: var(--color-cream);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
}

.add-trail-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.85rem;
}

/* ── Dashboard Header Right ───────────────────────── */
.dashboard-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.trail-counter {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    font-weight: 500;
    white-space: nowrap;
    padding: 0.3rem 0.75rem;
    background: var(--color-cream);
    border-radius: 20px;
    border: 1px solid var(--color-cream-dark);
}

.btn-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


/* ── Upgrade Banner ──────────────────────────────── */
.upgrade-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 1;
}

.upgrade-banner-text {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.premium-banner {
    position: fixed;
    top: 70px;
    left: 1rem;
    margin-bottom: 0;
    padding: 0.6rem 1rem;
    border-color: rgba(196, 154, 60, 0.3);
    background: linear-gradient(135deg, rgba(196, 154, 60, 0.06) 0%, var(--color-surface) 100%);
    z-index: 50;
    width: auto;
}

.support-card {
    position: fixed;
    top: 70px;
    left: 1rem;
    z-index: 50;
    padding: 0.65rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    max-width: 260px;
}
.support-card-icon { font-size: 1.3rem; line-height: 1; flex-shrink: 0; }
.support-card-text { display: flex; flex-direction: column; gap: 0.15rem; line-height: 1.4; }
.support-card-text strong { color: var(--color-text); font-size: 0.82rem; }
.support-card-text a { color: var(--color-trail); text-decoration: none; }
.support-card-text a:hover { text-decoration: underline; }

.btn-upgrade {
    background: linear-gradient(135deg, #c49a3c 0%, #a6832e 100%);
    color: white;
    padding: 0.5rem 1.5rem;
    font-size: 0.85rem;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(196,154,60,0.3);
    border-radius: 8px;
}
.btn-upgrade:hover {
    box-shadow: 0 6px 20px rgba(196,154,60,0.4);
    transform: translateY(-1px);
}

/* ── Upgrade Modal ──────────────────────────────── */
.upgrade-modal {
    max-width: 440px;
}

.upgrade-price {
    text-align: center;
    margin-bottom: 1.25rem;
}

.upgrade-price-amount {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--color-text);
}

.upgrade-price-period {
    font-size: 1rem;
    color: var(--color-text-muted);
    font-weight: 500;
    margin-left: 0.25rem;
}

.upgrade-features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.upgrade-feature {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
}

.upgrade-feature-icon {
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.upgrade-feature strong {
    display: block;
    font-size: 0.92rem;
    color: var(--color-text);
    margin-bottom: 0.15rem;
}

.upgrade-feature p {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.4;
}

/* ── Animations ───────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes progressGrow {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

/* ── Dashboard Trail Cards ─────────────────────────── */
.trail-list { display: flex; flex-direction: column; gap: 0.85rem; }

.trail-card-wrap {
    position: relative;
    display: flex;
    align-items: stretch;
    animation: fadeInUp 0.4s ease-out both;
}
.trail-card-wrap:nth-child(1) { animation-delay: 0s; }
.trail-card-wrap:nth-child(2) { animation-delay: 0.06s; }
.trail-card-wrap:nth-child(3) { animation-delay: 0.12s; }
.trail-card-wrap:nth-child(4) { animation-delay: 0.18s; }
.trail-card-wrap:nth-child(5) { animation-delay: 0.24s; }
.trail-card-wrap:nth-child(6) { animation-delay: 0.3s; }
.trail-card-wrap:nth-child(n+7) { animation-delay: 0.36s; }

.trail-settings-btn,
.trail-remove-btn {
    position: absolute;
    top: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(4px);
    color: var(--color-text-light);
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 2;
    opacity: 0;
}
.trail-remove-btn { right: 10px; font-size: 1.2rem; }
.trail-settings-btn { right: 42px; font-size: 0.95rem; }
.trail-hide-btn { right: 74px; font-size: 0.85rem; }

.trail-card-wrap:hover .trail-remove-btn,
.trail-card-wrap:hover .trail-settings-btn,
.trail-card-wrap:hover .trail-hide-btn { opacity: 1; }
.trail-remove-btn:hover {
    background: rgba(199,69,59,0.1);
    color: var(--color-danger);
    transform: scale(1.1);
}
.trail-settings-btn:hover {
    background: rgba(58,107,78,0.1);
    color: var(--color-trail);
    transform: scale(1.1);
}
.trail-hide-btn:hover {
    background: rgba(100,100,200,0.1);
    color: #555;
    transform: scale(1.1);
}

/* ── Hidden Trails Section ──────────────────────────── */
.hidden-trails-section {
    margin-top: 1.5rem;
}
.hidden-trails-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.55rem 1rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: var(--radius);
    font-family: inherit;
    width: 100%;
    text-align: left;
    box-sizing: border-box;
}
.hidden-trails-toggle:hover { color: var(--color-text); background: var(--color-trail-bg); }
.hidden-trails-chevron { transition: transform 0.2s; margin-left: auto; font-size: 0.7rem; }
.hidden-trails-toggle.open .hidden-trails-chevron { transform: rotate(180deg); }
.hidden-trails-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.4rem 0 0;
}
.hidden-trail-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.hidden-trail-name { font-weight: 500; flex: 1; color: var(--color-text); }
.hidden-trail-pct { color: var(--color-text-muted); font-size: 0.8rem; }
.hidden-trail-show-btn {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: all 0.15s;
}
.hidden-trail-show-btn:hover { background: var(--color-trail-bg); color: var(--color-trail); }

/* ── Add All Trails footer ──────────────────────────── */
.add-trail-footer {
    padding: 0.6rem;
    border-top: 1px solid var(--color-border-light);
}
.add-all-btn {
    width: 100%;
    font-size: 0.82rem;
    padding: 0.45rem 0.75rem;
}

.trail-card-wrap .trail-card { flex: 1; }

.trail-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
}
.trail-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--color-trail) 0%, var(--color-trail-light) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}
.trail-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: rgba(58,107,78,0.2);
    text-decoration: none;
}
.trail-card:hover::before { opacity: 1; }

.trail-card-body { flex: 1; min-width: 0; }

.trail-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
}
.trail-card-header h2 {
    font-size: 1.1rem;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.trail-length {
    color: var(--color-text-light);
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    background: var(--color-cream);
    padding: 0.15rem 0.6rem;
    border-radius: 12px;
}

.trail-card-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

/* Circular progress ring on trail cards */
.trail-card-ring {
    position: relative;
    width: 68px;
    height: 68px;
    flex-shrink: 0;
}

.progress-ring {
    width: 68px;
    height: 68px;
    transform: rotate(-90deg);
}

.progress-ring circle:first-child {
    stroke: var(--color-cream);
}
.progress-ring circle:last-child {
    transition: stroke-dasharray 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    stroke: var(--color-trail);
    filter: drop-shadow(0 0 3px var(--color-trail-glow));
}

.ring-pct {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--color-trail);
}

/* ── Progress Bars ─────────────────────────────────── */
.progress-bar-container {
    background: var(--color-cream);
    border-radius: 6px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    position: relative;
}
.progress-bar-container.large {
    height: 20px;
    border-radius: 10px;
    overflow: visible;
    background: var(--color-cream-dark);
}

.progress-bar {
    background: linear-gradient(90deg, var(--color-trail) 0%, var(--color-trail-light) 60%, #5ca872 100%);
    height: 100%;
    border-radius: inherit;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-width: 0;
}

.progress-bar-container.large .progress-bar {
    border-radius: 10px;
    box-shadow: 0 2px 8px var(--color-trail-glow);
    transform-origin: left;
    animation: progressGrow 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: white;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.progress-label.outside {
    color: var(--color-text-muted);
    position: absolute;
    right: auto;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    text-shadow: none;
}

/* ── Stats Row ─────────────────────────────────────── */
.stats-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}
.stat-card {
    flex: 1;
    min-width: 140px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    text-align: center;
    box-shadow: var(--shadow-xs);
    transition: all 0.25s;
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
    letter-spacing: -0.02em;
}
.stat-value.accent { color: var(--color-trail); }
.stat-label {
    font-size: 0.72rem;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-top: 0.3rem;
}

/* ── Trail Map ─────────────────────────────────────── */
.map-wrap {
    position: relative;
    margin-bottom: 2rem;
    cursor: pointer;
}
.map-wrap.map-expanded {
    position: fixed;
    inset: 0;
    z-index: 2000;
    margin: 0;
    padding: 0;
    cursor: default;
    background: #000;
}
.map-wrap.map-expanded .trail-map {
    height: 100dvh;
    border-radius: 0;
    border: none;
}

.trail-map {
    height: 420px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.map-close-btn {
    display: none;
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2100;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(6px);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    box-shadow: var(--shadow-md);
}
.map-close-btn:hover { background: #fff; }
.map-wrap.map-expanded .map-close-btn { display: block; }

.map-legend {
    display: flex;
    gap: 1.25rem;
    padding: 0.5rem 0.85rem;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 10px;
    border: 1px solid rgba(221,213,197,0.6);
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 800;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    box-shadow: var(--shadow-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-swatch {
    width: 14px;
    height: 4px;
    border-radius: 2px;
    display: inline-block;
}

/* ── Tables ────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    font-size: 0.88rem;
}
th, td { padding: 0.75rem 1rem; text-align: left; }
th {
    background: var(--color-cream-light);
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border);
}
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: var(--color-cream-light); }
tr:not(:last-child) td { border-bottom: 1px solid var(--color-border-light); }

/* ── Activities Table ──────────────────────────────── */
.activities-table a {
    color: var(--color-strava);
    text-decoration: none;
    font-weight: 500;
}
.activities-table a:hover { text-decoration: underline; }
.activities-table a::after {
    content: '\2197';
    font-size: 0.7em;
    margin-left: 0.3em;
    opacity: 0.5;
}

/* ── Segments Table & Join UI ──────────────────────── */
.section-hint {
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-bottom: 0.75rem;
    font-style: italic;
}

.seg-checkbox {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--color-trail);
}

.gap-cell {
    color: var(--color-text-light);
    font-size: 0.85rem;
}

.join-panel {
    margin-top: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--color-trail-bg);
    border-radius: var(--radius);
    border: 1px solid #b5d8b5;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    animation: slideDown 0.25s ease-out;
    box-shadow: 0 2px 8px rgba(58,107,78,0.06);
}
.join-panel p { font-size: 0.9rem; color: var(--color-text); }
.join-panel .btn {
    margin-top: 0;
    padding: 0.45rem 1.25rem;
    font-size: 0.85rem;
}
.join-panel .btn:disabled { opacity: 0.4; cursor: not-allowed; }
.join-error { color: var(--color-danger); font-size: 0.85rem; font-weight: 500; }

/* ── Section Headers with Actions ──────────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 2.5rem 0 0.5rem;
}
.section-header h2 { margin: 0; }
.section-count {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    font-weight: 500;
    background: var(--color-cream);
    padding: 0.2rem 0.65rem;
    border-radius: 12px;
}

/* ── Empty States ──────────────────────────────────── */
.empty-state {
    text-align: left;
    padding: 1.2rem 1.5rem;
    color: var(--color-text-muted);
    animation: fadeInUp 0.5s ease-out;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    position: relative;
    max-width: 360px;
}
.empty-state-close {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    background: none;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-light);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}
.empty-state-close:hover { color: var(--color-text); background: var(--color-cream-dark); }
.empty-state-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
    opacity: 0.7;
}
.empty-state p { max-width: 400px; margin: 0; font-size: 0.95rem; line-height: 1.6; }

/* ── Settings Cards ────────────────────────────────── */
.settings-cards {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 0.75rem;
}
.setting-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.2s;
}
.setting-card:hover { box-shadow: var(--shadow-sm); }
.setting-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}
.setting-card > p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 0.85rem;
}
.setting-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}
.setting-status {
    font-size: 0.85rem;
    margin-top: 0.5rem;
}
.setting-status.success { color: var(--color-trail); font-weight: 500; }
.setting-status.error { color: var(--color-danger); font-weight: 500; }

.date-input {
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.date-input:focus {
    outline: none;
    border-color: var(--color-trail);
    box-shadow: 0 0 0 3px rgba(58,107,78,0.1);
}

.btn-danger {
    background: linear-gradient(135deg, #c7453b 0%, #a83830 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(199,69,59,0.2);
}
.btn-danger:hover {
    box-shadow: 0 4px 14px rgba(199,69,59,0.3);
    transform: translateY(-1px);
}
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Forms ─────────────────────────────────────────── */
.form-card {
    max-width: 500px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 0.3rem;
    color: var(--color-text);
}
.form-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1.5px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    outline: none;
    border-color: var(--color-trail);
    box-shadow: 0 0 0 3px rgba(58,107,78,0.1);
}

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30,51,41,0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.15s ease-out;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 440px;
    animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border-light);
}
.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}
.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--color-cream);
    border-radius: 8px;
    font-size: 1.1rem;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.modal-close:hover {
    background: var(--color-cream-dark);
    color: var(--color-text);
}

.modal-body {
    padding: 1.25rem 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-cream-light);
}

/* Radio options in modal */
.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}
.radio-option:last-of-type { margin-bottom: 0; }
.radio-option:hover { border-color: var(--color-text-light); }
.radio-option.selected {
    border-color: var(--color-trail);
    background: var(--color-trail-bg);
    box-shadow: 0 0 0 3px rgba(58,107,78,0.08);
}

.radio-option input[type="radio"] {
    accent-color: var(--color-trail);
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
}

.radio-option-content { flex: 1; }
.radio-option-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text);
    display: block;
    margin-bottom: 0.15rem;
}
.radio-option-desc {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.modal-date-wrap {
    margin-top: 0.75rem;
    padding-left: 2.5rem;
    animation: slideDown 0.2s ease-out;
}

/* ── Activity type selector ────────────────────────── */
.activity-type-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}
.activity-type-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}
.activity-type-groups {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}
.act-group-btn {
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-light);
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.act-group-btn:hover { border-color: var(--color-trail); color: var(--color-trail); }
.act-group-btn-active {
    background: var(--color-trail);
    color: #fff;
    border-color: var(--color-trail);
}
.activity-type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem 1rem;
}
.act-type-cb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--color-text);
    cursor: pointer;
}
.act-type-cb input[type="checkbox"] {
    accent-color: var(--color-trail);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* ── Admin ─────────────────────────────────────────── */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.admin-header h1 { margin-bottom: 0; }

/* Admin tier toggle (dev only) */
.admin-tier-toggle {
    position: fixed;
    bottom: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.6rem;
    background: var(--color-nav);
    border-radius: 10px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.05);
    z-index: 9999;
    font-size: 0.75rem;
}
.admin-tier-label {
    color: #7a8a78;
    font-weight: 600;
    margin-right: 0.2rem;
}
.tier-btn {
    padding: 0.3rem 0.7rem;
    border: 1px solid #3a5538;
    border-radius: 6px;
    background: transparent;
    color: #8a9a88;
    font-size: 0.75rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.tier-btn:hover { border-color: #5a7a58; color: #b5c5b3; }
.tier-btn-active {
    background: var(--color-trail);
    border-color: var(--color-trail);
    color: white;
}
.tier-btn-active:hover { background: var(--color-trail-light); }

/* ── Unit toggle ───────────────────────────────────── */
.unit-toggle {
    display: inline-flex;
    border: 1px solid var(--color-border);
    border-radius: 5px;
    overflow: hidden;
    margin: 0 0.5rem;
}
.unit-btn {
    padding: 2px 9px;
    font-size: 0.75rem;
    font-family: inherit;
    font-weight: 500;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: background 0.15s, color 0.15s;
}
.unit-btn-active {
    background: var(--color-trail);
    color: #fff;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
    /* Beta badge — tuck below navbar, smaller on mobile */
    .beta-badge {
        top: auto;
        bottom: 1rem;
        right: 1rem;
        font-size: 0.65rem;
        padding: 0.2rem 0.6rem;
    }

    /* Admin toggle — nudge up so it doesn't clash with beta badge */
    .admin-tier-toggle {
        bottom: 56px;
    }
}

@media (max-width: 640px) {
    .navbar { padding: 0 1rem; }
    .container { padding: 1.5rem 1rem; }
    .trails-bg-wrap { display: none; }
    .hero-inner { padding: 3rem 1rem; }
    .hero h1 { font-size: 2.2rem; }
    .hero-logo { width: 90px; height: 90px; border-radius: 18px; }
    .stats-row { gap: 0.5rem; }
    .stat-card { padding: 0.75rem; min-width: 100px; }
    .stat-value { font-size: 1.2rem; }
    .hero-features { gap: 1rem; }
    th, td { padding: 0.5rem 0.6rem; font-size: 0.82rem; }

    .trail-card { flex-direction: column; gap: 0.75rem; }
    .trail-card-ring { align-self: center; }

    .map-legend {
        position: static;
        margin-top: 0.5rem;
        justify-content: center;
        background: transparent;
        border: none;
        box-shadow: none;
        backdrop-filter: none;
    }

    .modal { max-width: 100%; border-radius: var(--radius-lg); }
    .add-trail-dropdown { width: calc(100vw - 2rem); right: -1rem; }

    .dashboard-header { flex-direction: column; gap: 0.75rem; }
    .dashboard-header-right { align-self: stretch; }
    .add-trail-wrap { width: 100%; }
    .add-trail-wrap > .btn { width: 100%; }
    .add-all-btn { width: 100%; }
}

/* Button spinner for async operations */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
    vertical-align: middle;
}
@keyframes btnSpin {
    to { transform: rotate(360deg); }
}
