/* THE INNER ROOM — dark, spare, typographic. One accent. Charts central. */
:root {
  /* Primary look: VELNA cream, near-black ink, gold accent, dark-olive buttons */
  --accent: #a68749;
  --accent-soft: rgba(166, 135, 73, 0.14);
  --bg: #f6f1e8;
  --bg-raised: #fbf8f1;
  --bg-card: #fbf8f1;
  --line: #e2dccd;
  --line-soft: #ece7db;
  --ink: #242927;
  --ink-mid: #55574f;
  --ink-mute: #8a8b80;
  --ink-faint: #bab9ab;
  --good: #5f7a44;
  --warn: #a68749;
  --danger: #b0573f;
  --btn: #3a3f26;         /* dark olive button */
  --btn-ink: #f6f1e8;     /* cream text on button */
  --radius: 4px;
  --maxw: 580px;
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
}
[data-theme="light"] {
  --accent: #a68749;
  --accent-soft: rgba(166, 135, 73, 0.14);
  --bg: #f6f1e8;
  --bg-raised: #fbf8f1;
  --bg-card: #fbf8f1;
  --line: #e2dccd;
  --line-soft: #ece7db;
  --ink: #242927;
  --ink-mid: #55574f;
  --ink-mute: #8a8b80;
  --ink-faint: #bab9ab;
  --good: #5f7a44;
  --warn: #a68749;
  --danger: #b0573f;
  --btn: #3a3f26;
  --btn-ink: #f6f1e8;
}
[data-theme="dark"] {
  /* Dark olive variant, same gold accent, olive buttons */
  --accent: #c9a24a;
  --accent-soft: rgba(201, 162, 74, 0.16);
  --bg: #171a10;
  --bg-raised: #1e2116;
  --bg-card: #22261a;
  --line: #343a28;
  --line-soft: #272c1d;
  --ink: #ececed;
  --ink-mid: #b0b1a4;
  --ink-mute: #838476;
  --ink-faint: #4a4d3a;
  --good: #7fb682;
  --warn: #c9a24a;
  --danger: #c96a5f;
  --btn: #4a5130;
  --btn-ink: #f6f1e8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
.app { max-width: var(--maxw); margin: 0 auto; min-height: 100%; padding: 0 20px 120px; }

/* Typography */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.12; letter-spacing: 0; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { color: var(--ink-mid); }
a { color: var(--accent); text-decoration: none; }
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }

.eyebrow {
  font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-mute); font-weight: 600;
}
.muted { color: var(--ink-mute); }
.mid { color: var(--ink-mid); }
.small { font-size: 0.85rem; }
.tiny { font-size: 0.75rem; }
.accent { color: var(--accent); }
.center { text-align: center; }

/* Header / brand */
.brand { padding: 30px 0 8px; }
.brand .logo { display: block; width: 40px; height: auto; opacity: 0.9; margin: 0 0 12px; }
.brand.center .logo { margin-left: auto; margin-right: auto; }
[data-theme="dark"] .brand .logo { filter: invert(1) brightness(1.4); }
.brand .name { font-family: var(--serif); font-size: 2rem; letter-spacing: 0.01em; font-weight: 600; line-height: 1.05; }
.brand .sub { font-family: var(--serif); font-style: italic; color: var(--accent); font-size: 1.05rem; margin-top: 6px; }

/* Top bar (in-app) */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0 10px; position: sticky; top: 0; background: var(--bg); z-index: 20;
  border-bottom: 1px solid var(--line-soft);
}
.topbar .title { font-size: 0.78rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-mute); }
.topbar .back { color: var(--ink-mid); font-size: 0.85rem; cursor: pointer; background: none; border: none; padding: 6px 0; }
.topbar .back:hover { color: var(--ink); }

/* Cards */
.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin: 14px 0;
}
.card.tight { padding: 16px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-size: 0.95rem; font-weight: 500;
  padding: 13px 20px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--bg-raised); color: var(--ink); cursor: pointer; width: 100%;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}
.btn:hover { border-color: var(--ink-faint); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); font-weight: 600; letter-spacing: 0.02em; }
.btn-primary:hover { opacity: 0.9; border-color: var(--btn); }
.btn-ghost { background: transparent; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; width: auto; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.9rem; padding: 0; }

/* Inputs */
label.field { display: block; margin: 16px 0 6px; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-mute); }
.access-error { margin: 12px 0 0; font-size: 0.9rem; line-height: 1.4; color: var(--danger); }
input[type="text"], input[type="time"], textarea, select {
  width: 100%; background: var(--bg-raised); border: 1px solid var(--line);
  color: var(--ink); border-radius: var(--radius); padding: 12px 14px;
  font-family: var(--sans); font-size: 1rem; resize: vertical;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 84px; line-height: 1.5; }
.code-input { font-family: var(--mono); letter-spacing: 0.18em; text-transform: uppercase; text-align: center; font-size: 1.1rem; }

/* Slider */
.slider-wrap { margin: 20px 0 8px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.slider-val { font-size: 2.6rem; font-weight: 300; font-family: var(--serif); color: var(--accent); line-height: 1; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 2px; background: var(--line); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 4px solid var(--bg);
}
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 4px solid var(--bg); }
.scale-ticks { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--ink-faint); margin-top: 8px; }

/* Stepper progress */
.progress { display: flex; gap: 6px; margin: 4px 0 20px; }
.progress .dot { flex: 1; height: 3px; background: var(--line); border-radius: 3px; }
.progress .dot.done { background: var(--accent); }
.progress .dot.active { background: var(--ink-mid); }
.step-count { font-size: 0.75rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-mute); }

/* Idea block */
.idea { font-family: var(--serif); font-size: 1.18rem; line-height: 1.62; color: var(--ink); }
.reading { border-left: 2px solid var(--accent); padding-left: 14px; color: var(--ink-mid); font-family: var(--serif); font-style: italic; }

/* Transmission timer */
.timer { text-align: center; padding: 24px 0; }
.timer .ring { font-size: 4rem; font-family: var(--serif); font-weight: 300; color: var(--accent); font-variant-numeric: tabular-nums; }
.timer .note { color: var(--ink-mute); margin-top: 8px; }

/* Today hub */
.day-hero { text-align: center; padding: 22px 0 8px; }
.day-hero .dayno { font-size: 4.2rem; font-family: var(--serif); font-weight: 300; line-height: 1; }
.day-hero .of { color: var(--ink-mute); font-size: 1rem; }
.day-hero .theme { font-family: var(--serif); font-style: italic; font-size: 1.15rem; margin-top: 10px; color: var(--ink-mid); }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.chip { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-mute); border: 1px solid var(--line); border-radius: 40px; padding: 4px 12px; }
.chip.accent { color: var(--accent); border-color: var(--accent); }

.stat-row { display: flex; gap: 12px; margin: 8px 0; }
.stat { flex: 1; text-align: center; padding: 14px 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.stat .num { font-size: 1.8rem; font-family: var(--serif); font-weight: 300; }
.stat .lbl { font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-mute); margin-top: 2px; }

/* Session buttons on today */
.session-btn { display: flex; align-items: center; justify-content: space-between; }
.session-btn .state { font-size: 0.75rem; color: var(--ink-mute); }
.session-btn .state.done { color: var(--good); }

/* Notice / unlock banner */
.banner { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.banner h3 { color: var(--accent); }

/* Lists */
.list-item { padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.list-item:last-child { border-bottom: none; }
/* Pain list (the contraction's fuel) */
.pain-list { list-style: none; margin: 6px 0 0; padding: 0; }
.pain-list .list-item { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; }
.pain-list .list-item span { flex: 1 1 auto; }
.pain-list .pain-del { flex: 0 0 auto; }
.pain-list .pain-empty { padding: 12px 0; border-bottom: none; display: block; }
.linkbtn { background: none; border: none; padding: 0; margin: 0; color: var(--ink-mid); font: inherit; font-size: 0.82rem; text-decoration: underline; cursor: pointer; }
.linkbtn:hover { color: var(--ink); }
.arr-actions { display: flex; gap: 16px; margin-top: 8px; align-items: center; }
.arr-actions .btn-sm { flex: 0 0 auto; }
.arr-edit-form { margin-top: 10px; flex-direction: column; gap: 8px; }
.arr-edit-form:not([hidden]) { display: flex; }
.arr-edit-form input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; }
/* The Ring (Part 3) */
.ring-line { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); cursor: pointer; color: var(--ink-mid); }
.ring-line .arrow { color: var(--ink-faint); }
.ring-list { margin-top: 8px; }
.ring-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.ring-item:last-child { border-bottom: none; }
.ring-box { flex: 0 0 auto; width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--paper); background: var(--paper); font-size: 0.95rem; line-height: 1; margin-top: 1px; }
.ring-item.on .ring-box { background: var(--accent); border-color: var(--accent); color: #fff; }
.ring-text { flex: 1 1 auto; }
.ring-label { color: var(--ink); font-weight: 500; }
.ring-item.on .ring-label { color: var(--ink); }
.ring-help { color: var(--ink-mid); font-size: 0.85rem; margin-top: 2px; }
.ring-optional { margin-top: 4px; }
.ring-opt-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; cursor: pointer; color: var(--ink-mid); }
.ring-opt-head .arrow { color: var(--ink-faint); }
.ring-opt-body { padding-bottom: 8px; }
.ring-opt-list { margin: 8px 0 0 18px; color: var(--ink-mid); }
.ring-opt-list li { margin: 2px 0; }
.nav-item { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.nav-item .arrow { color: var(--ink-faint); }
.nav-item.locked { opacity: 0.5; cursor: default; }

/* Verdict / quadrant */
.verdict { padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); margin: 14px 0; }
.verdict.sweet_spot { border-color: var(--good); }
.verdict.wanted_not_believed, .verdict.neither { border-color: var(--warn); }
.verdict .q { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-mute); }
.verdict .lbl { font-family: var(--serif); font-size: 1.2rem; margin: 4px 0 8px; }

/* Ladder */
.ladder { display: flex; flex-direction: column-reverse; gap: 2px; }
.rung { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-raised); }
.rung.stand { border-color: var(--good); background: var(--accent-soft); }
.rung.next { border-color: var(--accent); border-style: dashed; }
.rung .belief { font-family: var(--mono); color: var(--ink-mute); font-size: 0.85rem; }
.rung .tag { font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase; }
.rung.stand .tag { color: var(--good); }
.rung.next .tag { color: var(--accent); }

/* Charts */
.chart-wrap { margin: 16px 0; }
.chart-caption { font-size: 0.85rem; color: var(--ink-mute); margin-top: 8px; font-family: var(--mono); }
svg.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: 0.78rem; color: var(--ink-mid); margin-top: 10px; }
.legend .k { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend .sw.bar { width: 10px; height: 10px; border-radius: 2px; }

/* Mirror word list */
.words { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: baseline; margin: 12px 0; }
.words .w { color: var(--ink); }
.words .w .c { color: var(--ink-faint); font-size: 0.7rem; font-family: var(--mono); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.shift-col h4 { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-mute); margin-bottom: 8px; }
.shift-col .row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--line-soft); font-size: 0.9rem; }
.shift-col .row .d { font-family: var(--mono); color: var(--ink-faint); font-size: 0.75rem; }
.marker-shift .row { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 0.95rem; }
.marker-shift .row:last-child { border-bottom: none; }
.marker-shift .row .d { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-faint); }
.marker-shift .row .d.rose { color: var(--accent); }
.marker-shift .row .d.fell { color: var(--ink-mute); }
.marker-shift .row .d.steady { color: var(--ink-faint); }

/* Calendar grid */
.cal { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; margin: 16px 0; }
.cell { aspect-ratio: 1; border-radius: 3px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 0.62rem; color: var(--ink-faint); cursor: pointer; font-family: var(--mono); }
.cell.complete { background: var(--accent); border-color: var(--accent); color: #16100a; }
.cell.partial { border-color: var(--accent); color: var(--accent); }
.cell.future { opacity: 0.4; cursor: default; }
.cell.today { outline: 2px solid var(--ink); outline-offset: 1px; }
[data-theme="light"] .cell.complete { color: #fff; }

/* Footer disclaimer */
.footer { margin-top: 40px; padding: 20px 0 10px; border-top: 1px solid var(--line-soft); }
.footer .disc { font-size: 0.72rem; color: var(--ink-faint); line-height: 1.5; }
.footer a { color: var(--ink-mute); font-size: 0.75rem; }
.disc-full { font-size: 0.85rem; color: var(--ink-mid); line-height: 1.6; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--ink);
  padding: 12px 18px; border-radius: var(--radius); font-size: 0.9rem; z-index: 100;
  max-width: 90%; box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.offline-bar { background: var(--accent-soft); color: var(--accent); text-align: center; font-size: 0.78rem; padding: 6px; border-radius: var(--radius); margin: 10px 0; }

/* Segmented control */
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { flex: 1; background: var(--bg-raised); border: none; color: var(--ink-mid); padding: 10px; cursor: pointer; font-size: 0.9rem; }
.seg button.on { background: var(--accent); color: #16100a; font-weight: 600; }
[data-theme="light"] .seg button.on { color: #fff; }

.spacer { height: 12px; }
.hr { height: 1px; background: var(--line-soft); margin: 20px 0; border: none; }
.hidden { display: none !important; }
.fade-in { animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }


/* ============ THEORY LAYER ============ */

/* Day head — replaces the old idea block. Law line is the largest serif on its own line. */
.day-head { margin: 6px 0 4px; }
.day-head .law-line {
  font-family: var(--serif); font-weight: 600; color: var(--ink);
  font-size: 1.9rem; line-height: 1.14; letter-spacing: 0; margin-bottom: 12px;
}
.day-head .law-body {
  font-family: var(--serif); font-size: 1.12rem; line-height: 1.6; color: var(--ink-mid);
}
.day-head .head-rule { height: 1px; background: var(--line); border: none; margin: 18px 0; }
.day-head .today-line { font-size: 1rem; line-height: 1.62; color: var(--ink); }
.day-head .today-line strong { font-family: var(--serif); font-weight: 600; letter-spacing: 0.01em; }
.today-crit {
  display: inline; font-style: italic; color: var(--accent);
}
.day-head .today-line .today-crit { color: var(--accent); }

/* Glossary term — subtle tappable underline, opens an in-place panel. */
.gloss {
  border-bottom: 1px dotted var(--accent); color: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gloss:hover { color: var(--accent); }
.gloss-overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end;
  justify-content: center; background: rgba(20, 18, 12, 0.42);
  animation: fade 0.18s ease;
}
.gloss-panel {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0; padding: 24px 22px 28px;
  width: 100%; max-width: var(--maxw); box-shadow: 0 -12px 40px rgba(0,0,0,0.28);
}
@media (min-width: 620px) {
  .gloss-overlay { align-items: center; }
  .gloss-panel { border-radius: var(--radius); }
}
.gloss-term { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.gloss-def { color: var(--ink-mid); font-size: 1rem; line-height: 1.6; margin-bottom: 18px; }
.gloss-close { margin: 0; }

/* Theory cards — primer, phase openings, reference. Pre-rendered HTML from theory.json. */
.theory-card h1 { font-family: var(--serif); font-size: 1.7rem; line-height: 1.16; margin-bottom: 12px; color: var(--ink); }
.theory-card h2 { font-family: var(--serif); font-size: 1.3rem; margin: 18px 0 8px; color: var(--ink); }
.theory-card h3 { font-family: var(--serif); font-size: 1.08rem; margin: 16px 0 6px; color: var(--ink); }
.theory-card p { color: var(--ink-mid); font-size: 1.04rem; line-height: 1.66; margin: 10px 0; }
.theory-card p:first-child { margin-top: 0; }
.theory-card strong { color: var(--ink); font-weight: 600; }
.theory-card em { font-style: italic; }
.theory-card hr { height: 1px; background: var(--line); border: none; margin: 18px 0; }
.theory-card ul, .theory-card ol { margin: 10px 0 10px 20px; color: var(--ink-mid); }
.theory-card li { margin: 6px 0; line-height: 1.6; }
.theory-card table, .ref-table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 0.95rem; }
.theory-card th, .theory-card td, .ref-table th, .ref-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); color: var(--ink-mid); vertical-align: top;
}
.theory-card th, .ref-table th { color: var(--ink-mute); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; }

/* Primer flow — dots reuse .progress .dot. Give the card a little more breathing room. */
.primer-card { min-height: 40vh; }

/* Reference — collapsible sections. */
.ref-section { border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; background: var(--bg-card); }
.ref-section > summary {
  list-style: none; cursor: pointer; padding: 16px 18px; font-family: var(--serif);
  font-size: 1.12rem; color: var(--ink); display: flex; justify-content: space-between; align-items: center;
}
.ref-section > summary::-webkit-details-marker { display: none; }
.ref-section > summary::after { content: "+"; color: var(--ink-faint); font-family: var(--sans); font-size: 1.2rem; }
.ref-section[open] > summary::after { content: "–"; }
.ref-section[open] > summary { border-bottom: 1px solid var(--line-soft); }
.ref-section .theory-card { padding: 4px 18px 18px; }

/* Phase-opening card on Today — a banner variant that invites, never blocks. */
.banner.phase-open { border-color: var(--accent); }
.banner.phase-open .eyebrow { color: var(--accent); margin-bottom: 6px; }
.banner.phase-open h3 { font-family: var(--serif); color: var(--ink); margin-bottom: 10px; }

/* Mirror markers — recurring phrases and returned-to words as a ranked list. */
.marker-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line-soft);
}
.marker-row:last-child { border-bottom: none; }
.marker-term { font-family: var(--serif); font-size: 1.08rem; color: var(--ink); }
.marker-count { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-mute); letter-spacing: 0.04em; }

/* Handwriting guidance shown on writing steps */
.write-note { margin-top: 14px; padding: 12px 14px; background: var(--accent-soft); border-left: 2px solid var(--accent); border-radius: var(--radius); }
.write-note p { margin: 0; font-size: 0.86rem; line-height: 1.55; color: var(--ink-mid); }

/* End-of-day guidance on the Today screen */
.next-day-note { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-raised); }
.next-day-note p { margin: 0; font-size: 0.86rem; line-height: 1.55; color: var(--ink-mid); font-family: var(--serif); font-style: italic; }



/* ===== Expansion: pinned chief aim, tools bar, toolbox, reset, physiology, cancel ===== */

/* Pinned chief aim card — visible on every screen from day 28 onward. Compact, sticky. */
.pinned-aim {
  position: sticky; top: 0; z-index: 40;
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 14px; margin: 0 0 10px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.pinned-aim-label { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-mute); }
.pinned-aim-text { font-family: var(--serif); font-size: 0.98rem; color: var(--ink); line-height: 1.35; }
.pinned-aim-scores { font-size: 0.76rem; color: var(--ink-mid); }

/* Control bar — the Guide and Tools pair, fixed and reachable from every onboarded screen. */
.control-bar {
  position: fixed; right: 16px; bottom: 18px; z-index: 50;
  display: flex; gap: 8px;
}
.tools-bar-btn {
  padding: 10px 18px; border: 1px solid var(--line);
  background: var(--btn); color: var(--btn-ink);
  border-radius: 22px; font-family: var(--sans); font-size: 0.82rem; letter-spacing: 0.03em;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18); cursor: pointer;
}
.tools-bar-btn:hover { opacity: 0.92; }
/* The Guide button reads as the quieter, outlined member of the pair. */
.guide-bar-btn {
  background: var(--bg-card); color: var(--ink); border-color: var(--line);
}
.guide-bar-btn:hover { opacity: 1; border-color: var(--accent); color: var(--accent); }

/* Guide documents — quickstart, how it all works, questions. Headings inherit theory-card. */
.guide-doc h2 { scroll-margin-top: 64px; }
.guide-hiw-body h2 { scroll-margin-top: 8px; }

/* How it all works — a sticky section list above the full document. */
.guide-hiw { margin-top: 4px; }
.guide-toc {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 0 12px; margin-bottom: 8px;
  background: var(--paper); border-bottom: 1px solid var(--line-soft);
}
.guide-toc-link {
  font-family: var(--sans); font-size: 0.74rem; letter-spacing: 0.02em;
  color: var(--ink-mid); background: var(--bg-raised);
  border: 1px solid var(--line-soft); border-radius: 14px;
  padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
.guide-toc-link:hover { color: var(--accent); border-color: var(--accent); }

/* Guide overlay — How it all works layered over the current screen (not a route change). */
.guide-overlay {
  position: fixed; inset: 0; z-index: 300; display: flex;
  align-items: stretch; justify-content: center;
  background: rgba(20, 18, 12, 0.42); animation: fade 0.18s ease;
}
.guide-panel {
  background: var(--bg-card); width: 100%; max-width: var(--maxw);
  display: flex; flex-direction: column; height: 100%;
  box-shadow: 0 0 40px rgba(0,0,0,0.3);
}
.guide-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: var(--bg-card); flex-shrink: 0;
}
.guide-panel-title { font-family: var(--serif); font-size: 1.08rem; color: var(--ink); }
.guide-panel-scroll { overflow-y: auto; flex: 1; padding: 4px 20px 40px; }
.guide-panel-scroll .guide-toc { top: 0; background: var(--bg-card); }
@media (min-width: 620px) {
  .guide-overlay { align-items: center; padding: 24px; }
  .guide-panel { height: auto; max-height: 90vh; border-radius: var(--radius); }
}

/* Questions — groups always visible, each question collapsed. */
.q-group {
  font-family: var(--serif); font-size: 1.18rem; color: var(--ink);
  margin: 22px 0 4px;
}
.q-list { border-top: 1px solid var(--line-soft); }
.q-item { border-bottom: 1px solid var(--line-soft); }
.q-item summary {
  list-style: none; cursor: pointer; padding: 12px 24px 12px 0; position: relative;
  font-family: var(--serif); font-size: 1.02rem; color: var(--ink); line-height: 1.4;
}
.q-item summary::-webkit-details-marker { display: none; }
.q-item summary::after {
  content: '+'; position: absolute; right: 2px; top: 10px;
  color: var(--ink-mute); font-family: var(--sans); font-size: 1.1rem;
}
.q-item[open] summary::after { content: '\2013'; }
.q-answer { padding: 0 0 14px; }
.q-answer p { color: var(--ink-mid); font-size: 1rem; line-height: 1.62; margin: 0; }

/* Reference search. */
.ref-search-wrap { margin-bottom: 14px; }
.ref-search {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg-raised);
  font-family: var(--sans); font-size: 0.95rem; color: var(--ink);
}
.ref-search:focus { outline: none; border-color: var(--accent); }
.ref-results { margin-top: 4px; }
.ref-result-group {
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-mute); display: block; margin-bottom: 2px;
}

/* State toolbox */
.toolbox-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft);
}
.toolbox-item:last-child { border-bottom: none; }
.toolbox-text { font-family: var(--serif); font-size: 1.02rem; color: var(--ink); flex: 1; }
.toolbox-actions { display: flex; gap: 10px; flex-shrink: 0; }
.link-btn { background: none; border: none; color: var(--ink-mute); font-size: 0.78rem; cursor: pointer; padding: 2px 4px; }
.link-btn:hover { color: var(--ink); }
.toolbox-edit-input { flex: 1; }
.toolbox-add { display: flex; gap: 8px; margin-top: 14px; }
.toolbox-add input { flex: 1; }

/* Reset routine + physiology lists */
.reset-list, .physiology-list { margin: 10px 0 0 4px; list-style: none; padding: 0; }
.reset-list li, .physiology-list li {
  padding: 8px 0 8px 20px; position: relative;
  font-family: var(--serif); font-size: 1.04rem; color: var(--ink); line-height: 1.4;
  border-bottom: 1px solid var(--line-soft);
}
.reset-list li:last-child, .physiology-list li:last-child { border-bottom: none; }
.reset-list li::before, .physiology-list li::before {
  content: "—"; position: absolute; left: 0; color: var(--ink-mute);
}
.physiology-list li { font-size: 1.2rem; }
.range-val { margin-top: 6px; font-family: var(--mono); font-size: 0.9rem; color: var(--ink-mid); }

/* Cancel counter — one large tap target */
.cancel-target {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 240px; margin: 18px 0;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--accent-soft); cursor: pointer;
  transition: transform 0.06s ease;
}
.cancel-target:active { transform: scale(0.98); }
.cancel-count { font-family: var(--serif); font-size: 4.2rem; line-height: 1; color: var(--ink); }
.cancel-label { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-mute); }
/* Part 4: THE WEEK assignment banner (above the day head, never blocks the day) */
.week-assign { background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 16px 18px; margin: 0 0 18px; }
.week-assign .eyebrow { color: var(--accent); }
.week-assign h3 { margin: 4px 0 6px; }
.week-assign .write-note { margin-top: 10px; }
