/* ==========================================================================
   InterExe — HSK pages (levels, pinyin ↔ hanzi practice, writing, word list).
   SAT Practice's tokens and components from theme.css; hk- class names only.
   ========================================================================== */

/* Level page: the mode cards. Six of them, so 3 + 3 on a wide screen (a 4-column grid left
   two orphans on the second row), 2 × 3 on a tablet or small laptop, one column on a phone. */
.hk-modes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .hk-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .hk-modes { grid-template-columns: minmax(0, 1fr); } }

/* Textbook lesson picker (level page): All · 1 … 15, any number of lessons
   on at once. A pressed lesson is filled in the brand colour, the same signal a lit filter
   gives in the deck strip. */
.hk-lessons { margin: 0 0 22px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.hk-lessons-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 12px; }
.hk-lessons-lab { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.hk-lessons-src { font-size: .82rem; color: var(--muted); }
.hk-lchips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.hk-lchip { min-width: 38px; height: 38px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: 10px; background: var(--surface); color: var(--ink-2);
  font: 600 .9rem var(--font-ui); font-variant-numeric: tabular-nums; cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.hk-lchip:hover { border-color: var(--brand-400); color: var(--ink); }
.hk-lchip[aria-pressed="true"] { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.hk-lsum { margin-left: auto; font-size: .82rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
@media (max-width: 560px) {
  .hk-lessons { padding: 14px; }
  .hk-lchip { min-width: 40px; height: 40px; }
  .hk-lsum { margin-left: 0; width: 100%; }
}
/* Touch screens: 44px targets with 8px between them (phones and tablets alike). */
@media (pointer: coarse) {
  .hk-lchips { gap: 8px; }
  .hk-lchip { min-width: 44px; height: 44px; }
}

/* Listen & choose pinyin: a big play button, four pinyin choices (Inter — the display serif
   breaks tone marks), then the result. The card never flips. */
.hk-dface { gap: 12px; justify-content: center; }
.hk-dplayrow { display: flex; align-items: center; gap: 10px; }
.hk-dplay { display: inline-grid; place-items: center; width: 76px; height: 76px; padding: 0; border: 0; border-radius: 50%;
  background: var(--brand-600); color: #fff; cursor: pointer; box-shadow: var(--shadow-md); transition: transform var(--t-fast), background var(--t-fast); }
.hk-dplay:hover { background: var(--brand-700); }
.hk-dplay:active { transform: scale(.96); }
.hk-dplay svg { width: 32px; height: 32px; }
.hk-dnovoice { max-width: 46ch; margin: 0; padding: 12px 14px; border-radius: var(--r); background: var(--warn-bg); color: var(--ink-2); font-size: .9rem; line-height: 1.5; }
.hk-dlab { margin-top: 6px; font-size: .82rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.hk-dopts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: min(460px, 100%); }
.hk-dopt { position: relative; display: grid; place-items: center; min-height: 60px; padding: 8px 30px; border: 1.5px solid var(--border-2); border-radius: 12px;
  background: var(--surface); color: var(--ink); cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast); }
.hk-dopt-p { font: 600 1.4rem var(--font-ui); letter-spacing: .01em; overflow-wrap: anywhere; }
.hk-dkey { position: absolute; top: 6px; left: 8px; font: 600 .7rem var(--font-ui); color: var(--muted); }
.hk-dopt:not(:disabled):hover { border-color: var(--brand-400); background: color-mix(in srgb, var(--brand-600) 6%, var(--surface)); }
.hk-dopt:not(:disabled):active { transform: scale(.98); }
.hk-dopt:disabled { cursor: default; opacity: .55; }
.hk-dopt.is-right { opacity: 1; border-color: var(--ok); background: var(--ok-bg); }
.hk-dopt.is-wrong { opacity: 1; border-color: var(--bad); background: var(--bad-bg); }
.hk-dopt.is-right .hk-dopt-p { color: var(--ok); }
.hk-dopt.is-wrong .hk-dopt-p { color: var(--bad); }
.hk-dcheck { min-width: 170px; justify-content: center; }
.hk-dresult { width: min(440px, 100%); padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hk-dresult[hidden] { display: none; }
.hk-dverdict { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .9rem; }
.hk-dverdict svg { width: 16px; height: 16px; }
.hk-dresult.is-ok .hk-dverdict { color: var(--ok); }
.hk-dresult.is-tones .hk-dverdict { color: var(--warn); }
.hk-dresult.is-no .hk-dverdict { color: var(--bad); }
.hk-dword { display: flex; align-items: center; gap: 10px; }
.hk-dword-h { font: 500 1.6rem var(--font-zh); color: var(--ink); }
.hk-dword-p { font: 600 1.25rem var(--font-ui); color: var(--brand-600); }
.hk-dword-e { margin: 0; color: var(--muted); }
.hk-dcheck[hidden] { display: none; }
@media (max-width: 560px) { .hk-dopts { gap: 8px; } .hk-dopt { min-height: 56px; padding-inline: 22px; } .hk-dopt-p { font-size: 1.2rem; } .hk-dplay { width: 64px; height: 64px; } }
@media (pointer: coarse) { .hk-dkey { display: none; } }

/* Shared page shell (loading state, word list). */
.hk-wrap { max-width: none; }
.hk-word-e { margin: 0; color: var(--muted); }
.hk-say { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.hk-say:hover { color: var(--brand-600); border-color: var(--brand-300); }
.hk-say svg { width: 17px; height: 17px; }
.hk-say[hidden] { display: none; }
.hk-cardprog { margin-top: auto; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--muted-2); }

/* ======================================================================
   HANZI ↔ PINYIN FLASHCARDS — SAT Practice's vocabulary flashcard, copied VERBATIM from its
   styles.css (VOCABULARY FLASHCARD section) so the two sites look and behave the same.
   Keep in step with SAT Practice rather than editing here; HSK-only additions follow it.
   ====================================================================== */
.flash { perspective: 1600px; max-width: none; margin: 0 auto; }
.flash-inner { position: relative; width: 100%; min-height: 400px; transform-style: preserve-3d; transition: transform .6s var(--ease-spring); cursor: pointer; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 32px; border-radius: var(--r-xl); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-md); }
.flash-back { transform: rotateY(180deg); background: var(--brand-50); }
[data-theme="dark"] .flash-back { background: var(--paper); }
.flash-word { font-family: var(--font-display); font-size: 3rem; font-weight: 500; color: var(--ink); }
.flash-hint { font-size: .84rem; color: var(--faint); margin-top: 22px; }
.flash-tall .flash-inner { min-height: 620px; }
/* Position in the run ("12 / 1,448" + a thin bar) across the top of the card. On .flash,
   outside the rotating .flash-inner, so it stays put while the card turns; the faces
   start below it. pointer-events:none so a tap on the line still flips the card. */
.flash { position: relative; }
.flash-pos { position: absolute; top: 14px; left: 22px; right: 22px; z-index: 2; pointer-events: none;
  display: flex; align-items: center; gap: 10px; }
.flash-pos .bar { flex: 1; height: 4px; }
.flash-pos .bar > span { background: var(--lc, var(--brand-600)); }
.flash-pos-n { font-size: .74rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.flash:has(.flash-pos) .flash-face { padding-top: 44px; }
/* Part of speech + IPA + the pronunciation button, on one centred row. */
.svb-top { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.svb-ipa { font-size: .84rem; color: var(--muted); letter-spacing: .01em; }
.svb-audio { display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; cursor: pointer;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--brand-600); }
.svb-audio:hover { background: var(--brand-50); border-color: var(--brand-600); }
.svb-audio svg { width: 14px; height: 14px; }
/* Deck controls sit in a column BESIDE the card, not under it. The card is 620px tall,
   so nav underneath fell below the fold on a laptop and the student had to scroll to
   reach Next on every single word. Alongside, all three stay in reach while the card
   is read. The column holds only the two recall answers (Still learning / Know) and is
   centred on the card; plain navigation (Prev, Shuffle) sits in .flash-below, under the
   card, where it was before.

   🔴 align-items MUST stay `stretch`. The card has no intrinsic size of its own — its
   faces are position:absolute and the height comes from .flash-inner's min-height — so
   under `flex-start` it collapses to zero width the moment the stage turns into a column
   on mobile. The nav is positioned with align-self instead. */
.flash-stage { display: flex; align-items: stretch; gap: 18px; }
/* margin:0 overrides .flash's own `margin: 0 auto`. An auto margin on the cross axis
   beats align-items:stretch, so the card would size to its content — and its content is
   two position:absolute faces, i.e. zero. Belt and braces: width:100% in the column case. */
.flash-stage > .flash { flex: 1 1 auto; min-width: 0; margin: 0; }
.flash-nav { display: flex; flex-direction: column; justify-content: center;
             align-self: center; flex: 0 0 170px; gap: 12px; }
.flash-nav .btn { width: 100%; justify-content: center; }

/* Recall scoreboard above the card: how far through the deck, and how the answers split.
   Sized to the card (not the stage) with the same padding-right the below-row uses, so the
   three panels line up with the card edges rather than floating over the button column. */
.flash-stats { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 12px;
               margin-bottom: 16px; padding-right: 188px; }
/* Each panel is a <button> (it filters the run), so the browser's own button styling has
   to be reset back to a plain card: full width, left-aligned, inherited font. */
.fs-item { background: var(--surface); border: 1px solid var(--border);
           border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 12px 16px;
           width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
           display: block; transition: border-color var(--t-fast), background var(--t-fast); }
.fs-item:hover { border-color: var(--border-2); }
/* The active filter. Each panel lights in its own colour so the strip says both "this is
   the filter" and "this is the bucket" at once.
   The ring is an INSET SHADOW, not a thicker border: border-width would change the box and
   the grid columns would shift by a few pixels as the student clicks between filters
   (worse on mobile, where the padding compensation is overridden). A shadow costs no layout. */
.fs-total.on { border-color: var(--brand-600); box-shadow: inset 0 0 0 2px var(--brand-600);
               background: color-mix(in srgb, var(--brand-600) 7%, var(--surface)); }
.fs-know.on  { border-color: var(--ok);   box-shadow: inset 0 0 0 2px var(--ok);
               background: color-mix(in srgb, var(--ok) 9%, var(--surface)); }
.fs-learn.on { border-color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn);
               background: color-mix(in srgb, var(--warn) 9%, var(--surface)); }
/* Same blue as an exam card nobody has opened yet (--exam-line): both mean "untouched". */
.fs-fresh.on { border-color: var(--exam-line); box-shadow: inset 0 0 0 2px var(--exam-line);
               background: color-mix(in srgb, var(--exam-line) 9%, var(--surface)); }
.fs-lab { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
          color: var(--muted); }
.fs-num { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; color: var(--ink);
          line-height: 1.2; margin-top: 2px; }
.fs-of { font-size: .95rem; font-weight: 500; color: var(--muted); }
.fs-total .bar { margin-top: 8px; }
.fs-know .fs-num { color: var(--ok, #1e8e5a); }
.fs-learn .fs-num { color: var(--warn, #d98324); }
.fs-fresh .fs-num { color: var(--exam-line); }

/* Deck navigation, under the card and centred: this is where Shuffle lived originally
   and it is not a recall answer, so it stays out of the pair on the right.
   The padding-right is the nav column (170px) plus the stage gap (18px): without it the
   row centres on the whole stage and sits ~94px right of the card it belongs to. */
.flash-below { display: flex; justify-content: center; gap: 12px; margin-top: 18px;
               flex-wrap: wrap; padding-right: 188px; }

/* The two answers are colour-coded and the code carries through to the card itself, so a
   student paging back reads the state at a glance instead of hunting for a lit button.
   Same two colours and the same 7% tint the exam catalogue uses for resume/completed —
   see .test-card-resume / .test-card-done — so the whole site means one thing by amber
   and one thing by green. */
.flash-know  { --btn-bg: var(--ok);   --btn-fg: #fff; border-color: transparent; box-shadow: var(--shadow-sm); }
.flash-know:hover  { --btn-bg: color-mix(in srgb, var(--ok) 86%, #000); }
.flash-learn { --btn-bg: var(--warn); --btn-fg: #fff; border-color: transparent; box-shadow: var(--shadow-sm); }
.flash-learn:hover { --btn-bg: color-mix(in srgb, var(--warn) 86%, #000); }
/* The card that has already been answered: edge in the answer's colour, and the FRONT
   face tinted to match. The back face keeps its own reading background untouched. */
.flash-known .flash-face:not(.flash-back) {
  border-color: var(--ok); background: color-mix(in srgb, var(--ok) 7%, var(--surface)); }
.flash-learning .flash-face:not(.flash-back) {
  border-color: var(--warn); background: color-mix(in srgb, var(--warn) 7%, var(--surface)); }
/* The answer already given is the one ringed, so the pair does not read as two live options. */
.flash-know.on { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 32%, transparent); }
.flash-learn.on { box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 32%, transparent); }

/* Below ~760px there is no room for a side column: drop back to a row under the card
   (the original layout), still one group, still wrapping rather than clipping Next. */
@media (max-width: 760px) {
  .flash-stage { flex-direction: column; }
  .flash-stage > .flash { width: 100%; }
  .flash-nav { align-self: stretch; }
  .flash-below { margin-top: 12px; padding-right: 0; }   /* no side column to offset against */
  .flash-stats { padding-right: 0; gap: 8px; }
  .fs-item { padding: 10px 12px; }
  .fs-num { font-size: 1.2rem; }
  /* Still learning / Know are the primary pair, so on a phone they split the full width
     side by side rather than hugging the right edge. */
  .flash-nav { flex: 0 0 auto; flex-direction: row; justify-content: center;
               margin-top: 20px; }
  .flash-nav .btn { flex: 1 1 0; width: auto; }
}
.svb-freq { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: .82rem; color: var(--muted); }
.svb-freq b { color: var(--ink-2); font-weight: 700; }
/* SAT Vocab flashcard back — part of speech at the top, meaning up high,
   synonyms + antonyms split across the bottom. */
.sv-back { justify-content: flex-start; align-items: stretch; text-align: center; padding: 26px 30px 24px; }
.svb-pos { align-self: center; display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: 4px 13px; border-radius: 999px; }
/* Which deck the word came from ("Very common", "CEFR B2"). It used to sit above the
   card as a page badge; moved inside, left of the part-of-speech pill, so the header
   row could go entirely. Lighter weight than .svb-pos so the two never compete. */
.svb-deck { align-self: center; display: inline-block; font-size: .72rem; font-weight: 600;
  letter-spacing: .02em; padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
/* The same deck/part-of-speech/IPA row repeated on the FRONT face, under the word, so a
   student can check the sense and pronunciation without flipping. It reuses .svb-top for
   the layout and only adds the spacing that separates it from the word and the hint. */
.flash-meta { margin-top: 18px; }
/* Transcription + speaker as one unit: on a phone the row wraps, and the speaker on a
   line of its own under the IPA reads as a stray icon. */
.svb-say { display: inline-flex; align-items: center; gap: 10px; }
.flash-face > .flash-meta + .flash-hint { margin-top: 18px; }
.svb-main { margin-top: 30px; }
.svb-def { font-size: 1.4rem; line-height: 1.4; color: var(--ink); font-weight: 500; text-wrap: balance; }

/* HSK additions: the deck sits centred at SAT Practice's 980px; Chinese on the card uses the
   CJK serif; the speaker is hidden on a device with no Chinese voice. */
.hk-deckwrap { max-width: 980px; margin-inline: auto !important; }

/* 🔴 The deck fits the SCREEN, not a fixed 620px. A 620px card ran off a 720px laptop
   (Shuffle under the fold) and pushed Still learning / Know below a phone's screen, so every
   single card needed a scroll. The flip card's height is the screen minus what sits above it
   (header, back link, the strip) and below it (Shuffle, or on a phone the answer pair),
   never taller than before and never too short for the word. --hk-chrome is that "above +
   below", measured: card top ≈183px + Shuffle row ≈90px on a laptop; ≈249px + the answer
   row ≈80px on a phone.
   The writing and Listen & write cards never flip, so they take the height of what is in
   them instead: their face is laid out in the flow, not stacked absolutely for a 3D turn. */
.hk-deckwrap { --hk-chrome: 285px; }
.hk-deckwrap .flash-tall .flash-inner { min-height: clamp(320px, calc(100dvh - var(--hk-chrome)), 620px); }
.hk-deckwrap .hk-wcard .flash-inner { min-height: 0; }
.hk-deckwrap .hk-wcard .flash-face { position: relative; inset: auto; }
@media (max-width: 760px) {
  .hk-deckwrap { --hk-chrome: 335px; }
  .hk-deckwrap .flash-nav { margin-top: 0; }   /* the stage gap already separates it from the card */
  .hk-deckwrap .flash-face { padding-inline: 18px; padding-bottom: 22px; }
  /* The strip is four across on a phone: two-line labels made it 83px tall. */
  .hk-deckwrap .fs-lab { font-size: .64rem; letter-spacing: .03em; }
  .hk-deckwrap .fs-total .bar { margin-top: 6px; }
}
/* A finger needs a 44px target; the card's speaker is 26px for a mouse. */
@media (pointer: coarse) {
  .hk-deckwrap .svb-audio, .hk-wd .svb-audio, .hk-dresult .svb-audio { width: 44px; height: 44px; }
  .hk-deckwrap .svb-audio svg, .hk-wd .svb-audio svg { width: 18px; height: 18px; }
}
.hk-deck { color: var(--brand-600); background: color-mix(in srgb, var(--brand-600) 12%, transparent); border: 1px solid color-mix(in srgb, var(--brand-600) 33%, transparent); }
.flash-word.hk-flash-h { font-family: var(--font-zh); font-size: clamp(4rem, 9vw, 6.5rem); font-weight: 400; line-height: 1.15; }
/* 🔴 Pinyin is set in Inter, never the display serif: Fraunces has no proper glyphs for some
   tone letters (mā drew its macron beside the a) and its fallback Georgia has none at all —
   shuǐ came out as "shui" with a loose ˇ floating after it. Inter draws every tone mark,
   ü with tones included (ǖ ǘ ǚ ǜ). */
.flash-word.hk-flash-p { font-family: var(--font-ui); font-weight: 600; letter-spacing: -.01em; }
.hk-flash-gloss { margin: 10px 0 0; font-size: 1.05rem; color: var(--muted); max-width: 36ch; }
/* The meaning deck's front: pinyin under the characters, as on the back (Inter, see above). */
.hk-front-p { margin: 6px 0 0; font-family: var(--font-ui); font-size: 1.6rem; font-weight: 600; color: var(--brand-600); }
.hk-back { justify-content: center; }
.hk-back .svb-main { margin-top: 0; }
.hk-back-h { font-family: var(--font-zh); font-size: clamp(3.4rem, 7vw, 5rem); font-weight: 400; line-height: 1.15; color: var(--ink); }
.hk-back-p { margin: 6px 0 18px; font-size: 1.6rem; font-weight: 600; color: var(--brand-600); }
.svb-audio[hidden] { display: none; }

/* Writing decks (write = with a guide, blind = without): the vocabulary card holding a
   Hanzi Writer pad instead of a flip. The card never turns over, so it keeps the default
   cursor; a tap on the pad is a stroke, not a flip. */
.hk-wcard .flash-inner { cursor: default; }
.hk-wface { gap: 12px; justify-content: center; }
.hk-wclue { display: flex; align-items: center; gap: 10px; min-height: 34px; }
/* Pinyin in Inter for the same reason as .hk-flash-p — the display serif breaks tone marks. */
.hk-wpy { font-family: var(--font-ui); font-size: 1.6rem; font-weight: 600; color: var(--brand-600); }
/* touch-action:none + no selection/callout: on a phone or tablet a stroke must draw, never
   scroll the page, select text or open the long-press menu. */
.hk-pad { width: min(300px, 100%); aspect-ratio: 1; border: 1.5px dashed var(--border-2); border-radius: var(--r-lg); background:
  linear-gradient(var(--border) 0 0) center / 100% 1px no-repeat,
  linear-gradient(var(--border) 0 0) center / 1px 100% no-repeat, var(--surface); touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.hk-write-hint { margin: 0; min-height: 1.5em; color: var(--muted); font-weight: 600; }
.hk-wface .hk-word-e { max-width: 46ch; }
.hk-mask { color: var(--brand-600); }
.hk-wclue { flex-wrap: wrap; justify-content: center; }
.hk-wtools { display: inline-flex; gap: 6px; margin-left: 6px; padding-left: 12px; border-left: 1px solid var(--border); }
.hk-wtools .btn { gap: 6px; }
/* A phone gets the biggest pad that fits: writing with a finger needs room more than the
   card needs margins. A big tablet or desktop gets a little more than before too. */
@media (min-width: 700px) and (min-height: 900px) { .hk-pad { width: min(360px, 100%); } }
/* On a phone the pad also gives way to the screen's HEIGHT, so Still learning / Know — the
   way on to the next character — stay on screen under it (≈560px of card, strip and buttons
   around the pad on a 390×844 phone). Never under 230px: below that a finger cannot write. */
@media (max-width: 560px) {
  .hk-pad { width: min(320px, 100%, max(230px, calc(100dvh - 560px))); }
  .hk-wface { gap: 8px; }
  .hk-wclue { min-height: 30px; }
  .hk-deckwrap .hk-wcard .flash-face { padding-top: 40px; }
  .hk-write-hint { font-size: .85rem; }   /* one line, not two, on a 360px phone */
  .hk-wt-lab { display: none; }   /* icons only; the aria-label / title still name them */
  .hk-wtools .btn { width: 44px; height: 44px; padding: 0; justify-content: center; }
  /* A long CC-CEDICT gloss ran to six lines (155px) and pushed the answer pair off screen;
     three lines carry the sense, the full meaning is in the word list. */
  .hk-wface .hk-word-e { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
}
/* A phone on its side (≈390px tall): the page has to scroll anyway, but the whole pad must
   fit on screen at once, or a stroke runs off the bottom edge. */
@media (min-width: 561px) and (max-height: 500px) { .hk-pad { width: min(300px, 100%, calc(100dvh - 110px)); } }
/* A short phone (≈740px and under): two lines of meaning, and the pad may go a little smaller. */
@media (max-width: 560px) and (max-height: 760px) {
  .hk-wface .hk-word-e { -webkit-line-clamp: 2; line-clamp: 2; }
  .hk-pad { width: min(320px, 100%, max(220px, calc(100dvh - 540px))); }
}

/* Word list */
.hk-table-wrap { overflow-x: auto; }
.hk-table { width: 100%; border-collapse: collapse; }
.hk-table th { text-align: left; padding: 12px 16px; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border); }
.hk-table td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.hk-table tr:last-child td { border-bottom: 0; }
.hk-td-h { font-family: var(--font-zh); font-size: 1.3rem; font-weight: 500; white-space: nowrap; }
.hk-td-p { font-weight: 600; color: var(--brand-700); white-space: nowrap; }
.hk-td-l { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* A row opens the word popup. */
.hk-row { cursor: pointer; transition: background var(--t-fast); }
.hk-row:hover, .hk-row:focus-visible { background: color-mix(in srgb, var(--brand-600) 6%, transparent); outline: none; }
/* On a phone the four columns were 635px wide — the meaning sat off-screen behind a sideways
   scroll. Each row becomes a small block instead: the word on the left, pinyin over the
   meaning in the middle, the lesson and the speaker on the right. The header row goes; the
   lesson cell carries its own label (data-lab) so "3, 7" still says what it is. */
@media (max-width: 600px) {
  .hk-table thead { display: none; }
  .hk-table, .hk-table tbody { display: block; }
  .hk-table tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "h p l" "h e s";
    align-items: center; column-gap: 14px; row-gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .hk-table tr:last-child { border-bottom: 0; }
  .hk-table td { padding: 0; border: 0; }
  .hk-td-h { grid-area: h; min-width: 2.2em; font-size: 1.45rem; }
  .hk-td-p { grid-area: p; }
  .hk-td-e { grid-area: e; font-size: .9rem; line-height: 1.35; }
  .hk-td-l { grid-area: l; justify-self: end; font-size: .74rem; }
  .hk-td-l::before { content: attr(data-lab) " "; font-weight: 600; }
  .hk-table td:last-child { grid-area: s; justify-self: end; }
}

/* Word popup: the word writing itself in stroke order on 田字格 pads, looping until closed;
   pinyin, speaker, meaning and lesson underneath. Site tokens — not the exam's .dlg. */
/* margin:auto + inset:0 put it back in the middle — the site's reset zeroes a dialog's own margin. */
dialog.hk-wd { position: fixed; inset: 0; margin: auto; height: fit-content; width: calc(100% - 32px); max-width: 560px; max-height: calc(100dvh - 32px); overflow: auto; padding: 26px 24px 22px;
  border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-md); }
dialog.hk-wd::backdrop { background: rgba(10, 14, 20, .5); }
.hk-wd-x { position: absolute; top: 12px; right: 12px; display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.hk-wd-x:hover { color: var(--brand-600); border-color: var(--brand-300); }
.hk-wd-x svg { width: 18px; height: 18px; }
.hk-wd-pads { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 6px 0 18px; }
/* A phone fits two pads a row (longer words wrap); a one-character word gets the whole width. */
.hk-wd-pad { width: min(var(--pad), calc((100vw - 100px) / var(--cols, 2))); aspect-ratio: 1; border: 1.5px dashed var(--border-2); border-radius: var(--r-lg); background:
  linear-gradient(var(--border) 0 0) center / 100% 1px no-repeat,
  linear-gradient(var(--border) 0 0) center / 1px 100% no-repeat, var(--surface); }
.hk-wd-pad svg { width: 100%; height: 100%; }
.hk-wd-pad.is-text { display: grid; place-items: center; font: 400 calc(var(--pad) * .55) var(--font-zh); color: var(--ink); }
.hk-wd-info { text-align: center; }
.hk-wd-top { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px 12px; }
.hk-wd-h { font: 500 1.7rem var(--font-zh); color: var(--ink); }
/* Pinyin in Inter, like every pinyin on the site — the display serif breaks tone marks. */
.hk-wd-py { font: 600 1.35rem var(--font-ui); color: var(--brand-600); }
.hk-wd-e { margin: 10px auto 0; max-width: 44ch; font-size: 1.05rem; line-height: 1.5; color: var(--ink-2); }
.hk-wd-meta { margin: 10px 0 0; font-size: .82rem; font-weight: 600; color: var(--muted); }
.hk-td-e { color: var(--ink-2); }

@media (pointer: coarse) { .hk-say, .hk-wd-x { width: 44px; height: 44px; } }

/* "+2 XP" — rises from the button that earned it and fades (hsk.js flyXp). Fixed to the
   viewport, so a card re-render under it does not cut it short. */
.hk-xpfly {
  position: fixed; z-index: 60; transform: translate(-50%, -100%); pointer-events: none;
  font: 700 .95rem/1 var(--font-ui); color: var(--brand-link); white-space: nowrap;
  animation: hk-xpfly .95s var(--ease-out, ease-out) forwards;
}
@keyframes hk-xpfly {
  from { opacity: 0; transform: translate(-50%, -60%); }
  20%  { opacity: 1; }
  to   { opacity: 0; transform: translate(-50%, -260%); }
}
/* "How HSK XP works": the repeat ladder has four paying rungs, one more than CSCA's. */
.xp-lad.hk-lad { grid-template-columns: minmax(0, 1fr) repeat(2, 76px); }
.xp-lad.hk-lad + .xp-lad.hk-lad { margin-top: 10px; }
@media (max-width: 480px) { .xp-lad.hk-lad { grid-template-columns: minmax(0, 1fr) repeat(2, 64px); } }
@media (prefers-reduced-motion: reduce) {
  .hk-xpfly { animation: hk-xpfade .95s linear forwards; }
  @keyframes hk-xpfade { 0%, 60% { opacity: 1; } to { opacity: 0; } }
}
