#content-textbooks { margin-top:20px; }
.textbook-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; padding:12px 2px 22px; }
.textbook-heading h2 { margin:0 0 8px; font-size:28px; letter-spacing:-.5px; }
.textbook-heading p { margin:0; color:var(--muted); font-size:14px; line-height:1.6; }
.textbook-badge { flex-shrink:0; padding:8px 12px; border-radius:10px; background:#faeee8; color:var(--accent-dark); font-size:12px; }
.textbook-layout { display:grid; grid-template-columns:220px minmax(0,1fr); gap:20px; align-items:start; }
.textbook-directory { padding:12px; background:var(--paper); border:1px solid var(--line); border-radius:20px; }
.textbook-directory h3 { margin:4px 4px 12px; font-size:14px; }
.textbook-pages { display:grid; gap:8px; max-height:70vh; overflow:auto; padding:3px; }
.textbook-page { display:flex; align-items:center; gap:10px; padding:8px; min-width:0; text-align:left; color:var(--ink); background:transparent; border:2px solid transparent; border-radius:12px; }
.textbook-page:hover { background:var(--bg); }
.textbook-page[aria-current="page"] { border-color:var(--accent); background:#faeee8; }
.textbook-page img { width:72px; height:48px; object-fit:contain; background:#fff; border:1px solid var(--line); border-radius:5px; }
.textbook-page span { font-size:12px; line-height:1.5; }
.textbook-page small { display:block; color:var(--muted); font-size:11px; }
.textbook-reader { min-width:0; background:var(--paper); border:1px solid var(--line); border-radius:20px; overflow:hidden; }
.textbook-toolbar { display:flex; align-items:center; gap:8px; flex-wrap:wrap; padding:14px; border-bottom:1px solid var(--line); }
.textbook-toolbar button, .textbook-toolbar a, .textbook-toolbar select { min-height:40px; padding:8px 12px; border:1px solid #dfe2e7; border-radius:9px; background:white; color:var(--ink); font:inherit; font-size:13px; text-decoration:none; }
.textbook-toolbar button:disabled { opacity:.35; cursor:default; }
.textbook-toolbar select { max-width:100%; min-width:0; }
.textbook-zoom { display:flex; gap:6px; align-items:center; margin-left:auto; }
.textbook-zoom output { width:42px; text-align:center; font-size:12px; color:var(--muted); }
.textbook-stage { overflow:auto; max-height:78vh; min-height:160px; background:#e9ebee; overscroll-behavior:contain; }
.textbook-stage img { display:block; width:calc(100% * var(--textbook-zoom, 1)); max-width:none; height:auto; margin:0 auto; }
.textbook-status { margin:0; padding:12px 16px; color:var(--muted); font-size:13px; line-height:1.6; }
.textbook-status:empty { display:none; }
.textbook-status.is-error { color:#a63d25; }
.textbook-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 16px; border-top:1px solid var(--line); font-size:13px; }
.textbook-footer p { margin:0; color:var(--muted); }
.textbook-footer strong { flex-shrink:0; font-variant-numeric:tabular-nums; }
.textbook-toolbar a:focus-visible, .textbook-toolbar select:focus-visible { outline:3px solid #c4543570; outline-offset:3px; }
@media(min-width:1024px) { .topic-nav { max-width:640px; } }
@media(max-width:900px) {
  .textbook-layout { grid-template-columns:minmax(0,1fr); gap:14px; }
  .textbook-directory { padding:10px; }
  .textbook-directory h3 { margin-bottom:8px; }
  .textbook-pages { display:flex; max-height:none; overflow-x:auto; scroll-snap-type:x proximity; }
  .textbook-page { flex:0 0 116px; flex-direction:column; align-items:stretch; gap:6px; scroll-snap-align:start; }
  .textbook-page img { width:96px; height:62px; }
  .textbook-page small { display:none; }
  .textbook-stage { max-height:70vh; }
}
@media(max-width:480px) {
  .topic-tab { padding:12px 4px; } .topic-tab strong { font-size:13px; }
  .textbook-heading { align-items:flex-start; flex-direction:column; gap:10px; padding-top:10px; }
  .textbook-heading h2 { font-size:26px; }
  .textbook-toolbar { padding:10px; gap:6px; }
  .textbook-toolbar button, .textbook-toolbar a, .textbook-toolbar select { min-height:44px; padding:8px 10px; font-size:12px; }
  .textbook-toolbar select { flex:1; }
  .textbook-zoom { width:100%; justify-content:center; margin:0; }
  .textbook-zoom a { margin-left:auto; }
  .textbook-footer { align-items:flex-start; font-size:12px; }
}

html.textbook-fullscreen-open { overflow:hidden; }
.textbook-fullscreen { position:fixed; inset:0; width:100%; max-width:none; height:100%; height:100dvh; max-height:none; margin:0; padding:0; border:0; background:#000; color:#fff; overflow:hidden; }
.textbook-fullscreen::backdrop { background:#000; }
.textbook-fullscreen-bar { position:absolute; inset:0 0 auto; z-index:2; display:flex; align-items:center; justify-content:space-between; gap:12px; padding:calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); background:linear-gradient(#11151bc9, transparent); pointer-events:none; }
.textbook-fullscreen-bar strong { font-size:14px; font-weight:500; }
.textbook-fullscreen-image { position:absolute; inset:0; overflow:hidden; background:#000; }
.textbook-fullscreen-image img { display:block; width:100%; height:100%; max-width:none; object-fit:contain; object-position:center; margin:0; }
.textbook-fullscreen-image p { position:absolute; bottom:10px; left:0; right:0; margin:0; padding:10px; text-align:center; background:#11151be6; color:white; font-size:13px; }
.textbook-fullscreen-image p:empty { display:none; }
.textbook-fullscreen-arrow { position:absolute; top:50%; transform:translateY(-50%); z-index:2; display:grid; place-items:center; width:48px; height:64px; padding:0; border:1px solid #ffffff30; border-radius:12px; background:#303741e6; color:#fff; font-size:40px; line-height:1; }
.textbook-fullscreen-previous { left:max(12px, env(safe-area-inset-left)); }
.textbook-fullscreen-next { right:max(12px, env(safe-area-inset-right)); }
.textbook-fullscreen-arrow:disabled { opacity:.25; cursor:default; }
@media(max-width:600px) {
  .textbook-zoom { flex-wrap:wrap; }
  .textbook-fullscreen-arrow { top:auto; bottom:calc(12px + env(safe-area-inset-bottom)); transform:none; width:64px; height:48px; font-size:32px; }
  .textbook-fullscreen-previous { left:calc(50% - 80px); }
  .textbook-fullscreen-next { right:calc(50% - 80px); }
  .textbook-fullscreen-bar strong { font-size:12px; }
}
