/* Fluo. Paper, ink, and one highlighter.
   The yellow means one thing only: what you do not know yet (a marked word, a marked phrase, a count of gaps).
   Nothing else is yellow, the logo apart. English is set in the serif; everything the app says is in the sans. */
:root {
  --paper: #ffffff;
  --desk: #f6f6f3;
  --ink: #1b1b18;
  --muted: #6c6c64;
  --faint: #a3a39a;
  --rule: #e9e9e4;
  --rule-strong: #d5d5ce;
  --soft: #f3f3ef;
  --hover: rgba(27, 27, 24, 0.05);
  --press: rgba(27, 27, 24, 0.09);
  --fluo: #f4f03c;
  --fluo-ink: #1b1b18;
  --learned: #1e7a52;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(27, 27, 24, 0.06), 0 12px 32px rgba(27, 27, 24, 0.14);
  --sans: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --phonetic: system-ui, -apple-system, 'Segoe UI', 'Noto Sans', sans-serif;
  --gutter: 40px;
  --side: 232px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #191918;
    --desk: #121211;
    --ink: #ecece6;
    --muted: #9d9d94;
    --faint: #6d6d66;
    --rule: #2c2c2a;
    --rule-strong: #3d3d3a;
    --soft: #222221;
    --hover: rgba(236, 236, 230, 0.06);
    --press: rgba(236, 236, 230, 0.11);
    --fluo: #ece83a;
    --learned: #63c69b;
    --danger: #f2877f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
button:disabled { opacity: 0.35; cursor: default; }
a { color: inherit; }
p { margin: 0; }

h1, h2, h3 { margin: 0; font-family: var(--sans); font-weight: 650; }
h1 { font-size: 24px; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 16px; line-height: 1.3; letter-spacing: -0.01em; }
h3 { font-size: 15px; line-height: 1.3; }

/* ---- The highlighter ----
   One stroke of a marker behind a word: slanted ends, a hair off the baseline, never a plain rectangle.
   On one line (a word, a count, the logo) it is drawn by a layer behind the text. */
.hl, .marked, .word[data-status='unknown'] .mark, .related-gap, .nav-count, .logo-word {
  position: relative;
  z-index: 0;
  color: var(--fluo-ink);
  white-space: nowrap;
}
.hl::before, .marked::before, .word[data-status='unknown'] .mark::before, .related-gap::before, .nav-count::before, .logo-word::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0.1em -0.3em 0.04em;
  background: var(--fluo);
  border-radius: 0.14em 0.42em 0.2em 0.46em / 0.4em 0.2em 0.5em 0.24em;
  transform: skewX(-9deg) rotate(-0.7deg);
  transform-origin: 0 50%;
}
/* Over several lines (a phrase, the word being learned inside its sentences) it is a band of colour that follows the text. */
.phrase[aria-pressed='true'] .phrase-en, .learn .detail-example strong, .band {
  margin: 0 -0.2em;
  padding: 0 0.2em;
  border-radius: 3px;
  background: linear-gradient(var(--fluo), var(--fluo)) no-repeat 0 72% / 100% 80%;
  color: var(--fluo-ink);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
/* The stroke is drawn once, on the word or the phrase just touched; the others hold still. */
@keyframes stroke { from { scale: 0 1; } }
@keyframes band { from { background-size: 0% 80%; } }
.word[data-fresh][data-status='unknown'] .mark::before { animation: stroke 200ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.phrase[data-fresh][aria-pressed='true'] .phrase-en { animation: band 260ms cubic-bezier(0.2, 0.7, 0.2, 1); }

/* ---- The frame: a sidebar and the page ---- */
.side {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  background: var(--desk);
  border-right: 1px solid var(--rule);
  overflow-y: auto;
}
.logo { align-self: flex-start; display: inline-flex; margin: 0 0 22px 12px; padding: 4px 2px; text-decoration: none; }
.logo-word { font: 800 25px/1 var(--sans); letter-spacing: -0.045em; }
.logo-word::before { inset: 0.02em -0.26em -0.06em -0.22em; transform: skewX(-11deg) rotate(-2deg); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  font-weight: 500;
  text-decoration: none;
  transition: background 120ms;
}
.nav-item svg { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.nav-item .nav-fluo { fill: var(--fluo); stroke: none; }
.nav-item:hover { background: var(--hover); }
.nav-item[aria-current='page'] { background: var(--press); font-weight: 650; }
.nav-item[aria-current='page'] svg { color: var(--ink); }
.nav-group { margin: 18px 0 4px; padding: 0 10px; font-size: 12px; font-weight: 500; color: var(--muted); }
.nav-short { display: none; }
.nav-count { margin-left: auto; margin-right: 4px; font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.nav-count:empty { display: none; }
.side-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 12px 10px 0; min-height: 30px; font-size: 12px; color: var(--muted); }
.side-foot .save-status { flex: 1; min-width: 0; }
/* The language switch names the other language, as on the portfolio: « EN » on the French interface. */
.lang-switch { flex: none; height: 28px; margin-left: auto; padding: 0 8px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: 0.04em; }
.lang-switch:hover { background: var(--hover); color: var(--ink); }
/* The demo says so where the answers would say they are saved. */
.demo-tag { display: none; }
body.demo .demo-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 5px; background: var(--soft); box-shadow: inset 0 0 0 1px var(--rule-strong); color: var(--ink); font-weight: 600; cursor: help; }
.save-status { font-size: 12px; color: var(--muted); }

.page { min-width: 0; }
/* One container sets the horizontal padding for every block: headers and content share its edges. */
.col { max-width: 960px; margin: 0 auto; padding-inline: var(--gutter); }
main { padding-top: 36px; padding-bottom: 96px; container: view / inline-size; }

/* Head of a screen: its name on the left, its one control on the right. */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; min-height: 36px; }
.hint { margin: 10px 0 0; max-width: 72ch; color: var(--muted); }
.empty { margin-top: 12px; max-width: 60ch; color: var(--muted); }
.credit { margin-top: 64px; max-width: 76ch; font-size: 12px; line-height: 1.5; color: var(--muted); }
.credit a { text-underline-offset: 2px; }

/* A choice between two: the list of words. */
.segmented { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--soft); box-shadow: inset 0 0 0 1px var(--rule); }
.segmented button { height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed='true'] { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--rule-strong), 0 1px 2px rgba(27, 27, 24, 0.08); }

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 120ms;
}
.primary:hover { opacity: 0.86; }
.ghost { min-height: 30px; padding: 4px 10px; border: 1px solid var(--rule-strong); border-radius: 7px; background: none; font-size: 13px; font-weight: 500; transition: background 120ms; }
.ghost:hover:not(:disabled) { background: var(--hover); }
a.ghost { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
.text-link { display: inline-block; font-size: 13px; font-weight: 600; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 4px; }
.text-link:hover { text-decoration-color: var(--ink); }

/* A thin line that fills: how much of something is done. */
.meter { display: block; height: 4px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 2px; background: var(--ink); }

/* ---- Dashboard ---- */
.level { margin-top: 28px; }
.level-lead { max-width: 24ch; font-size: 36px; line-height: 1.1; font-weight: 650; letter-spacing: -0.03em; text-wrap: balance; }
.level-text { margin-top: 14px; max-width: 68ch; font-size: 15px; line-height: 1.55; color: var(--muted); }

/* The page of a band (lib/band-page.js): one dash per word. Ink: known at first sight; under a stroke of highlighter:
   a gap; green: learned since; pale: not read yet. A paragraph on the Mots screen, a narrow column on the dashboard. */
.page { display: block; }
.page-svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.page-unseen { stroke: var(--rule-strong); }
.page-known { stroke: var(--ink); }
.page-learned { stroke: var(--learned); }
.page-gap { stroke: var(--fluo-ink); }
.page-stroke { fill: var(--fluo); stroke: none; }

/* The measure: Nation's ten bands side by side, each as a column of its page. */
.measure { list-style: none; margin: 32px 0 0; padding: 0; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 0 16px; }
.measure-band { display: grid; align-content: start; padding-bottom: 4px; text-decoration: none; }
.measure-k { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.measure-tag { min-height: 2.6em; font-size: 12px; line-height: 1.3; color: var(--faint); }
.measure-band[data-reached='true'] .measure-tag { color: var(--ink); }
.measure-band .page { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule); transition: border-color 120ms; }
.measure-band:hover .page { border-top-color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 18px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 16px; height: 3px; }
.m-known { background: var(--ink); }
.m-unknown { background: var(--fluo-ink); box-shadow: 0 0 0 3px var(--fluo); }
.m-learned { background: var(--learned); }
.m-unseen { background: var(--rule-strong); }
.legend .legend-note { flex-basis: 100%; }

.board { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 56px; margin-top: 48px; }
.work-list { list-style: none; margin: 12px 0 0; padding: 0; border-bottom: 1px solid var(--rule); }
.work {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 104px;
  grid-template-areas: 'name count go' 'where meter go';
  align-items: center;
  gap: 2px 20px;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
  text-decoration: none;
}
.work-name { grid-area: name; font-size: 15px; font-weight: 600; }
.work-where { grid-area: where; min-width: 0; font-size: 13px; color: var(--muted); }
.work-count { grid-area: count; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.work-count small { font-size: 13px; font-weight: 400; color: var(--muted); }
.work .meter { grid-area: meter; width: 148px; justify-self: end; }
.work-go { grid-area: go; justify-self: end; display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: 7px; font-size: 13px; font-weight: 500; transition: background 120ms, color 120ms, border-color 120ms; }
.work:hover .work-go { background: var(--ink); border-color: var(--ink); color: var(--paper); }

@container view (max-width: 760px) {
  .board { grid-template-columns: minmax(0, 1fr); gap: 44px; }
}
.review-count { margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); }
.review .empty { padding-top: 14px; border-top: 1px solid var(--rule); }
.review-words a { text-decoration: none; }
.review-words a:hover .hl::before { filter: brightness(0.94); }
.review-words { list-style: none; margin: 14px 0 0; padding: 0 0.3em; display: flex; flex-wrap: wrap; gap: 6px 22px; font: 400 21px/1.4 var(--serif); }
.review .text-link { margin-top: 18px; }

/* ---- Mots: what was read and highlighted, then one band after the other, each as its page ---- */
.words-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.words-say { font-size: 44px; line-height: 1.06; font-weight: 700; letter-spacing: -0.035em; }
.words-about { margin-top: 16px; max-width: 64ch; font-size: 15px; line-height: 1.55; color: var(--muted); }
.words-about strong { font-weight: 600; color: var(--ink); }

/* A band: its name, its page, and on the right its way in, its figures and its detail. */
.band-list { list-style: none; margin: 36px 0 0; padding: 0; border-bottom: 1px solid var(--rule); }
.band-row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) 168px;
  grid-template-areas: 'name page go' 'name page figs' 'name page more' '. detail detail';
  grid-template-rows: auto auto 1fr auto;
  column-gap: 24px;
  align-items: start;
  padding: 22px 0 24px;
  border-top: 1px solid var(--rule);
}
.band-name { grid-area: name; display: grid; }
.band-k { font-size: 32px; line-height: 1; font-weight: 700; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.band-tag { margin-top: 8px; font-size: 13px; line-height: 1.3; font-weight: 600; }
.band-range { font-size: 12px; line-height: 1.4; color: var(--muted); white-space: nowrap; }
.band-k + .band-range { margin-top: 8px; }
.band-row[data-state='new'] .band-k { color: var(--faint); }
.band-row[data-state='new'] .band-tag { color: var(--muted); }
.band-page { grid-area: page; display: block; padding-top: 2px; text-decoration: none; }
.band-go { grid-area: go; justify-self: end; display: inline-flex; align-items: center; height: 32px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; text-decoration: none; }
.band-go:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 4px; }
/* The band in progress is the one to open: its way in looks like a button. */
.band-row[data-state='going'] .band-go { padding: 0 12px; border-radius: 7px; background: var(--ink); color: var(--paper); text-decoration: none; }
.band-figs { grid-area: figs; display: grid; justify-items: end; gap: 2px; margin-top: 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.band-figs strong { font-weight: 600; color: var(--ink); }
.band-figs .hl { margin: 0 0.25em; font-weight: 600; }
.band-more { grid-area: more; justify-self: end; display: inline-flex; align-items: center; gap: 4px; height: 32px; margin-top: 6px; padding: 0; border: 0; background: none; font-size: 13px; color: var(--muted); }
.band-more:hover { color: var(--ink); }
.band-more svg { transition: rotate 160ms; }
.band-more[aria-expanded='true'] svg { rotate: 180deg; }
.band-detail { grid-area: detail; margin-top: 20px; }
.band-words { margin-top: 0; padding: 0 0.3em; }
.band-quiet { color: var(--muted); }
.band-taste { font: italic 400 18px/1.4 var(--serif); color: var(--ink); }
.band-detail .milestone-text { margin-top: 14px; }
.milestone-text { max-width: 64ch; }
.milestone-sources { margin-top: 6px; font-size: 12px; color: var(--muted); }
.milestone-sources a { text-underline-offset: 2px; }

/* Narrow: the name and the way in on a line, the page across the full width, the figures under it. */
@container view (max-width: 700px) {
  .band-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'name go' 'page page' 'figs more' 'detail detail';
    grid-template-rows: auto;
    column-gap: 16px;
    padding: 18px 0 14px;
  }
  .band-name { grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; align-items: baseline; }
  .band-k { font-size: 26px; }
  .band-tag, .band-k + .band-range { margin-top: 0; }
  .band-range { grid-column: 2; }
  .band-tag + .band-range { display: none; }
  .band-go { align-self: center; }
  .band-page { padding-top: 14px; }
  .band-figs { justify-items: start; display: flex; flex-wrap: wrap; gap: 0 14px; margin-top: 12px; text-align: left; align-self: center; }
  .band-more { margin-top: 12px; align-self: center; }
  .band-detail { margin-top: 12px; }
}

/* ---- Exercise: where you are and the pages stay on screen; below, only the words ---- */
.ex-head { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 1px solid var(--rule); }
.ex-head[hidden] { display: none; }
/* Wide screen: one row, title on the left, pages on the right. */
.ex-in { display: flex; align-items: center; gap: 4px 24px; padding-block: 6px; }
.ex-top { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.back {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  margin-left: -10px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 120ms;
}
.back:hover { background: var(--hover); color: var(--ink); }
.ex-title { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-sub { margin-left: 6px; font-size: 13px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.ex-top .save-status { margin-left: auto; white-space: nowrap; }

.pager { flex: none; width: 380px; display: flex; align-items: center; gap: 4px; }
.pager-arrow { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 8px; background: none; }
.pager-arrow:hover:not(:disabled) { background: var(--hover); }
/* One bar per page: filled once validated, ringed when open. The whole 44 px height is the target. */
.steps { flex: 1; display: flex; gap: 4px; list-style: none; margin: 0; padding: 0 4px; }
.steps li { flex: 1; }
.step { display: block; width: 100%; height: 44px; border: 0; background: none; padding: 0; }
.step span { display: block; height: 6px; border-radius: 3px; background: var(--rule-strong); }
.step[data-done='true'] span { background: var(--ink); }
.step[aria-current] span { outline: 2px solid var(--ink); outline-offset: 2px; }
.step:hover span { background: var(--muted); }
.step[data-done='true']:hover span { background: var(--ink); }
.pager-label { min-width: 40px; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

body[data-view='exercise'] main, body[data-view='phrase-list'] main, body[data-view='learn'] main { padding-top: 20px; padding-bottom: 0; }
.ex-hint { margin: 0; }

/* Words are set like a page of text: you mark the ones you don't know, with the highlighter. */
.field {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0 8px;
}
/* Vertical padding only, so the words line up with the headings; the stroke spills sideways without moving them. */
.word { width: 100%; border: 0; background: none; text-align: left; padding: 6px 0; font: 400 20px/1.35 var(--serif); }
.word:hover .mark { text-decoration: underline; text-decoration-color: var(--rule-strong); text-decoration-thickness: 1px; text-underline-offset: 5px; }
.word[data-status='known'] { color: var(--muted); }
.word[data-status='unknown']:hover .mark { text-decoration: none; }
.word[data-status='learned'] { color: var(--learned); }
.word[data-status='learned'] .mark { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
/* No two strokes of a hand are the same: the angle changes a little from one word to the next. */
.field li:nth-child(3n) .mark::before { transform: skewX(-9deg) rotate(0.5deg); }
.field li:nth-child(4n + 1) .mark::before { transform: skewX(-9deg) rotate(-1.3deg); }

.actions {
  position: sticky;
  bottom: 0;
  margin-top: 24px;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.tally { color: var(--muted); font-variant-numeric: tabular-nums; }
.tally .marked { margin: 0 0.3em; font-weight: 600; }

/* ---- Learning one gap: a narrow column, one step at a time ---- */
body[data-view='learn'] .col { max-width: 720px; }
.learn-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.learn-steps { flex: none; display: flex; gap: 4px; width: 168px; margin: 0; padding: 0; list-style: none; }
.learn-steps li { flex: 1; height: 6px; border-radius: 3px; background: var(--rule-strong); }
.learn-steps li[data-state='done'] { background: var(--ink); }
.learn-steps li[data-state='open'] { outline: 2px solid var(--ink); outline-offset: 2px; }
.learn-step { margin-top: 28px; padding-bottom: 32px; }

/* The word, as large as on its card and larger: it is the subject of the whole screen. */
.learn-word { font: 500 46px/1.1 var(--serif); letter-spacing: -0.02em; }
.learn-word + .detail-say { margin: 6px 0 0; }
.learn-meaning { margin-top: 20px; }
.learn-meaning .detail-main { font-size: 17px; }
.learn .detail-example { margin-top: 24px; }
.learn .detail-example-en p[lang='en'] { font-size: 21px; }
.learn .detail-example strong { font-weight: 400; }
.learn .detail-other { font-size: 15px; }

.learn-prompt { font-size: 24px; line-height: 1.25; letter-spacing: -0.02em; text-wrap: balance; }
.learn-term { font: 500 30px/1 var(--serif); letter-spacing: -0.01em; }
.learn-context { margin-top: 20px; padding: 18px 20px; border-radius: 12px; background: var(--soft); }
.learn-sentence { font: 400 22px/1.45 var(--serif); }
.learn-sentence .say { margin: -6px 0 -6px 6px; vertical-align: middle; }
.learn-fr { margin-top: 6px; color: var(--muted); }
/* The hole: a blank of the page with a line to write on. */
.hole { display: inline-block; width: 5.2em; height: 1.1em; margin: 0 0.1em; vertical-align: -0.22em; border-radius: 4px 4px 0 0; background: var(--paper); box-shadow: 0 2px 0 var(--ink); }

.learn-options { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 8px; }
.learn-options-en { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.learn-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  background: var(--paper);
  text-align: left;
  font-size: 15px;
  line-height: 1.35;
  transition: border-color 120ms, background 120ms;
}
.learn-options-en .learn-option { font: 400 21px/1.3 var(--serif); }
.learn-option kbd { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--rule-strong); border-radius: 6px; font: 600 12px/1 var(--sans); color: var(--muted); }
.learn-option:hover:not(:disabled) { border-color: var(--ink); background: var(--hover); }
.learn-option:disabled { opacity: 1; }
.learn-option[data-state='right'] { border-color: var(--learned); box-shadow: inset 0 0 0 1px var(--learned); }
.learn-option[data-state='right'] kbd { border-color: var(--learned); background: var(--learned); color: var(--paper); }
.learn-option[data-state='wrong'] { color: var(--muted); }
.learn-option[data-state='wrong'] span { text-decoration: line-through; text-decoration-thickness: 1px; }
.learn-option[data-state='off'] { opacity: 0.45; }

.learn-form { margin-top: 20px; }
.learn-form input, .learn-typed {
  display: flex;
  align-items: center;
  width: 100%;
  height: 56px;
  padding: 0 16px;
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: 400 23px/1 var(--serif);
}
.learn-form input::placeholder { font: 400 15px var(--sans); color: var(--faint); }
.learn-form input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.learn-typed { margin-top: 20px; }
.learn-typed[data-state='right'] { border-color: var(--learned); box-shadow: inset 0 0 0 1px var(--learned); }
.learn-typed[data-state='wrong'] { color: var(--muted); }
.learn-typed[data-state='wrong'] span { text-decoration: line-through; text-decoration-thickness: 1px; }

.learn-listen { display: flex; align-items: center; gap: 16px; margin-top: 20px; }
.learn-listen .say { flex: none; width: 56px; height: 56px; margin: 0; background: var(--soft); color: var(--ink); }
.learn-listen .say:hover { background: var(--press); }
.learn-listen .say svg { width: 24px; height: 24px; }
.learn-listen .learn-fr { margin: 0; font-size: 15px; }

.learn-feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-top: 18px; font-size: 15px; }
.learn-result { font-weight: 650; }
.learn-feedback[data-state='right'] .learn-result { color: var(--learned); }
.learn-feedback strong { font: 500 21px/1.2 var(--serif); }
.learn-feedback .say { margin: -6px 0 -6px 2px; vertical-align: middle; }
.learn-again { flex-basis: 100%; font-size: 13px; color: var(--muted); }

/* A phrase being learned: the phrase itself is the subject of the screen, a little smaller than a single word. */
.learn-phrase { font: 500 32px/1.25 var(--serif); letter-spacing: -0.015em; text-wrap: balance; }
.learn-phrase .say { margin: -4px 0 -4px 8px; vertical-align: middle; }
.learn-step > .learn-gloss:first-of-type { margin-top: 10px; }
.learn .learn-tags { margin-top: 16px; }
.learn-serves { margin-top: 10px; font-size: 13px; color: var(--muted); }
.learn-skip { margin-top: 28px; }
.learn-options-phrases .learn-option { font: 400 19px/1.35 var(--serif); }
.learn-step > .learn-prompt + .learn-gloss { margin-top: 8px; font-size: 16px; }

/* Tiles: the line being built, ruled like a line of a notebook, then the words left. */
.tiles-line { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; min-height: 64px; margin-top: 22px; padding: 8px 0 12px; border-bottom: 1px solid var(--rule-strong); }
.tiles-hint { align-self: center; font-size: 14px; color: var(--faint); }
.tiles-bank { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tile { display: inline-flex; align-items: center; height: 42px; padding: 0 14px; border: 1px solid var(--rule-strong); border-radius: 9px; background: var(--paper); box-shadow: 0 1px 0 var(--rule-strong); font: 400 19px/1 var(--serif); transition: border-color 120ms, background 120ms; }
.tile:hover { border-color: var(--ink); }
.tile-used { border-style: dashed; background: var(--soft); box-shadow: none; color: transparent; }
.learn-built { height: auto; min-height: 56px; padding: 12px 16px; line-height: 1.3; }

/* The answer to a phrase step: the whole phrase, its sound, its French. */
.learn-feedback-phrase { display: block; }
.learn-feedback-phrase > p + p { margin-top: 4px; }
.learn-answer { font: 500 21px/1.35 var(--serif); }
.learn-answer .say { margin: -6px 0 -6px 4px; vertical-align: middle; }
.learn-feedback-phrase .learn-fr { margin-top: 2px; }
.learn-feedback-phrase .learn-again { margin-top: 6px; }

/* The end of a round, and the word once learned. */
.learn-end { margin-top: 44px; }
.learn-gloss { margin-top: 10px; font-size: 16px; color: var(--muted); }
.learn-end .learn-prompt { margin-top: 36px; }
.learn-choices { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.learn-choices .primary, .learn-choices .ghost { height: 42px; padding: 0 18px; font-size: 14px; font-weight: 600; }
.learn-word-done { color: var(--learned); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 8px; }

@media (max-width: 640px) {
  .learn-word { font-size: 38px; }
  .learn-phrase { font-size: 27px; }
  .tile { height: 44px; }
  .learn-prompt { font-size: 21px; }
  .learn-sentence { font-size: 20px; }
  .learn-option kbd { display: none; }
  .learn-choices > * { flex: 1 1 100%; }
  .learn-choices .primary, .learn-choices .ghost { height: 48px; justify-content: center; }
}

/* ---- Lacunes: what is left to review, band after band, then the phrases ---- */
/* Two tabs under the head: to review, learned since. Links (each has its address), underlined when open. */
.tabs { display: flex; gap: 24px; margin-top: 28px; border-bottom: 1px solid var(--rule); }
.tab { display: inline-flex; align-items: center; gap: 8px; height: 44px; margin-bottom: -1px; border-bottom: 2px solid transparent; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; transition: color 120ms, border-color 120ms; }
.tab:hover { color: var(--ink); }
.tab[aria-current='page'] { border-bottom-color: var(--ink); color: var(--ink); font-weight: 650; }
.tab-count { font-size: 13px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.tabs + .words-about { margin-top: 20px; }
.jump { display: flex; gap: 6px; margin-top: 16px; }
.jump button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 0; border-radius: 7px; background: var(--soft); font-size: 13px; font-weight: 500; }
.jump button:hover { background: var(--press); }
.jump span { color: var(--muted); font-variant-numeric: tabular-nums; }
#gaps-words, #gaps-phrases { scroll-margin-top: 16px; }

/* A band of gaps: on the left its name, as on the Mots screen, and how many it holds; on the right its words. The
   name stays in sight while the words of the band scroll. */
.gap-bands { margin-top: 36px; }
.gap-band { display: grid; grid-template-columns: 128px minmax(0, 1fr); column-gap: 24px; align-items: start; padding-bottom: 36px; border-top: 1px solid var(--rule); }
.gap-band-head { position: sticky; top: 0; padding-top: 14px; }
.gap-band-head .band-name { font-weight: 400; }
.gap-band-count { margin-top: 10px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gap-band-count .hl { margin: 0 0.25em; font-weight: 600; }
.gap-kind { font-size: 20px; line-height: 1.6; letter-spacing: -0.02em; }
.gap-rank { margin-left: 6px; font: 400 12px var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
/* Each word under a rule; the rules of the first words lie on the rule of the band. */
.gap-list { list-style: none; margin: -1px 0 0; padding: 0; columns: 2; column-gap: 56px; }
.gap-list li { break-inside: avoid; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 4px 0; border-top: 1px solid var(--rule); }
/* The word itself opens its card: the whole cell is the target, the word looks like a word. */
.gap-word { min-height: 44px; border: 0; background: none; padding: 0; text-align: left; font: 400 20px/1.35 var(--serif); }
.gap-word:hover .mark { text-decoration: underline; text-decoration-color: var(--rule-strong); text-decoration-thickness: 1px; text-underline-offset: 5px; }
/* The same button on every row: quiet until the row is under the hand, so the words are what the eye reads. */
.gap-list .ghost { border-color: transparent; color: var(--muted); }
.gap-list a.ghost { color: var(--ink); }
.gap-list li:hover .ghost { border-color: var(--rule-strong); color: var(--ink); }
/* Narrow: the name of the band on a line with its count, its words under it across the full width. */
@container view (max-width: 700px) {
  .gap-band { grid-template-columns: minmax(0, 1fr); padding-bottom: 28px; }
  .gap-band-head { position: static; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 14px 0 12px; }
  .gap-band-count { margin-top: 0; white-space: nowrap; }
  .gap-list { margin-top: 0; columns: 1; }
}



/* ---- Before the password: nothing personal on screen ---- */
body.locked { grid-template-columns: minmax(0, 1fr); }
body.locked .side { display: none; }
.login { display: grid; gap: 14px; max-width: 340px; margin: 14vh auto 0; }
.login-logo { margin: 0 0 18px 6px; justify-self: start; }
.login .logo-word { padding: 0; font-size: 34px; }
.login .logo-rest { display: inline; } /* the whole name, whatever the width */
.login h1 { font-size: 30px; line-height: 1.1; letter-spacing: -0.03em; text-wrap: balance; }
.login .hint { margin: 0; }
.login input { height: 40px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: 9px; background: var(--paper); color: var(--ink); font: inherit; }
.login input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.login .primary { height: 40px; }
.login-error { min-height: 1.5em; color: var(--danger); }
.login-demo { color: var(--muted); }
.login .lang-switch { justify-self: start; margin-left: -8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  transform: translate(-50%, 16px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 200ms;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- Phrases: the library of lists, and a list swept page by page ---- */
/* The library opens as the Mots screen does (what was read, what was highlighted), then one block per way of
   sorting the phrases. A list is a row set as a band of the Mots screen: on the left its name and what it holds, in
   the middle its page (one dash per phrase, lib/phrase-page.js), on the right its way in and its figures. */
.phrase-block { margin-top: 44px; }
.plist { list-style: none; margin: 12px 0 0; padding: 0; border-bottom: 1px solid var(--rule); }
.plist-row {
  position: relative;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 168px;
  grid-template-areas: 'name page go' 'name page figs';
  grid-template-rows: auto 1fr;
  column-gap: 24px;
  align-items: start;
  padding: 22px 0 24px;
  border-top: 1px solid var(--rule);
}
.plist-name { grid-area: name; min-width: 0; }
.plist-label { font-size: 17px; line-height: 1.25; font-weight: 650; letter-spacing: -0.015em; text-wrap: balance; }
.plist-label[lang='en'] { font: 400 20px/1.3 var(--serif); letter-spacing: 0; }
/* The name is the only link of a row, and the whole row is its target. */
.plist-label a { text-decoration: none; }
.plist-label a::after { content: ''; position: absolute; inset: 0; }
.plist-row:hover .plist-label a { text-decoration: underline; text-decoration-color: var(--rule-strong); text-decoration-thickness: 1px; text-underline-offset: 4px; }
.plist-desc { margin-top: 6px; font-size: 13px; line-height: 1.45; color: var(--muted); }
/* The first line of dashes sits at the height of the name. */
.plist-page { grid-area: page; display: block; padding-top: 7px; }
.plist-go { grid-area: go; justify-self: end; display: inline-flex; align-items: center; height: 32px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.plist-row:hover .plist-go { color: var(--ink); }
/* The list where the reading goes on is the one to open: its way in looks like a button. */
.plist-row[data-next] .plist-go { padding: 0 12px; border-radius: 7px; background: var(--ink); color: var(--paper); transition: opacity 120ms; }
.plist-row[data-next]:hover .plist-go { opacity: 0.86; color: var(--paper); }
.plist-figs { grid-area: figs; display: grid; justify-items: end; gap: 2px; margin-top: 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.plist-figs .hl { margin: 0 0.25em; font-weight: 600; }

/* A long index of small lists (the frames): one line per list. Its name, a few dashes, its figures; no way in to
   read, the row is the way in. */
.plist-compact { grid-template-columns: minmax(0, 1fr) 72px 176px; grid-template-areas: 'name page figs'; grid-template-rows: auto; align-items: center; padding: 12px 0; }
.plist-compact .plist-desc { margin-top: 2px; }
.plist-compact .plist-page { padding-top: 0; }
.plist-compact .plist-go { display: none; }
.plist-compact .plist-figs { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 14px; margin-top: 0; }

/* Narrow: the name across the full width, the page under it, then the figures and the way in on one line. */
@container view (max-width: 700px) {
  .plist-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'name name' 'page page' 'figs go';
    grid-template-rows: auto;
    column-gap: 16px;
    align-items: center;
    padding: 18px 0 14px;
  }
  .plist-page { padding-top: 14px; }
  .plist-go { margin-top: 10px; }
  .plist-figs { display: flex; flex-wrap: wrap; justify-items: start; gap: 0 14px; margin-top: 10px; text-align: left; }
  /* The few dashes of a frame start at the left edge, under its name, its figures after them. */
  .plist-compact { grid-template-columns: 72px minmax(0, 1fr); grid-template-areas: 'name name' 'page figs'; column-gap: 12px; padding: 12px 0; }
  .plist-compact .plist-page { padding-top: 0; }
  .plist-compact .plist-page, .plist-compact .plist-figs { margin-top: 8px; }
  .plist-compact .plist-figs { justify-content: flex-start; }
}

/* The page of a family: back link, title and description, then its rows. */
.phrase-head { display: grid; justify-items: start; }
.phrase-head .phrase-title { margin: 0; }
.phrase-head + .plist { margin-top: 24px; }
.phrase-head + .empty { margin-top: 16px; }
.phrase-title[lang='en'] { font: 500 28px/1.2 var(--serif); letter-spacing: -0.01em; }

/* The description of a list, under its title: muted, never under 13px. */
.phrase-desc { margin: 4px 0 0; max-width: 70ch; font-size: 14px; line-height: 1.45; color: var(--muted); }

/* Head of a list: back, title and order on the left, the pager on the right, all inside the column's edges. */
.phrase-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; align-items: center; }
.phrase-top .back { grid-column: 1 / -1; justify-self: start; }
.phrase-heading { grid-column: 1; min-width: 0; }
.phrase-order { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.phrase-top .pager { grid-column: 2; grid-row: 2; width: auto; margin: 0 -14px 0 0; }
.phrase-position { min-width: 72px; text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.phrase-top + .hint { margin-top: 14px; }

/* One phrase per line, full width. The rank sits in a fixed column; the English text and the unfolded
   translation both start at --phrase-text, so they share one left edge. */
.phrase-field { --phrase-rank: 28px; --phrase-text: 40px; list-style: none; margin: 16px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.phrase-item { border-bottom: 1px solid var(--rule); }
.phrase {
  position: relative;
  display: block;
  width: 100%;
  min-height: 48px;
  border: 0;
  background: none;
  padding: 11px 0 11px var(--phrase-text);
  text-align: left;
  font: 400 19px/1.4 var(--serif);
}
.phrase-rank { position: absolute; left: 0; top: 11px; width: var(--phrase-rank); text-align: left; font: 400 12px/27px var(--sans); color: var(--faint); font-variant-numeric: tabular-nums; }
.phrase:hover .phrase-en { text-decoration: underline; text-decoration-color: var(--rule-strong); text-decoration-thickness: 1px; text-underline-offset: 5px; }
.phrase[aria-pressed='true']:hover .phrase-en { text-decoration: none; }
.phrase-more { display: flex; align-items: center; flex-wrap: wrap; gap: 0 8px; padding: 0 0 12px var(--phrase-text); }
.phrase-fr { flex-basis: 100%; margin: 0 0 4px; color: var(--muted); }
.phrase-more .say { width: 44px; height: 44px; margin: -6px 0 -6px -13px; }
.phrase-tags { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0; }
.phrase-tag { padding: 1px 7px; border-radius: 5px; background: var(--soft); font: 500 12px/1.6 var(--sans); color: var(--muted); }
/* The frame of a phrase is a tag that is also a link to the frame's list. It looks like the other tags (same shape, same
   12px text, same height, so the baseline of the tags does not move), in the ink colour to show it can be touched. The
   touch area is taller than the tag: an invisible layer reaches 6px above and below it without taking room. */
.phrase-tag-link { position: relative; color: var(--ink); text-decoration: none; box-shadow: inset 0 0 0 1px var(--rule-strong); background: none; }
.phrase-tag-link::after { content: ''; position: absolute; inset: -6px -4px; }
.phrase-tag-link:hover { box-shadow: inset 0 0 0 1px var(--muted); }

/* The phrases to review: one block each, the English with its sound, the French, where it serves. */
.phrase-gap-list { list-style: none; margin: 16px 0 0; padding: 0; }
.phrase-gap { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.phrase-gap-main { display: grid; justify-items: stretch; gap: 4px; min-width: 0; }
.phrase-gap > .ghost { white-space: nowrap; }
/* Like the words above: the way into the tunnel is quiet until the row is under the hand. */
.phrase-gap > a.ghost { border-color: transparent; }
.phrase-gap:hover > a.ghost { border-color: var(--rule-strong); }
.phrase-gap-en { font: 400 19px/1.4 var(--serif); }
.phrase-gap-en p { display: inline; }
.phrase-gap-last { white-space: nowrap; }
.phrase-gap-en .say { width: 40px; height: 40px; margin: -8px 0 -8px 2px; vertical-align: middle; }
.phrase-serves { font-size: 13px; color: var(--muted); }

/* The phrase gaps close the Lacunes screen, set as a band of words above: their name on the left, the phrases in the
   column of the words. */
.phrase-gaps { margin-top: 28px; }
.phrase-gaps-body > .hint { margin-top: 18px; }
.phrase-gaps-body > .phrase-gap-list:first-child { margin-top: -1px; }
.phrase-gaps .phrase-gap-list { margin-top: 12px; border-top: 1px solid var(--rule); }
.phrase-gaps .phrase-gap > .ghost { min-height: 44px; }
.phrase-gaps .phrase-serves a { display: inline-block; padding: 10px 0; color: var(--muted); }
.phrase-gaps .phrase-serves { margin-top: -6px; }
.phrase-gaps .phrase-serves a:not(:last-child) { margin-right: 4px; }

/* ---- A word's card: same content in the grid and on the Lacunes screen ---- */
.detail-main { margin: 0; font-size: 16px; }
/* One block per nature: the nature as a small label, its translation, then its forms and synonyms. */
.detail-nature + .detail-nature { margin-top: 12px; }
.detail-pos { display: inline-block; min-width: 0; margin-right: 6px; padding: 0 6px; border-radius: 5px; background: var(--soft); font: 500 12px/1.6 var(--sans); color: var(--muted); vertical-align: 2px; }
.detail-nature .detail-related, .detail-nature .detail-forms { margin-top: 4px; }
.detail-other { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.detail-also { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.detail-sense { margin-left: 6px; font: italic 400 15px/1.3 var(--serif); color: var(--muted); }
.detail-also .detail-sense { margin-left: 4px; font-size: 14px; }
.detail-none { margin: 0; font-size: 14px; color: var(--muted); }
/* Synonyms and antonyms: one small line under the senses, the English words in ink. */
.detail-related { margin: 8px 0 0; font-size: 13px; line-height: 1.5; }
.detail-related-label { color: var(--muted); }
.detail-related-other { margin-top: 4px; }
.related-gap { margin: 0 0.3em; }
/* The written American pronunciation and the button that says the word. */
.detail-say { display: flex; align-items: center; gap: 6px; margin: 2px 0 10px; }
.detail-ipa { border: 0; background: none; padding: 0; font: 400 14px var(--phonetic); color: var(--muted); text-decoration: underline dotted; text-underline-offset: 3px; }
.detail-ipa:hover { color: var(--ink); }
.say { display: inline-grid; place-items: center; width: 32px; height: 32px; margin: -4px 0; border: 0; border-radius: 999px; background: none; color: var(--muted); transition: background 120ms; }
.say:hover { background: var(--hover); color: var(--ink); }
/* Up to five sentences, one under the other; each says itself, its French right under it. */
.detail-example { list-style: none; margin: 14px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.detail-example-item { padding: 12px 0 0; }
.detail-example-item + .detail-example-item { margin-top: 4px; }
.detail-example-en { display: flex; align-items: flex-start; gap: 4px; }
.detail-example-en p[lang='en'] { flex: 1; margin: 0; font: 400 18px/1.4 var(--serif); }
.detail-example-en .say { flex: none; margin: -2px -6px 0 0; }
.detail-example .detail-other { margin-top: 2px; }
/* The word inside its example is only heavier: the yellow is kept for what is marked unknown. */
.detail-example strong { font-weight: 600; }
.detail-written { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.detail-forms { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.detail-forms [lang='en'] { color: var(--ink); }
.detail-register { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 5px; background: var(--soft); font: 500 12px/1.6 var(--sans); letter-spacing: 0; color: var(--muted); vertical-align: 5px; }
.detail-link { display: inline-block; margin-top: 12px; font-size: 13px; color: var(--muted); }

/* Header and footer hold still; only the middle scrolls, and its scrolling never carries the page along. */
.word-card {
  position: fixed;
  z-index: 20;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.word-card[hidden] { display: none; }
.card-head { flex: none; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 16px 8px; }
.card-head .detail-say { margin-bottom: 0; }
.card-handle { display: none; }
.card-word { margin: 0; font: 500 27px/1.15 var(--serif); letter-spacing: -0.01em; }
.card-close { display: grid; place-items: center; width: 28px; height: 28px; margin: -2px -4px 0 0; border: 0; border-radius: 7px; background: none; font-size: 20px; line-height: 1; color: var(--muted); }
.card-close:hover { background: var(--hover); color: var(--ink); }
.card-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px 16px; }
.card-actions { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--rule); }
.card-status { margin: 0; font-size: 13px; color: var(--muted); }
.card-actions .ghost { margin-left: auto; }
.card-actions .primary { height: 32px; padding: 0 12px; font-size: 13px; }
.link-button { border: 0; background: none; padding: 0; font-size: 13px; color: var(--muted); text-decoration: underline; }

/* ---- The lesson on reading the pronunciation: one line per sound, its symbol, how it sounds, examples ---- */
.lesson > h2 { font-size: 24px; line-height: 1.2; letter-spacing: -0.02em; min-height: 36px; display: flex; align-items: center; }
.ipa { font-family: var(--phonetic); }
/* The part of a transcription a line talks about: a grey ground, not the highlighter. */
.lesson mark { padding: 0 1px; border-radius: 3px; background: var(--press); color: inherit; }
.decode { margin-top: 24px; padding: 18px 20px 20px; border-radius: 12px; background: var(--soft); }
.decode-word { display: flex; align-items: center; gap: 10px; margin: 0; }
.decode-word [lang='en'] { font: 500 27px/1.15 var(--serif); letter-spacing: -0.01em; }
.decode-word .ipa { font-size: 17px; color: var(--muted); }
.decode-parts { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; }
.decode-parts a { display: grid; gap: 2px; min-width: 56px; padding: 8px 12px; border-radius: 8px; background: var(--paper); box-shadow: 0 0 0 1px var(--rule); color: inherit; text-decoration: none; transition: box-shadow 120ms; }
.decode-parts a:hover { box-shadow: 0 0 0 1px var(--muted); }
.decode-parts .ipa { font-size: 20px; line-height: 1.2; }
.decode-parts span:last-child { font-size: 12px; color: var(--muted); }
.sound-group { margin-top: 40px; }
.sound-group h3 { font-size: 18px; letter-spacing: -0.015em; }
.sound-group .hint { margin-top: 6px; }
.sound-list { margin: 14px 0 0; padding: 0; list-style: none; border-bottom: 1px solid var(--rule); }
.sound { display: grid; grid-template-columns: 56px 1fr; gap: 16px; padding: 14px 0; border-top: 1px solid var(--rule); scroll-margin-top: 16px; }
.sound:target { background: var(--soft); }
.sound-symbol { font-size: 28px; line-height: 1.1; text-align: center; }
.ipa .syllable { font-size: 0.6em; color: var(--muted); }
.sound-as { margin: 0; font-weight: 600; }
.sound-note { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.sound-note .ipa { white-space: nowrap; }
.sound-examples { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 6px 0 0; padding: 0; list-style: none; }
.sound-examples li { display: inline-flex; align-items: center; gap: 6px; }
.sound-examples [lang='en'] { font: 400 18px/1.35 var(--serif); }
.sound-examples .ipa { color: var(--muted); }
.sound-examples .say { margin: -6px -6px -6px -4px; }

/* ---- Medium screen: the sidebar folds into a rail of icons ---- */
@media (max-width: 1099px) {
  :root { --side: 64px; --gutter: 32px; }
  .side { align-items: center; padding: 16px 0 12px; }
  .logo { align-self: center; margin: 0 0 20px; }
  .logo-rest { display: none; }
  .logo-word { padding: 0 0.12em; }
  .nav { align-items: center; }
  .nav-item { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .nav-group { width: 24px; height: 1px; margin: 10px 0; padding: 0; overflow: hidden; background: var(--rule-strong); font-size: 0; }
  .nav-count { position: absolute; top: -1px; right: -9px; margin: 0; font-size: 11px; }
  .side-foot { flex-direction: column; gap: 6px; padding: 12px 0 0; }
  .side-foot .save-status { display: none; }
  .lang-switch { margin-left: 0; }
  .board { gap: 40px; }
}

/* ---- Phone: the logo on top, the screens in a bar at the bottom; an open list takes the whole screen ---- */
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  body { display: block; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; justify-content: space-between; padding: 14px 16px 0; background: none; border: 0; overflow: visible; }
  .logo { margin: 0 0 0 6px; }
  .logo-rest { display: inline; }
  .logo-word { padding: 0; font-size: 22px; }
  .side-foot { flex-direction: row; margin: 0; padding: 0; min-height: 0; }
  .side-foot .save-status { display: inline; }
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--paper);
    border-top: 1px solid var(--rule);
  }
  .nav-group { display: none; }
  .nav-item { width: auto; height: 48px; flex-direction: column; gap: 3px; border-radius: 9px; color: var(--muted); font-size: 12px; }
  .nav-item:hover, .nav-item[aria-current='page'] { background: none; }
  .nav-item[aria-current='page'] { color: var(--ink); }
  .nav-short { display: block; }
  .nav-count { top: 1px; right: calc(50% - 32px); }
  body[data-view='exercise'] .side, body[data-view='phrase-list'] .side, body[data-view='learn'] .side { display: none; }

  main { padding-top: 22px; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
  .section-head .primary { width: 100%; height: 44px; }
  .level { margin-top: 22px; }
  .level-lead { font-size: 28px; }
  .measure { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 22px 12px; }
  .measure-tag { display: none; }
  .words-say { font-size: 32px; }
  .board { grid-template-columns: minmax(0, 1fr); gap: 40px; margin-top: 36px; }
  .work { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'name count' 'where where' 'meter meter'; gap: 2px 12px; }
  .work .meter { width: 100%; margin-top: 10px; }
  .work-go { display: none; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }

  /* Exercise header on a phone: back and title, then the pages; two rows, nothing else. */
  .ex-in { flex-direction: column; align-items: stretch; gap: 0; padding-block: 4px; }
  .back { width: 44px; padding: 0; justify-content: center; }
  .back span, .ex-top .save-status { display: none; }
  .ex-sub { font-size: 12px; }
  .pager { width: auto; margin-left: -10px; }
  .field { grid-template-columns: repeat(2, 1fr); }
  .actions .primary { height: 44px; padding: 0 20px; }

  /* The list head stacks (back, title, order, then the pager across the full width); the back link keeps its word. */
  .phrase-top { grid-template-columns: minmax(0, 1fr); }
  .phrase-top .back, .phrase-head .back { width: auto; padding: 0 10px; }
  .phrase-top .back span, .phrase-head .back span { display: inline; }
  .phrase-top .pager { grid-column: 1; grid-row: auto; margin: 4px -14px 0; }
  .phrase-position { flex: 1; }

  /* The word card is a sheet over the bottom half at most; the list behind stays scrollable and touchable. */
  .word-card {
    left: 0; right: 0; bottom: 0; top: auto; width: auto;
    max-height: 50vh; max-height: 50dvh;
    border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .card-head { position: relative; padding-top: 22px; touch-action: none; }
  .card-handle { display: block; position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--rule-strong); }
  .card-close { width: 40px; height: 40px; margin: -8px -8px 0 0; font-size: 26px; }
  /* Room under the list for the open sheet (--sheet: its height, set while it is open). */
  main { padding-bottom: max(var(--sheet, 0px), calc(96px + env(safe-area-inset-bottom))); }
  body[data-view='exercise'] main, body[data-view='phrase-list'] main, body[data-view='learn'] main { padding-bottom: var(--sheet, 0px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
