/* Parts every notebook has: the study buttons on narrow screens, the list of mistakes, the free preview line and the practice box */

/* tablets and wide phones: the study buttons take the whole line, the level dropdown sits under them; the practise
   buttons (the same size in every notebook on a wide screen, css/<code>/style.css) fill the line too */
@media (max-width: 1100px) {
  .subj {
    flex-basis: 100%;
    max-width: none;
  }
  .tabs {
    --bw: 1fr;
  }
}
/* practise buttons whose labels would get too small in one row (large text): two rows (js/shared/drill-fit.js) */
.tabs.two {
  grid-template-columns: repeat(var(--half, 3), minmax(0, 1fr));
}
/* computers: the study buttons and the practise buttons always keep one width, the width of the card beside the side
   column (the study set and progress), every practise button the same width, so nothing moves when a tab with a card
   of the whole width (charts, word lists) opens. The Level menu sits over the side column. Up to 1100px the card always
   takes the whole width (css/<code>/style.css), and so do they. */
@media (min-width: 1101px) {
  :is(.subj, .tabs) {
    max-width: calc(100% - 18.5rem - 28px);
  }
  .tabs {
    --bw: 1fr;
  }
  /* just over 1100px six or seven practise buttons share a narrow row: their labels shrink a little to fit */
  .tabs button {
    font-size: min(0.98rem, 1.34vw);
  }
}
/* the Study label lines up with the study buttons, never with the middle of the buttons and the Level row together
   (the Level row wraps under them below 1200px, on an iPad held sideways too) */
@media (min-width: 601px) {
  #subjLab {
    align-self: start;
    display: flex;
    align-items: center;
    min-height: 46px;
  }
}

.mx {
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  padding: 6px 12px;
  margin: 0;
}
.mx + .mx {
  margin-top: -6px;
}
.mx p {
  margin: 0;
}
/* a mistake line: the mark, the sentence and its meaning side by side on one text line, with or without furigana
   (the reading hangs under the sentence); a long meaning wraps inside its own column on the right */
.mx-w,
.mx-r {
  display: grid;
  grid-template-columns: auto minmax(0, max-content) minmax(7em, 1fr);
  column-gap: 10px;
  align-items: baseline;
  padding: 6px 0;
}
.mx-r {
  border-top: 1px dashed var(--rule);
}
.mx-w > b {
  color: var(--bad);
  font-weight: 700;
}
.mx-r > b {
  color: var(--ok);
  font-weight: 700;
}
.mx-y {
  border-top: 1px solid var(--rule);
  margin-top: 2px !important;
  padding: 7px 0 5px;
  color: var(--ink-2);
  font-size: 0.93em;
}
.mx-y > b {
  color: var(--ink);
}

.fpv {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 10px 0 2px;
  padding: 9px 12px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: var(--surface);
  font: 500 0.9rem/1.4 var(--f-body);
  color: var(--ink-2);
}
.fpv span {
  flex: 1 1 16rem;
}
.fpv b {
  color: var(--ink);
}
.fpv .btn {
  padding: 5px 12px;
  font-size: 0.85rem;
}

/* extra practice under each grammar lesson */
.pq {
  margin: 18px 0 6px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
  padding: 18px 18px 16px;
  color: var(--ink);
}
.pq h4 {
  margin: 0 0 4px;
  font: 700 1.08rem/1.25 var(--f-display, inherit);
  display: flex;
  align-items: center;
  gap: 8px;
}
.pq h4 .ico {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--accent);
}
.pq .pq-sub {
  margin: 0 0 12px;
  color: var(--ink-2);
  font-size: 0.92rem;
  line-height: 1.45;
}
.pq .pq-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.pq .pq-btn {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  font: 600 0.95rem/1 var(--f-body, inherit);
  cursor: pointer;
}
.pq .pq-btn.pri {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent, #fff);
}
.pq .pq-btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.pq .pq-btn:focus-visible,
.pq .pq-opt:focus-visible,
.pq .pq-tok:focus-visible,
.pq textarea:focus-visible,
.pq input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pq .pq-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font: 600 0.78rem/1 var(--f-body, inherit);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.pq .pq-bar {
  height: 4px;
  border-radius: 4px;
  background: var(--rule);
  overflow: hidden;
  margin-bottom: 14px;
}
.pq .pq-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s;
}
.pq .pq-p {
  margin: 0 0 10px;
  font-weight: 600;
  line-height: 1.4;
}
.pq .pq-t {
  font-size: 1.35rem;
  line-height: 1.5;
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}
.pq [lang="ja"] {
  font-family: var(--f-kana, inherit);
}
.pq [lang="zh-Hans"] {
  font-family: var(--f-han, inherit);
}
.pq [lang="ko"] {
  font-family: var(--f-kana, inherit);
}
.pq .pq-src {
  font-size: 1.1rem;
  line-height: 1.45;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--paper);
  border-radius: 0 8px 8px 0;
}
.pq .pq-opts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
@media (max-width: 520px) {
  .pq .pq-opts {
    grid-template-columns: 1fr;
  }
}
.pq .pq-opt {
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: 500 1.05rem/1.35 var(--f-body, inherit);
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.pq .pq-opt:hover:not(:disabled) {
  border-color: var(--accent);
}
.pq .pq-opt.right {
  border-color: var(--ok);
  background: var(--ok-bg, transparent);
  color: var(--ok);
}
.pq .pq-opt.wrong {
  border-color: var(--bad);
  background: var(--bad-bg, transparent);
  color: var(--bad);
}
.pq .pq-opt:disabled {
  cursor: default;
}
/* after the answer, a tap on the greyed-out box, choices or words falls through to the practice box: it goes to the next question */
.pq :is(button, input, textarea):disabled {
  pointer-events: none;
}
.pq input.pq-in,
.pq textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.15rem/1.45 var(--f-body, inherit);
  margin-bottom: 10px;
  resize: vertical;
}
.pq textarea {
  min-height: 84px;
}
.pq .pq-line {
  min-height: 52px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1.5px dashed var(--rule);
  border-radius: 10px;
  margin-bottom: 10px;
  align-items: center;
}
.pq .pq-toks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.pq .pq-tok {
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
}
.pq .pq-tok.used {
  visibility: hidden;
}
.pq .pq-fb {
  margin: 4px 0 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
  display: grid;
  gap: 8px;
  line-height: 1.45;
}
.pq .pq-fb.ok {
  border-color: var(--ok);
}
.pq .pq-fb.mid {
  border-color: #c98a12;
}
.pq .pq-fb.no {
  border-color: var(--bad);
}
.pq .pq-v {
  font-weight: 700;
}
.pq .pq-fb.ok .pq-v {
  color: var(--ok);
}
.pq .pq-fb.mid .pq-v {
  color: #b07400;
}
.pq .pq-fb.no .pq-v {
  color: var(--bad);
}
.pq .pq-s {
  font-size: 1.2rem;
  overflow-wrap: anywhere;
}
.pq .pq-r {
  color: var(--ink-2);
  font-size: 0.92rem;
}
.pq .pq-m {
  font-size: 0.95rem;
}
.pq .pq-k {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 700;
}
.pq .pq-err {
  color: var(--bad);
  font-size: 0.92rem;
  margin: 0 0 10px;
}
.pq .pq-ok {
  color: var(--ok);
  font-size: 0.92rem;
  margin: 0 0 10px;
}
.pq .pq-tr {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pq .pq-hc {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink);
}
.pq .pq-hc.none {
  color: var(--ink-2);
}
.pq .pq-hint {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, #e2b33c 16%, transparent);
  border: 1px solid color-mix(in srgb, #e2b33c 45%, transparent);
  line-height: 1.45;
}
.pq .pq-hint b {
  display: block;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.pq .pq-out {
  margin: 0 0 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px dashed var(--rule);
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
}
.pq .pq-out small {
  color: var(--ink-2);
}
.pq .pq-r2k {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: -4px 0 12px;
  color: var(--ink-2);
  font-size: 0.84rem;
  line-height: 1.35;
  cursor: pointer;
}
.pq .pq-r2k input {
  margin-top: 2px;
}
.pq .pq-meta {
  color: var(--ink-2);
  font-size: 0.82rem;
  margin: 10px 0 0;
}
.pq .pq-link {
  border: 0;
  background: none;
  padding: 6px 0;
  color: var(--ink-2);
  font: 500 0.82rem var(--f-body, inherit);
  text-decoration: underline;
  cursor: pointer;
}
.pq .pq-score {
  font: 700 2rem/1 var(--f-display, inherit);
  margin: 4px 0 6px;
}
.pq .pq-wait {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
  padding: 8px 0;
}
.pq .pq-wait i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--rule);
  border-top-color: var(--accent);
  animation: pqspin 0.8s linear infinite;
}
@keyframes pqspin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .pq .pq-wait i {
    animation: none;
  }
}

/* in the lessons, a word or sentence carries its reading (rōmaji, pinyin or romanization) small under it, not beside
   it; in a table, the example's meaning goes on its own line under it */
.lesson p .jw,
.lesson td .jw,
.lesson .exr .jw {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  vertical-align: top;
  line-height: 1.35;
  margin: 1px 0;
}
/* in running text and in a table cell, the word sits on the same line as the words and commas around it, with or
   without furigana; its reading hangs below */
.lesson p .jw,
.lesson td .jw,
.lesson .exr .jw {
  vertical-align: baseline;
}
/* its rōmaji is centred under it, in the narrower text face, so a reading seldom needs more room than the word and the
   sentence keeps its normal spacing (the pattern box and mistake cards keep theirs: there the word stands alone) */
.lesson p .jw:not(:is(.pat, .mx) .jw) {
  align-items: center;
}
.lesson p .jw:not(:is(.pat, .mx) .jw) > .rm-s {
  font-family: var(--f-body, inherit);
  font-size: 0.72em;
  white-space: nowrap;
}
/* Japanese rōmaji may reach a little past its word; Korean words sit closer together, so theirs stays within */
.lesson p .jw:has(> [lang="ja"]):not(:is(.pat, .mx) .jw) > .rm-s {
  margin-inline: -0.5em;
}
/* Chinese carries its pinyin above (ruby), so a word sits on the line like the text around it */
.lesson p .jw:has(> .zrl) {
  display: inline;
  vertical-align: baseline;
  margin: 0;
}
/* in a table cell the word keeps room above it for its pinyin, so the cell centres the pinyin and hanzi together; the
   hanzi sit on the same line as the English beside them */
.lesson td .jw:has(> .zrl),
.lesson .exr .jw:has(> .zrl) {
  display: inline-block;
  vertical-align: baseline;
  padding-top: 0.6em;
  margin: 0;
}
.lesson p .jw > .rm-s,
.lesson td .jw > .rm-s,
.lesson .exr .jw > .rm-s {
  font-size: 0.8em;
  color: var(--ink-2);
}
.gt .gm {
  display: block;
  margin-top: 4px;
}
/* on a mistake card, the meaning sits to the right of the sentence, on its line; on the next line only when there is
   no room */
.mx-w > span,
.mx-r > span {
  display: contents;
}
.mx .gm {
  color: var(--ink-2);
}

/* a lesson's patterns: a title, then one pattern per line with its example under it, a thin line between them */
.pat .pat-h {
  display: block;
  margin-bottom: 6px;
  font: 600 0.72rem/1.2 var(--f-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.pat .pat-i {
  display: block;
}
.pat .pat-i + .pat-i {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}
.pat .pat-x {
  display: block;
  margin-top: 6px;
  font-weight: 400;
  font-size: 0.92rem;
}
.pat .pat-x [lang] {
  color: inherit;
  font-size: 1.05em;
}
.pat .pat-x .gm {
  display: block;
  margin-top: 2px;
  color: var(--ink-2);
}

/* rōmaji (Japanese) and romanization (Korean), from Profile → Learning: by level, they show only in beginner
   content (data-rl="b": N5, TOPIK I); "on" always; "off" never. The kana chart and practice answers are not marked */
html:not([data-roma="on"]) [data-rl="a"] .rm-m,
html[data-roma="off"] [data-rl] .rm-m,
html:not([data-roma="on"]) [data-rl="a"] .rm-line,
html[data-roma="off"] [data-rl] .rm-line {
  display: none !important;
}

/* Chinese: the pinyin over the example takes room above it, so it gets more space from the pattern */
.pat .pat-x:has(.zrl) {
  margin-top: 14px;
}
.pat .pat-x:has(.zrl) .gm {
  margin-top: 0;
}

/* the fonts keep different room above and below their letters: each script's mistake lines are nudged so the
   sentence and its reading sit with the same space above and below in every notebook */
.mx-w:has([lang="ja"]),
.mx-r:has([lang="ja"]),
.mx-w:has(.zrl),
.mx-r:has(.zrl) {
  padding: 8px 0 4px;
}
.mx-w:has([lang="ko"]),
.mx-r:has([lang="ko"]) {
  padding: 4px 0 8px;
}

/* examples in rows under the sentence that explains them ("- example | meaning" in the lesson files): the word with its
   reading on the left, its meaning beside it; on a very narrow phone the meaning goes under the word */
.exr {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(8em, 1fr);
  column-gap: 20px;
  margin: -4px 0 16px;
  padding-left: 14px;
  border-left: 3px solid var(--rule);
}
.exr-r {
  display: contents;
}
.exr-j,
.exr-m {
  padding: 7px 0;
  border-top: 1px dashed var(--rule);
  align-self: stretch;
  display: flex;
  align-items: center;
}
.exr-r:first-child > span {
  border-top: 0;
}
.exr-j {
  flex-wrap: wrap;
  align-items: baseline;
  align-content: center;
  gap: 4px 2px;
}
.exr-m {
  color: var(--ink-2);
}
@media (max-width: 520px) {
  .exr {
    grid-template-columns: minmax(0, max-content) minmax(6em, 1fr);
    column-gap: 14px;
  }
}
/* examples too long to share the line with their meaning (js/shared/lesson-fit.js), and every block on a very narrow
   phone: the meaning goes under its example */
.exr.exr-stack {
  grid-template-columns: minmax(0, 1fr);
}
.exr.exr-stack .exr-m {
  border-top: 0;
  padding-top: 0;
}
@media (max-width: 340px) {
  .exr {
    grid-template-columns: minmax(0, 1fr);
  }
  .exr-m {
    border-top: 0;
    padding-top: 0;
  }
}
/* a word's furigana sits over the word as one piece; the kanji are not pulled apart to fit a longer reading */
.lesson ruby {
  ruby-align: center;
}

/* the Build tab: the sentence being put together (tray), the words left to use (bank), and a word (tile) */
.tray {
  width: 100%;
  min-height: 4.6rem;
  border: 1.5px dashed var(--grid);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
  justify-content: center;
}
.bank {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  width: 100%;
  min-height: 3.4rem;
}
.tile {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  padding: 5px 10px 4px;
  display: grid;
  justify-items: center;
  gap: 0;
  min-width: 2.6rem;
}
.tile:hover {
  border-color: var(--accent);
}
.tile [lang="ja"],
.tile [lang="ko"] {
  font-size: 1.3rem;
  line-height: 1.9;
}
.tile [lang="ko"] {
  line-height: 1.4;
}
.tile small {
  font-size: 0.74rem;
  line-height: 1.1;
  color: var(--ink-2);
}

/* ---------- the Level picker: a row of its own, labelled like Study and Practise ----------
   A wide screen keeps it beside the Study buttons. Narrower, it is its own row: on a tablet its label sits in the
   label column and the picker lines up with the buttons; on a phone the label is above and the picker is as wide
   as the rows. */
.navmain .lvl-t {
  font: 600 0.72rem/1 var(--f-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
@media (min-width: 601px) and (max-width: 1199px) {
  .navmain .lvl {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    gap: 12px;
    margin-left: calc(-4.4rem - 12px);
  }
  .navmain .lvl-t {
    flex: 0 0 4.4rem;
  }
}
@media (max-width: 600px) {
  .navmain .lvl {
    flex: 1 1 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    margin-top: 6px;
  }
  .navmain .lvl-ticks,
  .navmain .lvd,
  .navmain .lvd-b {
    width: 100%;
  }
  .navmain .lvd-b small {
    margin-left: auto;
  }
}

/* ---------- Look-alikes: pairs that look alike, side by side (Grammar → Look-alikes) ---------- */
.al-list {
  display: grid;
  gap: 8px;
}
/* a pair's row has no lesson number: the pair takes the room, a lock (if any) on the right */
.lrow.al-row {
  grid-template-columns: minmax(0, 1fr) auto;
}
.al-row b {
  font-size: 1.12rem;
}
.al-row b .vs,
.al-title .vs {
  margin: 0 0.45em;
  font: 600 0.62em/1 var(--f-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  vertical-align: middle;
}
.al-filt {
  margin: 2px 0;
}
.al-title {
  margin-bottom: 2px;
}
.al-sub {
  margin: 0 0 4px;
  color: var(--ink-2);
}
.al-test {
  margin: 10px 0 4px;
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.al-test > b {
  display: block;
  margin-bottom: 6px;
  font: 600 0.72rem/1 var(--f-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.al-test p {
  margin: 0;
}
.al-sides {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 14px;
  margin: 14px 0 6px;
}
.al-side {
  min-width: 0;
  padding: 14px 16px 6px;
  border: 1px solid var(--rule);
  border-radius: 14px;
}
.al-side h4 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
  font-size: 1.3rem;
}
.al-lv {
  padding: 2px 7px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font: 600 0.66rem/1.3 var(--f-body);
  letter-spacing: 0.06em;
  color: var(--ink-2);
}
.al-mean {
  color: var(--ink-2);
}
.al-try {
  margin: 10px 0;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  text-align: center;
}
.al-q {
  margin: 4px 0;
  font-size: 1.15rem;
}
.al-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.al-link {
  margin-top: 18px;
}
/* the lesson title holds words in their own spans: as flex items they stood in columns, so the text flows instead */
.al-link .btn {
  display: inline-block;
  max-width: 100%;
  text-align: left;
  line-height: 1.5;
}

/* ---------- swiping to the next or previous item (js/shared/swipe.js) ----------
   a copy of the ‹ or › button that follows the finger in from the side, and the new page sliding in from that side */
/* on the card a finger scrolls the page up and down only; a sideways swipe is left to swipe.js, so the page does
   not dip with the finger during it. Tables and button rows that scroll sideways are boxes of their own and keep
   their sideways scrolling. */
#sheet {
  touch-action: pan-y pinch-zoom;
}
/* pinch-zoomed in: a finger moves the zoomed view any way, and swiping does not step (js/shared/swipe.js) */
html.pinched #sheet,
html.pinched .zoom .zcard {
  touch-action: auto;
}
/* the next card slides in from the right; for that moment it reached past the edge of the page, the page grew wider
   and a phone shifted the whole view, so the page dipped on every "next" (never on "back", which comes from the
   left). What slides past the edge is cut off instead. clip, unlike hidden, does not stop the side column sticking. */
.layout {
  overflow-x: clip;
}
.sw-hint {
  position: fixed;
  top: 50%;
  z-index: 40;
  height: 46px;
  margin-top: -23px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 0.35em;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.18);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.12s,
    background 0.12s,
    color 0.12s;
}
.sw-hint[data-side="next"] {
  right: 10px;
}
.sw-hint[data-side="prev"] {
  left: 10px;
}
.sw-hint.go {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
#sheet.sw-next {
  animation: sw-next 0.24s ease-out;
}
#sheet.sw-prev {
  animation: sw-prev 0.24s ease-out;
}
@keyframes sw-next {
  from {
    opacity: 0;
    transform: translateX(36px);
  }
}
@keyframes sw-prev {
  from {
    opacity: 0;
    transform: translateX(-36px);
  }
}
@media (prefers-reduced-motion: reduce) {
  #sheet.sw-next,
  #sheet.sw-prev {
    animation: none;
  }
}

/* ---------- the top row of an opened kanji, character, word, radical or lesson ----------
   on a wide screen, previous and next sit on either side of the counter in the middle of the row, where the eye
   already is; on a phone they keep their own line under it */
@media (min-width: 760px) {
  .kd-nav {
    display: grid;
    grid-template-columns: minmax(max-content, 1fr) auto minmax(0, auto) auto 1fr;
  }
  .kd-nav > * {
    grid-row: 1;
  }
  .kd-nav > .btn {
    grid-column: 1;
    justify-self: start;
  }
  .kd-nav > .meta {
    grid-column: 3;
    text-align: center;
  }
  .kd-nav > .acts {
    display: contents;
  }
  .kd-nav [data-go] {
    grid-row: 1;
  }
  .kd-nav [data-go="prev"] {
    grid-column: 2;
  }
  .kd-nav [data-go="next"] {
    grid-column: 4;
  }
}

/* on a phone, swiping moves to the next or previous item (js/shared/swipe.js): the ‹ and › buttons are hidden but
   stay for screen readers, and a short tip under the row says how to move on until the first swipe */
.sw-tip {
  display: none;
}
@media (max-width: 759px) and (pointer: coarse) {
  .kd-nav > .acts {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .sw-tip {
    display: block;
    margin: -4px 0 0;
  }
}

/* a radical's kanji or characters, level by level */
.lvh {
  margin: 14px 0 6px;
  font: 700 0.92rem/1.2 var(--f-display);
  color: var(--ink);
}
.lvh:first-of-type {
  margin-top: 0;
}
.lvh small {
  font: 400 0.85rem/1.2 var(--f-body);
  color: var(--ink-2);
}

/* a button sinks a little while the finger or mouse is on it and comes back when let go (.pressing is set by
   js/shared/press.js, so a quick tap on a phone shows it too); the tiles, flash cards and
   arrows that already have their own press keep it. Weak selectors (:where), so a button's own transition wins.
   Off for people who ask their device for less motion. */
@media (prefers-reduced-motion: no-preference) {
  :where(button, a.btn, [role="button"]):where(:not(.wt, .kt, .rt, .pc, .gl, .fcard, .znav)) {
    transition-property: scale, background-color, border-color, color, box-shadow;
    transition-duration: 0.12s;
  }
  :where(button:not(:disabled), a.btn, [role="button"]):where(:not(.wt, .kt, .rt, .pc, .gl, .fcard, .znav)):active,
  :where(button, a.btn, [role="button"]):where(:not(.wt, .kt, .rt, .pc, .gl, .fcard, .znav)).pressing {
    scale: 0.96;
    transition-duration: 0.05s;
  }
}

/* Quiz and Type keep one size from question to question: the Next and Open buttons have their room before they
   show, and options, the word asked and the answer line stay on one line (js/shared/drill-fit.js makes a long
   one smaller; .fit-wrap lets a long grammar explanation wrap) */
.drill > .acts {
  min-height: 43px;
}
.drill .opt.txt,
.drill .kword,
.drill .tp-prompt .meta,
.drill .tp-prompt .mean,
.drill .fb {
  white-space: nowrap;
}
.drill .fb {
  overflow: hidden;
}
.drill .opt.txt.fit-wrap,
.drill .kword.fit-wrap,
.drill .fb.fit-wrap,
.drill .fit-wrap {
  white-space: normal;
}
/* the rank note has its own line under the answer, and the answer box has room for it from the start; the timer
   bar under the buttons takes no room of its own */
.drill .fb {
  min-height: 4.25rem;
}
.drill .fb small {
  white-space: nowrap;
}
.drill {
  position: relative;
}
.drill > .pacebar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -12px;
  margin: 0 auto;
}
/* a grammar gap question explains its answer in a sentence: its answer box has room for two lines from the start */
.drill:has(.pq) .fb {
  min-height: 3.75rem;
}
.drill .fb.fit-wrap {
  line-height: 1.3;
}
/* when the practice box is held taller than what it shows (js/shared/drill-fit.js), the room goes to the bottom:
   the title and the question stay where they are */
#sheet {
  align-content: start;
}
/* the part of a quiz above the answer options (js/shared/drill-fit.js) and the prompt of a Type tab: as tall as a
   question line plus the kanji square, so every question type has the same box; a shorter prompt sits centred */
.drill > .qtop,
.drill > .tp-prompt {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-content: center;
  gap: 18px;
  width: 100%;
  min-height: calc(1.6rem + 18px + 14.5rem);
}
/* kanji, hanzi and letter pages: the buttons stand clear of the writing square */
div.kd-fig {
  row-gap: 16px;
}
div.kd-fig > .sq + .acts {
  margin-top: 4px;
}
/* a question type without the square uses the room for what it asks: a bigger word, a bigger meaning */
.drill > .qtop:not(:has(.sq)) .kword {
  font-size: clamp(3rem, 15vw, 5rem);
}
.drill > .qtop:not(:has(.sq)) .meta {
  font-size: 1.1rem;
}
.drill > .qtop:not(:has(.sq, .kword)) .ask {
  font-size: clamp(1.35rem, 5vw, 1.9rem);
  line-height: 1.4;
  text-wrap: balance;
}
/* gap questions: the sentence gets the width of the box and, on a wider screen, stays on one line (made smaller
   to fit by js/shared/drill-fit.js, and only a very long one wraps); on a phone it wraps as before. The answer
   options keep their usual width */
.drill:has(> .ex) {
  max-width: 46rem;
}
.drill:has(> .ex) > .opts,
.drill:has(> .ex) > .full:not(.ex),
.drill:has(> .ex) > .acts {
  max-width: 27rem;
}
@media (min-width: 700px) {
  .drill > .ex .ex-j {
    white-space: nowrap;
  }
}
.drill > .ex .ex-j.fit-wrap {
  white-space: normal;
}
/* the sentence box is as wide as its sentence, never narrower than the answer options, and the sentence, its
   translation and the colour key sit centred in it */
.drill > .ex {
  grid-template-columns: minmax(0, 1fr);
  justify-self: center;
  width: fit-content;
  min-width: min(100%, 27rem);
  max-width: 100%;
  padding: 12px 24px;
  text-align: center;
}
.drill > .ex .rlegend {
  justify-content: center;
}
