/* Story screens — audio list, audio reader, text story lists and text reader.
   Mirrors the mobile "Reader B" design (shared/ui/story/**, theme/Color.kt, AppTokens.kt). */
/* The story tokens (--sn-*) live in app.css :root: the PRO, notes and records sheets use them too. */

/* ---------- App shell on story screens ----------
   The web header stays the shell's own. Only phones (< 768px) give readers the whole screen:
   their bottom dock replaces the phone tab bar, like the app. */
@media (max-width: 767px) {
  .app-shell:has(.story-reader) .sidebar { display: none; }
  .app-shell:has(.story-reader) .workspace { padding-bottom: 0; }
}
html:has(.story-reader) { scroll-padding-bottom: 150px; }

.story-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.audio-page { color: var(--sn-ink); }
.audio-page button, .audio-page select { -webkit-tap-highlight-color: transparent; }
.audio-page .button { font-size: 14px; }
.story-loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 48px 0; color: var(--sn-muted); }
.story-spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--sn-container); border-top-color: var(--sn-appbar); animation: story-spin .8s linear infinite; }
@keyframes story-spin { to { transform: rotate(360deg); } }

/* ---------- Lists ---------- */
.story-list { max-width: 760px; margin: 0 auto; }
.story-list-head { padding-top: 4px; }
.story-listen-card { position: relative; display: flex; align-items: center; gap: 12px; min-height: 72px; margin-top: 18px; padding: 14px 100px 14px 16px; border-radius: 18px; background: var(--sn-hero); color: #fff; }
.story-listen-card:hover { background: #005a4f; }
.story-listen-play { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; background: #fff; color: var(--sn-hero); }
.story-listen-play svg { width: 24px; height: 24px; }
.story-listen-text { display: grid; gap: 2px; min-width: 0; }
.story-listen-text strong { font: 600 16px/22px Mali, sans-serif; }
.story-listen-text small { font-size: 13px; line-height: 18px; color: var(--sn-on-hero-muted); }
.story-listen-mam { position: absolute; right: 6px; top: -18px; width: 92px; height: auto; pointer-events: none; }
.story-chiprow { display: flex; gap: 8px; margin: 12px calc(-1 * var(--sn-gutter)) 0; padding: 0 var(--sn-gutter) 2px; overflow-x: auto; scrollbar-width: none; }
.story-chiprow::-webkit-scrollbar { display: none; }
.story-chips, .story-continue { display: flex; gap: 8px; flex-shrink: 0; margin: 0; }
.story-continue-label, .story-continue-title, .story-listen-cta, .story-intro, .story-card-art, .story-meta, .audio-now { display: none; }
.story-chip { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; min-height: 38px; padding: 0 14px; border: 1px solid var(--sn-line); border-radius: 999px; background: var(--sn-surface); color: var(--sn-ink); font-size: 14px; font-weight: 600; white-space: nowrap; }
.story-chip svg { width: 16px; height: 16px; color: var(--sn-hero); }
.story-chip:hover { border-color: var(--sn-appbar); background: #f7fbfa; }
.story-chip[aria-current="page"] { background: var(--sn-container); border-color: #b9ddd5; color: var(--sn-on-container); }
.story-toolbar { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.story-search { position: relative; flex: 1; min-width: 0; }
.story-search svg { position: absolute; left: 12px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--sn-muted); pointer-events: none; }
.story-search input { width: 100%; min-height: 44px; padding: 10px 12px 10px 40px; border: 1px solid var(--sn-line); border-radius: 12px; background: var(--sn-surface); color: var(--sn-ink); font: inherit; font-size: 15px; }
.story-search input::placeholder { color: #7d908c; }
.story-filter { flex: 0 0 auto; }
.story-filter select { min-height: 44px; width: 132px; padding: 8px 32px 8px 12px; border: 1px solid var(--sn-line); border-radius: 12px; background: var(--sn-surface); color: var(--sn-ink); font-size: 14px; }
.story-icon-btn { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border: 1px solid var(--sn-line); border-radius: 12px; background: var(--sn-surface); color: var(--sn-hero); }
.story-icon-btn:hover { background: var(--sn-container); }
.story-icon-btn svg { width: 20px; height: 20px; }
.audio-list-count { margin: 12px 2px 8px; font-size: 13px; color: var(--sn-muted); }
.story-rows { border: 1px solid var(--sn-line); border-radius: 18px; background: var(--sn-surface); overflow: hidden; }
.story-rows.is-empty { border: 0; background: transparent; }
.story-row { display: flex; align-items: center; gap: 4px; min-height: 60px; padding: 0 6px 0 0; }
.story-row + .story-row { border-top: 1px solid var(--sn-line); }
.story-row > a { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; align-self: stretch; padding: 8px 0 8px 14px; }
.story-row:hover { background: #f7faf9; }
.audio-story-number { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--sn-line); background: var(--sn-bg); color: var(--sn-muted); font: 600 13px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.story-row.is-read .audio-story-number { border-color: var(--sn-container); background: var(--sn-container); color: var(--sn-on-container); }
.story-row-text { display: grid; gap: 2px; min-width: 0; }
.story-row h2 { margin: 0; font: 600 16px/22px Mali, sans-serif; color: var(--sn-ink); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.story-row-sub { font-size: 13px; line-height: 18px; color: var(--sn-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story-row small { font-size: 12px; line-height: 16px; color: var(--sn-muted); }
.story-star { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 50%; background: transparent; color: var(--sn-outline); }
.story-star:hover { background: var(--sn-soft); }
.story-star svg { width: 22px; height: 22px; }
.story-star[aria-pressed="true"] { color: var(--sn-star); }
.story-star[aria-pressed="true"] svg { fill: currentColor; }
.story-pro { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; padding: 4px 8px; border-radius: 8px; background: var(--sn-lock); color: #fff; font: 700 12px/16px system-ui, sans-serif; }
.story-pro svg { width: 13px; height: 13px; }
.audio-pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 18px 0 8px; font-size: 13px; color: var(--sn-muted); }
.audio-pagination:empty { display: none; }
.audio-pagination .button { min-height: 44px; padding: 8px 14px; border-radius: 999px; font-size: 13px; }
.audio-local { font-size: 12px; line-height: 1.6; color: var(--sn-muted); margin-top: 14px; }
.story-list > .audio-local { text-align: center; margin: 20px auto 0; max-width: 520px; }

/* Empty / error / gate states (MascotEmptyState) */
.story-empty { display: grid; justify-items: center; gap: 12px; padding: 24px 32px 40px; text-align: center; }
.story-empty .story-empty-mam { width: 150px; height: auto; }
.story-empty h2 { font: 600 22px/28px Mali, sans-serif; color: var(--sn-ink); margin: 0; }
.story-empty p { max-width: 320px; margin: 0; font-size: 16px; line-height: 22px; color: var(--sn-muted); }
.story-error-detail { display: block; margin-top: 6px; font-size: 13px; }
.story-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.story-empty-actions .button { min-height: 50px; padding: 0 26px; border-radius: 999px; }
.story-empty-actions .button svg { width: 18px; height: 18px; }
.story-empty-text { color: var(--sn-muted); font-size: 16px; padding: 16px 0; }

.audio-status { min-height: 1px; margin: 0; font-size: 13px; }
.audio-status:not(:empty) { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 25; width: max-content; max-width: calc(100vw - 36px); background: #1e2b28; color: #e8f0ee; border-radius: 14px; padding: 12px 16px; box-shadow: 0 4px 24px #0e242033; pointer-events: none; }
@media (max-width: 767px) { .audio-status:not(:empty) { bottom: 100px; } }
.story-reader .audio-status:not(:empty) { bottom: 148px; }

/* ---------- Reader ---------- */
.story-reader { --story-font: 22px; }
.story-tabbar { position: sticky; top: var(--story-topbar, 72px); z-index: 9; margin-top: calc(-1 * var(--sn-main-top)); padding: 4px 0 12px; background: var(--sn-appbar); box-shadow: 0 0 0 100vmax var(--sn-appbar); clip-path: inset(0 -100vmax); }
.story-seg { --tabs: 4; --tab-index: 0; position: relative; display: grid; grid-template-columns: repeat(var(--tabs), minmax(0, 1fr)); height: 46px; max-width: 560px; margin: 0 auto; padding: 4px; border-radius: 14px; background: #ffffff24; }
.story-seg-pill { position: absolute; top: 4px; left: 4px; bottom: 4px; width: calc((100% - 8px) / var(--tabs)); border-radius: 10px; background: #fff; box-shadow: 0 1px 3px #0e242033; transform: translateX(calc(var(--tab-index) * 100%)); transition: transform .35s cubic-bezier(.3, 1.35, .5, 1); }
.story-seg button { position: relative; z-index: 1; min-width: 0; border: 0; border-radius: 10px; background: transparent; color: var(--sn-on-hero-muted); font: 600 12px/16px system-ui, sans-serif; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story-seg[style*="--tabs:3"] button { font-size: 14px; }
.story-seg button[aria-selected="true"] { color: var(--sn-hero); }
.story-seg button:hover:not([aria-selected="true"]) { color: #fff; }
.story-seg button:focus-visible { outline: 3px solid #ffd27a; outline-offset: 0; }

.story-reader-layout { display: grid; grid-template-columns: minmax(0, 720px); justify-content: center; gap: 32px; align-items: start; }
.story-reader-main { display: flex; flex-direction: column; min-width: 0; min-height: calc(100dvh - var(--story-topbar, 72px) - 54px - var(--sn-main-top)); }
.story-reader-main > * { flex-shrink: 0; }
.story-reader-main > .audio-local { margin-bottom: 16px; }
/* Phones: the teal tab strip leads the screen, as in the app. */
.story-reader-main > .story-tabbar { order: -1; }
.story-reader-layout > .story-dock { grid-column: 1 / -1; }
.story-reader .audio-tools { display: none; }
.audio-queue-picker { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; font-size: 13px; color: var(--sn-muted); }
.audio-queue-picker select { flex: 1; min-width: 0; min-height: 44px; border: 1px solid var(--sn-line); border-radius: 12px; background: #fff; padding: 8px 12px; font-size: 15px; color: var(--sn-ink); }

/* Waveform header with the round play button (RhythmWaveform + reveal button). */
.story-wave { position: relative; height: 66px; margin: 3px 0 0; color: var(--sn-ink); }
@media (max-width: 767px) { .story-wave { margin-inline: calc(-1 * var(--sn-gutter)); } }
.story-wave-line { position: absolute; inset: 3px 0 auto; width: 100%; height: 60px; }
.story-wave-play { position: absolute; left: 50%; top: 8px; display: grid; place-items: center; width: 50px; height: 50px; padding: 0; transform: translateX(-50%); border: 0; border-radius: 50%; background: var(--sn-appbar); color: #fff; }
.story-wave-play:hover { background: var(--sn-hero); }
.story-wave-play svg { width: 26px; height: 26px; margin-left: 3px; }
.is-buffering .story-wave-play::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--sn-appbar); animation: story-spin .9s linear infinite; }

.story-titlebar { display: flex; align-items: center; gap: 8px; padding: 12px 0 8px; }
.story-title { flex: 1; min-width: 0; margin: 0; font: 600 20px/26px Mali, sans-serif; color: var(--sn-ink); overflow-wrap: anywhere; }
.story-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; margin-right: -6px; }
.story-action { display: grid; place-items: center; width: 40px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--sn-muted); }
.story-action svg { width: 22px; height: 22px; }
.story-action:hover { background: var(--sn-soft); color: var(--sn-hero); }
.story-action[aria-pressed="true"] { color: var(--sn-star); }
.story-action[data-audio="like"][aria-pressed="true"] svg, .story-action[data-reader="like"][aria-pressed="true"] svg { fill: currentColor; }
.story-action[data-audio="download"][aria-pressed="true"] { color: var(--sn-appbar); }
.story-action[href^="mailto"] { color: var(--sn-muted); }

#audio-tabpanel, #reading-panel { font-size: var(--story-font); }
#audio-tabpanel:focus-visible, #reading-panel:focus-visible { outline-offset: 2px; }
.audio-reading { padding: 0 0 8px; font-family: Mali, sans-serif; color: var(--sn-ink); }
.audio-reading mark { color: inherit; border-radius: 3px; }
.audio-cover { margin: 4px 0 14px; }
.audio-cover img { display: block; width: 100%; height: 160px; object-fit: cover; border-radius: 16px; }
.audio-cover figcaption { text-align: right; padding: 4px 2px 0; font: italic 11px/14px system-ui, sans-serif; color: var(--sn-muted); }
.audio-cover a { text-decoration: underline; text-underline-offset: 3px; }
.audio-cover[hidden] { display: none; }

/* Paragraphs: plain (audio English) or cards (Vietnamese, text stories). */
.story-para { display: grid; grid-template-columns: minmax(0, 1fr) 40px; column-gap: 6px; align-items: start; overflow-wrap: anywhere; }
.story-para > p { grid-column: 1; margin: 0; }
.story-para-translation { grid-column: 1; margin-top: 6px; font-size: .9em; line-height: 1.3; color: var(--sn-muted); animation: story-reveal .22s ease-out; }
@keyframes story-reveal { from { opacity: 0; transform: translateY(-4px); } }
.story-para-tools { grid-column: 2; grid-row: 1 / span 2; display: grid; gap: 2px; justify-items: center; }
.story-speak, .story-reveal { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; }
.story-speak { background: var(--sn-soft); color: var(--sn-hero); }
.story-speak svg { width: 18px; height: 18px; }
.story-speak:hover { background: var(--sn-container); }
.story-reveal { background: transparent; color: var(--sn-muted); font: 700 12px/1 system-ui, sans-serif; }
.story-reveal:hover { background: var(--sn-soft); }
.story-reveal[aria-expanded="true"] { background: var(--sn-container); color: var(--sn-on-container); }
.story-plain .story-para { line-height: 1.7; margin-bottom: 1.1em; }
.story-plain .story-para-tools { margin-top: .2em; }
.story-plain .story-speak { background: transparent; color: var(--sn-outline); }
.story-plain .story-speak:hover { background: var(--sn-soft); color: var(--sn-hero); }
.story-plain .story-para.speaking > p { background: #e3f3ef; border-radius: 6px; box-shadow: 0 0 0 4px #e3f3ef; }
.story-plain .story-para.speaking .story-speak { background: var(--sn-appbar); color: #fff; }
.story-cards .story-para { margin: 0 0 10px; padding: 12px 10px 12px 14px; border: 2px solid transparent; border-radius: 18px; background: var(--sn-surface); line-height: 1.6; transition: border-color .22s, box-shadow .22s; }
.audio-reading.story-cards[lang="vi"] .story-para { line-height: 1.55; }
.story-cards .story-para.speaking { border-color: var(--sn-appbar); box-shadow: 0 6px 16px #0e24201f; }
.story-cards .story-para.speaking .story-speak { background: var(--sn-appbar); color: #fff; }
.story-reader[data-kind="audio"] .story-cards .story-para { border: 1px solid var(--sn-line); }
.story-reader[data-kind="audio"] .story-cards .story-para.speaking { border-color: var(--sn-appbar); }

/* TipCard */
.story-tip { margin: 0 -8px 14px; padding: 14px 4px 4px 14px; border-radius: 16px; background: var(--sn-amber); color: var(--sn-on-amber); font: 300 14px/20px system-ui, sans-serif; }
.audio-reading .story-tip { font-family: system-ui, sans-serif; }
.story-tip > p { display: flex; gap: 8px; margin: 0; padding-right: 10px; }
.story-tip > p svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--sn-star); }
.story-tip-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.story-tip-actions label { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 0; font-size: 12px; font-weight: 400; color: var(--sn-on-amber); cursor: pointer; }
.story-tip-actions input { width: 18px; height: 18px; margin: 0 2px 0 3px; accent-color: var(--sn-appbar); }
.story-tip-actions button { min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--sn-hero); font: 700 14px/20px system-ui, sans-serif; }
.story-tip-actions button:hover { background: #ffe3bd; }
.story-cards > .story-tip:last-child { margin-top: 14px; }

/* Vocabulary tab */
.audio-vocabs { display: grid; gap: 10px; padding: 12px 0 8px; font-family: system-ui, sans-serif; font-size: 16px; }
.audio-vocabs .story-tip { margin: 0; }
.audio-vocab-heading { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.audio-vocab-heading h2 { flex: 1; margin: 0; font: 600 18px/24px Mali, sans-serif; color: var(--sn-ink); }
.audio-vocab-heading span { font-size: 13px; color: var(--sn-muted); }
.audio-vocab-heading .story-icon-btn { width: 40px; height: 40px; border: 0; background: transparent; }
.audio-vocab-card { display: grid; gap: 6px; padding: 12px 4px 10px 14px; border: 1px solid var(--sn-line); border-radius: 18px; background: var(--sn-surface); }
.audio-vocab-main { display: grid; grid-template-columns: minmax(0, 1fr) 48px; align-items: start; }
.audio-vocab-main h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0; font: 600 18px/24px Mali, sans-serif; color: var(--sn-ink); }
.vocab-type { padding: 1px 7px; border-radius: 8px; background: var(--sn-container); color: var(--sn-on-container); font: 700 11px/14px system-ui, sans-serif; }
.vocab-phon { font: 300 13px/18px system-ui, sans-serif; color: var(--sn-muted); }
.audio-vocab-main p { margin: 2px 0 0; font: 300 16px/22px Mali, sans-serif; color: var(--sn-ink); }
.story-bookmark { display: grid; place-items: center; width: 48px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--sn-outline); }
.story-bookmark svg { width: 24px; height: 24px; }
.story-bookmark:hover { background: var(--sn-soft); }
.story-bookmark[aria-pressed="true"] { color: var(--sn-pro); }
.story-bookmark[aria-pressed="true"] svg { fill: currentColor; }
.audio-vocab-example { margin: 0 10px 0 0; font: italic 14px/20px system-ui, sans-serif; color: var(--sn-muted); }
.audio-vocab-actions { display: flex; align-items: center; gap: 6px; }
.story-voice { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 10px; border: 1px solid var(--sn-line); border-radius: 999px; background: var(--sn-surface); color: var(--sn-hero); font: 700 12px/16px system-ui, sans-serif; }
.story-voice svg { width: 18px; height: 18px; }
.story-voice:hover { background: var(--sn-container); }
.story-more { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; margin-left: auto; padding: 0 6px 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--sn-hero); font: 700 14px/20px system-ui, sans-serif; }
.story-more svg { width: 18px; height: 18px; }
.story-more:hover { background: var(--sn-soft); }
.story-idioms { display: grid; gap: 8px; padding: 12px 14px; border-radius: 18px; background: var(--sn-amber); color: var(--sn-on-amber); }
.story-idioms h3 { margin: 0; font: 700 14px/20px system-ui, sans-serif; color: var(--sn-amber-strong); }
.story-idioms strong { font: 600 16px/22px Mali, sans-serif; }
.story-idioms p { margin: 0; font-size: 14px; line-height: 20px; }

/* Game tab (StoryGameTab + MascotCard) */
.story-game-hub { display: grid; gap: 14px; padding: 16px 0 8px; font-family: system-ui, sans-serif; font-size: 16px; }
.story-mascot-card { display: flex; align-items: center; gap: 4px; min-height: 84px; padding: 12px 12px 12px 4px; border-radius: 20px; background: var(--sn-amber); color: var(--sn-on-amber); }
.story-game-mam { width: 76px; height: auto; flex-shrink: 0; margin: -10px 0 -6px; }
.story-mascot-card h2 { margin: 0; font: 600 18px/24px Mali, sans-serif; color: var(--sn-on-amber); }
.story-mascot-card p { margin: 0; font-size: 14px; line-height: 20px; }
.story-game-card { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--sn-line); border-radius: 22px; background: var(--sn-surface); }
.story-game-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 0; border: 0; background: transparent; text-align: left; color: var(--sn-ink); border-radius: 14px; }
.story-game-head > span:last-child { display: grid; gap: 2px; }
.story-game-head strong { font: 600 18px/24px Mali, sans-serif; }
.story-game-head small { font-size: 13px; line-height: 18px; color: var(--sn-muted); }
.story-game-head:hover strong { color: var(--sn-hero); }
.story-game-tile { display: grid; place-items: center; width: 48px; height: 48px; flex-shrink: 0; border-radius: 16px; background: var(--sn-container); color: var(--sn-on-container); }
.story-game-tile.amber { background: var(--sn-amber); color: var(--sn-on-amber); }
.story-game-steps { display: flex; flex-wrap: wrap; gap: 8px; }
.story-step { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--sn-soft); color: var(--sn-muted); font: 600 12px/16px system-ui, sans-serif; }
button.story-step { min-height: 36px; }
button.story-step:hover { background: var(--sn-container); color: var(--sn-on-container); }
.story-step b { color: var(--sn-hero); font-weight: 700; }
.story-game-note { margin: 0; text-align: center; font-size: 13px; line-height: 18px; color: var(--sn-muted); }
.story-game-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
/* StoryGameTab's PRO tag (AppTokens pro / onPro) */
.story-game-pro { padding: 2px 8px; border-radius: 10px; background: var(--sn-pro); color: var(--sn-on-pro); font: 700 11px/16px system-ui, sans-serif; letter-spacing: .4px; }
.story-game-head:hover .story-game-pro { color: var(--sn-on-pro); }

/* End of story (StoryEndCard.kt): Mầm rises above the card, games side by side, next story pill */
.story-end { position: relative; margin: 12px 0 20px; padding-top: 48px; font-family: system-ui, sans-serif; font-size: 16px; line-height: 22px; }
.story-end-mam { position: absolute; top: 0; left: 50%; z-index: 1; width: 118px; transform: translateX(-50%); }
.story-end-card { display: grid; gap: 14px; padding: 96px 18px 18px; border: 1px solid var(--sn-line); border-radius: 24px; background: var(--sn-surface); box-shadow: 0 1px 3px #0e242014; text-align: center; }
.story-end-card h2 { margin: 0; font: 700 26px/32px Mali, sans-serif; color: var(--sn-ink); }
.story-end-card > p { margin: -8px 0 0; color: var(--sn-muted); }
.story-end-games { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.story-end-game { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 52px; padding: 8px 10px; border: 0; border-radius: 16px; background: var(--sn-container); color: var(--sn-on-container); font: 600 14px/18px system-ui, sans-serif; cursor: pointer; }
.story-end-game svg { width: 20px; height: 20px; flex-shrink: 0; }
.story-end-game:hover { box-shadow: 0 2px 8px #0e24201f; }
.story-end-next { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px; padding: 8px 24px; border-radius: 999px; background: var(--sn-appbar); color: #fff; font: 600 14px/20px system-ui, sans-serif; text-decoration: none; }
.story-end-next > span { overflow-wrap: anywhere; }
.story-end-next svg { width: 20px; height: 20px; flex-shrink: 0; }
.story-end-next.is-locked svg:first-child { width: 16px; height: 16px; }
.story-end-next:hover { background: var(--sn-hero); }
.story-end-next:focus-visible, .story-end-game:focus-visible { outline-offset: 3px; }
@media (max-width: 420px) { .story-end-games { grid-template-columns: 1fr 1fr; } .story-end-game { font-size: 13px; } .story-end-card { padding-inline: 14px; } }
@media (min-width: 1024px) { .story-end-card { padding-inline: 32px; } }

/* Bottom dock: audio player bar + ReaderToolsRow */
.story-dock { position: sticky; bottom: 0; z-index: 8; margin-top: 16px; background: var(--sn-surface); box-shadow: 0 -1px 0 var(--sn-line), 0 -6px 18px #0e242014; }
@media (max-width: 767px) { .story-dock { margin-inline: calc(-1 * var(--sn-gutter)); padding-bottom: env(safe-area-inset-bottom); } }
.story-toolsrow { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: 54px; border-top: 3px solid var(--sn-bg); }
.story-toolsrow button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: transparent; color: var(--sn-ink); font: 600 11px/14px system-ui, sans-serif; }
.story-toolsrow button svg { width: 20px; height: 20px; color: var(--sn-muted); }
.story-toolsrow button:hover { background: var(--sn-soft); }
.story-toolsrow button:focus-visible { outline-offset: -3px; }

.audio-player { background: var(--sn-appbar); color: #fff; padding: 0 8px; animation: story-player-in .3s ease-out; }
@keyframes story-player-in { from { clip-path: circle(0 at 50% 50%); } to { clip-path: circle(100vmax at 50% 50%); } }
.audio-player[hidden] { display: none; }
.audio-player #audio-play-status { margin: 0; padding: 6px 8px 0; font-size: 12px; color: #e8f6f3; text-align: center; }
.audio-player #audio-play-status:empty { display: none; }
.audio-player-row { display: flex; align-items: center; gap: 4px; min-height: 70px; }
.story-pbtn { display: grid; place-items: center; width: 40px; height: 44px; flex-shrink: 0; padding: 0; border: 0; border-radius: 12px; background: transparent; color: #fff; }
.story-pbtn svg { width: 24px; height: 24px; }
.story-pbtn:hover:not(:disabled) { background: #ffffff1f; }
.story-pbtn:disabled { opacity: .45; cursor: default; }
.story-pbtn[aria-pressed="true"] { background: #ffffff33; }
.story-pbtn[data-audio="repeat"] svg { width: 20px; height: 20px; }
.story-skip { font: 700 13px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.audio-transport { display: flex; align-items: center; gap: 2px; }
.audio-player .audio-play { display: grid; place-items: center; width: 40px; height: 40px; margin: 0 2px; padding: 0; flex-shrink: 0; border: 0; border-radius: 50%; background: #fff; color: var(--sn-appbar); }
.audio-player .audio-play svg { width: 20px; height: 20px; }
.audio-player .audio-play:disabled { opacity: .6; cursor: wait; }
.audio-player :focus-visible { outline-color: #ffd27a; outline-offset: 1px; }
.audio-seek { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; font: 14px/20px system-ui, sans-serif; font-variant-numeric: tabular-nums; color: #fff; }
.audio-seek input { flex: 1; min-width: 0; }
.audio-player input[type="range"] { appearance: none; -webkit-appearance: none; height: 44px; margin: 0; background: transparent; cursor: pointer; }
.audio-player input[type="range"]::-webkit-slider-runnable-track { height: 2px; border-radius: 2px; background: linear-gradient(to right, #fff var(--range-fill, 0%), #ffffff66 var(--range-fill, 0%)); }
.audio-player input[type="range"]::-moz-range-track { height: 2px; border-radius: 2px; background: linear-gradient(to right, #fff var(--range-fill, 0%), #ffffff66 var(--range-fill, 0%)); }
.audio-player input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px; border-radius: 50%; background: #fff; }
.audio-player input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; }
.audio-player input[type="range"]:disabled { opacity: .5; cursor: default; }
#audio-position, #audio-duration { font-size: 12px; color: #e8f6f3; }
.audio-player-options { display: flex; align-items: center; gap: 4px; }
.audio-player-options > label { position: relative; display: flex; align-items: center; gap: 6px; color: #fff; }
.audio-player-options > label > svg { width: 24px; height: 24px; flex-shrink: 0; }
.audio-speed > svg { position: absolute; left: 6px; pointer-events: none; }
#audio-speed { appearance: none; -webkit-appearance: none; width: 70px; min-height: 44px; padding: 0 6px 0 34px; border: 0; border-radius: 12px; background: transparent; color: #fff; font: 600 13px/1 system-ui, sans-serif; cursor: pointer; }
#audio-speed:hover { background: #ffffff1f; }
#audio-speed option { color: var(--sn-ink); }
#audio-volume { width: 72px; --range-fill: 100%; }
/* Phone: the mobile bar (close · play · repeat · seek · time · speed). Extra web controls on wider screens or in Nghe liên tục. */
#audio-remaining { display: none; }
@media (max-width: 699px) {
  .audio-player:not(.is-listening) .story-extra, .audio-player-options > .audio-volume, #audio-position, #audio-duration { display: none; }
  #audio-remaining { display: inline; }
  .audio-player.is-listening .story-skip { display: none; }
}

/* ---------- Tools panel (desktop column / sheet) ---------- */
.audio-tools { gap: 12px; align-content: start; font-family: system-ui, sans-serif; font-size: 14px; }
.audio-tools label { display: grid; gap: 6px; margin: 12px 0; font-size: 13px; color: var(--sn-muted); }
.audio-tools input:not([type="range"]):not([type="checkbox"]), .audio-tools select { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--sn-line); border-radius: 12px; background: #fff; color: var(--sn-ink); font: inherit; font-size: 16px; }
.audio-tools [type="range"] { width: 100%; min-height: 44px; accent-color: var(--sn-appbar); }
.audio-tools .button { min-height: 44px; font-size: 13px; padding: 8px 12px; }
.audio-tools form { display: grid; gap: 8px; margin-top: 12px; }
.audio-tools form label { margin: 0; }
.audio-tools #dictionary-feedback { margin: 0; font-size: 12px; }
.audio-tools p { overflow-wrap: anywhere; }
.audio-tool-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.audio-panel-title h2 { margin: 0; font: 600 18px/24px Mali, sans-serif; }
.audio-panel-title p { margin: 2px 0 0; font-size: 12px; color: var(--sn-muted); }
.audio-tool-section { border: 1px solid var(--sn-line); border-radius: 16px; background: #fff; overflow: hidden; }
.audio-tool-section > summary { display: flex; align-items: center; min-height: 48px; padding: 0 16px; font: 600 15px Mali, sans-serif; cursor: pointer; }
.audio-tool-section-body { padding: 0 16px 16px; }
.audio-saved-mark { display: flex; gap: 6px; border-top: 1px solid var(--sn-line); padding: 8px 0; }
.audio-saved-mark button { border: 0; background: transparent; padding: 4px; text-align: left; min-height: 44px; }
.audio-saved-mark button:first-child { display: flex; align-items: start; gap: 8px; flex: 1; min-width: 0; font-size: 13px; }
.audio-saved-mark button:last-child { width: 44px; flex-shrink: 0; font-size: 22px; }
.audio-saved-mark small { display: block; font-size: 11px; color: var(--sn-muted); margin-top: 4px; }
.audio-mark-dot { width: 12px; height: 12px; flex-shrink: 0; border-radius: 50%; margin-top: 5px; }
.audio-mobile-icon { display: inline-block; width: 24px; height: 24px; object-fit: contain; flex-shrink: 0; }

/* Dialogs: bottom sheets on phones. */
.audio-color-dialog, .audio-tools-dialog { width: min(520px, calc(100vw - 28px)); max-height: 85dvh; padding: 20px; border: 0; border-radius: 24px; color: var(--sn-ink); background: var(--sn-bg); box-shadow: 0 12px 40px #0e242040; }
.audio-color-dialog::backdrop, .audio-tools-dialog::backdrop { background: #0812147a; }
.audio-tools-dialog .audio-tools { display: grid; }
.audio-tools-dialog .audio-panel-title { display: none; }
.audio-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.audio-dialog-head h2 { margin: 0; font: 600 20px/26px Mali, sans-serif; }
.audio-dialog-head button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: #fff; font-size: 24px; color: var(--sn-ink); }
.audio-color-dialog label { display: grid; gap: 8px; margin: 16px 0; font-size: 14px; }
.audio-color-dialog input { width: 100%; min-height: 44px; accent-color: var(--sn-appbar); }
.audio-color-dialog blockquote { max-height: 170px; overflow: auto; margin: 16px 0; padding: 16px; border-radius: 12px; background: #fff; white-space: pre-wrap; overflow-wrap: anywhere; }
.audio-color-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.audio-color-swatches button { width: 44px; height: 44px; background: var(--swatch); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px var(--sn-line); }
.audio-dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 18px; }
@media (max-width: 700px) {
  .audio-tools-dialog, .audio-color-dialog { margin: auto 0 0; width: 100%; max-width: none; border-radius: 24px 24px 0 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* Text-selection menu (Màu chữ · Đổ nền · Dịch · Sao chép) */
.audio-selection-bar { position: fixed; z-index: 30; left: 50%; bottom: 140px; transform: translateX(-50%); display: flex; gap: 2px; max-width: calc(100vw - 16px); padding: 6px; border-radius: 12px; background: var(--sn-appbar); color: #fff; box-shadow: 0 6px 24px #0e242047; }
.audio-selection-bar.is-anchored { bottom: auto; transform: none; }
.audio-selection-bar[hidden] { display: none; }
.audio-selection-bar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 52px; min-height: 52px; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; color: #fff; font: 600 11px/14px system-ui, sans-serif; }
.audio-selection-bar button:hover { background: #ffffff25; }
.audio-selection-bar .audio-mobile-icon { width: 22px; height: 22px; filter: brightness(0) invert(1); }
.audio-selection-bar [data-selection="dismiss"] { min-width: 36px; font-size: 22px; }

/* ---------- Community (Thảo luận) ---------- */
.audio-community { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--sn-line); font-family: system-ui, sans-serif; }
.audio-community > .audio-tool-row .button, .reading-discussion-toggle { min-height: 40px; padding: 6px 16px; border-radius: 999px; font-size: 14px; }
.audio-community [aria-pressed="true"] { background: var(--sn-container); color: var(--sn-on-container); border-color: #b9ddd5; }
#audio-community-body, .reading-discussion { margin-top: 18px; }
.audio-discussion-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.audio-discussion-heading > span { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: 14px; color: var(--sn-hero); background: var(--sn-container); }
.audio-discussion-heading h2 { margin: 0 0 2px; font: 600 20px/26px Mali, sans-serif; }
.audio-discussion-heading small { font: 600 13px system-ui; background: var(--sn-container); padding: 2px 8px; border-radius: 20px; vertical-align: middle; }
.audio-discussion-heading p, .audio-comment-login p { color: var(--sn-muted); font-size: 13px; }
#audio-community-form { display: grid; gap: 8px; padding: 16px; border: 1px solid var(--sn-line); border-radius: 18px; background: #fff; }
#audio-community-form > label { color: var(--sn-ink); font-weight: 600; font-size: 15px; }
#audio-community-form textarea { width: 100%; min-height: 96px; max-height: 400px; padding: 12px; border: 1px solid var(--sn-line); border-radius: 12px; background: #fff; font: inherit; font-size: 16px; line-height: 1.6; resize: vertical; }
.audio-compose-options { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.audio-compose-options > span { font-size: 12px; color: var(--sn-muted); white-space: nowrap; }
#audio-community-form .audio-anonymous { display: flex; gap: 10px; align-items: center; min-height: 44px; font-size: 12px; margin: 0; }
#audio-community-form .audio-anonymous input { width: 20px; height: 20px; accent-color: var(--sn-appbar); flex-shrink: 0; }
.audio-compose-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-top: 1px solid var(--sn-line); padding-top: 12px; }
.audio-compose-footer p { color: var(--sn-muted); font-size: 12px; line-height: 1.6; max-width: 420px; }
.audio-compose-footer .button { flex-shrink: 0; border-radius: 999px; }
.audio-comment-login { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 16px; border-radius: 18px; background: var(--sn-container); color: var(--sn-on-container); }
.audio-comment-login .button { flex-shrink: 0; border-radius: 999px; }
.audio-comment-sort { color: var(--sn-muted); font-size: 12px; margin: 18px 0 4px; }
.audio-comment-card { display: flex; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--sn-line); }
.audio-comment-avatar { display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; background: var(--sn-container); color: var(--sn-hero); font-weight: 600; }
.audio-comment-content { flex: 1; min-width: 0; }
.audio-comment-content header { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 14px; }
.audio-comment-content time { color: var(--sn-muted); font-size: 11px; }
.audio-comment-content > p { margin: 6px 0 8px; font-size: 16px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.audio-comment-reactions { display: flex; flex-wrap: wrap; gap: 8px; }
.audio-comment-reactions button { min-height: 36px; padding: 4px 12px; border: 1px solid var(--sn-line); border-radius: 999px; background: transparent; color: var(--sn-muted); font-size: 12px; }
.audio-comment-reactions button:hover { border-color: var(--sn-appbar); color: var(--sn-hero); }
.audio-comment-reactions span { margin-left: 6px; font-weight: 600; }
.audio-comment-empty { text-align: center; padding: 24px 20px; border: 1px dashed var(--sn-line); border-radius: 18px; margin-top: 16px; }
.audio-comment-empty svg { width: 30px; height: 30px; color: var(--sn-hero); margin: 0 auto 10px; }
.audio-comment-empty h3 { font-size: 17px; }
.audio-comment-empty p { font-size: 14px; color: var(--sn-muted); margin: 8px 0; }
#audio-community-status:not(:empty) { color: var(--sn-hero); padding: 10px 0; font-size: 14px; }
@media (max-width: 700px) {
  .audio-compose-footer, .audio-comment-login { align-items: stretch; flex-direction: column; gap: 12px; }
}

/* ---------- Exercises (order, fill, flashcards) ---------- */
.audio-game { margin: 16px 0 8px; padding: 18px 16px; border: 1px solid var(--sn-line); border-radius: 22px; background: #fff; font-family: system-ui, sans-serif; font-size: 16px; overflow-anchor: none; }
.audio-game .eyebrow { margin: 0 0 4px; color: var(--sn-hero); }
.audio-game h2 { margin: 0 0 8px; font: 600 20px/26px Mali, sans-serif; }
.audio-game > p { margin: 0 0 12px; }
.audio-game label { display: grid; gap: 8px; margin: 16px 0; font: 300 16px/1.6 Mali, sans-serif; color: var(--sn-ink); }
.audio-game input:not([type="checkbox"]) { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--sn-line); border-radius: 12px; font: 16px system-ui, sans-serif; }
.audio-game input[aria-invalid="true"] { border: 2px solid #ba1a1a; }
.audio-game input[readonly] { background: var(--sn-container); }
.audio-game .audio-tool-row, .reading-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.audio-game .button, .reading-actions .button { min-height: 44px; padding: 8px 16px; border-radius: 999px; font-size: 14px; }
.audio-answer-feedback { font: 13px system-ui, sans-serif; color: var(--sn-muted); }
.audio-game progress { width: 100%; accent-color: var(--sn-appbar); }
.audio-game-success { margin-top: 16px; padding: 16px; border-radius: 16px; background: var(--sn-container); color: var(--sn-on-container); }
#audio-drag-tip, #reading-drag-tip { font-size: 13px; color: var(--sn-muted); line-height: 1.6; }
.audio-order-row { position: relative; display: grid; grid-template-columns: 44px 20px minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 10px; padding: 10px; border: 1px solid var(--sn-line); border-radius: 16px; background: var(--sn-bg); font: 300 16px/1.6 Mali, sans-serif; }
.audio-order-row p { margin: 0; overflow-wrap: anywhere; }
.audio-order-number { color: var(--sn-hero); font: 700 14px system-ui, sans-serif; }
.audio-game .audio-order-row { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: grab; }
.audio-drag-preview { position: fixed; z-index: 60; pointer-events: none; background: var(--sn-container); border: 2px solid var(--sn-appbar); box-shadow: 0 12px 30px #0e242040; margin: 0; }
.audio-drag-preview .audio-order-arrows { visibility: hidden; }
.audio-game .audio-order-row.is-dragging { opacity: .3; }
.audio-order-placeholder { display: grid; place-items: center; margin-bottom: 10px; border: 2px dashed var(--sn-appbar); border-radius: 16px; background: #ddf0ec80; color: var(--sn-hero); font-size: 13px; box-sizing: border-box; }
.audio-order-arrows { display: flex; gap: 4px; }
.audio-order-arrows .button { min-width: 44px; padding: 8px; border-radius: 12px; }
.audio-drag-handle { display: grid; place-items: center; width: 44px; height: 48px; border: 0; border-radius: 10px; color: var(--sn-muted); background: transparent; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.audio-drag-handle:hover { background: var(--sn-container); color: var(--sn-hero); }
.audio-order-row.is-dragging { border-color: var(--sn-appbar); background: var(--sn-container); }
.is-dragging .audio-drag-handle { cursor: grabbing; }
@media (max-width: 700px) {
  .audio-order-row { grid-template-columns: 44px 18px minmax(0, 1fr); }
  .audio-order-arrows { grid-column: 3; justify-content: flex-end; }
}
.audio-flash-game { max-width: 640px; margin-inline: auto; overflow: hidden; }
.audio-flash-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audio-flash-heading h2 { margin: 0; }
.audio-flash-heading .button { width: 44px; padding: 10px; }
.audio-flash-progress { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--sn-muted); margin-top: 16px; }
.audio-flash-game progress { height: 6px; display: block; margin: 10px 0 24px; }
.audio-flash-deck { position: relative; margin: 0 8px 24px; isolation: isolate; }
.audio-flash-deck::before, .audio-flash-deck::after { content: ''; position: absolute; inset: 6px 6px -6px; z-index: -1; background: #f5e6cf; border: 1px solid #e7d3b4; border-radius: 22px; transform: rotate(-2deg); }
.audio-flash-deck::after { inset: 12px 12px -12px; z-index: -2; transform: rotate(2deg); background: #fbf0df; }
.audio-flash { position: relative; display: block; width: 100%; height: 300px; padding: 0; border: 0; background: transparent; perspective: 1100px; border-radius: 22px; touch-action: pan-y; user-select: none; -webkit-user-select: none; color: var(--sn-ink); }
.audio-flash-inner { display: block; position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .32s ease; }
.audio-flash.is-flipped .audio-flash-inner { transform: rotateY(180deg); }
.audio-flash-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 30px 24px 52px; border-radius: 22px; border: 1px solid #ecd9b8; background: var(--sn-amber); box-shadow: 0 8px 20px #0e242010; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: auto; touch-action: pan-y; }
.audio-flash-back { transform: rotateY(180deg); background: var(--sn-container); border-color: #bcded0; }
.audio-flash-face small { position: absolute; top: 22px; font: 600 11px/1.4 system-ui; letter-spacing: 2px; color: var(--sn-muted); }
.audio-flash-face strong { font: 600 clamp(23px, 3vw, 34px)/1.5 Mali, sans-serif; overflow-wrap: anywhere; max-width: 100%; }
.audio-flash-phonetic { color: var(--sn-muted); font: 16px/1.5 system-ui; }
.audio-flash-turn { display: flex; gap: 8px; align-items: center; position: absolute; bottom: 20px; font: 12px/1.5 system-ui; color: var(--sn-muted); }
.audio-flash-turn svg { width: 18px; height: 18px; }
#audio-flash-hint { text-align: center; font: 12px/1.6 system-ui; color: var(--sn-muted); margin: 20px 0 16px; }
#audio-flash-hint::after { content: ' Vuốt trái / phải để đổi từ.'; }
.audio-flash-navigation { display: flex; justify-content: center; align-items: center; gap: 18px; }
.audio-flash-navigation .button { min-width: 44px; padding: 10px; }
.audio-flash-ratings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.audio-flash-ratings .button { padding: 12px 8px; }
.audio-flash-ratings [data-audio="flash-yes"] { background: var(--sn-appbar); color: #fff; border-color: var(--sn-appbar); }
.audio-flash-game > .audio-tool-row { justify-content: center; margin-top: 24px; }
.audio-flash-game .audio-game-success .button { display: block; margin: 12px auto 0; }
@media (prefers-reduced-motion: reduce) {
  .audio-flash-inner, .story-seg-pill, .story-cards .story-para { transition: none; }
  .audio-player, .story-para-translation { animation: none; }
}

/* Journal's dictionary form styles assume journal tokens; restate them for the reader tools. */
.audio-tools #dictionary-form { display: grid; gap: 8px; }
.audio-tools #dictionary-form input { width: 100%; min-height: 44px; padding: 8px 14px; border: 1px solid var(--sn-line); border-radius: 12px; background: #fff; color: var(--sn-ink); font: 16px system-ui, sans-serif; }
.audio-tools #dictionary-form .button { justify-self: start; min-height: 44px; padding: 8px 20px; border-radius: 999px; }
.story-filter select { height: 44px; }
.story-toolbar { align-items: stretch; }
.story-row > a:focus-visible, .story-star:focus-visible { outline-offset: -3px; border-radius: 12px; }
.story-chips .story-chip:focus-visible { outline-offset: -3px; }
.story-toolbar label { margin: 0; }
.story-search input { height: 44px; }

/* ======================================================================
   Web layouts (>= 768px tablet, >= 1024px desktop).
   Same palette, Mali type, cards and tiles as the app; web positions:
   page head + continue card, underline tabs beside the toolbar, a card
   grid, article readers with a sticky tools column and a docked player.
   ====================================================================== */
.story-discuss-entry { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 4px 12px; align-items: center; padding: 14px 16px; border: 1px solid var(--sn-line); border-radius: 16px; background: #fff; font-family: system-ui, sans-serif; }
.story-discuss-tile { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--sn-container); color: var(--sn-hero); }
.story-discuss-tile svg { width: 22px; height: 22px; }
.story-discuss-entry strong { font: 600 15px/20px Mali, sans-serif; color: var(--sn-ink); }
.story-discuss-entry p { margin: 2px 0 0; font-size: 12px; line-height: 16px; color: var(--sn-muted); }
.audio-tools .story-discuss-entry .button { grid-column: 1 / -1; justify-self: start; min-height: 40px; padding: 6px 16px; border-radius: 999px; }

@media (min-width: 768px) {
  /* ---------- Library pages ---------- */
  .story-list { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "head head" "tabs tools" "count count" "grid grid" "pages pages" "local local"; column-gap: 0; max-width: 1200px; margin: 0; }
  .story-list > * { min-width: 0; }
  .story-list-head, .story-chiprow { display: contents; }
  .story-list:has(.has-continue) { grid-template-areas: "head cont" "tabs tools" "count count" "grid grid" "pages pages" "local local"; column-gap: 0; }
  .story-list > .story-loading, .story-list > .story-empty, .story-list > .audio-status { grid-column: 1 / -1; }

  .story-listen-card, .story-intro { grid-area: head; }
  .story-listen-card { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 18px; align-content: center; min-height: 148px; margin: 0; padding: 24px 200px 24px 28px; border-radius: 24px; background: linear-gradient(120deg, var(--sn-hero) 0%, var(--sn-appbar) 100%); box-shadow: 0 10px 28px #00695c2e; overflow: visible; transition: transform .2s ease, box-shadow .2s ease; }
  .story-listen-card:hover { background: linear-gradient(120deg, #005a4f 0%, var(--sn-hero) 100%); transform: translateY(-2px); box-shadow: 0 14px 32px #00695c3d; }
  .story-listen-play { grid-row: 1 / span 2; align-self: center; width: 56px; height: 56px; }
  .story-listen-play svg { width: 28px; height: 28px; margin-left: 3px; }
  .story-listen-text strong { font-size: 22px; line-height: 28px; }
  .story-listen-text small { font-size: 14px; line-height: 20px; }
  .story-listen-cta { grid-column: 2; display: inline-flex; align-items: center; gap: 8px; justify-self: start; margin-top: 14px; padding: 9px 18px 9px 14px; border-radius: 999px; background: #fff; color: var(--sn-hero); font: 600 14px/20px Mali, sans-serif; }
  .story-listen-cta svg { width: 16px; height: 16px; }
  .story-listen-mam { right: 28px; top: auto; bottom: -4px; width: 150px; }

  .story-intro { display: flex; align-items: center; gap: 16px; padding: 20px 24px; border: 1px solid var(--sn-line); border-radius: 24px; background: var(--sn-surface); }
  .story-intro-tile { display: grid; place-items: center; width: 56px; height: 56px; flex-shrink: 0; border-radius: 18px; background: var(--sn-container); color: var(--sn-hero); }
  .story-intro-tile svg { width: 28px; height: 28px; }
  .story-intro p { margin: 0; font-size: 14px; line-height: 20px; color: var(--sn-muted); }
  .story-intro .story-intro-title { margin-bottom: 4px; font: 600 18px/24px Mali, sans-serif; color: var(--sn-ink); }

  .story-continue { grid-area: cont; display: flex; flex-direction: column; justify-content: center; gap: 4px; width: auto; min-width: clamp(280px, 27vw, 380px); margin: 0 0 0 20px; padding: 16px 12px 12px; border: 1px solid var(--sn-line); border-radius: 24px; background: var(--sn-surface); }
  .story-continue-label { display: block; margin: 0 8px 4px; font: 700 11px/16px system-ui, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: var(--sn-muted); }
  .story-continue .story-chip { display: grid; grid-template-columns: 36px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 12px; align-items: center; min-height: 0; padding: 8px; border: 0; border-radius: 14px; background: transparent; white-space: normal; }
  .story-continue .story-chip:hover { background: var(--sn-soft); }
  .story-continue .story-chip svg { grid-row: 1 / span 2; width: 36px; height: 36px; padding: 8px; border-radius: 12px; background: var(--sn-container); }
  .story-continue .story-chip span { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--sn-muted); }
  .story-continue-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 15px/20px Mali, sans-serif; color: var(--sn-ink); }

  /* Underline tabs on the left, toolbar on the right, one rule beneath both. */
  .story-chips { grid-area: tabs; display: flex; align-items: flex-end; gap: 4px 24px; flex-wrap: wrap; margin: 28px 0 0; padding: 0; border-bottom: 1px solid var(--sn-line); }
  .story-chips .story-chip { min-height: 48px; padding: 0 2px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: var(--sn-muted); font: 600 15px/20px Mali, sans-serif; }
  .story-chips .story-chip svg { width: 18px; height: 18px; color: currentColor; }
  .story-chips .story-chip:hover { background: transparent; color: var(--sn-ink); border-bottom-color: var(--sn-line); }
  .story-chips .story-chip[aria-current="page"] { color: var(--sn-hero); border-bottom-color: var(--sn-appbar); background: transparent; }
  .story-chips .story-chip-aside { margin-left: 8px; padding-left: 20px; border-left: 1px solid var(--sn-line); border-bottom-color: transparent; min-height: 30px; margin-bottom: 9px; }
  .story-chips .story-chip-aside:hover { border-bottom-color: transparent; color: var(--sn-hero); }
  .story-toolbar { grid-area: tools; align-self: stretch; align-items: center; gap: 8px; margin: 28px 0 0; padding: 0 0 8px 20px; border-bottom: 1px solid var(--sn-line); }
  .story-toolbar .story-search { flex: 0 1 280px; }
  .story-search input, .story-filter select, .story-icon-btn { height: 40px; min-height: 40px; }
  .story-icon-btn { width: 40px; }
  .audio-list-count { grid-area: count; margin: 16px 2px 12px; font-size: 13px; }

  /* Card grid */
  .story-rows { grid-area: grid; display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 20px; border: 0; border-radius: 0; background: transparent; overflow: visible; }
  .story-rows.is-empty { display: block; }
  .story-row { position: relative; flex-direction: column; align-items: stretch; gap: 0; min-height: 0; padding: 0; border: 1px solid var(--sn-line); border-radius: 20px; background: var(--sn-surface); overflow: hidden; box-shadow: 0 1px 2px #0e24200d; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
  .story-row + .story-row { border-top: 1px solid var(--sn-line); }
  .story-row:hover { background: var(--sn-surface); transform: translateY(-3px); border-color: #b9ddd5; box-shadow: 0 12px 28px #0e24201a; }
  .story-row > a { flex-direction: column; align-items: stretch; gap: 0; padding: 0; }
  .story-row > a:focus-visible { outline-offset: -3px; border-radius: 20px; }
  .story-card-art { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; overflow: hidden; background: var(--tone-bg); color: var(--tone-ink); }
  .story-card-art[data-tone="mint"] { --tone-bg: #ddf0ec; --tone-ink: #00796b; }
  .story-card-art[data-tone="amber"] { --tone-bg: #fff1de; --tone-ink: #b8650a; }
  .story-card-art[data-tone="rose"] { --tone-bg: #fde7ec; --tone-ink: #a3324f; }
  .story-card-art[data-tone="violet"] { --tone-bg: #ece8fb; --tone-ink: #5a47b8; }
  .story-card-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .story-card-wave { width: 112%; height: 56%; opacity: .55; }
  .story-card-glyph svg { width: 54px; height: 54px; opacity: .7; }
  .story-card-excerpt { align-self: end; justify-self: stretch; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin: 44px 16px 14px; font: 400 14px/20px Mali, sans-serif; color: var(--tone-ink); }
  .story-card-excerpt::before { content: '“'; margin-right: 2px; font-size: 1.4em; line-height: 0; vertical-align: -.25em; opacity: .6; }
  .story-row:hover .story-card-img { transform: scale(1.03); }
  .story-card-img { transition: transform .35s ease; }
  .audio-story-number { position: absolute; top: 12px; left: 12px; width: auto; min-width: 34px; height: 28px; padding: 0 8px; border: 0; border-radius: 999px; background: #ffffffe6; color: var(--sn-ink); box-shadow: 0 1px 3px #0e24201f; }
  .story-row.is-read .audio-story-number { background: var(--sn-appbar); color: #fff; }
  .story-row-text { gap: 4px; padding: 14px 16px 16px; }
  .story-row h2 { font-size: 16px; line-height: 22px; min-height: 44px; }
  .story-row small { display: inline-flex; justify-self: start; align-self: start; margin-top: 4px; padding: 2px 8px; border-radius: 999px; background: var(--sn-container); color: var(--sn-on-container); font-weight: 600; }
  .story-star { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; background: #ffffffe6; box-shadow: 0 1px 3px #0e24201f; }
  .story-star:hover { background: #fff; color: var(--sn-star); }
  .story-pro { position: absolute; top: 14px; left: 54px; padding: 3px 8px; }
  .story-star:focus-visible { outline-offset: 2px; }
  .audio-pagination { grid-area: pages; margin: 28px 0 8px; }
  .story-list > .audio-local { grid-area: local; max-width: 560px; }

  /* ---------- Readers: article column ---------- */
  .story-reader .story-reader-layout { grid-template-columns: minmax(0, 760px); justify-content: center; gap: 0 clamp(24px, 3vw, 48px); }
  .story-reader-main { min-height: 0; }
  .story-reader-main > .story-tabbar { order: 0; }
  .story-titlebar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 8px 0 18px; }
  .story-title { font-size: clamp(26px, 2.4vw, 34px); line-height: 1.25; }
  .story-meta { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 8px 0 0; font-size: 14px; line-height: 20px; color: var(--sn-muted); }
  .story-meta span + span::before { content: '·'; margin: 0 8px; color: var(--sn-outline); }
  .story-actions { flex-wrap: wrap; gap: 8px; margin: 0; }
  .story-action { display: inline-flex; gap: 6px; width: auto; height: 38px; padding: 0 14px 0 10px; border: 1px solid var(--sn-line); border-radius: 999px; background: var(--sn-surface); color: var(--sn-ink); font: 600 13px/1 system-ui, sans-serif; }
  .story-action svg { width: 18px; height: 18px; color: var(--sn-muted); }
  .story-action::after { content: attr(title); }
  .story-action:hover { border-color: #b9ddd5; background: var(--sn-soft); color: var(--sn-hero); }
  .story-action:hover svg { color: var(--sn-hero); }
  .story-action[aria-pressed="true"] { border-color: #f6cf98; background: var(--sn-amber); color: var(--sn-on-amber); }
  .story-action[aria-pressed="true"] svg { color: var(--sn-star); }
  .story-action[data-audio="download"][aria-pressed="true"] { border-color: #b9ddd5; background: var(--sn-container); color: var(--sn-on-container); }
  .story-action[data-audio="download"][aria-pressed="true"] svg { color: var(--sn-appbar); }

  /* Underline tabs at the top of the article */
  .story-tabbar { position: sticky; top: var(--story-topbar, 64px); z-index: 9; margin: 0 0 20px; padding: 0; background: var(--sn-bg); box-shadow: none; clip-path: none; border-bottom: 1px solid var(--sn-line); }
  .story-seg { display: flex; gap: 28px; height: auto; max-width: none; margin: 0; padding: 0; border-radius: 0; background: transparent; }
  .story-seg-pill { display: none; }
  .story-seg button { flex: none; min-height: 48px; padding: 0 2px; border-radius: 0; color: var(--sn-muted); font: 600 15px/20px Mali, sans-serif; overflow: visible; }
  .story-seg[style*="--tabs:3"] button { font-size: 15px; }
  .story-seg button::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: transparent; }
  .story-seg button[aria-selected="true"] { color: var(--sn-hero); }
  .story-seg button[aria-selected="true"]::after { background: var(--sn-appbar); }
  .story-seg button:hover:not([aria-selected="true"]) { color: var(--sn-ink); }
  .story-seg button:focus-visible { outline: 3px solid #bb7815; outline-offset: -3px; }

  .story-wave { margin: 0 0 8px; }
  .audio-cover img { height: clamp(180px, 17vw, 240px); border-radius: 20px; }
  .reading-cover { height: clamp(160px, 16vw, 220px); border-radius: 20px; }
  .story-tip { margin: 0 0 18px; }
  .story-plain .story-para { line-height: 1.75; }
  .story-cards .story-para { padding: 14px 12px 14px 18px; border-color: var(--sn-line); }
  .reading-detail .story-cards .story-para { border: 1px solid var(--sn-line); }
  .reading-detail .story-cards .story-para.speaking { border-color: var(--sn-appbar); }
  .audio-community { margin-top: 32px; }

  /* Tablet: one column, the player + tools row docked like a web toolbar. */
  .story-reader-layout > .story-dock { margin-top: 24px; border: 1px solid var(--sn-line); border-bottom: 0; border-radius: 18px 18px 0 0; overflow: hidden; }
}

/* ---------- Desktop: article + sticky tools column + docked web player ---------- */
@media (min-width: 1024px) {
  .story-list { grid-template-columns: minmax(0, 1fr) auto; }
  .story-rows { grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 24px 20px; }

  .story-reader .story-reader-layout { grid-template-columns: minmax(0, 720px) clamp(272px, 25vw, 340px); justify-content: center; align-items: start; }
  .story-reader-layout > .story-reader-main { grid-column: 1; grid-row: 1; min-height: calc(100dvh - var(--story-topbar, 64px) - 150px); }
  .story-reader .audio-reader-layout > .audio-tools { grid-column: 2; grid-row: 1; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 12px; position: sticky; top: calc(var(--story-topbar, 64px) + 20px); max-height: calc(100dvh - var(--story-topbar, 64px) - 132px); overflow: auto; overscroll-behavior: contain; margin-top: 8px; padding: 0 2px 12px; scrollbar-width: thin; }
  .reading-detail .audio-reader-layout > .audio-tools { max-height: calc(100dvh - var(--story-topbar, 64px) - 40px); }
  .story-actions [data-audio="tools"], .story-actions [data-reader="tools"] { display: none; }
  .story-toolsrow { display: none; }
  .reading-detail .story-dock { display: none; }

  .audio-panel-title { padding: 4px 4px 2px; }
  .audio-panel-title h2 { font-size: 17px; }
  .audio-tool-section { border-radius: 18px; box-shadow: 0 1px 2px #0e24200d; }
  .audio-tool-section > summary:hover { color: var(--sn-hero); }
  .audio-tools .audio-tool-row .button { min-height: 38px; padding: 6px 12px; border-radius: 999px; font-size: 13px; }
  .audio-tools label { margin: 8px 0; }
  .audio-tools input:not([type="range"]):not([type="checkbox"]), .audio-tools select, .audio-tools #dictionary-form input { min-height: 40px; font-size: 14px; }
  .audio-tools [type="range"] { min-height: 32px; }
  .audio-tool-section > summary { min-height: 48px; font-size: 14px; }
  .audio-tool-section-body { padding: 0 16px 14px; }
  .audio-tool-section-body > .audio-local:first-child { margin-top: 0; }
  .audio-tools #dictionary-form .button { min-height: 38px; padding: 6px 18px; }

  /* "Nghe toàn bài" card (text reader): status pill + transport in the column. */
  .reading-aloud-card { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--sn-line); border-radius: 18px; background: #fff; box-shadow: 0 1px 2px #0e24200d; }
  .reading-aloud-card[hidden], .reading-aloud-card:has(> .reading-aloud-bar[hidden]) { display: none; }
  .reading-aloud-card .reading-aloud-bar { margin: 0; }
  .reading-aloud-card .story-aloud { flex-wrap: wrap; row-gap: 2px; }
  .reading-aloud-card .story-aloud-meta { flex-basis: 100%; padding-left: 38px; }
  .reading-aloud-card .story-transport { justify-content: space-between; gap: 2px; padding: 0; }
  .reading-aloud-card .story-rate select { padding: 0 8px; }
  .reading-aloud-card .story-tbtn { width: 40px; height: 40px; }
  .reading-aloud-card .story-tbtn svg { width: 22px; height: 22px; }
  .reading-aloud-card .story-transport-play { width: 50px; height: 50px; }

  /* Web player bar: docked to the bottom of the viewport across the content area. */
  .story-reader-layout > .story-dock { grid-column: 1 / -1; grid-row: 2; position: sticky; bottom: 0; z-index: 12; margin: 28px 0 0; padding: 0 0 16px; border: 0; border-radius: 0; overflow: visible; background: transparent; box-shadow: none; }
  .story-reader-layout > .story-dock::before { content: ''; position: absolute; inset: 24px -40px 0; background: linear-gradient(transparent, var(--sn-bg) 45%); pointer-events: none; z-index: -1; }
  .story-reader .audio-status:not(:empty) { bottom: 112px; }
  .audio-selection-bar:not(.is-anchored) { bottom: 120px; }
  html:has(.story-reader) { scroll-padding-bottom: 120px; }
}

/* Web player bar look (tablet + desktop): light surface, teal accents. */
@media (min-width: 768px) {
  .story-wave, .story-wave[hidden], .audio-player [data-audio="close"] { display: none; }
  .audio-player { padding: 6px 12px; background: var(--sn-surface); color: var(--sn-ink); animation: none; }
  .audio-player-row { gap: 8px 14px; min-height: 60px; }
  .audio-player #audio-play-status { color: var(--sn-hero); padding: 4px 8px 0; }
  .audio-now { display: none; align-items: center; gap: 12px; flex: 0 1 240px; min-width: 0; order: 0; }
  .audio-now-art { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: 14px; background: var(--sn-container); color: var(--sn-hero); }
  .audio-now-art svg { width: 22px; height: 22px; }
  .audio-now-text { display: grid; min-width: 0; }
  .audio-now-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 14px/20px Mali, sans-serif; }
  .audio-now-text small { font-size: 12px; line-height: 16px; color: var(--sn-muted); }
  .audio-transport { order: 1; gap: 4px; }
  .audio-seek { order: 2; color: var(--sn-muted); }
  .audio-player .story-pbtn[data-audio="repeat"] { order: 3; }
  .audio-player-options { order: 4; }
  .story-pbtn { color: var(--sn-ink); }
  .story-pbtn:hover:not(:disabled) { background: var(--sn-soft); color: var(--sn-hero); }
  .story-pbtn[aria-pressed="true"] { background: var(--sn-container); color: var(--sn-hero); }
  .audio-player .audio-play { width: 46px; height: 46px; margin: 0 4px; background: var(--sn-appbar); color: #fff; box-shadow: 0 4px 12px #00796b47; }
  .audio-player .audio-play:hover:not(:disabled) { background: var(--sn-hero); }
  .audio-player .audio-play svg { width: 22px; height: 22px; }
  .audio-player .audio-play[aria-label="Phát audio"] svg { margin-left: 3px; }
  #audio-position, #audio-duration { color: var(--sn-muted); }
  .audio-player input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(to right, var(--sn-appbar) var(--range-fill, 0%), var(--sn-line) var(--range-fill, 0%)); }
  .audio-player input[type="range"]::-moz-range-track { height: 4px; background: linear-gradient(to right, var(--sn-appbar) var(--range-fill, 0%), var(--sn-line) var(--range-fill, 0%)); }
  .audio-player input[type="range"]::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5px; background: var(--sn-appbar); box-shadow: 0 0 0 3px #fff, 0 1px 4px #0e242040; }
  .audio-player input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; background: var(--sn-appbar); }
  .audio-player-options > label { color: var(--sn-muted); }
  #audio-speed { color: var(--sn-ink); }
  #audio-speed:hover { background: var(--sn-soft); }
  .audio-player :focus-visible { outline-color: #bb7815; }
}
@media (min-width: 1024px) {
  .audio-player { padding: 8px 16px; border: 1px solid var(--sn-line); border-radius: 20px; background: #fffffff7; box-shadow: 0 10px 34px #0e242024; backdrop-filter: blur(10px); }
}
@media (min-width: 1280px) { .audio-now { display: flex; } }
@media (min-width: 1024px) and (max-width: 1279px) {
  .story-list { grid-template-areas: "head head" "tabs tabs" "tools tools" "count count" "grid grid" "pages pages" "local local"; }
  .story-list:has(.has-continue) { grid-template-areas: "head cont" "tabs tabs" "tools tools" "count count" "grid grid" "pages pages" "local local"; }
  .story-toolbar { margin-top: 0; padding: 12px 0; border-bottom: 0; }
  .story-toolbar .story-search { flex: 1 1 auto; }
  .story-rows { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); }
  .story-listen-card { padding-right: 170px; }
  .story-listen-mam { width: 128px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .story-list, .story-list:has(.has-continue) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "cont" "tabs" "tools" "count" "grid" "pages" "local"; }
  .story-continue { width: auto; min-width: 0; margin: 16px 0 0; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .story-continue .story-chip { flex: 1 1 220px; }
  .story-continue-label { flex-basis: 100%; }
  .story-toolbar { margin-top: 0; padding: 12px 0; border-bottom: 0; }
  .story-toolbar .story-search { flex: 1 1 auto; }
  .story-listen-card { padding-right: 150px; }
  .story-listen-mam { width: 120px; right: 16px; }
}
@media (min-width: 768px) and (prefers-reduced-motion: reduce) {
  .story-row, .story-listen-card, .story-card-img { transition: none; }
  .story-row:hover, .story-listen-card:hover { transform: none; }
}

/* ---------- "Truyện ngắn" (/audio, story-hub.js): the section tabs ----------
   A segmented control under the library tabs, each section with its count: four equal cells
   on phones (names wrap), one row on wider screens. */
.hub-tabs { display: grid; grid-template-columns: repeat(var(--hub-tabs, 4), minmax(0, 1fr)); gap: 4px; margin-top: 16px; padding: 4px; border-radius: 16px; background: #e7eeec; }
.hub-tabs a { display: grid; align-content: center; justify-items: center; gap: 2px; min-width: 0; min-height: 56px; padding: 6px 4px; border-radius: 12px; color: var(--sn-muted); text-align: center; text-decoration: none; }
.hub-tab-name { font: 700 13px/16px var(--font-app-bold); }
/* Phones: "Truyện" over the section's own word(s), the same two lines in every cell. */
@media (max-width: 767px) { .hub-tab-break { display: block; height: 0; overflow: hidden; } }
.hub-tab-count { font: 600 12px/16px system-ui, sans-serif; font-variant-numeric: tabular-nums; color: var(--sn-outline); }
.hub-tabs a:hover:not([aria-current]) { color: var(--sn-ink); }
.hub-tabs a[aria-current="page"] { background: var(--sn-surface); color: var(--sn-hero); box-shadow: 0 1px 3px #0e242026; }
.hub-tabs a[aria-current="page"] .hub-tab-count { color: var(--sn-appbar); }
.hub-tabs a:focus-visible { outline-offset: -3px; }
@media (min-width: 768px) {
  .story-list.story-hub { grid-template-areas: "head head" "tabs tools" "hub hub" "count count" "grid grid" "pages pages" "local local"; }
  .story-list.story-hub:has(.has-continue) { grid-template-areas: "head cont" "tabs tools" "hub hub" "count count" "grid grid" "pages pages" "local local"; }
  .hub-tabs { grid-area: hub; justify-self: start; width: min(100%, 720px); margin-top: 24px; }
  .hub-tabs a { grid-auto-flow: column; justify-content: center; gap: 8px; min-height: 48px; padding: 0 10px; }
  .hub-tab-name { font-size: 14px; line-height: 18px; white-space: nowrap; }
  .hub-tab-count { min-width: 28px; padding: 1px 8px; border-radius: 999px; background: #ffffffb3; }
  .hub-tabs a[aria-current="page"] .hub-tab-count { background: var(--sn-container); color: var(--sn-on-container); }
  .story-hub .audio-list-count { margin-top: 14px; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  .story-list.story-hub { grid-template-areas: "head head" "tabs tabs" "tools tools" "hub hub" "count count" "grid grid" "pages pages" "local local"; }
  .story-list.story-hub:has(.has-continue) { grid-template-areas: "head cont" "tabs tabs" "tools tools" "hub hub" "count count" "grid grid" "pages pages" "local local"; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .story-list.story-hub, .story-list.story-hub:has(.has-continue) { grid-template-areas: "head" "cont" "tabs" "tools" "hub" "count" "grid" "pages" "local"; }
}

/* ---------- #audio/favorites: Truyện / Từ vựng (StoryFavoritesScreen.kt) ----------
   SegmentedControl (a tinted track, the chosen side raised) under the library tabs, and the
   liked words as FavoriteVocabCard: one column on phones, a card grid on wider screens. */
.fav-seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; margin-top: 16px; padding: 4px; border-radius: 14px; background: #e7eeec; }
.fav-seg a { display: grid; place-items: center; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--sn-muted); font: 700 14px/18px var(--font-app-bold); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-seg a:hover:not([aria-current]) { color: var(--sn-ink); }
.fav-seg a[aria-current="page"] { background: var(--sn-surface); color: var(--sn-hero); box-shadow: 0 1px 3px #0e242026; }
.fav-seg a:focus-visible { outline-offset: -3px; }
.fav-words { display: grid; gap: 12px; margin-top: 16px; font-family: system-ui, sans-serif; }
.fav-words.is-empty { display: block; }
.fav-word { cursor: pointer; }
.fav-word .audio-vocab-main h3 { overflow-wrap: anywhere; }
.fav-word .audio-vocab-actions { flex-wrap: wrap; }
.story-bookmark.is-saved { color: var(--sn-pro); }
.story-bookmark.is-saved svg { fill: currentColor; }
.fav-unsave-dialog { --yv-error: var(--md-error); --yv-error-container: var(--md-error-container); }
.fav-unsave-dialog p strong { font-family: var(--font-app-bold); }
@media (min-width: 768px) {
  .story-list.story-favorites { grid-template-areas: "head head" "tabs tools" "seg seg" "count count" "grid grid" "pages pages" "local local"; }
  .story-list.story-favorites:has(.has-continue) { grid-template-areas: "head cont" "tabs tools" "seg seg" "count count" "grid grid" "pages pages" "local local"; }
  .fav-seg { grid-area: seg; justify-self: start; width: min(100%, 380px); margin-top: 24px; }
  .story-favorites .audio-list-count { margin-top: 14px; }
  .fav-words { grid-area: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 20px; }
  .fav-word { display: flex; flex-direction: column; gap: 10px; padding: 16px 8px 12px 20px; border-radius: 20px; box-shadow: 0 1px 2px #0e24200d; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
  .fav-word:hover { transform: translateY(-2px); border-color: #b9ddd5; box-shadow: 0 12px 28px #0e24201a; }
  .fav-word .audio-vocab-main h3 { font-size: 19px; line-height: 26px; }
  .fav-word .audio-vocab-actions { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--sn-soft); }
}
@media (min-width: 1024px) {
  .fav-words { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  .story-list.story-favorites { grid-template-areas: "head head" "tabs tabs" "tools tools" "seg seg" "count count" "grid grid" "pages pages" "local local"; }
  .story-list.story-favorites:has(.has-continue) { grid-template-areas: "head cont" "tabs tabs" "tools tools" "seg seg" "count count" "grid grid" "pages pages" "local local"; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .story-list.story-favorites, .story-list.story-favorites:has(.has-continue) { grid-template-areas: "head" "cont" "tabs" "tools" "seg" "count" "grid" "pages" "local"; }
}
@media (min-width: 768px) and (prefers-reduced-motion: reduce) {
  .fav-word { transition: none; }
  .fav-word:hover { transform: none; }
}
