* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f4f6f8;
    color: #1f2933;
    line-height: 1.45;
}

.topbar {
    background: #111827;
    color: white;
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0;
}

.topbar-right nav {
    display: flex;
    align-items: center;
}

.topbar-right form {
    border-left: 1px solid rgba(255,255,255,0.15);
    padding-left: 16px;
    margin-left: 16px;
}

.topbar h1 {
    margin: 0;
    font-size: 26px;
}

.topbar p {
    margin: 4px 0 0;
    color: #cbd5e1;
}

nav a {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    font-weight: 600;
}

nav a:hover {
    text-decoration: underline;
}

.nav-logout {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.35);
    color: #cbd5e1;
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.nav-logout:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

nav a.nav-active {
    border-bottom: 2px solid white;
    padding-bottom: 2px;
}

.container {
    max-width: 1180px;
    margin: 32px auto;
    padding: 0 24px;
}

h2 {
    margin: 0 0 24px;
    font-size: 26px;
}

h3 {
    font-size: 20px;
}

h4 {
    font-size: 15px;
    margin: 22px 0 10px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.card {
    background: white;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

.card h3 {
    margin-top: 0;
    margin-bottom: 16px;
}

.card.primary {
    border-left: 6px solid #2563eb;
}

.wide-card,
.card.wide {
    grid-column: 1 / -1;
}

.ai-summary {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.5;
}

.ai-block {
    margin-top: 18px;
}

.ai-block h4 {
    margin-bottom: 6px;
}

.ai-block p {
    margin-top: 0;
    line-height: 1.5;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 20px;
}

.metric-grid div {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 14px;
}

.metric-grid span {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
    font-weight: 600;
}

.metric-grid strong {
    display: block;
    font-size: 18px;
}

.metric-grid small {
    display: block;
    margin-top: 4px;
    color: #64748b;
}

.flag-list,
.trend-list,
.zone-list,
.distribution-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.signal,
.flag,
.trend-row,
.distribution-row {
    border-radius: 12px;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

.signal-title {
    font-weight: 700;
    margin-bottom: 4px;
}

.signal-description {
    line-height: 1.45;
}

.signal .muted {
    display: block;
    margin-top: 6px;
}

.signal-positive {
    border-left: 4px solid #2e7d32;
    background: #f0f8f1;
}

.signal-notice {
    border-left: 4px solid #f9a825;
    background: #fff8e1;
}

.signal-warning {
    border-left: 4px solid #c62828;
    background: #ffebee;
}

.stale-notice {
    font-size: 13px;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 8px 12px;
    margin: 0 0 12px;
}

.trend-row,
.distribution-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.trend-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.trend-text strong {
    font-weight: 700;
}

.trend-text small {
    color: #64748b;
    font-size: 13px;
    line-height: 1.35;
}

.trend-badge {
    flex-shrink: 0;
    min-width: 92px;
    text-align: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e8edf5;
    font-size: 13px;
    font-weight: 700;
    text-transform: capitalize;
}

.period-menu {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 14px 0 16px;
}

.period-menu a,
.period-menu button {
    padding: 7px 13px;
    border-radius: 999px;
    text-decoration: none;
    background: #eef2f7;
    color: #334155;
    font-size: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.period-menu a.active,
.period-menu button.active {
    background: #1f2937;
    color: white;
}

.selected-period,
.muted {
    color: #64748b;
    font-size: 14px;
}

.zone-row {
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

.zone-row-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 7px;
}

.zone-row-header span {
    color: #64748b;
    font-size: 14px;
}

.zone-bar {
    width: 100%;
    height: 9px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.zone-bar-fill {
    width: var(--bar-width);
    height: 100%;
    border-radius: 999px;
    background: #2563eb;
}

.status {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
}

.status.passed,
.status.ok,
.status.high {
    background: #dcfce7;
    color: #166534;
}

.status.warning,
.status.medium {
    background: #fef3c7;
    color: #92400e;
}

.status.failed,
.status.low {
    background: #fee2e2;
    color: #991b1b;
}

ul {
    padding-left: 20px;
}

hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 18px 0;
}

@media (max-width: 800px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .topbar-right {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .topbar-right form {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
    }

    nav a {
        margin-left: 0;
        margin-right: 16px;
    }

    .grid,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .trend-row,
    .distribution-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .trend-badge {
        min-width: auto;
    }
}

.chat-box {
    min-height: 180px;
    max-height: 420px;
    overflow-y: auto;
    padding: 14px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    margin-bottom: 14px;
}

.chat-message {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 12px;
}

.chat-message.user {
    background: #e8edf5;
}

.chat-message.assistant {
    background: white;
    border: 1px solid #e5e7eb;
}

.chat-message strong {
    display: block;
    margin-bottom: 4px;
}

.chat-message p {
    margin: 0;
    line-height: 1.45;
}

.chat-form input {
    flex: 1;
    padding: 11px 13px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    font-size: 15px;
}

.chat-form button {
    padding: 11px 16px;
    border: none;
    border-radius: 10px;
    background: #2563eb;
    color: white;
    font-weight: 700;
    cursor: pointer;
}

.chat-form button:hover {
    background: #1d4ed8;
}

.chat-message.assistant p {
    margin: 0 0 10px;
}

.chat-message.assistant ul {
    margin: 8px 0 12px;
    padding-left: 20px;
}

.chat-message.assistant li {
    margin-bottom: 4px;
}

.chat-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-textarea {
    width: 100%;
    min-height: 70px;
    max-height: 240px;
    resize: none;

    padding: 14px 16px;

    border-radius: 14px;
    border: 1px solid #cbd5e1;

    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;

    background: white;
    color: #1f2933;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.chat-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.chat-actions {
    display: flex;
    justify-content: flex-end;
}

.chat-actions button {
    padding: 11px 18px;
    border: none;
    border-radius: 10px;

    background: #2563eb;
    color: white;

    font-size: 14px;
    font-weight: 700;

    cursor: pointer;

    transition:
        background 0.15s ease,
        transform 0.1s ease;
}

.chat-actions button:hover {
    background: #1d4ed8;
}

.chat-actions button:active {
    transform: translateY(1px);
}

.chat-answer { line-height: 1.6; }

.chat-answer > *:first-child { margin-top: 0; }
.chat-answer > *:last-child  { margin-bottom: 0; }

.chat-answer p  { margin: 0 0 10px; }
.chat-answer hr { border: none; border-top: 1px solid #dbe2ea; margin: 14px 0; }

.chat-answer h1, .chat-answer h2,
.chat-answer h3, .chat-answer h4 {
    font-size: 15px;
    font-weight: 700;
    margin: 16px 0 6px;
}

.chat-answer ul, .chat-answer ol {
    margin: 4px 0 12px;
    padding-left: 22px;
}

.chat-answer li          { margin-bottom: 5px; line-height: 1.5; }
.chat-answer strong      { font-weight: 700; }
.chat-answer em          { font-style: italic; }
.chat-answer code        { font-family: monospace; font-size: 13px; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }

.chat-answer table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}
.chat-answer th, .chat-answer td {
    border: 1px solid #dbe2ea;
    padding: 7px 10px;
    text-align: left;
}
.chat-answer th { background: #f1f5f9; font-weight: 700; }

.chat-table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 14px;
}

.chat-table td {
    border: 1px solid #dbe2ea;
    padding: 8px 10px;
}

.chat-table tr:first-child td {
    background: #f1f5f9;
    font-weight: 700;
}

.sync-button {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    background: #2563eb;
    color: white;
    font-weight: 700;
    cursor: pointer;
}

.sync-button:hover {
    background: #1d4ed8;
}

.sync-button:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.chart-controls {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.chart-controls div {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chart-controls label {
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
}

.chart-controls select {
    min-width: 180px;
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: white;
    font: inherit;
}

.chart-card {
    height: 340px;
    padding: 16px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

/* ── Hero banner ── */
.hero {
    border-radius: 18px;
    padding: 32px 36px;
    margin-bottom: 20px;
}

.hero-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.hero-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    background: rgba(0,0,0,0.1);
    margin-bottom: 10px;
}

.hero-readiness {
    font-size: 52px;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}

.hero-readiness-label {
    font-size: 16px;
    font-weight: 600;
    opacity: 0.65;
}

.hero-summary {
    font-size: 16px;
    line-height: 1.5;
    max-width: 560px;
    margin: 0;
    opacity: 0.85;
}

.hero-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.hero-sync-btn {
    padding: 11px 22px;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 10px;
    background: rgba(0,0,0,0.08);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.hero-sync-btn:hover   { background: rgba(0,0,0,0.16); }
.hero-sync-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.hero-sync-status {
    font-size: 13px;
    margin: 0;
    opacity: 0.7;
    text-align: right;
}

/* day-type colour themes */
.hero-easy     { background: #d1fae5; color: #064e3b; }
.hero-rest     { background: #fee2e2; color: #7f1d1d; }
.hero-moderate { background: #fef3c7; color: #78350f; }
.hero-hard     { background: #ffedd5; color: #7c2d12; }
.hero-unknown  { background: #f1f5f9; color: #334155; }

/* ── Data gap notice ── */
.data-gap-notice {
    background: #fef9c3;
    color: #713f12;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    margin-bottom: 16px;
}
.data-gap-notice.data-gap-stale {
    background: #fff7ed;
    color: #9a3412;
    border-color: #fed7aa;
}
@media (prefers-color-scheme: dark) {
    .data-gap-notice { background: #422006; color: #fef08a; border-color: #713f12; }
    .data-gap-notice.data-gap-stale { background: #431407; color: #fdba74; border-color: #9a3412; }
}
:root[data-theme="light"] .data-gap-notice { background: #fef9c3; color: #713f12; border-color: #fde68a; }
:root[data-theme="light"] .data-gap-notice.data-gap-stale { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
:root[data-theme="dark"] .data-gap-notice { background: #422006; color: #fef08a; border-color: #713f12; }
:root[data-theme="dark"] .data-gap-notice.data-gap-stale { background: #431407; color: #fdba74; border-color: #9a3412; }

/* ── Metric strip ── */
.metric-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
    /* Allow extra tiles to wrap to a second row */
    grid-auto-rows: auto;
}

.ms-tile {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 16px 18px 12px;
    box-shadow: 0 1px 4px rgba(15,23,42,0.06);
}

.ms-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ms-value {
    display: block;
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 10px;
    line-height: 1;
}

.sparkline {
    display: block;
    width: 100%;
    height: 28px;
    color: #94a3b8;
}

.ms-tile.metric-high  { border-left: 4px solid #22c55e; }
.ms-tile.metric-high .sparkline { color: #22c55e; }

.ms-tile.metric-medium { border-left: 4px solid #f59e0b; }
.ms-tile.metric-medium .sparkline { color: #f59e0b; }

.ms-tile.metric-low   { border-left: 4px solid #ef4444; }
.ms-tile.metric-low .sparkline { color: #ef4444; }

/* TSB (form) color coding */
.ms-tile.tsb-fresh        { border-left: 4px solid #22c55e; } /* positive — fresh/peaked */
.ms-tile.tsb-neutral      { border-left: 4px solid #3b82f6; } /* -10..5 — normal training */
.ms-tile.tsb-tired        { border-left: 4px solid #f59e0b; } /* -25..-10 — some fatigue */
.ms-tile.tsb-overreaching { border-left: 4px solid #ef4444; } /* < -25 — overreaching */

/* Divider between health and PMC tiles */
.ms-tile-divider {
    border-top: 3px solid #e5e7eb;
    margin-top: 2px;
}

/* Sub-label inside tile label (e.g. "fitness" next to "CTL") */
.ms-sublabel {
    font-size: 10px;
    font-weight: 500;
    color: #94a3b8;
    margin-left: 4px;
    text-transform: none;
    letter-spacing: 0;
}

/* Interval counter fraction styling */
.ms-of {
    font-size: 14px;
    font-weight: 600;
    color: #94a3b8;
    margin-left: 1px;
}

/* ── AI Reasoning collapsible ── */
.ai-details {
    margin-bottom: 20px;
}

.ai-details-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
    font-size: 16px;
    font-weight: 700;
    padding-bottom: 0;
    gap: 12px;
}

.ai-details-summary::-webkit-details-marker { display: none; }

.ai-details-summary::after {
    content: "▸";
    font-size: 14px;
    color: #94a3b8;
    transition: transform 0.2s;
    margin-left: auto;
}

.ai-details[open] .ai-details-summary::after {
    transform: rotate(90deg);
}

.ai-detail-body {
    margin-top: 18px;
    border-top: 1px solid #e5e7eb;
    padding-top: 18px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

/* ── Bottom grid (Data Quality + System Status) ── */
.bottom-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* ── Chat page ── */
.chat-page-card {
    max-width: 780px;
}

/* ── Activity hero ── */
.hero-activity { background: #1e293b; color: white; }
.hero-activity .hero-badge { background: rgba(255,255,255,0.15); }
.hero-activity .muted { color: rgba(255,255,255,0.6); }

.hero-name {
    font-size: 36px;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 8px;
}

.hero-meta { margin: 0; font-size: 15px; }

/* Load / status pill */
.status-pill {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    text-transform: capitalize;
}
.pill-high, .pill-high-load { background: #ffedd5; color: #9a3412; }
.pill-moderate, .pill-moderate-load { background: #fef3c7; color: #92400e; }
.pill-low, .pill-low-load { background: #dcfce7; color: #166534; }

/* ms-tile sub-label */
.ms-sub {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    line-height: 1.3;
}

/* section header with inline period menu */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 0;
}

.section-header h3 { margin: 0; }

/* Activity workout structure card */
.activity-kv {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 12px;
}

.activity-kv-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.activity-kv-label {
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.activity-kv-value {
    font-size: 14px;
    font-weight: 600;
    text-align: right;
}

.activity-interval-desc {
    font-size: 14px;
    color: #475569;
    margin: 12px 0 0;
    line-height: 1.5;
}

.activity-hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 16px 0;
}

.activity-fatigue-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 4px;
}

.activity-fatigue-text {
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 12px;
}

.activity-summary {
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
    white-space: pre-wrap;
    margin: 8px 0 0;
}

/* Training interpretation grid */
.interp-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.interp-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.interp-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
}

.interp-value {
    font-weight: 700;
    font-size: 15px;
}

/* ── Responsive ── */
@media (max-width: 800px) {
    .hero-content { flex-direction: column; }
    .hero-right   { align-items: flex-start; }
    .hero-readiness { font-size: 38px; }

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

    .ai-detail-body { grid-template-columns: 1fr; }

    .bottom-grid { grid-template-columns: 1fr; }
}

/* Metric tile colour variants */
.metric-grid div.metric-high {
    background: #f0fdf4;
    border-color: #86efac;
}

.metric-grid div.metric-medium {
    background: #fffbeb;
    border-color: #fcd34d;
}

.metric-grid div.metric-low {
    background: #fff1f2;
    border-color: #fca5a5;
}

/* Recommendation badge */
.rec-badge {
    display: inline-block;
    margin-left: 10px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    vertical-align: middle;
    letter-spacing: 0.05em;
}

.rec-rest    { background: #fee2e2; color: #991b1b; }
.rec-easy    { background: #dcfce7; color: #166534; }
.rec-moderate { background: #fef3c7; color: #92400e; }
.rec-hard    { background: #ffedd5; color: #9a3412; }
.rec-unknown { background: #f1f5f9; color: #64748b; }

/* ── Workout card ── */
.workout-card {
    border-left: 4px solid #2563eb;
    margin-bottom: 20px;
}

/* Workout day tabs */
.workout-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0;
}

.workout-tab {
    padding: 8px 18px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}

.workout-tab:hover { color: #2563eb; }

.workout-tab-active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* Assessment card */
.assess-card {
    border-left: 4px solid #7c3aed;
    margin-bottom: 20px;
}

.assess-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.assess-header h3 { margin: 0 0 4px; }

.assess-btn {
    padding: 8px 18px;
    background: #7c3aed;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.assess-btn:hover { background: #6d28d9; }
.assess-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.assess-result {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.assess-section h4 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin: 0 0 6px;
}

.assess-section p {
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
}

.workout-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 14px;
}

.workout-header h3 { margin: 0 0 4px; }

.workout-goal {
    font-size: 15px;
    font-weight: 600;
    color: #1e40af;
    margin: 0 0 20px;
    line-height: 1.4;
}

.workout-structure {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.workout-phase {
    padding: 14px 18px;
    border-bottom: 1px solid #f1f5f9;
}

.workout-phase:last-child { border-bottom: none; }

.workout-phase-main {
    background: #eff6ff;
}

.workout-phase-label {
    display: block;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    margin-bottom: 4px;
}

.workout-phase-main .workout-phase-label { color: #1d4ed8; }

.workout-phase-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

.workout-note {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.45;
    color: #78350f;
    margin-bottom: 4px;
}

.workout-empty {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.workout-empty h3 { margin: 0 0 6px; }

.workout-gen-btn {
    padding: 12px 24px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.workout-gen-btn:hover    { background: #1d4ed8; }
.workout-gen-btn:disabled { background: #94a3b8; cursor: not-allowed; }

.workout-regen-btn {
    padding: 8px 16px;
    background: transparent;
    color: #2563eb;
    border: 1.5px solid #2563eb;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s;
}

.workout-regen-btn:hover    { background: #eff6ff; }
.workout-regen-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.workout-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sport-toggle {
    display: flex;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.sport-btn {
    padding: 7px 14px;
    background: transparent;
    color: #64748b;
    border: none;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.sport-btn + .sport-btn {
    border-left: 1.5px solid #e2e8f0;
}

.sport-btn-active {
    background: #2563eb;
    color: white;
}

.sport-btn:not(.sport-btn-active):hover {
    background: #f1f5f9;
    color: #1e293b;
}

/* Duration toggle — same visual as sport-toggle but smaller text */
.duration-toggle {
    display: flex;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.dur-btn {
    padding: 7px 10px;
    background: transparent;
    color: #64748b;
    border: none;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.dur-btn + .dur-btn { border-left: 1.5px solid #e2e8f0; }

.dur-btn-active { background: #0f766e; color: white; }

.dur-btn:not(.dur-btn-active):hover { background: #f1f5f9; color: #1e293b; }

/* Mini coach chat card */
.mini-chat-card {
    border-left: 4px solid #0f766e;
    margin-bottom: 20px;
}

.mini-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.mini-chat-header h3 { margin: 0; }

.mini-chat-subtitle {
    margin: 0 0 14px;
    font-size: 13px;
}

.mini-chat-link {
    font-size: 13px;
    color: #0f766e;
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.mini-chat-link:hover { text-decoration: underline; }

.mini-chat-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
    margin-bottom: 14px;
}

.mini-chat-msg { display: flex; }

.mini-chat-user { justify-content: flex-end; }
.mini-chat-assistant { justify-content: flex-start; }

.mini-chat-bubble {
    max-width: 92%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
}

.mini-chat-bubble-user { max-width: 75%; }

.mini-chat-bubble-user {
    background: #eff6ff;
    color: #1e3a8a;
    border-bottom-right-radius: 4px;
}

.mini-chat-bubble-coach {
    background: #f0fdf4;
    color: #14532d;
    border-bottom-left-radius: 4px;
    border: 1px solid #d1fae5;
    max-width: 100%;
}

.mini-chat-bubble p { margin: 0 0 6px; }
.mini-chat-bubble p:last-child { margin-bottom: 0; }
.mini-chat-bubble ul, .mini-chat-bubble ol {
    margin: 4px 0 6px;
    padding-left: 18px;
}
.mini-chat-bubble li { margin-bottom: 3px; }
.mini-chat-bubble strong { font-weight: 700; }
.mini-chat-bubble h1, .mini-chat-bubble h2, .mini-chat-bubble h3,
.mini-chat-bubble h4 {
    font-size: 13px;
    font-weight: 700;
    margin: 8px 0 4px;
}

.mini-chat-empty {
    font-size: 13px;
    color: #94a3b8;
    text-align: center;
    padding: 20px 0;
    margin: 0;
}

.mini-chat-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mini-chat-form {
    display: flex;
    gap: 8px;
}

.mini-chat-input {
    flex: 1;
    padding: 9px 13px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    background: #f8fafc;
}

.mini-chat-input:focus {
    border-color: #0f766e;
    background: white;
}

.mini-chat-send {
    padding: 9px 18px;
    background: #0f766e;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s;
}

.mini-chat-send:hover { background: #0d6b61; }

.mini-regen-btn {
    width: 100%;
    padding: 9px 16px;
    background: white;
    color: #0f766e;
    border: 1.5px solid #0f766e;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mini-regen-btn:hover {
    background: #0f766e;
    color: white;
}

.workout-status {
    font-size: 13px;
    color: #64748b;
    margin: 8px 0 0;
    min-height: 18px;
}

@media (max-width: 800px) {
    .workout-empty { flex-direction: column; align-items: flex-start; }
    .workout-header { flex-direction: column; align-items: flex-start; }
    .workout-actions { flex-wrap: wrap; }
}

/* ── Templates page ── */
.template-count {
    display: inline-block;
    background: #e5e7eb;
    color: #374151;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 8px;
    vertical-align: middle;
}

.upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 14px;
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    margin-top: 16px;
}

.upload-area:hover, .upload-area.drag-over {
    border-color: #2563eb;
    background: #eff6ff;
}

.upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
    color: #94a3b8;
}

.upload-area p { margin: 0; color: #64748b; }

.upload-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.upload-filename {
    margin: 0;
    font-size: 14px;
    color: #1f2933;
    font-weight: 600;
}

.upload-submit-btn {
    padding: 10px 22px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.upload-submit-btn:hover    { background: #1d4ed8; }
.upload-submit-btn:disabled { background: #94a3b8; cursor: not-allowed; }

.upload-status {
    font-size: 13px;
    color: #64748b;
    margin: 10px 0 0;
    min-height: 18px;
}

.template-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.template-item {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px 20px;
    background: #f8fafc;
}

.template-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.template-item-name {
    display: block;
    font-size: 16px;
    margin-bottom: 2px;
}

.template-item-meta {
    font-size: 12px;
    color: #64748b;
}

.template-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.template-item-source {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
}

.template-delete-btn {
    padding: 4px 12px;
    border: 1px solid #fca5a5;
    background: #fff1f2;
    color: #dc2626;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.template-delete-btn:hover { background: #fee2e2; }

.template-item-goal {
    font-size: 13px;
    color: #374151;
    margin: 0 0 14px;
    font-style: italic;
}

.template-phases {
    display: flex;
    flex-direction: column;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
}

.template-phase {
    display: flex;
    gap: 14px;
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}

.template-phase:last-child { border-bottom: none; }

.template-phase-main { background: #eff6ff; }

.template-phase-text { color: #374151; }

.template-item-builtin {
    background: white;
    opacity: 0.85;
}

.builtin .template-item { cursor: default; }

@media (max-width: 700px) {
    .template-item-header { flex-direction: column; }
    .template-item-actions { flex-wrap: wrap; }
}
/* ── Login page ── */
.login-body {
    background: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px 36px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

.login-header {
    margin-bottom: 28px;
}

.login-header h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

.login-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 18px;
}

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #374151;
}

.login-form input {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    margin-bottom: 18px;
    outline: none;
    transition: border-color 0.12s;
}

.login-form input:focus {
    border-color: #2563eb;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 4px;
}

.login-btn:hover { background: #1d4ed8; }

/* ── Chat clear button ── */
.chat-clear-btn {
    padding: 6px 14px;
    background: transparent;
    color: #94a3b8;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.12s, border-color 0.12s;
}

.chat-clear-btn:hover {
    color: #b91c1c;
    border-color: #fca5a5;
}

/* ── Training phase card ── */
.phase-card {
    padding: 16px 20px;
    margin-bottom: 16px;
}

.phase-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.phase-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.phase-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.phase-base         { background: #dcfce7; color: #15803d; }
.phase-build        { background: #dbeafe; color: #1d4ed8; }
.phase-peak         { background: #fef9c3; color: #a16207; }
.phase-taper        { background: #fce7f3; color: #be185d; }
.phase-goal_reached { background: #f3e8ff; color: #7e22ce; }
.phase-none         { background: #f1f5f9; color: #64748b; }

.phase-meta {
    font-size: 13px;
    color: #475569;
}

.phase-description {
    margin: 10px 0 2px;
    font-size: 14px;
    color: #1e293b;
}

.phase-emphasis {
    margin: 0;
    font-size: 12px;
}

.phase-edit-btn {
    padding: 5px 13px;
    background: transparent;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color 0.12s, color 0.12s;
}

.phase-edit-btn:hover { border-color: #94a3b8; color: #1e293b; }

.phase-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

.phase-form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.phase-form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 180px;
}

.phase-form-date { flex: 0 0 180px; }

.phase-form-field label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.phase-form-field input {
    padding: 8px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.12s;
}

.phase-form-field input:focus { border-color: #2563eb; }

.phase-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.phase-save-btn {
    padding: 7px 18px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s;
}

.phase-save-btn:hover    { background: #1d4ed8; }
.phase-save-btn:disabled { background: #94a3b8; cursor: not-allowed; }

.phase-delete-btn {
    padding: 7px 14px;
    background: transparent;
    color: #b91c1c;
    border: 1.5px solid #fca5a5;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s;
}

.phase-delete-btn:hover { background: #fef2f2; }

.phase-cancel-btn {
    padding: 7px 14px;
    background: transparent;
    color: #64748b;
    border: none;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}

.phase-status {
    font-size: 12px;
    color: #b91c1c;
    margin: 6px 0 0;
}

/* ── Latest Activity card (dashboard) ── */
.act-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.act-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.act-metric {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
}

.act-metric-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 3px;
}

.act-metric-value {
    display: block;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.1;
}

.act-metric-sub {
    display: block;
    font-size: 11px;
    color: #64748b;
    margin-top: 3px;
    line-height: 1.3;
}

.act-interval {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.act-interval-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #1d4ed8;
    margin-bottom: 4px;
}

.act-interval-pattern {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.4;
    white-space: pre-line;
}

.act-interval-sub {
    display: block;
    font-size: 12px;
    color: #475569;
    margin-top: 4px;
}

.act-stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 12px 0 16px;
}

.act-stat {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 10px 8px;
    text-align: center;
}

.act-stat span {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.act-stat strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.act-fatigue {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.act-fatigue-label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

.act-fatigue-desc {
    font-size: 13px;
    color: #475569;
    line-height: 1.5;
    margin: 0;
}

/* Training Effect card */
.te-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 0;
    border-bottom: 1px solid #f1f5f9;
    gap: 12px;
}

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

.te-label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    flex-shrink: 0;
}

.te-stimulus-text {
    font-size: 13px;
    font-weight: 600;
    text-align: right;
}

@media (max-width: 800px) {
    .act-metrics { grid-template-columns: repeat(2, 1fr); }
}

/* custom duration input in workout duration toggle */
.dur-custom {
    width: 72px;
    padding: 6px 8px;
    border: none;
    border-left: 1.5px solid #e2e8f0;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    color: #64748b;
    background: transparent;
    outline: none;
}

.dur-custom:focus { color: #1e293b; }

.dur-unit {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    padding-right: 8px;
}

/* ── Profile page ── */
.profile-header {
    margin-bottom: 20px;
}

.profile-header h2 { margin: 0 0 4px; }

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

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

.profile-section {
    margin-bottom: 24px;
}

.profile-section:last-of-type { margin-bottom: 16px; }

.profile-section-title {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #94a3b8;
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}

.profile-row {
    display: flex;
    gap: 16px;
}

.profile-row .profile-field { flex: 1; }

.profile-field label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.profile-field input,
.profile-field select {
    padding: 9px 11px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: #1e293b;
    outline: none;
    transition: border-color 0.12s;
    background: white;
}

.profile-field input:focus,
.profile-field select:focus {
    border-color: #2563eb;
}

.profile-input-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-input-unit input { flex: 1; }

.profile-unit {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    white-space: nowrap;
}

.profile-hint {
    font-size: 12px;
    color: #94a3b8;
}

.profile-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-top: 4px;
}

.profile-save-btn {
    padding: 9px 22px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.14s;
}

.profile-save-btn:hover    { background: #1d4ed8; }
.profile-save-btn:disabled { background: #94a3b8; cursor: not-allowed; }

.profile-status {
    font-size: 13px;
    margin: 0;
}

/* Body composition tiles */
.profile-body-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.profile-body-tile {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-body-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
}

.profile-body-value {
    font-size: 22px;
    font-weight: 800;
    color: #1e293b;
}

.profile-body-unit {
    font-size: 12px;
    color: #94a3b8;
}
