/* ============================================================
   SimplyRunFaster — Design System
   Based on UI Direction Document v1.0
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
    /* Accent: Forest Teal */
    --accent-fill:    #E1F5EE;
    --accent-mid:     #1D9E75;
    --accent-strong:  #0F6E56;
    --accent-dark:    #085041;

    /* Surface — Light Mode (default) */
    --page-bg:        #F5F3EF;
    --card-bg:        #FFFFFF;
    --recessed-bg:    #F0EDE7;
    --nav-bg:         #FFFFFF;
    --elevated-bg:    #F7F5F2;
    --border-color:   rgba(0, 0, 0, 0.08);
    --border-strong:  rgba(0, 0, 0, 0.15);

    /* Typography — Light */
    --text-primary:   #1A1A1A;
    --text-secondary: #6B6B6B;
    --text-muted:     #9A9A9A;
    --text-accent:    #0F6E56;

    /* Semantic */
    --color-success:  #1D9E75;
    --color-warning:  #BA7517;
    --color-danger:   #A32D2D;
    --color-info:     #185FA5;

    /* Nav */
    --nav-height-bottom: 64px;
    --sidebar-width:     240px;
    --content-max-width: 720px;

    /* Radius */
    --radius-card:   12px;
    --radius-sm:     8px;
    --radius-xs:     6px;
    --radius-pill:   6px;

    /* Shadows — none by design; depth from surface contrast */
    --card-border: 0.5px solid var(--border-color);
}

/* Dark mode */
[data-theme="dark"] {
    --page-bg:        #161616;
    --card-bg:        #1E1E1E;
    --recessed-bg:    #2A2A2A;
    --nav-bg:         #161616;
    --elevated-bg:    #252525;
    --border-color:   rgba(255, 255, 255, 0.08);
    --border-strong:  rgba(255, 255, 255, 0.15);

    --text-primary:   #F0F0F0;
    --text-secondary: #A0A0A0;
    --text-muted:     #6A6A6A;
    --text-accent:    #1D9E75;

    /* Dark mode accent adjustments */
    --accent-fill:    #085041;
    --accent-strong:  #5DCAA5;
}

/* System preference fallback */
@media (prefers-color-scheme: dark) {
    [data-theme="system"] {
        --page-bg:        #161616;
        --card-bg:        #1E1E1E;
        --recessed-bg:    #2A2A2A;
        --nav-bg:         #161616;
        --elevated-bg:    #252525;
        --border-color:   rgba(255, 255, 255, 0.08);
        --border-strong:  rgba(255, 255, 255, 0.15);
        --text-primary:   #F0F0F0;
        --text-secondary: #A0A0A0;
        --text-muted:     #6A6A6A;
        --text-accent:    #1D9E75;
        --accent-fill:    #085041;
        --accent-strong:  #5DCAA5;
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--page-bg);
    min-height: 100vh;
    min-height: 100dvh;
    overscroll-behavior-y: none;
}

a {
    color: var(--text-accent);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ── Typography ────────────────────────────────────────────── */
.page-heading {
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
}

.section-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.card-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
}

.body-text {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.6;
}

.metric-value {
    font-size: 24px;
    font-weight: 500;
    color: var(--text-primary);
}

.metric-label {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
}

/* ── Layout — Mobile first ──────────────────────────────────── */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 52px;
    background: var(--nav-bg);
    border-bottom: var(--card-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.top-nav .logo {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    flex: 1;
}

.top-nav .logo span {
    color: var(--accent-mid);
}

.top-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-content {
    padding: 60px 16px 80px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    max-width: var(--content-max-width);
    margin: 0 auto;
    width: 100%;
}

/* Bottom tab nav (mobile / athlete) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    min-height: var(--nav-height-bottom);
    background: var(--nav-bg);
    border-top: var(--card-border);
    display: flex;
    align-items: stretch;
    padding-bottom: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
    text-decoration: none;
    padding: 8px 4px;
    transition: color 0.15s;
    position: relative;
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
    color: var(--accent-mid);
    text-decoration: none;
}

.bottom-nav-item svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.75;
}

/* Athlete desktop top-nav links (hidden on mobile) */
.athlete-nav-links {
    display: none;
}

.athlete-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: color 0.1s, background 0.1s;
    white-space: nowrap;
}

.athlete-nav-link:hover {
    color: var(--accent-mid);
    background: var(--recessed-bg);
    text-decoration: none;
}

.athlete-nav-link.active {
    color: var(--accent-mid);
    background: var(--accent-fill);
}

.top-nav-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--color-danger);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
}

/* Desktop: left sidebar nav */
@media (min-width: 1024px) {
    .app-container {
        flex-direction: row;
    }

    .sidebar-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--sidebar-width);
        background: var(--nav-bg);
        border-right: var(--card-border);
        display: flex;
        flex-direction: column;
        padding: 20px 0;
        z-index: 100;
    }

    .sidebar-logo {
        padding: 0 20px 20px;
        font-size: 16px;
        font-weight: 600;
        color: var(--text-primary);
        border-bottom: var(--card-border);
        margin-bottom: 8px;
    }

    .sidebar-logo span { color: var(--accent-mid); }

    .sidebar-nav-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 20px;
        color: var(--text-secondary);
        font-size: 14px;
        font-weight: 400;
        text-decoration: none;
        transition: background 0.1s, color 0.1s;
    }

    .sidebar-nav-item:hover,
    .sidebar-nav-item.active {
        background: var(--recessed-bg);
        color: var(--accent-mid);
        text-decoration: none;
    }

    .sidebar-nav-item svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
        stroke-width: 1.75;
    }

    .sidebar-roster {
        flex: 1;
        overflow-y: auto;
        padding: 12px 0;
    }

    .sidebar-roster-label {
        font-size: 11px;
        font-weight: 500;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--text-muted);
        padding: 0 20px 8px;
    }

    .sidebar-roster-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 20px;
        color: var(--text-secondary);
        font-size: 13px;
        text-decoration: none;
        transition: background 0.1s;
    }

    .sidebar-roster-item:hover {
        background: var(--recessed-bg);
        text-decoration: none;
        color: var(--text-primary);
    }

    .page-content {
        margin-left: var(--sidebar-width);
        padding: 32px 32px 32px;
        max-width: 100%;
    }

    .bottom-nav { display: none; }
    .top-nav { left: var(--sidebar-width); }

    /* Coach pages: hide redundant top-nav and constrain content width */
    body.coach-page .top-nav { display: none; }
    body.coach-page .page-content { padding-top: 32px; max-width: 1280px; }

    /* Athlete pages: full-width top nav, no sidebar offset */
    body:not(.coach-page) .top-nav { left: 0; }
    body:not(.coach-page) .top-nav .logo { flex: none; }

    /* Athlete pages: center content column, clear fixed top nav */
    body:not(.coach-page) .page-content {
        width: auto;
        margin-left: auto;
        margin-right: auto;
        max-width: var(--content-max-width);
        padding: 68px 32px 40px;
    }

    /* Show athlete nav links centered between logo and actions */
    .athlete-nav-links {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1;
        gap: 2px;
    }
}

/* Coach athlete view: responsive two-column grid */
.av-grid {
    display: grid;
    gap: 16px;
    align-items: start;
}
@media (min-width: 1024px) {
    .av-grid { grid-template-columns: 1fr 280px; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .page-content {
        padding: 60px 24px 80px;
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    }
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: var(--radius-card);
    padding: 16px 20px;
}

.card + .card,
.card + .section-label {
    margin-top: 12px;
}

.card-next-up {
    border-left: 3px solid var(--accent-mid);
    padding-left: 17px; /* 20px - 3px border */
}

/* Metric tiles */
.metric-tile {
    background: var(--recessed-bg);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* ── Workout Type Pills ──────────────────────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.pill-easy      { background: #E1F5EE; color: #085041; }
.pill-long      { background: #0F6E56; color: #FFFFFF; }
.pill-interval  { background: #042C53; color: #FFFFFF; }
.pill-tempo     { background: #185FA5; color: #FFFFFF; }
.pill-hill      { background: #3B6D11; color: #FFFFFF; }
.pill-fartlek   { background: #639922; color: #FFFFFF; }
.pill-recovery  { background: #D3D1C7; color: #444441; }
.pill-rest      { background: #F1EFE8; color: #5F5E5A; }
.pill-race      { background: #993C1D; color: #FFFFFF; }
.pill-cross_train { background: #4A3B8A; color: #FFFFFF; }

/* Severity pills */
.pill-info     { background: #EAF2FF; color: #185FA5; }
.pill-warning  { background: #FEF3CD; color: #7A4C00; }
.pill-critical { background: #FDECEA; color: #A32D2D; }

/* Status pills */
.pill-active   { background: #E1F5EE; color: #085041; }
.pill-pending  { background: #FEF3CD; color: #7A4C00; }
.pill-trialing { background: #EAF2FF; color: #185FA5; }
.pill-comped   { background: #F3EAF9; color: #6B2FA0; }
.pill-past-due { background: #FDECEA; color: #A32D2D; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-mid);
    color: #FFFFFF;
}
.btn-primary:hover {
    background: var(--accent-strong);
    color: #FFFFFF;
    text-decoration: none;
}

.btn-secondary {
    background: transparent;
    border: 0.5px solid var(--border-strong);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--recessed-bg);
    text-decoration: none;
}

.btn-danger {
    background: transparent;
    border: 0.5px solid var(--color-danger);
    color: var(--color-danger);
}
.btn-danger:hover {
    background: #FDECEA;
}

.btn-sm {
    font-size: 12px;
    padding: 5px 12px;
}

.btn-full { width: 100%; }

/* Icon buttons */
.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
}
.btn-icon:hover {
    background: var(--recessed-bg);
    color: var(--text-primary);
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s;
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent-mid);
    box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.12);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239A9A9A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Pill choice selectors (onboarding) */
.pill-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill-choice {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border-strong);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.pill-choice input[type="radio"],
.pill-choice input[type="checkbox"] {
    display: none;
}

.pill-choice:has(input:checked),
.pill-choice.selected {
    border-color: var(--accent-mid);
    background: var(--accent-fill);
    color: var(--accent-dark);
}

/* Toggle switches */
.toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.toggle {
    position: relative;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-strong);
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent-mid);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* Day picker (availability) */
.day-picker {
    display: flex;
    gap: 6px;
}

.day-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1.5px solid var(--border-strong);
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.day-btn.selected {
    border-color: var(--accent-mid);
    background: var(--accent-mid);
    color: white;
}

.day-btn.must-off {
    border-color: var(--color-danger);
    color: var(--color-danger);
}

/* ── Alert / Flag Cards ─────────────────────────────────────── */
.flag-card {
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: var(--radius-card);
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.flag-card-warning { border-left: 3px solid var(--color-warning); }
.flag-card-critical { border-left: 3px solid var(--color-danger); }
.flag-card-info     { border-left: 3px solid var(--color-info); }

.flag-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.flag-body { flex: 1; }
.flag-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    line-height: 1;
    padding: 0;
}

/* ── Phase Progress Bar ─────────────────────────────────────── */
.phase-bar-wrap {
    margin: 12px 0;
}

.phase-bar-track {
    height: 6px;
    background: var(--recessed-bg);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.phase-bar-fill {
    height: 100%;
    background: var(--accent-mid);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.phase-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.phase-bar-labels .active-phase {
    color: var(--accent-mid);
    font-weight: 600;
}

/* ── Weekly Calendar Rows ───────────────────────────────────── */
.week-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: var(--card-border);
    gap: 12px;
}

.week-row:last-child { border-bottom: none; }

.week-row-day {
    width: 32px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.week-row-today .week-row-day {
    color: var(--accent-mid);
}

.week-row-body { flex: 1; min-width: 0; }

.week-row-duration {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ── Compliance indicators ──────────────────────────────────── */
.compliance-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.compliance-good    { background: var(--color-success); }
.compliance-ok      { background: var(--color-warning); }
.compliance-poor    { background: var(--color-danger); }
.compliance-none    { background: var(--border-strong); }

/* Sparkline (compliance over 4-6 weeks) */
.sparkline {
    display: flex;
    gap: 3px;
    align-items: flex-end;
    height: 24px;
}

.sparkline-bar {
    width: 8px;
    border-radius: 2px;
    min-height: 4px;
    background: var(--color-success);
}

.sparkline-bar.ok   { background: var(--color-warning); }
.sparkline-bar.poor { background: var(--color-danger); }
.sparkline-bar.none { background: var(--border-strong); }

/* ── Coach Roster Table ─────────────────────────────────────── */
.roster-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.roster-row {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    gap: 12px;
    background: var(--card-bg);
    border-bottom: var(--card-border);
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.1s;
    position: relative;
}

.roster-row:first-child { border-radius: var(--radius-card) var(--radius-card) 0 0; }
.roster-row:last-child  { border-bottom: none; border-radius: 0 0 var(--radius-card) var(--radius-card); }
.roster-row:only-child  { border-radius: var(--radius-card); }

.roster-row:hover {
    background: var(--elevated-bg);
    text-decoration: none;
}

.roster-row.flag-critical { border-left: 3px solid var(--color-danger); padding-left: 17px; }
.roster-row.flag-warning  { border-left: 3px solid var(--color-warning); padding-left: 17px; }

.roster-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--recessed-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.roster-info { flex: 1; min-width: 0; }

.roster-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.roster-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.roster-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.roster-flag-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-danger);
}

/* ── Auth pages ─────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--page-bg);
    padding: 24px 16px;
}

.auth-card {
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: var(--radius-card);
    padding: 32px 28px;
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    text-align: center;
}

.auth-logo span { color: var(--accent-mid); }

.auth-divider {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin: 16px 0;
    position: relative;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 20px);
    height: 1px;
    background: var(--border-color);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }

/* ── Onboarding ─────────────────────────────────────────────── */
.onboarding-page {
    background: var(--page-bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.onboarding-progress {
    background: var(--nav-bg);
    border-bottom: var(--card-border);
    padding: 16px 20px 12px;
}

.onboarding-steps {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.onboarding-step-dot {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: var(--border-strong);
}

.onboarding-step-dot.done     { background: var(--accent-mid); }
.onboarding-step-dot.current  { background: var(--accent-mid); opacity: 0.4; }

.onboarding-step-label {
    font-size: 12px;
    color: var(--text-muted);
}

.onboarding-content {
    padding: 24px 20px;
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

.onboarding-heading {
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.onboarding-subheading {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.onboarding-footer {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--nav-bg);
    border-top: var(--card-border);
    gap: 12px;
}

/* Goal path cards (step 1) */
.goal-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-card);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    width: 100%;
    margin-bottom: 10px;
}

.goal-card:hover,
.goal-card.selected {
    border-color: var(--accent-mid);
    background: var(--accent-fill);
}

.goal-card-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.goal-card-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.goal-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ── Flash messages ─────────────────────────────────────────── */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}

.flash-error   { background: #FDECEA; color: var(--color-danger); }
.flash-success { background: #E1F5EE; color: var(--accent-dark); }
.flash-info    { background: #EAF2FF; color: var(--color-info); }

/* ── Misc ───────────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.empty-state-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent-mid); }
.text-danger  { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-success { color: var(--color-success); }

.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

/* ── Theme toggle button in nav ─────────────────────────────── */
.theme-toggle-form { display: inline; }
.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 6px;
    border-radius: var(--radius-xs);
    display: inline-flex;
    align-items: center;
    transition: color 0.15s;
}
.theme-toggle-btn:hover { color: var(--text-primary); }
.theme-toggle-btn svg { width: 18px; height: 18px; }

/* ── Return-to-running stage bar ────────────────────────────── */
.return-stage-bar {
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: var(--radius-card);
    padding: 14px 18px;
}

.return-stage-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.return-stage-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* ── Watch badge ────────────────────────────────────────────── */
.watch-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--recessed-bg);
    padding: 2px 8px;
    border-radius: 4px;
}

/* ── Offline banner ─────────────────────────────────────────── */
.offline-banner {
    display: none;
    background: var(--color-warning);
    color: white;
    font-size: 12px;
    text-align: center;
    padding: 6px 16px;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    z-index: 200;
}

body.is-offline .offline-banner { display: block; }

/* ── Responsive helpers ─────────────────────────────────────── */
@media (max-width: 1023px) {
    .sidebar-nav { display: none; }
    body.coach-page .page-content { padding-top: 60px; }
}

@media (max-width: 480px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .page-heading { font-size: 18px; }
}

/* ── Messages ────────────────────────────────────────────────── */

.msg-thread {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
}

.msg-row {
    display: flex;
    flex-direction: column;
}

.msg-row.coach  { align-items: flex-start; }
.msg-row.athlete { align-items: flex-end; }

.msg-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.msg-row.coach  .msg-bubble {
    background: #F0EDE7;
    color: #1A1A1A;
    border-bottom-left-radius: 4px;
}

.msg-row.athlete .msg-bubble {
    background: #1D9E75;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

[data-theme="dark"] .msg-row.coach  .msg-bubble { background: #2A2A2A; color: #F0F0F0; }
[data-theme="dark"] .msg-row.athlete .msg-bubble { background: #0F6E56; }

[data-theme="dark"] .pill-choice:has(input:checked),
[data-theme="dark"] .pill-choice.selected {
    background: var(--accent-mid);
    color: #FFFFFF;
}

@media (prefers-color-scheme: dark) {
    [data-theme="system"] .pill-choice:has(input:checked),
    [data-theme="system"] .pill-choice.selected {
        background: var(--accent-mid);
        color: #FFFFFF;
    }
}

.msg-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
    padding: 0 2px;
}

.msg-timestamp {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    padding: 8px 0;
    align-self: center;
}

/* Session note card */
.msg-session-card {
    max-width: 85%;
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: 12px;
    padding: 12px 14px;
    border-left: 3px solid var(--accent-mid);
}

.msg-session-card-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-mid);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.msg-session-card-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.msg-session-link {
    font-size: 12px;
    color: var(--accent-mid);
    font-weight: 500;
    text-decoration: none;
}
.msg-session-link:hover { text-decoration: underline; }

/* Compose elements */
.msg-compose {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.msg-compose-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-strong);
    background: var(--recessed-bg);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.5;
    overflow-y: auto;
}
.msg-compose-input:focus { border-color: var(--accent-mid); }
.msg-compose-input::placeholder { color: var(--text-muted); }

.msg-compose-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-mid);
    border: none;
    cursor: pointer;
    color: #fff;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.msg-compose-send:hover { background: var(--accent-strong); }
.msg-compose-send:disabled { background: var(--border-strong); cursor: default; }

/* Compose bar wrapper — fixed on mobile, inline on desktop */
.msg-compose-wrap {
    padding: 10px 16px;
    background: var(--nav-bg);
    border-top: var(--card-border);
}

@media (max-width: 1023px) {
    .msg-compose-wrap {
        position: fixed;
        bottom: calc(var(--nav-height-bottom) + env(safe-area-inset-bottom, 0px));
        left: 0;
        right: 0;
        z-index: 50;
    }
    /* Extra padding so thread content isn't hidden behind compose + bottom nav */
    .page-content.has-fixed-compose {
        padding-bottom: calc(80px + 60px + env(safe-area-inset-bottom, 0px));
    }
}

@media (min-width: 1024px) {
    .msg-compose-wrap {
        padding: 12px 0 0;
        border-top: var(--card-border);
        margin-top: 8px;
    }
    /* mobileCompose sits outside .page-content; hide it on desktop to prevent overflow */
    .page-content ~ .msg-compose-wrap {
        display: none;
    }
}

/* Unread badge on bottom-nav Messages tab */
.nav-unread-badge {
    position: absolute;
    top: 5px;
    right: calc(50% - 20px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--color-danger);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

/* Inline unread badge */
.unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--color-danger);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    vertical-align: middle;
}

/* Unread message badge on coach roster rows */
.roster-msg-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--color-info);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
}

/* 6-tab bottom nav: shrink font on very small screens */
@media (max-width: 400px) {
    .bottom-nav-item { font-size: 10px; }
    .bottom-nav-item svg { width: 20px; height: 20px; }
}
