/* Fraunces and Instrument Sans (SIL Open Font License), latin subsets, served from this origin.
   Same paper-and-ink look as Life Tracker. */
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url(fonts/fraunces.woff2) format("woff2");
}
@font-face {
  font-family: "Fraunces"; font-style: italic; font-weight: 300 800; font-display: swap;
  src: url(fonts/fraunces-italic.woff2) format("woff2");
}
@font-face {
  font-family: "Instrument Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(fonts/instrument-sans.woff2) format("woff2");
}

:root {
  --bg: #f4efe4;
  --surface: #fffcf5;
  --sunk: #ece6d8;
  --text: #1f1b15;
  --muted: #5f5749;
  --faint: #73695a;
  --border: #e3dbca;
  --line: #ece5d6;
  --accent: #2f5745;
  --ink-btn: #1f1b15;
  --ink-btn-text: #f7f2e7;
  --bad: #b13f22;
  --warn: #865e0b;
  --new: #59698a;
  --ok: #456f4a;
  --track: #e6dfcf;
  --signal: #d9663f;
  --c1: #2f5745; /* left / main series */
  --c2: #b4572e; /* right / second series */
  --c3: #9a8f7c;
  --radius: 14px;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 1px 0 rgb(255 255 255 / .6) inset, 0 1px 2px rgb(60 45 20 / .05), 0 6px 20px -12px rgb(60 45 20 / .18);
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130f;
    --surface: #1d1a15;
    --sunk: #24201a;
    --text: #efe8da;
    --muted: #a59b88;
    --faint: #8c8270;
    --border: #2f2a22;
    --line: #29251e;
    --accent: #9cc3a8;
    --ink-btn: #efe8da;
    --ink-btn-text: #17140f;
    --bad: #e8735a;
    --warn: #deb054;
    --new: #9aabcf;
    --ok: #93b98f;
    --track: #2e2920;
    --c1: #9cc3a8;
    --c2: #e89466;
    --c3: #776d5d;
    --shadow: 0 1px 0 rgb(255 255 255 / .03) inset, 0 8px 24px -14px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(var(--nav-h) + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  min-height: 100dvh;
}
main, .top, .foot { max-width: 760px; margin: 0 auto; padding: 0 20px; }
@media (max-width: 560px) { main, .top, .foot { padding: 0 16px; } }
h1, h2, h3 { font-family: var(--serif); font-weight: 560; letter-spacing: -.01em; font-variation-settings: "opsz" 48, "SOFT" 50; }
h1 { font-size: 1.3rem; margin: 0; line-height: 1.1; }
h2 { font-size: 1.4rem; margin: 0 0 .4rem; }
h3 { font-size: 1.1rem; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */

button, .button {
  font: inherit; font-weight: 550;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .45rem 1rem; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: default; }
button.small, .button.small { min-height: 34px; padding: .3rem .8rem; font-size: .88rem; }
button.primary, .button.primary { background: var(--ink-btn); border-color: var(--ink-btn); color: var(--ink-btn-text); }
button.ghost, .button.ghost { background: transparent; }
button.ghost:hover, .button.ghost:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
button.danger, .danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button.icon { min-width: 40px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); font-size: 1.2rem; }
button.icon:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
button.icon svg { width: 20px; height: 20px; }
button.link {
  border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); font-weight: 600; border-radius: 2px;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; display: inline; text-align: left;
}
button.link.plain { color: inherit; text-decoration: none; font: inherit; }
button.link.plain:hover { text-decoration: underline; }

/* ---------- shell ---------- */

.sample-bar {
  display: flex; flex-wrap: wrap; gap: 4px 18px; justify-content: center; padding: 9px 16px; font-size: .85rem; text-align: center;
  background: var(--ink-btn); color: var(--ink-btn-text);
}
.sample-bar .link { color: inherit; }
.sample-actions { display: inline-flex; gap: 16px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; padding-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 34px; height: 34px; color: var(--text); }
.mark .dot { fill: var(--signal); }
.top-actions { display: flex; gap: 4px; }
.error {
  background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  border-radius: var(--radius); padding: .75rem 1rem; margin: 12px 0; white-space: pre-wrap;
}
#view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding-top: 8px; }
.card, .section { min-width: 0; }
.foot { padding-top: 32px; padding-bottom: 24px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--faint); font-size: .8rem; }
.foot .sign { font-family: var(--serif); font-style: italic; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-top: 1px solid var(--border); backdrop-filter: blur(8px);
}
.nav button {
  flex: 1; max-width: 140px; flex-direction: column; gap: 2px; border: 0; background: none; color: var(--muted);
  font-size: .74rem; font-weight: 600; padding: 4px 0; min-height: 50px; border-radius: 12px;
}
.nav button svg { width: 22px; height: 22px; }
.nav button[aria-current="true"] { color: var(--text); background: var(--sunk); }

.page-head { display: grid; gap: 6px; }
.page-head h2 { margin: 0; }
.kicker { margin: 0; font-size: .72rem; font-weight: 650; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.lede { font-family: var(--serif); font-size: 1.05rem; line-height: 1.35; color: var(--muted); max-width: 44ch; }
.note {
  font-size: .9rem; padding: .55rem .8rem; border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.alert {
  padding: .7rem .9rem; border-radius: 12px; font-size: .92rem;
  background: color-mix(in srgb, var(--bad) 11%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
}

/* ---------- cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; display: grid; gap: 10px;
}
.card.slim { padding: 10px 14px; }
.card > button { justify-self: start; }
.card.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { font-size: 1.15rem; margin: 0; }
.card-title.big { font-size: 1.6rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card-actions.end { justify-content: flex-end; }
.plan-list { margin: 0; padding-left: 1.3rem; display: grid; gap: 8px; }
.plan-list li { display: grid; }
.plan-name { font-weight: 600; }
.next { color: var(--accent); }
.cue { color: var(--muted); font-style: italic; }
.prs { margin: 0; padding-left: 1.1rem; }
.flag-list { margin: 0; padding-left: 1.1rem; display: grid; gap: 6px; font-size: .92rem; }

.badge {
  font-size: .72rem; font-weight: 650; line-height: 1; padding: .3rem .5rem; border-radius: 999px; white-space: nowrap;
  color: var(--tone, var(--muted)); background: color-mix(in srgb, var(--tone, var(--muted)) 13%, transparent);
}
.st-progressing { --tone: var(--ok); }
.st-stalled { --tone: var(--warn); }
.st-regressing { --tone: var(--bad); }
.st-new { --tone: var(--new); }
.side-left, .side-right { --tone: var(--warn); }
.side-even { --tone: var(--ok); }

/* ---------- logging ---------- */

.session-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.ex-card { gap: 6px; }
.ex-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ex-name { font-size: 1.15rem; }
.last { color: var(--muted); font-variant-numeric: tabular-nums; }
.set-rows { display: grid; gap: 0; margin-top: 4px; }
.setrow {
  display: grid; grid-template-columns: 2.2rem auto auto 1fr auto; gap: 6px 10px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.setrow[data-side="R"] { border-top-style: dashed; }
.setrow.saved { background: linear-gradient(90deg, color-mix(in srgb, var(--ok) 8%, transparent), transparent 70%); }
.setrow.matched:not(.saved) .step-field input { color: var(--accent); }
.set-label { font-weight: 650; font-variant-numeric: tabular-nums; display: flex; gap: 3px; align-items: baseline; }
.set-label b { font-size: .78rem; color: var(--muted); }
.set-label em { font-size: .7rem; color: var(--faint); font-style: normal; }
.no-weight { min-width: 4rem; }
.check {
  width: 42px; height: 42px; min-height: 0; padding: 0; border-radius: 50%;
  border: 1.5px solid var(--border); background: transparent; color: var(--muted);
}
.check svg { width: 20px; height: 20px; }
.check.on { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.set-more { grid-column: 1 / -1; }
.set-more > summary { list-style: none; cursor: pointer; color: var(--faint); font-size: .85rem; width: max-content; padding: 0 4px; }
.set-more > summary::-webkit-details-marker { display: none; }
.set-extra { display: grid; gap: 10px; padding: 8px 0 4px; }
@media (max-width: 560px) {
  .setrow { grid-template-columns: 1.8rem minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 6px 8px; }
  .setrow .chips { grid-column: 2 / 4; grid-row: 2; }
  .setrow .check { grid-row: 1 / span 2; grid-column: 4; }
  .setrow .no-weight { min-width: 0; }
}

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.stepper .step { min-width: 36px; min-height: 40px; padding: 0; border: 0; background: none; font-size: 1.2rem; color: var(--muted); border-radius: 10px; }
.stepper .step:hover { color: var(--text); }
.step-field { display: inline-flex; align-items: baseline; gap: 2px; }
.step-field input {
  width: 3.4rem; min-height: 40px; border: 0; padding: 0; text-align: center; background: none; font-weight: 650; font-size: 1.05rem;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.step-field input::-webkit-outer-spin-button, .step-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step-field .unit { font-size: .72rem; color: var(--faint); margin-right: 2px; }
@media (max-width: 560px) {
  .stepper { width: 100%; min-width: 0; justify-content: space-between; }
  .stepper .step { min-width: 32px; flex: none; }
  .step-field { flex: 1; min-width: 0; justify-content: center; }
  .step-field input { width: 100%; min-width: 0; max-width: 3rem; }
}

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  min-height: 34px; min-width: 34px; padding: .2rem .6rem; font-size: .85rem; border-radius: 999px;
  background: var(--sunk); border-color: transparent; color: var(--muted); font-variant-numeric: tabular-nums;
}
.chip[aria-pressed="true"] { background: var(--ink-btn); color: var(--ink-btn-text); }
.lbl { display: block; font-size: .84rem; font-weight: 550; color: var(--muted); margin-bottom: 4px; }
.sym-grid { display: grid; gap: 10px; }
.sym-grid .chip { min-width: 30px; padding: .2rem .4rem; }

.rest {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); z-index: 6;
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 16px; border-radius: 999px;
  background: var(--ink-btn); color: var(--ink-btn-text); box-shadow: 0 18px 40px -12px rgb(20 12 0 / .45);
}
.rest .kicker { color: inherit; opacity: .7; }
.rest strong { font-family: var(--serif); font-size: 1.5rem; font-variant-numeric: tabular-nums; min-width: 3.2ch; }
.rest button { color: inherit; border-color: color-mix(in srgb, var(--ink-btn-text) 30%, transparent); }
.rest.ready { background: var(--ok); }

/* ---------- lists ---------- */

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { border: 0; background: var(--sunk); color: var(--muted); min-height: 34px; padding: .3rem .8rem; font-size: .88rem; }
.tab[aria-selected="true"] { background: var(--ink-btn); color: var(--ink-btn-text); }
.week { display: grid; gap: 8px; }
.week-head { font-size: 1rem; color: var(--muted); }
.card-list {
  list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-list > li + li { border-top: 1px solid var(--line); }
.hist-row, .ex-row {
  display: flex; align-items: center; gap: 12px; width: 100%; justify-content: flex-start; text-align: left;
  border: 0; border-radius: 0; background: none; padding: 11px 14px; font-weight: 400; min-height: 52px;
}
.hist-row:hover, .ex-row:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
.hist-row .when { width: 5.6rem; flex: none; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.what { display: grid; flex: 1; min-width: 0; }
.what b { font-weight: 600; }
.plan-row { display: flex; align-items: center; }
.plan-row .hist-row .when { width: 1.4rem; }
.move { display: flex; padding-right: 6px; }
.move .icon { min-width: 34px; min-height: 34px; font-size: 1rem; }
.section { display: grid; gap: 10px; margin-top: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.section-head h2, .section-head h3 { margin: 0; }
.sub { font-family: var(--sans); font-size: .9rem; font-weight: 650; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin-top: 6px; }
.program-day { display: grid; gap: 8px; margin-top: 10px; }
.empty { text-align: center; padding: 2.4rem 1.2rem; border: 1px dashed color-mix(in srgb, var(--text) 18%, transparent); border-radius: var(--radius); }
.empty p { font-family: var(--serif); font-size: 1.2rem; }
.empty small { display: block; font-family: var(--sans); font-size: .9rem; color: var(--muted); margin-top: 6px; }
.skeleton > div { height: 64px; border-radius: var(--radius); background: var(--sunk); margin-bottom: 10px; }

/* ---------- progress ---------- */

.verdicts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 680px) { .verdicts { grid-template-columns: 1fr; } }
.verdict {
  border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 4px; align-content: start;
  background: color-mix(in srgb, var(--tone) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone) 30%, var(--border));
}
.verdict h3 { font-size: 1.25rem; color: var(--text); }
.tone-good { --tone: var(--ok); }
.tone-fair { --tone: var(--warn); }
.tone-poor { --tone: var(--bad); }
.tone-none { --tone: var(--faint); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { display: grid; padding: 10px 12px 10px 0; }
.stat + .stat { padding-left: 12px; border-left: 1px solid var(--line); }
@media (max-width: 560px) { .stat:nth-child(3) { border-left: 0; padding-left: 0; } .stat:nth-child(n+3) { border-top: 1px solid var(--line); } }
.stat strong { font-family: var(--serif); font-weight: 450; font-size: 1.8rem; line-height: 1.1; font-variant-numeric: lining-nums; }
.stat strong small { font-size: .5em; color: var(--muted); }
.stat span { font-size: .78rem; color: var(--muted); }
.vol { display: grid; gap: 4px; }
.vol-row { display: grid; grid-template-columns: 6.5rem 1fr 2.6rem; gap: 10px; align-items: center; font-size: .88rem; }
.vol-n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar { width: 100%; height: 12px; display: block; }
.bar .track { fill: var(--track); }
.bar .band { fill: color-mix(in srgb, var(--ok) 22%, transparent); }
.bar .fill { fill: var(--c1); }
.bar.under .fill { fill: var(--c3); }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { font: 9px var(--sans); fill: var(--faint); }
.chart .band { fill: color-mix(in srgb, var(--ok) 12%, transparent); }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series.s1 .ln { stroke: var(--c1); } .series.s1 circle { fill: var(--c1); }
.series.s2 .ln { stroke: var(--c2); } .series.s2 circle { fill: var(--c2); }
.series.s3 .ln { stroke: var(--c3); } .series.s3 circle { fill: var(--c3); }
.legend { display: inline-flex; gap: 10px; align-items: center; font-weight: 500; color: var(--muted); font-size: .8rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: -6px; }
.legend i.s1 { background: var(--c1); } .legend i.s2 { background: var(--c2); } .legend i.s3 { background: var(--c3); }
.spark { width: 64px; height: 20px; flex: none; }
.spark path { fill: none; stroke: var(--tone, var(--c1)); stroke-width: 1.6; }
.spark circle { fill: var(--tone, var(--c1)); }
table.dexa, table.sets { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
table.dexa th, table.dexa td, table.sets td { text-align: left; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.dexa thead th { color: var(--muted); font-weight: 600; font-size: .8rem; }
table.dexa tbody th { font-weight: 550; }
.detail-ex { display: grid; gap: 4px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- dialogs and forms ---------- */

.menu { display: grid; gap: 2px; }
.menu > * { justify-content: flex-start; border-color: transparent; border-radius: 10px; }
dialog {
  border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 22px;
  box-shadow: 0 30px 80px -20px rgb(30 20 5 / .45);
}
dialog.wide { width: min(680px, calc(100vw - 24px)); }
dialog::backdrop { background: rgb(24 18 8 / .42); backdrop-filter: blur(2px); }
@media (max-width: 560px) {
  dialog, dialog.wide {
    margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; border-bottom: 0;
    padding: 24px 16px calc(18px + env(safe-area-inset-bottom));
  }
  .dlg-actions .primary { flex: 1; }
}
dialog h2 { font-size: 1.4rem; margin-bottom: 0; line-height: 1.2; }
.dlg-sub { margin-top: -8px; }
dialog form { display: grid; gap: 14px; }
dialog label { display: grid; gap: 5px; font-size: .84rem; font-weight: 550; color: var(--muted); }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .92rem; font-weight: 450; }
label.inline input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.stack { display: grid; gap: 12px; padding-top: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: .5rem .7rem; min-height: 42px; width: 100%;
}
.dlg-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.spacer { flex: 1; }
details summary { cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 10;
  transform: translate(-50%, 16px); opacity: 0; transition: opacity .2s, transform .25s;
  max-width: calc(100vw - 32px); width: max-content; padding: 11px 18px; border-radius: 14px; font-size: .92rem;
  background: var(--ink-btn); color: var(--ink-btn-text); box-shadow: 0 18px 40px -12px rgb(20 12 0 / .45);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#refresh.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (pointer: coarse) { .chip { min-height: 38px; min-width: 38px; } }

/* ---------- discomfort colours (heatmap, calendar dots, score chips) ---------- */

.hm { fill: var(--hm); background: var(--hm); }
.h0 { --hm: var(--track); }
.h1 { --hm: color-mix(in srgb, var(--signal) 32%, var(--surface)); }
.h2 { --hm: color-mix(in srgb, var(--signal) 62%, var(--surface)); }
.h3 { --hm: var(--signal); }
.h4 { --hm: var(--bad); }
.hx { --hm: color-mix(in srgb, var(--track) 40%, transparent); }
.chart.heat .mk.lower { fill: var(--c1); }
.chart.heat .mk.upper { fill: var(--c2); }
.mk-key { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; }
.mk-key.lower { background: var(--c1); } .mk-key.upper { background: var(--c2); }
.legend.heat-legend { gap: 6px; font-weight: 500; }
.legend.heat-legend i { width: 10px; height: 10px; border-radius: 2px; margin-right: 0; }
.bar.s2 .fill { fill: var(--c2); }
.score { display: inline-grid; place-items: center; min-width: 1.7rem; height: 1.45rem; border-radius: 6px; font-weight: 650; }
.score.h3, .score.h4 { color: #fff; }
table.sym-table th { font: 600 .72rem var(--sans); color: var(--muted); text-align: left; padding: 0 8px 4px 0; }

/* ---------- calendar ---------- */

.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cal-bar { display: flex; align-items: center; gap: 4px; }
.cal-title { font-size: 1.2rem; margin: 0; min-width: 9.5rem; text-align: center; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); align-items: center; }
.sw { display: inline-block; width: 16px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid transparent; }

/* workout status, shared by the month, the week and the day dialog */
.st-done.sw, .cal-item.st-done { background: var(--ok); color: var(--surface); }
.st-planned.sw, .cal-item.st-planned { border: 1.5px dashed var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.st-missed.sw, .cal-item.st-missed { border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }
.cal-item.st-missed span { text-decoration: line-through; text-decoration-thickness: 1px; }
.st-open.sw, .cal-item.st-open { border: 1.5px solid var(--warn); color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }

.month { display: grid; gap: 4px; }
.month-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.month-wd span { font-size: .72rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: center; }
.month .short, .cal-item .short { display: none; }
.cal-day {
  position: relative; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 3px;
  min-height: 88px; min-width: 0; padding: 6px; border-radius: 10px; text-align: left; font-weight: 500; font-size: .8rem;
  background: var(--surface); border: 1px solid var(--border);
}
.cal-day:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.cal-day.out { opacity: .42; }
.cal-day.today { border: 2px solid var(--accent); padding: 5px; }
.cal-day.today .cal-num { background: var(--accent); color: var(--surface); }
.month-row.deload .cal-day { background: color-mix(in srgb, var(--new) 9%, var(--surface)); }
.cal-num { font-weight: 650; font-variant-numeric: tabular-nums; width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 50%; margin: -2px 0 0 -2px; }
.cal-sym { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; }
.cal-items { display: grid; gap: 3px; min-width: 0; }
.cal-item { display: block; font-size: .72rem; font-weight: 600; line-height: 1.35; padding: 1px 5px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid transparent; }
.cal-item b { margin-right: 3px; }
.cal-cardio { font-size: .66rem; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: auto; }
@media (max-width: 560px) {
  .month, .month-row { gap: 3px; }
  .month .full, .cal-item .full { display: none; }
  .month .short, .cal-item .short { display: inline; }
  .cal-day { min-height: 70px; padding: 3px; gap: 2px; border-radius: 8px; align-items: center; text-align: center; }
  .cal-day.today { padding: 2px; }
  .cal-num { margin: 0; width: 1.45rem; height: 1.45rem; font-size: .78rem; }
  .cal-items { width: 100%; }
  .cal-item { padding: 1px 2px; text-align: center; font-size: .7rem; }
  .cal-item b { margin-right: 1px; }
  .cal-sym { top: 4px; right: 4px; width: 7px; height: 7px; }
  .cal-cardio { font-size: .6rem; width: 100%; }
  .cal-title { min-width: 0; font-size: 1.05rem; }
}

/* week: one row per day, workouts drag between rows */
.wk { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.wk-row { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 12px 8px 8px; min-height: 62px; border-top: 1px solid var(--line); transition: background-color .12s; }
.wk-row:first-child { border-top: 0; }
.wk-row.today { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.wk-row.past .wk-date { opacity: .65; }
.wk-row.over { background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: inset 0 0 0 2px var(--accent); }
.wk-row.blocked { background: color-mix(in srgb, var(--bad) 8%, transparent); }
.wk-date { flex-direction: column; gap: 0; border: 0; background: none; padding: 2px 0; min-height: 0; color: var(--muted); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; border-radius: 8px; }
.wk-date b { font-family: var(--serif); font-size: 1.35rem; letter-spacing: 0; color: var(--text); line-height: 1.1; }
.wk-row.today .wk-date b { color: var(--accent); }
.wk-items { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; min-width: 0; }
.wk-item { display: inline-flex; align-items: center; gap: 4px; padding: 3px 12px 3px 3px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); user-select: none; -webkit-user-select: none; max-width: 100%; }
.wk-item[data-drag="1"] { cursor: grab; }
.wk-item.st-done { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.wk-item.st-planned { border: 1.5px dashed var(--accent); }
.wk-item.st-missed { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.wk-item.st-missed b { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--bad); }
.wk-item.st-open { border: 1.5px solid var(--warn); }
.grip { display: grid; place-items: center; width: 26px; height: 36px; color: var(--faint); cursor: grab; touch-action: none; border-radius: 8px; }
.grip:hover { color: var(--text); background: var(--sunk); }
.grip svg { width: 9px; height: 14px; fill: currentColor; }
.wk-mark { width: 22px; text-align: center; font-weight: 700; color: var(--ok); }
.wk-item.st-open .wk-mark { color: var(--warn); }
.wk-open { display: grid; justify-items: start; gap: 0; border: 0; background: none; padding: 2px 0; min-height: 0; text-align: left; line-height: 1.25; border-radius: 6px; min-width: 0; }
.wk-open b { font-weight: 650; }
.wk-open .small { font-weight: 500; color: var(--muted); font-size: .78rem; }
.wk-cardio, .wk-empty { color: var(--faint); }
.wk-sym { color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.wk-sym i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.wk-item.dragging { opacity: .3; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; margin: 0; box-shadow: 0 16px 34px -10px rgb(20 12 0 / .4); opacity: .96; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }

/* one day */
.day-block { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 12px; }
.day-block.st-done { border-left-color: var(--ok); }
.day-block.st-planned { border-left-color: var(--accent); }
.day-block.st-missed { border-left-color: var(--bad); }
.day-block.st-open { border-left-color: var(--warn); }
.day-block h3 { margin: 0; }
.day-ex { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .9rem; }
.chart.heat, .chart.stage { max-width: 600px; }
