/* Vedic Sandhya participant app — calm educational workbook style.
   Fonts: system fonts only (no remote requests). Segoe UI / Roboto / SF include every
   diacritic used in the course texts; Georgia and Palatino do not, so they are not used. */

:root {
  --ivory: #FBF8F1;
  --paper: #FFFDF8;
  --green: #1F4D3A;
  --green-2: #2A6149;
  --green-tint: #E6EFE9;
  --gold: #B08D3C;          /* decorative only — never body text */
  --gold-soft: #F1E7CC;
  --ink: #26241F;
  --muted: #55504A;
  --border: #DDD3BF;
  --error: #9B2C2C;
  --error-bg: #FBEAEA;
  --ok: #1D6435;
  --warn-bg: #FFF4D6;
  --focus: #0B57D0;
  --scale: 1;
  --mantra-scale: 1.15;
  --lh: 1.65;
  --radius: 10px;
  --topbar-h: 3.6rem;
  --nav-h: 4.2rem;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-head: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", Arial, sans-serif;
}
:root[data-spacing="normal"] { --lh: 1.55; }
:root[data-spacing="relaxed"] { --lh: 1.7; }
:root[data-spacing="extra"] { --lh: 1.95; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  font-size: calc(112.5% * var(--scale)); /* 18px at standard size */
  scroll-padding-top: calc(var(--topbar-h) + 1rem);
  scroll-padding-bottom: calc(var(--nav-h) + 1rem);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--font);
  line-height: var(--lh);
  overflow-wrap: break-word;
}
img, svg { max-width: 100%; }
a { color: var(--green); text-underline-offset: 0.18em; }
a:hover { color: var(--green-2); }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.3; color: var(--green); margin: 1.4em 0 0.5em; }
h1 { font-size: 1.75rem; margin-top: 0.4em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.12rem; }
h4 { font-size: 1rem; color: var(--ink); }
p, ul, ol, dl { margin: 0.5em 0 0.9em; }
li { margin: 0.25em 0; }
.small { font-size: 0.86rem; color: var(--muted); }
.lead { font-size: 1.1rem; }
.eyebrow { font-size: 0.85rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1:focus, h1:focus-visible, [tabindex="-1"]:focus:not(:focus-visible) { outline: none; }
.seq-step:focus-visible { outline: 3px solid var(--focus); }

.skip-link { position: absolute; left: 0.5rem; top: -4rem; background: var(--paper); color: var(--green); padding: 0.6rem 1rem; border: 2px solid var(--green); border-radius: var(--radius); z-index: 100; }
.skip-link:focus { top: 0.5rem; }

/* ---------- Top bar & navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  min-height: var(--topbar-h); padding: 0.35rem 1rem;
  background: var(--green); color: #fff;
  border-bottom: 3px solid var(--gold);
}
.brand { color: #fff; text-decoration: none; display: flex; flex-direction: column; line-height: 1.15; }
.brand:hover { color: #fff; }
.brand-main { font-weight: 700; font-size: 1.05rem; }
.brand-sub { font-size: 0.72rem; opacity: 0.9; }
.topbar-tools { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
.topbar :focus-visible { outline-color: #FFE08A; }
.save-state { font-size: 0.78rem; opacity: 0.95; }
.save-state[data-kind="error"] { background: #fff; color: var(--error); padding: 0.15rem 0.5rem; border-radius: 6px; font-weight: 600; }
.save-state[data-kind="memory"] { background: var(--warn-bg); color: #5a4300; padding: 0.15rem 0.5rem; border-radius: 6px; }
.btn-mode { background: transparent; color: #fff; border-color: rgba(255,255,255,0.7); }
.btn-mode:hover { background: rgba(255,255,255,0.12); color: #fff; }

.workshop-bar { position: sticky; top: var(--topbar-h); z-index: 25; background: var(--gold-soft); border-bottom: 1px solid var(--border); padding: 0.4rem 1rem; }
.code-form-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; max-width: 60rem; margin: 0 auto; }
.code-form-inline label { font-weight: 600; font-size: 0.9rem; }
.code-form-inline input { width: 6.5rem; }
.code-error { color: var(--error); font-size: 0.85rem; }

.banner { padding: 0.6rem 1rem; background: var(--green-tint); border-bottom: 1px solid var(--border); }
.banner p { margin: 0; max-width: 60rem; margin-inline: auto; }
.banner-warn { background: var(--warn-bg); }

.layout { display: block; }
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--green); border-top: 3px solid var(--gold);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: var(--nav-h); padding: 0.25rem 0.1rem; color: #fff; text-decoration: none; font-size: 0.72rem; text-align: center; line-height: 1.2;
}
.nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255,255,255,0.14); box-shadow: inset 0 3px 0 var(--gold); font-weight: 700; }
.nav-icon { font-size: 1.25rem; line-height: 1; margin-bottom: 0.15rem; }
.nav :focus-visible { outline-color: #FFE08A; outline-offset: -4px; }

main { display: block; padding: 1rem 1rem calc(var(--nav-h) + 2rem); outline: none; }
.view { max-width: 46rem; margin: 0 auto; }

@media (min-width: 960px) {
  html { scroll-padding-bottom: 1rem; }
  .layout { display: grid; grid-template-columns: 13.5rem 1fr; }
  .nav {
    position: sticky; top: var(--topbar-h); bottom: auto; align-self: start;
    height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; gap: 0.2rem;
    border-top: 0; border-right: 3px solid var(--gold); padding: 1rem 0.6rem;
  }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 0.7rem; font-size: 1rem; min-height: 3rem; padding: 0.4rem 0.8rem; border-radius: 8px; text-align: left; }
  .nav a[aria-current="page"] { box-shadow: inset 4px 0 0 var(--gold); }
  .nav-icon { margin: 0; width: 1.4rem; text-align: center; }
  main { padding: 1.5rem 2rem 4rem; }
  .workshop-bar { position: sticky; }
}

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.75rem; padding: 0.45rem 1rem;
  font: inherit; font-size: 0.95rem; font-weight: 600; line-height: 1.25; text-align: center; text-decoration: none;
  color: var(--green); background: var(--paper);
  border: 2px solid var(--green); border-radius: var(--radius); cursor: pointer;
}
.btn:hover { background: var(--green-tint); color: var(--green); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-2); color: #fff; }
.btn-danger { background: var(--error); border-color: var(--error); color: #fff; }
.btn-danger:hover { background: #7f2020; color: #fff; }
.btn-small { min-height: 2.25rem; padding: 0.3rem 0.75rem; font-size: 0.86rem; }
.btn-quiet { border-color: var(--border); color: var(--green); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn[aria-pressed="true"]:not(.btn-mode) { background: var(--green-tint); }
.segmented .btn[aria-pressed="true"] { background: var(--green); color: #fff; }
.reader-controls .btn[aria-current="true"] { background: var(--green); color: #fff; }

input[type="text"], input[type="search"], input[type="date"], input[type="number"], select, textarea {
  font: inherit; font-size: 1rem; color: var(--ink); background: #fff;
  border: 2px solid #9C927E; border-radius: 8px; padding: 0.55rem 0.7rem; min-height: 2.75rem; max-width: 100%;
}
textarea { width: 100%; line-height: 1.5; resize: vertical; min-height: 5rem; }
input[type="text"], input[type="search"] { width: 100%; }
select { cursor: pointer; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
input[type="checkbox"], input[type="radio"] { width: 1.3rem; height: 1.3rem; accent-color: var(--green); flex: none; margin: 0.15rem 0 0; }
label { font-weight: 600; }
.check { display: flex; align-items: flex-start; gap: 0.6rem; font-weight: 400; padding: 0.4rem 0; min-height: 2.5rem; cursor: pointer; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 1rem 0.8rem; margin: 0.8rem 0; min-width: 0; }
legend { font-weight: 700; padding: 0 0.3rem; }

.field { margin: 0.9rem 0; }
.field label { display: block; margin-bottom: 0.3rem; }
.field .hint { margin: 0 0 0.35rem; }
.field-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.3rem 0; }
.field-inline label { margin: 0; font-weight: 400; font-size: 0.9rem; }
.field-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 1.6rem; }
.save-status { font-size: 0.82rem; color: var(--muted); }
.save-status[data-kind="ok"] { color: var(--ok); }
.save-status[data-kind="warn"] { color: #6b4e00; }
.save-status[data-kind="error"] { color: var(--error); font-weight: 600; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.hint { font-size: 0.88rem; color: var(--muted); }
.private-tag { font-size: 0.85rem; color: var(--muted); font-style: italic; }
.search-row { display: flex; gap: 0.5rem; }
.search-row input { flex: 1; min-width: 0; }
.grid2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Cards & blocks ---------- */
.card { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.card h2, .card h3 { margin-top: 0.1em; }
.cards { list-style: none; padding: 0; display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(2, 1fr); } .cards.days { grid-template-columns: 1fr; } }
.home-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; margin: 1rem 0; }
@media (min-width: 700px) { .home-grid { grid-template-columns: repeat(2, 1fr); } }
.day-card { border-left: 5px solid var(--gold); }
.block { margin: 1.4rem 0; }
.block > h3:first-child, .block > h2:first-child { margin-top: 0; }
.note, .note-inline { background: var(--green-tint); border-radius: var(--radius); padding: 0.8rem 1rem; }
.note-inline { font-size: 0.92rem; }
.care { background: var(--paper); border: 1px solid var(--border); border-left: 5px solid var(--green); border-radius: var(--radius); padding: 0.7rem 1rem; }
.care h3 { margin-top: 0.2rem; font-size: 1rem; }
.notice { background: var(--warn-bg); border: 1px solid #E8D39A; border-radius: var(--radius); padding: 0.6rem 0.9rem; }
.story { border-left: 4px solid var(--gold); padding: 0.4rem 1rem; background: var(--paper); border-radius: 0 var(--radius) var(--radius) 0; }
.pair { background: var(--paper); border: 1px dashed #B7AC95; border-radius: var(--radius); padding: 0.7rem 1rem; }
.private-only { background: #F7F2E6; border-radius: var(--radius); padding: 0.7rem 1rem; }
.danger-zone { border: 2px solid #E3B7B7; border-radius: var(--radius); padding: 0.8rem 1rem; }
.kinds, .aims { display: grid; gap: 0.8rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .kinds, .aims { grid-template-columns: repeat(2, 1fr); } }
.kind-card { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.7rem 0.9rem; min-width: 0; }
.kind-card h4 { margin: 0 0 0.3rem; color: var(--green); }
.terms div { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.terms dt { font-weight: 700; }
.terms dd { margin: 0; }
.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--gold-soft); color: #4A3A12; border: 1px solid #DCC98F; text-decoration: none; vertical-align: middle; }
.badge-draft { background: var(--gold-soft); }
.badge-ok { background: var(--green-tint); color: var(--green); border-color: #B9D1C3; }
.links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.8rem 0; }
.big-actions .btn { min-height: 3.2rem; font-size: 1.05rem; }
.crumbs { font-size: 0.9rem; margin: 0 0 0.3rem; }
.source { margin-top: 2rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; vertical-align: top; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); }
thead th { background: var(--green-tint); color: var(--green); }
.break-row td { background: #F4EEE0; font-style: italic; }
.code-chip { font-weight: 700; white-space: nowrap; color: var(--green); }

/* ---------- Module ---------- */
.module-head .code { font-size: 1rem; font-weight: 800; color: var(--green); background: var(--gold-soft); display: inline-block; padding: 0.1rem 0.6rem; border-radius: 6px; margin: 0.3rem 0 0; letter-spacing: 0.03em; }
.module-head h1 { margin-top: 0.25em; }
.meta { font-size: 0.9rem; color: var(--muted); }
.purpose { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 1rem; }
.purpose p { margin: 0.3rem 0; }
.cues { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }
.cue { font-size: 0.78rem; font-weight: 700; padding: 0.05rem 0.5rem; border-radius: 999px; border: 1px solid var(--border); background: var(--paper); color: var(--ink); }
.step { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.1rem 0.45rem; border-radius: 4px; background: var(--green-tint); color: var(--green); vertical-align: middle; margin-right: 0.3rem; }
.steps li { margin: 0.4rem 0; }
.parts { display: flex; flex-direction: column; gap: 0.3rem; margin: 1rem 0; padding: 0.7rem 1rem; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); }
.parts a[aria-current="page"] { font-weight: 700; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; margin: 2rem 0 1rem; }
.module-record { border-top: 2px solid var(--border); padding-top: 0.5rem; }
.review-toggle { margin: 0.6rem 0; }
.explore { margin: 1rem 0; }
details > summary { cursor: pointer; font-weight: 600; color: var(--green); min-height: 2.5rem; display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; display: inline-block; width: 1em; flex: none; }
details[open] > summary::before { content: "▾"; }
.reveal { border-bottom: 1px solid var(--border); }
.reveal-hint { font-size: 0.8rem; color: var(--muted); font-weight: 400; margin-left: auto; }
.reveal[open] .reveal-hint { visibility: hidden; }
.quiz { margin: 0.8rem 0 1.2rem; }
.quiz-feedback[data-kind="ok"] { border-left: 4px solid var(--ok); padding-left: 0.8rem; }
.quiz-feedback[data-kind="retry"] { border-left: 4px solid var(--gold); padding-left: 0.8rem; }
.match-row { display: grid; grid-template-columns: 1fr; gap: 0.3rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
@media (min-width: 640px) { .match-row { grid-template-columns: 1.2fr 1fr auto; align-items: center; } }
.match-result { font-size: 0.85rem; font-weight: 600; }
.match-result[data-kind="ok"] { color: var(--ok); }
.match-result[data-kind="retry"] { color: #6b4e00; }
.segmented { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0 1rem; }
.scenario-opt { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.8rem; margin: 0.4rem 0; background: var(--paper); }
.checklist { background: var(--paper); border-radius: var(--radius); padding: 0.4rem 1rem; border: 1px solid var(--border); }
.closing-words { margin: 1rem 0; padding: 0.6rem 1rem; border-left: 4px solid var(--gold); background: var(--paper); font-style: italic; }
.recall-row { border-bottom: 1px solid var(--border); padding: 0.4rem 0; }
.recall-row p { margin: 0.2rem 0; }
.break-screen .lead { font-size: 1.25rem; }
.next-step { margin-top: 0; }

/* Workshop mode: larger, simpler */
:root[data-mode="workshop"] .module { font-size: 1.08rem; }
:root[data-mode="workshop"] .module-head .code { font-size: 1.5rem; }

/* ---------- Mantra text ---------- */
.mantra { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem 1rem; margin: 1rem 0; min-width: 0; }
.mantra-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.4rem 1rem; }
.mantra-head h3, .mantra-head h4, .mantra-head h1 { margin: 0.2rem 0; }
.mantra-intro { font-size: 0.92rem; color: var(--muted); }
.skt {
  font-size: calc(1em * var(--mantra-scale));
  line-height: 1.8;
  color: var(--ink);
  overflow-wrap: anywhere;
  hyphens: none;
  padding-block: 0.05em; /* room for dots below and macrons above */
}
.lines { margin: 0.6rem 0; }
.line { margin: 0.1rem 0 0.35rem; }
.line.refrain { padding-left: 0.8rem; border-left: 3px solid var(--gold-soft); }
.refrain-tag { font-size: 0.72rem; color: var(--muted); font-style: italic; white-space: nowrap; }
.continuous { margin: 0.6rem 0; }
.phrase-list { list-style: none; padding: 0; margin: 0.6rem 0; counter-reset: ph; }
.phrase-list li { display: grid; grid-template-columns: 1fr; gap: 0 1rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); counter-increment: ph; }
.phrase-list li::before { content: counter(ph) "."; font-size: 0.8rem; color: var(--muted); }
@media (min-width: 560px) { .phrase-list li { grid-template-columns: 1.6rem 1.3fr 1fr; align-items: baseline; } }
.phrase-list .ref { font-size: 0.9rem; color: var(--muted); }
.meaning { margin: 0.6rem 0; }
.meaning .kind { margin: 0.5rem 0; }
.meaning h4 { margin: 0.4rem 0 0.1rem; font-size: 0.9rem; color: var(--green); }
.meaning .caveat { font-size: 0.86rem; color: var(--muted); font-style: italic; }
.kind-app { border-left: 3px solid var(--gold); padding-left: 0.7rem; }
.kind-ask { border-left: 3px solid var(--green); padding-left: 0.7rem; }
.notes { font-size: 0.9rem; }
.audio-none { font-size: 0.88rem; color: var(--muted); background: #F5F0E3; border-radius: 8px; padding: 0.45rem 0.7rem; }
.audio { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.track { border-style: dashed; }
.track legend { font-weight: 600; font-size: 0.9rem; }
.track .check { display: inline-flex; margin-right: 1rem; }
.reader .reader-text { margin: 1rem 0; }
.reader-controls { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.8rem 0; }
.one-line .big { font-size: calc(1.35em * var(--mantra-scale)); }
.sample { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 1rem; }

/* Library */
.lib-list { list-style: none; padding: 0; }
.lib-list li { border-bottom: 1px solid var(--border); padding: 0.5rem 0; }
.lib-list a { display: flex; flex-direction: column; text-decoration: none; min-height: 2.75rem; }
.lib-name { font-weight: 700; text-decoration: underline; text-underline-offset: 0.18em; }
.lib-open { font-size: 0.95rem; color: var(--muted); }
.results { list-style: none; padding: 0; }
.results li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }

/* Sequence */
.sequence { margin: 1rem 0; }
.seq-nav { position: sticky; top: calc(var(--topbar-h) + 0.3rem); z-index: 5; background: var(--ivory); padding: 0.5rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; border-bottom: 1px solid var(--border); }
:root[data-mode="workshop"] .seq-nav { top: calc(var(--topbar-h) + 3.4rem); }
.seq-nav select { max-width: 100%; }
.seq-ref { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 1.6rem 0 0.2rem; border-top: 2px solid var(--gold-soft); padding-top: 0.5rem; }
.seq-step { padding: 0.2rem 0 0.8rem; }
.seq-step h2, .seq-step h4 { margin: 0.6rem 0 0.2rem; }
.seq-num { display: inline-flex; align-items: center; justify-content: center; min-width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--green); color: #fff; font-size: 0.85rem; margin-right: 0.3rem; }
.cue-text { font-size: 0.92rem; color: var(--muted); }
.seq-text { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.9rem; margin: 0.5rem 0; }
.seq-text-name { margin: 0.2rem 0; }

/* Focus view: menus hidden, text unchanged, exit control stays visible */
body.focus-view { background: #F1EBDD; }
body.focus-view .nav, body.focus-view .workshop-bar, body.focus-view .banner, body.focus-view .topbar-tools .btn-mode { display: none !important; }
body.focus-view .layout { display: block; }
body.focus-view main { padding-bottom: 3rem; }
body.focus-view .seq-nav { top: calc(var(--topbar-h) + 0.3rem); background: #F1EBDD; }

/* Timer */
.timer { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 1rem; }
.timer-title { margin: 0.2rem 0; }
.timer-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.timer-controls label { font-weight: 400; display: flex; gap: 0.4rem; align-items: center; }
.timer-display { font-variant-numeric: tabular-nums; font-size: 1.3rem; font-weight: 700; color: var(--green); min-width: 3.5rem; }

/* Homework & workbook */
.hw { margin: 1rem 0; }
.hw.is-done { border-left: 5px solid var(--ok); }
.hw-parts { padding-left: 1.2rem; }
.mins { display: inline-block; min-width: 3.6rem; font-weight: 700; color: var(--green); }
.hw-mini { list-style: none; padding: 0; }
.hw-mini li { border-bottom: 1px solid var(--border); padding: 0.5rem 0; }
.hw-record { background: var(--paper); }
.tabs { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; margin: 1rem 0; }
.tabs a { padding: 0.3rem 0; min-height: 2.5rem; display: inline-flex; align-items: center; }
.tabs a[aria-current="page"] { font-weight: 700; box-shadow: inset 0 -3px 0 var(--gold); }
.wb-section { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.3rem 1rem; margin: 0.7rem 0; }
.wb-section > summary { justify-content: flex-start; }
.wb-section > summary .small { margin-left: auto; font-weight: 400; }
.wb-mod h3 { font-size: 1rem; }
.qlist { list-style: none; padding: 0; }
.qlist li { display: flex; gap: 0.5rem; border-bottom: 1px solid var(--border); padding: 0.5rem 0; }
.qlist li.is-done p:first-child { color: var(--muted); }
.log-list { list-style: none; padding: 0; }
.log-list li { border-bottom: 1px solid var(--border); padding: 0.5rem 0; }
.week { margin: 0.8rem 0; }

/* Progress */
.progress { margin: 2rem 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stats div { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.8rem; }
.stats dt { font-size: 0.82rem; color: var(--muted); }
.stats dd { margin: 0.2rem 0 0; font-size: 1.5rem; font-weight: 700; color: var(--green); }
.stats dd span { font-size: 0.9rem; font-weight: 400; color: var(--muted); }

/* Menus, glossary, facts */
.menu-list { list-style: none; padding: 0; }
.menu-list a { display: flex; flex-direction: column; padding: 0.7rem 0.3rem; border-bottom: 1px solid var(--border); text-decoration: none; min-height: 3rem; }
.menu-title { font-weight: 700; text-decoration: underline; text-underline-offset: 0.18em; }
.glossary div { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.glossary dt { font-weight: 700; }
.glossary dd { margin: 0; }
.facts div { display: grid; grid-template-columns: 1fr; padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
@media (min-width: 560px) { .facts div { grid-template-columns: 8rem 1fr; gap: 1rem; } }
.facts dt { font-weight: 700; }
.facts dd { margin: 0; }
.faq { border-bottom: 1px solid var(--border); }
.status-card .state { font-size: 1.15rem; margin: 0.2rem 0; display: flex; align-items: center; gap: 0.5rem; }
.state-icon { display: inline-flex; width: 1.8rem; height: 1.8rem; align-items: center; justify-content: center; border-radius: 50%; border: 2px solid currentColor; font-weight: 700; }
.state-ready { color: var(--ok); }
.state-failed, .state-partial { color: #7a4d00; }
progress { width: 100%; max-width: 20rem; height: 1rem; accent-color: var(--green); }
.welcome { padding-top: 0.5rem; }
.welcome h1 { font-size: 2rem; }
.welcome-days { list-style: none; padding: 0; }
.welcome-days li { border-left: 4px solid var(--gold); padding: 0.3rem 0.8rem; margin: 0.5rem 0; background: var(--paper); border-radius: 0 8px 8px 0; }
.qs-steps { padding-left: 1.2rem; }
.qs-steps h2 { font-size: 1.1rem; margin: 0.8rem 0 0.2rem; }
.conflicts li { border-bottom: 1px solid var(--border); padding: 0.4rem 0; }

/* Toast & dialog */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 1rem); z-index: 60; max-width: min(34rem, calc(100vw - 2rem)); background: var(--ink); color: #fff; padding: 0.7rem 1rem; border-radius: var(--radius); box-shadow: 0 4px 18px rgba(0,0,0,0.2); }
.toast[data-kind="error"] { background: var(--error); }
@media (min-width: 960px) { .toast { bottom: 1.5rem; } }
.dialog { border: 0; border-radius: 14px; padding: 0; max-width: min(38rem, calc(100vw - 1.5rem)); width: 100%; max-height: calc(100vh - 2rem); background: var(--ivory); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.dialog::backdrop { background: rgba(20, 30, 25, 0.55); }
.dialog-inner { padding: 1rem 1.2rem 1.2rem; }
.dialog-inner h2 { margin-top: 0.2rem; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* Presentation view */
body.presenting .topbar, body.presenting .nav, body.presenting .workshop-bar, body.presenting .banner { display: none !important; }
body.presenting .layout { display: block; }
body.presenting main { padding: 1rem 1.5rem 3rem; }
body.presenting .view { max-width: 70rem; font-size: 1.35rem; }
.present-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; font-size: 0.8rem; margin-bottom: 1rem; }
.present-code { font-size: 1.4rem; font-weight: 800; color: var(--green); margin: 0; }
.present h1 { font-size: 2.3rem; margin-top: 0.1em; }
.present-cues { color: var(--muted); }
.present .print-mantra { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 1rem; margin: 0.8rem 0; }

/* Print view on screen */
.print-options { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem 1rem; margin-bottom: 1.5rem; }
.printable .print-module { border-top: 2px solid var(--border); margin-top: 2rem; }
.print-field { margin: 0.6rem 0; }
.print-label { font-weight: 600; margin-bottom: 0.2rem; }
.write-lines { height: 4.5em; background: repeating-linear-gradient(to bottom, transparent 0, transparent 1.45em, #C9BFAA 1.45em, #C9BFAA 1.5em); }
.print-answer { white-space: normal; border-left: 3px solid var(--gold); padding-left: 0.6rem; }
.print-meaning { font-size: 0.92rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a { transition: background-color 0.15s ease; }
}

/* ---------- Reflow at 320px and at the largest text sizes ---------- */
.topbar { flex-wrap: wrap; }
select, input[type="date"], input[type="number"] { min-width: 0; max-width: 100%; }
.match-row > *, .grid2 > *, .home-grid > *, .cards > *, .kinds > *, .aims > *, .stats > *, .field, .timer-controls > *, .seq-nav > * { min-width: 0; }
.match-row select, .seq-nav select, .hw-record select, .log-form select { width: 100%; }
.timer-controls label { flex-wrap: wrap; }
details > summary { flex-wrap: wrap; }
.wb-section > summary .small { margin-left: 0; }
@media (min-width: 480px) { .wb-section > summary .small { margin-left: auto; } }
.eyebrow { overflow-wrap: anywhere; }
.printable table { table-layout: fixed; word-break: break-word; }
.nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.nav a { min-width: 0; }
.nav-label { overflow-wrap: anywhere; max-width: 100%; }
.check > span { min-width: 0; }
/* Sticky-bar heights are measured at runtime (app.js) so focused elements are never hidden. */
html { scroll-padding-top: calc(var(--sticky-top, var(--topbar-h)) + 0.75rem); scroll-padding-bottom: calc(var(--sticky-bottom, var(--nav-h)) + 0.75rem); }
main { padding-bottom: calc(var(--sticky-bottom, var(--nav-h)) + 2rem); }
.workshop-bar { top: var(--topbar-px, var(--topbar-h)); }
.seq-nav, :root[data-mode="workshop"] .seq-nav, body.focus-view .seq-nav { top: calc(var(--sticky-top, var(--topbar-h)) + 0.2rem); }
.toast { bottom: calc(var(--sticky-bottom, var(--nav-h)) + 1rem); }
@media (min-width: 960px) { .toast { bottom: 1.5rem; } main { padding-bottom: 4rem; } .nav { top: var(--sticky-top, var(--topbar-h)); height: calc(100vh - var(--sticky-top, var(--topbar-h))); } }
@media (max-width: 479px) { .brand-sub { display: none; } .save-state { font-size: 0.72rem; } }
input[type="checkbox"], input[type="radio"] { width: 1.45rem; height: 1.45rem; }
input[type="file"] { font: inherit; font-size: 0.95rem; min-height: 2.75rem; padding: 0.4rem 0; max-width: 100%; }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; min-height: 2.5rem; padding: 0.3rem 0.9rem; margin-right: 0.6rem; border: 2px solid var(--green); border-radius: var(--radius); background: var(--paper); color: var(--green); cursor: pointer; }
/* Compact one-row workshop code bar */
.workshop-bar { padding: 0.3rem 0.75rem; }
.code-form-inline { flex-wrap: nowrap; gap: 0.4rem; }
.code-form-inline label { font-size: 0.8rem; white-space: nowrap; }
.code-form-inline input[type="text"] { width: 5.2rem; flex: 0 1 5.2rem; min-height: 2.5rem; padding: 0.3rem 0.5rem; }
.code-form-inline .btn { flex: none; }
.code-error:empty { display: none; }
.code-error { position: absolute; left: 0.75rem; right: 0.75rem; top: 100%; background: var(--paper); border: 1px solid var(--border); border-radius: 6px; padding: 0.2rem 0.5rem; }
.workshop-bar { position: sticky; }
