/* ============================================================
   intervl — design system (from Figma "iai-build")
   ============================================================ */
:root {
    --bg: #1a2b26;          /* main canvas */
    --bg-dark: #121a17;     /* sidebar, cards, chat bar */
    --mint: #3ddc97;        /* primary actions & accents */
    --muted: #a1c9b6;       /* secondary text */
    --light: #e3fcef;       /* near-white w/ green tint */
    --zone-work: #ffb74d;   /* work intervals (orange) */
    --zone-rest: #3a7ca5;   /* recovery intervals (blue) */
    --zone-ramp: #b0beb0;   /* warmup / cooldown (sage) */
    --row-work: rgba(255, 183, 77, 0.3);
    --row-rest: rgba(58, 124, 165, 0.3);
    --row-ramp: rgba(176, 190, 176, 0.3);
    /* TrainerRoad power zones (% of FTP): z1 <55, z2 55-75, z3 76-87,
       z4 88-94, z5 95-105, z6 106-120, z7 >120.
       z1 is deliberately near-neutral so recovery reads as muted by design. */
    --z1: #7d8d85;          /* recovery (slate) */
    --z2: #58aef7;          /* endurance (blue) */
    --z3: #84d68c;          /* tempo (green) */
    --z4: #c9dc57;          /* sweet spot (yellow-green) */
    --z5: #f6e35b;          /* threshold (yellow) */
    --z6: #fb8c1e;          /* VO2 max (orange) */
    --z7: #e84a47;          /* anaerobic (red) */
    --row-z1: rgba(125, 141, 133, 0.3);
    --row-z2: rgba(88, 174, 247, 0.3);
    --row-z3: rgba(132, 214, 140, 0.3);
    --row-z4: rgba(201, 220, 87, 0.3);
    --row-z5: rgba(246, 227, 91, 0.3);
    --row-z6: rgba(251, 140, 30, 0.3);
    --row-z7: rgba(232, 74, 71, 0.3);
    /* 8-point spacing system */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 40px;
    --space-6: 48px;
    --space-7: 56px;
    --space-8: 64px;
    --sidebar-w: 300px;
    --font-display: 'Roboto Condensed', 'Roboto', sans-serif;
    /* Condensed display scale: hero → page → feature → section → panel → label. */
    --type-display-hero: 48px;
    --type-display-hero-line: 1.75em;
    --type-display-page: 32px;
    --type-display-page-line: 40px;
    --type-display-feature: 26px;
    --type-display-feature-line: 32px;
    --type-display-section: 24px;
    --type-display-section-line: 30px;
    --type-display-panel: 20px;
    --type-display-panel-line: 26px;
    --type-display-label: 18px;
    --type-display-label-line: 24px;
    --type-display-tracking: -0.015em;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: 'Roboto', sans-serif;
    background: var(--bg);
    color: #fff;
    font-size: 16px;
    line-height: 24px;
}

/* ============================================================
   Brand launch splash — once per browser session
   ============================================================ */
.brand-splash {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    place-items: center;
    overflow: hidden;
    isolation: isolate;
    cursor: pointer;
    background:
        radial-gradient(circle at 50% 46%, rgba(61, 220, 151, 0.12), transparent 28%),
        radial-gradient(circle at 50% 50%, #1a2b26 0%, #121a17 72%);
}
.show-brand-splash body { overflow: hidden; }
.show-brand-splash .brand-splash { display: grid; }
.brand-splash-glow {
    position: absolute;
    width: min(78vw, 620px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(61, 220, 151, 0.12), rgba(61, 220, 151, 0.025) 42%, transparent 68%);
    filter: blur(12px);
    opacity: 0;
    animation: splash-glow 1.5s cubic-bezier(.2,.75,.2,1) .1s forwards;
}
.brand-splash-lockup {
    position: relative;
    z-index: 1;
    width: min(72vw, 310px);
    display: grid;
    justify-items: center;
}
.brand-splash-mark {
    width: clamp(104px, 17vw, 150px);
    height: auto;
    overflow: visible;
    color: var(--mint);
    filter: drop-shadow(0 0 18px rgba(61, 220, 151, 0.16));
}
.brand-splash-mark path { fill: currentColor; transform-box: fill-box; transform-origin: center; }
.brand-splash-arc {
    opacity: 0;
    transform: translate(-20px, 18px) rotate(-7deg) scale(.88);
    animation: splash-arc .72s cubic-bezier(.16,.84,.32,1) .08s forwards;
}
.brand-splash-bolt {
    opacity: 0;
    transform: translate(12px, -9px) scale(.72);
    animation: splash-bolt .55s cubic-bezier(.18,1.45,.42,1) .48s forwards;
}
.brand-splash-name {
    margin-top: 18px;
    color: var(--light);
    font-family: var(--font-display);
    font-size: clamp(38px, 8vw, 56px);
    font-style: italic;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.04em;
    opacity: 0;
    transform: translateY(12px);
    animation: splash-name .48s cubic-bezier(.2,.8,.2,1) .72s forwards;
}
.brand-splash-line {
    width: min(68vw, 250px);
    height: 2px;
    margin-top: 20px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(227, 252, 239, 0.1);
    opacity: 0;
    animation: splash-line-in .2s ease .92s forwards;
}
.brand-splash-line span {
    display: block;
    width: 42%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, var(--mint), var(--light));
    transform: translateX(-120%);
    animation: splash-charge .78s cubic-bezier(.4,0,.2,1) 1s forwards;
}
.brand-splash-skip {
    position: absolute;
    bottom: max(28px, env(safe-area-inset-bottom));
    color: rgba(161, 201, 182, 0.56);
    font-size: 11px;
    line-height: 16px;
    letter-spacing: .12em;
    text-transform: uppercase;
    opacity: 0;
    animation: splash-name .35s ease 1.1s forwards;
}
.brand-splash.is-leaving { animation: splash-away .42s cubic-bezier(.4,0,.2,1) forwards; }

@keyframes splash-arc {
    0% { opacity: 0; transform: translate(-20px, 18px) rotate(-7deg) scale(.88); }
    55% { opacity: 1; }
    100% { opacity: 1; transform: none; }
}
@keyframes splash-bolt {
    0% { opacity: 0; transform: translate(12px, -9px) scale(.72); }
    70% { opacity: 1; transform: translate(-2px, 2px) scale(1.04); }
    100% { opacity: 1; transform: none; }
}
@keyframes splash-name { to { opacity: 1; transform: none; } }
@keyframes splash-line-in { to { opacity: 1; } }
@keyframes splash-charge { to { transform: translateX(260%); } }
@keyframes splash-glow {
    0% { opacity: 0; transform: scale(.72); }
    45% { opacity: 1; }
    100% { opacity: .55; transform: scale(1.08); }
}
@keyframes splash-away { to { opacity: 0; visibility: hidden; transform: scale(1.025); } }

@media (prefers-reduced-motion: reduce) {
    .brand-splash *, .brand-splash { animation-duration: .01ms !important; animation-delay: 0ms !important; }
    .brand-splash-arc, .brand-splash-bolt, .brand-splash-name, .brand-splash-line { opacity: 1; transform: none; }
    .brand-splash-glow { opacity: .5; }
    .brand-splash-line span { transform: translateX(140%); }
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 700;
    letter-spacing: var(--type-display-tracking);
}

.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at 50% 15%, rgba(61, 220, 151, 0.12), transparent 34%), var(--bg-dark);
}
.auth-gate[hidden] { display: none; }
.auth-card { width: min(440px, 100%); text-align: center; }
.auth-card .logo { display: inline-flex; margin-bottom: 42px; }
.auth-card h1 { margin: 0 0 14px; color: var(--light); font-size: var(--type-display-page); line-height: var(--type-display-page-line); }
.auth-card p { margin: 0 auto 22px; color: var(--muted); font-size: 16px; line-height: 24px; }
.auth-form { display: grid; gap: 12px; text-align: left; }
.auth-form label { display: grid; gap: 5px; }
.auth-form label span { color: var(--muted); font-size: 12px; line-height: 18px; }
.auth-form input {
    width: 100%; height: 48px; padding: 0 13px; border: 1px solid rgba(227, 252, 239, 0.18);
    border-radius: 8px; outline: none; background: var(--bg); color: var(--light); font: inherit;
}
.auth-form input:focus { border-color: var(--mint); }
.auth-submit {
    width: 100%; padding: 13px 18px; border-radius: 999px; background: var(--mint);
    color: var(--bg-dark); font-size: 16px; font-weight: 700;
}
.auth-submit:disabled { opacity: 0.55; cursor: default; }
.auth-error { min-height: 18px; color: #ff9e9e; font-size: 12px; line-height: 18px; }
.auth-mode { margin-top: 10px; color: var(--mint); font-size: 13px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ''; height: 1px; flex: 1; background: rgba(227, 252, 239, 0.12); }
.strava-login {
    display: block;
    width: 100%;
    padding: 14px 18px;
    border-radius: 999px;
    background: #fc4c02;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
}
.strava-login:hover { filter: brightness(1.07); }
.auth-card small { display: block; margin-top: 13px; color: var(--muted); font-size: 12px; }

button {
    font-family: inherit;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
}

input, textarea {
    font-family: inherit;
}

a { color: inherit; }

.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'liga';
}
.material-symbols-outlined.filled { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.icon-16 { font-size: 16px; }
.icon-18 { font-size: 18px; }
.icon-20 { font-size: 20px; }
.icon-28 { font-size: 28px; }
.icon-30 { font-size: 30px; }
.icon-32 { font-size: 32px; }

/* ============================================================
   App shell
   ============================================================ */
.app {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-dark);
    padding: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    transition: margin-left 0.25s ease, transform 0.25s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app.sidebar-collapsed .sidebar {
    margin-left: calc(var(--sidebar-w) * -1);
}

.sidebar-backdrop { display: none; }

.sidebar-primary {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

/* Library bar */
.library-bar {
    background: var(--bg);
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1);
    width: 100%;
    cursor: pointer;
}
.library-bar:hover { filter: brightness(1.1); }

.library-thumb {
    width: var(--space-8);
    height: var(--space-8);
    border-radius: 5px;
    background: linear-gradient(135deg, #f9d423 0%, #e14fad 55%, #8b2fc9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.library-info { min-width: 0; text-align: left; }

.library-info .title { font-size: 16px; line-height: 24px; }
.library-info .meta {
    font-size: 12px;
    line-height: 16px;
    display: flex;
    gap: 5px;
    align-items: center;
    white-space: nowrap;
}

/* Chat history */
.chat-history {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
#chatSessions {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.chat-history h2 {
    font-size: var(--type-display-label);
    line-height: var(--type-display-label-line);
    font-weight: 700;
    margin: 0;
}

.chat-item {
    position: relative;
    width: 100%;
    border-radius: 5px;
}
.chat-item:hover,
.chat-item.active,
.chat-item.menu-open { background: var(--bg); }
.chat-chip {
    display: flex;
    align-items: center;
    padding: 5px 42px 5px 10px;
    border-radius: 5px;
    width: 100%;
    text-align: left;
    cursor: pointer;
}
.chat-chip-copy { min-width: 0; }
.chat-chip .title {
    font-size: 16px;
    line-height: 24px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-chip .meta {
    font-size: 12px;
    line-height: 16px;
    display: flex;
    gap: 9px;
    align-items: center;
}
.chat-history .empty {
    color: var(--muted);
    font-size: 13px;
    padding: 0 10px;
}
.chat-row-menu-btn {
    position: absolute;
    top: 50%;
    right: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 5px;
    color: var(--muted);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%);
}
.chat-item:hover .chat-row-menu-btn,
.chat-item:focus-within .chat-row-menu-btn,
.chat-item.menu-open .chat-row-menu-btn { opacity: 1; pointer-events: auto; }
.chat-row-menu-btn:hover { color: var(--light); background: rgba(227, 252, 239, 0.08); }
.chat-row-menu {
    position: absolute;
    top: calc(100% - 2px);
    right: 3px;
    z-index: 55;
    display: none;
    width: 150px;
    padding: 6px;
    border: 1px solid rgba(227, 252, 239, 0.12);
    border-radius: 8px;
    background: var(--bg-dark);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
}
.chat-item.menu-open .chat-row-menu { display: block; }
.chat-row-menu button { width: 100%; padding: 10px 11px; border-radius: 5px; color: var(--light); text-align: left; font-size: 14px; }
.chat-row-menu button:hover { background: var(--bg); }

/* ---------- Main column ---------- */
/* ============================================================
   Design system: buttons
   One pill-shaped .btn; icons lead or trail purely by markup
   order. Variants: -primary (mint fill), -secondary (outline),
   -ghost (text), -danger (red outline). Sizes: default, -sm,
   -icon (round, icon only).
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: var(--light);
    background: none;
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}
.btn .icon { font-size: 18px; }
.btn-primary { background: var(--mint); color: var(--bg-dark); }
.btn-primary:hover { background: #58e3a8; }
.btn-secondary { border-color: rgba(227, 252, 239, 0.25); }
.btn-secondary:hover { border-color: var(--mint); color: var(--mint); }
.btn-ghost { padding: 10px 14px; }
.btn-ghost:hover { color: var(--mint); }
.btn-danger { color: #ff8a80; border-color: rgba(255, 138, 128, 0.55); }
.btn-danger:hover { background: rgba(255, 138, 128, 0.12); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-sm .icon { font-size: 16px; }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn:disabled { opacity: 0.4; cursor: default; }

/* ============================================================
   ShareKit modal (share.js) — used on index, recap, and execute
   ============================================================ */
.share-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 320;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.62);
}
.share-modal {
    width: min(460px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--bg-dark);
    border: 1px solid rgba(227, 252, 239, 0.16);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.share-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.share-modal-head h3 { margin: 0; font-size: var(--type-display-panel); line-height: var(--type-display-panel-line); color: var(--light); }
.share-modal-preview {
    width: min(100%, 300px);
    margin: 0 auto 14px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(227, 252, 239, 0.14);
    line-height: 0;
}
.share-modal-preview img { width: 100%; display: block; }
.share-modal-text {
    width: 100%;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--light);
    font: 500 13px/1.55 'Roboto Mono', monospace;
    padding: 10px 12px;
    resize: vertical;
    outline: none;
    margin-bottom: 14px;
}
.share-modal-text:focus { border-color: var(--mint); }
.share-modal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.share-modal-note { margin: 14px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

/* ============================================================
   Page navigation subhead — one shared component rendered once
   above the views (never per-view), so its position never
   shifts between the chat column and the wider library grid.
   ============================================================ */
.page-nav {
    position: sticky;
    top: 72px;
    z-index: 25;
    display: flex;
    align-items: center;
    width: min(1060px, calc(100% - 60px));
    margin: 0 auto;
    min-height: 46px;
    padding: 6px 0;
}
.page-nav[hidden] { display: none; }
.page-nav .btn-ghost { background: var(--bg); }  /* legible while sticky */
.page-nav-actions { margin-left: auto; display: flex; align-items: center; }

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    min-width: 0;
}

.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2) var(--space-3);
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(26, 43, 38, 0.9);
    border-bottom: 1px solid rgba(227, 252, 239, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-family: var(--font-display);
    font-size: 32px;
    font-style: italic;
    line-height: 36px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
    text-decoration: none;
}
.logo .brand-mark {
    width: 31px;
    height: 36px;
    flex: 0 0 auto;
    background: var(--mint);
    -webkit-mask: url('/static/intervl-mark.svg') center / contain no-repeat;
    mask: url('/static/intervl-mark.svg') center / contain no-repeat;
}

.profile-bubble {
    position: absolute;
    right: 24px;
    top: 16px;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background: var(--light);
    color: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}
.profile-bubble:hover { filter: brightness(0.95); }
.profile-bubble { overflow: hidden; }
.profile-bubble img { width: 100%; height: 100%; object-fit: cover; }

/* Stylized initials lockup — the avatar when no Strava photo exists.
   Brand gradient ground, condensed italic initials; the default (no name
   yet) shows the bolt on the same ground. No user uploads. */
.avatar-initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(120% 120% at 20% 15%, rgba(227, 252, 239, 0.28), transparent 42%),
        linear-gradient(135deg, #2fbd82 0%, #1f8f74 55%, #2b5f8f 100%);
    color: #0e1613;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 0 rgba(227, 252, 239, 0.35);
    user-select: none;
}
.avatar-initials.avatar-default .icon { color: rgba(14, 22, 19, 0.85); }

.header-action {
    position: absolute;
    left: 24px;
    top: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--light);
}
.header-action:hover { background: rgba(227, 252, 239, 0.08); }
.menu-button .icon { font-size: 32px; }
.menu-icon-expanded { display: none; }
.menu-button[aria-expanded="true"] .menu-icon-closed { display: none; }
.menu-button[aria-expanded="true"] .menu-icon-expanded { display: inline-block; }

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    line-height: 16px;
    padding: var(--space-2) 0 var(--space-1);
    margin-top: auto;
}
.footer a { color: inherit; text-underline-offset: 3px; }
.footer a:hover { color: var(--light); }

/* ============================================================
   Legal pages
   ============================================================ */
.legal-page {
    min-height: 100dvh;
    background: var(--bg-dark);
    color: var(--light);
}
.legal-topbar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 16px clamp(18px, 4vw, 48px);
    border-bottom: 1px solid rgba(227, 252, 239, 0.1);
    background: rgba(3, 10, 8, 0.94);
    backdrop-filter: blur(12px);
}
.legal-topbar .logo { position: static; transform: none; }
.legal-content {
    width: min(760px, calc(100% - 36px));
    margin: 0 auto;
    padding: clamp(56px, 8vw, 96px) 0 64px;
}
.legal-content > .eyebrow {
    margin: 0 0 8px;
    color: var(--mint);
    font: 700 12px/16px var(--font-mono);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.legal-content h1 {
    margin: 0;
    font-size: clamp(40px, 7vw, 64px);
    line-height: 1;
    letter-spacing: -0.04em;
}
.legal-updated { margin: 16px 0 40px; color: var(--muted); }
.legal-content section {
    padding: 32px 0 0;
    margin-top: 32px;
    border-top: 1px solid rgba(227, 252, 239, 0.1);
}
.legal-content h2 {
    margin: 0 0 12px;
    font: 600 20px/28px var(--font-mono);
}
.legal-content p,
.legal-content li { color: rgba(227, 252, 239, 0.78); font-size: 15px; line-height: 1.75; }
.legal-content p { margin: 0 0 16px; }
.legal-content ul { margin: 0; padding-left: 22px; }
.legal-content li + li { margin-top: 10px; }
.legal-content strong { color: var(--light); }
.legal-content a { color: var(--mint); text-underline-offset: 3px; }
.legal-footer { padding: 0 18px max(24px, env(safe-area-inset-bottom)); }

@media (max-width: 520px) {
    .legal-topbar { min-height: 64px; }
    .legal-content { padding-top: 48px; }
    .legal-content section { padding-top: 24px; margin-top: 24px; }
}

/* ============================================================
   Home (default) view
   ============================================================ */
.home-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: clamp(80px, 22vh, 240px);
    gap: 25px;
}

.home-view h1 {
    font-size: var(--type-display-hero);
    line-height: var(--type-display-hero-line);
    font-weight: 700;
    letter-spacing: -0.25px;
    margin: 0 0 12px;
    text-align: center;
}

/* ---------- Chat bar (pill input) ---------- */
.chat-bar {
    background: var(--bg-dark);
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px;
    width: min(700px, calc(100% - 40px));
}

.chat-bar input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 14px;
    line-height: 20px;
    padding: 0 20px;
    min-width: 0;
}
.chat-bar input::placeholder { color: var(--muted); }
.home-view .chat-bar input { font-size: 17px; }

.chat-send {
    background: var(--mint);
    width: 70px;
    height: 50px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-dark);
    flex-shrink: 0;
}
.chat-send:hover { filter: brightness(1.06); }
.chat-send:disabled { opacity: 0.5; cursor: default; }

/* ---------- Onboarding (confirm data, ask one question) ---------- */
.onboarding-overlay[hidden] { display: none; }
.onboarding-overlay {
    position: fixed;
    inset: 0;
    z-index: 320;
    display: grid;
    place-items: center;
    padding: var(--space-2);
    background: rgba(10, 16, 14, 0.82);
    backdrop-filter: blur(6px);
}
.onboarding-panel {
    width: min(560px, 100%);
    max-height: min(88vh, 720px);
    overflow-y: auto;
    background: var(--bg-dark);
    border: 1px solid rgba(61, 220, 151, 0.25);
    border-radius: 20px;
    padding: var(--space-4);
}
.ob-loading { color: var(--muted); text-align: center; padding: var(--space-5) 0; }
.ob-title {
    margin: 0 0 6px;
    font-size: var(--type-display-feature);
    line-height: var(--type-display-feature-line);
}
.ob-sub { margin: 0 0 var(--space-2); color: var(--muted); font-size: 14px; line-height: 20px; }
.ob-snapshot {
    background: rgba(61, 220, 151, 0.08);
    border: 1px solid rgba(61, 220, 151, 0.25);
    border-radius: 12px;
    padding: 12px 16px;
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    line-height: 19px;
    color: var(--light);
    margin-bottom: var(--space-2);
}
.ob-snapshot-empty { background: none; border-color: rgba(161, 201, 182, 0.25); color: var(--muted); font-family: inherit; }
.ob-snapshot-empty a { color: var(--mint); }
.ob-cards { display: grid; gap: 12px; margin-bottom: var(--space-3); }
.ob-card {
    display: grid;
    grid-template-columns: 84px 1fr;
    grid-template-areas: "label value" "label note";
    align-items: center;
    gap: 2px 16px;
    background: var(--bg);
    border-radius: 14px;
    padding: 14px 18px;
}
.ob-card-label {
    grid-area: label;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 700;
    font-size: var(--type-display-label);
    color: var(--light);
}
.ob-card-value { grid-area: value; display: flex; align-items: baseline; gap: 8px; }
.ob-card-value input {
    width: 88px;
    background: var(--bg-dark);
    border: 1px solid rgba(161, 201, 182, 0.3);
    border-radius: 8px;
    color: #fff;
    font-family: 'Roboto Mono', monospace;
    font-size: 18px;
    padding: 6px 10px;
}
.ob-card-value em { font-style: normal; color: var(--muted); font-size: 13px; }
.ob-card-note { grid-area: note; color: var(--muted); font-size: 12px; line-height: 17px; }
.ob-focus-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: var(--space-2); }
.ob-focus {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 14px;
    background: var(--bg);
    border: 1px solid rgba(161, 201, 182, 0.2);
    border-radius: 14px;
    color: var(--light);
    text-align: left;
    font-size: 14px;
    line-height: 19px;
}
.ob-focus .icon { color: var(--mint); font-size: 26px; }
.ob-focus.selected { border-color: var(--mint); background: rgba(61, 220, 151, 0.1); }
.ob-guess {
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mint);
}
.ob-event { display: flex; align-items: center; justify-content: space-between; gap: 12px;
    color: var(--muted); font-size: 13px; margin-bottom: var(--space-3); }
.ob-event em { font-style: normal; opacity: 0.7; }
.ob-event input {
    background: var(--bg);
    border: 1px solid rgba(161, 201, 182, 0.3);
    border-radius: 8px;
    color: #fff;
    padding: 8px 10px;
    color-scheme: dark;
}
.ob-next { width: 100%; justify-content: center; min-height: 48px; }

@media (max-width: 760px) {
    .onboarding-panel { padding: var(--space-3); }
    .ob-focus-grid { grid-template-columns: 1fr; }
}

/* ---------- Suggestions (coach takeover + rotating example prompts) ---------- */
.suggestions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: min(700px, calc(100% - 40px));
    margin-top: var(--space-2);
}
.suggestions .prompt-chips { width: 100%; }

.coach-pick-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
}

.coach-pick-btn {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 26px 11px 20px;
    border-radius: 999px;   /* design-system pill */
    color: var(--bg-dark);
    background: linear-gradient(120deg, #2fbd82, var(--mint) 45%, #8bf2c6);
    transition: filter 0.2s ease;
}
.coach-pick-btn:hover { filter: brightness(1.05); }
.coach-pick-btn::after {
    /* single shimmer sweep on hover — the "magic" affordance */
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, 0.45) 50%, transparent 68%);
    transform: translateX(-110%);
    pointer-events: none;
}
.coach-pick-btn:hover::after { animation: coach-shimmer 0.9s ease; }
@keyframes coach-shimmer {
    from { transform: translateX(-110%); }
    to { transform: translateX(110%); }
}

.coach-pick-btn .icon { font-size: 24px; }
.coach-pick-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}
.coach-pick-title {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 700;
    font-size: 17px;
    line-height: 20px;
    letter-spacing: var(--type-display-tracking);
}
.coach-pick-sub {
    font-size: 12px;
    line-height: 16px;
    opacity: 0.78;
}

.coach-pick-hard {
    color: var(--light);
    background: linear-gradient(120deg, #24443a, #1c332b 52%, #3a2a1a);
    border: 1px solid rgba(251, 140, 30, 0.55);
    transition: border-color 0.2s ease;
}
.coach-pick-hard .icon { color: var(--z6); }
.coach-pick-hard:hover {
    filter: none;
    border-color: rgba(251, 140, 30, 0.9);
}
.coach-pick-hard::after {
    background: linear-gradient(115deg, transparent 32%, rgba(255, 200, 120, 0.28) 50%, transparent 68%);
}

@media (prefers-reduced-motion: reduce) {
    .coach-pick-btn:hover::after { animation: none; }
}

/* ---------- Suggested prompts ---------- */
/* An h3 subhead: condensed italic comes from the global heading rule. */
.suggested-label {
    margin: 0;
    font-size: var(--type-display-label);
    line-height: var(--type-display-label-line);
}

.prompt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 20px;
    justify-content: center;
    width: min(700px, calc(100% - 40px));
}

.prompt-chip {
    border: 1px solid var(--light);
    border-radius: 999px;   /* design-system pill */
    padding: 10px;
    font-size: 14px;
    line-height: 20px;
    color: #fff;
    white-space: nowrap;
}
.prompt-chip:hover { background: rgba(227, 252, 239, 0.08); }

/* Mobile-only progressive disclosure for the chips (see 760px block). */
.chips-more { display: none; }

/* ============================================================
   Chat (conversation) view
   ============================================================ */
.chat-view {
    flex: 1;
    display: none;
    flex-direction: column;
    width: min(700px, calc(100% - 40px));
    margin: 0 auto;
    padding: 10px 0 120px;   /* the shared .page-nav above carries the top gap */
    gap: 20px;
}

.chat-view.visible { display: flex; }
.app.in-chat .home-view { display: none; }

.chat-workout-stage {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.chat-workout-stage:not(:empty)::before,
.chat-section-label {
    color: var(--muted);
    font-family: 'Roboto Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    line-height: 16px;
    text-transform: uppercase;
}

.chat-workout-stage:not(:empty)::before { content: 'Current workout'; }

.chat-conversation {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 4px;
    border-top: 1px solid rgba(227, 252, 239, 0.1);
}

.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Chat's ⋯ menu wrapper — lives in the shared .page-nav actions slot */
.chat-page-actions {
    position: relative;
    display: flex;
    align-items: center;
}
.chat-details-btn { display: flex; align-items: center; justify-content: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%; color: var(--muted); }
.chat-details-btn:hover,
.chat-page-actions.menu-open .chat-details-btn { color: var(--light); background: rgba(227, 252, 239, 0.08); }
.chat-details-menu {
    position: absolute;
    top: calc(100% - 3px);
    right: 0;
    display: none;
    width: 180px;
    padding: 6px;
    border: 1px solid rgba(227, 252, 239, 0.12);
    border-radius: 8px;
    background: var(--bg-dark);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
}
.chat-page-actions.menu-open .chat-details-menu { display: block; }
.chat-details-menu button { width: 100%; padding: 10px 11px; border-radius: 5px; color: var(--light); text-align: left; font-size: 14px; }
.chat-details-menu button:hover { background: var(--bg); }
.chat-details-menu button.danger { color: #ff8a80; }

.msg-user {
    align-self: flex-end;
    background: var(--bg-dark);
    border-radius: 7px;
    padding: 10px 15px;
    max-width: 80%;
    font-size: 16px;
    line-height: 24px;
}

.msg-assistant {
    align-self: flex-start;
    padding: 10px 15px;
    max-width: 80%;
    font-size: 16px;
    line-height: 24px;
}

.msg-assistant:not(.thinking) {
    border-left: 2px solid rgba(123, 239, 178, 0.7);
}

.msg-assistant.has-action {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.undo-refinement {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 38px;
    padding: 7px 11px;
    border: 1px solid rgba(227, 252, 239, 0.35);
    border-radius: 999px;
    color: var(--light);
    font-size: 14px;
    font-weight: 600;
    line-height: 18px;
}
.undo-refinement:hover { background: rgba(227, 252, 239, 0.08); }
.undo-refinement:disabled { opacity: 0.5; cursor: default; }

.msg-assistant.thinking { color: var(--muted); }
.msg-assistant.thinking .dots::after {
    content: '';
    animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

.msg-error {
    background: rgba(244, 67, 54, 0.15);
    color: #ff8a80;
    border-radius: 7px;
    padding: 10px 15px;
    font-size: 14px;
}

/* Refine bar pinned at bottom of chat view */
.refine-dock {
    position: fixed;
    bottom: var(--space-4);
    left: var(--sidebar-w);
    right: 0;
    display: none;
    justify-content: center;
    pointer-events: none;
    z-index: 30;
    transition: left 0.25s ease;
}
.app.sidebar-collapsed .refine-dock { left: 0; }
.app.in-chat .refine-dock { display: flex; }
.refine-dock .chat-bar {
    pointer-events: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   Workout card
   ============================================================ */
.workout-card {
    background: var(--bg-dark);
    border-radius: 7px;
    padding: 15px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.workout-card .card-title {
    font-size: var(--type-display-feature);
    line-height: var(--type-display-feature-line);
    font-weight: 700;
    padding: 0 15px;
    margin: 0;
}

/* ----- power graph ----- */
.power-graph {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 5px;
    padding: 10px 0 0;
    height: 140px;
}

.power-graph .bar {
    border-radius: 3px;
    min-height: 8px;
    position: relative;
}
.power-graph .bar.work { background: var(--zone-work); }
.power-graph .bar.rest { background: var(--zone-rest); }
.power-graph .bar.ramp-up {
    background: var(--zone-ramp);
    border-radius: 0;
    clip-path: polygon(0 100%, 100% 0, 100% 100%);
}
.power-graph .bar.ramp-down {
    background: var(--zone-ramp);
    border-radius: 0;
    clip-path: polygon(0 0, 100% 100%, 0 100%);
}

/* zone-colored bars */
.bar.z1 { --zone-c: var(--z1); }
.bar.z2 { --zone-c: var(--z2); }
.bar.z3 { --zone-c: var(--z3); }
.bar.z4 { --zone-c: var(--z4); }
.bar.z5 { --zone-c: var(--z5); }
.bar.z6 { --zone-c: var(--z6); }
.bar.z7 { --zone-c: var(--z7); }
.power-graph .bar.z1, .power-graph .bar.z2, .power-graph .bar.z3,
.power-graph .bar.z4, .power-graph .bar.z5, .power-graph .bar.z6,
.power-graph .bar.z7 {
    background: var(--zone-c);
}
/* clickable bars open the interval edit modal */
.power-graph .bar.clickable { cursor: pointer; }
.power-graph .bar.clickable:hover {
    filter: brightness(1.18);
    z-index: 100;
}

/* ramps: clip the slope on an inner shape so the hover tooltip isn't clipped */
.power-graph .bar.ramp {
    background: transparent;
    border-radius: 0;
}
.power-graph .bar.ramp .ramp-shape {
    display: block;
    position: absolute;
    inset: 0;
    background: var(--zone-c);
}

.power-graph .bar .tip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 6px;
    background: var(--bg);
    color: var(--light);
    font-size: 12px;
    line-height: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 101;
}
.power-graph .bar:hover .tip { display: flex; align-items: center; gap: 5px; }
.power-graph .tip-edit {
    display: inline-flex;
    color: var(--muted);
}
.power-graph .tip-edit .icon {
    font-size: 14px;
}

.ftp-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 2px dashed #fff;
    pointer-events: none;
}

/* ----- FTP row ----- */
.ftp-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 15px;
    font-size: 16px;
    font-weight: 600;
    line-height: 20px;
}
.ftp-row .dash {
    width: 47px;
    border-top: 2px dashed #fff;
}
.ftp-row .edit-btn { color: #fff; display: flex; }
.ftp-row .edit-btn:hover { color: var(--mint); }

/* ----- meta chips ----- */
.meta-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 15px;
}
.meta-chip {
    background: var(--light);
    color: var(--bg-dark);
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    font-size: 16px;
    font-weight: 600;
    line-height: 20px;
}

/* ----- description ----- */
.card-desc {
    padding: 7px 15px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.card-desc p { margin: 0; font-size: 16px; line-height: 24px; }
.card-desc .read-more {
    align-self: center;
    font-size: 14px;
    line-height: 20px;
    text-decoration: underline;
    color: #fff;
}
.card-desc .read-more:hover { color: var(--mint); }

/* ----- interval bar list ----- */
.interval-list { position: relative; }
.interval-rows {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 0 15px;
    overflow: hidden;
    position: relative;
}
.interval-list.clipped .interval-rows { max-height: 98px; }
.interval-list.clipped .fade {
    position: absolute;
    left: 0; right: 0; bottom: 34px;
    height: 30px;
    background: linear-gradient(to bottom, transparent, var(--bg-dark));
    pointer-events: none;
}
.interval-list:not(.clipped) .fade { display: none; }

.interval-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--space-1);
    padding: 5px 15px;
    min-height: 29px;
    font-size: 14px;
    line-height: 20px;
    color: var(--light);
}
.interval-row.work { background: var(--row-work); }
.interval-row.rest { background: var(--row-rest); }
.interval-row.ramp { background: var(--row-ramp); }
.interval-row.z1 { background: var(--row-z1); }
.interval-row.z2 { background: var(--row-z2); }
.interval-row.z3 { background: var(--row-z3); }
.interval-row.z4 { background: var(--row-z4); }
.interval-row.z5 { background: var(--row-z5); }
.interval-row.z6 { background: var(--row-z6); }
.interval-row.z7 { background: var(--row-z7); }
.interval-row .power {
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}
.interval-row .row-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.interval-row .row-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s, color 0.15s;
}
.interval-row .row-edit .icon { font-size: 15px; }
.interval-row:hover .row-edit { opacity: 1; }
.interval-row .row-edit:hover { color: var(--mint); }

.interval-set {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    border-radius: var(--space-1);
}
.interval-set .interval-row { border-radius: 0; }
.repeat-badge {
    position: absolute;
    z-index: 2;
    left: 60%;
    top: 50%;
    min-width: var(--space-6);
    height: var(--space-4);
    padding: 0 var(--space-2);
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--space-2);
    background: var(--light);
    color: var(--bg-dark);
    font-family: 'Roboto Mono', monospace;
    font-size: 16px;
    line-height: 1;
    font-weight: 800;
    pointer-events: none;
}

/* ----- ride history on the workout card ----- */
.ride-history {
    margin-top: 14px;
    padding: 10px 15px;
    background: rgba(61, 220, 151, 0.07);
    border: 1px solid rgba(61, 220, 151, 0.18);
    border-radius: 5px;
}
.history-head {
    font-size: 13px;
    font-weight: 600;
    color: var(--mint);
    margin-bottom: 6px;
}
.history-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 13px;
    line-height: 22px;
    color: var(--light);
}
.history-row .h-date { color: var(--muted); flex-shrink: 0; }
.history-row .h-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.history-row .h-stats { margin-left: auto; color: var(--muted); white-space: nowrap; }
.history-row.linked { cursor: pointer; border-radius: 5px; padding: 0 4px; margin: 0 -4px; }
.history-row.linked:hover { background: rgba(61, 220, 151, 0.08); }
.history-row.linked:hover .h-title { color: var(--mint); }
.history-row .h-go { color: var(--muted); flex-shrink: 0; align-self: center; }
.history-more { font-size: 12px; color: var(--muted); margin-top: 3px; }

.lib-rides { color: var(--mint); }

.toggle-intervals {
    display: block;
    margin: 0 auto;
    padding: 10px 0;
    font-size: 14px;
    line-height: 20px;
    color: #fff;
    text-decoration: underline;
}
.toggle-intervals:hover { color: var(--mint); }

/* ----- action bar ----- */
.action-bar {
    background: var(--bg);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 10px;
    gap: 10px;
}
.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    line-height: 20px;
    color: #fff;
    padding: 9px 12px;
    border-radius: 999px;   /* design-system pill */
}
.action-btn:hover { color: var(--mint); }
.action-btn.save-action.saved { color: var(--mint); }
.action-btn.save-action.saved:hover { background: rgba(61, 220, 151, 0.08); }
.action-btn.primary {
    background: var(--mint);
    color: var(--bg-dark);
}
.action-btn.primary:hover { color: var(--bg-dark); filter: brightness(1.06); }

/* ============================================================
   Modal (FTP / profile)
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--bg-dark);
    border-radius: 7px;
    padding: 30px;
    width: min(420px, calc(100% - 40px));
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.modal h2 { margin: 0; font-size: var(--type-display-panel); line-height: var(--type-display-panel-line); font-weight: 700; }
.modal p { margin: 0; color: var(--muted); font-size: 14px; line-height: 20px; }
.modal input {
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 5px;
    color: #fff;
    font-size: 16px;
    padding: 12px 15px;
    outline: none;
}
.modal input:focus { border-color: var(--mint); }
.modal .modal-save {
    background: var(--mint);
    color: var(--bg-dark);
    font-weight: 600;
    border-radius: 5px;
    padding: 12px;
}

/* interval edit modal fields */
.modal .field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.modal .field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.modal .field span {
    font-size: 13px;
    color: var(--muted);
}
.modal .field input { width: 100%; }
.modal .field[hidden] { display: none; }
.modal .check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--light);
    cursor: pointer;
    user-select: none;
}
.modal .check-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--mint);
    cursor: pointer;
}
.modal .field-hint {
    margin: -3px 0 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--muted);
    opacity: 0.85;
}
.modal-confirm {
    background: var(--mint);
    color: var(--bg-dark);
    font-weight: 600;
}
.modal-confirm:hover { filter: brightness(1.06); }
.modal-confirm.danger { background: #d94b4b; color: #fff; }
.modal-confirm:disabled { opacity: 0.55; cursor: default; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--light);
    color: var(--bg-dark);
    font-size: 14px;
    font-weight: 500;
    border-radius: 25px;
    padding: 8px 18px;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
}
.toast.show { opacity: 1; }

/* ============================================================
   Workout library view
   ============================================================ */
.app.in-library .home-view,
.app.in-library .chat-view,
.app.in-library .refine-dock,
.app.in-routes .home-view,
.app.in-routes .chat-view,
.app.in-routes .refine-dock { display: none !important; }

.library-view {
    display: none;
    flex: 1;
    width: min(1060px, calc(100% - 60px));
    margin: 0 auto;
    padding: 10px 0 80px;   /* the shared .page-nav above carries the top gap */
}
.app.in-library #libraryView,
.app.in-routes #routeView { display: block; }

.route-bar { margin-top: -6px; }
.route-thumb { background: linear-gradient(145deg, #ef6c35, #c7471c); }
.route-library-head { align-items: center; justify-content: space-between; }
.route-library-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.route-library-actions { display: flex; align-items: center; gap: 10px; }
.route-sort-label { color: var(--muted); font-size: 13px; }
.route-status { color: var(--muted); font-size: 14px; margin: -12px 0 22px; }

/* Route library sections: intervl routes in one scrollable row, Strava
   routes in the grid below, each under its own sub-heading. */
.route-section-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin: 28px 0 14px;
}
.route-section-head:first-of-type { margin-top: 4px; }
.route-section-head h2 {
    font-size: var(--type-display-section);
    line-height: var(--type-display-section-line);
    font-weight: 700;
    letter-spacing: -0.1px;
    margin: 0;
}
.route-sync-note { color: var(--muted); font-size: 12px; }
.route-section-head .route-library-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.route-carousel-nav { margin-left: auto; display: flex; gap: 8px; }
.route-carousel-nav[hidden] { display: none; }
.route-row {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: thin;
}
.route-row .lib-card { flex: 0 0 280px; }
.route-empty { color: var(--muted); font-size: 14px; padding: 4px 0 8px; grid-column: 1 / -1; }
.route-card { overflow: hidden; }
.route-card-main { display: flex; flex-direction: column; gap: 12px; text-align: left; margin: -16px -16px 0; padding: 0 16px 4px; color: inherit; cursor: pointer; flex: 1; }
.route-card-main:hover .route-details-link { color: var(--mint); }
.route-card-art { height: 100px; margin: -16px -16px 0; display: block; overflow: hidden; color: var(--mint); background: radial-gradient(circle at 68% 22%, #263c34, #121c18 68%); }
.route-card-art svg { width: 100%; height: 100%; display: block; }
.route-cover-road { fill: none; stroke: rgba(184,206,196,.1); stroke-width: 2; }
.route-cover-road.road-b { stroke-width: 1; }
.route-cover-road.road-c { stroke: rgba(184,206,196,.07); stroke-width: 3; }
.route-cover-shadow { fill: none; stroke: rgba(0,0,0,.6); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.route-cover-line { fill: none; stroke: var(--mint); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.route-cover-start { fill: #fff; stroke: #121a17; stroke-width: 2; }
.route-cover-finish { fill: var(--mint); stroke: #121a17; stroke-width: 2; }
.route-cover-empty { fill: none; stroke: rgba(61,220,151,.7); stroke-width: 3; }
.route-cover-empty-dot { fill: rgba(61,220,151,.7); }
.route-card-copy { flex: 1; }
.route-card-title-row { display: flex; gap: 8px; align-items: flex-start; }
.route-provider { flex-shrink: 0; margin-top: 2px; border: 1px solid rgba(61,220,151,.3); border-radius: 10px; padding: 2px 6px; color: var(--mint); font-size: 8px; font-weight: 700; letter-spacing: .08em; }
.route-star { color: #f6c453; flex-shrink: 0; }
.route-description { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 18px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.route-card-stats { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 12px; }
.route-details-link { color: var(--light); font-size: 12px; font-weight: 600; transition: color .15s; }
.route-start { margin-left: auto; border-radius: 18px; padding: 8px 14px; }
.route-start:disabled { opacity: .55; }
.route-picker-modal { width: min(620px, calc(100vw - 32px)); }
.launch-step { color: var(--mint); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.route-picker-sync { display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid rgba(61,220,151,.18); border-radius: 8px; padding: 11px 12px; background: rgba(61,220,151,.045); }
.route-picker-sync[hidden] { display: none; }
.route-picker-sync span, .route-picker-sync strong, .route-picker-sync small { display: block; }
.route-picker-sync strong { color: var(--light); font-size: 13px; }
.route-picker-sync small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.route-picker-sync .profile-secondary { flex-shrink: 0; text-decoration: none; text-align: center; }
.route-picker-list { display: grid; gap: 20px; max-height: min(520px, 58vh); overflow-y: auto; margin-top: 18px; padding-right: 3px; }
.route-picker-group { display: grid; gap: 10px; }
.route-picker-heading { display: block; padding: 0 2px; }
.route-picker-heading strong, .route-picker-heading small { display: block; }
.route-picker-heading strong { color: var(--light); font-size: 13px; }
.route-picker-heading small { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 16px; }
.route-picker-group-empty { border: 1px dashed rgba(227,252,239,.13); border-radius: 8px; padding: 16px 12px; color: var(--muted); font-size: 12px; text-align: center; }
.route-picker-option { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 12px; min-height: 82px; overflow: hidden; border: 1px solid rgba(227,252,239,.12); border-radius: 8px; background: var(--bg); text-align: left; }
.route-picker-option:hover { border-color: var(--mint); }
.route-picker-option:disabled { opacity: .6; cursor: wait; }
.route-picker-option .route-card-art { width: 120px; height: 82px; margin: 0; }
.route-picker-copy { min-width: 0; padding: 10px 12px 10px 0; }
.route-picker-copy strong, .route-picker-copy small { display: block; }
.route-picker-copy strong { color: var(--light); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-picker-copy strong em { margin-left: 5px; color: var(--mint); font-size: 8px; font-style: normal; letter-spacing: .08em; vertical-align: 2px; }
.route-picker-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 16px; }
.route-picker-empty { padding: 30px 14px; color: var(--muted); text-align: center; }
.lib-route-start { display: flex; align-items: center; gap: 5px; padding: 7px 9px; border: 1px solid rgba(227,252,239,.16); border-radius: 5px; color: var(--light); font-size: 12px; }
.lib-route-start:hover { color: var(--mint); border-color: var(--mint); }

.ride-mode-modal { width: min(620px, calc(100vw - 32px)); }
.ride-mode-featured, .ride-workout-list { display: grid; gap: 9px; }
.ride-mode-option, .ride-workout-option { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; border: 1px solid rgba(227,252,239,.13); border-radius: 9px; padding: 13px; color: var(--light); background: var(--bg); text-align: left; }
.ride-mode-option:hover, .ride-workout-option:hover { border-color: var(--mint); background: rgba(61,220,151,.045); }
.ride-mode-option:disabled, .ride-workout-option:disabled { opacity: .55; cursor: wait; }
.ride-mode-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: var(--bg-dark); background: var(--mint); }
.ride-mode-option strong, .ride-mode-option small, .ride-workout-option strong, .ride-workout-option small { display: block; }
.ride-mode-option strong, .ride-workout-option strong { font-size: 14px; }
.ride-mode-option small, .ride-workout-option small { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 16px; }
.ride-mode-arrow { color: var(--mint); font-size: 18px; }
.ride-mode-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.ride-mode-divider::before, .ride-mode-divider::after { content: ''; height: 1px; flex: 1; background: rgba(227,252,239,.1); }
.ride-workout-list { max-height: min(340px, 38vh); overflow-y: auto; }
.ride-workout-option { grid-template-columns: 106px 1fr auto; padding: 9px; }
.ride-workout-option .power-graph.mini { width: 106px; height: 56px; margin: 0; }
.ride-mode-empty { padding: 18px; border: 1px dashed rgba(227,252,239,.15); border-radius: 8px; color: var(--muted); text-align: center; }
.ride-mode-empty p { margin-bottom: 10px; }

/* Route details — wide dialog on desktop, bottom sheet on phones. */
.route-detail-overlay { position: fixed; inset: 0; z-index: 120; display: flex; justify-content: center; align-items: center; padding: 24px; background: rgba(4,10,8,.76); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s, visibility .2s; }
.route-detail-overlay.open { opacity: 1; visibility: visible; pointer-events: auto; }
.route-detail-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(760px, 100%);
    max-height: min(860px, calc(100vh - 48px));
    overflow: hidden;
    border: 1px solid rgba(227,252,239,.16);
    border-radius: 12px;
    background: var(--bg-dark);
    box-shadow: 0 24px 80px rgba(0,0,0,.42);
    padding: 26px 26px 0;
}
.route-detail-content { flex: 1; overflow-y: auto; padding-bottom: 96px; }
/* CTA pinned over the scroll with a gradient so the seam reads naturally */
.route-detail-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 40px 26px 18px;
    background: linear-gradient(to top, var(--bg-dark) 58%, rgba(18, 26, 23, 0));
    pointer-events: none;
    display: flex;
}
.route-detail-footer[hidden] { display: none; }
.route-detail-footer .btn { width: 100%; pointer-events: auto; padding: 13px 18px; }
.route-detail-loading, .route-detail-error { color: var(--muted); text-align: center; padding: 70px 20px; }
.route-detail-badges { display: flex; gap: 8px; margin-bottom: 14px; }
.route-detail-badges span { border: 1px solid rgba(227,252,239,.16); border-radius: 14px; padding: 4px 9px; color: var(--muted); font-size: 11px; }
.route-detail-description { color: var(--light); font-size: 14px; line-height: 20px; margin: 0 0 18px; }
.route-map { height: 280px; position: relative; overflow: hidden; border: 1px solid rgba(227,252,239,.16); border-radius: 8px; margin-bottom: 14px; background: #18251f; z-index: 0; }
.route-map-fallback { width: 100%; height: 100%; display: block; }
.route-map-fallback-label { position: absolute; right: 9px; bottom: 8px; padding: 3px 6px; border-radius: 4px; color: var(--muted); background: rgba(18,26,23,.85); font-size: 10px; }
.route-map .leaflet-control-attribution { font-size: 9px; }
.route-map .leaflet-control-zoom a { color: #121a17; }
.route-elevation-chart { height: 230px; position: relative; overflow: hidden; border: 1px solid rgba(61,220,151,.16); border-radius: 8px; background: linear-gradient(180deg,rgba(61,220,151,.08),rgba(61,220,151,.015)); }
.route-elevation-chart svg { width: 100%; height: 100%; display: block; }
.route-chart-high, .route-chart-low { position: absolute; left: 10px; padding: 3px 6px; border-radius: 4px; background: rgba(18,26,23,.82); color: var(--light); font-size: 11px; }
.route-chart-high { top: 9px; }
.route-chart-low { bottom: 9px; }
/* elevation hover scrubber: vertical cursor + dot, tooltip, map marker */
.route-elevation-chart { cursor: crosshair; }
.route-chart-cursor {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dashed rgba(227, 252, 239, 0.55);
    pointer-events: none;
}
.route-chart-cursor .dot {
    position: absolute;
    left: -5px;
    top: var(--dot-y, 50%);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #f6e35b;
    border: 2px solid #121a17;
    transform: translateY(-50%);
}
.route-chart-tip {
    position: absolute;
    top: 8px;
    transform: translateX(-50%);
    background: rgba(18, 26, 23, 0.92);
    border: 1px solid rgba(227, 252, 239, 0.18);
    border-radius: 6px;
    padding: 5px 9px;
    font-size: 11px;
    color: var(--light);
    pointer-events: none;
    white-space: nowrap;
    z-index: 2;
}
.route-detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.route-detail-stats span { display: flex; flex-direction: column; gap: 3px; border-radius: 7px; padding: 12px; background: rgba(227,252,239,.045); }
.route-detail-stats strong { font-size: 19px; }
.route-detail-stats small { color: var(--muted); font-size: 11px; }
.route-detail-note { color: var(--muted); font-size: 12px; line-height: 17px; margin: 16px 0; }
.route-detail-ride { width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; }
body.route-detail-open { overflow: hidden; }

.library-head {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 26px;
}
.library-head h1 {
    font-size: var(--type-display-page);
    line-height: var(--type-display-page-line);
    font-weight: 700;
    letter-spacing: -0.25px;
    margin: 0;
}
.library-count { color: var(--muted); font-size: 14px; }

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    align-items: stretch;
}

.lib-card {
    background: var(--bg-dark);
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.lib-card:hover { border-color: rgba(227, 252, 239, 0.2); }

.lib-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
    width: 100%;
    cursor: pointer;
    flex: 1;
}

.lib-title {
    font-size: var(--type-display-panel);
    line-height: var(--type-display-panel-line);
    font-weight: 700;
    margin: 0;
    min-height: 52px; /* always reserve 2 lines so cards align */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.power-graph.mini {
    height: 72px;
    gap: 1px;
    padding: 4px 0 0;
}
.power-graph.mini .bar {
    min-width: 2px;
    min-height: 5px;
    border-radius: 2px;
}

.lib-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    color: var(--muted);
    font-size: 13px;
}
.lib-meta span { display: inline-flex; align-items: center; gap: 5px; }
.lib-meta .icon { font-size: 14px; }

.lib-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto; /* pin to card bottom so rows align */
    padding-top: 12px;
    border-top: 1px solid rgba(227, 252, 239, 0.1);
}
.lib-date { color: var(--muted); font-size: 12px; margin-right: auto; }

.lib-remove {
    color: var(--muted);
    display: flex;
    padding: 4px;
}
.lib-remove:hover { color: #ff8a80; }

.lib-start {
    background: var(--mint);
    color: var(--bg-dark);
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;   /* design-system pill */
    padding: 8px 16px;
    justify-content: center;
    display: flex;
    align-items: center;
    gap: 6px;
}
.lib-start:hover { filter: brightness(1.06); }

.library-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 70px 20px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.library-empty p { margin: 0; font-size: 16px; }
.library-empty .hint { font-size: 14px; }
.library-empty .action-btn { margin-top: 14px; }

/* ----- library header controls ----- */

.library-sort {
    margin-left: auto;
    align-self: center;
    background: var(--bg-dark);
    color: var(--light);
    border: 1px solid rgba(227, 252, 239, 0.2);
    border-radius: 999px;   /* design-system pill */
    padding: 8px 16px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}
.library-sort:hover, .library-sort:focus { border-color: var(--mint); }
.library-sort option { background: var(--bg-dark); color: var(--light); }

/* ----- sidebar: new workout ghost button ----- */
.new-workout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border: 1px dashed rgba(227, 252, 239, 0.35);
    border-radius: 999px;   /* design-system pill */
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.new-workout-btn:hover {
    border-color: var(--mint);
    color: var(--mint);
    background: rgba(61, 220, 151, 0.06);
}

/* ----- modal confirm buttons ----- */
.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 5px;
}
.modal-actions button {
    flex: 1;
    border-radius: 999px;   /* design-system pill */
    padding: 12px;
    font-weight: 600;
}
.modal-cancel {
    background: transparent;
    border: 1px solid rgba(227, 252, 239, 0.25);
    color: var(--light);
}
.modal-cancel:hover { border-color: var(--light); }
.modal-danger {
    background: #e57373;
    color: var(--bg-dark);
}
.modal-danger:hover { filter: brightness(1.06); }

/* ============================================================
   Profile panel
   ============================================================ */
.profile-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    justify-content: flex-end;
    background: rgba(3, 10, 8, 0.56);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.profile-overlay.open { opacity: 1; visibility: visible; }
.profile-panel {
    width: min(440px, 100%);
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg-dark);
    border-left: 1px solid rgba(227, 252, 239, 0.1);
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.32);
    padding: 28px;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.profile-overlay.open .profile-panel { transform: translateX(0); }
.profile-panel-head,
.profile-identity,
.profile-section-head,
.connection-row {
    display: flex;
    align-items: center;
}
.profile-panel-head { justify-content: space-between; margin-bottom: 24px; }
.profile-panel-head .eyebrow {
    display: block;
    color: var(--mint);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    line-height: 16px;
    text-transform: uppercase;
}
.profile-panel h2 { margin: 2px 0 0; font-size: var(--type-display-feature); line-height: var(--type-display-feature-line); }
.panel-close {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg);
}
.profile-identity { gap: 12px; margin-bottom: 18px; }
.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--light);
    color: var(--bg-dark);
    overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-identity strong,
.profile-identity small { display: block; }
.profile-identity strong { font-size: 16px; }
.profile-identity small { color: var(--muted); font-size: 13px; }
.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    overflow: hidden;
    margin-bottom: 28px;
    border: 1px solid rgba(227, 252, 239, 0.1);
    border-radius: 8px;
    background: rgba(227, 252, 239, 0.1);
}
.profile-stats span { padding: 13px 10px; text-align: center; background: var(--bg); }
.profile-stats strong,
.profile-stats small { display: block; }
.profile-stats strong { color: var(--light); font-size: 16px; }
.profile-stats small { color: var(--muted); font-size: 11px; line-height: 16px; text-transform: uppercase; }
.profile-form,
.profile-connections { padding-top: 24px; border-top: 1px solid rgba(227, 252, 239, 0.1); }
.profile-connections { margin-top: 26px; }
.profile-account { margin-top: 0; margin-bottom: 26px; }
.account-claim-form { padding-top: 0; border-top: 0; }
.profile-section-head { justify-content: space-between; margin-bottom: 14px; }
.profile-section-head h3 { margin: 0; font-size: var(--type-display-label); line-height: var(--type-display-label-line); }
.profile-section-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 17px; }
.profile-form .field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-form .field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.profile-form .field > span { color: var(--muted); font-size: 12px; line-height: 18px; }
.profile-form input,
.profile-form select {
    width: 100%;
    height: 46px;
    border: 1px solid rgba(227, 252, 239, 0.16);
    border-radius: 7px;
    outline: none;
    background: var(--bg);
    color: var(--light);
    padding: 0 12px;
    font: inherit;
}
.profile-form input:focus,
.profile-form select:focus { border-color: var(--mint); }
.input-unit { position: relative; }
.input-unit input { padding-right: 54px; }
.input-unit small {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 11px;
    pointer-events: none;
}
.profile-save {
    width: 100%;
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 7px;
    background: var(--mint);
    color: var(--bg-dark);
    font-size: 14px;
    font-weight: 700;
}
.profile-save:disabled { opacity: 0.55; cursor: default; }
.connection-list { display: flex; flex-direction: column; gap: 9px; }
.connection-row {
    justify-content: space-between;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid rgba(227, 252, 239, 0.1);
    border-radius: 8px;
    background: var(--bg);
}
.connection-copy strong,
.connection-copy small { display: block; }
.connection-copy strong { font-size: 14px; }
.connection-copy small { color: var(--muted); font-size: 11px; line-height: 16px; }
.connection-state {
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(61, 220, 151, 0.12);
    color: var(--mint);
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}
.connection-state.connect { background: var(--mint); color: var(--bg-dark); }
.connection-state.disconnect {
    border: 1px solid rgba(239, 123, 123, 0.5);
    background: transparent;
    color: #ef9a9a;
    cursor: pointer;
}
.connection-state.disconnect:hover { border-color: #ef9a9a; }
.connection-state.disconnect:disabled { opacity: 0.55; cursor: default; }
.connection-state.unavailable { background: rgba(227, 252, 239, 0.08); color: var(--muted); }
.connection-loading { color: var(--muted); font-size: 13px; padding: 12px 0; }
.profile-secondary {
    flex: 0 0 auto;
    padding: 8px 10px;
    border: 1px solid rgba(227, 252, 239, 0.18);
    border-radius: 999px;   /* design-system pill */
    color: var(--light);
    font-size: 12px;
}
.profile-secondary:hover { border-color: var(--mint); color: var(--mint); }
.account-data-actions { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.account-data-actions .profile-secondary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    text-decoration: none;
    cursor: pointer;
}
.account-data-actions .icon { font-size: 17px; }
.account-data-actions .account-delete { color: #ef9a9a; }
.account-data-actions .account-delete:hover { border-color: #ef9a9a; color: #ffcdd2; }
.profile-logout {
    width: 100%;
    margin-top: 28px;
    padding: 11px;
    border: 1px solid rgba(227, 252, 239, 0.14);
    border-radius: 7px;
    color: var(--muted);
    font-size: 13px;
}
.profile-logout:hover { color: var(--light); border-color: rgba(227, 252, 239, 0.3); }
body.profile-open,
body.menu-open { overflow: hidden; }

/* ============================================================
   Responsive shell
   ============================================================ */
@media (max-width: 760px) {
    :root {
        --sidebar-w: min(calc(100vw - var(--space-6)), 300px);
        --type-display-hero: 30px;
        --type-display-hero-line: 38px;
        --type-display-page: 28px;
        --type-display-page-line: 34px;
        --type-display-feature: 24px;
        --type-display-feature-line: 30px;
        --type-display-section: 22px;
        --type-display-section-line: 28px;
    }
    .app { display: block; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 100;
        width: var(--sidebar-w);
        min-width: var(--sidebar-w);
        height: 100dvh;
        margin-left: 0 !important;
        padding-top: calc(max(var(--space-1), env(safe-area-inset-top)) + var(--space-7));
        transform: translateX(-102%);
        box-shadow: 16px 0 40px rgba(0, 0, 0, 0.42);
    }
    .app.sidebar-open .sidebar { transform: translateX(0); }
    .app.sidebar-open .menu-button {
        position: fixed;
        z-index: 110;
    }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 90;
        display: block;
        background: rgba(3, 10, 8, 0.62);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }
    .app.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }
    .main { width: 100%; min-height: 100dvh; }
    .topbar {
        min-height: calc(var(--space-7) + env(safe-area-inset-top));
        padding: max(var(--space-1), env(safe-area-inset-top)) var(--space-2) var(--space-1);
    }
    .topbar .logo { font-size: 24px; line-height: 30px; }
    .topbar .logo .brand-mark { width: 25px; height: 29px; }
    .header-action { left: var(--space-2); top: max(var(--space-1), env(safe-area-inset-top)); }
    .profile-bubble { right: var(--space-2); top: max(var(--space-1), env(safe-area-inset-top)); }
    .home-view {
        min-height: calc(100dvh - var(--space-7));
        justify-content: flex-start;
        padding: clamp(var(--space-7), 13vh, 112px) var(--space-2) 96px;
        gap: var(--space-3);
    }
    .home-view h1 { max-width: 320px; }
    .chat-bar,
    .prompt-chips,
    .suggestions { width: 100%; }
    .suggestions { margin-top: 0; }
    .coach-pick-actions { width: 100%; flex-direction: column; }
    .coach-pick-btn { width: 100%; justify-content: center; min-height: 52px; }
    /* Full-width buttons have room, so the copy runs on one line:
       [icon  Coach's pick  The right session for today] */
    .coach-pick-btn .coach-pick-copy {
        flex-direction: row;
        align-items: baseline;
        gap: 10px;
        text-align: center;
    }
    .chat-bar { min-height: 58px; }
    .chat-bar input { padding: 0 10px 0 14px; }
    .chat-send { width: 52px; height: 44px; }
    .prompt-chips { gap: 10px; justify-content: center; }
    .prompt-chip { max-width: 100%; white-space: normal; text-align: center; padding: 9px 12px; }
    /* Keep the phone screen simple: two example chips, the rest fade out
       under a mask until "See more" expands them. */
    .prompt-chips:not(.expanded) {
        max-height: 102px;   /* two chip rows plus a fading sliver of the third */
        overflow: hidden;
        -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent 97%);
        mask-image: linear-gradient(to bottom, #000 62%, transparent 97%);
    }
    .chips-more {
        display: inline-flex;
        margin-top: -8px;
        padding: 6px 12px;
        background: none;
        border: none;
        color: var(--muted);
        font-size: 13px;
        line-height: 18px;
        text-decoration: underline;
        text-underline-offset: 3px;
        cursor: pointer;
    }
    .chat-view { width: 100%; padding: 24px 14px 120px; }
    .msg-user,
    .msg-assistant { max-width: 92%; }
    .page-nav { top: calc(66px + env(safe-area-inset-top)); width: calc(100% - 28px); }
    .chat-row-menu-btn { opacity: 0.72; pointer-events: auto; }
    .undo-refinement { min-height: 44px; padding-inline: 14px; }
    .refine-dock { left: 0 !important; right: 0; bottom: max(12px, env(safe-area-inset-bottom)); padding: 0 10px; }
    .library-view { width: 100%; padding: 24px 14px 80px; }
    .library-head { align-items: flex-start; flex-wrap: wrap; }
    .library-head h1 { width: 100%; }
    .library-sort { margin-left: auto; }
    .route-library-head { display: block; }
    .route-section-head .route-library-actions { flex: 1 1 100%; margin-left: 0; }
    .route-section-head .route-library-actions .library-sort { flex: 1; margin: 0; }
    .library-grid { grid-template-columns: 1fr; }
    .action-bar { flex-wrap: wrap; }
    .action-btn { min-width: 42%; }
    .route-picker-option { grid-template-columns: 92px 1fr; }
    .route-picker-option .route-card-art { width: 92px; }
    .route-picker-sync { align-items: stretch; flex-direction: column; }
    .ride-workout-option { grid-template-columns: 76px 1fr auto; }
    .ride-workout-option .power-graph.mini { width: 76px; }
    .modal-overlay { align-items: flex-end; }
    .modal { width: 100%; max-height: 88dvh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 24px 18px max(24px, env(safe-area-inset-bottom)); }
    .profile-overlay { align-items: flex-end; }
    .profile-panel {
        width: 100%;
        height: auto;
        max-height: 92dvh;
        border: 0;
        border-top: 1px solid rgba(227, 252, 239, 0.1);
        border-radius: 18px 18px 0 0;
        padding: 22px 18px max(28px, env(safe-area-inset-bottom));
        transform: translateY(102%);
    }
    .profile-overlay.open .profile-panel { transform: translateY(0); }
    .route-detail-overlay { align-items: flex-end; padding: 0; }
    .route-detail-panel { width: 100%; max-height: 92dvh; border-width: 1px 0 0; border-radius: 18px 18px 0 0; padding: 22px 16px 0; }
    .route-detail-footer { padding: 36px 16px max(16px, env(safe-area-inset-bottom)); }
    .route-elevation-chart { height: 180px; }
    .route-map { height: 230px; }
    .route-detail-stats { grid-template-columns: repeat(2, 1fr); }
    .route-detail-stats strong { font-size: 17px; }
    .profile-form .field-grid { grid-template-columns: 1fr 1fr; }
    .footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (max-width: 390px) {
    .profile-form .field-grid { grid-template-columns: 1fr; }
    .profile-stats span { padding-inline: 6px; }
}

/* Super narrow: the one-line coach copy no longer fits, stack it again. */
@media (max-width: 360px) {
    .coach-pick-btn .coach-pick-copy {
        flex-direction: column;
        align-items: center;
        gap: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-backdrop,
    .profile-overlay,
    .profile-panel { transition: none; }
}
