/* Study / Kanji screen for the new design. Every class is
   prefixed .kj-; shared tokens come from styles.css. The kanji
   type colours — shu #DE5B2C, its deep step #B8461F and the
   wash #FBEBE2, plus the warning pair — are the design board's
   own and are not in the shared sheet yet, so they are declared
   here on the screen root; central integration can lift them
   into styles.css when a second screen needs them. */
.kj-root{
  --kj-shu:#de5b2c;
  --kj-shu-deep:#b8461f;
  --kj-wash:#fbebe2;
  --kj-warn:#b97e14;
  --kj-warn-wash:#fdf6e0;
  display:grid;gap:20px;
  max-width:720px;margin:0 auto;
}
.kj-meta{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.kj-chip{display:inline-block;font-size:.75rem;font-weight:700;letter-spacing:.04em;
  border-radius:999px;padding:6px 14px;min-height:28px}
.kj-chip-type{background:var(--kj-wash);color:var(--kj-shu-deep)}
.kj-chip-new{background:var(--lime);color:var(--violet-deep)}
.kj-chip-studied{background:var(--kj-wash);color:var(--kj-shu-deep)}
.kj-context{color:var(--muted);font-size:.8125rem;font-weight:600}
.kj-status{margin-left:auto;color:var(--muted);font-size:.8125rem}
.kj-card{background:var(--white);border:1px solid var(--lav-2);border-radius:20px;padding:26px}

/* hero */
.kj-hero{border-radius:var(--r-lg);display:flex;gap:24px;flex-wrap:wrap}
.kj-tile{background:var(--kj-wash);border-radius:16px;flex:none;width:150px;min-height:150px;
  display:grid;place-items:center}
.kj-glyph{font-family:var(--jp);font-size:6rem;font-weight:600;color:var(--kj-shu);line-height:1}
/* The basis is the hero's wrap point: while tile, gap and
   basis fit the card, the main column grows beside the tile
   exactly as a plain flex:1 did; when they stop fitting —
   which the text-size zoom causes inside this same phone
   layout, the effective card shrinking under it — the column
   wraps under the tile at the card's full width instead of
   squeezing into what is left and pushing its reading pills
   out of the card (2026-12-02). */
.kj-hero-main{flex:1 1 140px;min-width:250px}
.kj-kind{color:var(--kj-shu-deep);font-size:.6875rem;font-weight:700;letter-spacing:.09em;margin:0 0 10px}
.kj-pills{display:flex;gap:12px;flex-wrap:wrap}
/* A pill may shrink below its one-line width and let its
   label wrap at the space: beside the glyph tile the hero's
   main column is only as wide as the card leaves it, and at
   the larger text sizes a full reading on one line ran past
   the column and out of the card's scroll region (2026-12-02).
   When the column has room, nothing changes. */
.kj-pill{min-width:0;max-width:100%;border:1px solid var(--lav-2);background:var(--white);border-radius:999px;
  padding:7px 18px;font-family:var(--jp);font-size:.875rem;font-weight:600;min-height:44px;
  display:inline-flex;align-items:center;cursor:pointer;color:inherit}
.kj-pill-filled{background:var(--kj-shu);border-color:var(--kj-shu);color:var(--white);font-weight:700}
/* The pill is the Listen button (2026-11-26): its speaker
   sign sits after the romaji, sized to the pill's text. */
.kj-pill .lucide{width:15px;height:15px;margin-left:7px;flex:none}
.kj-note{color:var(--muted);font-size:.75rem;margin:10px 0 0}
.kj-meanings{font-size:1.625rem;font-weight:800;letter-spacing:-.01em;margin:12px 0 0;line-height:1.25}
.kj-facts{color:var(--muted);font-size:.8125rem;margin:16px 0 0}
.kj-picture{border:1px solid var(--lav-2);border-radius:16px;padding:12px;text-align:center;width:212px}
.kj-pic-label{color:var(--kj-shu-deep);font-size:.625rem;font-weight:700;letter-spacing:.06em;margin:0}
.kj-pic-caption{color:var(--muted);font-size:.75rem;margin:6px 0 0}

/* paired cards: taken apart / strokes, watch out / remember */
.kj-pair{display:grid;gap:20px}
.kj-sec-label{color:var(--kj-shu-deep);font-size:.6875rem;font-weight:700;
  letter-spacing:.09em;margin:0 0 16px}
.kj-parts{display:flex;gap:12px;flex-wrap:wrap}
.kj-part{background:var(--kj-wash);border-radius:12px;padding:10px 8px;flex:1;min-width:98px;
  display:flex;flex-direction:column;align-items:center;gap:2px;text-align:center}
.kj-part-glyph{font-family:var(--jp);font-size:1.875rem;font-weight:600;color:var(--kj-shu);line-height:1.3}
.kj-part-label{color:var(--muted);font-size:.6875rem;font-family:var(--jp)}
.kj-story{font-size:.875rem;line-height:1.5;margin:16px 0 0}
.kj-card > .kj-story:first-of-type{margin-top:0}
.kj-stroke-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:8px}
/* Stroke cells stand 44px tall (UI audit tap-target batch);
   equal negative margins hand the growth back to the grid. */
.kj-stroke-cell{background:var(--paper);border:1px solid var(--lav-2);border-radius:8px;
  min-height:44px;margin:-2px 0;display:grid;place-items:center;font-weight:700;font-size:.8125rem;color:var(--muted);
  font-family:inherit;cursor:pointer;padding:0}
.kj-stroke-first{background:var(--kj-shu);border-color:var(--kj-shu);color:var(--white)}
.kj-stroke-on{background:var(--violet);border-color:var(--violet);color:var(--white)}
.kj-anim{background:var(--paper);border:1px solid var(--lav-2);border-radius:16px;
  margin-top:12px;padding:12px;display:grid;place-items:center}
.kj-anim-svg{width:200px;height:200px;max-width:100%}
.kj-trace{display:block;background:var(--kj-wash);color:var(--kj-shu-deep);border-radius:12px;
  padding:12px;font-weight:600;font-size:.8125rem;text-align:center;margin:8px 0 0;text-decoration:none}

/* words with this kanji */
.kj-words-label{margin:0}
.kj-words{display:grid;gap:12px}
.kj-word{background:var(--white);border:1px solid var(--lav-2);border-radius:var(--r-md);
  padding:10px 20px;display:flex;align-items:center;gap:16px;min-height:64px;
  text-decoration:none;color:inherit;-webkit-user-drag:none;cursor:pointer}
.kj-word b{font-family:var(--jp);font-size:1.1875rem;font-weight:700}
.kj-word-reading{color:var(--muted);font-size:.8125rem;font-family:var(--jp)}
.kj-word-meaning{margin-left:auto;text-align:right;font-size:.875rem}

/* example */
.kj-example{display:flex;gap:16px;align-items:flex-start;justify-content:space-between}
/* The lines column must be allowed to shrink below its
   longest line: the romaji line is written without word
   spaces, so its min-content is the whole sentence, and
   beside the fixed Listen button that sum forced the row
   wider than the card — the button ended up clipped at the
   card's edge inside its scroll region (2026-12-02). With
   min-width:0 the column takes the width the card has, and
   the two derived pronunciation lines wrap anywhere rather
   than holding the row open. */
.kj-example-lines{flex:1;min-width:0}
.kj-example-lines p{margin:0}
.kj-ex-ja{font-family:var(--jp);font-size:1.0625rem;font-weight:500}
.kj-ex-kana{font-family:var(--jp);font-size:.75rem;color:var(--muted);padding-top:4px}
.kj-ex-romaji{font-size:.75rem;color:var(--muted);padding-top:2px;overflow-wrap:anywhere}
.kj-ex-say{font-size:.75rem;color:var(--violet-deep);font-weight:800;padding-top:2px;overflow-wrap:anywhere}
.kj-ex-sub{color:var(--muted);font-size:.75rem;font-family:var(--jp);padding-top:4px}
.kj-ex-en{color:var(--muted);font-size:.8125rem;padding-top:6px}
.kj-listen{background:var(--lav-1);color:var(--violet);border:0;border-radius:12px;
  font-family:var(--sans);font-weight:700;font-size:.8125rem;padding:12px 16px;
  min-height:44px;cursor:pointer;flex:none}

/* watch out / remember */
.kj-warn{background:var(--kj-warn-wash);border:0}
.kj-warn-label{color:var(--kj-warn)}
.kj-remember{background:var(--lav-1);border:0}
.kj-remember-label{color:var(--violet)}

/* Sticky Scene (Phase 0): the composed scene inside the
   Remember-it note. Drawn actors are ink line art on the note
   paper; the shu accent (#DE5B2C, the concept's accent) marks
   the part that acts. Chips name the parts the split left over. */
.kj-scene{margin-top:10px}
.scene-canvas{display:block;width:100%;max-width:230px;height:auto;margin:0 auto}
.scene-actor{color:var(--ink)}
.scene-accent{color:#de5b2c}
.scene-chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.scene-chip{display:inline-flex;align-items:baseline;gap:6px;background:var(--white);
  border:1px solid var(--lav-2);border-radius:999px;padding:5px 12px;
  font-size:.8125rem;font-weight:700;color:var(--ink)}
.scene-chip-label{color:var(--muted);font-weight:600}
.scene-chip.scene-accent{border-color:#de5b2c;color:#de5b2c}
.scene-chip.scene-accent .scene-chip-label{color:#de5b2c}
.kj-keyword-chip{margin:10px 0 0;font-weight:800;font-size:.875rem;color:var(--violet)}
.kj-keyword-kana{color:var(--ink)}
.scene-stroke{fill:none;stroke:var(--ink);stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
.scene-box{fill:none;stroke:var(--muted);stroke-width:1;stroke-dasharray:4 3}
.scene-box-faint{opacity:.45}
.scene-box.scene-accent{stroke:#de5b2c}
.scene-step-marker{margin:0 0 6px;font-size:.75rem;font-weight:800;letter-spacing:.08em;color:var(--muted)}
.scene-controls{display:flex;gap:10px;margin-top:8px}
.scene-step-btn,.scene-replay-btn{background:var(--white);border:1px solid var(--lav-2);
  border-radius:999px;padding:10px 18px;min-height:44px;cursor:pointer;
  font-family:var(--sans);font-weight:700;font-size:.875rem;color:var(--violet)}

/* returns + actions */
.kj-returns{background:var(--white);border:1px solid var(--lav-2);border-radius:12px;
  padding:12px 16px;text-align:center;font-weight:600;font-size:.875rem;margin:0}
.kj-actions{display:flex;align-items:center;gap:16px;flex-wrap:wrap}
.kj-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;cursor:pointer;
  font-family:var(--sans);font-weight:700;font-size:1rem;border-radius:16px;
  padding:14px 24px;min-height:56px;text-decoration:none}
.kj-btn-ghost{background:var(--white);border:1px solid var(--lav-2);color:var(--ink)}
.kj-btn-primary{background:var(--violet);color:var(--white);box-shadow:0 4px 0 var(--violet-deep)}
.kj-btn-primary:active{transform:translateY(2px);box-shadow:0 2px 0 var(--violet-deep)}
.kj-dots{display:flex;gap:6px;margin:0 auto;align-items:center}
.kj-dot{width:8px;height:8px;border-radius:50%;border:1.5px solid var(--violet)}
.kj-dot-on{background:var(--violet)}

@media (min-width:900px){
  .kj-tile{width:240px;min-height:212px}
  .kj-glyph{font-size:9.375rem}
  .kj-pair{grid-template-columns:1fr 1fr}
  .kj-words{grid-template-columns:1fr 1fr}
  /* One row, as the board has it: Previous, the dots, Next.
     The base rule wraps, so a long lesson's dots pushed Next
     onto its own row, stranded at its fixed width (San,
     2026-11-20). The row now holds, and the dots — the one
     element that can lose pieces without losing meaning —
     clip when space runs out. */
  .kj-actions{flex-wrap:nowrap}
  .kj-actions .kj-dots{margin:0 auto;min-width:0;overflow:hidden;flex:0 1 auto}
  .kj-actions .kj-dot{flex:none}
  .kj-btn{white-space:nowrap}
  .kj-btn-ghost{flex:none}
  .kj-btn-primary{flex:0 0 360px;margin-left:auto}
}

/* Session bar (the board's study chrome, shared shape with the
   grammar page) and the phone forms: chapter at the meta row's
   right with no status line, glyph tile full width, returns as
   plain centred text, footer buttons side by side. */
.kj-session{display:flex;align-items:center;gap:12px}
.kj-nav-btn{flex:none;width:44px;height:44px;display:grid;place-items:center;
  text-decoration:none;color:var(--muted);font-size:1.125rem;font-weight:700;border-radius:var(--r-md)}
.kj-nav-btn:hover{color:var(--ink);background:var(--lav-1)}
.kj-session-title{flex:1;text-align:center;color:var(--muted);font-weight:600;font-size:.875rem}
.kj-session-title-m{display:none}
.kj-session-count{flex:none;font-weight:600;font-size:.875rem;min-width:96px;text-align:right}
.kj-track{height:5px;border-radius:999px;background:var(--lav-2);overflow:hidden}
.kj-track i{display:block;height:100%;background:var(--violet);border-radius:999px}
@media (max-width:899px){
  .kj-session-title{display:none}
  .kj-session-count{display:none}
  .kj-session-title-m{display:block;flex:1;text-align:center;font-weight:700;font-size:.9375rem}
  .kj-status{display:none}
  .kj-context{margin-left:auto}
  .kj-tile{width:100%;min-height:190px}
  .kj-returns{background:none;border:0;padding:4px 0}
  /* Side by side whenever they fit — the wrap only takes over
     when the pair's own width runs out, which the text-size
     zoom can cause inside this same phone layout: at the
     largest sizes the two nowrap buttons' smallest widths sum
     past the bar and Next ran off the edge (2026-12-02). */
  .kj-actions{flex-wrap:wrap}
  .kj-actions .kj-dots{display:none}
  .kj-btn{white-space:nowrap;padding:14px 16px}
  .kj-btn-primary{flex:1}
}

/* ---- the one-card layout (2026-11-18 redesign) ---- */
.kj-one{display:flex;flex-direction:column;gap:14px}
.kj-main-card{flex:1;min-height:0;display:flex;flex-direction:column;border-radius:var(--r-lg);padding:20px}
.kj-segs{display:flex;gap:2px;border:1px solid var(--lav-2);border-radius:16px;padding:4px;flex:none}
.kj-seg{flex:1;min-width:0;overflow:hidden;display:flex;flex-direction:column;align-items:center;gap:1px;
  background:none;border:0;border-radius:12px;padding:7px 0 6px;cursor:pointer;
  color:var(--muted);font-family:var(--sans);min-height:52px}
.kj-seg-glyph{font-family:var(--jp);font-size:1.25rem;font-weight:700;line-height:1.15}
.kj-seg-label{font-size:.6875rem;font-weight:700;letter-spacing:.03em}
.kj-seg-on{background:var(--lav-1);color:var(--violet)}
.kj-seg-body{flex:1;min-height:0;overflow-y:auto;margin-top:16px;overscroll-behavior:contain;
  -webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 16px),transparent);
  mask-image:linear-gradient(to bottom,#000 calc(100% - 16px),transparent)}
.kj-seg-body[hidden]{display:none}
/* Words segment: the body itself carries no fade — the
   scroll box inside it does — so the "more words" line
   below the box is never faded (2026-11-26). */
.kj-seg-words{overflow:visible;display:flex;flex-direction:column;
  -webkit-mask-image:none;mask-image:none}
.kj-words-scroll{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;
  -webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 16px),transparent);
  mask-image:linear-gradient(to bottom,#000 calc(100% - 16px),transparent)}
/* Parts segment: same shape as Words — the body itself
   carries no fade, the scroll box inside it does, so the
   "more kanji" line below the box is never faded
   (2026-11-26). */
.kj-seg-parts{overflow:visible;display:flex;flex-direction:column;
  -webkit-mask-image:none;mask-image:none}
.kj-parts-scroll{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;
  -webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 16px),transparent);
  mask-image:linear-gradient(to bottom,#000 calc(100% - 16px),transparent)}
.kj-seg-strokes{overflow:hidden;display:flex;flex-direction:column}
.kj-hero-c{display:flex;gap:16px;flex-wrap:wrap}
.kj-tile-c{width:112px;min-height:112px;border-radius:14px}
.kj-glyph-c{font-size:4.25rem}
.kj-meanings-c{font-size:1.375rem;margin-top:8px}
.kj-example-in{margin-top:18px;border-top:1px solid var(--lav-2);padding-top:14px}
.kj-remember-in{margin-top:14px;border-radius:14px;padding:14px 16px}
.kj-remember-in .kj-story{margin-top:6px}
.kj-returns-in{margin-top:14px}
.kj-radical-note{color:var(--muted);font-size:.8125rem;margin:16px 0 0;line-height:1.5}
.kj-subs{display:inline-flex;gap:2px;border:1px solid var(--lav-2);border-radius:999px;padding:3px;flex:none;align-self:flex-start}
/* The Steps / Practice sub-tabs stand 44px tall (UI audit
   tap-target batch); negative margins hand the growth back. */
.kj-sub{background:none;border:0;border-radius:999px;padding:7px 18px;cursor:pointer;
  font-family:var(--sans);font-weight:700;font-size:.8125rem;color:var(--muted);min-height:44px;margin:-2px 0}
.kj-sub-on{background:var(--lav-1);color:var(--violet)}
.kj-steps-view{margin-top:14px}
.kj-trace-view{margin-top:12px;display:flex;flex-direction:column;min-height:0;flex:1}
.kj-trace-stage{border-radius:16px;max-width:332px;width:100%;margin:0 auto}
.kj-trace-stage .db-box{background:var(--lav-1)}
.kj-coach{background:var(--kj-wash);border-radius:12px;padding:10px 14px;margin-top:10px;
  display:flex;align-items:center;gap:12px}
.kj-coach-ok{background:#e2f3e8}
.kj-coach-text{font-size:.8125rem;font-weight:600;margin:0;flex:1;line-height:1.4}
.kj-coach-dots{display:flex;gap:5px;flex:none}
.kj-coach-dot{width:8px;height:8px;border-radius:50%;border:1.5px solid var(--violet);display:block}
.kj-coach-dot-on{background:var(--violet)}
.kj-trace-ctrls{display:flex;align-items:center;gap:8px;margin-top:6px}
/* Trace links (Play the animation, Undo, Clear — the same
   class serves the practice Writing question) stand 44px tall
   (UI audit tap-target batch); negative margins hand it back. */
.kj-trace-link{background:none;border:0;color:var(--violet);font-family:var(--sans);
  font-weight:700;font-size:.8125rem;padding:10px 6px;cursor:pointer;min-height:44px;
  margin:-2px 0;display:inline-flex;align-items:center;gap:6px}
.kj-trace-link .lucide{width:15px;height:15px;flex:none}
.kj-trace-ctrls .kj-trace-link:first-child{margin-right:auto}
.kj-words-in .kj-word{background:var(--paper)}
.kj-words-foot{color:var(--muted);font-size:.75rem;text-align:center;margin:10px 0 0}
@media (min-width:900px){
  .kj-seg-body{min-height:400px}
  .kj-trace-stage{max-width:300px}
  /* Desktop one-card bound (the phone rule below has its twin):
     cap the column at the viewport the shell leaves (40 top +
     64 bottom main padding) so the segment body scrolls inside
     the card and the actions stay on screen at short landscape
     heights instead of pushing the page past one screen. */
  .kj-one{max-height:calc(100vh - 104px);max-height:calc(100dvh - 104px)}
}
@media (min-width:900px) and (max-height:900px){
  .kj-seg-body{min-height:0}
}
@media (max-width:899px){
  .kj-one{height:calc(100vh - 130px);height:calc(100dvh - 130px);gap:12px}
  .kj-main-card{padding:16px}
  .kj-tile-c{width:104px;min-height:104px}
}
.kj-one .kj-hero-main{min-width:0}
.kj-seg-strokes .kj-steps-view{overflow-y:auto;min-height:0}
/* The stage flexes to the leftover height, but it needs a
   floor: where the height chain above it is content-sized
   (the short-desktop media rule drops the segment body's
   min-height), flex hands it nothing and the draw box —
   sized height:100% — collapsed to 0x0, leaving the
   Practice tab with no pane to draw in (San, 2026-11-24).
   200px sits below every size the flex actually deals
   (228px phone, 246px desktop), so it only ever catches
   the collapse. */
.kj-trace-stage{flex:1;min-height:200px;display:grid;place-items:center;width:100%}
.kj-trace-stage .db-box{height:100%;width:auto;max-width:100%}
.kj-tile-c{align-self:flex-start;height:112px;min-height:112px}
@media (max-width:899px){ .kj-tile-c{height:104px;min-height:104px} }
.kj-stroke-all{background:var(--violet);border-color:var(--violet);color:#fff}

/* Sound family (2026-11-27): under the Built-from tiles in
   the Parts segment, spaced like the radical note below it. */
.kj-family{margin-top:20px}
.kj-family .kj-sec-label{margin-bottom:8px}
.kj-family-line{font-size:.875rem;line-height:1.5;margin:0}

/* The learner's own reminder (2026-11-27): the note block
   under the Remember-it box on the study page, and the
   "written by you" subline in the feedback box. */
.kj-note-sub{color:var(--muted);font-size:.75rem;margin:8px 0 0}
.kj-note-block{margin-top:14px}
.kj-note-block .kj-sec-label{margin-bottom:8px}
.kj-note-text{font-size:.875rem;line-height:1.5;margin:0 0 8px}
.kj-note-write,.kj-note-btn{background:none;border:0;color:var(--violet);
  font-family:var(--sans);font-weight:700;font-size:.8125rem;cursor:pointer;
  padding:10px 6px;min-height:44px;margin:-2px 0;
  display:inline-flex;align-items:center}
.kj-note-edit textarea{width:100%;box-sizing:border-box;min-height:88px;
  font-family:var(--sans);font-size:16px;line-height:1.5;color:var(--ink);
  background:var(--white);border:1px solid var(--lav-2);border-radius:var(--r-md);
  padding:12px;resize:vertical}
.kj-note-btns{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-top:10px}
.kj-note-btns .kj-btn{min-height:44px;padding:10px 20px;font-size:.875rem}
.kj-note-btns .kj-note-btn{margin-left:auto}
