/*
 * discamus
 *
 * Mobile first, because spaced repetition happens on a phone at odd moments and
 * the practice screen is the product. Every colour is a custom property defined
 * once on :root and redefined for dark, so a theme is a change of values and
 * never a second stylesheet — vocabu.la shipped dark and let light rot.
 *
 * Spacing and layout use logical properties throughout. A right-to-left
 * language should be a stylesheet's business, not a rewrite.
 */

/* ── tokens ───────────────────────────────────────────────────────── */

:root {
  color-scheme: light;

  --bg: #fcfcfb;
  --surface: #ffffff;
  --surface-sunk: #f2f1ee;
  --border: #dcdad4;
  --border-strong: #b4b1a8;

  --ink: #16150f;
  --ink-muted: #52514e;
  --ink-faint: #77756e;

  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-sunk: #1c5cab;

  /* Fixed status colours. They ship with an icon and a word, never alone. */
  --good: #0ca30c;
  --bad: #d03b3b;

  /* Memory tiers: one hue, monotone lightness, so the order is legible in the
   * colour itself and survives greyscale and colour-vision deficiency.
   * Validated light→dark against this surface. */
  --tier-1: #86b6ef;
  --tier-2: #5598e7;
  --tier-3: #2a78d6;
  --tier-4: #1c5cab;
  --tier-5: #0d366b;

  --focus: #0d366b;

  /* One face for the interface and for both languages on the screen. IBM Plex
   * Sans tells `l` from `I` — 156 units wide against 280, which is the thing
   * that rules Roboto out — and it has the macrons and monotonic Greek. */
  --font-ui: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* The same face, with a fallback the interface has no use for. Gentium
   * catches the two things Plex lacks: y-macron, which the Latin corpus uses
   * five times, and polytonic Greek, which Classical Greek will need.
   * `unicode-range` means it is only fetched when one of them appears. */
  --font-text: 'IBM Plex Sans', 'Gentium Book Plus', system-ui, sans-serif;

  --radius: 10px;
  --radius-sm: 6px;
  --tap: 44px;

  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: 1.375rem;
  --step-3: clamp(1.75rem, 1.2rem + 2.6vw, 2.75rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;

    --bg: #1a1a19;
    --surface: #242422;
    --surface-sunk: #131312;
    --border: #3a3a37;
    --border-strong: #55544f;

    --ink: #f4f3ee;
    --ink-muted: #c3c2b7;
    --ink-faint: #93918a;

    --accent: #3987e5;
    --accent-ink: #0b1220;
    --accent-sunk: #6da7ec;

    --good: #3fbe3f;
    --bad: #e56b6b;

    /* The ramp flips its anchor: on a dark surface prominence is lightness. */
    --tier-1: #184f95;
    --tier-2: #256abf;
    --tier-3: #3987e5;
    --tier-4: #6da7ec;
    --tier-5: #9ec5f4;

    --focus: #9ec5f4;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --bg: #1a1a19;
  --surface: #242422;
  --surface-sunk: #131312;
  --border: #3a3a37;
  --border-strong: #55544f;

  --ink: #f4f3ee;
  --ink-muted: #c3c2b7;
  --ink-faint: #93918a;

  --accent: #3987e5;
  --accent-ink: #0b1220;
  --accent-sunk: #6da7ec;

  --good: #3fbe3f;
  --bad: #e56b6b;

  --tier-1: #184f95;
  --tier-2: #256abf;
  --tier-3: #3987e5;
  --tier-4: #6da7ec;
  --tier-5: #9ec5f4;

  --focus: #9ec5f4;
}

/* ── base ─────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* A guard, not a fix: anything wide enough to need it should scroll inside
   * its own container. But one stray table must not take the page's chrome
   * off the side of the screen. */
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin-block: 0 0.5em;
  font-weight: 600;
}

a {
  color: var(--accent);
}

:where(a, button, input, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  inset-block-start: -100%;
  inset-inline-start: 0;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  z-index: 10;
}
.skip-link:focus {
  inset-block-start: 0;
}

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Foreign text. `lang` is what a screen reader, a hyphenator and font fallback
 * all read, so the selector is the attribute rather than a class somebody has
 * to remember to add. */
[lang]:not([lang|='en']) {
  font-family: var(--font-text);
}

/* ── shell ────────────────────────────────────────────────────────── */

.shell {
  max-inline-size: 42rem;
  margin-inline: auto;
  padding: 1rem;
}

.topbar {
  border-block-end: 1px solid var(--border);
  background: var(--surface);
}

/*
 * The chrome sits over the same column as the content. Full-width it drifted
 * to the far edges of a wide window, a long way from anything it belonged to,
 * and on a narrow one it had nowhere to go and overflowed — which pushes the
 * whole document wider than the viewport and takes the right-hand controls
 * off the screen with it.
 */
.topbar__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  max-inline-size: 42rem;
  margin-inline: auto;
  padding-inline: 1rem;
}

.topbar__brand {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

/*
 * The language frame (ADR 0007). A `<details>`, so it opens and closes with
 * no JavaScript; the menu is a form, so choosing posts.
 *
 * It carries the `margin-inline-end: auto` that used to sit on the brand,
 * which is what keeps the frame beside the name it belongs to and everything
 * else — Progress, theme, sign out — over on the far side.
 */
.frame {
  position: relative;
  margin-inline-end: auto;
}

.frame__current {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-block-size: var(--tap);
  padding-inline: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-size: 0.9375rem;
  cursor: pointer;
  /* The default triangle is replaced by our own chevron, which can sit on the
     correct side of the label in a right-to-left script. */
  list-style: none;
}
.frame__current::-webkit-details-marker {
  display: none;
}
.frame__current:hover {
  background: var(--surface-sunk);
  color: var(--ink);
}
.frame[open] .frame__chevron {
  transform: rotate(180deg);
}
.frame__chevron {
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.frame__menu {
  position: absolute;
  z-index: 20;
  inset-block-start: calc(100% + 0.25rem);
  inset-inline-start: 0;
  /* Wide enough for a name and its count, never wider than a phone. */
  min-inline-size: 15rem;
  max-inline-size: min(22rem, calc(100vw - 2rem));
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 6px 24px rgb(0 0 0 / 12%);
}

.frame__option {
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-areas: 'icon name' 'icon count';
  align-items: center;
  gap: 0 0.6rem;
  inline-size: 100%;
  min-block-size: var(--tap);
  padding: 0.4rem 0.5rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.frame__option:hover {
  background: var(--surface-sunk);
}
/* The framed language, marked by more than colour: it keeps a rule down its
   leading edge, which survives a greyscale screen and a colour-blind reader. */
.frame__option[aria-current='true'] {
  background: var(--surface-sunk);
  box-shadow: inset 3px 0 0 var(--accent);
  font-weight: 600;
}
.frame__option--all {
  border-block-start: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  margin-block-start: 0.25rem;
}

.frame__icon {
  grid-area: icon;
  inline-size: 28px;
  block-size: 28px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.frame__icon--none {
  background: var(--surface-sunk);
  box-shadow: inset 0 0 0 1px var(--border);
}
.frame__current .frame__icon {
  inline-size: 22px;
  block-size: 22px;
}
.frame__name {
  grid-area: name;
}
.frame__count {
  grid-area: count;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--ink-faint);
}

.iconbutton {
  display: inline-grid;
  place-items: center;
  min-inline-size: var(--tap);
  min-block-size: var(--tap);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
}
.iconbutton:hover {
  background: var(--surface-sunk);
  color: var(--ink);
}
.iconbutton svg {
  inline-size: 22px;
  block-size: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── buttons ──────────────────────────────────────────────────────── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-block-size: var(--tap);
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.button:hover {
  border-color: var(--ink-faint);
}
.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.button--primary:hover {
  background: var(--accent-sunk);
  border-color: var(--accent-sunk);
}
.button--quiet {
  border-color: transparent;
  background: none;
  color: var(--ink-muted);
}
.button--quiet:hover {
  background: var(--surface-sunk);
  color: var(--ink);
}
.button--block {
  inline-size: 100%;
}
.button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── the practice screen ──────────────────────────────────────────── */

.practice {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
}

.status {
  display: grid;
  /* The first column is fixed. Left to size itself it followed the tier
   * label, so 'NEW' and 'LEARNING' were different widths and the mascot and
   * the progress bar jumped sideways whenever the tier changed — which is
   * every time a verdict appears. */
  grid-template-columns: 5rem auto 1fr;
  align-items: center;
  gap: 0.75rem;
  margin-block-end: 1.25rem;
}

/* Memory tier. Five boxes reading upward: the count is the signal, the ramp
 * is the reinforcement. Colour alone never says which tier this is — the
 * number of filled boxes does, and the label spells it out. */
.meter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.meter__boxes {
  display: flex;
  flex-direction: column-reverse;
  gap: 3px;
}

/* The name is not decoration. A gauge with no label was read as progress
 * through the session, which is the bar on the other side of the mascot. */
.meter__label {
  max-inline-size: 5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.meter__box {
  inline-size: 14px;
  block-size: 9px;
  border-radius: 2px;
  background: var(--surface-sunk);
  box-shadow: inset 0 0 0 1px var(--border);
}
.meter__box[data-tier='1'] { background: var(--tier-1); box-shadow: none; }
.meter__box[data-tier='2'] { background: var(--tier-2); box-shadow: none; }
.meter__box[data-tier='3'] { background: var(--tier-3); box-shadow: none; }
.meter__box[data-tier='4'] { background: var(--tier-4); box-shadow: none; }
.meter__box[data-tier='5'] { background: var(--tier-5); box-shadow: none; }

.mascot {
  inline-size: 84px;
  block-size: 84px;
  display: block;
}

.status__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.progress {
  inline-size: 100%;
  block-size: 6px;
  border-radius: 3px;
  background: var(--surface-sunk);
  overflow: hidden;
}
.progress__fill {
  block-size: 100%;
  background: var(--accent);
  transition: inline-size 240ms ease;
}

.question__label {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-block-end: 0.35rem;
}

.question__stem {
  font-size: var(--step-3);
  font-weight: 600;
  line-height: 1.15;
  margin-block-end: 1.25rem;
  overflow-wrap: break-word;
}

/* One column at 360px. Two only when a second genuinely fits, because a
 * squeezed pair of options is worse than a list. */
.options {
  display: grid;
  gap: 0.5rem;
  margin-block-end: 0.5rem;
}
@media (min-width: 30rem) {
  .options {
    grid-template-columns: 1fr 1fr;
  }
}

.option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-block-size: var(--tap);
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--step-1);
  text-align: start;
  cursor: pointer;
}
.option:hover {
  border-color: var(--accent);
}
.option__ordinal {
  flex: none;
  display: grid;
  place-items: center;
  inline-size: 1.6rem;
  block-size: 1.6rem;
  border-radius: 50%;
  background: var(--surface-sunk);
  color: var(--ink-faint);
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font-ui);
}

.answer {
  display: flex;
  gap: 0.5rem;
}
.answer__input {
  flex: 1;
  min-inline-size: 0;
  min-block-size: var(--tap);
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--step-1);
}
.answer__input::placeholder {
  color: var(--ink-faint);
}

/* ── the verdict ──────────────────────────────────────────────────── */

/*
 * This replaces the answer form rather than covering it. vocabu.la disabled
 * the buttons behind a modal, which left a text box a learner could still
 * type the right answer into after being told they were wrong. A form that no
 * longer exists cannot be answered twice.
 */
.verdict {
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface-sunk);
}
.verdict__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: var(--step-1);
}
.verdict--right .verdict__head {
  color: var(--good);
}
.verdict--wrong .verdict__head {
  color: var(--bad);
}
.verdict__head svg {
  inline-size: 1.25rem;
  block-size: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.verdict__detail {
  margin-block: 0.5rem 0;
  color: var(--ink-muted);
}
.verdict__answer {
  color: var(--ink);
  font-size: var(--step-2);
  font-weight: 600;
}
.verdict__given {
  text-decoration: line-through;
  text-decoration-color: var(--bad);
}
.verdict__actions {
  margin-block-start: 0.9rem;
}

/* ── ending ───────────────────────────────────────────────────────── */

.tally {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.75rem;
  margin-block: 1.25rem;
}
.tally__cell {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  background: var(--surface);
}
.tally__label {
  font-size: 0.8125rem;
  color: var(--ink-faint);
}
.tally__value {
  font-size: var(--step-2);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.notice {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.25rem;
  color: var(--ink-muted);
}

.stack > * + * {
  margin-block-start: 1rem;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.push {
  margin-inline-start: auto;
}

/*
 * The accent keys, under a typed answer. Answers require their diacritics,
 * and this is what makes that reasonable on a phone.
 *
 * It scrolls rather than wraps: Greek offers eleven, and a row that reflows to
 * two lines moves the Check button down between one question and the next.
 */
.keys {
  display: flex;
  gap: 0.35rem;
  margin-block-start: 0.5rem;
  padding-block-end: 0.2rem;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}
.keys__key {
  flex: none;
  min-inline-size: var(--tap);
  min-block-size: var(--tap);
  padding-inline: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
}
.keys__key:hover {
  background: var(--surface-sunk);
  border-color: var(--border-strong);
}
.keys__key:active {
  background: var(--surface-sunk);
  transform: translateY(1px);
}

/* ── the workspace ────────────────────────────────────────────────── */

/* `.worklist` is a list of words in the workspace, and both lists are one:
   what needs a person, and every word there is. The second shows a gloss
   where the first does not, and nothing else about a row differs. */
.doors {
  margin-block-start: 0.75rem;
}

.find {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-block: 1rem;
}
.find__label {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  color: var(--ink-muted);
}
.find__input {
  flex: 1 1 14rem;
  min-block-size: var(--tap);
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.pager {
  display: flex;
  gap: 0.5rem;
  margin-block-start: 1rem;
}

.worklist {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}
.worklist__row {
  padding-block: 0.6rem;
  border-block-start: 1px solid var(--border);
}
.worklist__word {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-block-size: var(--tap);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  text-decoration: none;
}
.worklist__word:hover {
  text-decoration: underline;
}
.worklist__pos {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-faint);
}
.worklist__gloss {
  margin: 0.1rem 0 0;
  font-size: 0.875rem;
  color: var(--ink-muted);
}
.worklist__notes,
.notes {
  list-style: none;
  margin: 0.15rem 0 0;
  padding: 0;
}

/* Severity carries a word as well as a colour, because the message says which
   it is — colour is never the only signal. */
.note {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  padding-inline-start: 0.6rem;
  border-inline-start: 2px solid var(--border-strong);
}
.note--error {
  border-inline-start-color: var(--bad);
  color: var(--ink);
}

.curate {
  margin-block: 1rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-block: 0 1rem;
}
.field label {
  font-weight: 600;
  font-size: 0.9375rem;
}
.field input[type='text'],
.field textarea,
.field select {
  inline-size: 100%;
  min-block-size: var(--tap);
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-family: var(--font-text);
}
.field ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
.field__help {
  font-size: 0.8125rem;
  color: var(--ink-faint);
}
.field__error {
  font-size: 0.8125rem;
  color: var(--bad);
}
.curate__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* One meaning per card, because a gloss is four questions at once: what it
   says, what it is written in, which lessons teach it, and whether it goes. */
.glosses {
  list-style: none;
  margin: 0.25rem 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.gloss {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.gloss > .field:last-child,
.gloss > fieldset:last-child {
  margin-block-end: 0;
}
.gloss__said {
  display: grid;
  grid-template-columns: 1fr 7rem;
  gap: 0 0.75rem;
}
@media (max-width: 30rem) {
  .gloss__said {
    grid-template-columns: 1fr;
  }
}
.gloss__taught {
  border: 0;
  padding: 0;
  margin-inline: 0;
}
.gloss__taught legend {
  padding: 0;
  font-weight: 600;
  font-size: 0.9375rem;
}

/* The lessons themselves, capped in height because Latin teaches from 51 of
   them and a word can have eight senses; rows clear the 24px AA target size
   without pretending a dense list is a practice screen. */
.gloss__lessons {
  max-block-size: 12rem;
  overflow-y: auto;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.gloss__lessons > div {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0 1rem;
}
.gloss__lessons label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-block-size: 1.75rem;
  font-weight: 400;
  font-size: 0.875rem;
}
.gloss__remove {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.gloss__remove label {
  font-weight: 400;
  color: var(--ink-muted);
}

/* The column mapping of a pasted list. A table with a select over each column
   and the first few rows beneath it, so the choice is made next to the data it
   is about rather than against a list of column numbers. It is the one place
   in the workspace with a genuinely wide layout — a Latin list can be eight
   columns — so it scrolls inside its own box and never the page. */
.table-scroll {
  overflow-x: auto;
  margin-block-end: 1rem;
}
.mapping {
  border-collapse: collapse;
  font-size: 0.875rem;
}
.mapping th {
  text-align: start;
  padding: 0.35rem 0.5rem;
  border-block-end: 1px solid var(--border-strong);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-faint);
  white-space: nowrap;
}
.mapping td {
  padding: 0.35rem 0.5rem;
  border-block-end: 1px solid var(--border);
  vertical-align: top;
}
.mapping select {
  min-block-size: var(--tap);
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.8125rem;
}
/* Samples are evidence, not content: enough of a cell to recognise the column
   by, and never enough to stretch the table past reading width. */
.mapping__sample {
  max-inline-size: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-muted);
}

.facts {
  list-style: none;
  margin: 0.25rem 0 1rem;
  padding: 0;
}
.facts__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding-block: 0.35rem;
  border-block-start: 1px solid var(--border);
}
.facts__label {
  min-inline-size: 9rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
}
.facts__value {
  font-family: var(--font-text);
  font-size: 1.0625rem;
}
.facts__origin {
  margin-inline-start: auto;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

/* ── motion ───────────────────────────────────────────────────────── */

.htmx-swapping {
  opacity: 0;
  transition: opacity 90ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── choosing what to practise ────────────────────────────────────── */

.door {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.75rem 1rem;
  margin-block-end: 0.5rem;
}
.door__name {
  font-weight: 600;
  font-size: var(--step-1);
}
.door__count {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.door__count--quiet {
  color: var(--ink-faint);
  font-weight: 400;
}

.collection {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-block-end: 0.5rem;
}
.collection > summary {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  min-block-size: var(--tap);
  padding: 0.7rem 1rem;
  cursor: pointer;
  border-radius: var(--radius);
}
.collection > summary::marker {
  color: var(--ink-faint);
}
.collection__name {
  font-weight: 600;
}

.lesson {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-block-size: var(--tap);
  padding: 0.35rem 1rem 0.35rem 2rem;
  border-block-start: 1px solid var(--border);
  cursor: pointer;
}
.lesson:hover {
  background: var(--surface-sunk);
}
.lesson input {
  inline-size: 1.15rem;
  block-size: 1.15rem;
  flex: none;
  accent-color: var(--accent);
}

/* ── meeting a word ───────────────────────────────────────────────── */

.intro__chips {
  margin-block: -0.75rem 1rem;
}
.chip {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 600;
}
.chip--quiet {
  background: var(--surface-sunk);
  color: var(--ink-muted);
  box-shadow: inset 0 0 0 1px var(--border);
}

.forms {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 0.9rem;
  margin: 0 0 1rem;
  padding-block-start: 0.9rem;
  border-block-start: 1px solid var(--border);
}
.forms dt {
  color: var(--ink-faint);
  font-size: 0.8125rem;
  align-self: baseline;
}
.forms dd {
  margin: 0;
  font-weight: 500;
}

.glosses {
  margin: 0 0 1.25rem;
  padding-inline-start: 1.4rem;
  padding-block-start: 0.9rem;
  border-block-start: 1px solid var(--border);
  font-size: var(--step-1);
}
.glosses li {
  margin-block-end: 0.2rem;
}

/* ── the report ───────────────────────────────────────────────────── */

/* Each figure is a link into the list below, so it has to look pressable. */
a.tally__cell {
  display: block;
  color: inherit;
  text-decoration: none;
}
a.tally__cell:hover {
  border-color: var(--accent);
}
a.tally__cell[aria-current] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.tally__cell .tally__label,
.tally__cell .tally__value {
  display: block;
}
.tally__of {
  color: var(--ink-faint);
  font-weight: 400;
  font-size: var(--step-0);
}
.tally__hint {
  display: block;
  margin-block-start: 0.15rem;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

/* The tier chart. A row per tier, and the description gets its own line
 * rather than a column squeezed to nothing on a phone. */
.tiers {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}
.tiers__link {
  display: block;
  padding: 0.6rem 0.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.tiers__link:hover {
  background: var(--surface);
  border-color: var(--border);
}
.tiers__link[aria-current] {
  background: var(--surface);
  border-color: var(--accent);
}
.tiers__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.tiers__name {
  font-weight: 600;
}
.tiers__count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.tiers__track {
  display: block;
  block-size: 8px;
  margin-block: 0.35rem 0.3rem;
  border-radius: 4px;
  background: var(--surface-sunk);
  box-shadow: inset 0 0 0 1px var(--border);
  overflow: hidden;
}
.tiers__fill {
  display: block;
  block-size: 100%;
  min-inline-size: 2px;
  border-radius: 4px;
}
.tiers__note {
  display: block;
  font-size: 0.8125rem;
  color: var(--ink-faint);
}

/* One mark per card. Height carries the tier as well as colour, so the row
 * reads in greyscale and to anyone who cannot separate the blues — and the
 * word opens to a list that names every facet in words. */
.facets {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  block-size: 16px;
}
.facets__mark {
  inline-size: 6px;
  border-radius: 1px;
  background: var(--surface-sunk);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.facets__mark[data-tier='0'] { block-size: 3px; }
.facets__mark[data-tier='1'] { block-size: 6px;  background: var(--tier-1); box-shadow: none; }
.facets__mark[data-tier='2'] { block-size: 9px;  background: var(--tier-2); box-shadow: none; }
.facets__mark[data-tier='3'] { block-size: 12px; background: var(--tier-3); box-shadow: none; }
.facets__mark[data-tier='4'] { block-size: 15px; background: var(--tier-4); box-shadow: none; }
.facets__mark[data-tier='5'] { block-size: 18px; background: var(--tier-5); box-shadow: none; }

.tiers__fill[data-tier='0'] { background: var(--border-strong); }
.tiers__fill[data-tier='1'] { background: var(--tier-1); }
.tiers__fill[data-tier='2'] { background: var(--tier-2); }
.tiers__fill[data-tier='3'] { background: var(--tier-3); }
.tiers__fill[data-tier='4'] { background: var(--tier-4); }
.tiers__fill[data-tier='5'] { background: var(--tier-5); }

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-block-end: 1.25rem;
}
.pill {
  padding: 0.35rem 0.8rem;
  min-block-size: var(--tap);
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.pill[aria-current] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.wordlist {
  list-style: none;
  margin: 0;
  padding: 0;
}
.word {
  border-block-end: 1px solid var(--border);
}
.word > summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-block-size: var(--tap);
  padding: 0.4rem 0.25rem;
  cursor: pointer;
}
.word > summary::marker {
  color: var(--ink-faint);
}
.word__head {
  font-weight: 600;
  font-size: var(--step-1);
  margin-inline-end: auto;
  overflow-wrap: anywhere;
}
.word__score {
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  min-inline-size: 3ch;
  text-align: end;
}
.word__facets {
  inline-size: 100%;
  border-collapse: collapse;
  margin: 0 0 0.75rem;
  padding-inline-start: 1.5rem;
  font-size: 0.9375rem;
}
.word__facets th {
  text-align: start;
  font-weight: 500;
  padding: 0.25rem 0.5rem 0.25rem 1.5rem;
}
.word__facets td {
  padding: 0.25rem 0.5rem;
  color: var(--ink-muted);
}
.word__facets .facets__mark {
  display: inline-block;
  margin-inline-end: 0.5rem;
  vertical-align: baseline;
}
.word__recall {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── the shelf ────────────────────────────────────────────────────── */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-block-end: 0.75rem;
  font-size: 0.875rem;
  color: var(--ink-faint);
}
.crumbs a {
  color: var(--ink-muted);
  text-decoration: none;
  padding-block: 0.35rem;
}
.crumbs a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.6rem;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.tile {
  position: relative;
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.tile:hover {
  border-color: var(--accent);
}

.tile__body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-block-size: 4.25rem;
  padding: 0.75rem 0.85rem;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius);
}
.tile__label {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.tile__sub {
  font-size: 0.8125rem;
  color: var(--ink-faint);
}
.tile__more {
  position: absolute;
  inset-block-start: 0.6rem;
  inset-inline-end: 0.7rem;
  color: var(--ink-faint);
}

/* The checkbox and the info button sit above the tile's own link rather than
 * inside it: a control nested in an anchor is not operable by keyboard. */
.tile__pick {
  position: absolute;
  inset-block-start: 0.4rem;
  inset-inline-end: 0.4rem;
  display: grid;
  place-items: center;
  inline-size: 1.9rem;
  block-size: 1.9rem;
}
.tile__pick input {
  inline-size: 1.1rem;
  block-size: 1.1rem;
  accent-color: var(--accent);
}
.tile__info {
  position: absolute;
  inset-block-end: 0.3rem;
  inset-inline-end: 0.3rem;
  display: grid;
  place-items: center;
  inline-size: 2rem;
  block-size: 2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}
.tile__info:hover {
  color: var(--accent);
  background: var(--surface-sunk);
}
.tile__info svg {
  inline-size: 17px;
  block-size: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.shelf-combine {
  margin: 0 0 0.5rem;
}

/* ── the settings sheet ───────────────────────────────────────────── */

/*
 * A native dialog: focus trapping, Escape and the backdrop come with it, and
 * a hand-rolled modal reimplements all three badly. On a phone it rises from
 * the bottom, which is where a thumb is.
 */
.sheet {
  inline-size: min(30rem, 100%);
  max-block-size: 85dvh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  overflow: auto;
}
.sheet::backdrop {
  background: rgb(0 0 0 / 0.45);
}
@media (max-width: 34rem) {
  .sheet {
    inline-size: 100%;
    max-inline-size: 100%;
    margin: auto 0 0;
    border-radius: var(--radius) var(--radius) 0 0;
  }
}

.sheet__body {
  padding: 0.9rem 1rem 1.1rem;
}
.sheet__head {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-block-end: 0.25rem;
}
.sheet__title {
  flex: 1;
  margin: 0;
  font-size: var(--step-1);
  overflow-wrap: anywhere;
}

.sheet__settings {
  margin-block: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sheet__settings > summary {
  min-block-size: var(--tap);
  display: flex;
  align-items: center;
  padding: 0.6rem 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.sheet__limit {
  margin-block-end: 1rem;
}
.sheet__limit .answer__input {
  max-inline-size: 8rem;
}

/* When there is no dialog to hold it, the sheet is simply a page. */
.shell > .sheet__body {
  padding-inline: 0;
}

.wordpeek {
  list-style: none;
  margin: 0.5rem 0 1rem;
  padding: 0;
  max-block-size: 45dvh;
  overflow: auto;
}
.wordpeek li {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding-block: 0.3rem;
  border-block-end: 1px solid var(--border);
}
.wordpeek__word {
  font-weight: 600;
  min-inline-size: 8ch;
}
.wordpeek__gloss {
  color: var(--ink-muted);
  font-size: 0.9375rem;
}

/* ── the settings drawer ──────────────────────────────────────────── */

.options-group {
  border: 0;
  border-block-start: 1px solid var(--border);
  margin: 0;
  padding: 0.5rem 0 0.6rem;
}
.options-group legend {
  padding: 0.6rem 1rem 0.1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.options-group .lesson {
  border-block-start: 0;
}

/* ── meeting a word ───────────────────────────────────────────────── */

/*
 * Its own screen inside the same page. The status strip above it is hidden
 * while it is showing: the mascot, the meter and the progress bar all say
 * "you are being asked something", and here nothing is.
 */
.practice:has(.intro) .status {
  display: none;
}

.intro {
  padding-block: 0.5rem 0.25rem;
}

.intro__counter {
  margin: 0 0 0.9rem;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.intro__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  border: 1px solid var(--accent);
  background: color-mix(in oklab, var(--accent) 12%, transparent);
  color: var(--accent-sunk);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.chip--pos {
  border-color: var(--border-strong);
  background: var(--surface-sunk);
  color: var(--ink-muted);
}

.intro__headword {
  margin: 0.6rem 0 0.3rem;
  font-size: var(--step-3);
  font-weight: 500;
  line-height: 1.1;
  overflow-wrap: break-word;
}

/* One flowing line of forms, each label small above its value. */
.intro__forms {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0;
  margin: 0 0 0.9rem;
  font-size: var(--step-1);
  color: var(--ink-muted);
}
.intro__form {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}
.intro__form-label {
  font-size: 0.625rem;
  line-height: 1;
  margin-block-end: 3px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}
.intro__form-value {
  color: var(--ink);
}
.intro__dot {
  align-self: flex-end;
  padding-inline: 0.55rem;
  color: var(--ink-faint);
  user-select: none;
}

.intro__rule {
  block-size: 1px;
  background: var(--border);
  margin-block: 0.25rem 0.9rem;
}

.intro__meanings {
  margin: 0 0 0.5rem;
  padding-inline-start: 1.5rem;
  font-size: var(--step-1);
}
.intro__meanings li {
  margin-block-end: 0.35rem;
}

.intro__go {
  display: flex;
  justify-content: flex-end;
  margin-block-start: 1.25rem;
}
.intro__button {
  border-color: var(--accent);
  color: var(--accent-sunk);
  background: none;
}
.intro__button:hover {
  background: color-mix(in oklab, var(--accent) 12%, transparent);
  border-color: var(--accent);
}

/* An answer that is right about the word but not about this lesson. Marked
 * apart from a plain wrong answer, because it is a different thing. */
.verdict__elsewhere {
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}

/* What a lesson still holds that has not been asked about. */
.untouched {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
}
.untouched li {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.875rem;
  color: var(--ink-muted);
}
.untouched__count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* A tier row that is a statement rather than a link. */
span.tiers__link {
  display: block;
  padding: 0.6rem 0.75rem;
}

/* How far into a lesson the learner already is, on its tile. */
.tile__bar {
  display: block;
  block-size: 4px;
  margin-block-start: 0.35rem;
  border-radius: 2px;
  background: var(--surface-sunk);
  box-shadow: inset 0 0 0 1px var(--border);
  overflow: hidden;
}
.tile__bar-fill {
  display: block;
  block-size: 100%;
  min-inline-size: 2px;
  border-radius: 2px;
  background: var(--tier-3);
}

/* A door that carries a bar and a note under its row. */
.door--stacked {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.4rem 0.75rem;
  align-items: center;
}
.door__bar {
  grid-column: 1 / -1;
  block-size: 6px;
  border-radius: 3px;
  background: var(--surface-sunk);
  box-shadow: inset 0 0 0 1px var(--border);
  overflow: hidden;
}
.door__bar-fill {
  display: block;
  block-size: 100%;
  min-inline-size: 2px;
  border-radius: 3px;
  background: var(--tier-3);
}
.door__note {
  grid-column: 1 / -1;
}

/* When this card comes back — the one signal that moves on every answer. */
.verdict__when {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-block: 0.75rem 0;
  color: var(--ink-muted);
  font-size: 0.9375rem;
}
.verdict__when svg {
  inline-size: 1rem;
  block-size: 1rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* ── credits ──────────────────────────────────────────────────────── */

.footer {
  max-inline-size: 42rem;
  margin: 2.5rem auto 1.5rem;
  padding-inline: 1rem;
  font-size: 0.875rem;
}
.footer a {
  color: var(--ink-faint);
}

.credits {
  list-style: none;
  margin: 1.5rem 0;
  padding: 0;
}
.credit {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  padding-block: 0.9rem;
  border-block-start: 1px solid var(--border);
}
.credit__thumb {
  inline-size: 56px;
  block-size: 56px;
  flex: none;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-sunk);
}
.credit__title {
  margin: 0 0 0.15rem;
  font-weight: 600;
}
.credit__line {
  margin: 0;
  font-size: 0.875rem;
  color: var(--ink-muted);
}

/* A language's picture on its tile. Decorative — the name is beside it. */
.tile__icon {
  inline-size: 44px;
  block-size: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  margin-block-end: 0.35rem;
}

.credit__thumb--none {
  display: block;
  background: var(--surface-sunk);
  box-shadow: inset 0 0 0 1px var(--border);
}
.credit__note {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--ink-faint);
}
