/* Components of static/app/ui/. One section per component, tokens only, no literal colors. */

/* ---------- NavBar, Head (ui/nav.js) ---------- */
.nav {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 52px;
  margin-inline: calc(var(--space-4) * -1); padding-inline: var(--space-2) var(--space-4);
  background: var(--blur-bg); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
/* Scoped to .nav: the card's back face is ".face.back", and this justify-self shrank it to its
   text and pushed it to the edge (a narrow strip on the right once flipped). */
.nav .back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); padding: var(--space-2); justify-self: start; min-height: 44px; text-decoration: none; }
.nav .back svg { width: 13px; height: 21px; }
.nav .back { transition: opacity 0.2s; }
.nav .back:active { opacity: var(--press-dim); transition-duration: var(--press-in); }
.nav-title { font-weight: 600; font-size: var(--text-body); opacity: 0; transition: opacity 0.2s; }
.nav.scrolled .nav-title { opacity: 1; }
.head { display: grid; gap: var(--space-1); padding-top: var(--space-4); }
.nav + .head { padding-top: 0; }
.eyebrow { color: var(--muted); font-size: var(--text-subhead); }
.large-title { font-size: var(--text-large-title); font-weight: var(--head-weight); letter-spacing: var(--head-track); line-height: var(--leading-title); text-wrap: balance; }
.lead { color: var(--muted); font-size: var(--text-callout); }
/* Titles and rows show names people type (own topics, groups, words, their name). One long
   word without spaces breaks inside the word instead of widening the whole screen. */
.large-title, .lead, .t1, .t2 { overflow-wrap: anywhere; }
.note { color: var(--muted); font-size: var(--text-footnote); padding-inline: var(--space-4); letter-spacing: var(--small-track); }

/* ---------- Button (ui/button.js) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 48px; padding: 0 var(--space-6);
  border-radius: var(--radius-button); corner-shape: var(--corner); background: var(--primary); color: var(--on-primary); font-weight: 600; font-size: var(--text-callout); text-decoration: none;
  transition: transform 0.2s var(--ease-out), filter 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(var(--press-scale)); filter: brightness(0.92); transition-duration: var(--press-in); }
.btn.plain:active, .btn.danger:active { transform: none; filter: none; opacity: var(--press-dim); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.plain { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--again); }
.btn.wide { width: 100%; }
.btn.small { min-height: 36px; padding: 0 var(--space-4); font-size: var(--text-subhead); }

/* ---------- Group, Row (ui/list.js) ---------- */
.group-label { font-size: var(--text-footnote); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding-left: var(--space-4); margin-bottom: calc(var(--space-4) * -1); }
.group {
  background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius-group); corner-shape: var(--corner);
  overflow: hidden;
}
.row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-4); align-items: center;
  width: 100%; text-align: left; padding: var(--space-3) var(--space-4); min-height: 58px; position: relative;
  color: inherit; text-decoration: none; transition: background 0.15s;
}
.row.no-left { grid-template-columns: minmax(0, 1fr) auto; }
a.row:active, button.row:active, .row.selected { background: var(--fill); }
a.row:active, button.row:active { transition-duration: 0s; }
button.row { cursor: pointer; }
button.row .t1 { color: var(--accent); } /* an action in a list is tinted, as in iOS */
.row + .row::before { content: ""; position: absolute; top: 0; left: 70px; right: 0; height: 1px; background: var(--line); }
.row.no-left + .row::before, .row + .row.no-left::before { left: 16px; }
.row-text { min-width: 0; }
/* A row with a segmented control: when both do not fit ("Оформление" + three options on a
   phone), the control moves under the title instead of clipping it. */
.row.no-left:has(> .seg) { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-2) var(--space-4); }
.row.no-left:has(> .seg) > .row-text { flex: 1 1 auto; }
.t1 { font-weight: 500; display: block; }
.t2 { color: var(--muted); font-size: var(--text-subhead); display: block; font-variant-numeric: tabular-nums; }
.chev { width: 8px; height: 14px; color: var(--muted); opacity: 0.6; }
.bar { display: flex; height: 4px; border-radius: var(--radius-indicator); background: var(--line); margin-top: var(--space-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
/* Two segments (known, then learning) meet without a rounded seam. */
.bar i:not(:last-child) { border-start-end-radius: 0; border-end-end-radius: 0; }
.bar i + i { border-start-start-radius: 0; border-end-start-radius: 0; }

/* ---------- Icon (ui/icon.js) ---------- */
.icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font: 600 var(--text-body) var(--font-word); color: var(--on-accent); flex: none; }
.icon.large { width: 56px; height: 56px; border-radius: 14px; font-size: var(--text-title1); }

/* ---------- Pill (ui/pill.js) ---------- */
.pill { font-size: var(--text-caption1); font-weight: 600; padding: var(--space-1) var(--space-3); border-radius: 999px; background: var(--fill); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--know-soft); color: var(--know); }
.pill.started { background: var(--started-soft); color: var(--started); }
.pill.warn { background: var(--again-soft); color: var(--again); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Ring (ui/ring.js) ---------- */
.ring { flex: none; }
.ring circle { fill: none; }
.ring .track { stroke: var(--line); }
.ring .val { transform: rotate(-90deg); transform-origin: 50% 50%; stroke-linecap: round; transition: stroke-dashoffset 0.9s var(--ease-out); }
.ring text { fill: var(--fg); text-anchor: middle; dominant-baseline: central; font-family: var(--font-ui); font-weight: 700; }

/* ---------- Segmented (ui/form.js) ---------- */
/* Flex with wrap: with large system text the options take a second line instead of running
   off the screen. */
.seg {
  display: inline-flex; flex-wrap: wrap; max-width: 100%; background: var(--fill); padding: 2px;
  border: 1px solid var(--card-border); border-radius: var(--radius-segment); corner-shape: var(--corner);
}
.seg button {
  padding: var(--space-2) var(--space-3); border: 1px solid transparent; border-radius: var(--radius-segment-item); corner-shape: var(--corner);
  font-size: var(--text-subhead); font-weight: 500; min-width: 44px; min-height: 44px;
}
.seg button[aria-pressed="true"] {
  background: var(--surface); border-color: var(--card-border); box-shadow: var(--shadow);
}
.seg button:focus-visible { outline-offset: -2px; }

/* ---------- Field (ui/field.js) ---------- */
.field { display: grid; gap: var(--space-2); }
.field label { font-size: var(--text-footnote); color: var(--muted); padding-left: var(--space-1); }
/* select: same box as input */
.field input, .field textarea, .field select { min-height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: var(--space-3) var(--space-4); font-size: var(--text-body); }
.field textarea { min-height: 160px; resize: vertical; line-height: var(--leading-read); }
/* a long topic title must not widen the form: the list takes the column and cuts the text */
.field:has(select) { min-width: 0; }
.field select { appearance: auto; color: var(--fg); width: 100%; min-width: 0; text-overflow: ellipsis; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.field .hint { font-size: var(--text-footnote); color: var(--muted); padding-left: var(--space-1); }
.field.invalid input, .field.invalid textarea { border-color: var(--again); }
.field.invalid .hint { color: var(--again); }

/* ---------- Empty state (ui/empty.js) ---------- */
.empty { display: grid; justify-items: center; gap: var(--space-3); text-align: center; padding: var(--space-12) var(--space-4); color: var(--muted); }
.empty b { color: var(--fg); font-size: var(--text-title3); }

/* ---------- Today (ui/today.js) ---------- */
.view:has(> .today-day) { row-gap: var(--space-4); }
.view:has(> .today-day) .eyebrow { font-size: var(--text-footnote); }
.view:has(> .today-day) .large-title { font-size: clamp(var(--text-title1), 4vw, var(--text-large-title)); }
.today-day, .course-today-card {
  background: var(--surface); border: 1px solid var(--card-border);
  border-radius: var(--radius-today); corner-shape: var(--corner);
}
.today-day { padding: var(--space-4); }

/* ---------- Goal of the day and streak (ui/goal.js) ---------- */
/* Flex with wrap, not three grid columns: with large system text (200 %) the text moves under
   the ring instead of being squeezed to one letter per line. */
.day-goal {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4);
  padding: var(--space-4) var(--space-4); background: var(--surface); border: 1px solid var(--card-border);
  border-radius: var(--radius-today); corner-shape: var(--corner);
}
.day-goal .ring text { font-variant-numeric: tabular-nums; }
.day-goal-text { display: grid; gap: var(--space-1); overflow-wrap: anywhere; flex: 1 1 7em; min-width: 0; }
.day-goal-label { color: var(--muted); font-size: var(--text-footnote); letter-spacing: var(--small-track); }
.day-goal-main { font-weight: 700; font-variant-numeric: tabular-nums; }
.day-goal-note { color: var(--muted); font-size: var(--text-footnote); letter-spacing: var(--small-track); }
.day-goal-streak { margin-inline-start: auto; display: grid; justify-items: end; text-align: end; line-height: var(--leading-title); }
.day-goal-streak b { font-size: var(--text-title2); font-variant-numeric: tabular-nums; }
.day-goal-streak span { color: var(--muted); font-size: var(--text-footnote); letter-spacing: var(--small-track); }
.today-day-text { display: grid; gap: var(--space-1); overflow-wrap: anywhere; }
.today-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.today-breakdown { color: var(--muted); font-size: var(--text-footnote); }
.today-courses { display: grid; gap: var(--space-2); min-width: 0; }
.today-courses > .group-label {
  padding: 0; margin: 0; font: 500 var(--text-caption1)/var(--leading-small) var(--font-ui);
}
.today-courses .card-grid { gap: var(--space-3); }
.course-today-card {
  min-width: 0; color: inherit; text-decoration: none; overflow-wrap: anywhere;
  transition: transform 0.18s var(--ease-out), border-color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}
/* The link: the whole card, or its upper part when quick review sits below (course-today-split). */
a.course-today-card, .course-today-link {
  display: grid; grid-template-columns: 4px minmax(0, 1fr) fit-content(42%); gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-3); min-width: 0; color: inherit; text-decoration: none;
}
a.course-today-card::before, .course-today-link::before {
  content: ""; background: var(--course-color); border-radius: var(--radius-indicator);
}
.course-today-split { display: grid; }
.course-today-link { border-radius: inherit; }
.course-today-link:focus-visible { outline-offset: -3px; }
/* The card answers in its course's colour: a lift under the pointer, the border on touch and keyboard. */
a.course-today-card:active, a.course-today-card:focus-visible,
.course-today-split:has(.course-today-link:active) { border-color: var(--course-color); }
@media (hover: hover) {
  .course-today-card:hover { border-color: var(--course-color); transform: translateY(-2px); box-shadow: var(--shadow); }
}
@media (hover: hover) and (prefers-reduced-motion: reduce) {
  .course-today-card:hover { transform: none; box-shadow: none; }
}
a.course-today-card:active, .course-today-split:has(.course-today-link:active) {
  transform: scale(var(--press-scale)); transition-duration: var(--press-in);
}
@media (prefers-reduced-motion: reduce) {
  a.course-today-card:active, .course-today-split:has(.course-today-link:active) { transform: none; opacity: 0.7; }
}
.course-today-quick {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  margin: 0 var(--space-4); padding: var(--space-3) 0 var(--space-4); border-top: 1px solid var(--line);
}
.course-today-quick > span { flex: 1 1 auto; color: var(--muted); font-size: var(--text-footnote); }
.course-today-quick .btn.secondary {
  min-width: 64px; background: color-mix(in srgb, var(--course-color) 16%, transparent); color: var(--fg);
}
.course-today-quick-hint { color: var(--muted); font-size: var(--text-footnote); }
.course-today-card h3 { font-size: var(--text-headline); line-height: var(--leading-headline); font-weight: var(--head-weight); }
.course-today-caption { margin-top: var(--space-1); color: var(--muted); font-size: var(--text-footnote); }
.course-today-main .bar { margin-top: var(--space-2); }
.course-today-detail { margin-top: var(--space-2); font-size: var(--text-subhead); }
.course-today-status { color: var(--again); font-weight: 600; }
.course-today-detail + .course-today-status { margin-top: var(--space-1); }
.today-action {
  align-self: center; text-align: end; color: var(--accent); font-size: var(--text-subhead); font-weight: 600;
}
.course-today-card:hover .today-action, .today-more a:hover .today-action { text-decoration: underline; }
.today-more {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-4);
  padding: var(--space-1) var(--space-4); border: 1px dashed var(--line); border-radius: var(--radius-today); corner-shape: var(--corner);
}
.today-more h2 { font-size: var(--text-subhead); font-weight: 650; }
.today-more ul { flex: 1 1 200px; list-style: none; margin: 0; padding: 0; }
.today-more li + li { border-block-start: 1px solid var(--line); }
.today-more a {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-2);
  min-height: 44px; text-decoration: none; color: var(--muted); font-size: var(--text-subhead);
  overflow-wrap: anywhere;
}

/* ---------- Profile ---------- */
.profile-person-name { font-size: var(--text-title3); font-weight: 700; }
.me .row-text, .row[href="/accounts/profile/"] .t2 { overflow-wrap: anywhere; }
.profile-notice {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-group); corner-shape: var(--corner);
  background: var(--accent-soft);
  color: var(--fg);
}
.me { display: flex; align-items: center; gap: var(--space-4); }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: var(--text-title2); flex: none; }

/* ---------- Birthday greeting ---------- */
.birthday-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: clamp(var(--space-4), 3vw, var(--space-6));
  border: 1px solid var(--line);
  border-radius: var(--radius-card); corner-shape: var(--corner);
  background: var(--accent-soft);
  overflow-wrap: anywhere;
}
.birthday-card h2 { margin: 0; font-size: clamp(var(--text-title3), 4vw, var(--text-title1)); }
.birthday-card p { margin: var(--space-1) 0 0; }
.birthday-card .btn.secondary { min-height: 44px; background: var(--surface); }

/* ---------- Word list (screens/lesson.js, topic preview) ---------- */
.words-list { background: var(--surface); border-radius: var(--radius-group); corner-shape: var(--corner); overflow: hidden; }
.word-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); padding: var(--space-3) var(--space-4); align-items: baseline; }
.word-row + .word-row { border-top: 1px solid var(--line); }
.word-row b { font: 500 var(--text-title3) var(--font-word); overflow-wrap: anywhere; }
.word-row span { color: var(--muted); font-size: var(--text-subhead); text-align: right; }
.words-list.with-status .word-row { gap: var(--space-1) var(--space-3); }
.words-list.with-status .word-status { font-weight: 600; }
.words-list.with-status .word-row > span:last-child {
  grid-column: 1 / -1; text-align: start; padding-inline-start: var(--space-4); overflow-wrap: anywhere;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: var(--space-2); background: var(--line); vertical-align: middle; }
.dot.started { background: var(--accent); }
.dot.known { background: var(--know); }
.actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* ---------- Layout on a wide screen (ui/layout.js) ---------- */
.cols, .col { display: grid; gap: var(--space-6); align-content: start; min-width: 0; }
.card-grid { display: grid; gap: var(--space-4); }
@media (min-width: 900px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}
@media (min-width: 1100px) {
  .cols { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--space-6) var(--space-8); }
  /* A long word list reads in two columns instead of one very wide one. */
  .cols .words-list.wide { display: block; }
  .words-list.wide { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1px; background: var(--line); }
  .words-list.wide .word-row { background: var(--surface); border-top: 0; }
  .words-list.wide .word-row:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

/* ---------- Two panes on desktop (screens/topic.js) ---------- */
.panes { display: grid; gap: var(--space-6); }
.pane-list { display: grid; gap: var(--space-6); align-content: start; min-width: 0; }
.preview { display: none; }
@media (min-width: 900px) {
  .panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: var(--space-6) var(--space-8); align-items: start; }
  .preview { display: grid; gap: var(--space-4); position: sticky; top: 24px; background: var(--surface); border-radius: var(--radius-card); corner-shape: var(--corner); padding: var(--space-6); box-shadow: var(--shadow); }
  .shell:not(.bare) .preview { top: calc(var(--topbar-h) + 52px + env(safe-area-inset-top, 0px)); }
  .preview h2 { font-size: var(--text-title2); font-weight: 700; }
  .preview .words-list { max-height: 46vh; overflow-y: auto; margin-inline: calc(var(--space-6) * -1); border-radius: 0; }
}

/* ---------- Study session (screens/session.js, ui/studycard.js) ---------- */
.session { min-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); display: grid; grid-template-rows: auto 1fr auto; gap: var(--space-4); padding-block: var(--space-3); max-width: 460px; width: 100%; margin: 0 auto; }
/* The session fills the window by itself: no page padding under it, so nothing scrolls. */
.shell.bare .main:has(.session) { padding-bottom: 0; }
.sess-top { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto 44px; align-items: center; gap: var(--space-2); }
.sess-top .theme-toggle { grid-area: 1 / 4; }
.close { width: 44px; height: 44px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; color: var(--muted); }
.close svg { width: 14px; height: 14px; }
.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width 0.45s var(--ease-out); }
.counter { text-align: right; color: var(--muted); font-size: var(--text-subhead); font-variant-numeric: tabular-nums; }
.stack { position: relative; perspective: 1400px; min-height: 360px; }
.card { position: absolute; inset: 0; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab; }
.card.behind { transform: translateY(14px) scale(0.94); opacity: 0.7; transition: transform 0.4s var(--spring), opacity 0.3s; pointer-events: none; }
.inner { position: absolute; inset: 0; transform-style: preserve-3d; -webkit-transform-style: preserve-3d; transition: transform 0.55s var(--ease-out); }
.card.flipped .inner { transform: rotateY(180deg); }
.card:focus-visible { outline: none; }
.card:focus-visible .face { outline: 3px solid var(--accent); outline-offset: 3px; }
.face { position: absolute; inset: 0; border-radius: var(--radius-study); corner-shape: var(--corner); background: var(--paper); box-shadow: var(--shadow); backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; align-content: center; justify-items: center; gap: var(--space-3); padding: var(--space-8) var(--space-6); text-align: center; overflow: hidden; }
.face.back { transform: rotateY(180deg) translateZ(1px); align-content: start; justify-items: stretch; text-align: left; gap: var(--space-4); overflow-y: auto; overscroll-behavior-y: contain; }
/* Safari can paint a hidden backface for a frame (first paint of a card): the mirrored back
   side flashed. Two guards that leave the flip itself untouched:
   1. the back side is hidden until the card is turned, shown at the very start of the turn,
      and hidden again only after the card has turned all the way back (0.55s);
   2. the back sits 1px behind the front, so if Safari ever draws it anyway, the front covers it.
   (Hiding sides mid-turn made the flip blink and look worse, so nothing changes mid-turn.) */
.face.back { visibility: hidden; transition: visibility 0s linear 0.55s; }
.card.flipped .face.back { visibility: visible; transition-delay: 0s; }
.pos { font-size: var(--text-caption1); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.word { font: 600 clamp(var(--text-large-title), 10vw, var(--text-display-large))/1.05 var(--font-word); letter-spacing: var(--track-body); overflow-wrap: anywhere; }
.ipa { font: italic 400 var(--text-title3) var(--font-word); color: var(--muted); }
/* Not ".hint": that name is the form field hint, and the absolute position threw it to the page bottom. */
.flip-hint { position: absolute; bottom: 22px; left: 0; right: 0; text-align: center; font-size: var(--text-footnote); color: var(--muted); }
.face.back .word { font-size: var(--text-title1); }
.face.front[lang="uk"] .word { font-size: clamp(var(--text-title2), 6vw, var(--text-large-title)); line-height: var(--leading-title); }
.tr { font-size: var(--text-title2); font-weight: 600; line-height: var(--leading-title3); }
.tr span { color: var(--muted); font-weight: 400; }
.ex { font: italic 400 var(--text-body)/var(--leading-body) var(--font-word); padding-left: var(--space-4); border-left: 3px solid var(--accent-soft); }
.ex mark { background: none; color: var(--accent); font-weight: 600; font-style: normal; }
.syn { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.syn span { font-size: var(--text-subhead); padding: var(--space-1) var(--space-3); border-radius: 999px; background: var(--bg); }
.syn em { color: var(--muted); font-style: normal; }
/* Flip control in the corner of the answered card; it stays put while the card turns. */
.card-flip {
  position: absolute; top: 8px; right: 8px; z-index: 3; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted); background: transparent; font-size: var(--text-body);
}
.card-flip:hover { color: var(--fg); background: var(--surface); }
.card-flip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.stamp { position: absolute; top: 26px; padding: var(--space-2) var(--space-4); border-radius: 10px; font-weight: 700; font-size: var(--text-body); border: 3px solid currentColor; opacity: 0; pointer-events: none; z-index: 2; }
.stamp.know { left: 22px; color: var(--know); transform: rotate(-12deg); }
.stamp.again { right: 22px; color: var(--again); transform: rotate(12deg); }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.answer { min-height: 58px; border-radius: 18px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: var(--space-2); background: var(--surface); transition: transform 0.2s var(--ease-out); }
.answer:active { transform: scale(var(--press-scale)); transition-duration: var(--press-in); }
.answer.again { color: var(--again); }
.answer.know { color: var(--know); }
.answer svg { width: 18px; height: 18px; }
.answer-browse { color: var(--muted); }
.answer-browse[data-next] svg { transform: scaleX(-1); } /* browsing: chevrons, the arrows are keys */
.keys { text-align: center; color: var(--muted); font-size: var(--text-caption1); margin-top: var(--space-2); }
/* Keys (ui/small.js KeyHint): only where a keyboard is likely. On touch the swipe hint instead. */
.key-hint { display: none; }
@media (hover: hover) and (pointer: fine) {
  .key-hint {
    display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 var(--space-2);
    border: 1px solid var(--line); border-bottom-width: 2px; border-radius: var(--radius-segment-item); corner-shape: var(--corner);
    background: var(--fill); color: var(--muted);
    font: 500 var(--text-caption1) var(--font-ui); letter-spacing: var(--small-track); line-height: 1;
  }
  .flip-hint .key-hint { margin-inline-start: var(--space-2); vertical-align: 1px; }
  .keys { visibility: hidden; } /* keeps its row: the card stays centred */
}
/* Computer: a flashcard, not a phone-tall rectangle across the whole window. Wider and
   landscape, centred together with its buttons. (Phone keeps the tall card for the thumb.) */
/* The card stack keeps its 360px height there (it no longer stretches to the window). */
/* The card's centre is the window's centre: equal rows above and below it hold the top bar
   and the answers, so it stays centred whatever their heights and the window size.
   The breadcrumbs lie over the top padding instead of pushing the session down. */
@media (min-width: 900px) {
  .session { max-width: none; grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); gap: var(--space-6); padding-block: var(--space-16); }
  .session > .sess-top { align-self: end; }
  .session > :last-child { align-self: start; }
  .view:has(> .session) { position: relative; }
  .view:has(> .session) > .course-crumbs { position: absolute; top: 0; inset-inline: 0; }
}
.type-card { background: var(--paper); border-radius: var(--radius-study); corner-shape: var(--corner); box-shadow: var(--shadow); padding: var(--space-8) var(--space-6); display: grid; gap: var(--space-4); align-content: center; text-align: center; }
.type-card .verdict { font-weight: 600; }
.type-card .verdict.ok { color: var(--know); }
.type-card .verdict.bad { color: var(--again); }
.exercise { text-align: start; min-width: 0; }
.exercise fieldset { display: grid; gap: var(--space-2); border: 0; margin: 0; padding: 0; min-width: 0; }
/* With large system text (a phone at 200 %) the grid of answer circles is wider than the card:
   only the grid scrolls sideways, the task text keeps the card's width and wraps. Only on such
   narrow screens, so the scroll box never clips focus rings at normal sizes. */
.exercise fieldset > * { min-width: 0; }
@media (max-width: 22rem) { .exercise .answer-grid { overflow-x: auto; padding: var(--space-1); } }
.exercise legend { padding: 0; font: 600 var(--text-title2)/var(--leading-title3) var(--font-ui); overflow-wrap: anywhere; white-space: pre-line; }
.exercise-option > span { white-space: pre-line; }
.exercise-kind { color: var(--muted); margin: var(--space-2) 0; }
.exercise-figure { display: block; width: 100%; height: auto; }
.figure-photo { width: auto; max-width: 100%; max-height: min(55vh, 420px); margin-inline: auto; border-radius: var(--radius-group); corner-shape: var(--corner); background: var(--fill); }
.exercise-figure.figure-photo { max-height: min(40vh, 320px); }
.exercise-input-hint { margin: 0; color: var(--again); }
.exercise input[inputmode="decimal"] { min-height: 44px; }
.math-formula .katex { white-space: normal; overflow-wrap: normal; }
/* A mark next to an inline formula ("($x$).") stays on its line; the formula itself still wraps. */
.math-glue, .math-keep { white-space: nowrap; }
.math-glue > .math-formula { white-space: normal; }
.math-formula[data-display] { display: block; max-width: 100%; overflow-x: auto; }
.math-formula[data-display] > .katex-display { margin: .65em 0; }
.exercise-option { display: flex; gap: var(--space-3); align-items: center; min-height: 44px; padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-group); corner-shape: var(--corner); overflow-wrap: anywhere; }
.exercise-option { cursor: pointer; }
.exercise-option input { accent-color: var(--accent); flex: none; }
.exercise-option:has(:checked) { background: var(--accent-soft); border-color: var(--accent); }

/* NMT answer sheet: marked options, then a grid "rows × letters" (or one row of squares). */
.answer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.answer-list li { display: grid; grid-template-columns: 1.75em 1fr; gap: var(--space-2); align-items: baseline; overflow-wrap: anywhere; white-space: pre-line; }
.answer-list + .answer-list { margin-top: var(--space-1); padding-top: var(--space-3); border-top: 1px solid var(--line); }
.answer-mark { font-weight: 700; color: var(--accent); }
/* Columns shrink from 44px to 32px before a long sheet would scroll sideways on a phone. */
.answer-grid { display: grid; grid-template-columns: 2.5em repeat(var(--answer-cols), minmax(32px, 44px)); justify-content: start; align-items: center; margin-top: var(--space-2); }
.answer-line { display: contents; }
.answer-head, .answer-row { text-align: center; font-weight: 600; color: var(--muted); }
.answer-head { padding-bottom: var(--space-1); }
.answer-row { color: var(--fg); }
.answer-squares { display: grid; grid-template-columns: repeat(var(--answer-cols), minmax(32px, 44px)); margin-top: var(--space-2); }
.answer-cell { position: relative; display: grid; place-items: center; width: 100%; height: 44px; cursor: pointer; }
.answer-cell input {
  appearance: none; margin: 0; width: 28px; height: 28px; cursor: pointer;
  border: 2px solid var(--muted); border-radius: 6px; background: var(--surface);
  transition: background-color .15s var(--ease-out), border-color .15s var(--ease-out);
}
.answer-cell input:checked { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--paper); }
.answer-cell input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.answer-cell input:disabled { cursor: default; opacity: .6; }
.answer-cell span { position: absolute; font-size: var(--text-footnote); font-weight: 700; color: var(--muted); pointer-events: none; }
.answer-squares .answer-cell input:checked { box-shadow: none; }
.answer-cell:has(:checked) span { color: var(--on-accent); }
@media (prefers-reduced-motion: reduce) { .answer-cell input { transition: none; } }
/* Checked (Exercise review): your right answer is filled green with ✓, your wrong one filled with
   the error colour and ✕, the right one you did not pick is outlined green with ✓. Shape and
   icon tell them apart, not only the colour; the rest of the sheet stays faded. */
.answer-sign { display: inline-grid; place-items: center; flex: none; color: var(--know); }
.answer-sign svg { width: 16px; height: 16px; }
[data-mark="wrong"] > .answer-sign { color: var(--again); }
.answer-cell[data-mark] input:disabled { opacity: 1; }
.answer-cell[data-mark="right"] input { background: var(--know); border-color: var(--know); box-shadow: none; }
.answer-cell[data-mark="wrong"] input { background: var(--again); border-color: var(--again); box-shadow: none; }
.answer-cell[data-mark="missed"] input { background: var(--know-soft); border-color: var(--know); }
.answer-cell[data-mark="right"] > .answer-sign, .answer-cell[data-mark="wrong"] > .answer-sign { color: var(--on-accent); }
.answer-cell[data-mark="missed"] > .answer-sign { color: var(--know); }
.answer-squares .answer-cell[data-mark="missed"] span { color: var(--know); }
.answer-list li[data-mark] { grid-template-columns: 1.75em 1fr auto; }
.exercise-option[data-mark] { cursor: default; }
.exercise-option[data-mark="right"] { border-color: var(--know); background: var(--know-soft); }
.exercise-option[data-mark="wrong"] { border-color: var(--again); background: var(--again-soft); }
.exercise-option[data-mark="missed"] { border: 2px solid var(--know); padding: calc(var(--space-2) - 1px) calc(var(--space-3) - 1px); background: none; }
.exercise-option > .answer-sign { margin-inline-start: auto; }
.exercise-option[data-mark] input:disabled { opacity: 1; }
.exercise .verdict { white-space: pre-line; }
.verdict:empty, #save-error:empty { display: none; }
#save-error { color: var(--again); margin-bottom: var(--space-2); }
/* minmax(0, …): a wide formula or table scrolls in its own block instead of widening the column. */
.lesson-notes { max-width: 72ch; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); line-height: var(--leading-read); overflow-wrap: anywhere; }
.lesson-notes ul, .lesson-notes ol { margin: 0; padding-inline-start: 1.5em; }
.lesson-notes + #lesson-items { margin-top: var(--space-6); }
.lesson-figure { margin: var(--space-1) 0; display: grid; gap: var(--space-2); justify-items: center; }
.lesson-figure-image { display: block; max-width: 100%; height: auto; }
.lesson-figure figcaption { color: var(--muted); font-size: var(--text-footnote); text-align: center; overflow-wrap: anywhere; }
.notes-quote { margin: var(--space-1) 0; padding: var(--space-1) 0 var(--space-1) var(--space-4); border-inline-start: 3px solid var(--accent); }
.notes-quote p { margin: 0; font-style: italic; }
.notes-quote footer { margin-top: var(--space-2); color: var(--muted); font-size: var(--text-footnote); }
/* nmt-notes-table (ui/lesson-notes.js): a table that does not fit its column becomes cards,
   one row per card, the column name before each value. */
.notes-table { display: block; overflow-x: auto; }
.notes-table table { border-collapse: collapse; min-width: 100%; font-size: var(--text-subhead); line-height: var(--leading-body); }
.notes-table th, .notes-table td {
  padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); text-align: start; vertical-align: top;
  /* Not `anywhere` from .lesson-notes: it lets a column shrink to a letter and split words. */
  overflow-wrap: normal; hyphens: auto;
}
.notes-table th { color: var(--muted); font-weight: 600; }
.notes-table-cards thead { display: none; }
.notes-table-cards table, .notes-table-cards tbody, .notes-table-cards tr, .notes-table-cards td { display: block; }
.notes-table-cards tr { padding-block: var(--space-2); border-bottom: 1px solid var(--line); }
.notes-table-cards td { padding: var(--space-1) 0; border: 0; overflow-wrap: break-word; }
.notes-table-cards td:first-child { font-weight: 600; }
.notes-table-cards td:not(:first-child)[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 400; }
.notes-table-cards td:empty { display: none; }
/* On a phone tighter cells let most tables stay tables. */
@media (max-width: 440px) {
  .notes-table table { font-size: var(--text-subhead); }
  .notes-table th, .notes-table td { padding: var(--space-2) var(--space-1); }
  .notes-table th:first-child, .notes-table td:first-child { padding-inline-start: 0; }
  .notes-table-cards td { padding: var(--space-1) 0; }
}

/* ---------- Widgets of the notes (ui/widget.js, widgets/) ---------- */
nmt-widget { display: block; min-width: 0; }
.widget {
  display: grid; gap: var(--space-4); min-width: 0; padding: var(--space-4); container-type: inline-size;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-group); corner-shape: var(--corner);
}
.widget > * { min-width: 0; }
/* The same limit as in .lesson-notes, for every grid between the widget and a formula. */
.steps-body, .steps-list, .steps-step, .quick-check-item, .quick-check .exercise, .quick-check .exercise fieldset {
  grid-template-columns: minmax(0, 1fr);
}
.quick-check .exercise-option > span { min-width: 0; }
.widget-kind, .widget-hint, .widget-stub { color: var(--muted); font-size: var(--text-subhead); }
.widget-stub { padding: var(--space-4) var(--space-4); border: 1px dashed var(--line); border-radius: var(--radius-group); corner-shape: var(--corner); }
.widget-title { margin: 0; font-size: var(--text-title3); }
.widget-actions { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: center; }

/* step-solution: a rail of numbered steps, the rule under each */
.steps-task { font-size: var(--text-body); font-weight: 600; }
.steps-body { display: grid; gap: var(--space-3); min-width: 0; }
.lesson-notes .steps-list { list-style: none; counter-reset: step; display: grid; padding: 0; }
.steps-step { position: relative; counter-increment: step; display: grid; gap: var(--space-2); min-width: 0; padding: var(--space-1) 0 var(--space-4) var(--space-12); }
.steps-step::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--subject-math); color: var(--surface); font-size: var(--text-subhead); font-weight: 700;
}
.steps-step::after { content: ""; position: absolute; left: 13px; top: 32px; bottom: 4px; width: 2px; border-radius: var(--radius-indicator); background: var(--line); }
.steps-step:last-child::after { content: none; }
.steps-step > * { min-width: 0; }
.steps-why { padding: var(--space-2) var(--space-3); border-radius: var(--radius-action); corner-shape: var(--corner); background: color-mix(in srgb, var(--again) 8%, var(--surface)); font-size: var(--text-subhead); }
.steps-why b { color: var(--again); }
.steps-answer { padding: var(--space-3) var(--space-4); border-radius: var(--radius-action); corner-shape: var(--corner); background: color-mix(in srgb, var(--know) 8%, var(--surface)); font-weight: 600; }
.steps-answer b { color: var(--know); }
.steps-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-1) var(--space-3); }
.steps-count { color: var(--muted); font-size: var(--text-subhead); font-variant-numeric: tabular-nums; }

/* quick-check: the usual exercise, flat and compact inside the notes */
.quick-check-item { display: grid; gap: var(--space-3); min-width: 0; }
.quick-check-item + .quick-check-item { border-top: 1px solid var(--line); padding-top: var(--space-4); }
.quick-check .exercise { padding: 0; background: none; box-shadow: none; border-radius: 0; gap: var(--space-3); }
.quick-check .exercise legend { max-width: 100%; font-size: var(--text-body); line-height: var(--leading-body); }
.quick-check .exercise-kind { margin: 0; font-size: var(--text-subhead); }
.quick-check .exercise-option { background: var(--surface); }
.quick-check .exercise-option:has(:checked) { background: var(--accent-soft); }
.quick-check .exercise .btn { width: auto; min-height: 44px; justify-self: start; }
.quick-check .field input { width: 100%; max-width: 280px; }
.quick-check-result { padding: var(--space-3) var(--space-4); border-radius: var(--radius-action); corner-shape: var(--corner); font-size: var(--text-subhead); }
.quick-check-result:empty { padding: 0; margin-top: calc(var(--space-3) * -1); }
.quick-check-result[data-state="right"] { background: color-mix(in srgb, var(--know) 8%, var(--surface)); }
.quick-check-result[data-state="right"] b { color: var(--know); }
.quick-check-result:is([data-state="wrong"], [data-state="hint"]) { background: color-mix(in srgb, var(--again) 8%, var(--surface)); }
.quick-check-result:is([data-state="wrong"], [data-state="hint"]) b { color: var(--again); }

/* function-graph. The colors of roles are the same in every widget (docs/content/math-widgets.md). */
.graph-formula { font-size: var(--text-title2); }
.graph-body { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); }
.graph-picture, .graph-controls { display: grid; gap: var(--space-3); align-content: start; min-width: 0; }
.graph-svg {
  display: block; width: 100%; height: auto; touch-action: pan-y; cursor: crosshair;
  background: var(--surface); border-radius: var(--radius-action); corner-shape: var(--corner);
}
.graph-line { color: var(--subject-math); }
.graph-cross { color: var(--accent); }
.graph-root { color: var(--know); }
.graph-vertex { color: var(--again); }
.graph-axis { color: var(--started); }
.graph-here { color: var(--fg); }
.graph-grid { stroke: var(--graph-grid); }
.graph-axes { fill: none; stroke: var(--graph-axis); stroke-width: 1.4; }
.graph-arrow { fill: var(--graph-axis); }
.graph-tick { fill: var(--muted); font: var(--text-footnote) var(--font-ui); }
.graph-axis-name { fill: var(--muted); font: italic var(--text-callout) var(--font-word); }
.graph-curve { fill: none; stroke: var(--subject-math); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.graph-symmetry { stroke: var(--started); stroke-width: 1.5; stroke-dasharray: 5 5; }
.graph-why { fill: none; stroke: var(--again); stroke-width: 2; }
.graph-level { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 6 4; }
.graph-trace { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 3 4; }
.graph-dot { fill: currentColor; stroke: var(--surface); stroke-width: 2; }
.graph-label { fill: currentColor; font: 600 var(--text-subhead) var(--font-ui); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.graph-slider { display: grid; grid-template-columns: 24px minmax(0, 1fr) 48px; gap: var(--space-2); align-items: center; }
.graph-slider label { font: italic var(--text-title3) var(--font-word); text-align: center; }
.graph-slider input { width: 100%; min-height: 44px; margin: 0; accent-color: var(--subject-math); touch-action: pan-y; }
.graph-slider output { text-align: end; font-weight: 600; font-variant-numeric: tabular-nums; }
.graph-presets { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.graph-preset { min-height: 44px; padding: var(--space-1) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-action); corner-shape: var(--corner); background: var(--surface); font-size: var(--text-subhead); }
.graph-preset[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.graph-warning { color: var(--again); font-size: var(--text-subhead); font-weight: 600; }
.graph-why-toggle { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: var(--space-3); align-items: center; min-height: 44px; cursor: pointer; font-size: var(--text-subhead); line-height: var(--leading-headline); }
.graph-why-toggle input { width: 22px; height: 22px; margin: 0; accent-color: var(--again); }
.graph-explain { padding: var(--space-3) var(--space-3); border-radius: var(--radius-action); corner-shape: var(--corner); background: color-mix(in srgb, var(--again) 8%, var(--surface)); font-size: var(--text-subhead); }
.lesson-notes .graph-facts { list-style: none; padding: 0; display: grid; gap: var(--space-2) var(--space-6); font-size: var(--text-subhead); }
.graph-facts li { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: var(--space-3); align-items: baseline; }
.graph-swatch { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.graph-table { width: 100%; max-width: 440px; table-layout: fixed; border-collapse: collapse; font-size: var(--text-subhead); font-variant-numeric: tabular-nums; }
.graph-table caption { padding-bottom: var(--space-2); color: var(--muted); font-size: var(--text-subhead); text-align: start; }
.graph-table :is(th, td) { height: 44px; padding: 0; border: 1px solid var(--line); text-align: center; font-weight: 500; overflow-wrap: normal; background: var(--surface); }
.graph-table th[scope="row"] { color: var(--muted); font: italic var(--text-body) var(--font-word); }
.graph-table .graph-key { font-weight: 700; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.graph-table button { width: 100%; height: 44px; font-weight: inherit; font-variant-numeric: inherit; }
.graph-table button:hover { background: var(--fill); }
.graph-table button:focus-visible { outline-offset: -3px; }
@container (min-width: 520px) {
  .graph-body { grid-template-columns: minmax(0, 1fr) minmax(0, 240px); }
  .lesson-notes .graph-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: no-preference) {
  .steps-step, .steps-answer { animation: widget-appear .32s var(--ease-out) both; }
  .graph-play .graph-reveal { animation: graph-reveal .36s var(--ease-out) both; animation-delay: calc(var(--step) * 200ms); }
}
@keyframes widget-appear { from { opacity: 0; transform: translateY(8px); } }
@keyframes graph-reveal { from { opacity: 0; } }

/* ---------- SubjectTabs, SubjectNotes, SubjectReference (ui/subject.js) ---------- */
.view:has(> .subject-tabs, > .subject-deck, [data-topic-mark]) > .nav {
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
}
.view:has(> .subject-tabs, > .subject-deck, [data-topic-mark]) > .nav .nav-title {
  overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap;
}
.subject-tabs {
  position: relative; display: flex; align-items: center; gap: var(--space-2); min-width: 0; overflow-x: auto;
  padding-block: var(--space-1);
  touch-action: pan-x pan-y;
}
.subject-tabs a {
  display: inline-flex; align-items: center; min-height: 44px; flex: 0 0 auto; padding: 0 var(--space-4);
  border: 1px solid var(--card-border); border-radius: var(--radius-button); corner-shape: var(--corner);
  background: var(--surface); color: var(--fg);
  font-weight: 600; text-decoration: none;
}
.subject-tabs a[aria-current="page"] {
  background: var(--primary); color: var(--on-primary); border-color: var(--primary);
}
.subject-tabs a[aria-current="page"]:focus-visible { outline-color: var(--on-primary); }
.subject-tabs a:focus-visible, .subject-disclosure summary:focus-visible { outline-offset: -3px; }
.subject-group, .subject-notes { display: grid; min-width: 0; gap: var(--space-2); }
.subject-group + .subject-group { margin-top: var(--space-4); }
.subject-group h2 { margin: 0; font-size: var(--text-title3); font-weight: 650; overflow-wrap: anywhere; }
.subject-group > .btn { justify-self: start; }
.subject-disclosure {
  border: 1px solid var(--line); border-radius: var(--radius-group); corner-shape: var(--corner); background: var(--surface);
}
.subject-disclosure summary {
  padding: var(--space-3) var(--space-4); min-height: 44px; cursor: pointer; font-weight: 600; overflow-wrap: anywhere;
}
.subject-disclosure[open] summary { border-block-end: 1px solid var(--line); }
.subject-disclosure > :not(summary) { padding: var(--space-3) var(--space-4); }
.subject-disclosure > .subject-mistakes-topic { padding-inline: 0; }
.subject-mistakes-topic h3 { margin: 0; padding-inline: var(--space-4); font-size: var(--text-callout); overflow-wrap: anywhere; }
.subject-mistakes-topic :is(.answer-grid, .answer-squares) { overflow-x: auto; }
.subject-mistakes-topic :is(.answer-cell, .exercise-option) { cursor: default; }
.subject-mistakes-topic .answer-cell input:disabled { opacity: 1; }
.subject-mistakes-topic .exam-question h4 { margin: 0; font-size: var(--text-body); overflow-wrap: anywhere; white-space: pre-line; }
.subject-mistakes-topic .btn { margin-inline-start: var(--space-4); }
.subject-deck { display: grid; gap: var(--space-4); }
.subject-deck > :is(.btn, .seg) { justify-self: start; max-width: 100%; }
.subject-deck .seg button { min-width: 44px; min-height: 44px; padding-inline: clamp(var(--space-2), 2vw, var(--space-3)); }
.subject-reference { width: 100%; table-layout: fixed; border-spacing: 0; overflow-wrap: anywhere; }
.subject-reference th, .subject-reference td { text-align: start; padding: var(--space-2) var(--space-1); vertical-align: top; }
.subject-reference tr + tr > * { border-block-start: 1px solid var(--line); }
.btn[data-topic-mark][aria-pressed="true"] { background: var(--fill); color: var(--know); }
.btn[data-topic-mark][aria-pressed="true"]::before { content: "✓" / ""; }
#lesson-items { display: grid; gap: var(--space-3); }
/* .session-done, not .done: .day.done (week strip) uses that name. */
.session-done { display: grid; gap: var(--space-6); justify-items: center; text-align: center; align-content: center; min-height: 60dvh; }
.session-done .big { font: 600 var(--text-display-large)/1 var(--font-word); }
.done-stats { display: flex; gap: var(--space-8); }
.done-stats div { display: grid; gap: var(--space-1); }
.done-stats b { font-size: var(--text-large-title); font-weight: 700; font-variant-numeric: tabular-nums; }
.done-stats .k { color: var(--know); }
.done-stats .a { color: var(--again); }
.done-stats span { color: var(--muted); font-size: var(--text-subhead); }

/* ---------- Forms on a surface, upload result (screens/mywords.js) ---------- */
.inline-form { display: grid; gap: var(--space-3); background: var(--surface); border-radius: var(--radius-group); corner-shape: var(--corner); padding: var(--space-4); }
.result { background: var(--surface); border-radius: var(--radius-group); corner-shape: var(--corner); padding: var(--space-4) var(--space-4); display: grid; gap: var(--space-2); font-size: var(--text-subhead); }
.result .err { color: var(--again); font-size: var(--text-subhead); }

.course-crumbs { display: none; }
.nav .back { min-width: 0; max-width: 100%; }
.nav .back svg { flex: none; }
.nav .back span, .nav-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* fit-content(50%): a long small title must not squeeze the back label to an empty arrow. */
.view > .nav { grid-template-columns: minmax(0, 1fr) fit-content(50%) minmax(0, 1fr); }
.view > .nav:has(> .back[href="/app/"]) {
  grid-template-columns: minmax(max-content, 1fr) minmax(0, 2fr) minmax(0, 1fr);
}
@media (min-width: 900px) {
  .course-crumbs { display: block; margin-block: var(--space-2); }
  /* The trail already links every level, so the Up arrow would only repeat its last link.
     The bar itself stays: it shows the small title after scrolling. */
  .course-crumbs + .nav .back { visibility: hidden; }
  .course-crumbs ol { display: flex; list-style: none; margin: 0; padding: 0; }
  .course-crumbs li { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
  .course-crumbs li + li { margin-left: var(--space-2); }
  .course-crumbs a, .course-crumbs [aria-current] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .course-crumbs a { color: var(--accent); padding-block: var(--space-2); }
  .course-crumbs span { color: var(--muted); }
}

/* English topic list, lesson tiles and the topic's daily queue. */
.english-topics, .english-units, .english-lesson, .english-today, .english-dialog form { display: grid; gap: var(--space-3); }
.english-topics .row, .english-units .row, .english-add, .english-today {
  border: 1px solid var(--line); border-radius: var(--radius-group); corner-shape: var(--corner); background: var(--paper); padding: var(--space-4);
}
.english-topics .row + .row::before, .english-units .row + .row::before { display: none; }
.english-topics .t1, .english-units .t1 { font: 600 var(--text-title2)/var(--leading-title) var(--font-word); }
.english-add { display: grid; place-items: center; min-height: 52px; border-style: dashed; color: var(--accent); text-decoration: none; cursor: pointer; }
.english-units { grid-template-columns: repeat(auto-fill, minmax(142px, 1fr)); }
.english-units .row { min-height: 94px; grid-template-columns: 1fr; }
.english-new-unit summary { height: 100%; }
.english-new-unit[open] { grid-column: 1 / -1; }
.english-new-unit[open] summary { height: auto; }
.english-today { padding: var(--space-6); }
.english-today h2, .english-today .note { margin: 0; padding: 0; }
.english-topic-activity, .english-limit, .english-lesson-upload { display: grid; gap: var(--space-3); }
.english-lesson-upload > button { justify-self: start; }
.english-limit-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.english-limit-steps { display: flex; gap: var(--space-2); }
.english-limit-steps .btn { width: 44px; height: 44px; padding: 0; font-size: var(--text-title2); }
.english-limit-error { color: var(--again); }
.english-metrics { display: flex; gap: clamp(var(--space-4), 5vw, var(--space-16)); }
.english-metrics b { display: block; font: 600 var(--text-large-title)/var(--leading-title) var(--font-word); }
.english-metrics span, .paper-seen { font-size: var(--text-subhead); color: var(--muted); }
.english-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.english-modes .btn { padding: var(--space-3); min-height: 60px; border-radius: var(--radius-group); corner-shape: var(--corner); }
.english-dialog { margin: auto; padding: var(--space-6); max-width: min(92vw, 30rem); color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); corner-shape: var(--corner); }
.english-dialog::backdrop { background: color-mix(in srgb, var(--fg) 30%, transparent); }
.english-remove, .paper-detail { min-width: 44px; min-height: 44px; border-radius: var(--radius-group); corner-shape: var(--corner); }
.english-remove { color: var(--again); background: var(--fill); grid-column: 2; grid-row: 1 / 3; }
.english-lesson .word-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-1) var(--space-2); }
.english-lesson .word-row > span { grid-column: 1; text-align: left; padding-left: var(--space-4); }
.english-lesson .dot { background: var(--fill); }
.english-lesson .dot.known { background: var(--know); }
.english-lesson .dot.started { background: var(--started); }
.word-row.word-choice, .english-lesson .word-row.word-choice {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-1) var(--space-3);
  min-height: 44px;
  cursor: pointer;
}
.word-choice input { grid-area: 1 / 1 / span 2; margin: 0; inline-size: 20px; block-size: 20px; accent-color: var(--primary); }
.word-choice b, .word-row.word-choice .word-choice-detail { grid-column: 2; text-align: start; padding: 0; }
.word-choice:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
.own-words-backup, .words-export-screen, .words-export-group, .word-export-part { display: grid; gap: var(--space-3); }
.own-words-backup, .word-export-part { border: 1px solid var(--line); border-radius: var(--radius-group); corner-shape: var(--corner); background: var(--paper); padding: var(--space-4); }
.own-words-backup .note, .words-export-screen .note, .word-export-part .note { margin: 0; padding: 0; }
[data-import-result]:empty, [data-export-error]:empty, [data-part-status]:empty { display: none; }
.words-export-group + .words-export-group { margin-block-start: var(--space-4); }
.words-export-group h2, .word-export-part h2 { overflow-wrap: anywhere; }
.word-export-part summary { min-height: 44px; align-content: center; color: var(--accent); cursor: pointer; }
.words-part-group li, .own-words-backup .result li { overflow-wrap: anywhere; }

.card .face.front { background-image: repeating-linear-gradient(transparent 0 35px, var(--paper-rule) 35px 36px); border: 1px solid var(--line); }
.card .face.front::before { content: ""; position: absolute; inset: 60px 0 auto; border-top: 2px solid var(--paper-margin); }
.card .face.front .pos { position: absolute; top: 18px; inset-inline: 16px; color: var(--accent); }
.paper-translations { list-style-position: inside; padding: 0; font-size: clamp(var(--text-title3), 5vw, var(--text-title1)); font-weight: 600; max-height: 100%; overflow-y: auto; overflow-wrap: anywhere; }
.paper-translations li::marker { font: var(--text-footnote) var(--font-mono); color: var(--muted); }
.card .face.front:has(.paper-translations) { padding-block: 74px 52px; }
/* Phone turned sideways: the card is about 180px tall, and the usual 126px of padding left the
   translations an 11px strip. Smaller margins and type keep two or three lines readable. */
@media (orientation: landscape) and (max-height: 500px) {
  .card .face.front:has(.paper-translations) { padding-block: 46px 34px; }
  .card .face.front::before { inset-block-start: 36px; }
  .paper-tag { top: 8px; }
  .paper-translations { font-size: clamp(var(--text-body), 6dvh, var(--text-title1)); }
  .card .face.back .word { font-size: clamp(var(--text-title1), 11dvh, var(--text-display-large)); }
}
.card .ipa { font: var(--text-subhead) var(--font-mono); }
.card .face.back { text-align: center; align-content: safe center; }
.card .face.back .word { font-size: clamp(var(--text-large-title), 9vw, var(--text-display-large)); }
.card .ex { border: 0; background: var(--fill); border-radius: var(--radius-group); corner-shape: var(--corner); padding: var(--space-3) var(--space-4); }
.paper-details { display: flex; justify-content: center; align-items: start; flex-wrap: wrap; gap: var(--space-2); }
.paper-details .syn { flex-basis: 100%; }
.paper-detail { padding-inline: var(--space-3); background: var(--accent-soft); color: var(--accent); }
.answers { grid-template-columns: 44px 1fr 1fr 44px; gap: var(--space-2); }
.answers .answer { min-height: 52px; border: 1px solid var(--line); border-radius: var(--radius-group); corner-shape: var(--corner); }
.answers .answer:disabled { opacity: .45; }
.answer.know { border-color: var(--know); }
.answer.again { border-color: var(--again); }
@media (min-width: 900px) {
  .english-topics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.paper-title { grid-column: 2; text-align: center; font: 600 var(--text-title2) var(--font-word); }
.sess-top .counter { grid-area: 1 / 3; }
.sess-top .progress { grid-column: 1 / -1; }
.paper-tag { position: absolute; top: 14px; left: 12px; padding: var(--space-1) var(--space-2); background: var(--accent-soft); color: var(--accent); font-size: var(--text-caption1); border-radius: var(--radius-group); corner-shape: var(--corner); }
.card[data-english="true"] .pos { inset-inline: 86px 8px; }
.session:has(.paper-translations) { grid-template-rows: minmax(0, 1fr) min(51dvh, 430px) minmax(0, 1fr); }
.session:has(.paper-translations) > .sess-top { align-self: end; }
.session:has(.paper-translations) > :last-child { align-self: start; }
/* Computer: a short window shrinks the card rather than push it off centre;
   344px is the padding, the top bar and a gap, twice. */
@media (min-width: 900px) {
  .session:has(.paper-translations) { grid-template-rows: minmax(0, 1fr) clamp(240px, 100dvh - 344px, 430px) minmax(0, 1fr); }
  .session > .stack { min-height: clamp(240px, 100dvh - 344px, 360px); }
}
.session:has(.paper-translations) .stack { min-height: 0; }
.paper-score { grid-column: 1 / -1; display: flex; gap: var(--space-4); color: var(--muted); font-size: var(--text-footnote); }
.paper-score [data-know-count] { color: var(--know); }
.paper-score [data-again-count] { color: var(--again); }

.subject-tabs { scrollbar-width: none; }
.subject-tabs::-webkit-scrollbar { display: none; }
.subject-tabs-more { mask-image: linear-gradient(to right, var(--fg) calc(100% - 24px), transparent); }
.subject-step-index { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.subject-step-index a, .subject-next { display: inline-flex; align-items: center; color: var(--accent); min-height: 44px; }
.subject-step-index a { padding: var(--space-1) var(--space-3); border-radius: var(--radius-group); corner-shape: var(--corner); background: var(--accent-soft); text-decoration: none; font-size: var(--text-subhead); }
.subject-group[id^="subject-step-"] { scroll-margin-top: 64px; }
.subject-due-empty { font-size: var(--text-callout); color: var(--muted); }
/* NMT readiness on the subject overview (decision 0103) */
.readiness-scale { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-1) 0; }
.readiness-scale p, .readiness-few { margin: 0; font-size: var(--text-callout); color: var(--muted); }
.readiness-figure { font-variant-numeric: tabular-nums; color: var(--muted); font-size: var(--text-callout); text-align: right; }
.readiness-note { margin: 0; font-size: var(--text-footnote); color: var(--muted); letter-spacing: var(--small-track); padding-inline: var(--space-4); }
.subject-offline-hint { margin: 0; font-size: var(--text-footnote); color: var(--muted); }
@media (min-width: 1100px) {
  .view:has(> .cols) .subject-step-index { display: none; }
}

/* FAQ in the cabinet: rows of the grouped list that open in place. */
.faq-row + .faq-row { border-top: 1px solid var(--line); }
.faq-row summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-4); align-items: center;
  min-height: 52px; padding: var(--space-3) var(--space-4); cursor: pointer; list-style: none; font-weight: 600;
}
.faq-row summary::-webkit-details-marker { display: none; }
.faq-row summary:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.faq-row summary .chev { transition: transform .2s var(--ease-out); color: var(--muted); }
.faq-row[open] summary .chev { transform: rotate(90deg); }
.faq-row p { margin: 0; padding: 0 var(--space-4) var(--space-4); color: var(--muted); line-height: var(--leading-read); }
@media (prefers-reduced-motion: reduce) { .faq-row summary .chev { transition: none; } }

/* ---------- Study plan (ui/plan.js) ---------- */
.plan-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card); corner-shape: var(--corner);
  display: grid;
  align-content: start;
  gap: var(--space-4);
  padding: var(--space-6);
  min-width: 0;
  overflow-wrap: anywhere;
}
.plan-panel h2, .plan-schedule > h2 { font-size: var(--text-title2); line-height: var(--leading-title); }
.plan-topic-title { color: inherit; text-decoration: none; }
.plan-view, .plan-saved, .plan-schedule { display: grid; gap: var(--space-4); }
.plan-form { width: 100%; max-width: 680px; }
.plan-form[hidden], .plan-error:empty { display: none; }
.plan-range-hint { margin: calc(var(--space-2) * -1) 0 0; text-align: center; color: var(--muted); font-size: var(--text-footnote); }
.plan-form-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.plan-form input, .plan-topic-editor input { width: 100%; min-width: 0; }
.plan-form input[type="number"] { max-width: 108px; }
.plan-form > .seg { justify-self: start; }
.plan-form[data-mode="pace"] .plan-dates { grid-template-columns: minmax(0, 1fr); }
.plan-rate { display: grid; gap: var(--space-2); }
.plan-rate-row, .plan-rate-buttons { display: flex; align-items: end; gap: var(--space-2); }
.plan-rate-row { flex-wrap: wrap; }
.plan-rate-row input[type="number"] { appearance: textfield; }
.plan-rate-row input::-webkit-inner-spin-button { appearance: none; }
.plan-rate-buttons .btn { min-width: 44px; min-height: 44px; padding: 0; font-size: var(--text-title2); }
.plan-forecast, .plan-rate-summary { margin: 0; font-size: var(--text-subhead); color: var(--muted); }
.plan-weekdays { border: 0; min-inline-size: 0; padding: 0; margin: 0; }
.plan-weekdays legend { color: var(--muted); font-size: var(--text-footnote); margin-block-end: var(--space-2); }
.plan-weekdays > div, .plan-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.plan-buttons .btn { text-align: center; white-space: normal; }
.plan-weekdays label { position: relative; }
.plan-weekdays input { position: absolute; inset: 0; block-size: 100%; margin: 0; opacity: 0; cursor: pointer; }
.plan-weekdays span {
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-group); corner-shape: var(--corner);
  background: var(--fill);
  color: var(--fg);
  font-weight: 600;
}
.plan-weekdays input:checked + span { background: var(--accent); color: var(--on-accent); }
.plan-weekdays input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.plan-progress { display: grid; gap: var(--space-2); color: var(--muted); font-size: var(--text-subhead); }
.plan-progress .bar { width: 100%; }
.plan-pace { font-size: var(--text-subhead); font-weight: 600; }
.plan-pace-on, .plan-status-done { color: var(--know); }
.plan-pace-behind, .plan-status-overdue, .plan-error { color: var(--started); }
.plan-status-today { color: var(--accent); }
.plan-month { display: grid; gap: var(--space-2); }
.plan-month h3 { color: var(--muted); font-size: var(--text-callout); font-weight: 600; }
.plan-month ol { margin: 0; padding: 0; list-style: none; background: var(--surface); border-radius: var(--radius-group); corner-shape: var(--corner); }
.plan-topic { display: grid; gap: 0 var(--space-3); padding: var(--space-2) var(--space-4); min-width: 0; scroll-margin-top: calc(74px + env(safe-area-inset-top)); }
.plan-topic + .plan-topic { border-top: 1px solid var(--line); }
.plan-topic-today { background: var(--accent-soft); border-radius: var(--radius-group); corner-shape: var(--corner); }
.plan-topic-title { display: grid; align-content: center; gap: var(--space-1); min-height: 44px; min-width: 0; overflow-wrap: anywhere; }
.plan-topic-title b { font-weight: 600; }
.plan-topic-notes { color: var(--muted); display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-size: var(--text-footnote); }
.plan-topic-notes :is(.plan-status-done, .plan-status-today, .plan-status-overdue) { font-weight: 600; }
.plan-topic-editor summary { min-height: 44px; color: var(--accent); cursor: pointer; font-size: var(--text-subhead); align-content: center; }
.plan-topic-editor form { display: grid; gap: var(--space-2); padding-block-end: var(--space-2); }
.plan-topic-editor form .field { max-width: 240px; }
@media (min-width: 660px) {
  .plan-topic:has(.plan-topic-editor) { grid-template-columns: minmax(0, 1fr) minmax(144px, auto); align-items: start; }
  .plan-topic-editor:has([data-plan-topic]) { max-width: 320px; }
}
@media (max-width: 440px) {
  .plan-form { padding: var(--space-4); }
  .plan-form-dates { grid-template-columns: minmax(0, 1fr); }
  .plan-weekdays > div { gap: var(--space-1); }
}

/* Lesson plans and word tests share the regular plan and exercise controls. */
.plan-topic[data-current-unit] { background: var(--accent-soft); border-radius: var(--radius-group); corner-shape: var(--corner); }
.plan-unit-label, .english-current { font-weight: 600; }
.plan-unit-action { grid-column: 1 / -1; padding-block: var(--space-1); }
.plan-unit-action .btn.secondary { background: var(--surface); }
.session-done-actions { justify-content: center; }
.word-test { width: 100%; max-width: 640px; margin-inline: auto; }
body:has(.word-test) .offline-bar { pointer-events: none; }
body:has(.word-test):has(.offline-bar:not([hidden])) .main {
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 100px);
}
.word-test-question { justify-items: start; }
.word-test-question fieldset { display: grid; gap: var(--space-2); border: 0; margin: 0; padding: 0; min-inline-size: 0; width: 100%; }
.word-test-question legend { font: 600 var(--text-title2) var(--font-head); margin-block-end: var(--space-2); overflow-wrap: anywhere; }
.word-test-error:empty { display: none; }
.word-test-error { color: var(--again); }
.word-test-result { overflow-wrap: anywhere; }
.word-test-errors { display: grid; gap: var(--space-3); padding-inline-start: var(--space-6); }
.word-test-errors li span { display: block; }

/* ---------- Work on mistakes (decision 0104): portion, reflection, results ---------- */
.mistakes-portion { display: grid; gap: var(--space-3); background: var(--surface); border: 1px solid var(--card-border);
  border-radius: var(--radius-group); corner-shape: var(--corner); padding: var(--space-4); }
.mistakes-portion h2 { margin: 0; }
.mistakes-count { margin: 0; display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; font-size: var(--text-body); }
.mistakes-count b { font: var(--head-weight) var(--text-display)/1 var(--font-head); letter-spacing: var(--head-track); font-variant-numeric: tabular-nums; }
.mistakes-count span { color: var(--muted); font-size: var(--text-subhead); }
.mistakes-portion .seg { justify-self: start; }
.mistakes-portion .seg button { min-width: 56px; min-height: 44px; }
.mistakes-topics { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mistakes-topics li { background: var(--fill); border-radius: 999px; padding: var(--space-1) var(--space-3); font-size: var(--text-footnote); letter-spacing: var(--small-track); }
.mistakes-win { margin: 0; display: flex; align-items: center; gap: var(--space-2); color: var(--know); background: var(--know-soft);
  border-radius: var(--radius-action); corner-shape: var(--corner); padding: var(--space-3) var(--space-3); font-size: var(--text-subhead); font-weight: 600; }
.mistakes-win svg { flex: none; width: 18px; height: 18px; }
.mistakes-rest { display: grid; gap: var(--space-1); justify-items: start; }
.mistakes-rest b { font-size: var(--text-title3); }
.mistakes-rest span:not(.mistakes-rest-icon) { color: var(--muted); font-size: var(--text-subhead); }
.mistakes-rest-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  color: var(--know); background: var(--know-soft); }
.mistakes-rest-icon svg { width: 24px; height: 24px; }
.mistakes-all > summary { font-weight: 600; }
.mistake-reflection { display: grid; gap: var(--space-2); margin-top: var(--space-1); }
.mistake-reflection > p { margin: 0; font-weight: 600; }
.mistake-reasons { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mistake-reason { min-height: 44px; padding: var(--space-2) var(--space-4); border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--fg); font: inherit; font-size: var(--text-subhead); cursor: pointer;
  transition: transform var(--press-in) var(--ease-out); }
.mistake-reason:active { transform: scale(var(--press-scale)); }
.mistake-reason[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.mistake-notes { justify-self: start; color: var(--accent); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.mistakes-done .big { font-size: var(--text-display); }
.mistakes-done .mistakes-win { justify-self: center; }
@media (prefers-reduced-motion: reduce) { .mistake-reason { transition: none; } }
.course-today-mistakes > span { display: grid; gap: var(--space-1); }
.course-today-mistakes b { color: var(--fg); font-size: var(--text-subhead); font-weight: 600; }
.course-today-mistakes small { color: var(--know); font-size: var(--text-footnote); font-weight: 600; letter-spacing: var(--small-track); }
.course-today-mistakes .btn { min-width: 96px; min-height: 44px; }
.mistakes-offline { margin: 0; display: grid; gap: var(--space-1); padding: var(--space-3) var(--space-4); border-radius: var(--radius-group); corner-shape: var(--corner); background: var(--fill); }
.mistakes-portion .mistakes-offline { padding: var(--space-3) var(--space-3); border-radius: var(--radius-action); corner-shape: var(--corner); }
.mistakes-offline span:first-child { font-weight: 600; }
.mistakes-offline span:last-child { color: var(--muted); font-size: var(--text-subhead); }
.mistakes-done-today { margin: 0; display: flex; align-items: center; gap: var(--space-2); color: var(--know); font-size: var(--text-subhead); font-weight: 600; }
.mistakes-done-today svg { flex: none; width: 16px; height: 16px; }
.mistakes-note { margin: 0; color: var(--muted); font-size: var(--text-subhead); }

/* ---------- Toast with "Скасувати" (ui/toast.js) ---------- */
.toast-region {
  position: fixed; z-index: 26; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
  width: min(480px, calc(100% - 32px)); display: grid; gap: var(--space-2); pointer-events: none;
}
.toast-region:empty { display: none; }
body:has(#offline-bar:not([hidden])) .toast-region { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 60px); }
.toast {
  display: flex; align-items: center; gap: var(--space-3); min-height: 52px; padding: var(--space-1) var(--space-2) var(--space-1) var(--space-4);
  border-radius: var(--radius-group); corner-shape: var(--corner); background: var(--fg); color: var(--bg); box-shadow: var(--shadow);
  font-size: var(--text-subhead); pointer-events: auto; animation: toast-in 0.3s var(--ease-out);
}
.toast-text { flex: 1; min-width: 0; }
.toast-action {
  flex: none; min-height: 44px; padding: 0 var(--space-3); border-radius: var(--radius-action); corner-shape: var(--corner);
  color: var(--toast-action); font-weight: 600; font-size: var(--text-subhead);
}
.toast-action:focus-visible { outline: 2px solid var(--toast-action); outline-offset: -2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) {
  .toast { animation: toast-fade 0.2s linear !important; }
  @keyframes toast-fade { from { opacity: 0; } }
}

/* ---------- Skeleton of a first load (ui/skeleton.js, decision 0108) ---------- */
/* The real components in place, their text and marks turned into grey blocks. */
.skeleton { display: contents; }
.skeleton > * { pointer-events: none; animation: skeleton-pulse 1.2s ease-in-out infinite alternate; }
.skeleton :is(h1, h2, h3, p, b, small, .t1, .t2, .today-action, .tab-label), .skeleton :is(a, span, button):not(:has(*)) {
  color: transparent; background: var(--skeleton); border-radius: var(--radius-segment-item); corner-shape: var(--corner);
  width: fit-content; text-shadow: none;
}
.skeleton .row-text > * { width: fit-content; }
.skeleton :is(svg, .chev) { color: var(--skeleton); }
.skeleton .today-action > span { background: none; }
.skeleton .ring :is(.val, text) { stroke: transparent; fill: transparent; }
.skeleton .bar > * { background: transparent; }
.skeleton .subject-tabs a[aria-current] { background: var(--skeleton); }
@keyframes skeleton-pulse { to { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .skeleton > * { animation: none; } }


/* ---------- Report a mistake (ui/report.js, app/report.js; decision 0114) ---------- */
/* One small round button everywhere. In the corner it is quiet but always there: above the
   tab bar, the offline notice and toasts. A session shows it in its top bar instead: the
   bottom corner there holds the answer buttons. */
.report-fab {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer;
  transition: bottom 0.3s var(--ease-out), opacity 0.2s;
}
.report-fab svg { width: 22px; height: 22px; }
.report-fab:hover { color: var(--accent); }
.report-fab:active { opacity: var(--press-dim); transition-duration: var(--press-in); }
.report-fab:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.report-corner {
  position: fixed; z-index: 24;
  right: max(var(--space-4), env(safe-area-inset-right, 0px));
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--space-3));
  background: var(--blur-bg); box-shadow: var(--shadow);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
body:has(.shell.bare) .report-corner, body:has(.report-sheet[open]) .report-corner { display: none; }
body:has(#offline-bar:not([hidden])) .report-corner { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 64px); }
body:has(.toast-region:not(:empty)) .report-corner { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 76px); }
/* Room under the last button of a screen, so the round button never sits on it for good. */
body:has(.report-corner) .shell:not(.bare) .main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 72px); }
@media (min-width: 900px) {
  .report-corner, body:has(#offline-bar:not([hidden])) .report-corner, body:has(.toast-region:not(:empty)) .report-corner {
    bottom: max(var(--space-6), env(safe-area-inset-bottom, 0px)); right: max(var(--space-6), env(safe-area-inset-right, 0px));
  }
  body:has(.report-corner) .shell:not(.bare) .main { padding-bottom: calc(2 * var(--space-12) + var(--space-2)); }
}
.sess-top { grid-template-columns: 44px minmax(0, 1fr) auto 44px 44px; }
.sess-top .report-fab { grid-area: 1 / 5; }

/* The form: a sheet from the bottom on a phone, a dialog in the middle on a computer. */
.report-sheet {
  width: min(100%, 30rem); max-width: 100%; max-height: min(92dvh, 44rem); padding: 0; margin: auto auto 0; color: var(--fg);
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius-card) var(--radius-card) 0 0; corner-shape: var(--corner);
  animation: report-up 0.32s var(--ease-out);
}
.report-sheet::backdrop { background: color-mix(in srgb, var(--fg) 30%, transparent); }
.report-form, .report-done {
  display: grid; gap: var(--space-4);
  padding: var(--space-6) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
}
.report-sheet h2 { margin: 0; font-size: var(--text-title3); font-weight: 600; }
.report-sheet h2:focus { outline: none; }
.report-about, .report-note, .report-done p { margin: 0; color: var(--muted); font-size: var(--text-subhead); }
.report-note { font-size: var(--text-footnote); }
.report-about { margin-top: calc(-1 * var(--space-3)); }
.report-reasons { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin: 0; padding: 0; border: 0; }
.report-reasons legend { padding: 0 0 var(--space-2) var(--space-1); font-size: var(--text-footnote); color: var(--muted); }
.report-reason {
  display: flex; align-items: center; min-height: 48px; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius-group); corner-shape: var(--corner);
  font-size: var(--text-subhead); line-height: 1.25; cursor: pointer;
}
.report-reason input { position: absolute; opacity: 0; pointer-events: none; }
.report-reason:has(:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.report-reason:has(:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.report-sheet .field textarea { min-height: 96px; }
.report-error { margin: 0; color: var(--again); font-size: var(--text-footnote); }
.report-error:empty { display: none; }
.report-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
@keyframes report-up { from { transform: translateY(100%); } }
@media (min-width: 600px) {
  .report-sheet { margin: auto; border-bottom: 1px solid var(--line); border-radius: var(--radius-card); corner-shape: var(--corner); animation-name: vt-fade-in; }
  .report-form, .report-done { padding: var(--space-6); }
}
