@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f8fafc;
  --paper: #fff;
  --header-surface: var(--paper);
  --sidebar-surface: var(--paper);
  --elevated: var(--paper);
  --toolbar: var(--paper);
  --hover: var(--bg);
  --ink: #0f172a;
  --secondary: #43536a;
  --muted: #53637a;
  --muted-on-selected: var(--muted);
  --line: #e2e8f0;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-text: var(--accent);
  --control-line: #78889f;
  --on-accent: #fff;
  --soft: #eef2ff;
  --stage: #e8edf5;
  --good: #12664e;
  --good-bg: #e7f7ef;
  --bad: #9d2842;
  --bad-bg: #fceef1;
  --warning: #865507;
  --warning-bg: #fff2d8;
  --banner-ink: #fff;
  --banner-muted: #e0e6fa;
  --banner-button: #fff;
  --banner-button-ink: #212554;
  --banner-button-hover: #e9eaff;
  --art-grid: #ffffff20;
  --art-border: #ffffff52;
  --art-shadow: 9px 12px 0 #0b102c70, 0 20px 36px #090c2350;
  --cover-shadow: 0 5px 12px #12193328;
  --document-shadow: none;
  --overlay: #080d20d4;
  --drawer-overlay: #0b112077;
  --shadow: 0 2px 6px #182a4a06, 0 12px 26px #182a4a09;
  --shadow-raised: 0 10px 30px #182a4a1c;
  --radius: 18px;
  --header: 68px;
  --rail: 258px;
  --ease: 180ms ease;
  font-family: "IBM Plex Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  font-size: 16px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --paper: #1e293b;
  --header-surface: #0f172a;
  --sidebar-surface: #111827;
  --elevated: #263449;
  --toolbar: #182235;
  --hover: #263449;
  --ink: #f1f5f9;
  --secondary: #cbd5e1;
  --muted: #94a3b8;
  --muted-on-selected: #aab8d1;
  --line: #334155;
  --control-line: #70829e;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-text: #b4bfff;
  --on-accent: #111532;
  --soft: #312e81;
  --stage: #172236;
  --good: #4ade80;
  --good-bg: #15362c;
  --bad: #fb8da0;
  --bad-bg: #452533;
  --warning: #fbbf24;
  --warning-bg: #3d301d;
  --banner-ink: var(--ink);
  --banner-muted: var(--secondary);
  --banner-button: var(--accent);
  --banner-button-ink: var(--on-accent);
  --banner-button-hover: var(--accent-hover);
  --document-shadow: 0 6px 24px #04081470;
  --shadow: 0 8px 24px #04081430;
  --shadow-raised: 0 12px 34px #04081480;
}
:root[data-theme="sepia"] {
  --bg: #eae4d6;
  --paper: #f5f0e5;
  --header-surface: #f2ebdd;
  --sidebar-surface: #e2dacb;
  --elevated: #f8f3e8;
  --toolbar: #f2ebdd;
  --hover: #ddd4c1;
  --ink: #302e29;
  --secondary: #5f5a50;
  --muted: #655d51;
  --line: #d0c5b2;
  --control-line: #867b68;
  --accent: #596c50;
  --accent-hover: #495d42;
  --accent-text: #43563c;
  --on-accent: #fffaf0;
  --soft: #d2ddca;
  --stage: #d8cdbc;
  --good: #285c38;
  --good-bg: #dce9d7;
  --bad: #8e3341;
  --bad-bg: #f1dcd8;
  --warning: #805105;
  --warning-bg: #f2e1b9;
  --banner-ink: var(--ink);
  --banner-muted: var(--secondary);
  --banner-button: var(--accent);
  --banner-button-ink: var(--on-accent);
  --banner-button-hover: var(--accent-hover);
  --art-grid: #5f503a24;
  --art-border: #594c3638;
  --art-shadow: 9px 12px 0 #594c362e, 0 20px 36px #594c3638;
  --cover-shadow: 0 5px 12px #594c3628;
  --document-shadow: 0 6px 24px #594c3638;
  --overlay: #302820b8;
  --drawer-overlay: #30282070;
  --shadow: 0 2px 6px #594c3609, 0 12px 26px #594c3610;
  --shadow-raised: 0 10px 30px #594c3626;
}
* { box-sizing: border-box; }
html { background: var(--bg); scrollbar-color: var(--control-line) var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.55; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; z-index: 10; top: 8px; left: 8px; padding: 10px 14px; background: var(--paper); transform: translateY(-150%); }
.skip:focus { transform: none; }
.symbol { width: 20px; height: 20px; flex: 0 0 auto; vertical-align: middle; }
.top { position: sticky; inset-block-start: 0; z-index: 5; height: var(--header); display: flex; align-items: center; gap: 15px; padding: 0 24px; background: var(--header-surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.26rem; font-weight: 700; letter-spacing: -.045em; white-space: nowrap; }
.brand strong { color: var(--accent-text); }
.mark { width: 37px; height: 37px; display: flex; gap: 3px; align-items: flex-end; justify-content: center; padding-bottom: 9px; border-radius: 12px; background: var(--accent); }
.mark i { width: 4px; height: 8px; border-radius: 2px; background: var(--on-accent); }
.mark i:nth-child(2) { height: 13px; }
.mark i:nth-child(3) { height: 18px; }
.top-label { color: var(--muted); border-left: 1px solid var(--line); padding-left: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-switch { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }
.book-tab { display: grid; place-items: center; min-height: 42px; padding: 4px 15px; border-radius: 10px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.book-tab:hover, .book-tab[aria-current="page"] { color: var(--accent-text); background: var(--soft); }
.layout { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: calc(100dvh - var(--header)); }
.sidebar { position: sticky; top: var(--header); height: calc(100dvh - var(--header)); overflow: auto; align-self: start; background: var(--sidebar-surface); border-right: 1px solid var(--line); padding: 25px 15px; scrollbar-width: thin; }
.sidebar-collapsed .layout { grid-template-columns: minmax(0, 1fr); }
.sidebar-collapsed .sidebar { display: none; }
.nav-heading { margin: 22px 11px 8px; font-size: .86rem; font-weight: 600; color: var(--muted); }
.nav-home, .nav-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 44px; padding: 9px 10px; border-radius: 10px; }
.nav-home { font-weight: 600; }
.nav-item { font-size: .94rem; margin-block: 2px; }
.nav-item small { display: block; color: var(--muted); font-size: .82rem; }
.nav-home:hover, .nav-item:hover, .sidebar summary:hover { background: var(--hover); }
.nav-home[aria-current="page"], .nav-item[aria-current="page"] { background: var(--soft); color: var(--accent-text); font-weight: 600; }
.nav-number { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.nav-item[aria-current="page"] .nav-number, .result .muted { color: var(--muted-on-selected); }
.nav-check { color: var(--good); }
.nav-book { display: grid; place-items: center; width: 36px; height: 36px; color: var(--book-ink); background: var(--book-wash); border-radius: 10px; }
.sidebar details { margin-top: 7px; border-top: 1px solid var(--line); padding-top: 7px; }
.sidebar summary { cursor: pointer; padding: 10px 8px; border-radius: 8px; font-size: .94rem; font-weight: 600; }
.sidebar details .nav-item { margin-left: 7px; }
.backdrop { display: none; }
main { width: min(100%, 1440px); min-width: 0; margin-inline: auto; padding: clamp(24px, 3.05vw, 48px); }
main:focus { outline: none; }
.row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted, .crumb { color: var(--muted); }
.crumb { margin-bottom: 9px; font-size: .91rem; }
.crumb a:hover, .library-info h3 a:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.page-title { font-size: clamp(1.7rem, 2.8vw, 2.55rem); line-height: 1.28; margin-bottom: 19px; text-wrap: pretty; }
.button, .icon { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 15px; border: 1px solid transparent; border-radius: 11px; font-weight: 600; line-height: 1.35; text-align: center; transition: background var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease); }
.button { background: var(--accent); color: var(--on-accent); }
.button:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary, .icon { background: var(--elevated); color: var(--ink); border-color: var(--line); }
.button.secondary:hover, .icon:hover:not(:disabled), .appearance-control .icon[aria-expanded="true"], .icon[aria-pressed="true"] { background: var(--soft); border-color: var(--accent); color: var(--accent-text); }
.icon { padding-inline: 11px; }
.theme-toggle, .mobile-menu, .fullscreen, .reading-settings { width: 44px; flex: 0 0 auto; }
.appearance-control { position: relative; }
.appearance-panel { position: absolute; z-index: 2; inset: calc(100% + 9px) 0 auto auto; width: min(260px, calc(100vw - 28px)); max-height: calc(100dvh - var(--header) - 30px); overflow: auto; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--elevated); color: var(--ink); box-shadow: var(--shadow-raised); }
.reading-panel { max-height: min(420px, 55dvh); }
.reading-panel-title { display: block; margin: 2px 8px 6px; }
.theme-options { min-inline-size: 0; padding: 0; margin: 0; border: 0; }
.theme-options legend { padding: 2px 8px 5px; color: var(--secondary); font-size: .9rem; font-weight: 600; }
.theme-option, .appearance-action { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; min-height: 44px; width: 100%; padding: 8px 9px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: inherit; cursor: pointer; text-align: start; }
.theme-option:hover, .appearance-action:hover { background: var(--hover); }
.theme-option:has(input:checked), .appearance-action[aria-pressed="true"] { background: var(--soft); color: var(--accent-text); font-weight: 600; }
.theme-option:has(input:focus-visible) { outline: 2px solid var(--accent-text); outline-offset: -2px; }
.theme-check { visibility: hidden; }
.theme-option:has(input:checked) .theme-check { visibility: visible; }
.reading-options { display: grid; border-top: 1px solid var(--line); margin-top: 7px; padding-top: 6px; }
progress { display: block; width: 100%; height: 8px; appearance: none; border: 0; border-radius: 999px; background: var(--soft); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--soft); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

.tone-1 { --book-wash: #e7e9ff; --book-ink: #3834a2; --book-banner: #1f2452; --book-grid: #b8b8ff; }
.tone-2 { --book-wash: #dff4ee; --book-ink: #14644f; --book-banner: #113c3b; --book-grid: #a3f2d6; }
.tone-3 { --book-wash: #f1e8ff; --book-ink: #6335a5; --book-banner: #382255; --book-grid: #dbb8ff; }
:root[data-theme="dark"] .tone-1 { --book-wash: #2e365b; --book-ink: #bec8ff; --book-banner: #222c50; --book-grid: #bec8ff; }
:root[data-theme="dark"] .tone-2 { --book-wash: #23413f; --book-ink: #a9e0d0; --book-banner: #193635; --book-grid: #a9e0d0; }
:root[data-theme="dark"] .tone-3 { --book-wash: #393150; --book-ink: #ddc7ff; --book-banner: #302743; --book-grid: #ddc7ff; }
:root[data-theme="sepia"] .tone-1 { --book-wash: #dbddcc; --book-ink: #43563c; --book-banner: #dfdfcd; --book-grid: #43563c; }
:root[data-theme="sepia"] .tone-2 { --book-wash: #d9dfd0; --book-ink: #3e5844; --book-banner: #dce1d3; --book-grid: #3e5844; }
:root[data-theme="sepia"] .tone-3 { --book-wash: #e7d9ce; --book-ink: #674e47; --book-banner: #e8dbce; --book-grid: #674e47; }
.library-intro { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 18px 28px; margin-bottom: 26px; }
.library-intro h1 { font-size: clamp(2.2rem, 4vw, 3.55rem); font-weight: 700; line-height: 1.18; letter-spacing: -.045em; }
.library-intro p { color: var(--muted); font-size: 1.05rem; margin-top: 9px; }
.library-stats { display: flex; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.library-stats > div { display: grid; min-width: 94px; padding: 9px 17px; }
.library-stats > div + div { border-left: 1px solid var(--line); }
.library-stats strong { font-size: 1.54rem; line-height: 1.3; font-variant-numeric: tabular-nums; }
.library-stats span, .library-stats small { color: var(--muted); font-size: .88rem; }
.resume { position: relative; isolation: isolate; overflow: hidden; display: grid; align-items: center; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); min-height: 246px; background: var(--book-banner); color: var(--banner-ink); border-radius: var(--radius); box-shadow: var(--shadow); }
.resume-copy { position: relative; z-index: 1; padding: clamp(22px, 3vw, 38px); }
.resume-label { display: flex; align-items: center; gap: 8px; color: var(--book-grid); font-weight: 600; margin-bottom: 10px; }
.resume h2 { font-size: clamp(1.48rem, 2.45vw, 2.35rem); line-height: 1.24; text-wrap: balance; }
.resume h2 + p, .hero p { color: var(--banner-muted); margin-block: 9px 17px; }
.resume .button, .hero .mint { background: var(--banner-button); color: var(--banner-button-ink); }
.resume .button:hover, .hero .mint:hover { background: var(--banner-button-hover); }
.resume-art { position: relative; display: grid; place-items: center; align-self: stretch; padding: 20px 13% 20px 3%; }
.resume-art::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(to right, var(--art-grid) 1px, transparent 1px), linear-gradient(to bottom, var(--art-grid) 1px, transparent 1px); background-size: 27px 27px; mask-image: linear-gradient(90deg, transparent, #000 40%, #000); opacity: .48; }
.resume-art img { position: relative; width: min(100%, 340px); height: auto; border: 1px solid var(--art-border); border-radius: 12px; transform: rotate(-5deg); box-shadow: var(--art-shadow); }
.library-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 13px; }
.section-heading { font-size: 1.54rem; line-height: 1.3; margin-bottom: 14px; }
.library-heading .section-heading { margin-bottom: 0; }
.library { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(14px, 1.6vw, 24px); }
.library-card { display: flex; flex-direction: column; min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: box-shadow var(--ease), border-color var(--ease); }
.library-card:hover { border-color: var(--accent); box-shadow: var(--shadow-raised); }
.library-cover { display: block; padding: 13px; background: var(--book-wash); }
.library-cover:focus-visible { outline-offset: -4px; }
.library-cover img { width: 100%; height: auto; display: block; border-radius: 8px; box-shadow: var(--cover-shadow); }
.library-info { flex: 1; display: flex; flex-direction: column; gap: 7px; padding: clamp(15px, 1.55vw, 23px); }
.book-meta { color: var(--muted); font-size: .88rem; font-weight: 600; }
.book-meta span { margin-inline: 3px; }
.library-info h3 { font-size: clamp(1.13rem, 1.38vw, 1.42rem); line-height: 1.35; }
.library-info .muted { font-size: .94rem; }
.card-progress { margin-top: auto; padding-top: 12px; font-size: .9rem; color: var(--muted); }
.card-progress strong { color: var(--accent-text); }
.card-progress progress { margin-top: 6px; }
.card-action { justify-content: space-between; margin-top: 9px; }

.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; gap: 24px; padding: clamp(22px, 4vw, 48px); border-radius: var(--radius); background: var(--book-banner); color: var(--banner-ink); }
.eyebrow { color: var(--book-grid); font-size: .82rem; font-weight: 700; letter-spacing: .12em; margin-bottom: 10px; }
.hero h1 { font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.18; letter-spacing: -.04em; }
.cover { display: block; width: 100%; height: auto; border: 1px solid var(--art-border); border-radius: 12px; box-shadow: var(--art-shadow); }
.progress-strip { margin-block: 20px 27px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--paper); border-radius: var(--radius); }
.progress-strip.two-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric { padding: 15px clamp(10px, 2vw, 22px); }
.metric + .metric { border-left: 1px solid var(--line); }
.metric b { display: block; font-size: 1.55rem; }
.metric span, .part p { color: var(--muted); font-size: .94rem; }
.metric progress { margin-top: 7px; }
.parts { display: grid; gap: 12px; }
.part { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.part-index, .q-index { display: grid; place-content: center; border-radius: 10px; background: var(--soft); color: var(--accent-text); font-weight: 700; }
.part-index { min-height: 52px; font-size: 1.4rem; }
.part h3 { font-size: 1.15rem; }

[data-view="read"] main { width: 100%; padding: 15px clamp(14px, 2vw, 32px) 20px; }
.lesson-header { position: relative; z-index: 2; margin-bottom: 12px; }
.lesson-header .page-title { font-size: clamp(1.45rem, 2.4vw, 2.05rem); margin: 0; flex: 1 1 320px; }
.lesson-actions { flex-shrink: 0; }
.viewer { border: 1px solid var(--line); border-radius: var(--radius); background: var(--toolbar); box-shadow: var(--shadow); overflow: hidden; }
.viewer-image { display: grid; place-items: center; position: relative; min-width: 0; min-height: 150px; background: var(--stage); }
.viewer-image button { display: block; width: min(100%, max(480px, calc((100dvh - 248px) * 16 / 9))); padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.viewer-image button:focus-visible { outline-offset: -4px; }
.viewer-image img { display: block; width: 100%; height: auto; object-fit: contain; box-shadow: var(--document-shadow); }
.viewer-image[aria-busy="true"] img { visibility: hidden; }
.slide-status { position: absolute; z-index: 1; padding: 12px; color: var(--muted); text-align: center; pointer-events: none; }
.warning { border-radius: 9px; background: var(--warning-bg); color: var(--warning); }
.storage-warning { padding: 10px 13px; margin-bottom: 14px; }
.viewer-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 9px; padding: 10px 13px; border-top: 1px solid var(--line); }
.prev-page { justify-self: start; }
.next-page { justify-self: end; }
#jump-form { flex-wrap: nowrap; }
#jump-page, .response { padding: 8px 10px; min-height: 44px; border: 1px solid var(--control-line); border-radius: 9px; color: var(--ink); background: var(--bg); }
.response::placeholder { color: var(--muted); opacity: 1; }
#jump-page { width: 4.25em; text-align: center; appearance: textfield; font-variant-numeric: tabular-nums; }
#jump-page::-webkit-inner-spin-button { appearance: none; }
.slide-progress { height: 4px; border-radius: 0; }
.viewer-next { margin-top: 11px; }
.viewer-next .muted { font-size: .92rem; margin-right: auto; }
.focus-mode .top { display: none; }
.focus-mode .layout { min-height: 100dvh; }
.focus-mode .lesson-header .crumb { display: none; }
.focus-mode .viewer-image button { width: min(100%, max(480px, calc((100dvh - 168px) * 16 / 9))); }
.focus-mode .viewer-next > .muted { display: none; }

body[data-view="exercise"] main, body[data-view="quiz"] main { max-width: 1050px; }
.questions { display: grid; gap: 16px; }
.question, .result, .assessment-progress { min-width: 0; padding: clamp(17px, 2.8vw, 34px); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.assessment-progress { padding-block: 15px; }
.assessment-progress .row { margin-block: 8px; }
.question h2 { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; font-size: clamp(1.16rem, 1.65vw, 1.46rem); line-height: 1.45; margin-bottom: 18px; overflow-wrap: anywhere; }
.q-index { min-width: 35px; min-height: 35px; font-size: 1rem; }
.choice { display: flex; align-items: flex-start; gap: 12px; min-height: 52px; padding: 12px 14px; margin-bottom: 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer; transition: background var(--ease), border-color var(--ease); }
.choice:hover, .choice:has(input:checked) { background: var(--soft); border-color: var(--accent); }
.choice input { width: 18px; height: 18px; margin: 4px 0 0; flex-shrink: 0; accent-color: var(--accent); }
.review-choices { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 7px; }
.review-choices li { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 10px; }
.review-choices strong { font-size: .91rem; }
.review-choices .good { background: var(--good-bg); color: var(--good); }
.review-choices .missed { background: var(--bad-bg); color: var(--bad); }
.response { max-width: 100%; }
textarea.response { display: block; width: 100%; resize: vertical; }
.assessment-actions { justify-content: space-between; }
.source { display: inline-flex; align-items: center; min-height: 44px; background: transparent; color: var(--accent-text); border: 0; padding: 5px 0; font-size: .91rem; text-decoration: underline; text-underline-offset: 3px; text-align: left; margin-right: 14px; }
.feedback { padding: 14px 17px; margin-bottom: 8px; border-radius: 12px; background: var(--bg); overflow-wrap: anywhere; }
.feedback p { margin-top: 5px; white-space: pre-wrap; }
.feedback.good { background: var(--good-bg); color: var(--good); }
.feedback.missed { background: var(--bad-bg); color: var(--bad); }
.result { background: var(--soft); border-color: var(--accent); }
.result h2 { font-size: 1.36rem; }
.result h2 strong { display: block; font-size: clamp(2.7rem, 6vw, 4rem); line-height: 1.2; color: var(--accent-text); }
.result p { margin-top: 6px; }
dialog { width: min(96vw, 1720px); max-width: none; max-height: 94dvh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--paper); overflow: hidden; }
dialog::backdrop { background: var(--overlay); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; gap: 8px; border-bottom: 1px solid var(--line); }
#dialog-view { max-height: 80dvh; overflow: auto; background: var(--stage); }
#dialog-view img { display: block; width: min(100%, calc(80dvh * 16 / 9)); height: auto; margin-inline: auto; }
#dialog-view.zoomed img { width: max(150%, 1050px); max-width: none; margin: 0; }

@media (max-width: 1100px) {
  .library { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .part { grid-template-columns: 52px minmax(0, 1fr); }
  .part .row { grid-column: 2; }
}
@media (max-width: 900px) {
  :root { --header: 62px; }
  .layout { display: block; }
  .top { padding-inline: 15px; }
  .sidebar { position: fixed; inset: var(--header) auto 0 0; z-index: 4; height: auto; width: min(330px, 86vw); }
  .menu-open .backdrop { display: block; position: fixed; inset: var(--header) 0 0; z-index: 3; width: 100%; border: 0; background: var(--drawer-overlay); }
  .menu-open { overflow: hidden; }
  .viewer-image button, .focus-mode .viewer-image button { width: 100%; }
}
@media (max-width: 600px) {
  .top { gap: 8px; padding-inline: 12px; }
  .top-label, .book-switch { display: none; }
  .mobile-menu { margin-left: auto; }
  main { padding: 23px 15px 28px; }
  .library-intro { gap: 15px; margin-bottom: 17px; }
  .library-intro h1 { font-size: 2.15rem; }
  .library-stats { width: 100%; }
  .library-stats > div { flex: 1; }
  .resume { min-height: 0; grid-template-columns: minmax(0, 1fr); }
  .resume-copy { padding: 20px; }
  .resume-art { display: none; }
  .library-heading { margin-top: 23px; }
  .library { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .lesson-header .page-title { flex-basis: 100%; }
  .lesson-actions { gap: 6px; }
  .lesson-actions .icon { padding-inline: 9px; }
  .lesson-actions .appearance-control { position: static; }
  .viewer-foot { padding: 8px; gap: 5px; }
  .viewer-foot > button { min-width: 44px; padding-inline: 8px; gap: 4px; font-size: .86rem; }
  .viewer-foot .symbol { width: 16px; }
  #jump-form { gap: 5px; }
  #jump-page { width: 3em; padding-inline: 3px; }
  .jump-button { padding-inline: 8px; min-width: 41px; }
  .viewer-next .muted { width: 100%; }
}
@media (max-width: 360px) {
  .viewer-foot > button span { display: none; }
}
.theme-transition :is(body, .top, .sidebar, .nav-home, .nav-item, .book-tab, .button, .icon, .appearance-panel, .theme-option,
  .appearance-action, .library-stats, .resume, .library-card, .library-cover, .hero, .progress-strip, .part, .viewer,
  .viewer-image, #jump-page, .response, .question, .assessment-progress, .choice, .review-choices li, .result, .feedback, dialog, #dialog-view) {
  transition: background-color var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
