/* Trainr — "Chalk & Iron". Tokens mirror design/system/project/tokens.json (scripts/check-design-tokens.py). */
:root {
    color-scheme: dark;
    --bg: #0D0E10;
    --surface: #16181B;
    --surface-2: #1F2226;
    --line: #2B2F35;
    --text: #F2F0EB;
    --text-muted: #9A9EA5;
    --accent: #FF5A1F;
    --accent-ink: #0D0E10;
    --accent-soft: #FF5A1F24;
    --success: #3DDC97;
    --success-ink: #07130D;
    --warning: #FFB020;
    --danger: #FF4D4F;
    --info: #5AA9FF;
    --grid: #22262B;
    --shadow: none;

    --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --r-s: 8px;
    --r-m: 14px;
    --r-l: 22px;
    --nav-w: 232px;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        color-scheme: light;
        --bg: #F4F2ED;
        --surface: #FFFFFF;
        --surface-2: #ECE9E2;
        --line: #DAD6CD;
        --text: #141518;
        --text-muted: #63666C;
        --accent: #E5470E;
        --accent-ink: #FFFFFF;
        --accent-soft: #E5470E1A;
        --success: #16A56B;
        --success-ink: #07130D;
        --warning: #C98200;
        --danger: #D92D2F;
        --info: #1F74D6;
        --grid: #E6E2DA;
        --shadow: 0 1px 2px rgba(20, 21, 24, .06);
    }
}

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

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.1; }
p { margin: 0; }

.display {
    font-weight: 800;
    font-stretch: 125%;
    letter-spacing: -0.01em;
    text-transform: uppercase;
}
h1.display { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
.eyebrow {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.muted { color: var(--text-muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.accent { color: var(--accent); }
.ok { color: var(--success); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shell ---------- */
.shell { min-height: 100dvh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--nav-w);
    padding: 24px 16px;
    border-right: 1px solid var(--line);
    background: var(--bg);
    display: flex; flex-direction: column; gap: 4px;
    z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 24px; }
.brand svg { width: 34px; height: auto; color: var(--text); }
.brand span { font-weight: 800; font-stretch: 125%; font-size: 20px; letter-spacing: .02em; text-transform: uppercase; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--r-s);
    color: var(--text-muted); font-weight: 600; font-size: 15px;
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav-link svg { width: 20px; height: 20px; flex: none; }
.sidebar .spacer { flex: 1; }
.main { margin-left: var(--nav-w); padding: 32px clamp(16px, 4vw, 48px) 64px; max-width: calc(1180px + var(--nav-w)); }
.tabbar { display: none; }

@media (max-width: 860px) {
    .sidebar { display: none; }
    .main { margin-left: 0; padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
    .tabbar {
        display: grid; grid-template-columns: repeat(5, 1fr);
        position: fixed; inset: auto 0 0 0; z-index: 30;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        background: color-mix(in srgb, var(--bg) 88%, transparent);
        backdrop-filter: blur(14px);
        border-top: 1px solid var(--line);
    }
    .tabbar .nav-link { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 2px; justify-content: center; }
    .tabbar .nav-link.active { background: none; box-shadow: none; color: var(--accent); }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-head > .grow { flex: 1 1 260px; min-width: 0; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.back:hover { color: var(--text); }
.back svg { width: 16px; height: 16px; }

/* ---------- Surfaces ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-m);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card.tight { padding: 14px 16px; }
.card.stripe { position: relative; overflow: hidden; border: 0; }
.card.clickable { cursor: pointer; transition: background .15s; }
.card.clickable:hover { background: var(--surface-2); }
.card.stripe::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.lg { gap: 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--line); margin: 8px 0; border: 0; }
.section { margin-top: 32px; }
.section > .eyebrow { display: block; margin-bottom: 12px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px;
    border-radius: 999px; border: 1px solid var(--line);
    background: var(--surface-2); color: var(--text);
    font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap;
    transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.success { background: var(--success); border-color: var(--success); color: var(--success-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 14px; }
.btn.lg { height: 52px; padding: 0 26px; font-size: 17px; }
.btn.block { width: 100%; }
.icon-btn {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px; border-radius: 999px;
    border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.input, select.input, textarea.input {
    height: 42px; padding: 0 12px;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-s);
    outline: none; width: 100%;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.num { text-align: center; }
.input.compact { height: 36px; padding: 0 8px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-muted); }
.search .input { padding-left: 38px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    height: 32px; padding: 0 12px; border-radius: 999px;
    border: 1px solid var(--line); background: transparent; color: var(--text-muted);
    font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.accent-on.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 999px; border: 1px solid var(--line); }
.segmented button { border: 0; background: transparent; padding: 7px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; color: var(--text-muted); cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 0 var(--line); }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    height: 22px; padding: 0 8px; border-radius: 999px;
    font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    background: var(--surface-2); color: var(--text-muted);
}
.badge svg { width: 12px; height: 12px; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.badge.warn { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.badge.info { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 4px; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, button.list-item:hover { background: var(--surface-2); border-radius: var(--r-s); }
button.list-item { border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%; cursor: pointer; }
.chev { width: 18px; height: 18px; color: var(--text-muted); flex: none; }
.glyph {
    width: 40px; height: 40px; border-radius: 12px; flex: none;
    display: grid; place-items: center; background: var(--surface-2); color: var(--text);
}
.glyph svg { width: 20px; height: 20px; }
.glyph.accent { background: var(--accent-soft); color: var(--accent); }

.empty {
    border: 1px dashed var(--line); border-radius: var(--r-m);
    padding: 32px 20px; text-align: center; color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.empty svg { width: 32px; height: 32px; color: var(--text-muted); }

/* ---------- Stat tiles ---------- */
.tile { padding: 16px 18px; }
.tile .value { font-family: var(--mono); font-weight: 700; font-size: 32px; line-height: 1; margin-top: 10px; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 14px; color: var(--text-muted); margin-left: 4px; font-weight: 600; }
.tile .label { display: flex; align-items: center; gap: 6px; }
.tile .label svg { width: 14px; height: 14px; }

/* ---------- Hero ---------- */
.hero-card {
    padding: 24px; display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.hero-card h2 { font-size: 26px; font-weight: 800; font-stretch: 125%; text-transform: uppercase; margin-top: 6px; }
.hero-card .meta { display: flex; gap: 14px; margin-top: 8px; color: var(--text-muted); font-size: 14px; flex-wrap: wrap; }
.ex-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* ---------- Charts ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--text-muted); font-size: 11px; font-family: var(--mono); }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { fill: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g:hover .bar { filter: brightness(1.15); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#areaGrad); }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .value-label { fill: var(--text); font-size: 11px; font-family: var(--mono); font-weight: 600; }
.chart-tip {
    position: absolute; pointer-events: none; transform: translate(-50%, calc(-100% - 10px));
    background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: 8px;
    font-size: 12px; font-weight: 600; white-space: nowrap; font-family: var(--mono);
}
.chart-wrap { position: relative; }
.hbar { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 10px; font-size: 13px; }
.hbar .track { height: 10px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--accent); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--text-muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }

/* ---------- Workout logging ---------- */
.set-grid {
    display: grid;
    grid-template-columns: 40px minmax(64px, 1.1fr) minmax(64px, 1fr) minmax(52px, .7fr) 44px;
    gap: 8px; align-items: center;
}
.set-grid.head { font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 0 0 6px; }
.set-grid.head > * { text-align: center; }
.set-row { padding: 6px 0; border-radius: 10px; transition: background .2s ease; }
.set-row.done { background: color-mix(in srgb, var(--success) 7%, transparent); }
.set-row.active { background: var(--accent-soft); }
.set-idx {
    width: 32px; height: 32px; border-radius: 999px; margin: 0 auto;
    display: grid; place-items: center;
    border: 1.5px solid var(--line); font-family: var(--mono); font-weight: 700; font-size: 13px;
    background: transparent; cursor: pointer; color: var(--text);
}
.set-idx.warmup { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 50%, var(--line)); }
.set-idx.drop { color: var(--info); border-color: color-mix(in srgb, var(--info) 50%, var(--line)); }
.set-idx.failure { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); }
.set-row.active .set-idx { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.set-row.done .set-idx { background: var(--success); color: var(--success-ink); border-color: var(--success); }
.check {
    width: 40px; height: 40px; border-radius: 12px; margin: 0 auto;
    display: grid; place-items: center; cursor: pointer;
    border: 1.5px solid var(--line); background: var(--surface-2); color: var(--text-muted);
}
.check svg { width: 20px; height: 20px; }
.check:hover { border-color: var(--success); color: var(--success); }
.check.on { background: var(--success); border-color: var(--success); color: var(--success-ink); }
.hint { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.hint svg { width: 14px; height: 14px; }
.ex-card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.ex-card-head h3 { font-size: 17px; }
.drag-handle { display: flex; flex: none; align-self: flex-start; padding: 2px 0; color: var(--text-muted); cursor: grab; }
.drag-handle svg { width: 20px; height: 20px; }
.drag-handle:hover { color: var(--text); }
.drag-handle:active { cursor: grabbing; }
.card.dragging { opacity: .4; }
.card.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.card.drop-after { box-shadow: 0 3px 0 var(--accent); }
/* HTML drag does not work on touch screens: the move buttons remain there. */
@media (pointer: coarse) { .drag-handle { display: none; } }

.workout-bar {
    position: sticky; top: 0; z-index: 15;
    margin: -32px calc(-1 * clamp(16px, 4vw, 48px)) 20px; padding: 14px clamp(16px, 4vw, 48px);
    background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
@media (max-width: 860px) { .workout-bar { margin: -20px -16px 16px; padding: 12px 16px; } }
.clock { font-family: var(--mono); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }

.rest {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: 24px; z-index: 40; width: min(520px, calc(100% - 32px));
    background: var(--text); color: var(--bg);
    border-radius: var(--r-l); padding: 16px 20px 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
@media (max-width: 860px) { .rest { bottom: calc(84px + env(safe-area-inset-bottom)); } }
.rest .time { font-family: var(--mono); font-weight: 800; font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.rest .bar { height: 4px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 18%, transparent); margin-top: 14px; overflow: hidden; }
.rest .bar > div { height: 100%; background: var(--accent); transition: width 1s linear; }
.rest .btn { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 25%, transparent); }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: 12px; font-weight: 600; color: var(--text-muted); text-align: center; padding-bottom: 4px; text-transform: uppercase; letter-spacing: .08em; }
.cal-day {
    min-width: 0;
    min-height: 96px; padding: 8px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 4px; cursor: pointer; text-align: left;
}
.cal-day:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }
.cal-day.out { opacity: .4; }
.cal-day.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cal-day .d { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.cal-day.today .d { color: var(--accent-ink); background: var(--accent); border-radius: 999px; width: 26px; height: 26px; display: grid; place-items: center; }
.pill {
    font-size: 11px; font-weight: 700; padding: 3px 6px; border-radius: 6px;
    background: var(--surface-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    border-left: 3px solid var(--text-muted);
}
.pill.planned { border-left-color: var(--accent); }
.pill.shared { border-left-style: double; border-left-width: 4px; }
.shared-hints { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pill.completed { border-left-color: var(--success); color: var(--text-muted); }
.pill.done { border-left-color: var(--success); }
.pill.skipped { text-decoration: line-through; color: var(--text-muted); }
@media (max-width: 860px) {
    .cal-day { min-height: 58px; padding: 6px; }
    .cal-day .pill { font-size: 0; padding: 0; height: 6px; border-left: 0; background: var(--accent); }
    .cal-day .pill.completed { background: var(--success); }
    .cal-day .pill.skipped { background: var(--text-muted); }
}
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .layout-side { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 50; background: rgba(5, 6, 8, .6); backdrop-filter: blur(4px);
    display: grid; place-items: center; padding: 16px;
}
.modal {
    width: min(620px, 100%); max-height: min(86dvh, 820px);
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 12px; }
.modal-body { padding: 0 20px 16px; overflow: auto; flex: 1; }
.water-card { display: flex; flex-direction: column; gap: 12px; }
.water-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.water-card .value { white-space: nowrap; font-size: 28px; font-weight: 800; }
.water-card .value small { font-size: 14px; color: var(--text-muted); font-weight: 600; }
.water-drop { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); flex: none; }
.water-drop svg { width: 24px; height: 24px; }
.water-track { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.water-fill { height: 100%; background: var(--info); border-radius: 999px; transition: width .3s; }
.check-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 640px) {
    .modal-backdrop { place-items: end stretch; padding: 0; }
    .modal { width: 100%; border-radius: var(--r-l) var(--r-l) 0 0; max-height: 92dvh; }
}

.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
    background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 14px;
    display: flex; align-items: center; gap: 8px;
}
.toast svg { width: 16px; height: 16px; color: var(--success); }
.toast .btn { background: transparent; border-color: color-mix(in srgb, var(--bg) 40%, transparent); color: var(--bg); }
.toast .btn:hover { background: color-mix(in srgb, var(--bg) 14%, transparent); }
@media (max-width: 640px) {
    .toast { top: auto; bottom: calc(80px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 32px); justify-content: space-between; border-radius: var(--r-m, 14px); }
}

/* ---------- Calendar drag and drop ---------- */
.pill[draggable="true"] { cursor: grab; }
.pill[draggable="true"]:active { cursor: grabbing; }
.pill.dragging { opacity: .4; }
.cal-day.drop-target { border-color: var(--accent); outline: 2px dashed var(--accent); outline-offset: -3px; background: var(--accent-soft); }
.alert-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    border: 1px solid var(--danger); border-left-width: 3px; color: var(--danger); background: var(--surface);
    border-radius: var(--r-s); padding: 10px 14px; font-size: 14px; font-weight: 600; margin-bottom: 12px;
}

/* ---------- Welcome ---------- */
.welcome { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto auto; padding: 24px clamp(16px, 5vw, 64px); }
.welcome .top { display: flex; justify-content: space-between; align-items: center; }
.welcome .hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px; align-items: center; padding: 48px 0; }
.welcome h1 { font-size: clamp(44px, 8vw, 96px); font-weight: 800; font-stretch: 125%; line-height: .92; text-transform: uppercase; letter-spacing: -0.02em; }
.welcome h1 em { font-style: normal; color: var(--accent); }
.welcome .lead { font-size: 18px; color: var(--text-muted); max-width: 520px; margin: 24px 0 32px; }
.welcome .features { display: grid; gap: 12px; }
.welcome .features .card { display: flex; gap: 14px; align-items: flex-start; }
.welcome .mark { width: 100%; max-width: 360px; color: var(--text); justify-self: center; }
.welcome .signup { max-width: 720px; margin-bottom: 32px; }
.signup h2 { font-size: 22px; font-weight: 800; font-stretch: 125%; text-transform: uppercase; }
.signup > p.muted { margin: 6px 0 16px; max-width: 560px; }
.signup form { display: flex; flex-direction: column; gap: 14px; }
.signup textarea.input { min-height: 64px; }
.signup-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.signup-done { display: flex; align-items: center; gap: 8px; color: var(--success); font-weight: 600; }
.signup-done svg { width: 18px; height: 18px; flex: none; }
.signup-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 860px) { .welcome .hero { grid-template-columns: 1fr; gap: 24px; padding: 24px 0; } .welcome .mark { max-width: 200px; order: -1; justify-self: start; } }

/* ---------- Misc ---------- */
.pulse { width: 8px; height: 8px; border-radius: 999px; background: var(--info); box-shadow: 0 0 0 0 var(--info); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--info) 60%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
.loading { color: var(--text-muted); padding: 40px 0; text-align: center; }
.error-box { border: 1px solid var(--danger); color: var(--danger); border-radius: var(--r-s); padding: 10px 14px; font-size: 14px; }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: var(--danger); color: #fff; padding: 12px 20px;
}
#blazor-error-ui .reload { color: #fff; text-decoration: underline; margin-left: 8px; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }
.i14 { width: 14px; height: 14px; }
.i16 { width: 16px; height: 16px; }
.chip .i14 { width: 12px; height: 12px; }
.r { text-align: right; }
.meta-row > * { white-space: nowrap; }
.meta-row svg { flex: none; }
@media (max-width: 480px) {
    .list-item { gap: 10px; }
    .glyph { width: 36px; height: 36px; }
    .list-item .icon-btn { width: 30px; height: 30px; }
}
@media (max-width: 480px) {
    .workout-bar { gap: 10px; }
    .workout-bar .btn.primary { height: 38px; padding: 0 14px; font-size: 14px; }
    .set-grid { grid-template-columns: 34px minmax(56px, 1.1fr) minmax(52px, 1fr) minmax(44px, .7fr) 42px; gap: 6px; }
}

/* ---------- Supersets ---------- */
.ss-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin: 6px 0 -4px 4px; }
.card.ss { border-left: 3px solid var(--accent); }
.ss-link { display: flex; justify-content: center; margin: -6px 0; position: relative; }
.ss-link::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--line); transform: translateX(-50%); }
.ss-link.on::before { background: var(--accent); }
.ss-link-btn {
    position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 12px; border-radius: 999px; cursor: pointer;
    border: 1px dashed var(--line); background: var(--bg); color: var(--text-muted);
    font-size: 12px; font-weight: 700;
}
.ss-link-btn svg { width: 14px; height: 14px; }
.ss-link-btn:hover { color: var(--text); border-color: var(--text-muted); }
.ss-link.on .ss-link-btn { border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg)); color: var(--accent); }
.ss-card { border-left: 3px solid var(--accent); }
.ss-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ss-head .ss-label { margin: 0; flex: 1; }
.ss-members { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.ss-member { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ss-member:last-child { border-bottom: 0; }
.ss-tag { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-family: var(--mono); font-size: 11px; font-weight: 700; }
.ss-section { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin: 14px 0 6px; }
.ss-warmup { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto auto 40px; align-items: center; gap: 6px; padding: 4px 0; border-radius: 10px; }
.ss-warmup .input { width: 70px; }
.ss-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-rounds { display: grid; grid-template-columns: 34px repeat(var(--members), minmax(0, 1fr)); gap: 6px 8px; align-items: center; }
.ss-col-head { font-size: 12px; font-weight: 600; color: var(--text-muted); display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-cell { display: flex; align-items: center; gap: 4px; min-width: 0; padding: 4px; border-radius: 10px; position: relative; }
.ss-cell .input { min-width: 0; flex: 1; padding: 0 4px; }
.ss-cell .check { width: 36px; height: 36px; flex: none; margin: 0; }
.ss-cell.done, .ss-warmup.done { background: color-mix(in srgb, var(--success) 7%, transparent); }
.ss-cell.active, .ss-warmup.active { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.ss-cell.empty-cell { color: var(--text-muted); justify-content: center; }
.ss-x { color: var(--text-muted); font-size: 13px; }
.ss-type { flex: none; width: 22px; height: 22px; border-radius: 999px; border: 1.5px solid var(--line); background: none; font-size: 10px; font-weight: 800; cursor: pointer; color: var(--text); }
.ss-type.warmup { color: var(--warning); } .ss-type.drop { color: var(--info); } .ss-type.failure { color: var(--danger); }
.ss-pr { position: absolute; top: -6px; right: -4px; color: var(--accent); } .ss-pr svg { width: 14px; height: 14px; }
.set-idx.round-done { background: var(--success); border-color: var(--success); color: var(--success-ink); }
@media (max-width: 560px) {
    .ss-cell { flex-wrap: wrap; }
    .ss-cell .check { width: 100%; height: 30px; border-radius: 8px; }
    .ss-warmup { grid-template-columns: 30px minmax(0, 1fr) auto auto auto 40px; }
    .ss-warmup .input { width: 56px; }
}

/* Body diary */
.body-map { width: 100%; max-width: 220px; height: auto; display: block; margin: 8px auto; }
.body-map .region { fill: var(--surface-2); stroke: var(--line); stroke-width: 1.5; transition: fill .15s; }
.body-map.interactive .region { cursor: pointer; }
.body-map.interactive .region:hover { fill: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); }
.body-map .region:focus { outline: none; }
.body-map .region:focus-visible { stroke: var(--accent); stroke-width: 2.5; }
.body-map .region.on { fill: var(--accent); stroke: var(--accent); }
.body-map .region.heat { fill: color-mix(in srgb, var(--danger) var(--heat), var(--surface-2)); }
.body-editor { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 24px; align-items: start; }
.body-editor-map { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 640px) { .body-editor { grid-template-columns: 1fr; } .body-map { max-width: 200px; } }
.severity-pick { display: flex; gap: 8px; }
.sev { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); font-weight: 800; font-family: var(--mono); cursor: pointer; color: var(--text-muted); }
.sev.on { color: #fff; border-color: transparent; background: var(--sev); }
.sev-1 { --sev: var(--success); }
.sev-2 { --sev: color-mix(in srgb, var(--success) 50%, var(--warning)); }
.sev-3 { --sev: var(--warning); }
.sev-4 { --sev: color-mix(in srgb, var(--warning) 45%, var(--danger)); }
.sev-5 { --sev: var(--danger); }
.sev-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; font-family: var(--mono); font-size: 14px;
    background: color-mix(in srgb, var(--sev) 18%, transparent); color: var(--sev); }
.body-note { display: flex; gap: 14px; align-items: flex-start; }
.body-note-text { margin: 6px 0 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.body-stats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .body-stats { grid-template-columns: 1fr; } }
.body-heat { display: flex; flex-direction: column; gap: 12px; }
.body-heat-maps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.body-heat-maps figure { margin: 0; text-align: center; }
.body-heat-maps figcaption { font-size: 12px; color: var(--text-muted); }
.bar-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.bar-track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.empty-state { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 16px; }
.empty-state h2, .empty-state p { margin: 0; }
.body-card { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; }
.body-card .body-main { display: flex; align-items: center; gap: 14px; flex: 1 1 260px; min-width: 0; }
.body-card .body-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.body-card .body-icon svg { width: 24px; height: 24px; }

/* Medications */
.meds-card { display: flex; flex-direction: column; gap: 12px; }
.meds-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.meds-icon svg { width: 24px; height: 24px; }
.food-planned { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-top: 10px; border-radius: var(--r-input, 12px); background: var(--surface-2); }
.food-planned .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.food-planned-name { font-weight: 600; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.food-planned-name:hover { text-decoration: underline; }
.meds-taken { display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; }
.meds-time-btn { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.meds-time { background: transparent; border: 1px solid currentColor; border-radius: 6px; color: inherit; font: inherit; padding: 0 4px; height: 22px; color-scheme: dark; }
.icon-btn.xs { width: 20px; height: 20px; padding: 0; }
.icon-btn.xs svg { width: 12px; height: 12px; }
.meds-form { display: grid; grid-template-columns: 2fr 1fr auto; gap: 8px; }
@media (max-width: 640px) { .meds-form { grid-template-columns: 1fr 1fr; } .meds-form .btn { grid-column: 1 / -1; } }

/* Food */
.food-card { display: flex; flex-direction: column; gap: 12px; }
.food-card .value { white-space: nowrap; font-size: 28px; font-weight: 800; }
.food-card .value small { font-size: 14px; color: var(--text-muted); font-weight: 600; }
.food-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.food-icon svg { width: 24px; height: 24px; }
.food-fill { height: 100%; background: var(--warning); border-radius: 999px; transition: width .3s; }
.food-meals { display: flex; width: 100%; }
.food-meals button { flex: 1; padding: 7px 4px; }
.food-sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.food-sizes .btn { flex-direction: column; height: auto; padding: 10px 6px; gap: 2px; line-height: 1.1; }
.food-sizes .btn small { font-size: 12px; opacity: .8; font-weight: 600; }
.postpone-other { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.meds-recent { padding: 0 4px 0 0; gap: 2px; }
.meds-recent .meds-log { border: 0; background: none; color: inherit; font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 0 4px 0 12px; height: 100%; cursor: pointer; }

/* TV mode (/tv): always dark, sized for a 1080p screen across the room (scales with vh; 1280x720 still fits). 5vh/5vw keeps clear of TV overscan. */
.tv-frame {
    box-sizing: border-box; width: 100vw; height: 100vh; padding: 5vh 5vw; overflow: hidden;
    background: var(--bg); color: var(--text); font-family: var(--font);
    font-size: clamp(28px, 3.2vh, 40px); line-height: 1.25; cursor: none; user-select: none;
    display: flex; flex-direction: column; position: relative;
}
.tv-frame > * { min-height: 0; }
.tv-frame h1, .tv-frame h2, .tv-frame p, .tv-frame ul, .tv-frame ol { margin: 0; padding: 0; }
.tv-num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.tv-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tv-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tv-note { color: var(--text-muted); font-size: clamp(28px, 3.2vh, 40px); }
.tv-kicker { color: var(--text-muted); font-size: clamp(28px, 3.4vh, 44px); font-weight: 600; }
.tv-title { font-size: clamp(36px, 5vh, 64px); font-weight: 800; }
.tv-mark { color: var(--accent); width: clamp(72px, 11vh, 140px); display: block; }
.tv-mark svg { width: 100%; height: auto; display: block; }

.tv-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 3vh; }
.tv-code { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 800; font-size: clamp(48px, min(15vh, 12vw), 180px); letter-spacing: .12em; line-height: 1; padding-left: .12em; white-space: nowrap; }
.tv-steps { list-style: none; display: flex; flex-direction: column; gap: 1vh; max-width: 80vw; }
.tv-steps li { font-size: clamp(28px, 3.6vh, 44px); }
.tv-plan-list { list-style: none; width: min(70vw, 1100px); display: flex; flex-direction: column; gap: 1vh; text-align: left; }
.tv-plan-list li { display: flex; justify-content: space-between; gap: 2vw; padding: 1vh 2vh; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); }
.tv-idle .tv-kicker { font-size: clamp(36px, 5vh, 64px); color: var(--text); }

.tv-active { flex: 1; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); column-gap: 4vw; row-gap: 3vh; }
.tv-active.tv-single { grid-template-columns: minmax(0, 1fr); }
.tv-head { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 3vw; border-bottom: 1px solid var(--line); padding-bottom: 2vh; }
.tv-elapsed { font-size: clamp(36px, 5vh, 64px); color: var(--accent); }
.tv-now { display: flex; flex-direction: column; justify-content: center; gap: 2vh; min-width: 0; }
.tv-single .tv-now { align-items: center; text-align: center; }
.tv-current { font-size: clamp(48px, 8vh, 104px); font-weight: 800; line-height: 1.05; }
.tv-planned-set { font-size: clamp(48px, 7vh, 96px); color: var(--accent); }
.tv-next, .tv-progress, .tv-partner { color: var(--text-muted); }
.tv-partner { color: var(--text); padding-top: 1vh; }
.tv-list { list-style: none; display: flex; flex-direction: column; gap: .8vh; justify-content: center; min-width: 0; }
.tv-row { display: grid; grid-template-columns: 1.4em minmax(0, 1fr) auto; align-items: center; gap: 1.2vw; padding: .7vh 1.6vh; border-radius: var(--r-m); border: 1px solid transparent; color: var(--text-muted); }
.tv-row.current { color: var(--accent); background: var(--surface); border-color: var(--accent); font-weight: 700; }
.tv-row.done { color: var(--text-muted); }
.tv-row-mark { color: var(--success); display: inline-flex; }
.tv-row-mark svg { width: 1.1em; height: 1.1em; }
.tv-more { color: var(--text-muted); padding: .4vh 1.6vh; }
.tv-retrying { position: absolute; right: 5vw; bottom: 2vh; color: var(--text-muted); font-size: clamp(24px, 2.8vh, 32px); }

/* Framsteg: Stången (volume per week as plates), lift rows, trend lines. Tokens only. */
.barbell { display: block; width: 100%; height: auto; max-width: 560px; }
.barbell .bb-bar { stroke: var(--text-muted); stroke-width: 3; stroke-linecap: round; }
.barbell .bb-hit { fill: transparent; }
.barbell .bb-col.tap { cursor: pointer; outline: none; }
.barbell .bb-col.tap:focus-visible .bb-hit { stroke: var(--accent); stroke-width: 1.5; }
.barbell .bb-slab { fill: var(--text); }
.barbell .bb-slab.current { fill: var(--accent); }
.barbell .bb-collar { fill: var(--line); }
.barbell .bb-pending { fill: none; stroke: var(--text-muted); stroke-width: 1.5; stroke-dasharray: 3 4; }
.barbell .bb-selected { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.barbell.placeholder .bb-pending { opacity: .6; }
.progress-answer { margin-top: 8px; text-transform: uppercase; }
.progress-summary { color: var(--text-muted); margin-top: 8px; max-width: 560px; }
.progress-summary .num { color: var(--text); }
.bb-weeks { display: grid; grid-template-columns: repeat(8, 1fr); max-width: 560px; text-align: center; margin-top: 4px; }
.progress-values { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 16px; }
.progress-values > div { display: flex; flex-direction: column; gap: 2px; }
.lift-row { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; min-height: 64px; }
.lift-row .grow { min-width: 0; }
.lift-row .name { font-weight: 700; }
.lift-row .change { width: 64px; text-align: right; font-weight: 700; color: var(--text-muted); }
.lift-row .change.up { color: var(--success); }
.trend { width: 72px; height: 28px; flex: none; }
.trend path { fill: none; stroke: var(--text); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.trend circle { fill: var(--accent); }
.all-records { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; font-weight: 700; color: inherit; text-decoration: none; }
