/* Quintilian. Designed for a 16:9 screen first; the lesson workspace fits the window without page
   scrolling and adapts down to tablets and phones, where the page scrolls normally instead. */
:root {
  --bg: #f2ebdd;
  --surface: #fffcf6;
  --surface-2: #f8f1e3;
  --ink: #1a2238;
  --ink-2: #3a4360;
  --muted: #687087;
  --rule: #e2d6bf;
  --rule-2: #cdbd9f;
  --accent: #a3322b;
  --accent-2: #86251f;
  --gold: #c4912f;
  --gold-soft: #f7e7bf;
  --good: #2e6b47;
  --good-soft: #e4f1e7;
  --bad-soft: #f9e4e0;
  --night: #151b2e;
  --display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(26, 34, 56, .06), 0 10px 30px -12px rgba(26, 34, 56, .18);
  --top: 56px;
  --pad: clamp(10px, 1.2vw, 20px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; height: 100%; display: grid; grid-template-rows: var(--top) minmax(0, 1fr);
  color: var(--ink); font: 16px/1.5 var(--sans);
  background: radial-gradient(1200px 600px at 85% -10%, #f9f3e7 0%, transparent 60%), var(--bg);
}
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0 0 .35em; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 2.2vw, 2.3rem); }
h2 { font-size: clamp(1.15rem, 1.4vw, 1.45rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.loading { padding: 24px; }
.eyebrow { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
svg.i { width: 1.1em; height: 1.1em; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--pad); background: var(--night); color: #fff; z-index: 5;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06), 0 6px 20px -10px rgba(0, 0, 0, .5); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 1.3rem; font-weight: 600; letter-spacing: .02em; color: #fff; text-decoration: none; }
.mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: var(--night); font-size: 1.05rem; font-weight: 700;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35); }
.top nav { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, .07); }
.top nav a { color: #cfd5e6; text-decoration: none; padding: 6px 16px; border-radius: 999px; font-weight: 700; font-size: .92rem; }
.top nav a:hover { color: #fff; }
.top nav a.on { background: #fff; color: var(--ink); }

main { min-height: 0; overflow: hidden; }
body[data-view="parent"] main { overflow: auto; }

/* ---------- buttons and form controls ---------- */
button, .btn { font: inherit; font-weight: 700; cursor: pointer; border-radius: 12px; border: 1px solid var(--rule-2); background: var(--surface);
  color: var(--ink); padding: 9px 16px; min-height: 42px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color .15s, border-color .15s, transform .1s, box-shadow .15s; }
button:hover, .btn:hover { border-color: var(--ink-2); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 16px -8px rgba(163, 50, 43, .7); }
button.primary:hover, .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
button.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
button.ghost:hover { background: rgba(26, 34, 56, .06); }
button:disabled { opacity: .4; cursor: default; transform: none; }
input, textarea, select { font: inherit; color: inherit; background: #fff; border: 1px solid var(--rule-2); border-radius: 12px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: 3px solid var(--gold-soft); border-color: var(--gold); }
textarea { min-height: 96px; resize: vertical; }
label { display: block; font-weight: 700; margin: 12px 0 4px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 700; letter-spacing: .04em; padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor; background: var(--surface); }
.pill.mastered { color: var(--good); }
.pill.review, .pill.started { color: #8a5a00; }
.pill.available { color: var(--accent); }
.pill.locked { color: var(--muted); }
.banner { border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; }
.banner.warn { background: #fdf3d8; border: 1px solid #e6cf8a; }
.banner.ok { background: var(--good-soft); border: 1px solid #b6d6bf; }

/* ---------- home ---------- */
.home { height: 100%; display: grid; gap: var(--pad); padding: var(--pad);
  grid-template-columns: minmax(280px, 1fr) minmax(0, 2.3fr); grid-template-rows: minmax(0, 1fr) auto; }
.hero { grid-row: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; padding: clamp(20px, 2.4vw, 40px);
  background: linear-gradient(160deg, #1d2643 0%, var(--night) 70%); color: #fff; border: 0; overflow: hidden; position: relative; }
.hero::after { content: ""; position: absolute; right: -80px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%;
  border: 40px solid rgba(196, 145, 47, .12); pointer-events: none; }
.hero .eyebrow { color: var(--gold); }
.hero h1 { font-size: clamp(2rem, 3.3vw, 3.4rem); margin: 8px 0 6px; }
.hero .span { font-family: var(--display); font-style: italic; color: #cfd5e6; font-size: 1.15rem; }
.hero .intro { color: #d9deec; font-size: 1.02rem; max-width: 34ch; }
.meter { display: grid; gap: 8px; }
.meter-bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.meter-bar i { display: block; height: 100%; background: var(--gold); border-radius: inherit; }
.meter span { font-size: .9rem; color: #cfd5e6; }
.hero .btn.primary { align-self: flex-start; padding: 12px 22px; font-size: 1.05rem; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .7); }
.hero .done-note { color: #d9deec; }

.lesson-grid { grid-row: 1; list-style: none; margin: 0; padding: 0; display: grid; gap: var(--pad);
  grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); min-height: 0; }
.lesson-card { position: relative; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); overflow: hidden; padding: 0; min-height: 0;
  color: inherit; text-decoration: none; transition: transform .2s, box-shadow .2s; }
a.lesson-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(26, 34, 56, .08), 0 18px 36px -14px rgba(26, 34, 56, .3); }
.lesson-card .cover { position: relative; background: #e9dfca; min-height: 0; }
.lesson-card .cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lesson-card .num { position: absolute; left: 12px; top: 12px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface); font-family: var(--display); font-weight: 700; font-size: 1.2rem; color: var(--accent); box-shadow: var(--shadow); }
.lesson-card .body { display: flex; flex-direction: column; gap: 6px; padding: clamp(12px, 1.4vw, 22px); min-height: 0; overflow: hidden; }
.lesson-card h2 { margin: 4px 0 0; font-size: clamp(1.05rem, 1.35vw, 1.4rem); }
.lesson-card .years { font-size: .85rem; color: var(--muted); }
.lesson-card .bq { font-family: var(--serif); font-style: italic; color: var(--ink-2); margin: 4px 0 0; }
.lesson-card .go { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--accent); }
.lesson-card .stats { font-size: .8rem; color: var(--muted); }
.lesson-card.locked .cover img { filter: grayscale(1) contrast(.8); opacity: .55; }
.lesson-card.locked .body { opacity: .6; }
.lesson-card.locked .go { color: var(--muted); }

.timeline-band { grid-column: 1 / -1; padding: 14px 20px 10px; }
.timeline { display: flex; list-style: none; margin: 0; padding: 0; }
.timeline li { flex: 1 1 0; min-width: 0; border-top: 3px solid var(--rule-2); padding: 10px 10px 0 0; position: relative; font-size: .8rem; color: var(--ink-2); }
.timeline li::before { content: ""; position: absolute; top: -8px; left: 0; width: 13px; height: 13px; border-radius: 50%; background: var(--surface); border: 3px solid var(--rule-2); }
.timeline li.done { border-top-color: var(--good); }
.timeline li.done::before { border-color: var(--good); background: var(--good); }
.timeline b { display: block; font-family: var(--display); font-size: 1.05rem; color: var(--ink); }

/* ---------- lesson workspace ---------- */
.ws { --stage: 66%; height: 100%; display: grid; gap: var(--pad); padding: var(--pad);
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); }
.ws[data-stage="closed"] { --stage: 52px; }
.ws[data-stage="none"] { --stage: 0px; }
.lesson-pane { min-height: 0; display: grid; gap: 12px; grid-template-rows: auto var(--stage) minmax(0, 1fr);
  transition: grid-template-rows .55s cubic-bezier(.65, 0, .35, 1); }
.lesson-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.back { flex: 0 0 auto; width: 42px; height: 42px; padding: 0; border-radius: 50%; }
.lesson-id { min-width: 0; flex: 1; }
.lesson-id h1 { font-size: clamp(1.15rem, 1.6vw, 1.6rem); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.parts { display: flex; gap: 6px; flex: 0 0 auto; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--rule); }
.parts button { min-height: 34px; padding: 4px 14px; border-radius: 999px; border: 0; background: transparent; font-size: .88rem; color: var(--ink-2); }
.parts button:hover { background: var(--surface-2); }
.parts button.on { background: var(--ink); color: #fff; }
.parts button.seen:not(.on) { color: var(--good); }

.stage-wrap { min-height: 0; overflow: hidden; border-radius: var(--radius); background: var(--night); box-shadow: var(--shadow); }
#scene, .still { height: 100%; display: flex; flex-direction: column; }
.stage { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; cursor: pointer;
  background: radial-gradient(120% 120% at 50% 40%, #efe6d2 0%, #e2d5b8 100%); }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage text { font-family: var(--sans); }
.stage .serif { font-family: var(--display); }
.stage .halo { paint-order: stroke; stroke: rgba(255, 253, 248, .92); stroke-linejoin: round; }
.stage-big { position: absolute; left: 0; right: 0; bottom: 8%; margin: 0 auto; width: 88px; height: 88px; border-radius: 50%; border: 0; padding: 0;
  background: var(--accent); color: #fff; font-size: 2rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .35), 0 0 0 10px rgba(163, 50, 43, .18); }
.stage-big:hover { background: var(--accent-2); }
.stage-big[hidden] { display: none; }
.stage-bar { flex: 0 0 52px; display: flex; align-items: center; gap: 10px; padding: 0 10px; background: var(--night); color: #e6e9f3; }
.stage-btn, .stage-bar button { min-height: 36px; padding: 4px 14px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .06); color: #fff; font-size: .9rem; }
.stage-bar button:hover { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .3); }
.stage-btn.icon { width: 36px; padding: 0; }
.stage-progress { flex: 1; min-width: 40px; height: 6px; background: rgba(255, 255, 255, .14); border-radius: 3px; overflow: hidden; }
.stage-progress i { display: block; height: 100%; width: 0; background: var(--gold); }
.stage-bar .toggle { color: #cfd5e6; font-size: .85rem; }
.still .stage { cursor: zoom-in; }
.still .stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.still .stage-bar .caption { flex: 1; font-size: .85rem; color: #cfd5e6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.reader { min-height: 0; overflow: auto; scroll-behavior: smooth; padding: clamp(14px, 1.5vw, 24px) clamp(16px, 2vw, 32px); }
.reader-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.reader-head h2 { margin: 0; }
.narration { font-family: var(--serif); font-size: clamp(1.05rem, 1.15vw, 1.25rem); line-height: 1.7; max-width: 75ch; margin-bottom: 14px; }
.narration .say { cursor: pointer; border-radius: 4px; padding: 1px 0; transition: background-color .3s, color .3s; }
.narration .say:hover { background: var(--surface-2); }
.narration .say.now { background: var(--gold-soft); box-shadow: 0 0 0 3px var(--gold-soft); }
.ws[data-playing="true"] .narration .say:not(.now) { color: var(--muted); }
.look { border-left: 4px solid var(--gold); background: var(--surface-2); padding: 10px 14px; border-radius: 0 12px 12px 0; margin: 0 0 14px; max-width: 75ch; }
.look b { display: block; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: #8a6418; }
.words { max-width: 75ch; margin-bottom: 14px; }
.words summary { cursor: pointer; font-weight: 700; padding: 4px 0; color: var(--ink-2); }
.words dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0 0; }
.words dt { font-weight: 700; }
.words dd { margin: 0; color: var(--ink-2); }
.reader-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--rule); padding-top: 14px; max-width: 75ch; }
.credits { font-size: .78rem; color: var(--muted); max-width: 75ch; margin-top: 14px; }
.credits summary { cursor: pointer; }
.credit { margin: 6px 0; }
.credit b { color: var(--ink); }
.tag { display: inline-block; font-size: .64rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 4px; background: var(--ink); color: #fff; margin-right: 6px; }
.tag.later-artwork, .tag.modern-map { background: #8a5a00; }
.tag.generated-from-data { background: var(--muted); }

/* ---------- tutor ---------- */
.tutor { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: 0; overflow: hidden; }
.tutor-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--rule); background: var(--surface-2); }
.avatar { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--night); color: var(--gold);
  font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.tutor-head { flex-wrap: wrap; }
.tutor-head .who { flex: 1; min-width: 0; line-height: 1.25; }
.tutor-voice { flex: 1 0 100%; display: flex; align-items: center; gap: 8px; }
.tutor-voice label { margin: 0; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.tutor-voice select { padding: 5px 10px; border-radius: 10px; font-size: .88rem; min-width: 0; }
.tutor-voice button { min-height: 32px; width: 34px; padding: 0; }
.narrator { margin-left: auto; font-size: .82rem; color: var(--muted); }
.narrator b { color: var(--ink-2); }
.tutor-head .who b { display: block; font-family: var(--display); font-size: 1.1rem; font-weight: 600; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; vertical-align: 1px; }
.status-dot.off { background: #c9a227; }
.feed { overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.msg { max-width: 90%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; animation: rise .3s ease-out; }
.msg.assistant { background: var(--surface-2); border: 1px solid var(--rule); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.user { background: var(--ink); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.msg.error { background: var(--bad-soft); color: #7a1f1a; align-self: stretch; max-width: none; white-space: normal; }
.msg.error button { display: flex; margin-top: 8px; min-height: 34px; padding: 4px 14px; font-size: .88rem; }
.msg.note { align-self: stretch; max-width: none; background: transparent; border: 1px dashed var(--rule-2); color: var(--muted); font-size: .88rem; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.qc { align-self: stretch; border: 1px solid var(--rule); border-left: 5px solid var(--gold); border-radius: 14px; background: #fff; padding: 14px; animation: rise .35s ease-out;
  box-shadow: 0 8px 20px -14px rgba(26, 34, 56, .4); }
.qc.right { border-left-color: var(--good); }
.qc-tag { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: #8a6418; margin-bottom: 4px; }
.qc.right .qc-tag { color: var(--good); }
.qc-q { font-family: var(--display); font-size: 1.12rem; font-weight: 600; line-height: 1.3; margin: 0 0 10px; }
.qc-choices { display: grid; gap: 8px; }
.qc-choice { justify-content: flex-start; text-align: left; font-weight: 400; min-height: 44px; padding: 8px 12px; border-radius: 12px; background: var(--surface); line-height: 1.35; }
.qc-choice:hover:not(:disabled) { border-color: var(--gold); background: #fffaf0; }
.qc-letter { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem;
  background: var(--surface-2); border: 1px solid var(--rule-2); }
.qc-choice.wrong { border-color: var(--accent); background: var(--bad-soft); opacity: 1; animation: shake .35s; }
.qc-choice.wrong .qc-letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.qc-choice.correct { border-color: var(--good); background: var(--good-soft); opacity: 1; }
.qc-choice.correct .qc-letter { background: var(--good); border-color: var(--good); color: #fff; }
.qc-choice:disabled:not(.wrong):not(.correct) { opacity: .5; }
.qc-fb { margin: 10px 0 0; font-size: .95rem; }
.qc-fb.hint { color: #7a4f00; }
.qc-fb.ok { color: var(--good); }
.qc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Side quests */
.offer { align-self: stretch; border-radius: 14px; padding: 14px; color: #fff; animation: rise .35s ease-out;
  background: linear-gradient(140deg, #26305a 0%, var(--night) 75%); box-shadow: 0 10px 24px -14px rgba(21, 27, 46, .8); }
.offer-tag { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: var(--gold); }
.offer-title { font-family: var(--display); font-size: 1.2rem; font-weight: 600; line-height: 1.25; margin: 4px 0 10px; }
.offer button.primary { background: var(--gold); border-color: var(--gold); color: var(--night); box-shadow: none; }
.offer button.primary:hover { background: #d9a43c; border-color: #d9a43c; }
.offer button:not(.primary) { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .3); }
.offer-stage { margin: 10px 0 0; font-size: .88rem; color: #cfd5e6; }
.offer-stage.bad { color: #ffb4a8; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(21, 27, 46, .25); border-top-color: var(--night); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.side-list { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; max-width: 75ch; }
.side-list > b { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); margin-right: 4px; }
.side-chip { min-height: 34px; padding: 4px 12px; border-radius: 999px; font-size: .88rem; background: var(--night); color: #fff; border-color: var(--night); }
.side-chip:hover { background: #26305a; border-color: #26305a; }
.side-chip .tag { margin: 0 0 0 6px; }
.tag.unreviewed { background: #8a5a00; }
.eyebrow.side { color: #8a6418; }
.review-note { max-width: 75ch; font-size: .86rem; border-radius: 10px; padding: 8px 12px; margin: 4px 0 12px; background: #fdf3d8; border: 1px solid #e6cf8a; }
.review-note.approved { background: var(--good-soft); border-color: #b6d6bf; }
.review-note.rejected { background: var(--bad-soft); border-color: #e8b9b2; }
.pill.side-unreviewed { color: #8a5a00; }
.pill.side-approved { color: var(--good); }
.pill.side-rejected { color: var(--accent); }
.ws.solo { grid-template-columns: minmax(0, 1fr); }

.tutor-foot { border-top: 1px solid var(--rule); padding: 10px 12px 12px; background: var(--surface); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.chips button { flex: 0 0 auto; min-height: 32px; padding: 4px 12px; font-size: .82rem; font-weight: 700; border-radius: 999px; background: var(--surface-2); border-color: var(--rule); color: var(--ink-2); }
.ask { display: flex; gap: 8px; }
.ask input { flex: 1; min-width: 0; border-radius: 999px; padding-left: 16px; }
.ask button { border-radius: 999px; width: 44px; padding: 0; }
.tutor .banner { margin: 0 0 8px; font-size: .84rem; padding: 8px 12px; }

/* ---------- end-of-lesson check (inside the reader) ---------- */
.check-head { margin-bottom: 10px; }
.q { border-top: 1px solid var(--rule); padding: 14px 0; max-width: 80ch; }
.q:first-of-type { border-top: 0; padding-top: 4px; }
.q h3 { font-family: var(--display); font-size: 1.12rem; }
.choice { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 6px 0; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 12px; background: #fff; cursor: pointer; }
.choice:hover { border-color: var(--gold); }
.choice input { width: 18px; height: 18px; margin-top: 3px; flex: 0 0 auto; accent-color: var(--accent); }
.choice.right { border-color: var(--good); background: var(--good-soft); }
.choice.wrong { border-color: var(--accent); background: var(--bad-soft); }
.feedback { font-size: .93rem; margin-top: 6px; }
.feedback.ok { color: var(--good); }
.feedback.no { color: var(--accent); }
.result { text-align: center; margin: 10px 0 20px; max-width: 80ch; }
.result .score { font-family: var(--display); font-size: 3rem; font-weight: 700; color: var(--accent); }

/* ---------- accounts (hosted version) ---------- */
body[data-view="terms"] main, body[data-view="privacy"] main { overflow: auto; }
.account { min-height: 100%; display: grid; place-content: center; padding: var(--pad); overflow: auto; }
main:has(.account) { overflow: auto; }
.account-card { width: min(520px, calc(100vw - 32px)); padding: clamp(20px, 3vw, 36px); }
.account-card h1 { margin-top: 4px; }
.account-links { text-align: center; margin-top: 12px; }
button.wide { width: 100%; }
.or { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.check-line { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 14px 0 0; }
.check-line input { width: 18px; height: 18px; margin-top: 3px; flex: 0 0 auto; accent-color: var(--accent); }
.account-msg { min-height: 1.5em; margin: 12px 0 0; color: var(--accent); }
.account-msg.ok { color: var(--good); }
button.danger { border-color: var(--accent); color: var(--accent); }
button.danger[data-armed="1"] { background: var(--accent); color: #fff; }
.invite-list { list-style: none; margin: 0 0 12px; padding: 0; }
.invite-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.legal section { max-width: 75ch; }
.legal h2 { margin-top: 1.2em; }

/* ---------- voices ---------- */
body[data-view="voices"] main { overflow: auto; }
.voices-top { display: grid; gap: var(--pad); grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); margin-bottom: var(--pad); }
.sample-line { font-family: var(--serif); font-size: 1.15rem; font-style: italic; color: var(--ink-2); }
.cast-summary h2 { margin-bottom: 4px; }
.cast-names { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.filters { display: grid; gap: 8px; margin-bottom: var(--pad); }
.filter-chip { min-height: 34px; padding: 4px 14px; border-radius: 999px; font-size: .88rem; background: var(--surface); }
.filter-chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.voice-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.voice-card { padding: 14px; display: grid; gap: 10px; }
.voice-card b { font-family: var(--display); font-size: 1.15rem; font-weight: 600; }
.voice-card.chosen { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft), var(--shadow); }
.voice-play { min-height: 36px; padding: 4px 14px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; max-width: 420px; box-shadow: var(--shadow); }
@media (max-width: 860px) { .voices-top { grid-template-columns: 1fr; } }

/* ---------- parent ---------- */
.parent { max-width: 1200px; margin: 0 auto; padding: var(--pad) var(--pad) 60px; }
.parent > h1 { margin: 6px 0 14px; }
.parent-grid { display: grid; gap: var(--pad); grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); align-items: start; }
.parent-grid .wide { grid-column: 1 / -1; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 10px 0; }
.stat { border: 1px solid var(--rule); border-radius: 12px; padding: 10px 12px; background: #fff; }
.stat b { display: block; font-family: var(--display); font-size: 1.5rem; }
.media-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0 20px; }
.media-list li { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.media-list img, .media-list .thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: #ece4d2; }

#zoom { position: fixed; inset: 0; z-index: 20; background: rgba(15, 18, 30, .94); overflow: auto; cursor: zoom-out; display: grid; place-items: center; }
#zoom[hidden] { display: none; }
#zoom img { display: block; max-width: 96vw; max-height: 96vh; }

/* ---------- other window shapes ---------- */
/* Narrower windows: tutor column gets a little less room. */
@media (max-width: 1280px) {
  .ws { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); }
  .parts button { padding: 4px 10px; }
}
/* Ultrawide windows: the tutor does not need a full third. */
@media (min-aspect-ratio: 2/1) and (min-width: 1800px) {
  .ws { grid-template-columns: minmax(0, 1fr) minmax(380px, 640px); }
}
/* Tall or square windows: give the picture a bit more of the column. */
@media (min-aspect-ratio: 1/1) and (max-aspect-ratio: 3/2) {
  .ws { --stage: 58%; }
}
/* Short windows (a laptop with a docked browser bar, or landscape tablet). */
@media (max-height: 720px) {
  :root { --top: 48px; }
  .lesson-pane { gap: 8px; }
  .home { grid-template-rows: minmax(0, 1fr); }
  .timeline-band { display: none; }
  .hero .intro { display: none; }
}
/* Phones and narrow windows: stack everything and let the page scroll. */
@media (max-width: 860px), (max-height: 520px) {
  body { display: block; height: auto; }
  main, body[data-view] main { overflow: visible; }
  .top { position: sticky; top: 0; height: var(--top); }
  .home { display: flex; flex-direction: column; height: auto; }
  .lesson-grid { grid-template-columns: 1fr; grid-template-rows: none; }
  .lesson-card { grid-template-columns: 1fr; }
  .lesson-card .cover { aspect-ratio: 16 / 9; }
  .timeline-band { display: block; overflow-x: auto; }
  .timeline li { flex: 0 0 120px; }
  .hero .intro { display: block; }
  .ws { display: flex; flex-direction: column; height: auto; }
  .lesson-pane { display: flex; flex-direction: column; }
  .lesson-head { flex-wrap: wrap; }
  .parts { order: 3; width: 100%; justify-content: center; }
  .stage-wrap { height: calc(min(100vw, 860px) * .62 + 52px); transition: height .5s cubic-bezier(.65, 0, .35, 1); }
  .ws[data-stage="closed"] .stage-wrap { height: 52px; }
  .stage-bar { gap: 6px; padding: 0 8px; }
  .stage-bar button { white-space: nowrap; padding: 4px 10px; }
  .stage-bar [data-action="fold"] { width: 36px; padding: 0; font-size: 0; gap: 0; }
  .stage-bar [data-action="fold"] svg { width: 18px; height: 18px; }
  .ws[data-stage="none"] .stage-wrap { display: none; }
  .reader { overflow: visible; padding: 14px 4px; }
  .tutor { min-height: 70vh; max-height: 90vh; }
  .words dl { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .brand { font-size: 1.05rem; gap: 8px; }
  .mark { width: 28px; height: 28px; }
  .top nav a { padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
