:root {
    --bg: #111714;
    --surface: #17211c;
    --surface-2: #1e2d26;
    --text: #f3f1e8;
    --muted: #a8b3aa;
    --line: rgba(243, 241, 232, 0.14);
    --green: #79c68d;
    --blue: #7eb4d8;
    --amber: #d9a85f;
    --red: #d16f63;
    --violet: #a792da;
    --shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
    --max-width: 1240px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        linear-gradient(90deg, rgba(243, 241, 232, 0.035) 1px, transparent 1px),
        linear-gradient(180deg, rgba(243, 241, 232, 0.035) 1px, transparent 1px),
        var(--bg);
    background-size: 48px 48px;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

button,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
}

.app-shell {
    width: min(var(--max-width), calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 22px 0;
}

.brand,
.home-link,
.icon-button,
.segmented button {
    border: 1px solid var(--line);
    background: rgba(30, 45, 38, 0.84);
    color: var(--text);
    text-decoration: none;
}

.brand,
.icon-button {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-weight: 850;
}

.home-link {
    border-radius: 999px;
    padding: 10px 14px;
    color: var(--muted);
    font-weight: 750;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--amber);
    font-size: 0.74rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 1.25rem;
    line-height: 1;
}

h2 {
    max-width: 820px;
    margin-bottom: 0;
    font-size: clamp(2.4rem, 7vw, 6.6rem);
    line-height: 0.93;
    letter-spacing: 0;
}

h3 {
    margin-bottom: 0;
    font-size: 1.08rem;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.38fr);
    gap: 28px;
    align-items: end;
    border-top: 1px solid var(--line);
    padding: clamp(34px, 7vw, 78px) 0 28px;
}

.hero-status,
.panel,
.metric-card,
.controls {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(23, 33, 28, 0.86);
    box-shadow: var(--shadow);
}

.hero-status {
    padding: 18px;
    color: var(--muted);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    margin: 18px 0;
    padding: 12px;
}

.segmented {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.segmented button {
    min-width: 54px;
    border-radius: 999px;
    padding: 9px 12px;
    color: var(--muted);
    font-weight: 820;
}

.segmented button.is-active {
    border-color: rgba(121, 198, 141, 0.55);
    background: rgba(121, 198, 141, 0.15);
    color: var(--green);
}

.toggle {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-weight: 720;
}

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

.metric-card {
    min-height: 138px;
    padding: 16px;
}

.metric-card span,
.metric-card small,
.panel-heading span {
    color: var(--muted);
}

.metric-card span {
    display: block;
    margin-bottom: 14px;
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.metric-card strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: clamp(1.9rem, 4vw, 3.2rem);
    line-height: 1;
}

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

.panel {
    overflow: hidden;
    padding: 18px;
}

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

.panel-heading {
    display: flex;
    gap: 14px;
    align-items: start;
    justify-content: space-between;
    margin-bottom: 12px;
}

canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    border: 1px solid rgba(243, 241, 232, 0.08);
    border-radius: 6px;
    background: rgba(7, 10, 8, 0.24);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.legend span {
    display: inline-flex;
    gap: 7px;
    align-items: center;
}

.legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend .fitness {
    background: var(--green);
}

.legend .fatigue {
    background: var(--amber);
}

.legend .form {
    background: var(--blue);
}

.notes-panel p {
    color: var(--muted);
}

textarea {
    width: 100%;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(7, 10, 8, 0.24);
    padding: 12px;
    color: var(--text);
}

.activity-list {
    display: grid;
    gap: 8px;
}

.activity-row {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) repeat(5, minmax(76px, 0.22fr));
    gap: 10px;
    align-items: center;
    border-top: 1px solid var(--line);
    padding: 12px 0;
    color: var(--muted);
}

.activity-row strong {
    display: block;
    overflow: hidden;
    color: var(--text);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-row span {
    font-variant-numeric: tabular-nums;
}

@media (max-width: 980px) {
    .hero,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

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

    .activity-row {
        grid-template-columns: minmax(0, 1fr) repeat(2, minmax(70px, 0.25fr));
    }

    .activity-row span:nth-child(n+4) {
        display: none;
    }
}

@media (max-width: 620px) {
    .app-shell {
        width: min(100% - 24px, var(--max-width));
    }

    .topbar {
        grid-template-columns: 44px minmax(0, 1fr);
    }

    .home-link {
        grid-column: 1 / -1;
        justify-self: start;
    }

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

    .controls {
        align-items: stretch;
        flex-direction: column;
    }

    .segmented {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .segmented button {
        min-width: 0;
        padding-inline: 6px;
    }
}
