/* Proofreading site: the reader's page. Phone first: one reading column with a 16 px gutter,
   a sticky bar with the chapter and the reader's place, tap targets of at least 44 px.
   Colours are tokens with a dark set chosen by prefers-color-scheme.
   Fonts come from web/languages.json: web/core/languages.js registers each language's font files and
   adds a rule per language that sets --f-book (the book's text) and --f-ui (the interface), as
   :lang(th) { --f-book: "Sarabun", ...; }. Until then, and for a language the registry lacks, both
   are the system fonts below. Sarabun is self-hosted (SIL Open Font License, fonts/OFL.txt). */

:root {
  color-scheme: light;
  --paper: #f5f7f5; --surface: #ffffff; --ink: #1b2321; --ink-2: #33403c; --muted: #5d6965;
  --rule: #d9e0dc; --hover: #ecf0ed; --field-rule: #7f8b86;
  --accent: #1b5a84; --accent-ink: #ffffff;
  --flag: #9a4f0c; --flag-bg: #fbecd9; --mine: #1b5a84; --mine-bg: #e1edf6;
  --done: #276f45; --done-bg: #dff1e6; --done-ink: #ffffff; --hl: #fff0b8;
  --q1: #e3ecf4; --q2: #c4d7e8; --pk: #ffd66b;   /* words one comment quotes, two or more, and the words picked now */
  --q1-line: #6993b7; --q2-line: var(--mine);   /* the thin line under words one comment quotes, at least 3 to 1 against the page, and two or more */
  --bad: #b3261e; --bad-bg: #fbe4e2;
  --line: #05803a; --line-ink: #ffffff;   /* "Continue with LINE": LINE's green, dark enough for white text */
  --f-book: system-ui, -apple-system, "Segoe UI", sans-serif;   /* the book's text */
  --f-en: Georgia, "Times New Roman", serif;
  --f-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: 16px;
  --column: 40rem;
  --bar-h: 56px;
  --ts: 1;            /* the text size of A- and A+ (core/screens.js), a part of the usual size */
  --panel-w: 0px;     /* the width of the panel's column at the right, where the panel is a column */
  --side-gap: 24px;   /* between a paragraph and its English beside it */
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #131917; --surface: #1a2220; --ink: #e4eae7; --ink-2: #c3ccc8; --muted: #95a29d;
    --rule: #2b3532; --hover: #1d2624; --field-rule: #6a7773;
    --accent: #7db3dc; --accent-ink: #0d1a24;
    --flag: #eea456; --flag-bg: #3a2a18; --mine: #7db3dc; --mine-bg: #1b2d3b;
    --done: #6cc08b; --done-bg: #183026; --done-ink: #0d1f15; --hl: #4a4220;
    --q1: #1f2d38; --q2: #2c4458; --pk: #6b5a1c;
    --q1-line: #4c6f8d; --q2-line: var(--mine);
    --bad: #f2a29b; --bad-bg: #3d1d1a;
    --line: #05803a; --line-ink: #ffffff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--f-ui); font-size: 16px; line-height: 1.5;
  overflow-wrap: break-word;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.page {
  max-width: calc(var(--column) + 2 * var(--gutter)); margin: 0 auto;
  padding: 0 max(var(--gutter), env(safe-area-inset-right, 0px)) 72px max(var(--gutter), env(safe-area-inset-left, 0px));
}

/* ---- the layout of a chapter beside the panel (core/panel.js) ----
   On a screen wider than it is tall and at least 640 pixels wide, and on any window at least 900 pixels wide
   (html.panel-side), the panel is a column at the right, --panel-w wide: the width the reader dragged its border to,
   or 28rem, at most 44 percent of the window, which core/column.js works out and core/panel.js sets as --panel-px.
   --page-w is the page's width: one reading column, or with the English beside each paragraph (body.beside, at
   least 1200 pixels wide) two. In a chapter the page keeps free at the right only the room (--room) the column would
   otherwise cover, whether the panel is open or not: none when the page, in the middle of the window, ends left of
   the column, so the text stands in the middle as on the chapter list; otherwise just enough that the page ends
   where the column begins, and at most the column's width. So the text never moves when the panel opens or closes,
   and never stands under the column. */
html.panel-side { --panel-w: var(--panel-px, min(28rem, 44vw)); }
body { --page-w: calc(var(--column) + 2 * var(--gutter)); }
body.beside { --page-w: calc(2 * var(--column) + var(--side-gap) + 2 * var(--gutter)); }
html.panel-side body.reading {
  --room: max(0px, min(var(--panel-w), calc(var(--page-w) + 2 * var(--panel-w) - 100%)));
  padding-right: var(--room);
}
body.beside .page, body.beside .bar-row { max-width: var(--page-w); }
html:not(.wide) .wide-only { display: none; }

/* ---- bar ---- */
.bar {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 5;   /* Safari before 13 knows only -webkit-sticky */
  background: var(--paper); border-bottom: 1px solid var(--rule);
  padding-top: env(safe-area-inset-top, 0px);
}
.bar-row {
  display: flex; align-items: center; gap: 8px; min-height: var(--bar-h);
  max-width: calc(var(--column) + 2 * var(--gutter)); margin: 0 auto;
  padding: 0 max(var(--gutter), env(safe-area-inset-right, 0px)) 0 max(var(--gutter), env(safe-area-inset-left, 0px));
}
.back {
  display: inline-flex; align-items: center; min-height: 44px; min-width: 44px;
  margin-left: -8px; padding: 0 8px; border: 0; border-radius: 8px; background: none;
  color: var(--accent); font-weight: 500; white-space: nowrap;
}
.back::before { content: "‹"; font-size: 1.7em; line-height: 1; margin: -2px 6px 0 0; }
/* A− and A+ in the bar, next to "Show spaces", each a tap target of 44 by 44 pixels. At either end of the sizes a
   button is marked aria-disabled, not disabled, so it keeps the keyboard's focus (core/screens.js). */
.bar-size { display: flex; flex: none; margin-right: -8px; }
.size-btn { min-width: 44px; margin: 0; padding: 0 6px; font-size: 15px; font-weight: 600; }
.size-btn[aria-disabled="true"] { color: var(--muted); opacity: .45; cursor: default; }
.size-btn[aria-disabled="true"]:hover { background: none; }
/* On a phone the bar has room for the chapter's title only without the word of the way back and the place. */
@media (max-width: 400px) {
  .back-word, .bar-place { display: none; }
  .back::before { margin-right: 0; }
  .bar-row { gap: 4px; }
}
/* Beside the panel's column, as on a phone held sideways or beside a column dragged wide, the bar may be as narrow as
   a phone's: below 520 pixels (core/column.js, NARROW_BAR) core/panel.js sets html.narrow-bar. */
html.panel-side.narrow-bar body.reading .back-word, html.panel-side.narrow-bar body.reading .bar-place { display: none; }
html.panel-side.narrow-bar body.reading .back::before { margin-right: 0; }
html.panel-side.narrow-bar body.reading .bar-row { gap: 4px; }
.back:hover { background: var(--hover); }
.bar-title { flex: 1; min-width: 0; font-family: var(--f-book); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-place { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* "Show spaces" in the bar, as on the translator's reading page, so the reader reaches it anywhere in a chapter. */
.bar-btn {
  flex: none; min-height: 44px; margin-right: -8px; padding: 0 8px; border: 0; border-radius: 8px; background: none;
  color: var(--accent); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.bar-btn:hover { background: var(--hover); }
.bar-btn[aria-pressed="true"] { background: var(--mine-bg); color: var(--mine); font-weight: 600; }
/* The gear at the right of the bar opens the Settings screen (core/settings.js): a tap target of 44 by 44 pixels. */
.gear-bar-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; padding: 0; }
.gear { flex: none; display: block; }
/* On a narrow bar, as on a phone or beside the panel's column, "Show spaces" gives its room to the chapter's title;
   the Settings screen holds it too. */
@media (max-width: 520px) { .spaces-btn { display: none; } }
html.panel-side.narrow-bar body.reading .spaces-btn { display: none; }
/* Offline and not-saved notes float at the foot of the screen, over nothing the reader must tap: above the panel's
   sheet (--sheet-h, set by core/panel.js), in the middle of the screen, and in a chapter in the middle of the
   reading column beside the panel's column. The note is as wide as its words, centred between its left and right
   edges, so it may use the whole width before it wraps; core/panel.js keeps the words it uncovers above it. */
.sync {
  position: fixed; z-index: 6; left: var(--gutter); right: var(--gutter); margin: 0 auto;
  width: -webkit-max-content; width: max-content; max-width: calc(100% - 2 * var(--gutter));
  bottom: calc(12px + var(--sheet-h, 0px) + env(safe-area-inset-bottom, 0px));
  padding: 6px 14px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 14px; text-align: center;
  box-shadow: 0 2px 10px rgb(0 0 0 / .15);
}
html.panel-side body.reading .sync { right: calc(var(--gutter) + var(--room)); max-width: calc(100% - 2 * var(--gutter) - var(--room)); }
.sync.bad { color: var(--bad); border-color: var(--bad); background: var(--bad-bg); }
.sync.has-btn { padding: 0; }
.sync-btn {
  min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: none;
  color: inherit; font-size: 14px; font-weight: 600;
}
.sync-btn::after { content: " \203A"; }

.notice {
  max-width: var(--column); margin: 16px var(--gutter) 0; padding: 10px 14px;
  border: 1px solid var(--bad); border-radius: 8px; background: var(--bad-bg); color: var(--ink);
}
@media (min-width: 42rem) { .notice { margin: 16px auto 0; } }

.boot {
  width: 96px; height: 4px; margin: 38vh auto 0; border-radius: 2px;
  background: linear-gradient(90deg, var(--rule) 0%, var(--accent) 50%, var(--rule) 100%);
  background-size: 200% 100%; animation: boot 1.2s linear infinite;
}
@keyframes boot { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---- home and plain screens ---- */
.home-head, .message { padding-block: 28px 8px; }
.home-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h1 { font-size: 1.75rem; line-height: 1.3; margin: 4px 0 8px; font-weight: 600; }
.hello { margin: 0 0 4px; font-weight: 500; }
.lead { color: var(--ink-2); line-height: 1.6; margin: 0 0 16px; }
.lead.loading { padding-top: 32px; color: var(--muted); }
.message .row { margin-top: 8px; }

.settings { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/* The settings wrap under a long title, as with "Your devices" beside the language switch: a gap before the text. */
.home-top .settings { margin-bottom: 8px; }
.lang { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; flex: none; }
.lang-btn {
  min-height: 44px; min-width: 64px; padding: 0 14px; border: 0; background: var(--surface);
  color: var(--muted); font-size: 15px;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--rule); }
.lang-btn[aria-pressed="true"] { background: var(--mine-bg); color: var(--mine); font-weight: 600; }

.book { font-size: 1.15rem; margin: 28px 0 0; font-weight: 600; }
.shelf { list-style: none; margin: 16px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.shelf li { border-bottom: 1px solid var(--rule); }
.ch-row {
  display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline;
  width: 100%; min-height: 64px; padding: 14px 4px; border: 0; background: none; text-align: left;
}
.ch-row:hover { background: var(--hover); }
.ch-num { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.ch-names { min-width: 0; }
.ch-title { display: block; font-family: var(--f-book); font-size: 1.15rem; font-weight: 500; line-height: 1.45; }
.ch-en { display: block; color: var(--muted); font-size: 14px; }
.ch-meta { grid-column: 2 / 4; color: var(--muted); font-size: 14px; }
/* "Updated <date>" on the row of a chapter that changed since the reader last opened it. */
.ch-upd { grid-column: 2 / 4; color: var(--accent); font-size: 14px; font-weight: 500; }
.home-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 4px; }

.chip {
  display: inline-block; padding: 5px 9px; border-radius: 999px;
  font-size: 13px; line-height: 1; font-weight: 500; white-space: nowrap;
}
.chip.todo { background: var(--hover); color: var(--muted); }
.chip.reading, .chip.mine { background: var(--mine-bg); color: var(--mine); }
.chip.done { background: var(--done-bg); color: var(--done); }
.chip.flag { background: var(--flag-bg); color: var(--flag); }

/* ---- chapter ---- */
.ch-head { padding-block: 28px 12px; }
.ch-head h1 { font-family: var(--f-book); font-size: 1.9rem; }
.ch-head .ch-en { font-family: var(--f-en); font-size: 1.05rem; font-style: italic; margin: 0; }
.eyebrow { margin: 0; color: var(--muted); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.hint { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
/* The settings that stand in a chapter too, under the hint line, as "English beside the text" on a wide screen:
   the space goes on each item, so an item the screen hides leaves none. */
.ch-settings > * { margin-top: 12px; }
/* The line that says when the chapter changed and how many paragraphs changed. */
.upd-line {
  margin: 12px 0 0; padding: 8px 12px; border-left: 3px solid var(--accent); border-radius: 4px;
  background: var(--mine-bg); color: var(--ink); font-size: 15px;
}
.tool-btn {
  min-height: 44px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 15px;
}
.tool-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--mine-bg); color: var(--mine); font-weight: 600; }
/* "Settings" at the top of the chapter list: the gear before the word. */
.gear-btn { display: inline-flex; align-items: center; gap: 6px; padding-left: 10px; }
html.wide .narrow-only { display: none; }

/* ---- the Settings screen (core/settings.js): one section per setting, each with its heading ---- */
.set-item { margin-top: 24px; }
.set-item h2 { margin: 0 0 8px; font-size: 1.1rem; font-weight: 600; }
.set-row { display: flex; align-items: center; gap: 12px; }
.set-value { min-width: 3.5em; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.set-hint { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.set-item .devices { margin-bottom: 0; }
/* A paragraph of the book at the size chosen, with the dots of "Show spaces" when they show: its first three lines. */
.set-sample-box { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); }
.set-sample-box .label { margin: 0 0 4px; }
.set-sample { margin: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.settings-page > .row { margin-top: 28px; }

.para {
  position: relative; margin: 0 -10px; padding: 6px 10px; border-radius: 8px;
  cursor: pointer; scroll-margin-top: calc(var(--bar-h) + 16px + env(safe-area-inset-top, 0px));
  -webkit-tap-highlight-color: transparent;
}
.para:hover { background: var(--hover); }
.para.has-notes { box-shadow: inset 3px 0 0 var(--flag); }
.para.has-failed { box-shadow: inset 3px 0 0 var(--bad); }
.para.open { background: var(--surface); box-shadow: 0 0 0 1px var(--rule); cursor: default; }
.para.open.has-notes { box-shadow: 0 0 0 1px var(--rule), inset 3px 0 0 var(--flag); }
.para.open.has-failed { box-shadow: 0 0 0 1px var(--rule), inset 3px 0 0 var(--bad); }
/* The paragraph whose panel closed last keeps a soft background until another opens. */
.para.was { background: var(--surface); }
/* While the reader picks words, the open paragraph is the place to tap. */
body.picking .para.open { box-shadow: 0 0 0 2px var(--accent); }
body.picking .para.open .para-text, body.picking .para.open .fns { cursor: crosshair; }
.para.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--hl); } to { background: transparent; } }

.para-text { margin: 0 0 4px; font-family: var(--f-book); font-size: calc(1.2rem * var(--ts)); line-height: 1.95; }
.para-text em { font-style: italic; }
.para-text sup.fn { font-size: .62em; color: var(--accent); margin: 0 1px; position: relative; cursor: pointer; }
/* A tap on a footnote's number starts a comment on the footnote (para.js). The number is small, so a tap a little
   beside it, above it or below it counts too: an empty box around it, which moves no text. */
.para-text sup.fn::before { content: ""; position: absolute; left: -.5em; right: -.5em; top: -.4em; bottom: -.7em; }
/* A word of the book's break list, กระ with the letter after it, a closing mark with the letter before it, or a
   verse range: a line may end before or after it, never inside it. parsers/annotators/thai_keep.py adds these spans when a chapter is
   published; they hold no character of their own. */
.bt .nb, .kept .nb { white-space: nowrap; }
/* S'gaw Karen: a line ends only between two syllables. parsers/annotators/karen_syllables.py puts the text in
   span.syllables, where a line may end between any two characters, and each stretch of two characters or more between
   two syllables' starts, or between a syllable's start and a space, in span.nb above, which stays whole. */
.bt .syllables, .kept .syllables { word-break: break-all; }
/* Outside the book's own text, a stretch that holds no letter of the script, as a pasted link or a word in Latin letters,
   breaks by the browser's own rules, and a long one wraps where the card's overflow-wrap lets it (web/core/quotes.js,
   syllableRanges). */
.kept .syllables .free { word-break: normal; }
.tag { margin-left: .4em; color: var(--muted); font-family: var(--f-ui); font-size: .66em; white-space: nowrap; }
.badge { margin-left: .5em; color: var(--flag); font-family: var(--f-ui); font-size: .66em; font-weight: 600; white-space: nowrap; }
/* The chapter's title, a paragraph the reader taps and comments on (core/para.js): an h1 of the heading's size
   (.ch-head h1), with the heading's line height and without the paragraph number. */
.para.is-title .para-text { line-height: 1.3; margin: 4px 0; }
.para.is-title .tag { display: none; }
/* The mark at the start of a paragraph that changed since the reader last opened the chapter, until the
   reader opens it. */
.upd {
  display: inline-block; margin-right: .5em; padding: 2px 7px; border-radius: 999px; vertical-align: .15em;
  background: var(--mine-bg); color: var(--mine); font-family: var(--f-ui); font-size: .6em; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.para.is-changed { box-shadow: inset 3px 0 0 var(--accent); }
.para.is-changed.has-notes { box-shadow: inset 3px 0 0 var(--flag); }
/* "Show spaces": a faint dot over every space of the book text, also at the end of a line. The dot is
   generated content, so it is never selected or copied with the words. It comes before the space (::before), so
   the space's box ends the line whole and the dot stays on that line. The browser drops the width of a space that
   ends a line, so the dot's middle stands an eighth of an em after the box's start: the middle of a space inside a
   line, and just after the last letter of a line, never on that letter. */
.sp { position: relative; }
.sp::before {
  content: "\00B7"; position: absolute; left: .125em; top: 0; line-height: 1; transform: translate(-50%, .12em);
  color: var(--muted); opacity: .75; font-weight: 700; pointer-events: none;
  -webkit-user-select: none; user-select: none;
}
/* A Thai sentence and its English, lit while the paragraph's panel is open (features/sentences.js). */
.para.open .al-s { cursor: pointer; }
.para.open .al-s.hl, .panel .en .al-e.hl, .para.open .side-en .al-e.hl {
  background: var(--hl); border-radius: 3px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
/* Words the reader's comments quote: soft where one comment quotes them, deeper where two or more do, each with a
   thin line under the words, which stays visible at any brightness of the screen while the background stays soft;
   the words the comment being written holds from a pick or a selection are the strongest (core/para.js,
   paintQuotes). */
.qm { border-radius: 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.qm.q1 { background: var(--q1); box-shadow: inset 0 -2px 0 var(--q1-line); }
.qm.q2 { background: var(--q2); box-shadow: inset 0 -2px 0 var(--q2-line); }
.qm.pk { background: var(--pk); color: var(--ink); box-shadow: inset 0 -2px 0 var(--flag); }
/* The English sentence that holds words a comment quotes (core/para.js). The lit sentence (.hl) keeps its own light. */
.al-e.qe:not(.hl) { background: var(--q1); box-shadow: inset 0 -2px 0 var(--q1-line); border-radius: 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
/* The English beside each paragraph on a wide screen, aligned at the top of the paragraph (features/english.js). */
.para.with-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--side-gap); align-items: start; }
.para.with-side > .para-text, .para.with-side > .fns { grid-column: 1; }
.para.with-side > .side-en { grid-column: 2; grid-row: 1 / span 2; padding-top: .35em; }
.has-failed .badge { color: var(--bad); }
.fns { margin: 0 0 6px; padding-left: 1.6em; color: var(--ink-2); font-family: var(--f-book); font-size: calc(1rem * var(--ts)); line-height: 1.7; }

.label { margin: 0 0 6px; color: var(--muted); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.en { color: var(--ink-2); font-family: var(--f-en); font-size: calc(1.02rem * var(--ts)); line-height: 1.62; }
.en p { margin: 0 0 .6em; }
.en p:last-child { margin-bottom: 0; }
.en .verse { padding-left: 1.2em; font-style: italic; }

.notes { display: grid; gap: 10px; }
.note { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); }
.note.failed { border-color: var(--bad); }
.note-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-state { color: var(--muted); font-size: 13px; }
.note.failed .note-state { color: var(--bad); font-weight: 600; }
.note-acts { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.note-quote, .note-text { margin: 0; font-family: var(--f-book); font-size: 1.05rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-quote { color: var(--ink-2); }
.note-words { display: grid; gap: 6px; }
.note-where { margin: 0; color: var(--muted); font-size: 14px; }
.note-why { margin: 0; color: var(--bad); font-size: 14px; }
.note-wait { margin: 0; color: var(--muted); font-size: 14px; }
.note-changed { margin: 0; color: var(--ink-2); font-size: 14px; }
.note-reply { display: grid; gap: 4px; margin-top: 2px; padding: 8px 10px; border-left: 3px solid var(--done); border-radius: 4px; background: var(--done-bg); }
.note-reply .label { margin: 0; }
.reply-text { margin: 0; font-family: var(--f-book); font-size: 1.02rem; white-space: pre-wrap; overflow-wrap: anywhere; }
/* The translator's notes on a paragraph, under the English in its panel (features/notes.js). */
.tnotes { display: grid; gap: 8px; margin: 12px 0 4px; padding: 2px 0 2px 12px; border-left: 3px solid var(--rule); }
.tnotes .label { margin: 0; }
.tnote {
  margin: 0; color: var(--ink-2); font-size: calc(1rem * var(--ts)); line-height: 1.6;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.tnote-file { display: grid; gap: 2px; }
.tnote-file p { margin: 0; }
.tnote-span { font-family: var(--f-book); }
.tnote-en { font-family: var(--f-en); font-style: italic; }
/* An editor's choice in the text, the paragraphs of a side track, and the list of what to check (core/choices.js). */
.choice-words { background: var(--flag-bg); border-radius: 3px; }
.choice-hide { display: none; }
.choice-words.nothing::after { content: "\2026"; }
.quote-row[hidden] { display: none; }
.choice-quote { margin: 0 0 4px; padding: 4px 8px; background: var(--flag-bg); border-radius: 3px; font-family: var(--f-book); overflow-wrap: anywhere; }
.choice-quote[hidden] { display: none; }
.agenda-row .chip { flex: none; margin-left: auto; }
.over-form:empty { display: none; }
.para.near .para-text { color: var(--muted); font-size: calc(1.05rem * var(--ts)); }
.agenda { margin: 12px 0; padding: 8px 12px; border-left: 3px solid var(--flag); background: var(--surface); }
.agenda .label { margin: 0 0 4px; }
.agenda .hint { margin: 0 0 6px; }
.agenda-rows { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.agenda-row { display: flex; gap: 8px; width: 100%; min-height: 44px; align-items: center; text-align: left; }
.agenda-a { flex: none; font-variant-numeric: tabular-nums; }
.agenda-words { overflow-wrap: anywhere; font-family: var(--f-book); }
.choices { display: grid; gap: 10px; margin: 12px 0 4px; padding: 2px 0 2px 12px; border-left: 3px solid var(--flag); }
.choices .label { margin: 0; }
.choice-why { font-weight: 500; }
.no-change { justify-self: start; }
.no-change-said { margin: 0; }
.choice { display: grid; gap: 6px; justify-items: start; }
.choice-options { display: grid; gap: 6px; width: 100%; }
.choice-option {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; min-height: 44px; padding: 8px 10px;
  text-align: left; font-family: var(--f-book); font-size: calc(1rem * var(--ts)); color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--field-rule); border-radius: 8px; overflow-wrap: anywhere;
}
.choice-option.chosen { border: 2px solid var(--accent); background: var(--mine-bg); }
.choice-typed { margin: 0; font-family: var(--f-book); white-space: pre-wrap; overflow-wrap: anywhere; }
/* A question from the translator in a paragraph's panel (features/question.js). */
.questions { display: grid; gap: 10px; margin: 12px 0 4px; padding: 2px 0 2px 12px; border-left: 3px solid var(--accent); }
.question { display: grid; gap: 6px; }
.question .label { margin: 0; }
.q-text, .q-quote, .q-msg-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.q-quote, .q-msg-text { font-family: var(--f-book); }
.q-thread { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.q-msg.mine { padding-left: 10px; border-left: 2px solid var(--mine); }
.q-form { display: grid; gap: 6px; }
.q-answer { width: 100%; box-sizing: border-box; font-family: var(--f-book); font-size: 16px; }
.ch-questions { display: block; color: var(--flag); font-size: 14px; }
/* "Show the earlier wording" in a paragraph's panel, at the top of the English, between its label and its text. */
.lead-top:empty { display: none; }
.lead-top { margin: 0 0 8px; }
/* While the button is folded, its row stays at the top of the English as the English scrolls to a later sentence
   (core/updates.js sets .stuck), so a reader on a phone still sees it. */
.face-en .lead-top.stuck { position: -webkit-sticky; position: sticky; top: 0; z-index: 1; background: var(--surface); }
.earlier-block { display: grid; gap: 6px; }
.earlier-btn { justify-self: start; margin-left: -10px; }
.earlier-block .status:empty { display: none; }
.earlier-out:empty { display: none; }
.earlier-out { padding: 8px 12px; border: 1px dashed var(--rule); border-radius: 8px; }
.earlier-text { display: block; color: var(--ink-2); font-family: var(--f-book); font-size: calc(1.1rem * var(--ts)); line-height: 1.9; }
.earlier-out .fns { margin-top: 6px; }
.gone { display: grid; gap: 10px; margin-top: 32px; }
/* "My earlier comments": the reader's comments of earlier review rounds, read-only. */
.past-round { margin: 28px 0 0; font-size: 1.15rem; font-weight: 600; }
.past-ch { margin: 16px 0 8px; color: var(--ink-2); font-size: 1rem; font-weight: 600; }
.past-ch [lang] { font-family: var(--f-book); font-weight: 500; }
.past .book { margin-top: 32px; }
.past-screen > .row { margin-top: 24px; }
/* Search (features/search.js): the box for the words, then each paragraph found, with the words found marked and,
   for words found in the English, a softer mark on the Thai sentences that render them. */
.search-form { display: flex; gap: 8px; margin: 0 0 8px; }
.search-q {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; border: 1px solid var(--field-rule); border-radius: 8px;
  background: var(--surface); font-family: var(--f-book); font-size: 17px; -webkit-appearance: none; appearance: none;
}
.search-status { margin: 12px 0; }
.search-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.search-card { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); }
.search-where { margin: 0; color: var(--muted); font-size: 14px; }
.search-text, .search-fn { margin: 0; font-family: var(--f-book); font-size: calc(1.1rem * var(--ts)); line-height: 1.9; white-space: pre-line; }
.search-fn { color: var(--ink-2); font-size: calc(1rem * var(--ts)); }
.search-fn-n { color: var(--muted); font-family: var(--f-ui); font-size: 13px; }
.search-en { margin: 0; color: var(--ink-2); font-family: var(--f-en); font-size: calc(1rem * var(--ts)); line-height: 1.6; white-space: pre-line; }
.search-card .row { margin-top: 0; }
mark.search-hit { background: var(--pk); color: inherit; border-radius: 2px; }
mark.search-pair { background: var(--q1); color: inherit; border-bottom: 1px solid var(--q2); }
.gone h2 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.gone .hint { margin: 0; }

.link {
  min-height: 44px; min-width: 44px; padding: 0 10px; border: 0; border-radius: 8px; background: none;
  color: var(--accent); font-size: 15px; font-weight: 500;
}
.link:hover { background: var(--hover); }
.link.danger { color: var(--flag); }

.note-form { display: grid; gap: 12px; }
/* The two kinds of comment: one row of two buttons, each a label around a radio button that only the keyboard and a
   screen reader see, and under them the hint of the kind chosen (core/notes.js). The page marks the chosen button
   with the class chosen. */
.kinds { display: grid; gap: 4px; margin: 0; padding: 0; border: 0; min-width: 0; }
.kinds legend { padding: 0; }
.kind-row { display: flex; border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.kind {
  position: relative; flex: 1 1 0; display: flex; align-items: center; justify-content: center; min-width: 0;
  min-height: 44px; padding: 6px 10px; background: var(--surface); color: var(--ink-2);
  text-align: center; line-height: 1.25; cursor: pointer;
}
.kind + .kind { border-left: 1px solid var(--rule); }
.kind.chosen { background: var(--mine-bg); color: var(--mine); }
.kind input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.kind:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -4px; }
.kind-name { font-weight: 600; }
.kind-hint { margin: 0; color: var(--muted); font-size: 14px; }
.field-wrap { display: grid; gap: 2px; min-width: 0; }
.field { display: grid; gap: 4px; }
.field > span { color: var(--muted); font-size: 14px; }
.field input, .field textarea, .quote-row input {
  width: 100%; min-height: 44px; padding: 8px 10px;
  border: 1px solid var(--field-rule); border-radius: 8px; background: var(--surface); color: var(--ink);
  font-family: var(--f-book); font-size: 17px; line-height: 1.6;
}
.field textarea { min-height: 6.5em; resize: vertical; }
/* The quote box and Pick words beside it. */
.quote-row { display: flex; align-items: stretch; gap: 8px; }
.quote-row input { flex: 1; min-width: 0; }
.pick-btn { flex: none; padding: 8px 12px; white-space: nowrap; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.btn {
  min-height: 44px; padding: 8px 18px; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 500;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.done { border-color: var(--done); background: var(--done); color: var(--done-ink); }
.btn.wide { width: 100%; }
.status { color: var(--muted); font-size: 14px; }
.status.bad { color: var(--bad); font-weight: 500; }
/* A device's code, which the reader reads out or types on another device: large, and the same width for each letter. */
.device-code { font-size: 22px; font-weight: 600; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; color: var(--ink); }
/* The offer of a username and password on the waiting screen (core/screens.js, showDeviceWaiting), above the code. */
.wait-offer { margin: 4px 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--rule); }
.wait-offer h2 { margin: 0 0 8px; font-size: 18px; }
/* The count of characters under a text box near its limit. */
.count { justify-self: end; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.count.over { color: var(--bad); font-weight: 600; }

.finish {
  display: grid; gap: 14px; margin-top: 40px; padding: 20px;
  border: 1px solid var(--rule); border-radius: 10px; background: var(--surface);
}
.finish.is-done { border-color: var(--done); }
.finish h2 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.pager { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 10px; }
.pager-btn {
  display: grid; gap: 2px; min-height: 56px; padding: 8px 12px; text-align: left;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--paper);
}
.pager-btn:hover { background: var(--hover); }
.pager-btn.next { text-align: right; }
.page-dir { color: var(--muted); font-size: 13px; }
.page-title { color: var(--accent); font-family: var(--f-book); font-weight: 500; min-width: 0; }

/* ---- signing in (core/signin.js) and "Your devices" (core/account.js) ---- */
.auth-choices { display: grid; gap: 10px; max-width: 22rem; margin: 8px 0 16px; }
.line-btn { border-color: var(--line); background: var(--line); color: var(--line-ink); font-weight: 600; }
.skip-btn { justify-self: start; margin-left: -10px; }
/* Why the screen shows, or what a sign-in ended in. */
.auth-line { padding: 8px 12px; border-left: 3px solid var(--accent); border-radius: 4px; background: var(--mine-bg); color: var(--ink); }
.auth-line.bad { border-left-color: var(--bad); background: var(--bad-bg); }
.auth-form { display: grid; gap: 12px; max-width: 22rem; margin: 8px 0 16px; }
.auth-form .lead, .auth-form .hint, .auth-error { margin: 0; }
.auth-form .row { margin-top: 0; }
.auth-form .field input { font-family: var(--f-ui); }
/* The username of a reset link, shown and fixed. */
.auth-form .field input[readonly] { background: var(--hover); color: var(--ink-2); }
/* A grid item is never narrower than its longest word, so a long email address would widen the form and "Your
   devices" past the phone: the items may shrink, and the address breaks inside itself. */
.auth-form > *, .device > * { min-width: 0; }
.auth-form .lead, .device-name { word-break: break-word; overflow-wrap: anywhere; }   /* word-break first: Safari before 15.4 */
.code-field { letter-spacing: .3em; font-variant-numeric: tabular-nums; }
/* The rules of a new password under its field (core/password.js): a green check for a rule met, a red cross for one
   not met, and a grey dot while nothing is typed or the check is the server's. The marks are drawn here, so they are
   never selected or read as text; a screen reader hears each rule's state in words (.sr-only). */
.pw-rules { display: grid; gap: 2px; margin: -4px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--ink-2); }
.pw-rule { display: flex; align-items: baseline; gap: 8px; }
.pw-mark { flex: none; width: 1.1em; text-align: center; font-weight: 700; }
.pw-rule.wait .pw-mark::before { content: "\2022"; color: var(--muted); }
.pw-rule.ok .pw-mark::before { content: "\2713"; color: var(--done); }
.pw-rule.no .pw-mark::before { content: "\2717"; color: var(--bad); }
.pw-rule.no { color: var(--ink); }
/* The line while the form waits to send again because many people are signing in. */
.auth-wait { margin: 0; color: var(--ink-2); }
/* Words for a screen reader alone. */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
/* The dev server alone: "Enter as <reader>". */
.dev-box { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 24px; padding-top: 12px; border-top: 1px dashed var(--rule); }
.devices { list-style: none; margin: 0 0 8px; padding: 0; border-top: 1px solid var(--rule); }
.device { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; min-height: 52px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.device-name { grid-column: 1; font-weight: 500; }
.device-when { grid-column: 1; color: var(--muted); font-size: 14px; }
.device-when:empty { display: none; }
.device > .chip, .device > .link { grid-column: 2; grid-row: 1 / span 2; }
.ways { margin-top: 24px; }
.ways h2 { margin: 0 0 8px; font-size: 1.1rem; font-weight: 600; }
/* The line under the chapter list on adding the site to the Home Screen, in Safari on an iPhone or iPad. */
.home-hint { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; color: var(--muted); font-size: 14px; }
.home-hint > span { flex: 1; }
.home-hint .link { flex: none; font-size: 14px; }

/* ---- the panel of a paragraph (core/panel.js): a sheet from the bottom, or a column at the right ---- */
.panel {
  position: fixed; z-index: 8; display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
}
.panel.sheet {
  left: 0; right: 0; bottom: 0; max-height: 100%;
  border-top: 1px solid var(--rule); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 24px rgb(0 0 0 / .16);
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.panel.column {
  top: 0; right: 0; bottom: 0; width: var(--panel-w);
  border-left: 1px solid var(--rule); padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 0;
}
/* The border between the text and the column (core/panel.js, wireBorder): a strip over the column's left edge, 13
   pixels wide, or 29 where a finger points, with a grip in its middle like the sheet's bar. Drag it, or move it with
   the arrow keys, to make the text or the column wider. While it is dragged, the whole page shows the cursor of a
   border and selects no words (html.resizing). */
.col-border { display: none; }
.panel.column .col-border {
  display: block; position: absolute; z-index: 2; top: 0; bottom: 0; left: -7px; width: 13px;
  cursor: col-resize; touch-action: none; -webkit-tap-highlight-color: transparent;
}
@media (pointer: coarse) { .panel.column .col-border { left: -15px; width: 29px; } }
.col-grip {
  position: absolute; top: 50%; left: 50%; width: 5px; height: 40px; margin: -20px 0 0 -2.5px; border-radius: 3px;
  background: var(--field-rule); opacity: .6;
}
.col-border:hover .col-grip, .col-border:focus-visible .col-grip, html.resizing .col-grip { background: var(--accent); opacity: 1; }
.col-border:focus-visible { outline-offset: -2px; }
html.resizing, html.resizing * { cursor: col-resize !important; -webkit-user-select: none; user-select: none; }
/* The sheet's bar: drag it to any height, or tap it to fill the screen and back. The head of a sheet, outside its
   buttons, drags it too (core/panel.js, wireDrag). */
.grab-zone { flex: none; padding: 8px 0 6px; touch-action: none; cursor: grab; }
.panel.sheet .panel-head { touch-action: none; }
.grab { display: block; width: 40px; height: 5px; margin: 0 auto; border-radius: 3px; background: var(--field-rule); opacity: .6; }
.panel.column .grab-zone { display: none; }
.panel-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 0 8px 8px 16px; border-bottom: 1px solid var(--rule); }
/* In a column the head is exactly as tall as the bar, so the line under it meets the bar's line. */
.panel.column .panel-head { min-height: calc(var(--bar-h) + 1px); padding-top: 0; padding-bottom: 0; }
.panel-where { flex: none; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.faces { display: flex; flex: 1; min-width: 0; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
/* The English button keeps its one word whole; the comment button's label, as "Write a comment · 2" in a narrow
   column, takes a second line rather than being cut. */
.face-btn {
  flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 2px 10px; border: 0; background: var(--surface);
  color: var(--muted); font-size: 14px; line-height: 1.2; overflow-wrap: normal; word-break: normal;
}
.face-btn[data-face="en"] { flex: none; }
/* The switches clip what stands outside their buttons, so the focus ring is drawn inside them. */
.face-btn:focus-visible, .lang-btn:focus-visible { outline-offset: -4px; }
.face-btn + .face-btn { border-left: 1px solid var(--rule); }
.face-btn[aria-pressed="true"] { background: var(--mine-bg); color: var(--mine); font-weight: 600; }
/* With one face, its button is the panel's title. */
.panel.one-face .faces { border: 0; border-radius: 0; }
.panel.one-face .face-btn { flex: 0 1 auto; padding: 0; background: none; color: var(--ink); text-align: left; cursor: default; }
.panel-close {
  flex: none; min-height: 44px; min-width: 44px; padding: 0 6px; border: 0; border-radius: 8px; background: none;
  color: var(--accent); font-weight: 500;
}
.panel-close:hover { background: var(--hover); }
.panel-body {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 12px 16px 16px;
}
.face { display: grid; gap: 16px; }
.face-note .notes-block { margin-top: 4px; }
/* In the panel the text box starts three lines high, so Save stands near the comment box's resting height; the
   reader can drag it taller, and the sheet takes the whole screen while the reader types. */
.panel .field textarea { height: 4.6em; min-height: 4.6em; }
.under-form:empty { display: none; }
/* The state of the comment just saved, at the top of the comment box (core/panel.js, paintSaved). */
.saved-line { margin: 0; font-weight: 500; }
/* "Reply from the translator" at the top of the comment box of a paragraph with a reply: a tap scrolls to it. */
.reply-jump { justify-self: start; margin: -8px 0 -8px -10px; color: var(--done); font-weight: 600; }
.reply-jump::after { content: " \203A"; }
/* Previous sentence and Next sentence stay at the foot of the English while it scrolls; in a sheet dragged low
   (.short, a body under 200 pixels) they follow the English instead of covering it. */
.steps {
  position: -webkit-sticky; position: sticky; bottom: -16px; z-index: 1;
  display: flex; align-items: center; gap: 8px; margin: 0 -16px -16px; padding: 8px 16px calc(8px + 16px);
  border-top: 1px solid var(--rule); background: var(--surface);
}
.panel.short .steps { position: static; }
.step-btn { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 4px 8px; font-size: 14px; line-height: 1.25; }
.step-btn:disabled { opacity: .4; cursor: default; }
.step-count { flex: none; min-width: 3.2em; color: var(--muted); font-size: 13px; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Pick words: the sheet becomes a strip at the foot with the line and Cancel; a column shows the line at its top. */
.pick-strip { display: none; flex: none; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; color: var(--ink-2); }
.pick-strip > span { flex: 1; }
.panel.strip .pick-strip { display: flex; }
.panel.sheet.strip .grab-zone, .panel.sheet.strip .panel-head, .panel.sheet.strip .panel-body { display: none; }
.panel.column .pick-strip { order: 1; border-bottom: 1px solid var(--rule); background: var(--mine-bg); }
.panel.column .panel-body { order: 2; }

@media (max-width: 480px) {
  h1, .ch-head h1 { font-size: 1.55rem; }
  .para-text { font-size: calc(1.15rem * var(--ts)); }
}
@media (prefers-reduced-motion: reduce) {
  .para.flash { animation: none; }
  .boot { animation: none; }
}
