/* Story Writer — /stories (js/stories/stories-page.js).
   The canvas + slot row reuse css/vocab-word.css (.dw-*); this file owns
   the shelf, the reader (book, sentence line, prompt) and the word card. */

.st-reader {
  --dw-guide: var(--canvas-grid, rgba(32, 80, 126, .18));
  --dw-ghost: rgba(120, 130, 160, .16);
  --dw-ghost-line: rgba(100, 110, 140, .35);
  --st-jp: "Noto Sans JP", "Noto Sans CJK JP", "Hiragino Sans", sans-serif;
  --st-serif: 'Newsreader', Georgia, serif;
  --st-word: color-mix(in srgb, var(--accent) 9%, transparent);
  --st-particle: color-mix(in srgb, var(--orange) 14%, transparent);
  --st-particle-ink: var(--orange);
  --st-name: color-mix(in srgb, var(--green) 12%, transparent);
  max-width: 640px; margin: 0 auto;
}
#st-home { --st-jp: "Noto Sans JP", "Noto Sans CJK JP", "Hiragino Sans", sans-serif; }
html.dark .st-reader {
  --dw-ghost: rgba(160, 170, 200, .16);
  --dw-ghost-line: rgba(180, 190, 220, .35);
}

/* ── Settings: two segmented switches ───────────────────────────── */
.st-settings { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
.st-reader .st-settings { justify-content: center; margin: 4px 0 18px; }
.st-seg { display: inline-flex; padding: 3px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--inset); }
.st-seg__btn { border: 0; background: transparent; color: var(--muted); font: 600 13px/1 system-ui, sans-serif; padding: 8px 13px; border-radius: 999px; cursor: pointer; transition: background .15s, color .15s; }
.st-seg__btn:hover { color: var(--ink); }
.st-seg__btn[aria-pressed="true"] { background: var(--card); color: var(--accent); box-shadow: 0 1px 3px rgba(40, 50, 70, .14); }
.st-seg__btn:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 1px; }

/* ── Shelf ──────────────────────────────────────────────────────── */
/* Shelf heading: the site's blue section kicker (.group-title, as on /grammar). */
.st-series.group-title { margin: 0 0 12px; }
.st-card__ch { font: 700 11px/1 var(--font-ui); text-transform: uppercase; letter-spacing: .09em; color: var(--accent); }
.st-card__scene { font-size: 14px; line-height: 1.55; color: var(--muted); }
.st-card.is-next { border-color: var(--accent-border); }
.st-card__badge.is-next { color: var(--accent); border-color: var(--accent-border); background: var(--accent-bg); }
.st-shelf { list-style: none; margin: 0 0 28px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
/* Sit 12px under the blue heading like /grammar (beats the layout's
   sibling spacing), and let cards shrink below their one-line JP preview. */
#st-home .st-series + .st-shelf { margin-top: 0; }
.st-shelf > li { min-width: 0; }
/* Chapter cards match the /grammar lesson cards (.grammar-idx__link). */
.st-card { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: inherit; text-decoration: none; transition: border-color .15s, background .15s, box-shadow .15s, transform .1s; }
.st-card:hover { border-color: var(--accent); background: var(--accent-bg, var(--card)); box-shadow: 0 4px 14px rgba(0, 0, 0, .06); }
.st-card:active { transform: translateY(1px); }
.st-card:hover .st-card__title { color: var(--accent); }
.st-card:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.st-card__num { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); font: 700 17px/1 var(--font-ui); }
.st-card.is-done .st-card__num { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.st-card__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.st-card__title { font: 700 17px/1.25 var(--font-ui); color: var(--ink); }
.st-card__jp { font: 400 15px/1.3 var(--st-jp); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-card__meta { font-size: 12.5px; color: var(--faint); }
.st-card__badge { flex: 0 0 auto; font: 700 12px/1 var(--font-ui); color: var(--muted); padding: 6px 9px; border-radius: 999px; border: 1px solid var(--line-2); }
.st-card__badge.is-done { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.st-error { color: var(--red); }

/* ── Reader top bar ─────────────────────────────────────────────── */
.st-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-bottom: 6px; }
.st-exit { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--inset); color: var(--muted); font: 600 13px/1 system-ui, sans-serif; padding: 8px 12px; border-radius: 999px; cursor: pointer; }
.st-exit:hover { color: var(--accent); border-color: var(--accent-border); }
.st-top__title { min-width: 0; display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.st-top__num { font: 600 13px/1 system-ui, sans-serif; color: var(--accent); background: var(--accent-bg); padding: 4px 8px; border-radius: 999px; }
.st-top__name { font: 600 19px/1.2 var(--st-serif); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Sentence navigation: ‹ dots › — written dots are buttons, the one on screen is ringed. */
.st-nav { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 0 14px; }
/* Settings behind a gear in the reader */
.st-gear { position: relative; }
.st-gear__btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent-border); background: var(--accent-bg); }
.st-gear__panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; padding: 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line-2); box-shadow: 0 16px 36px rgba(20, 28, 45, .18); }
.st-gear__panel[hidden] { display: none; }
.st-gear__panel .st-settings { flex-direction: column; align-items: stretch; margin: 0; gap: 10px; }
.st-gear__panel .st-seg { display: flex; }
.st-gear__panel .st-seg__btn { flex: 1 1 0; white-space: nowrap; }
/* Pen settings (the shared options-panel pieces) under the switches */
.st-gear__panel { display: flex; flex-direction: column; gap: 6px; width: 290px; max-height: calc(100vh - 140px); overflow-y: auto; overscroll-behavior: contain; text-align: left; }
.st-gear__panel .options-divider { border-top-color: var(--line-2); margin: 6px 0 4px; }
.st-gear__panel .color-swatch-grid { justify-content: start; }
body:not(.st-guided) .st-guided-only, .st-gear__panel [hidden] { display: none; }
.st-nav__btn { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--inset); color: var(--muted); display: grid; place-items: center; cursor: pointer; padding: 0; }
.st-nav__btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent-border); }
.st-nav__btn:disabled { opacity: .35; cursor: default; }
.st-dots { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; justify-content: center; }
.st-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); border: 0; padding: 0; margin: 3px; transition: background .2s, transform .2s, box-shadow .2s; }
button.st-dot { cursor: pointer; }
button.st-dot:hover { transform: scale(1.3); }
.st-dot.is-done { background: var(--accent); opacity: .55; }
.st-dot.is-cur { background: var(--accent); opacity: 1; }
.st-dot.is-view { opacity: 1; transform: scale(1.35); box-shadow: 0 0 0 3px var(--accent-bg), 0 0 0 4px var(--accent-border); }
.st-dot:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }

/* ── Storyboard: one pixel frame per sentence, sliced from the chapter strip ── */
.st-board { width: 120px; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden;
  background-repeat: no-repeat; background-size: 100% auto; image-rendering: pixelated;
  border: 1px solid var(--line-2); box-shadow: 0 6px 18px rgba(30, 30, 50, .12); }
.st-board[hidden] { display: none; }
.st-board.is-in { animation: st-board-in .35s ease both; }
@keyframes st-board-in { from { opacity: .25; transform: scale(.985); } to { opacity: 1; transform: none; } }
/* Tap to enlarge: a corner badge says so; the large copy sits over the page. */
.st-board[role="button"] { position: relative; cursor: zoom-in; }
.st-board[role="button"]::after { content: ""; position: absolute; right: 5px; bottom: 5px; width: 20px; height: 20px; border-radius: 6px;
  background: rgba(20, 24, 36, .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7'/%3E%3C/svg%3E") center / 12px no-repeat;
  opacity: .7; transition: opacity .15s ease; }
.st-board[role="button"]:hover::after, .st-board[role="button"]:focus-visible::after { opacity: 1; }
.st-board[role="button"]:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.st-zoom { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 12, 20, .78); cursor: zoom-out; animation: st-zoom-in .2s ease both; }
.st-zoom[hidden] { display: none; }
.st-zoom__img { width: min(100%, calc(100svh - 32px), 768px); aspect-ratio: 1 / 1; border-radius: 16px; outline: none;
  background-repeat: no-repeat; background-size: 100% auto; image-rendering: pixelated;
  border: 1px solid rgba(255, 255, 255, .14); box-shadow: 0 24px 60px rgba(0, 0, 0, .45); animation: st-zoom-pop .22s ease both; }
@keyframes st-zoom-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes st-zoom-pop { from { transform: scale(.92); } to { transform: none; } }

/* ── Sentence card layout ────────────────────────────────────────
   Writing:  [thumb | speaker + translation] / line / prompt / canvas
   Done or reviewed: speaker + translation / line / FULL picture / actions */
.st-current { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 16px;
  grid-template-areas: "board head" "line line" "write write" "review review" "next next"; }
.st-current > .st-board { grid-area: board; align-self: center; margin: 0 0 12px; }
.st-current > .st-head { grid-area: head; align-self: center; text-align: left; margin: 0 0 12px; }
.st-current > .st-line { grid-area: line; }
.st-current > .st-write { grid-area: write; }
.st-current > .st-review { grid-area: review; }
.st-current > .st-next { grid-area: next; }
.st-head .st-tr { margin: 0; }
.st-current.no-art { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "line" "write" "review" "next"; }
.st-current.no-art > .st-head { text-align: center; }
.st-current.is-done { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "line" "board" "review" "next"; }
.st-current.is-done > .st-head { text-align: center; }
.st-current.is-done > .st-board { width: min(256px, 72vw); justify-self: center; margin: 4px 0 16px; border-radius: 14px; }

/* ── Chapter opener + speakers ──────────────────────────────────── */
.st-scene { font: italic 400 16px/1.5 var(--st-serif); color: var(--muted); text-align: center; max-width: 34em; margin: 4px auto 16px; }
.st-scene[hidden] { display: none; }
.st-who { font: 600 11.5px/1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .09em; color: var(--accent); }
.st-who { margin: 0 0 8px; min-height: 11.5px; }
.st-after { font: italic 400 17px/1.5 var(--st-serif); color: var(--ink); max-width: 30em; margin: 0 auto 22px; }

/* ── Tappable tokens ────────────────────────────────────────────── */
/* No padding: neighbouring tokens (たろう + くん) must read as one word —
   the hover tint spreads with a box-shadow instead. */
.st-tok { font: inherit; color: inherit; background: transparent; border: 0; padding: 0; margin: 0; border-radius: 4px; cursor: pointer; line-height: inherit;
  text-decoration: underline dotted color-mix(in srgb, var(--ink) 25%, transparent); text-underline-offset: 6px; text-decoration-thickness: 1.5px; transition: background .15s; }
.st-tok:hover, .st-tok.is-open { background: var(--st-word); box-shadow: 0 0 0 3px var(--st-word); text-decoration-color: var(--accent); position: relative; z-index: 1; }
.st-tok--particle { color: var(--st-particle-ink); }
.st-tok--particle:hover, .st-tok--particle.is-open { background: var(--st-particle); box-shadow: 0 0 0 3px var(--st-particle); text-decoration-color: var(--st-particle-ink); }
.st-tok--name:hover, .st-tok--name.is-open { background: var(--st-name); box-shadow: 0 0 0 3px var(--st-name); text-decoration-color: var(--green); }
.st-tok:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 1px; }
.st-tok ruby rt { font-size: .45em; color: var(--muted); letter-spacing: .02em; }
.st-sp { white-space: pre; }

/* ── The sentence being written ─────────────────────────────────── */
.st-current { border-radius: 20px; padding: 22px 18px 20px; background: var(--card); border: 1px solid var(--line-2); box-shadow: var(--shadow-card); text-align: center; }
.st-current[hidden] { display: none; }
.st-tr { font: 500 clamp(21px, 3.8vw, 27px)/1.3 var(--st-serif); color: var(--ink); margin: 0 0 14px; }
.st-line { font: 400 clamp(24px, 5vw, 32px)/2 var(--st-jp); color: var(--ink); min-height: 2em; margin: 0 0 6px; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; }
.st-kanji .st-line { line-height: 2.3; }
.st-blank { display: inline-block; width: calc(var(--n, 2) * .95em); height: .9em; margin: 0 2px; border-bottom: 2px solid var(--line-2); vertical-align: baseline; }
.st-tok.is-new { animation: st-land .45s cubic-bezier(.2, .9, .3, 1.3) both; }
@keyframes st-land { from { transform: translateY(14px) scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.st-line.is-pop { animation: st-pop .5s ease both; }
@keyframes st-pop { 0% { transform: scale(1); } 40% { transform: scale(1.05); } 100% { transform: scale(1); } }
.st-punct { color: var(--muted); }

/* The current word's slots, inline in the sentence (word-canvas's slot row is
   moved into .st-curword). Sized to the sentence text; the ACTIVE empty slot
   shows its character faint ("Show each character") with the reading below. */
.st-line { align-items: center; }
.st-curword { display: inline-flex; margin: 0 2px; }
.st-line .dw-slots { display: inline-flex; gap: 4px; margin: 0; max-width: none; }
.st-line .dw-slot { width: 1.3em; height: 1.3em; border-radius: 8px; }
.st-line .dw-slot__glyph { font-size: .74em; }
.st-line .dw-slot--active .dw-slot__glyph:empty::before { content: attr(data-hint); opacity: .32; color: var(--accent); }
.st-line .dw-slot--active .dw-slot__glyph::after { content: attr(data-say); position: absolute; left: 50%; top: calc(100% + 3px); transform: translateX(-50%);
  font: 600 11px/1 system-ui, sans-serif; color: var(--accent); white-space: nowrap; letter-spacing: .02em; }
.st-line .dw-slot__clear { top: -6px; right: -6px; width: 16px; height: 16px; font-size: 11px; }
.st-current:not(.is-done) .st-line { margin-bottom: 18px; }   /* room for the reading under the active slot */

.st-write[hidden] { display: none; }
.st-write .dw-slots { margin-bottom: 12px; }
.st-unread { border-color: var(--orange) !important; }
.st-tools { display: flex; justify-content: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.st-tool { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--inset); color: var(--ink); font: 600 13.5px/1 system-ui, sans-serif; cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.st-tool:hover { border-color: var(--accent-border); color: var(--accent); }
.st-tool--icon { width: 38px; padding: 0; }
.st-tool[hidden] { display: none; }
.st-tool.is-playing { color: var(--accent); border-color: var(--accent); }

.st-next { margin-top: 6px; }
.st-next[hidden] { display: none; }
.st-review { margin-top: 6px; }
.st-review[hidden] { display: none; }
.st-review__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.st-current.is-practice { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-bg), var(--shadow-card); }
.st-next__note { font-size: 13.5px; color: var(--muted); margin: 0 0 12px; }
.st-current.is-done { border-color: color-mix(in srgb, var(--green) 40%, var(--line-2)); }

/* ── Story complete ─────────────────────────────────────────────── */
.st-end { text-align: center; padding: 26px 18px; border-radius: 20px; background: var(--card); border: 1px solid var(--line-2); box-shadow: var(--shadow-card); }
.st-end[hidden] { display: none; }
.st-end__title { font: 600 28px/1.2 var(--st-serif); margin: 0 0 4px; }
.st-end__stats { color: var(--muted); margin: 0 0 18px; }
.st-end__h { font: 600 13px/1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 0 0 10px; }
.st-end__words { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 22px; }
.st-chip.st-tok { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 12px; box-shadow: none; border: 1px solid var(--line-2); border-radius: 12px; background: var(--inset); font: 400 19px/1.3 var(--st-jp); text-decoration: none; }
.st-chip:hover { border-color: var(--accent-border); }
.st-chip__jp { white-space: nowrap; }
.st-chip small { font: 400 11.5px/1.2 system-ui, sans-serif; color: var(--muted); max-width: 12em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-end__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.st-end__actions [hidden] { display: none; }

/* ── The whole chapter (end card): every sentence stacked, to read through ── */
.st-read { text-align: left; max-width: 640px; margin: 0 auto 22px; padding: 18px 18px 6px; border-radius: 16px; background: var(--inset); border: 1px solid var(--line-2); }
.st-read__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.st-read__bar .st-end__h { margin: 0; }
.st-read__toggle { flex: none; white-space: nowrap; font: 600 12.5px/1 system-ui, sans-serif; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); color: var(--muted); cursor: pointer; }
.st-read__toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-border); background: var(--accent-bg); }
.st-read__toggle::before { content: '✓ '; opacity: 0; }
.st-read__toggle[aria-pressed="true"]::before { opacity: 1; }
.st-read__scene { text-align: left; margin: 10px 0 4px; max-width: none; }
.st-read__list { list-style: none; margin: 0; padding: 0; }
.st-read__row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line-2); }
.st-read__row:first-child { border-top: 0; }
.st-read__row.no-art { grid-template-columns: minmax(0, 1fr); }
.st-read__pic { width: 72px; aspect-ratio: 1 / 1; padding: 0; border-radius: 10px; border: 1px solid var(--line-2); cursor: pointer;
  background-repeat: no-repeat; background-size: 100% auto; image-rendering: pixelated; }
.st-read__pic:hover { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-bg); }
.st-read__pic:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.st-read__text .st-who { margin: 0 0 4px; }
.st-read__jp { font: 400 22px/1.7 var(--st-jp); color: var(--ink); }
.st-read__jp ruby rt { font-size: .45em; color: var(--muted); }
.st-read__tr { font: 400 15px/1.45 var(--st-serif); color: var(--muted); margin-top: 2px; }
.st-read.hide-tr .st-read__tr { display: none; }

/* ── Word / particle card ───────────────────────────────────────── */
.card { position: relative; }
.st-pop { position: absolute; z-index: 40; width: min(320px, calc(100% - 16px)); padding: 16px 18px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line-2); box-shadow: 0 18px 40px rgba(20, 28, 45, .18); text-align: left; }
.st-pop[hidden] { display: none; }
.st-pop__x { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); font: 600 18px/1 system-ui, sans-serif; cursor: pointer; }
.st-pop__x:hover { color: var(--accent); background: var(--accent-bg); }
.st-pop__kind { font: 600 11px/1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); margin-bottom: 8px; }
.st-pop__jp { font: 500 30px/1.5 "Noto Sans JP", "Noto Sans CJK JP", sans-serif; color: var(--ink); }
.st-pop__jp ruby rt { font-size: .42em; color: var(--muted); }
.st-pop__rom { font-size: 13.5px; color: var(--muted); margin-bottom: 8px; letter-spacing: .02em; }
.st-pop__label { font: 600 15px/1.3 'Newsreader', Georgia, serif; color: var(--orange); margin-bottom: 4px; }
.st-pop__body { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--ink); }
.st-pop__meaning { font: 500 17px/1.4 'Newsreader', Georgia, serif; }
.st-pop__dict { font-size: 12.5px; color: var(--faint); margin-top: 6px; }
.st-pop__actions { display: flex; gap: 8px; margin-top: 12px; }
/* Grammar links (popover + end card): lesson name over the rule, to /grammar/<lesson>#<rule> */
.st-gram { display: flex; flex-direction: column; gap: 1px; margin-top: 10px; padding: 8px 12px; border-radius: 10px; border: 1px dashed var(--accent-line); color: var(--accent); text-decoration: none; text-align: left; }
.st-gram:hover { border-style: solid; border-color: var(--accent-border); background: var(--accent-bg); }
.st-gram__lesson { font: 700 10.5px/1.2 system-ui, sans-serif; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.st-gram__rule { font: 600 13.5px/1.3 system-ui, sans-serif; }
.st-gram__rule::after { content: '\00a0→'; }
.st-end__gram { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 22px; }
.st-end__gram .st-gram { margin-top: 0; }

@media (max-width: 560px) {
  /* The gear's panel becomes a bottom sheet (thumb reach, never cropped) */
  .st-gear__panel { position: fixed; top: auto; left: 10px; right: 10px; bottom: 10px; width: auto; max-height: min(74vh, 560px); box-shadow: 0 -8px 28px rgba(0, 0, 0, .24); }
  .st-board { width: 88px; border-radius: 10px; }
  .st-read { padding: 14px 12px 4px; }
  .st-read__row { grid-template-columns: 56px minmax(0, 1fr); gap: 10px; }
  .st-read__pic { width: 56px; border-radius: 8px; }
  .st-read__jp { font-size: 19px; }
  .st-read__tr { font-size: 14px; }
  .st-scene { font-size: 14px; line-height: 1.4; margin: 0 auto 10px; }
  /* Short phones: the canvas shrinks with the screen height (never below 230px). */
  .st-reader .dw-canvas-wrap { max-width: min(340px, max(230px, calc(100svh - 430px))); }
  .st-tools { margin-top: 10px; }
  .st-nav { margin-bottom: 10px; }
  .st-current { padding-top: 14px; }
  .st-current { column-gap: 12px; }
  .st-current > .st-board, .st-current > .st-head { margin-bottom: 8px; }
  .st-head .st-tr { font-size: 19px; }
  .st-current .st-line { font-size: 24px; margin-bottom: 2px; }
  .st-exit span { display: none; }
  .st-exit { padding: 8px 10px; }
  .st-current { padding: 18px 12px 16px; }
  .st-settings { gap: 8px; }
  .st-seg__btn { padding: 8px 10px; font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .st-tok.is-new, .st-line.is-pop, .st-board.is-in, .st-zoom, .st-zoom__img { animation: none; }
}

/* The promo rail starts level with the first chapter card (the shared
   --heading offset is 35px; this heading block is 33px). */
#st-home .layout-with-rail__rail--heading { margin-top: 33px; }

/* Phones: tighter tools so sound, Hint, Show me and Auto-complete share one row
   (very narrow screens with long labels still wrap rather than overflow). */
@media (max-width: 480px) {
  .st-write .st-tools { gap: 6px; }
  .st-write .st-tool { padding: 0 10px; font-size: 12.5px; white-space: nowrap; }
  .st-write .st-tool--icon { width: 34px; flex: 0 0 34px; padding: 0; }
}
