/* /doctrina: Latin drills. Uses tokens.css and base.css. */

/* Latin is set in Gentium Plus (regular only, so nothing Latin is bold or italic). */
@font-face {
  font-family: "Doctrina Latin";
  src: url("../fonts/GentiumPlus-Regular.woff2") format("woff2");
  font-display: swap;
}

:root { --good: #1F6B3A; --good-bg: #EAF3EC; --bad-bg: #FBECEC; --field: #fff; --rubric-deep: #8A1A23; --latin: "Doctrina Latin", "Gentium Plus", var(--serif); }

/* Night: the same page with the colours turned over. It follows the device unless the switch in
   the masthead has been used (js/theme.js sets data-theme). The two blocks must stay the same. */
:root[data-theme="dark"] {
  --paper: #17140F; --paper-2: #221E18; --ink: #ECE5D8; --ink-2: #A99F90; --rubric: #E8868C; --rule: #3A332A;
  --good: #86C99A; --good-bg: #1A2A1F; --bad-bg: #2E1A1B; --field: #1D1914; --rubric-deep: #F0A0A5;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17140F; --paper-2: #221E18; --ink: #ECE5D8; --ink-2: #A99F90; --rubric: #E8868C; --rule: #3A332A;
    --good: #86C99A; --good-bg: #1A2A1F; --bad-bg: #2E1A1B; --field: #1D1914; --rubric-deep: #F0A0A5;
    color-scheme: dark;
  }
}

.intro { text-align: center; }
.home { margin: var(--space-3) 0 0; font-size: var(--text-small); letter-spacing: .08em; text-transform: uppercase; }
.home a { text-decoration: none; }
.lede { font-size: 1.1em; }
.center { text-align: center; }
.small { font-size: var(--text-small); color: var(--ink-2); hyphens: manual; }
.label { color: var(--ink-2); font-variant-caps: all-small-caps; letter-spacing: .08em; }
h4 { margin: var(--space-2) 0 var(--space-1); font-size: 1em; color: var(--ink); }
#view { min-height: 40vh; }
#view:focus { outline: none; }

/* EB Garamond prints u as v in text tagged as Latin. Doctrina never tags its Latin, and switches
   the feature off as well, so u stays u. */
.doctrina, .doctrina input, .doctrina button { font-feature-settings: "locl" 0; }
.marked, .notes, .paradigm table, .chips { hyphens: none; }

/* ── tabs ─────────────────────────────────────── */
.tabs {
  display: flex; justify-content: center; gap: var(--space-1) var(--space-2); flex-wrap: wrap;
  margin: var(--space-2) 0 var(--space-3); padding: var(--space-1) 0;
  border-block: 1px solid var(--rule);
  font-variant-caps: all-small-caps; letter-spacing: .08em;
}
.tabs[hidden] { display: none; }
.tabs a { display: inline-block; padding: .6rem .25rem; text-decoration: none; color: var(--ink-2); }
.tabs a[aria-current="page"] { color: var(--rubric); border-bottom: 2px solid var(--rubric); }

/* ── buttons and forms ────────────────────────── */
button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: var(--text-small); color: var(--ink); text-decoration: none;
  min-height: 3rem; padding: 0 var(--space-2);
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius);
  cursor: pointer;
}
button:hover, .button:hover { border-color: var(--ink-2); }
button.primary, .button.primary {
  min-width: 9rem; background: var(--rubric); border-color: var(--rubric); color: var(--paper);
  font-size: 1.05rem; letter-spacing: .08em; text-transform: uppercase;
}
button.primary:hover, .button.primary:hover { background: var(--rubric-deep); border-color: var(--rubric-deep); }
button.quiet { background: none; }
button:disabled { opacity: .6; cursor: progress; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }

.card {
  margin: var(--space-3) 0; padding: var(--space-2);
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius);
}
.card h2, .card h3 { margin-top: var(--space-1); }
.form { max-width: 26rem; margin-inline: auto; }
.form label { display: block; margin: var(--space-2) 0 .25rem; font-size: var(--text-small); color: var(--ink-2); }
input[type="text"], input[type="email"], input[type="password"] {
  display: block; width: 100%; min-height: 3rem; padding: 0 .75rem;
  font: inherit; font-size: max(1rem, 16px);      /* 16px or more: phones do not zoom on focus */
  color: var(--ink); background: var(--field);
  border: 1px solid var(--rule); border-radius: var(--radius);
}
input:focus-visible { outline: var(--focus); outline-offset: 1px; }
.form button.primary { width: 100%; margin-top: var(--space-2); }
.form label.agree { display: flex; align-items: flex-start; gap: .55rem; line-height: 1.4; cursor: pointer; }
.form label.agree input { flex: none; width: 1.05rem; height: 1.05rem; margin: .15rem 0 0; accent-color: var(--ink); }
.form .switch { text-align: center; margin: var(--space-2) 0 0; }
.msg { min-height: 1.5em; margin: var(--space-1) 0 0; color: var(--ink-2); font-size: var(--text-small); text-align: center; }
.msg.error { color: var(--rubric); }

/* ── chapters ─────────────────────────────────── */
.crumb { margin: 0; text-align: center; font-size: var(--text-small); letter-spacing: .08em; text-transform: uppercase; }
.crumb a { text-decoration: none; }
h2 .sub { font-size: .8em; text-transform: none; letter-spacing: .02em; color: var(--ink); font-weight: 400; font-style: italic; }
.chapters { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.chapter {
  display: grid; grid-template-columns: 3.2rem 1fr; column-gap: var(--space-1); align-items: baseline;
  padding: .7rem .25rem; min-height: 3rem; border-bottom: 1px solid var(--rule);
  color: var(--ink); text-decoration: none;
}
.chapter:hover { background: var(--paper-2); }
.chapter .num { grid-row: span 2; color: var(--rubric); font-size: var(--numeral); text-align: center; font-variant-numeric: lining-nums; }
.chapter .name { font-size: 1.1em; }
.chapter .line { font-size: var(--text-small); color: var(--ink-2); }
.chapter[data-state="done"] .line { color: var(--good); }
.chapter[data-state="review"] .line { color: var(--rubric); }

.topics { list-style: none; margin: 0 0 var(--space-3); padding: 0; border-top: 1px solid var(--rule); }
.topics li { padding: .75rem 0; border-bottom: 1px solid var(--rule); }
.topics p { margin: .2rem 0 .4rem; hyphens: manual; }
.topic-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem var(--space-2); }
.mini { font-size: var(--text-small); display: inline-block; padding: .5rem 0; }
.tag { font-size: var(--text-small); font-variant-caps: all-small-caps; letter-spacing: .1em; color: var(--ink-2); white-space: nowrap; }
.tag[data-status="passed"] { color: var(--good); }
.tag[data-status="needs_practice"] { color: var(--rubric); }
.tag[data-status="in_progress"] { color: var(--ink); }

/* ── the drill ────────────────────────────────── */
.passage { list-style: none; margin: var(--space-3) 0; padding: 0; counter-reset: s; }
.sentence { counter-increment: s; position: relative; padding: var(--space-2) 0 var(--space-2) 2rem; border-top: 1px solid var(--rule); }
.sentence::before { content: counter(s) "."; position: absolute; left: 0; top: var(--space-2); color: var(--rubric); font-variant-numeric: lining-nums; }
.sentence.todo { color: var(--ink-2); }
.sentence.current { background: linear-gradient(var(--paper-2), var(--paper-2)) no-repeat 0 0 / 3px 100%; padding-left: 2rem; }
.sentence.current::before { left: .75rem; }
.english { margin: 0 0 var(--space-1); font-size: 1.15em; hyphens: manual; }
button.word {
  display: inline; min-height: 0; padding: .35em 0; margin: -.35em 0;
  font-size: inherit; background: none; border: 0; border-radius: 2px; color: inherit;
  text-decoration: underline dotted var(--ink-2); text-underline-offset: .22em;
}
button.word:hover { color: var(--rubric); }
.hint { margin: 0 0 var(--space-1); }
.tip { margin: var(--space-1) 0 0; }
.answer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin-top: var(--space-1); }
.answer-bar .count { margin-inline-end: auto; color: var(--ink-2); font-size: var(--text-small); font-variant-numeric: lining-nums tabular-nums; }
.answer .msg { text-align: left; }

/* red for what was wrong, green for what replaces it */
del.wrong { color: var(--rubric); text-decoration: line-through; text-decoration-thickness: .08em; }
ins.fix { color: var(--good); text-decoration: none; font-weight: 600; }

.feedback { margin-top: var(--space-1); padding: .6rem .75rem; border-left: 3px solid var(--rule); background: var(--paper-2); border-radius: 0 var(--radius) var(--radius) 0; }
.feedback[data-verdict="correct"] { border-left-color: var(--good); background: var(--good-bg); }
.feedback[data-verdict="incorrect"], .feedback[data-verdict="skipped"] { border-left-color: var(--rubric); background: var(--bad-bg); }
.feedback p { margin: 0 0 .35rem; hyphens: manual; }
.verdict { font-variant-caps: all-small-caps; letter-spacing: .12em; color: var(--ink-2); }
.feedback[data-verdict="correct"] .verdict { color: var(--good); }
.marked { font-size: 1.15em; }
.notes { list-style: none; margin: .25rem 0 .5rem; padding: 0; }
.notes li { margin-bottom: .2rem; }
.kind { color: var(--ink-2); font-size: var(--text-small); }
.explain { margin: .4rem 0 0; color: var(--ink); }
.explain:empty { display: none; }
.feedback button.quiet { min-height: 2.75rem; }

.paradigm { margin: .6rem 0; }
.paradigm figcaption { font-size: var(--text-small); color: var(--ink-2); margin-bottom: .25rem; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.paradigm table { border-collapse: collapse; background: var(--field); font-size: var(--text-small); font-variant-numeric: lining-nums; }
.paradigm th, .paradigm td { padding: .3rem .6rem; border: 1px solid var(--rule); text-align: left; white-space: nowrap; }
.paradigm th { font-weight: 400; color: var(--ink-2); background: var(--paper-2); }
.paradigm td.hit { background: var(--good-bg); color: var(--good); }

.changes { list-style: none; margin: var(--space-2) 0; padding: 0; text-align: center; }
.done h3 { color: var(--good); }
.done ul { margin: 0; padding-left: 1.2em; }

/* ── what you miss ────────────────────────────── */
.bars, .forms { list-style: none; margin: 0 0 var(--space-3); padding: 0; border-top: 1px solid var(--rule); }
.bars li { display: grid; grid-template-columns: 9rem 1fr 5.5rem; align-items: center; gap: var(--space-1); padding: .6rem 0; border-bottom: 1px solid var(--rule); }
.bars meter { width: 100%; height: .7rem; accent-color: var(--rubric); }
.bar-count { color: var(--ink-2); font-size: var(--text-small); text-align: end; font-variant-numeric: lining-nums; }
.forms li { display: flex; align-items: baseline; gap: .5rem; padding: .6rem 0; border-bottom: 1px solid var(--rule); font-size: 1.1em; }
.forms .bar-count { margin-inline-start: auto; }

.site-footer { margin-top: var(--space-4); padding-block: var(--space-2) var(--space-3); border-top: 1px solid var(--rule); text-align: center; color: var(--ink-2); font-size: var(--text-small); }

@media (max-width: 30em) {
  .tabs { gap: 0 .9rem; letter-spacing: .04em; }
  .bars li { grid-template-columns: 7rem 1fr 4.5rem; }
  .sentence { padding-left: 1.5rem; }
  .sentence.current { padding-left: 1.75rem; }
  .sentence.current::before { left: .5rem; }
  .answer-bar button.primary { flex: 1 1 8rem; }
}

/* the bars count mistakes, so they are red */
.bars meter { appearance: none; -webkit-appearance: none; background: var(--paper-2); border-radius: 999px; overflow: hidden; }
.bars meter::-webkit-meter-bar { background: var(--paper-2); border: 0; border-radius: 999px; height: .7rem; }
.bars meter::-webkit-meter-optimum-value { background: var(--rubric); border-radius: 999px; }
.bars meter::-moz-meter-bar { background: var(--rubric); border-radius: 999px; }

/* ── signed in: the page gets out of the way ──── */
body.in .lede { display: none; }
body.in .intro h1 { font-size: 1.35rem; margin: .4rem 0 0; letter-spacing: .14em; }
body.in .home { margin-top: var(--space-2); }
body.in .tabs { margin: var(--space-1) 0 var(--space-2); padding: 0; border-top: 0; }
.crumb { color: var(--ink-2); }
.passage { margin-top: var(--space-2); }
.sentence { padding-block: .9rem; }
.sentence::before { top: .9rem; }

/* word suggestions under the answer box */
.chips { display: flex; gap: .4rem; overflow-x: auto; margin-top: .4rem; min-height: 2.4rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
button.chip { flex: none; min-height: 2.4rem; padding: 0 .8rem; background: var(--field); font-size: 1rem; border-radius: 999px; }
button.chip:first-child { border-color: var(--ink-2); }
.answer-bar { margin-top: .4rem; }
.answer-bar button.primary { min-width: 7rem; }
.answer .msg:empty { display: none; }

/* feedback: one tinted line, details on demand */
.feedback { padding: .45rem .7rem; }
.feedback .verdict { float: right; margin-left: .75rem; font-size: var(--text-small); }
.feedback .marked { margin: 0; }
.feedback[data-verdict="pending"] { border-left-color: var(--rule); background: none; color: var(--ink-2); }
.notes { margin: .35rem 0 .25rem; font-size: var(--text-small); }
button.link { min-height: 2.25rem; padding: 0; background: none; border: 0; color: var(--rubric); text-decoration: underline; text-underline-offset: .18em; }
details.paradigm { margin: .25rem 0; }
details.paradigm summary { cursor: pointer; padding: .35rem 0; font-size: var(--text-small); color: var(--ink-2); }
details.paradigm[open] summary { margin-bottom: .25rem; }
.changes { font-size: var(--text-small); color: var(--ink-2); }
.button.quiet { background: none; }
.feedback[data-verdict="pending"] .verdict, .feedback[data-verdict="unchecked"] .verdict { color: var(--ink-2); }
.feedback[data-verdict="unchecked"] { border-left-color: var(--rule); background: var(--paper-2); }
.again { font-size: var(--text-small); font-variant-caps: all-small-caps; letter-spacing: .1em; color: var(--rubric); }

/* ── Latin text ───────────────────────────────── */
.marked, del.wrong, ins.fix, .paradigm td, #answer, .chips button, .chapter .name, h2 .sub {
  font-family: var(--latin); font-weight: 400; font-style: normal; font-synthesis: none;
}
.marked { font-size: 1.05em; }
.paradigm td strong { font-weight: 400; }
#answer { font-size: max(1rem, 16px); }

/* room for the longest numeral (XXXVIII) before the chapter title */
.chapter { grid-template-columns: 5rem 1fr; column-gap: .9rem; padding-inline: .5rem; }
.chapter .num { font-size: 1.05rem; text-align: end; white-space: nowrap; }

/* ── the drill: a page of a critical edition ─────────────────────
   The sentence is the text, in one fixed column. A count sits in the margin. Corrections are the
   apparatus at the foot. No boxes, rules or buttons; colour is kept for corrections alone. */
body.drilling .intro, body.drilling .tabs, body.drilling .site-footer { display: none; }
body.drilling main { max-width: calc(37.5rem + 2 * var(--gutter) + 6rem); min-height: 100svh; display: flex; flex-direction: column; }
body.drilling #view { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; padding-inline: clamp(0rem, 4vw, 3rem); }
.text-block, .answer, .chips { min-width: 0; }

.running { display: flex; align-items: baseline; justify-content: space-between; padding-top: .75rem; }
.running .close { width: 2.75rem; height: 2.75rem; margin-left: -.9rem; display: grid; place-items: center; font-size: 1.4rem; line-height: 1; color: var(--ink-2); text-decoration: none; }
.running .close:hover { color: var(--ink); }
.running .head { font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); text-align: right; }
.numeral { margin: clamp(1.5rem, 9vh, 5rem) 0 1.1rem; font-size: .95rem; letter-spacing: .14em; color: var(--ink); font-variant-numeric: lining-nums; }

.text-block { position: relative; min-height: 11rem; padding-right: 3.2rem; }
.margin { position: absolute; right: 0; top: .55rem; font-size: .75rem; letter-spacing: .06em; color: var(--ink-2); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.prompt { margin: 0 0 .5rem; text-align: left; font-size: clamp(1.3rem, 4.6vw, 1.6rem); line-height: 1.35; hyphens: manual; }
.again { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); font-variant-caps: normal; }

/* the Latin line: the largest thing on the page, typed or corrected in the same place */
.answer .line { display: flex; align-items: baseline; border: 0; border-bottom: 1px solid var(--rule); }
.answer .line:focus-within { border-bottom-color: var(--ink); }
.answer .line #answer, .text-block > .marked {
  font-family: var(--latin); font-size: clamp(1.45rem, 5.2vw, 1.85rem); line-height: 1.35; color: var(--ink);
}
.answer .line #answer { flex: 1; min-width: 0; min-height: 3rem; padding: 0; border: 0; border-radius: 0; background: none; text-align: left; }
.answer .line #answer:focus-visible { outline: none; }
.answer .line #answer::placeholder { color: var(--rule); }
.text-block > .marked { margin: 0; min-height: 3rem; padding-bottom: 1px; }
/* a right answer stays in ink; a small tick in the margin says so */
.margin .tick { color: var(--good); }
.chapter-title { margin-left: .9em; font-family: var(--latin); font-size: .95em; letter-spacing: .01em; color: var(--ink-2); }
button.go { min-height: 2.75rem; min-width: 2rem; padding: 0; background: none; border: 0; font-size: 1.1rem; color: var(--ink-2); }
button.go:disabled { opacity: .3; }
.chips { justify-content: flex-start; margin-top: .6rem; min-height: 2.2rem; }
button.chip { min-height: 2.2rem; padding: 0 .1rem; margin-right: .9rem; background: none; border: 0; border-radius: 0; font-size: 1.05rem; color: var(--ink-2); }
button.chip:first-child { color: var(--ink); border: 0; }
button.chip:hover { color: var(--ink); }
.under { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); min-height: 2rem; }
.under .msg { margin: 0; text-align: left; }
button.hint { margin-left: auto; color: var(--ink-2); font-size: .85rem; text-decoration: none; letter-spacing: .04em; }
button.hint:hover { color: var(--ink); }
.change { margin: 0 0 .25rem; font-size: var(--text-small); color: var(--ink-2); }

/* the apparatus: small, quiet notes at the foot, always in the same place */
.apparatus { min-height: 9.5rem; padding: 1rem 0 max(1.25rem, env(safe-area-inset-bottom)); font-size: .92rem; line-height: 1.45; color: var(--ink-2); hyphens: manual; }
.apparatus p { margin: 0 0 .35rem; }
.apparatus .notes { list-style: decimal inside; margin: 0 0 .35rem; padding: 0; font-size: inherit; }
.apparatus .notes li { margin: 0 0 .2rem; }
.apparatus .notes li::marker { color: var(--ink-2); font-variant-numeric: lining-nums; }
.apparatus .notes .marked { display: inline; font-size: 1em; }
.apparatus del.wrong, .apparatus ins.fix, .apparatus .la { font-size: 1.02em; }
.apparatus .la { font-family: var(--latin); color: var(--ink); }
.apparatus .lemma, .apparatus .bracket { color: var(--ink-2); }
.apparatus .lemma { font-style: italic; }
.apparatus button.link { min-height: 2rem; color: var(--ink-2); text-decoration: none; font-style: italic; font-size: inherit; }
.apparatus button.link:hover { color: var(--ink); }
.apparatus .explain { color: var(--ink); }
.apparatus .explain:empty { display: none; }
.apparatus details.paradigm summary { padding: .15rem 0; font-size: inherit; font-style: italic; list-style: none; }
.apparatus details.paradigm summary::-webkit-details-marker { display: none; }
.apparatus .turn { display: flex; align-items: baseline; justify-content: space-between; margin-top: .5rem; }
button.on { float: right; min-height: 2.75rem; padding: 0 0 0 1rem; background: none; border: 0; font-size: 1.05rem; color: var(--ink-2); letter-spacing: .04em; }
button.on:hover, button.on:focus-visible { color: var(--ink); }
button.on:focus-visible { outline: none; text-decoration: underline; text-underline-offset: .25em; }
.apparatus .turn button.on { float: none; }
.text-block .card.done { background: none; border: 0; padding: 0; margin-top: var(--space-2); }

/* the apparatus stays a line or two; "explain" opens the rest */
.apparatus { min-height: 7.5rem; display: flex; flex-direction: column; justify-content: flex-end; }
.apparatus > * { flex: none; }
.apparatus button.link { align-self: flex-start; }
.apparatus button.on { align-self: flex-end; margin-top: -2.75rem; float: none; }
.apparatus .turn button.on { margin-top: 0; }
.review-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .25rem; }
.apparatus .review-actions .on { flex: none; margin: 0 0 0 auto; }
.question-flag { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .6rem; }
.apparatus .question-flag button[aria-pressed="true"] { color: var(--rubric); }

/* ── three levels: the sentence, the line to type on, quiet metadata ── */
.running { display: grid; grid-template-columns: 2.75rem 1fr auto; align-items: center; gap: .5rem; padding-top: .5rem; }
.running .head { text-align: center; font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.running .count { min-width: 2.75rem; text-align: right; font-size: .8rem; letter-spacing: .06em; color: var(--ink-2); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.running .count .tick { color: var(--good); }
.context { margin: clamp(1.5rem, 9vh, 5rem) 0 .9rem; font-family: var(--latin); font-size: .9rem; color: var(--ink-2); min-height: 1.4em; }
.text-block { padding-right: 0; }
.prompt { font-size: clamp(1.45rem, 5vw, 1.85rem); margin-bottom: .9rem; color: var(--ink); }
.answer .line #answer, .text-block > .marked { font-size: clamp(1.35rem, 4.8vw, 1.7rem); }
button.go { font-size: 1rem; color: var(--rule); pointer-events: auto; }
.answer .line:focus-within button.go { color: var(--ink-2); }
button.chip.offer { font-family: var(--serif); font-style: italic; font-size: .9rem; color: var(--ink-2); }
.answer .msg { text-align: left; }

/* ── the pages around the drill: a table of contents, not a dashboard ───────── */
body.in .intro, body.in .site-footer .more { display: none; }
/* Terms and Privacy stay in reach under every page but the drill, in the quietest type on it. */
body.in .site-footer { border-top: 0; padding-block: var(--space-2); font-size: .8rem; letter-spacing: .04em; }
.site-footer .legal-links { margin: 0; }
.site-footer .legal-links a { color: var(--ink-2); text-decoration: none; }
.site-footer .legal-links a:hover { color: var(--ink); text-decoration: underline; }
body.in:not(.drilling) main { max-width: calc(56rem + 2 * var(--gutter)); }
.masthead { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); padding: 1.1rem 0 0; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; }
.masthead[hidden] { display: none; }
.masthead p { margin: 0; }
.masthead a { color: var(--ink-2); text-decoration: none; padding: .6rem 0; display: inline-block; }
.masthead a:hover, .masthead a[aria-current="page"] { color: var(--ink); }
.masthead .brand a + a::before { content: "/"; margin: 0 .6em; color: var(--rule); }
.masthead nav { display: flex; gap: 1.6rem; }

body.in #view h2, body.in #view h3, body.in #view h4 { color: var(--ink); text-align: left; text-transform: none; letter-spacing: 0; }
.overline { margin: clamp(1.25rem, 4vh, 2.25rem) 0 .2rem; font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-3); }
body.in #view h2.title { margin: 0; font-size: clamp(2rem, 6vw, 2.7rem); font-weight: 400; line-height: 1.1; }
h2.title.la { font-family: var(--latin); }
.title-row + .lead, .lead { color: var(--ink-2); margin: -1rem 0 var(--space-3); }
.continue { color: var(--rubric); text-decoration: none; font-size: 1.15rem; white-space: nowrap; padding: .5rem 0; }
.continue:hover { text-decoration: underline; text-underline-offset: .2em; }

.subjects, .contents { list-style: none; margin: 0 0 var(--space-4); padding: 0; border-top: 1px solid var(--rule); }
.contents { margin-top: var(--space-3); }
.subject { display: grid; grid-template-columns: 1fr auto; column-gap: var(--space-2); row-gap: .15rem; align-items: baseline; padding: 1.15rem .5rem 1.2rem; margin: 0 -.5rem; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.subject:hover, .entry:hover { background: var(--paper-2); }
.subject-name { font-size: clamp(1.3rem, 4vw, 1.65rem); font-weight: 600; line-height: 1.2; }
.subject-line { grid-column: 1 / -1; color: var(--ink-2); font-size: 1.1rem; hyphens: manual; }
.state { color: var(--ink-2); font-size: 1rem; white-space: nowrap; }
.entry { display: grid; grid-template-columns: 4.2rem 1fr auto; column-gap: .9rem; align-items: baseline; padding: .8rem .5rem; margin: 0 -.5rem; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; min-height: 3rem; }
.entry .num { text-align: right; color: var(--ink-2); font-variant-numeric: lining-nums; letter-spacing: .04em; }
.entry .name { font-family: var(--latin); font-size: 1.25rem; }
section.done { margin: 0 0 var(--space-4); }
section.done h3 { margin: 0 0 var(--space-1); font-size: 1.2rem; color: var(--ink); }
section.done h4 { color: var(--ink-2); font-weight: 400; font-size: 1rem; }
body.in #view > h2:not(.title) { margin: clamp(1.25rem, 4vh, 2.25rem) 0 var(--space-3); font-size: clamp(2rem, 6vw, 2.7rem); font-weight: 400; }
body.in #view > h3 { margin: var(--space-3) 0 var(--space-1); font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); font-weight: 400; }
body.in .card.form { background: none; border: 0; padding: 0; margin: 0; max-width: 26rem; margin-inline: 0; }
body.in .card.form h2 { margin: clamp(1.25rem, 4vh, 2.25rem) 0 var(--space-3); font-size: clamp(2rem, 6vw, 2.7rem); font-weight: 400; }
body.in .center { text-align: left; }
@media (max-width: 30em) {
  .masthead { font-size: .72rem; letter-spacing: .1em; }
  .masthead nav { gap: 1rem; }
  .entry { grid-template-columns: 3.4rem 1fr; }
  .entry .state { grid-column: 2; font-size: .9rem; }
}

body.drilling .masthead { display: none; }

/* ── statistics: the same plain lists ─────────── */
.lead.plain { margin: 0 0 var(--space-3); }
body.in .title + h3 { margin-top: var(--space-3); }
.bars { margin-bottom: var(--space-3); }
.bars li { grid-template-columns: minmax(8rem, 14rem) 1fr auto; padding: .8rem 0; }
.bar-label { font-size: 1.15rem; }
.bars meter { height: .35rem; }
.bars meter::-webkit-meter-bar { height: .35rem; background: var(--rule); }
.bars meter::-webkit-meter-optimum-value { background: var(--ink-2); }
.bars meter::-moz-meter-bar { background: var(--ink-2); }
.forms li { padding: .8rem 0; font-size: 1.2rem; gap: 0; }
.forms .bracket { color: var(--ink-2); white-space: pre; }
.forms .state { margin-left: auto; font-family: var(--serif); }
body.in .overline + h2.title { margin-bottom: var(--space-2); }
.masthead .brand { white-space: nowrap; }
@media (max-width: 30em) {
  /* no room for both names on a phone: Doctrina stays, and leads back to the chapters */
  .masthead .brand a:first-child { display: none; }
  .masthead .brand a + a::before { content: none; }
  .bars li { grid-template-columns: minmax(6.5rem, 9rem) 1fr auto; }
}

/* told plainly when right; the offer of the next word always in reach */
.apparatus .right { color: var(--good); letter-spacing: .02em; }
.under { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); min-height: 2rem; }
button.hint { margin-left: auto; min-height: 2.25rem; color: var(--ink-2); font-size: .9rem; font-style: italic; text-decoration: none; }
button.hint:hover { color: var(--ink); }

/* ── the way in: languages, the trail back up, the filter ─────────── */
.masthead nav { align-items: baseline; }
.masthead button.plain { min-height: 0; padding: .6rem 0; background: none; border: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--ink-2); }
.masthead button.plain:hover { color: var(--ink); }
.crumbs a { color: var(--ink-2); text-decoration: none; padding: .5rem 0; display: inline-block; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: .25em; }
.crumbs .sep { color: var(--rule); }
.languages h3 { margin-top: var(--space-3); }
.languages .contents { margin: var(--space-1) 0 var(--space-3); }
.entry.course { grid-template-columns: 1fr auto; }
.entry.course .name { font-family: var(--serif); font-size: clamp(1.3rem, 4vw, 1.65rem); }

.title-row .find {
  flex: 0 1 17rem; min-width: 11rem; min-height: 2.75rem; padding: 0; font: inherit; font-size: max(1rem, 16px); color: var(--ink);
  background: none; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; appearance: none; -webkit-appearance: none;
}
.title-row .find::placeholder { color: var(--ink-2); font-style: italic; }
.title-row .find:focus-visible { outline: none; border-bottom-color: var(--ink); }
.title-row:has(.find) { margin-bottom: 0; align-items: flex-end; }

/* the topics inside a chapter, under its line: each one opens its drill */
.contents li { border-bottom: 1px solid var(--rule); }
.contents .entry { border-bottom: 0; }
.contents li:has(.inside) .entry { padding-bottom: .15rem; min-height: 0; }
.inside { margin: 0 0 .85rem; padding-left: 5.1rem; font-size: 1rem; line-height: 1.7; color: var(--ink-2); hyphens: manual; }
.inside a { color: var(--ink-2); text-decoration: none; padding: .3rem 0; }
.inside a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: .2em; }
.inside a[data-status="passed"] { color: var(--good); }
.inside a[data-status="needs_practice"] { color: var(--rubric); }
.inside .sep { color: var(--ink-2); opacity: .6; }

.around { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--space-2); align-items: baseline; margin: 0 0 var(--space-4); font-size: 1rem; }
.around a { color: var(--ink-2); text-decoration: none; padding: .6rem 0; }
.around a:hover { color: var(--ink); }
.around > :last-child { text-align: right; }
.around .la { font-family: var(--latin); }

/* ── a passage being written ──────────────────── */
.writing .bar { position: relative; height: 1px; margin: 1.6rem 0 1.1rem; background: var(--rule); overflow: hidden; }
.writing .bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 28%; background: var(--ink); animation: writing 1.8s ease-in-out infinite; }
@keyframes writing { from { transform: translateX(-100%); } to { transform: translateX(460%); } }
@media (prefers-reduced-motion: reduce) { .writing .bar::after { animation: none; width: 100%; background: var(--ink-2); } }
.writing .wait { margin: 0; color: var(--ink-2); font-size: 1rem; hyphens: manual; }
.writing .clock { white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; color: var(--ink); }

/* the full explanation, in place of the notes: for each correction the change, the reason, a one-row table */
.apparatus .explain p { margin: .35rem 0 0; color: var(--ink); font-size: 1rem; line-height: 1.5; }
.apparatus .explain .fixed + .fixed { margin-top: 1rem; }
.apparatus .explain .change { margin: 0; font-size: 1.05rem; }
.apparatus .explain .paradigm { margin: .6rem 0 0; }
.apparatus .explain .paradigm figcaption { font-style: italic; }
.paradigm th.la { font-family: var(--latin); color: var(--ink); }

@media (max-width: 30em) {
  .inside { padding-left: 4.3rem; }
  .title-row .find { flex-basis: 100%; }
  .around { grid-template-columns: 1fr 1fr; }
  .around > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; text-align: center; }
}
/* with the explanation open, the way on sits under it and not over its last line */
.apparatus .explain:not(:empty) ~ button.on { margin-top: .25rem; }

/* a small heading with one action beside it (Statistics: Forms you miss most, Practise) */
.title-row.minor { margin: var(--space-3) 0 var(--space-1); align-items: baseline; }
body.in #view .title-row.minor h3 { margin: 0; font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); font-weight: 400; }
.title-row.minor .continue { font-size: 1rem; }

/* ── the experiment: long-vowel keys and the helper bar under the typing line ── */
/* A word of the sentence with the dictionary form of its Latin or Greek word under it, set as the
   reader sets a helped word. The column is as wide as its widest line and is there from the start,
   so the sentence keeps its spacing when the helper bar shows the form. */
.prompt .w { display: inline-flex; flex-direction: column; align-items: center; vertical-align: baseline; line-height: 1.15; }
.prompt .w .e { display: block; margin: .1em 0 .2em; font-family: var(--latin); font-size: .62em; line-height: 1.2; color: var(--rubric); white-space: nowrap; visibility: hidden; }
.prompt .w.on .e { visibility: visible; }
.prompt .extra .o { color: var(--ink-2); visibility: hidden; }
.prompt .extra .w.on .o { visibility: visible; }
/* A variation: the sentence it varies stands above it, small; the changed words are marked. */
.base { margin: 0 0 .5rem; font-size: .95rem; line-height: 1.35; color: var(--ink-2); text-align: left; hyphens: none; }
.base .la { font-family: var(--latin); font-style: italic; }
.base .la::before { content: "· "; font-style: normal; }
.prompt mark.changed { background: none; color: var(--rubric); }
/* The formula: the topic's rule in one line, close under the typing line, in the size of its button. */
.under { min-height: 1.6rem; margin-top: .15rem; }
.under .left { flex: 1; min-width: 0; text-align: left; }
.under button.hint { min-height: 0; line-height: 1.4; }
.formula { margin: 0; font-family: var(--latin); font-size: .9rem; line-height: 1.4; color: var(--ink-2); text-align: left; hyphens: none; }
.formula .arrow { color: var(--rubric); }
.formula .then { color: var(--ink); }
/* Vertical spacing of the drill. The room left on the screen is shared out: one part above the
   sentence, two parts below the keyboard, so the sentence is never pressed against the top bar and
   the page does not scroll. While a sentence is being typed the foot is empty and takes no room. */
body.drilling #view { grid-template-rows: auto minmax(1.5rem, 1fr) auto minmax(0, 2fr); }
.context { margin: 0; min-height: 0; max-height: 9rem; }
.text-block { min-height: 0; }
.apparatus { align-self: end; }
.apparatus:empty { min-height: 0; padding: 0; }
/* The suggestions share their row with the keyboard's own switch, which brings the keys up to the line. */
.answer .chips { margin-top: 0; min-height: 1.9rem; padding-right: 3rem; }
.answer .tools { margin-top: -1.9rem; }
.source { margin: .6rem 0 0; font-size: .8rem; line-height: 1.35; color: var(--ink-2); text-align: left; }
.formula.change { margin: 0 0 .35rem; font-size: .9rem; }
.formula .then { color: var(--ink); }
.tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; margin-top: 1.1rem; }
/* The Stobaeus keyboard under the typing line: its keys and switches, in Doctrina's colours. */
.kb { flex: 1 1 100%; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.kb-in { max-width: 620px; margin: 0 auto; }
.kb.hidden .kb-in { display: none; }
.kb .kbtoggle { display: flex; margin: 0 0 2px auto; padding: 6px 8px; min-height: 0; border: 0; border-radius: 7px; background: none; color: var(--ink-2); cursor: pointer; }
.kb .kbtoggle:hover { color: var(--ink); }
.kb .kbtoggle[aria-pressed="false"] { opacity: .55; }
.kb .kbtoggle svg { width: 19px; height: 13px; display: block; }
/* Room between the suggestions and the first row of keys. */
.kb-in { padding-top: 1.1rem; }
/* The row stops short of the keyboard switch (a margin, not padding, so a long row scrolls instead of running under it). */
.answer .chips { counter-reset: chip; padding-right: 0; margin-right: 3rem;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent); }
/* With a real keyboard, 1 to 9 picks a suggestion; each shows its number, faintly. */
@media (hover: hover) and (pointer: fine) {
  .answer button.chip::before { counter-increment: chip; content: counter(chip); margin-right: .3rem; font-size: .7rem; vertical-align: .3em; color: var(--ink-2); opacity: .6; }
}
.kb .row { display: flex; justify-content: center; gap: 4px; margin-top: 4px; }
.kb .k {
  position: relative; flex: 1 1 0; max-width: 52px; height: 40px; min-width: 0; min-height: 0; padding: 0;
  border: 0; border-radius: 9px; background: var(--paper-2); color: var(--ink); cursor: pointer;
  font-family: var(--latin); font-size: 19px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background .08s, opacity .12s;
}
.kb .k:active { background: var(--rule); }
.kb .k .lat { position: absolute; top: 4px; left: 6px; font-family: system-ui, sans-serif; font-size: 9px; color: var(--ink-2); }
.kb .k .hk { font-family: system-ui, sans-serif; font-size: 9.5px; color: var(--ink-2); line-height: 1; }
.kb .k.dim { opacity: .28; cursor: default; }
.kb .k.wide { max-width: 78px; flex-grow: 1.5; font-size: 14px; }
.kb .k.space { max-width: 276px; flex-grow: 5; font-family: var(--serif); font-size: 12px; color: var(--ink-2); }
.kb .k.on { background: var(--ink); color: var(--paper); }
.kb .k.on .lat, .kb .k.on .hk { color: inherit; opacity: .6; }
.kb .dia .k { height: 38px; font-size: 22px; flex-direction: column; gap: 2px; }
.kb .dia .k > span:first-child { line-height: .8; height: .55em; }
.kb .dia .gap { flex: 0 0 8px; }
/* the iota subscript and the dot below hang under the baseline; lift them clear of the key hint */
@media (hover: hover) {
  .kb .dia .k[data-mark="\345"] > span:first-child { transform: translateY(-.85em); }
  .kb .dia .k[data-mark="\323"] > span:first-child { transform: translateY(-.42em); }
}
@media (hover: none) { .kb .k .hk { display: none; } }
@media (max-width: 640px) {
  .kb .k { height: 44px; font-size: 20px; border-radius: 7px; }
  .kb .k .lat { top: 3px; left: 4px; }
  .kb .dia .k { height: 40px; font-size: 22px; }
  .kb .dia .gap { flex-basis: 3px; }
}
/* day and night: an icon in the keyboard's line style */
.masthead button#theme { display: inline-flex; align-items: center; }
#theme svg { width: 16px; height: 16px; display: block; position: relative; top: 3px; }
.helper { flex: 1 1 14rem; display: grid; grid-template-columns: auto minmax(6rem, 1fr) 6ch; align-items: center; gap: .75rem; max-width: 22rem; margin-left: auto; font-size: .85rem; font-style: italic; color: var(--ink-2); }
.helper input[type=range] { width: 100%; height: 2.5rem; margin: 0; accent-color: var(--ink-2); cursor: pointer; }
.helper output { text-align: end; font-style: normal; font-variant-numeric: lining-nums tabular-nums; }

/* ── trial, account and subscription ── */
.contents li.locked .entry .name, .contents li.locked .inside a { color: var(--ink-2); }
.contents li.locked .entry a.name { text-decoration: none; }
.contents li.locked .entry a.name:hover { color: var(--ink); }
.contents li.locked a.state { font-style: italic; color: var(--rubric); text-decoration: none; padding: .4rem 0; margin: -.4rem 0; }
.contents li.locked a.state:hover { text-decoration: underline; text-underline-offset: .2em; }
.locked-note { margin: 0 0 var(--space-3); padding: 1.1rem 1.25rem 1.25rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper-2); max-width: 30rem; }
.locked-note p { margin: 0 0 .9rem; }
.locked-note p:last-child { margin-bottom: 0; }
.locked-note .msg:empty { display: none; }
/* the one step that opens the chapters: a compact button with "or sign in" on its centre line */
.unlock-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem; }
.unlock-actions button.primary, .unlock-actions .button.primary { width: auto; min-width: 0; min-height: 2.6rem; margin: 0; padding: 0 1.25rem; font-size: .9rem; letter-spacing: .1em; }
.unlock-actions .or { margin: 0; }
.unlock-actions .or a { text-underline-offset: .18em; }
div.subject { cursor: default; }
/* the line of introduction a visitor sees under "Choose a language" */
body.in #view h2.title + .lead.plain { margin: .9rem 0 2.25rem; max-width: 40rem; font-size: 1.1rem; line-height: 1.5; }

/* ── the account page: three panels (subscription, password, delete) and Sign out ── */
.account { max-width: 30rem; margin-bottom: var(--space-4); }
body.in #view .account h2.title { margin: clamp(1.25rem, 4vh, 2.25rem) 0 var(--space-2); }
.account .who { margin: 0 0 var(--space-3); overflow-wrap: anywhere; }
.account p, .account li { hyphens: manual; }
.panel { margin: 0 0 var(--space-2); border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); }
.panel .icon { display: inline-flex; flex: none; color: var(--ink); }
.panel-head { display: flex; align-items: center; gap: .75rem; margin: 0 1.25rem; padding: 1.1rem 0 1rem; border-bottom: 1px solid var(--rule); }
body.in #view .panel h3, .fold-title { margin: 0; font-size: 1.3rem; font-weight: 500; line-height: 1.2; color: var(--ink); }
.badge { margin-left: auto; padding: .2rem .7rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper-2); font-size: .85rem; color: var(--ink-2); white-space: nowrap; }
.panel-body { padding: 1rem 1.25rem 1.25rem; }
.panel-body p { margin: 0 0 .75rem; }
.panel-body > :last-child, .panel-body form > :last-child { margin-bottom: 0; }
.panel .standing { margin: 0; font-size: 1.15rem; }
.panel .sub { margin: .1rem 0 0; color: var(--ink-2); font-size: 1rem; }
.panel .standing ~ button, .panel .sub + button { margin-top: 1rem; }
.account .wide { width: 100%; min-height: 3rem; }
.account .wide .icon { margin-left: .6rem; color: inherit; }
.account .wide .icon svg { width: 1.1em; height: 1.1em; }
.account button.primary.wide { text-transform: none; letter-spacing: .02em; font-size: 1.1rem; }
.account .unlock-actions .primary { width: 100%; min-height: 3rem; }
.panel .msg { text-align: left; }
.panel .msg:empty { display: none; }
/* a panel that opens */
details.panel summary { display: grid; grid-template-columns: auto 1fr auto; column-gap: .75rem; row-gap: .15rem; align-items: center; min-height: 2.75rem; padding: 1.1rem 1.25rem; cursor: pointer; list-style: none; border-radius: 10px; }
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary .sub { grid-column: 1 / 3; grid-row: 2; margin: 0; }
details.panel summary .icon-chevron { grid-column: 3; grid-row: 1 / 3; color: var(--ink-2); transition: transform .15s; }
details.panel[open] summary .icon-chevron { transform: rotate(90deg); }
details.panel summary:hover { background: var(--paper-2); }
details.panel summary:focus-visible { outline: var(--focus); outline-offset: 2px; }
details.panel[open] summary { border-bottom: 1px solid var(--rule); border-radius: 10px 10px 0 0; }
.panel label { display: block; margin: var(--space-2) 0 .25rem; font-size: var(--text-small); color: var(--ink-2); }
.panel form > label:first-child { margin-top: 0; }
.panel form button { margin-top: var(--space-2); }
.panel .confirm ul { margin: 0 0 var(--space-2); padding-left: 1.2em; }
.panel .confirm li { margin-bottom: .3em; }
button.danger { background: var(--rubric); border-color: var(--rubric); color: var(--paper); font-size: 1.05rem; letter-spacing: .02em; }
button.danger:hover { background: var(--rubric-deep); border-color: var(--rubric-deep); }
.account > button.wide { margin-top: var(--space-2); font-size: 1.1rem; }
@media (prefers-reduced-motion: reduce) { details.panel summary .icon-chevron { transition: none; } }

/* ── Terms and Privacy (doctrina/terms, doctrina/privacy): plain reading pages ───────── */
.legal { padding-bottom: var(--space-3); }
.legal .home { margin-bottom: var(--space-3); color: var(--ink-2); }
.legal h1, .legal h2, .legal h3 { text-align: left; text-transform: none; letter-spacing: 0; color: var(--ink); }
.legal h1 { margin: 0 0 var(--space-1); font-size: clamp(2rem, 6vw, 2.7rem); font-weight: 400; line-height: 1.1; }
.legal h1 + .small { margin: 0 0 var(--space-3); }
.legal h2 { margin: var(--space-4) 0 var(--space-1); font-size: 1.45rem; font-weight: 500; }
.legal h3 { margin: var(--space-3) 0 .25rem; font-size: 1.1rem; font-weight: 600; }
.legal p, .legal ul { margin: 0 0 var(--space-2); }
.legal ul { padding-left: 1.25rem; }
.legal li { margin-bottom: .35rem; }
/* The suggestion row keeps one height, empty or full, so the keyboard below never moves as words appear. */
.answer .chips { height: 1.9rem; min-height: 0; align-items: center; overflow-y: hidden; }
.answer button.chip { height: 1.9rem; min-height: 0; line-height: 1; }
