/* ============================================================================
   Training log — all styling. Editorial composition, portfolio-matched:
   content sits directly on the page background, whitespace and hairline
   rules do the separating, borders are reserved for genuinely interactive
   surfaces (steppers, the active set entry, calendar cells, overlays).

   Theming: dark is the default (defined on :root); html.light overrides the
   tokens. Everything below the tokens is written against roles, never raw
   hex, so the theme swaps in one place.

   Session identity (A/B/C) flows through --stype, stamped by data-stype
   attributes, so a component never hard-codes a session hue.
   ========================================================================= */

/* ---------- tokens: dark (default) ---------- */

:root {
  color-scheme: dark;

  --bg: #18181b;          /* zinc-900 */
  --card: #27272a;        /* zinc-800 — interactive surfaces only */
  --sunk: #1f1f22;
  --line: #3f3f46;        /* zinc-700 */
  --line-soft: #2c2c31;
  --ink: #fafafa;         /* zinc-50 */
  --ink-2: #a1a1aa;       /* zinc-400 */
  --ink-3: #71717a;       /* zinc-500 */

  --press: #303035;       /* active-state background */
  --track: #232327;       /* volume bar track */
  --glass: rgba(24, 24, 27, 0.85);   /* sticky header / now-bar */
  --scrim: rgba(0, 0, 0, 0.6);       /* sheet backdrop */
  --zone-bg: rgba(255, 255, 255, 0.13);
  --zone-edge: rgba(255, 255, 255, 0.4);
  --sheet-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);

  /* UI accent — portfolio blue. */
  --accent: #3987e5;
  --accent-dim: #2b5f9e;

  /* Session identity. Validated all-pairs for protan/deutan in both themes.
     Always paired with the letter A/B/C so hue is never the only cue. */
  --sA: #d95926;
  --sB: #199e70;
  --sC: #9085e9;
  --sD: #a34a86;

  /* Status. Warning always ships with a label, never color alone. */
  --warn: #fab219;

  --danger-ink: #e66767;
  --danger-line: #5c3030;

  --tap: 3rem; /* 48px minimum touch target */
  --bar-h: 4.25rem;
}

/* ---------- tokens: light ---------- */

html.light {
  color-scheme: light;

  --bg: #fafafa;          /* zinc-50 */
  --card: #ffffff;
  --sunk: #f1f1f2;
  --line: #d4d4d8;        /* zinc-300 */
  --line-soft: #e4e4e7;   /* zinc-200 */
  --ink: #18181b;         /* zinc-900 */
  --ink-2: #52525b;       /* zinc-600 */
  --ink-3: #71717a;       /* zinc-500 */

  --press: #e4e4e7;
  --track: #e9e9eb;
  --glass: rgba(250, 250, 250, 0.85);
  --scrim: rgba(0, 0, 0, 0.4);
  --zone-bg: rgba(0, 0, 0, 0.07);
  --zone-edge: rgba(0, 0, 0, 0.25);
  --sheet-shadow: 0 -12px 40px rgba(0, 0, 0, 0.15);

  --accent: #2563eb;      /* blue-600 */
  --accent-dim: #1d4ed8;

  /* C darkens so white letters stay legible on the fill. */
  --sC: #4a3aa7;

  --warn: #b45309;        /* amber-700 — 4.8:1 on the light surfaces */

  --danger-ink: #b91c1c;
  --danger-line: #fca5a5;
}

[data-stype="A"] { --stype: var(--sA); }
[data-stype="B"] { --stype: var(--sB); }
[data-stype="C"] { --stype: var(--sC); }
[data-stype="D"] { --stype: var(--sD); }

/* ---------- base ---------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px) + 1rem);
}

.wrap {
  max-width: 38rem;
  margin: 0 auto;
  padding: 0 1.125rem;
}

h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; }
p { margin: 0; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent); color: #fff; }

/* ---------- primitives ---------- */

.dim { color: var(--ink-3); }

.label {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}

/* Portfolio section header: label · hairline rule running to the right. */
.sec-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sec-rule { flex: 1; height: 1px; background: var(--line-soft); }

.tap {
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.625rem;
}

.btn {
  min-height: var(--tap);
  padding: 0 1rem;
  border-radius: 0.625rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 150ms, border-color 150ms, color 150ms;
}
.btn:active { background: var(--press); }
.btn[disabled] { opacity: 0.4; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:active { background: var(--accent-dim); }

.btn-sm {
  min-height: 2.5rem;
  padding: 0 0.7rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
}

/* Quiet text/icon button — the editorial default for secondary actions. */
.btn-ghost {
  min-height: 2.5rem;
  padding: 0 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-3);
  border-radius: 0.5rem;
  transition: color 150ms;
}
.btn-ghost:hover, .btn-ghost:active { color: var(--accent); }

.btn--danger { color: var(--danger-ink); border-color: var(--danger-line); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  color: var(--ink-2);
}
.pill--accent { color: var(--accent); border-color: var(--accent); }
.pill--warn { color: var(--warn); border-color: var(--warn); }
.pill--p { flex: none; color: var(--warn); border-color: var(--warn); }

.hidden { display: none !important; }

summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
.wu-chevron { display: inline-block; transition: transform 120ms linear; }
details[open] .wu-chevron { transform: rotate(90deg); }

table.data { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
table.data th, table.data td {
  text-align: left;
  padding: 0.3rem 0.5rem 0.3rem 0;
  border-bottom: 1px solid var(--line-soft);
}
table.data th { color: var(--ink-3); font-weight: 600; }
table.data td { font-variant-numeric: tabular-nums; }

/* ---------- app header (sticky, blurred, border on scroll) ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 -1.125rem 1rem;
  padding: 0.6rem 1.125rem;
  padding-top: calc(0.6rem + env(safe-area-inset-top, 0px));
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms;
}
.app-header.scrolled { border-color: var(--line-soft); }

.app-title { font-size: 1.0625rem; letter-spacing: -0.02em; }
#block-line { margin: 0.15rem 0 0; font-size: 0.75rem; color: var(--ink-3); }
.app-controls { display: flex; align-items: center; gap: 0.1rem; }

#block-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 0.8125rem;
  font-weight: 500;
  min-height: 2.5rem;
  padding: 0 0.4rem;
  border-radius: 0.5rem;
}

#theme-toggle svg { display: block; }
html.light #theme-toggle .icon-sun { display: none; }
html:not(.light) #theme-toggle .icon-moon { display: none; }

/* ---------- calendar (open, compact) ---------- */

.cal-sec { margin-top: 0.25rem; }

#cal-toggle {
  font-size: 0.6875rem;
  min-height: 1.75rem;
  padding: 0 0.4rem;
  color: var(--ink-3);
}

#cal-grid {
  display: grid;
  grid-template-columns: 1.4rem repeat(7, 1fr);
  gap: 0.2rem;
  margin-top: 0.6rem;
}

.cal-dow, .cal-wk {
  font-size: 0.5625rem;
  color: var(--ink-3);
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.cal-wk { display: flex; align-items: center; justify-content: center; }
.cal-wk.deload { color: var(--warn); }

.cal-cell {
  position: relative;
  height: 2rem;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  line-height: 1;
  color: var(--ink-3);
  background: transparent;
}

/* Past, not completed. The load-bearing rule: a skipped Monday and an
   ordinary rest Wednesday are indistinguishable. No marker of any kind. */
.cal-cell.past { color: var(--ink-3); }

.cal-cell.future-scheduled { border-color: var(--line-soft); }

.cal-cell.today { border-color: var(--line); color: var(--ink-2); }
.cal-cell.today.scheduled { border-color: var(--accent); color: var(--ink); }

.cal-cell.done { color: #fff; font-weight: 700; border-color: transparent; }
.cal-cell.done[data-type="A"] { background: var(--sA); }
.cal-cell.done[data-type="B"] { background: var(--sB); }
.cal-cell.done[data-type="C"] { background: var(--sC); }
.cal-cell.done[data-type="D"] { background: var(--sD); }
.cal-cell.done .cal-letter { font-size: 0.6875rem; }

/* Week 6 reads as its own thing without becoming an alarm. */
.cal-cell.in-deload:not(.done) { background: var(--sunk); }

#cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.55rem;
  font-size: 0.625rem;
  color: var(--ink-3);
}
.legend-item { display: inline-flex; align-items: center; gap: 0.3rem; }
.legend-swatch { width: 0.55rem; height: 0.55rem; border-radius: 0.2rem; }
.legend-deload { color: var(--warn); }

/* ---------- session ---------- */

#session-root { margin-top: 1.75rem; }
#volume-root, #recovery-root { margin-top: 2rem; }

.session-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.session-title { display: flex; align-items: center; gap: 0.55rem; }
.session-title h2 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stype-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 0.25rem;
  flex: none;
  background: var(--stype, var(--ink-3));
}

.session-sub { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--ink-2); }

.deload-flag {
  color: var(--warn);
  border-color: var(--warn);
  background: transparent;
  margin: 0.6rem 0 0;
}

.warmup { margin-top: 0.5rem; }
.warmup summary {
  cursor: pointer;
  min-height: 2.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.warmup-list {
  margin: 0.2rem 0 0.4rem;
  padding-left: 1.1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--ink-2);
}

/* ---------- check-in (collapsed recovery fields) ---------- */

.checkin summary {
  cursor: pointer;
  min-height: 2.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow: hidden;
}
.checkin-vals {
  font-size: 0.8125rem;
  color: var(--ink-2);
  margin-left: 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.recovery {
  margin: 0.35rem 0 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.rec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.rec-field { display: block; }
.rec-field .stepper, .rec-field input[type="date"] { margin-top: 0.25rem; }

.seg-row { display: flex; gap: 0.4rem; margin-top: 0.25rem; }
.seg {
  flex: 1;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font-size: 1.0625rem;
  font-weight: 600;
  transition: background-color 150ms, border-color 150ms, color 150ms;
}
.seg--on { border-color: var(--accent); background: var(--accent); color: #fff; }

/* ---------- rest day ---------- */

.rest-plain { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.rest-main { min-width: 0; }
.rest-next { margin: 0.3rem 0 0; font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
.rest-last { margin: 0.25rem 0 0; font-size: 0.8125rem; color: var(--ink-3); }
.rest-plain .btn-ghost { flex: none; margin-top: 0.1rem; }

/* ---------- exercise list (divided rows, portfolio-CV style) ---------- */

.ex-list { margin-top: 1rem; }

.ex-row { border-top: 1px solid var(--line-soft); }
.ex-row:last-child { border-bottom: 1px solid var(--line-soft); }

.ex-head {
  width: 100%;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0;
  text-align: left;
}

.ex-num {
  flex: none;
  width: 1.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.ex-num.is-done { color: var(--stype); }

.ex-main { flex: 1; min-width: 0; }
.ex-name { display: block; font-size: 1rem; font-weight: 600; line-height: 1.3; }
.ex-rx {
  display: block;
  font-size: 0.8125rem;
  margin-top: 0.15rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.ex-rx .count { color: var(--accent); }

.ex-caret {
  flex: none;
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink-3);
  width: 1.25rem;
  text-align: center;
}

.ex-panel { overflow: hidden; }
.ex-panel-inner {
  padding: 0.1rem 0 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ---------- last time (inline, promoted numbers) ---------- */

.last-line { display: flex; flex-direction: column; gap: 0.2rem; }
.last-head { display: flex; align-items: baseline; gap: 0.5rem; }
.last-vals {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.last-note { font-size: 0.75rem; color: var(--ink-3); }
.last-empty { font-size: 0.8125rem; color: var(--ink-3); }

/* ---------- logged sets (plain lines) ---------- */

.logged-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.4rem;
  font-variant-numeric: tabular-nums;
}
.set-tag {
  flex: none;
  width: 2.9rem;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.logged-vals { flex: 1; font-size: 0.9375rem; font-weight: 500; }
.logged-x { min-height: 2.4rem; padding: 0 0.5rem; color: var(--ink-3); }

/* ---------- the active set (the one interactive surface) ---------- */

.set-active {
  background: var(--sunk);
  border-radius: 0.75rem;
  padding: 0.65rem;
}

.set-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  padding: 0 0.1rem;
}
.set-target { font-size: 0.6875rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.set-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.stepper-label { text-align: center; margin-bottom: 0.2rem; }

.stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  overflow: hidden;
  background: var(--card);
}
.stepper button {
  width: 2.4rem;
  min-height: var(--tap);
  font-size: 1.25rem;
  color: var(--ink-3);
  flex: none;
}
.stepper button:active { background: var(--press); }
.stepper input {
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: var(--tap);
  border: none;
  background: transparent;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0;
  appearance: textfield;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.partials-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  min-height: 2.5rem;
  padding: 0 0.1rem;
}
.partials-row input { width: 1.25rem; height: 1.25rem; accent-color: var(--warn); }
.partials-text { font-size: 0.8125rem; color: var(--warn); }
.partials-cap { margin: 0.4rem 0 0; font-size: 0.6875rem; color: var(--ink-3); }

.log-btn { width: 100%; margin-top: 0.5rem; font-size: 1.0625rem; }

/* ---------- queued sets (ghost lines) ---------- */

.set-ghost {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 1.6rem;
  font-size: 0.8125rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.rest-note { margin: 0; font-size: 0.6875rem; color: var(--ink-3); }

/* Per-exercise note. Quiet until it has content, like the check-in line —
   it must never compete with the Log button for attention mid-session. */
.ex-note > summary {
  cursor: pointer;
  min-height: 2rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow: hidden;
  font-size: 0.6875rem;
  color: var(--ink-3);
}
.note-preview {
  margin-left: 0.4rem;
  color: var(--ink-2);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-input {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink);
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  resize: vertical;
}
.note-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Quieter than the partials row: this is a standing property of how the lift
   is performed, not a week-5 decision that needs to catch the eye. */
.unilateral-row .partials-text { color: var(--ink-3); }

/* Load convention, shown under the load box. Quiet, but always present —
   "kg" alone is ambiguous on a plate-loaded machine. */
.load-note {
  margin: 0.35rem 0 0;
  font-size: 0.6875rem;
  color: var(--ink-3);
}

.sheet-session-note {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ink-2);
}

.sheet-ex-note {
  margin: 0.4rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--ink-2);
}

.finish-btn { width: 100%; margin-top: 1rem; }

/* ---------- volume ---------- */

.vol-hint { font-size: 0.6875rem; color: var(--ink-3); }
.vol-rows { margin-top: 0.7rem; }

.vol-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr 2.75rem;
  align-items: center;
  gap: 0.5rem;
  padding: 0.22rem 0;
}
.vol-name { font-size: 0.8125rem; color: var(--ink-2); }
.vol-num {
  font-size: 0.8125rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.vol-num.is-flag { color: var(--warn); }

.vol-track {
  position: relative;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.vol-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: var(--ink-3);
}
.vol-fill.in-band { background: var(--accent); }
.vol-fill.over { background: var(--warn); }

/* The target band is an overlay on top of the bar, so it reads as a zone
   rather than as a second bar sitting beside it. */
.vol-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--zone-bg);
}
.vol-zone::before, .vol-zone::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--zone-edge);
}
.vol-zone::before { left: 0; }
.vol-zone::after { right: 0; }

.vol-note { margin: 0.7rem 0 0; font-size: 0.6875rem; color: var(--ink-3); }

/* ---------- readiness chart ---------- */

.chart-legend {
  display: flex;
  gap: 0.75rem;
  margin: 0.6rem 0 0.3rem;
  font-size: 0.6875rem;
  color: var(--ink-2);
}
.legend-dot { width: 0.55rem; height: 0.55rem; border-radius: 999px; background: var(--accent); }
.legend-tri {
  width: 0;
  height: 0;
  border-left: 0.3rem solid transparent;
  border-right: 0.3rem solid transparent;
  border-bottom: 0.5rem solid var(--warn);
}
.chart-empty { margin: 0.5rem 0 0; font-size: 0.8125rem; color: var(--ink-3); }
.chart-table { margin-top: 0.4rem; }
details.tbl { margin-top: 0.4rem; }
details.tbl summary { font-size: 0.6875rem; color: var(--ink-3); cursor: pointer; }

/* ---------- sticky chrome ---------- */

#now-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
  padding: 0.55rem 1.125rem;
  padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#rest-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line-soft);
  padding: 0.5rem 0.75rem;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rest-bar-main { flex: 1; min-width: 0; }
.rest-sub {
  font-size: 0.6875rem;
  margin-top: -0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-3);
}

.timer-btn {
  min-height: 2.75rem;
  padding: 0 0.7rem;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

#rest-time {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  min-width: 4.25rem;
}
#rest-bar.done #rest-time { color: var(--accent); }

/* ---------- sheets ---------- */

.sheet-back {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--scrim);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 38rem;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 1.25rem 1.25rem 0 0;
  box-shadow: var(--sheet-shadow);
  padding: 0.6rem 1.125rem 1rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

.sheet-handle {
  width: 2.5rem;
  height: 0.25rem;
  border-radius: 999px;
  background: var(--line);
  margin: 0 auto 0.9rem;
}

.sheet-title { font-size: 1.0625rem; letter-spacing: -0.01em; }
.sheet-sub { margin: 0.3rem 0 0.6rem; font-size: 0.8125rem; color: var(--ink-3); }
.sheet-meta {
  margin: 0.3rem 0 0.6rem;
  font-size: 0.8125rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Option list — divided rows, not slab buttons. */
.opt-list { margin-top: 0.25rem; }
.opt-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 3.4rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--line-soft);
  text-align: left;
}
.opt-row:active { background: var(--press); }
.opt-main { flex: 1; min-width: 0; }
.opt-name { display: block; font-size: 1rem; font-weight: 600; }
.opt-sub { display: block; font-size: 0.8125rem; color: var(--ink-3); margin-top: 0.1rem; }
.opt-chevron { flex: none; font-size: 1.125rem; color: var(--ink-3); }

/* Ghost close/cancel — one primary action per sheet, everything else quiet. */
.sheet-close {
  width: 100%;
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink-2);
  border-radius: 0.625rem;
}
.sheet-close:active { background: var(--press); }

.btn-ghost--danger { color: var(--danger-ink); }
.btn-ghost--danger:hover, .btn-ghost--danger:active { color: var(--danger-ink); }

/* Read-only session view — set lines in the session view's language. */
.sheet-ex { border-top: 1px solid var(--line-soft); padding: 0.6rem 0; }
.sheet-ex-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.sheet-ex-name { font-size: 0.9375rem; font-weight: 600; }
.sheet-ex-target {
  flex: none;
  font-size: 0.75rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.sheet-set {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-height: 1.7rem;
  font-variant-numeric: tabular-nums;
}
.sheet-set-vals { font-size: 0.9375rem; font-weight: 500; }
.sheet-set-extra { font-size: 0.75rem; color: var(--ink-3); }
.sheet-set-extra--p { color: var(--warn); }

.set-list { display: flex; flex-direction: column; gap: 0.85rem; }
.set-list > .btn { width: 100%; }
.set-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: var(--tap);
}
.set-toggle input { width: 1.4rem; height: 1.4rem; accent-color: var(--accent); }
input[type="date"].btn { width: 100%; justify-content: flex-start; }

/* ---------- footer / toast ---------- */

.app-footer {
  margin: 2rem 0 0.5rem;
  display: flex;
  justify-content: center;
}

#toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--bar-h) + 1.5rem);
  z-index: 70;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.6rem 0.9rem;
  font-size: 0.875rem;
  display: none;
}
#toast.show { display: block; }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  #rest-bar.done #rest-time { animation: pulse 1s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: 0.45; } }

@media (prefers-reduced-motion: reduce) {
  .wu-chevron { transition: none; }
  .btn, .btn-ghost, .seg, .app-header { transition: none; }
}

/* ---------- sign-in gate ---------- */

#auth-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}

.gate-card { width: 100%; max-width: 20rem; text-align: center; }
.gate-title { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; }
.gate-sub { margin: 0.4rem 0 1.5rem; font-size: 0.875rem; color: var(--ink-2); }
.gate-btn { width: 100%; }
.gate-status {
  margin-top: 0.75rem;
  min-height: 1.2rem;
  font-size: 0.8125rem;
  color: var(--ink-3);
}

/* Anchored readiness buttons — number over a fixed word, so the scale can't
   drift in meaning between months. */
.seg--anchored {
  flex-direction: column;
  gap: 0.1rem;
  min-height: var(--tap);
  padding: 0.35rem 0.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.625rem;
}
.seg--anchored .seg-num { font-size: 1rem; font-weight: 600; line-height: 1; }
.seg--anchored .seg-anchor {
  font-size: 0.5625rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0.75;
  line-height: 1;
}
.legend-dot--stype { background: var(--stype, var(--ink-3)); }

/* Editing a day other than today — has to be unmissable, or you log today's
   work into last Tuesday without noticing. */
.past-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.6rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--warn);
  border-radius: 0.6rem;
  font-size: 0.8125rem;
  color: var(--warn);
}
.past-banner .btn-ghost { flex: none; color: var(--warn); }
.sheet-edit { width: 100%; margin-top: 0.5rem; }
