:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #d9d6ce;
  --accent: #2f5d8a;
  --accent-ink: #ffffff;
  --target: #e6eef7;
  --ok: #2e7d4f;
  --bad: #b3261e;
  --missing: #c07a00;
  --mark: #2f5d8a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181b; --panel: #202227; --ink: #ececef; --muted: #a0a0a8; --line: #3a3c42;
    --accent: #7fb0e0; --accent-ink: #10151b; --target: #26384b;
    --ok: #6cc28f; --bad: #f2877e; --missing: #e7b35c; --mark: #9cc3ea;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* .modal and .controls set display; `hidden` must still win */
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .75rem 1.5rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--panel);
}
.top h1 { margin: 0; font-size: 1.15rem; }
.controls { display: flex; flex-wrap: wrap; gap: .75rem; }
.controls label { display: flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--muted); }
select, button { font: inherit; }
select { padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }

main { max-width: 64rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

.where { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; }
.citation { font-weight: 600; color: var(--ink); }
/* figured out: beside the citation, and a check at the right of the line itself */
.solved-flag { margin-left: .4rem; padding: .05rem .55rem; border-radius: 999px; background: var(--ok); color: var(--panel); font-weight: 600; font-size: .85rem; white-space: nowrap; }
.line-check {
  position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
  width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--ok); color: var(--panel);
  font: 700 1.15rem/1.9rem system-ui, sans-serif; text-align: center; pointer-events: none;
}
.line-check.fresh { animation: check-pop .45s ease-out; }
@keyframes check-pop { 0% { transform: translateY(-50%) scale(0); } 70% { transform: translateY(-50%) scale(1.25); } 100% { transform: translateY(-50%) scale(1); } }

/* the rest of a line the reading stops in the middle of: grey ITALICS after a dashed rule -- not the
   faded upright type of the lines before and after, which ARE the reading. Scanned all the same. */
.beyond { color: var(--muted); font-style: italic; }   /* colour, not opacity: opacity would fade the marks */
.reading-end {
  display: inline-block; width: 0; height: 1.05em; margin: 0 .28em 0 .12em; vertical-align: -.15em;
  border-left: 2px dashed var(--muted);
}
.line-note { margin: .2rem 0 .6rem; color: var(--muted); font-size: .85rem; text-align: center; }

/* The lines before and after, inside the box at full size: the same type, upright, faded -- the text
   going on, where the grey italics of a tail are words outside the reading. On one row each: the line
   above keeps its END, the line below its BEGINNING, which is where hypermetry happens. */
.ctx-line {
  all: unset; box-sizing: border-box; position: relative; display: block; width: 100%;
  padding: 0 2.9rem 0 1rem; color: var(--ink); opacity: .3; cursor: pointer;
  font-family: Tahoma, "Noto Sans", "DejaVu Sans", sans-serif; font-size: clamp(1.35rem, 3.6vw, 2.1rem);
  line-height: 2.1; user-select: none; -webkit-user-select: none;
}
div.ctx-line { cursor: default; }
button.ctx-line:hover { opacity: .5; }
button.ctx-line:focus-visible { opacity: .5; outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.ctx-text { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ctx-prev .ctx-text { direction: rtl; text-align: left; }           /* a long line keeps its END */
.ctx-prev .ctx-text > bdi { direction: ltr; unicode-bidi: isolate; }
.ctx-check { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); color: var(--ok); font: 700 1.1rem/1 system-ui, sans-serif; }
/* the scroll: the whole stretch slides by one line, clipped by the box */
.stage-lines.slide-up { animation: slide-up .32s ease-out; }
.stage-lines.slide-down { animation: slide-down .32s ease-out; }
@keyframes slide-up { from { transform: translateY(var(--step, 3.5rem)); } to { transform: none; } }
@keyframes slide-down { from { transform: translateY(calc(-1 * var(--step, 3.5rem))); } to { transform: none; } }

/* hypermetry: an elision split between two lines -- trailing and open on the first, unbegun on the next */
.tie.trail { border-right: none; border-radius: 0 0 0 100% / 0 0 0 100%; }
.tie.lead { border-left: none; border-radius: 0 0 100% 0 / 0 0 100% 0; }
.half-tie { pointer-events: none; cursor: default; }
.half-tie::after { display: none; }
.half-tie.faint { border-color: var(--muted); opacity: .7; }

/* Go to a line */
.goto { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; margin-top: .6rem; font-size: .9rem; }
.goto label { display: flex; align-items: center; gap: .4rem; color: var(--muted); }
.goto select, .goto input { font: inherit; padding: .3rem .45rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
.goto input { width: 8.5rem; }
.goto button:not(.link) { font: inherit; padding: .3rem .75rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer; }
#open-map { margin-left: auto; border-color: var(--accent); color: var(--accent); font-weight: 600; }
.goto-msg { flex-basis: 100%; color: var(--muted); font-size: .85rem; }
.goto-msg:empty { display: none; }

/* The map of lines */
.map-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(17rem, 100%), 1fr)); gap: .5rem 1.5rem; }
.map-passage h3 { display: flex; justify-content: space-between; gap: .5rem; margin: .9rem 0 .3rem; }
.map-count { color: var(--muted); font-weight: normal; font-size: .85rem; white-space: nowrap; }
.map-book { color: var(--muted); font-size: .8rem; margin: .3rem 0 .15rem; }
.map-grid { display: grid; grid-template-columns: 2.4rem repeat(10, 1.25rem); gap: 3px; align-items: center; }
.map-row { color: var(--muted); font-size: .72rem; text-align: right; padding-right: .35rem; font-variant-numeric: tabular-nums; }
.map-gap { margin: .45rem 0 .45rem 2.4rem; padding: .15rem 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); color: var(--muted); font-size: .72rem; text-align: center; max-width: calc(10 * 1.25rem + 27px); }
.cell { display: inline-block; width: 1.25rem; height: 1.25rem; border-radius: 3px; border: 1px solid var(--line); background: var(--panel); padding: 0; vertical-align: middle; }
button.cell { cursor: pointer; }
button.cell:hover { border-color: var(--accent); }
.cell.solved { background: var(--ok); border-color: var(--ok); }
.cell.todo { background: var(--panel); border-color: var(--muted); }
.cell.current { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.cell.none { visibility: hidden; }
.cell.omitted { background: transparent; border: 1px dashed var(--muted); opacity: .6; }
.cell.half { width: .62rem; background: repeating-linear-gradient(45deg, var(--line) 0 2px, transparent 2px 5px); }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; font-size: .85rem; color: var(--muted); }
.map-legend .cell { margin-left: .4rem; }
.map-legend .cell:first-child { margin-left: 0; }

/* The line. Tahoma first: sans, a capital I with serifs, and full macron coverage incl. ȳ. */
.line-box {
  margin: 1.25rem 0 1rem; padding: .5rem 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden;                                  /* the text scrolls inside the box */
}
.line {
  padding: 1rem 2.9rem .2rem 1rem;
  font-family: Tahoma, "Noto Sans", "DejaVu Sans", sans-serif;
  font-size: clamp(1.35rem, 3.6vw, 2.1rem);
  line-height: 2.9;
  overflow-wrap: anywhere;
  user-select: none;
  -webkit-user-select: none;
}
.nuc {
  position: relative;
  border-radius: 4px;
  cursor: pointer;
  outline-offset: 2px;
}
.nuc.target { background: var(--target); box-shadow: 0 0 0 3px var(--target); }
.nuc.elided { color: var(--muted); }
.nuc .mark {
  position: absolute;
  left: 50%;
  bottom: 1.05em;
  transform: translateX(-50%);
  font-size: .95em;
  line-height: 1;
  color: var(--mark);
  cursor: grab;
  touch-action: none;
  padding: 0 .12em;
}
.nuc.ok .mark { color: var(--ok); }
.nuc.bad .mark { color: var(--bad); }
.nuc.revealed .mark { color: var(--muted); }

/* Swooshes (elision) under the line and foot dividers above it live in one overlay. */
.line { position: relative; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.tie {
  position: absolute;
  border: 2px solid var(--mark);
  border-top: none;
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}
.tie::after { content: ""; position: absolute; inset: -8px -4px -10px; }   /* a bigger target to grab */
.tie.ok { border-color: var(--ok); }
.tie.bad { border-color: var(--bad); }
.tie.revealed { border-color: var(--muted); }
.tie.slot { border-style: dashed; border-color: var(--accent); pointer-events: none; }
.tie.slot.trail { border-right: none; }                /* the preview keeps the open ends of a split swoosh */
.tie.slot.lead { border-left: none; }
.bar { position: absolute; width: 2px; background: var(--muted); border-radius: 1px; }
.tie-sym {
  display: inline-block; width: 1.1em; height: .42em; vertical-align: middle;
  border: 2px solid currentColor; border-top: none; border-radius: 0 0 50% 50% / 0 0 100% 100%;
}

.tray { display: flex; gap: .6rem; justify-content: center; margin-top: .5rem; }
.chip {
  display: flex; align-items: center; gap: .45rem;
  padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--ink); cursor: grab; touch-action: none;
}
.chip .sym { font-family: Tahoma, "Noto Sans", sans-serif; font-size: 1.4rem; line-height: 1; color: var(--mark); }
.chip.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.hint { text-align: center; color: var(--muted); font-size: .85rem; margin: .5rem 0 1.25rem; }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.actions button {
  padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); cursor: pointer;
}
.actions button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.actions button:disabled { opacity: .45; cursor: default; }
/* Previous and Next new are a matched pair at the two ends of the row; the rest sit between them */
.actions { justify-content: space-between; align-items: center; }
.actions-mid { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; flex: 1; }
/* the tutorial has its own ends of the row: Back and Next / Next stage (body.tutorial) */
body.tutorial .practice-only, body.tutorial [data-practice-only], body:not(.tutorial) .tutorial-only { display: none; }
.stage-dots { display: inline-flex; gap: .4rem; align-items: center; }
.stage-dots button {
  all: unset; box-sizing: border-box; width: .95rem; height: .95rem; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--muted); background: transparent;
}
.stage-dots button.done { background: var(--ok); border-color: var(--ok); }
.stage-dots button.here { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.stage-dots button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.stage-dots .of { color: var(--muted); font-size: .85rem; margin-right: .2rem; }
.actions button.nav { min-width: 7.5rem; border-color: var(--accent); color: var(--accent); font-weight: 600; }

.feedback { margin-top: 1.25rem; text-align: center; min-height: 1.5em; }
.feedback .feet { font-family: Tahoma, "Noto Sans", sans-serif; font-size: 1.3rem; letter-spacing: .08em; margin-top: .35rem; }
.feedback .note { color: var(--muted); font-size: .9rem; }
.reason {
  margin: .75rem auto 0; max-width: 40rem; padding: 0; color: var(--ink);
}
.reason:not(:empty) { padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.reason b { font-family: Tahoma, "Noto Sans", sans-serif; }

.ghost {
  position: fixed; z-index: 10; pointer-events: none;
  font-family: Tahoma, "Noto Sans", sans-serif; font-size: 2rem; line-height: 1; color: var(--mark);
  transform: translate(-50%, -110%);
}

.foot { text-align: center; color: var(--muted); font-size: .75rem; padding: 1rem; }

/* ---- modes, lesson, progress ---------------------------------------------------------------------- */
.modes { display: flex; gap: .35rem; flex-wrap: wrap; }
.mode {
  padding: .35rem .8rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--ink); cursor: pointer;
}
.mode.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
a.mode { text-decoration: none; display: inline-block; }   /* the Devices link, dressed as a mode */
.foot-link { color: var(--accent); font-weight: 600; font-size: .85rem; }
.pill { font-size: .8rem; margin-left: .25rem; opacity: .85; }
main > .controls { justify-content: center; align-items: center; margin-bottom: 1rem; }
.kinds { display: flex; flex-wrap: wrap; gap: .25rem .9rem; border: 1px solid var(--line); border-radius: 8px; padding: .3rem .8rem .45rem; margin: 0; font-size: .9rem; }
.kinds legend { color: var(--muted); font-size: .8rem; padding: 0 .3rem; }
.kinds label { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink); }
.kinds label.kinds-all { font-weight: 600; }
.practice-more { margin-top: .9rem; }
.practice-more a { color: var(--accent); font-weight: 600; }
.link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }

.lesson { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.lesson-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.lesson-head h2 { margin: 0; font-size: 1.1rem; }
.lesson-body p, .lesson-body ul { margin: .6rem 0; }
.lesson-body .latin { font-family: Tahoma, "Noto Sans", sans-serif; font-size: 1.1rem; }
.lesson-body .howto { color: var(--muted); }
.lesson-body .whats-new { border-left: 3px solid var(--accent); padding-left: .6rem; }
.no-storage { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid #c0392b; border-radius: 8px; padding: .7rem 1rem; margin: 0 0 1rem; }
.stage-done { margin-top: .5rem; }
.stage-done button { margin-top: .5rem; }
.gain { color: var(--ok); font-weight: 600; }
.new-badge { display: inline-block; margin: .35rem .25rem 0; padding: .2rem .65rem; border-radius: 999px; border: 1px solid var(--ok); color: var(--ok); font-size: .9rem; }

.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 2rem 1rem; }
.modal-card { background: var(--panel); color: var(--ink); border-radius: 12px; padding: 1.25rem 1.5rem; max-width: 34rem; width: 100%; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.modal-card.roomy { max-width: 46rem; }   /* not .wide: phones hide .wide */
.modal-card h2 { margin: 0 0 .5rem; font-size: 1.2rem; }
.modal-head { display: flex; justify-content: space-between; align-items: baseline; }
.modal-actions { text-align: right; margin-top: 1rem; }
.modal-card button.primary, .report button.primary {
  padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.big-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: .6rem; margin: .75rem 0 1rem; }
.big-stats div { border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; }
.big-stats b { display: block; font-size: 1.45rem; color: var(--accent); }
.big-stats span { color: var(--muted); font-size: .8rem; }
.progress-row { display: grid; grid-template-columns: 12rem 1fr 6.5rem; gap: .6rem; align-items: center; margin: .3rem 0; font-size: .92rem; }
.meter { height: .55rem; background: var(--line); border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ok); }
.progress-row .nums { color: var(--muted); font-size: .82rem; text-align: right; }
.modal-card h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
.badge-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.badge-list span { border: 1px solid var(--line); border-radius: 999px; padding: .2rem .65rem; font-size: .88rem; }
.report { border-top: 1px solid var(--line); margin-top: 1.2rem; padding-top: .2rem; }
.report label { display: inline-flex; gap: .5rem; align-items: center; margin-right: .6rem; }
.report input { font: inherit; padding: .3rem .45rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); }
.danger { text-align: right; margin-top: .8rem; font-size: .85rem; }
@media (max-width: 34rem) { .progress-row { grid-template-columns: 1fr 5.5rem; } .progress-row .meter { grid-column: 1 / -1; grid-row: 2; } }

/* ---- touch: no double-tap zoom, no grey flash, no long-press menu on the line --------------------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, select, label, .chip, .nuc { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.chip { touch-action: none; }                              /* chips are dragged, not scrolled */
.line { -webkit-touch-callout: none; }
.nuc::before { content: ""; position: absolute; inset: -.35em -.2em; }   /* a fingertip-sized target */
.narrow { display: none; }

/* The "Lines with" box: on a wide screen the legend is only a label. */
.kinds-toggle { all: unset; color: var(--muted); font-size: .8rem; }
.kinds-summary { display: none; }

/* ---- fast scanning -------------------------------------------------------------------------------- */
.nuc.cursor { background: var(--target); box-shadow: 0 0 0 3px var(--target), inset 0 -3px 0 var(--accent); animation: blink 1.1s ease-in-out infinite; }
@keyframes blink { 50% { box-shadow: 0 0 0 3px var(--target), inset 0 -3px 0 transparent; } }
.chip .key { display: none; margin-left: .15rem; }
body.fast .chip .key { display: inline-block; }
@media (pointer: coarse) { body.fast .chip .key { display: none; } }   /* a phone has no i, u, o keys to show */
kbd { font: .8rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; padding: 0 .35rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--bg); color: var(--ink); }
.toggles { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem 1.2rem; margin: .6rem auto 0; }
.toggle { display: flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--ink); }
.hint kbd { font-size: .75rem; }

/* ---- the rhythm, singalong style ------------------------------------------------------------------ */
.rhythm-row { margin-top: .6rem; display: flex; flex-wrap: wrap; gap: .4rem .9rem; justify-content: center; align-items: center; }
.rhythm-row .note { flex-basis: 100%; }
.rhythm-btn { padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--accent); background: var(--panel); color: var(--accent); font-weight: 600; cursor: pointer; }
.nuc .mark { transition: transform .12s ease-out, color .12s; }
.line.singing .nuc { transition: color .15s; }
.line.singing .nuc.sung { color: var(--accent); }
.nuc.beat { background: var(--target); color: var(--accent); }
.nuc.beat .mark { transform: translateX(-50%) scale(1.7); color: var(--accent); }

/* ---- fast scanning unlocked: the celebration ------------------------------------------------------ */
.celebrate { text-align: left; }
.celebrate h2 { text-align: center; }
.burst { text-align: center; font-size: 3rem; line-height: 1; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { from { transform: scale(.2) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.keys { border-collapse: collapse; margin: .3rem 0 .6rem; }
.keys td { padding: .25rem .6rem .25rem 0; vertical-align: middle; }
.keys td.sym { font-family: Tahoma, "Noto Sans", sans-serif; font-size: 1.3rem; color: var(--mark); text-align: center; }
.modal-actions { display: flex; justify-content: flex-end; gap: 1rem; align-items: center; }

@media (prefers-reduced-motion: reduce) {
  .nuc.cursor, .burst { animation: none; }
  .nuc .mark { transition: none; }
  .line-check.fresh { animation: none; }
  .stage-lines.slide-up, .stage-lines.slide-down { animation: none; }
}

/* ---- phones --------------------------------------------------------------------------------------- */
@media (max-width: 40rem) {
  .wide { display: none; }
  .narrow { display: inline; }
  .top { padding: .55rem .75rem; gap: .4rem; flex-wrap: nowrap; }
  .modes { flex-wrap: nowrap; gap: .3rem; }
  .top h1 { font-size: 1rem; white-space: nowrap; }
  .mode { padding: .3rem .6rem; font-size: .85rem; }
  /* no room in a phone's header for a fourth pill: the footer link stands in for it */
  .top .mode-extra { display: none; }
  main { padding: .75rem .75rem 1rem; display: flex; flex-direction: column; }
  .controls { gap: .5rem; }
  .controls > label { width: 100%; }
  .controls select { flex: 1; min-width: 0; }
  /* the kinds fold away behind one line */
  .kinds { width: 100%; min-width: 0; max-width: 100%; display: block; padding: .35rem .7rem; }
  .kinds legend { display: contents; }
  .kinds-toggle { display: flex; width: 100%; min-width: 0; font-size: .88rem; color: var(--ink); cursor: pointer; white-space: nowrap; }
  .kinds-toggle::after { content: "▾"; color: var(--muted); margin-left: .3rem; }
  .kinds.open .kinds-toggle::after { content: "▴"; }
  .kinds-summary { display: block; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
  .kinds label { display: none; }
  .kinds.open label { display: flex; clear: left; padding: .25rem 0; }
  .lesson { padding: .75rem .9rem; margin-bottom: .6rem; }
  .line-box { margin: .6rem 0 .5rem; padding: .35rem 0; }
  .line { padding: .8rem 2.2rem .15rem .7rem; }
  .ctx-line { padding: 0 2.2rem 0 .7rem; }
  .line-check { right: .35rem; width: 1.5rem; height: 1.5rem; font-size: .95rem; line-height: 1.5rem; }
  /* one row: menu, book.line, Go, and the map as an icon */
  .goto { margin-top: .5rem; gap: .35rem; flex-wrap: wrap; }
  .goto > :not(.goto-msg) { flex-shrink: 0; }
  .goto label { flex: 1 1 0; min-width: 0; }
  .goto .goto-word { display: none; }                      /* no room for "Go to" beside the menu */
  .goto select { width: 100%; min-width: 0; }
  .goto input { width: 4.8rem; flex: 0 0 auto; }
  .goto button:not(.link) { padding: .3rem .55rem; }
  #open-map { margin-left: 0; }
  /* the dock: marks and buttons stay under the thumb */
  .dock {
    order: 10; position: sticky; bottom: 0; z-index: 5;
    margin: .5rem -.75rem -1rem; padding: .5rem .75rem calc(.6rem + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(0, 0, 0, .06);
  }
  .tray { margin-top: 0; gap: .4rem; }
  .chip { flex: 1 1 0; min-width: 0; justify-content: center; gap: .3rem; padding: .5rem .35rem; }
  .chip .word { font-size: clamp(.78rem, 3.9vw, .9rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chip .sym { font-size: 1.25rem; }
  body.fast .chip .key { display: none; }                  /* no room, and usually no keyboard */
  .hint { margin: .4rem 0 .5rem; font-size: .8rem; }
  .toggles { margin-top: .4rem; }
  .actions { flex-wrap: nowrap; gap: .3rem; }
  .actions button { padding: .5rem clamp(.35rem, 2vw, .6rem); font-size: clamp(.8rem, 3.9vw, .92rem); white-space: nowrap; }
  .actions #check { flex: 1; }
  .actions-mid { flex-wrap: nowrap; gap: .3rem; min-width: 0; }
  .actions button.nav { min-width: 0; flex: 0 0 auto; }
  .feedback { margin-top: .4rem; }
  .modal { padding: .75rem; }
  .modal-card { padding: 1rem .8rem; }
}
