/* ═══════════════════════════════════════════════════════════
   Ironman Trainer — Stylesheet
   Light theme, Strava-inspired clean design
   ═══════════════════════════════════════════════════════════ */

/* ── Reset & Custom Properties ─────────────────────────── */
:root {
    --bg-primary: #f7f7f7;
    --bg-white: #ffffff;
    --bg-hover: #f0f0f0;
    --bg-subtle: #fafafa;

    --border-color: #e5e5e5;
    --border-hover: #d0d0d0;
    --divider: #ebebeb;

    --text-primary: #1a1a1a;
    --text-secondary: #6b6b6b;
    --text-muted: #999999;
    --text-inverse: #ffffff;

    --accent: #059669;
    --accent-light: #d1fae5;
    --accent-dark: #047857;
    --accent-bg: rgba(5, 150, 105, 0.08);

    --accent-swim: #0891b2;
    --accent-bike: #d97706;
    --accent-run: #059669;
    --accent-strength: #7c3aed;
    --accent-hike: #92400e;

    --red: #dc2626;
    --red-bg: rgba(220, 38, 38, 0.08);
    --blue: #2563eb;
    --blue-bg: rgba(37, 99, 235, 0.08);
    --amber: #d97706;
    --amber-bg: rgba(217, 119, 6, 0.08);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 999px;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;
}

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

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

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Navbar ─────────────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding-top: env(safe-area-inset-top);
}

.nav-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    height: 44px;
    gap: 1rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
}

.brand-icon {
    font-size: 1.1rem;
}

.nav-links {
    display: flex;
    gap: 0.125rem;
    flex: 1;
}

.nav-link {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--transition);
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-link.active {
    color: var(--accent);
    font-weight: 600;
}

.nav-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* User Avatar Menu */
.user-menu {
    position: relative;
}

.user-menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    border-radius: 50%;
    transition: box-shadow var(--transition);
}

.user-menu-toggle:hover {
    box-shadow: 0 0 0 2px var(--accent);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.user-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 200;
    overflow: hidden;
}

.user-menu.open .user-dropdown {
    display: block;
}

.user-dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--divider);
}

.user-dropdown-header strong {
    display: block;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.user-dropdown-header span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background var(--transition);
}

.user-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}


.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
    transition: all var(--transition);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-primary {
    background: var(--accent);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background: var(--accent-dark);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-outline {
    background: var(--bg-white);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.btn:disabled, .btn.loading {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn.loading::after {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Main Content ───────────────────────────────────────── */
.main-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem max(1rem, env(safe-area-inset-right)) 1.5rem max(1rem, env(safe-area-inset-left));
    min-height: calc(100vh - 56px - 52px);
}

.page-header {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.125rem;
}

/* ── Sections ───────────────────────────────────────────── */
.section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

/* ── Cards (base) ──────────────────────────────────────── */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    transition: all var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-sm);
}

/* ── Race Cards ─────────────────────────────────────────── */
.race-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.race-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.race-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--border-hover);
}

.race-urgent {
    border-left: 3px solid var(--red);
}

.race-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

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

.race-info h3 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.race-date {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.race-notes {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.125rem;
}

.race-countdown-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--accent-bg);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.countdown-number {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}

.countdown-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* ── Race Management ───────────────────────────── */

.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.section-header-row .section-title {
    margin-bottom: 0;
}

.race-form {
    margin-bottom: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-group input,
.form-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--bg-white);
    color: var(--text-primary);
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Race card action buttons */
.race-actions {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--transition);
}

.race-card:hover .race-actions {
    opacity: 1;
}

.race-actions-visible {
    opacity: 1 !important;
}

.race-action-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.35rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.race-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.race-action-delete:hover {
    color: var(--red);
    border-color: var(--red);
    background: rgba(239, 68, 68, 0.06);
}

/* Race edit modal */
.race-modal {
    border: none;
    border-radius: var(--radius-lg);
    padding: 0;
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    width: 90vw;
}

.race-modal::backdrop {
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
}

.race-modal-content {
    padding: 1.5rem;
}

.race-modal-content h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .race-actions {
        opacity: 1;
        flex-direction: row;
    }
}

/* ── Metric Cards Grid ──────────────────────────────────── */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
}

.metric-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem 0.75rem;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.metric-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--border-hover);
}

.metric-card-health::before { background: var(--blue); }
.metric-card-run::before { background: var(--accent-run); }
.metric-card-bike::before { background: var(--accent-bike); }
.metric-card-swim::before { background: var(--accent-swim); }
.metric-card-body::before { background: var(--amber); }
.metric-card-load::before { background: var(--blue); }
.metric-card-alert::before { background: var(--red); }

.metric-icon {
    font-size: 1.25rem;
    margin-bottom: 0.375rem;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.metric-label {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.metric-unit {
    font-size: 0.625rem;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-tag {
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.tag-green {
    background: rgba(5, 150, 105, 0.1);
    color: #059669;
}

.tag-blue {
    background: rgba(37, 99, 235, 0.08);
    color: #2563eb;
}

.tag-amber {
    background: rgba(217, 119, 6, 0.08);
    color: #d97706;
}

.tag-red {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
}

/* ── Activity List (Dashboard) ──────────────────────────── */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.activity-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    padding-bottom: 0.875rem;
    transition: background var(--transition);
    border-bottom: 1px solid var(--divider);
    position: relative;
    flex-wrap: wrap;
}

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

.activity-row:hover {
    background: var(--bg-subtle);
}

.activity-sport-icon {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    font-size: 1rem;
    flex-shrink: 0;
}

.activity-row.sport-run .activity-sport-icon { background: rgba(5, 150, 105, 0.1); }
.activity-row.sport-bike .activity-sport-icon { background: rgba(217, 119, 6, 0.1); }
.activity-row.sport-swim .activity-sport-icon { background: rgba(8, 145, 178, 0.1); }
.activity-row.sport-strength .activity-sport-icon { background: rgba(124, 58, 237, 0.1); }
.activity-row.sport-hike .activity-sport-icon { background: rgba(146, 64, 14, 0.1); }
.activity-row.sport-walk .activity-sport-icon { background: rgba(146, 64, 14, 0.08); }
.activity-row.sport-yoga .activity-sport-icon { background: rgba(236, 72, 153, 0.1); }

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

.activity-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.activity-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.activity-stats {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.stat {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.stat-hr { color: var(--red); }
.stat-pace { color: var(--accent-run); }

/* ── Activities Table ───────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-full);
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.filter-btn.active {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}

/* ── Activity Card Feed ────────────────────────────────── */
.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.activity-card {
    display: block;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: box-shadow var(--transition), border-color var(--transition);
}

.activity-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.activity-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.375rem;
}

.activity-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.625rem;
}

.activity-card-stats {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.activity-stat {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.activity-stat-value {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.activity-stat-unit {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.activity-card-zones {
    margin-top: 0.625rem;
}

.activity-zone-bar {
    position: absolute;
    bottom: 0;
    left: 3rem;
    right: 0;
    padding: 0;
}

.mini-zone-bar {
    display: flex;
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
}

.mini-zone-bar > div {
    min-width: 1px;
}

/* Zone legend strip */
.zone-legend-inline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.zone-legend-title {
    font-weight: 600;
    color: var(--text-secondary);
}
.zone-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.zone-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

/* ── Activity Detail Page ──────────────────────────────── */
.back-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.back-link:hover { text-decoration: underline; }

.detail-section {
    margin-bottom: 1.5rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
}

.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    text-align: center;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0.125rem;
}

/* HR Zone bar */
.hr-zone-bar {
    display: flex;
    height: 2rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.hr-zone-segment {
    min-width: 2px;
    transition: opacity 0.2s;
    cursor: default;
}
.hr-zone-segment:hover { opacity: 0.8; }

.hr-zone-legend {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.hr-zone-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
}

.hr-zone-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.hr-zone-name {
    flex: 1;
    color: var(--text-secondary);
}

.hr-zone-time {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 3rem;
    text-align: right;
}

.hr-zone-pct {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 2.5rem;
    text-align: right;
}

/* Training Effect */
.te-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.te-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
}

.te-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

.te-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.te-bar {
    height: 4px;
    background: var(--bg-subtle);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.te-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* ── Progress Page / Charts ────────────────────────────── */
.chart-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    overflow: hidden;
}

.chart-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.empty-chart {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 2rem 1rem;
}

.pred-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.625rem;
    margin-bottom: 1rem;
}

.pred-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 0.625rem;
    text-align: center;
}

.pred-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.125rem;
}

.pred-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.pred-sub {
    font-size: 0.625rem;
    color: var(--text-muted);
}

/* ── Calendar Page ──────────────────────────────────────── */
.calendar-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.calendar-month-label {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 180px;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 2rem;
}

.calendar-day-header {
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.5rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calendar-cell {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-height: 100px;
    padding: 0.5rem;
    position: relative;
    transition: border-color 0.2s;
    overflow: hidden;
    cursor: pointer;
}

.calendar-cell:hover { border-color: var(--accent); }

.calendar-cell.today {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.15);
}

.calendar-cell.empty {
    background: transparent;
    border-color: transparent;
    min-height: 0;
    cursor: default;
}

.calendar-cell .day-number {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.calendar-cell.today .day-number { color: var(--accent); }

.cal-item {
    font-size: 0.6875rem;
    padding: 2px 5px;
    border-radius: 4px;
    margin-bottom: 2px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.cal-item.activity {
    background: rgba(5, 150, 105, 0.1);
    color: #059669;
    border-left: 3px solid #059669;
}

.cal-item.workout {
    background: rgba(37, 99, 235, 0.08);
    color: #2563eb;
    border-left: 3px solid #2563eb;
}

.cal-item.ai-workout {
    background: rgba(217, 119, 6, 0.08);
    color: #d97706;
    border-left: 3px solid #d97706;
}

.cal-item.weight {
    background: rgba(107, 107, 107, 0.08);
    color: var(--text-secondary);
    border-left: 3px solid var(--text-muted);
}

.cal-item .sport-icon { margin-right: 2px; }

.calendar-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
    font-size: 1rem;
}

/* Calendar day detail slide panel */
.day-detail-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3); z-index: 100;
}

.day-detail-panel {
    position: fixed; top: 0; right: 0; bottom: 0; width: 420px;
    background: var(--bg-white); border-left: 1px solid var(--border-color);
    z-index: 101; overflow-y: auto; padding: 1.5rem;
    box-shadow: -4px 0 20px rgba(0,0,0,0.08);
    animation: slideInPanel 0.2s ease-out;
}

@keyframes slideInPanel {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.day-detail-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.day-detail-header h2 { margin: 0; font-size: 1.125rem; font-weight: 700; }
.day-detail-body { display: flex; flex-direction: column; gap: 0.75rem; }

.detail-card {
    border: 1px solid var(--border-color); border-radius: 8px;
    padding: 1rem; background: var(--bg-subtle);
}

.detail-card.activity { border-left: 4px solid #059669; }
.detail-card.ai-workout { border-left: 4px solid #d97706; }
.detail-card.workout { border-left: 4px solid #2563eb; }

.detail-card .detail-title {
    font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.5rem;
    display: flex; align-items: center; gap: 0.5rem;
    color: var(--text-primary);
}

.detail-card .detail-meta {
    display: flex; flex-wrap: wrap; gap: 0.75rem;
    font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 0.5rem;
}

.detail-card .detail-meta span { display: flex; align-items: center; gap: 0.25rem; }
.detail-steps { margin-top: 0.75rem; }
.detail-steps h4 { font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 0.5rem; font-weight: 600; }

.step-item {
    display: flex; gap: 0.5rem; padding: 0.375rem 0.5rem;
    border-radius: 4px; margin-bottom: 3px; font-size: 0.75rem;
    background: var(--bg-hover);
}

.step-item .step-type { font-weight: 700; min-width: 70px; text-transform: capitalize; }
.step-item.warmup .step-type { color: #d97706; }
.step-item.cooldown .step-type { color: #2563eb; }
.step-item.interval .step-type { color: #dc2626; }
.step-item.main .step-type { color: #059669; }
.step-item.recovery .step-type { color: #7c3aed; }
.step-item .step-detail { color: var(--text-secondary); flex: 1; }
.step-item .step-target { color: var(--text-primary); font-weight: 600; white-space: nowrap; }
.empty-day { text-align: center; color: var(--text-muted); padding: 2rem; font-size: 0.875rem; }

/* ── Plan Generation Progress ──────────────────────────── */
.plan-progress {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
}

.plan-progress.active { display: flex; }

.plan-progress-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.plan-progress-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.plan-progress-steps {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 300px;
}

/* ── Preference Cards (collapsible) ────────────────────── */
.pref-section {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    overflow: hidden;
}

.pref-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    user-select: none;
    list-style: none;
}

.pref-toggle::-webkit-details-marker { display: none; }

.pref-toggle::before {
    content: "▶";
    font-size: 0.625rem;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.pref-section[open] .pref-toggle::before {
    transform: rotate(90deg);
}

.pref-count {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-subtle);
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
}

.pref-body {
    padding: 0 1rem 1rem;
}

.pref-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.625rem;
}

.pref-cards {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}

.pref-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: opacity var(--transition);
}

.pref-card.pref-inactive {
    opacity: 0.45;
}

.pref-toggle-active input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

.pref-text {
    flex: 1;
    font-size: 0.8125rem;
    color: var(--text-primary);
    outline: none;
    min-width: 0;
    word-break: break-word;
}

.pref-text:focus {
    background: var(--bg-white);
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.pref-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
    transition: color var(--transition);
}

.pref-delete:hover {
    color: #dc2626;
}

.pref-add {
    display: flex;
    gap: 0.5rem;
}

.pref-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--bg-white);
    color: var(--text-primary);
}

.pref-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* ── Route Map ─────────────────────────────────────────── */
.map-container {
    width: 100%;
    height: 300px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    position: relative;
    background: var(--bg-subtle);
}

.map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.map-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.detail-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--divider);
}

.detail-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sport-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.sport-run { background: rgba(5, 150, 105, 0.1); color: var(--accent-run); }
.sport-bike { background: rgba(217, 119, 6, 0.1); color: var(--accent-bike); }
.sport-swim { background: rgba(8, 145, 178, 0.1); color: var(--accent-swim); }
.sport-strength { background: rgba(124, 58, 237, 0.1); color: var(--accent-strength); }
.sport-hike { background: rgba(146, 64, 14, 0.1); color: var(--accent-hike); }
.sport-walk { background: rgba(146, 64, 14, 0.08); color: var(--accent-hike); }
.sport-yoga { background: rgba(236, 72, 153, 0.1); color: #db2777; }

.strava-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    color: #fc4c02;
    background: rgba(252, 76, 2, 0.08);
    border: 1px solid rgba(252, 76, 2, 0.2);
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
    vertical-align: middle;
    letter-spacing: 0.02em;
    cursor: help;
}

.source-badge {
    font-size: 0.6875rem;
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.source-garmin { background: rgba(8, 145, 178, 0.1); color: var(--accent-swim); }
.source-strava { background: rgba(252, 76, 2, 0.08); color: #fc4c02; }

.name-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Plan Tabs ──────────────────────────────────────────── */
.plan-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    padding: 3px;
    width: fit-content;
}

.tab-btn {
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-full);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.tab-btn.active {
    background: var(--bg-white);
    color: var(--text-primary);
    box-shadow: var(--shadow-xs);
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
}

.plan-tab-content {
    animation: fadeIn 0.2s ease;
}

.plan-tab-content.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.plan-actions {
    margin-bottom: 1.25rem;
}

.plan-content {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.plan-meta {
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Markdown Body ──────────────────────────────────────── */
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin-top: 1.25rem;
    margin-bottom: 0.625rem;
    font-weight: 700;
    color: var(--text-primary);
}

.markdown-body h1 { font-size: 1.375rem; }
.markdown-body h2 { font-size: 1.125rem; color: var(--accent); }
.markdown-body h3 { font-size: 1rem; }

.markdown-body p {
    margin-bottom: 0.625rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 0.625rem;
    padding-left: 1.5rem;
}

.markdown-body li {
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.markdown-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.8125rem;
}

.markdown-body table th,
.markdown-body table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border: 1px solid var(--border-color);
}

.markdown-body table th {
    background: var(--bg-subtle);
    font-weight: 600;
    color: var(--text-primary);
}

.markdown-body table td {
    color: var(--text-secondary);
}

.markdown-body code {
    background: var(--bg-hover);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.8em;
}

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    background: var(--bg-white);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
}

.empty-state p {
    font-size: 0.875rem;
}


/* ── Toast Notifications ────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    animation: toastIn 0.3s ease;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
}

.toast-success {
    background: var(--accent);
    color: var(--text-inverse);
}

.toast-error {
    background: var(--red);
    color: var(--text-inverse);
}

.toast-info {
    background: var(--text-primary);
    color: var(--text-inverse);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Footer ─────────────────────────────────────────────── */
.footer {
    border-top: 1px solid var(--border-color);
    padding: 1.25rem max(1rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    text-align: center;
}

.footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════
   Responsive — Mobile-first
   ═══════════════════════════════════════════════════════════ */

/* ── Mobile Drawer ─────────────────────────────────────── */

.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-backdrop.open {
    display: block;
    opacity: 1;
}

.nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    background: var(--bg-white);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-drawer.open {
    transform: translateX(0);
}

.nav-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.nav-drawer-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.nav-drawer-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: background var(--transition), color var(--transition);
}

.nav-drawer-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-drawer-links {
    flex: 1;
    padding: 0.75rem 0;
}

.nav-drawer-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.nav-drawer-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-drawer-link.active {
    color: var(--accent);
    background: rgba(34, 197, 94, 0.06);
    border-left-color: var(--accent);
    font-weight: 600;
}

.nav-drawer-link svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-drawer-link.active svg {
    opacity: 1;
    stroke: var(--accent);
}

.nav-drawer-actions {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ── Hamburger animation ──────────────────────────────── */

.nav-toggle.open span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

.nav-toggle.open span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

@media (max-width: 768px) {
    /* Hide desktop nav, show toggle */
    .nav-links,
    .nav-actions {
        display: none;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-container {
        flex-wrap: wrap;
    }

    .main-content {
        padding: 1rem max(0.75rem, env(safe-area-inset-right)) 1rem max(0.75rem, env(safe-area-inset-left));
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .activity-stats {
        flex-direction: column;
        gap: 0.125rem;
        align-items: flex-end;
    }

    .race-cards {
        grid-template-columns: 1fr;
    }

    .plan-content {
        padding: 1rem;
    }



    #toast-container {
        left: max(0.75rem, env(safe-area-inset-left));
        right: max(0.75rem, env(safe-area-inset-right));
        bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    .toast {
        max-width: 100%;
    }

    /* Bottom nav for mobile */
    .footer {
        display: none;
    }

    .mobile-bottom-nav {
        display: flex;
    }
}

@media (max-width: 480px) {
    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.375rem;
    }

    .metric-card {
        padding: 0.75rem 0.5rem;
    }

    .metric-value {
        font-size: 1.4rem;
    }



    .activity-stats {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 0.25rem;
        padding-left: 3rem;
    }

    /* Activity detail page mobile */
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .te-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .hr-zone-legend {
        gap: 0.25rem;
    }

    .hr-zone-item {
        font-size: 0.75rem;
    }

    .back-link {
        padding: 0.375rem 0;
    }

    .zone-legend-inline {
        gap: 0.5rem;
        font-size: 0.6875rem;
    }

    .detail-section {
        margin-bottom: 1.25rem;
    }

    .filter-bar {
        gap: 0.375rem;
    }

    .filter-btn {
        padding: 0.375rem 0.625rem;
        font-size: 0.6875rem;
    }

    /* Progress page mobile */
    .chart-card {
        padding: 0.5rem;
    }

    .pred-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .pred-value {
        font-size: 1rem;
    }

    .section-title {
        font-size: 0.9375rem;
    }

    .chart-subtitle {
        font-size: 0.75rem;
    }
}

/* ── Mobile Bottom Nav ──────────────────────────── */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    padding: 0.375rem 0 max(0.375rem, env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: center;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
    gap: 0.125rem;
}

.bottom-nav-item .nav-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.bottom-nav-item.active {
    color: var(--accent);
}

.bottom-nav-item:hover {
    color: var(--text-primary);
}

/* Ensure main content doesn't go under bottom nav on mobile */
@media (max-width: 768px) {
    .main-content {
        padding-bottom: calc(4rem + env(safe-area-inset-bottom));
    }
}

/* ── Prediction Cards (Progress page) ─────────── */
.pred-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.pred-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    text-align: center;
}

.pred-card .pred-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.pred-card .pred-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.pred-card .pred-sub {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* ── Feedback Textarea (Plan page) ────────────── */
.feedback-group {
    width: 100%;
    margin-bottom: 0.75rem;
}

.feedback-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.feedback-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.feedback-textarea {
    width: 100%;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
    transition: border-color 0.2s;
}

.feedback-textarea::placeholder {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

/* ── Alert Banners (Dashboard) ────────────────── */
.alert-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border-left: 4px solid;
    background: var(--bg-white);
}

.alert-banner.alert-critical {
    background: var(--red-bg);
    border-left-color: var(--red);
}

.alert-banner.alert-warning {
    background: var(--amber-bg);
    border-left-color: var(--amber);
}

.alert-banner.alert-caution {
    background: rgba(234, 179, 8, 0.06);
    border-left-color: #eab308;
}

.alert-content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
}

.alert-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.alert-text {
    font-size: 0.8125rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.alert-text strong {
    display: block;
    margin-bottom: 0.125rem;
    font-weight: 700;
}

.alert-text span {
    color: var(--text-secondary);
}

.alert-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.alert-dismiss:hover {
    opacity: 1;
}

/* ── Readiness Gauge (Race Cards) ─────────────── */
.readiness-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    flex-shrink: 0;
}

.readiness-ring-wrap {
    position: relative;
    width: 44px;
    height: 44px;
}

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

.readiness-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 3;
}

.readiness-fill {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 0.6s ease;
}

.readiness-fill.fill-good { stroke: var(--accent); }
.readiness-fill.fill-ok { stroke: var(--amber); }
.readiness-fill.fill-low { stroke: var(--red); }

.readiness-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.6875rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.readiness-label {
    font-size: 0.5625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    line-height: 1;
}

/* ── Sparklines (Metric Cards) ───────────────── */
.sparkline {
    width: 100%;
    height: 18px;
    margin-top: 0.25rem;
}

.sparkline polyline {
    fill: none;
    stroke: var(--text-muted);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sparkline.sparkline-good polyline {
    stroke: var(--accent);
}

/* ── Weekly Training Summary ────────────────── */
.weekly-stats {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.weekly-stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    min-width: 90px;
    flex: 1;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
}

.weekly-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.weekly-stat-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--border-hover);
}

.weekly-stat-icon {
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.weekly-stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.weekly-stat-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
    font-weight: 500;
}

.weekly-stat-card.sport-run::before { background: var(--accent-run); }
.weekly-stat-card.sport-bike::before { background: var(--accent-bike); }
.weekly-stat-card.sport-swim::before { background: var(--accent-swim); }
.weekly-stat-card.sport-strength::before { background: var(--accent-strength); }
.weekly-stat-card.sport-hike::before { background: var(--accent-hike); }

/* ── Progress page chart theme override ──────── */
.apexcharts-canvas {
    font-family: var(--font-family) !important;
}

/* ── Brand Logo ─────────────────────────────── */
.brand-logo {
    color: var(--accent);
    flex-shrink: 0;
}

/* ── Sport Dots (replace emoji sport icons) ──── */
.sport-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.sport-dot-run { background: var(--accent-run); }
.sport-dot-bike { background: var(--accent-bike); }
.sport-dot-swim { background: var(--accent-swim); }
.sport-dot-strength { background: var(--accent-strength); }
.sport-dot-hike { background: var(--accent-hike); }
.sport-dot-walk { background: #92400e; }
.sport-dot-yoga { background: #db2777; }

.activity-sport-icon {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Race Type Badge ─────────────────────────── */
.race-type-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-sm);
    background: var(--accent-bg);
    color: var(--accent);
    font-size: 0.6875rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

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

.dot-red { background: var(--red); }
.dot-amber { background: var(--amber); }
.dot-yellow { background: #eab308; }

/* ── Mobile Calendar Fix ─────────────────────── */
@media (max-width: 768px) {
    .calendar-grid {
        gap: 2px;
    }

    .calendar-cell {
        min-height: 60px;
        padding: 0.25rem;
    }

    .calendar-cell .day-number {
        font-size: 0.6875rem;
    }

    .cal-item {
        font-size: 0.5625rem;
        padding: 1px 3px;
        margin-bottom: 1px;
        border-left-width: 2px;
    }

    .cal-item .sport-icon {
        display: none;
    }

    .calendar-day-header {
        font-size: 0.625rem;
        padding: 0.375rem 0;
    }

    .calendar-controls {
        gap: 1rem;
    }

    .calendar-month-label {
        font-size: 1rem;
        min-width: 140px;
    }

    /* Day detail panel: full width on mobile */
    .day-detail-panel {
        width: 100% !important;
    }
}

@media (max-width: 380px) {
    .calendar-cell {
        min-height: 48px;
        padding: 0.125rem;
    }

    .cal-item {
        font-size: 0.5rem;
        padding: 1px 2px;
    }

    .calendar-cell .day-number {
        font-size: 0.5625rem;
    }
}
