/* The chapter reading room shares the site's existing colour tokens. */
body[data-page="chapter"] .workspace { padding-bottom: 110px; }
.reader-shell { max-width: 1200px; padding-top: 24px; }
.reader-topbar { margin-bottom: 22px; }
.reader-stage { display: grid; grid-template-columns: minmax(0, 1fr) 248px; gap: 34px; align-items: start; }
.reader-layout { min-width: 0; padding: 48px 54px 40px; border-radius: 14px; box-shadow: none; }
.reader-layout article { min-width: 0; }
.chapter-header { margin-bottom: 30px; }
.chapter-kicker { font-size: 11px; margin-bottom: 24px; letter-spacing: .03em; }
.chapter-header h1 { font: 400 clamp(36px, 3.8vw, 51px)/1.13 var(--serif); letter-spacing: -1.5px; max-width: 19ch; margin-bottom: 25px; }
.chapter-description { font-size: 16px; line-height: 1.85; margin-bottom: 26px; }
.chapter-meta { gap: 17px; font-size: 11px; }
.reader-actions { gap: 8px; padding-top: 20px; margin-top: 24px; }
.reader-actions button, .reader-actions .reader-offline-link { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 0 10px; font-size: 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--body); }
.reader-actions .reader-save { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.reader-actions :is(button, a):hover { background: var(--surface-soft); border-color: var(--accent); }
.chapter-guide { background: var(--surface-soft); margin-bottom: 37px; }
.chapter-guide > summary { padding: 14px 16px; font-size: 12px; }
.lesson-copy { max-width: 66ch; margin-inline: auto; font-size: calc(18px * var(--reader-scale)); line-height: 1.9; }
.lesson-copy p { margin-bottom: 1.45em; }
.lesson-copy h2 { margin-top: 2.5em; font-size: 1.4em; line-height: 1.45; letter-spacing: -.5px; }
.lesson-copy h3 { font-size: 1.15em; line-height: 1.5; }
.lesson-copy h2[tabindex="-1"]:focus-visible, .lesson-copy h3[tabindex="-1"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 8px; border-radius: 2px; }
.lesson-copy :is(.callout, .concept-note, .thought-check, .chapter-takeaway) { border-radius: 9px; }
.lesson-copy .callout { border-left: 3px solid var(--accent); }
.lesson-copy details summary { font-size: 13px; }
.lesson-copy .lesson-sources { font-size: 13px; }
.reader-outline { min-width: 0; align-self: stretch; }
.reader-outline-sticky { position: sticky; top: calc(var(--header) + 27px); display: flex; flex-direction: column; max-height: calc(100dvh - var(--header) - 138px); padding-top: 14px; }
.outline-caption { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 22px; color: var(--muted); font: 9px var(--mono); letter-spacing: .03em; }
.reader-outline h2 { font: 400 23px var(--serif); letter-spacing: -.4px; margin: 0 0 20px; }
.reader-outline nav { min-height: 70px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 3px 8px 3px 0; }
.reading-outline-links { display: grid; gap: 4px; list-style: none; padding: 0; margin: 0; }
.reading-outline-links a { display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: baseline; gap: 8px; padding: 10px 12px; border-left: 2px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.65; border-radius: 0 6px 6px 0; }
.reading-outline-links a:hover { color: var(--ink); background: var(--surface-hover); }
.reading-outline-links a[aria-current="location"] { border-left-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.outline-number { font: 10px var(--mono); color: var(--muted); }
.outline-reading-tip { display: flex; gap: 10px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--muted); }
.outline-reading-tip svg { width: 16px; height: 16px; margin-top: 3px; }
.outline-reading-tip p { font-size: 11px; line-height: 1.9; margin: 0; }
.outline-notebook { display: flex; align-items: center; gap: 8px; text-align: left; min-height: 44px; margin-top: 12px; padding: 0; color: var(--accent); font-size: 11px; }
.outline-notebook svg { width: 15px; height: 15px; }
.outline-notebook svg:last-child { margin-left: auto; }
.reading-dock { position: fixed; z-index: 35; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; width: min(850px, calc(100% - 40px)); padding: 10px 12px 10px 20px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); }
.reading-dock button { display: inline-flex; align-items: center; justify-content: center; min-width: 42px; height: 42px; border: 1px solid transparent; border-radius: 7px; color: var(--body); }
.reading-dock button:hover { color: var(--accent); background: var(--surface-soft); }
.reading-dock button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: var(--border); }
.reading-dock button:disabled { opacity: .3; }
.reading-dock svg { width: 18px; height: 18px; }
.dock-location { flex: 1; min-width: 0; }
.dock-location > span { display: block; color: var(--muted); font-size: 8px; font-weight: 600; letter-spacing: .12em; margin-bottom: 5px; }
.dock-location strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 500; }
.dock-progress { width: 56px; flex: 0 0 56px; color: var(--muted); text-align: right; font: 10px var(--mono); margin-inline: 7px; }
.dock-progress-track { height: 3px; background: var(--line); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.dock-progress-track i { display: block; width: 0; height: 100%; background: var(--accent); }
.dock-navigation { display: flex; gap: 3px; align-items: center; }
.dock-section-number { font: 10px var(--mono); color: var(--muted); white-space: nowrap; min-width: 42px; text-align: center; }
.dock-divider { height: 25px; border-left: 1px solid var(--border); margin-inline: 2px; }
.dock-button-label { display: none; }
.dock-aa { font: 22px var(--serif); letter-spacing: -1px; }
.chapter-outline-dialog { width: min(500px, calc(100% - 28px)); max-height: min(80dvh, 800px); margin: auto; padding: 28px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chapter-outline-dialog::backdrop { background: #151b2f70; }
.chapter-outline-dialog .dialog-head { margin-bottom: 0; }
.outline-dialog-title { font-size: 13px; line-height: 1.7; color: var(--muted); padding: 20px 0; margin: 0; border-bottom: 1px solid var(--line); }
.chapter-outline-dialog nav { margin-top: 17px; }
.chapter-outline-dialog .reading-outline-links a { font-size: 14px; min-height: 48px; }
.reading-preferences { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.reading-preferences label { display: grid; gap: 9px; font-size: 12px; color: var(--body); min-width: 0; }
.reading-preferences select { width: 100%; min-height: 44px; padding: 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 12px; }
.reading-width-options { padding: 0; margin: 22px 0 0; border: 0; }
.reading-width-options legend { padding: 0; margin-bottom: 10px; color: var(--body); font-size: 12px; }
.reading-choice-group { display: flex; gap: 6px; padding: 4px; background: var(--canvas); border: 1px solid var(--border); border-radius: 8px; }
.reading-choice-group button { flex: 1; min-height: 38px; border: 1px solid transparent; border-radius: 5px; color: var(--muted); font-size: 12px; }
.reading-choice-group button[aria-pressed="true"] { border-color: var(--border); background: var(--surface); color: var(--accent); font-weight: 600; }
.scroll-haptics-setting { margin-top: 22px; }
.scroll-haptics-setting label { display: block; color: var(--body); font-size: 12px; margin-bottom: 9px; }
.scroll-haptics-setting select { width: 100%; min-height: 44px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 12px; }
.scroll-haptics-setting select:disabled { opacity: .5; }
.scroll-haptics-setting p { margin: 12px 0 0; }
.haptics-status { margin-top: 16px; }
.haptics-test { min-height: 40px; padding: 0 15px; border: 1px solid var(--border); border-radius: 7px; color: var(--accent); font-size: 12px; }
.haptics-test:hover { background: var(--surface-soft); }
.reader-specific-settings .toggle-row { gap: 18px; }
.reader-specific-settings .toggle-row small { max-width: 260px; }
html[data-reading-font="serif"] .lesson-copy { font-family: var(--serif); }
html[data-reading-font="sans"] .lesson-copy { font-family: var(--sans); }
html[data-reading-spacing="relaxed"] .lesson-copy { line-height: 2.15; }
html[data-reading-spacing="relaxed"] .lesson-copy p { margin-bottom: 1.65em; }
html[data-reading-width="wide"] .reader-shell { max-width: 1280px; }
html[data-reading-width="wide"] .reader-layout { padding-inline: 38px; }
html[data-reading-width="wide"] .lesson-copy { max-width: 80ch; }
html.has-reader-tools .toast-region { bottom: calc(100px + env(safe-area-inset-bottom)); }
html.has-reader-tools .focus-exit { display: none !important; }
html.has-reader-tools { scroll-padding-bottom: 110px; }
html.focus-mode[data-focus-page="chapter"] .reader-stage { display: block; }
html.focus-mode[data-focus-page="chapter"] .reader-outline { display: none; }
html.focus-mode[data-focus-page="chapter"] .reader-shell { max-width: 860px; padding-top: 30px; }
html.focus-mode[data-focus-page="chapter"] .reader-layout { padding: 42px 54px; }
html.focus-mode[data-focus-page="chapter"] .chapter-guide { display: none; }
html[data-theme="epaper"] .reader-outline h2 { font-style: italic; }
html[data-theme="epaper"] .reading-dock { box-shadow: none; border-color: var(--muted); }
@media (max-width: 1100px) {
  .reader-stage { grid-template-columns: minmax(0, 1fr) 215px; gap: 24px; }
  .reader-layout { padding: 38px 35px; }
  .reader-actions { gap: 7px; }
  .chapter-header h1 { font-size: 41px; }
}
@media (max-width: 1000px) {
  .reader-shell { max-width: 820px; }
  .reader-stage { display: block; }
  .reader-outline { display: none; }
  .reader-layout { padding: 42px; }
  .chapter-header h1 { max-width: 24ch; font-size: 44px; }
}
@media (max-width: 620px) {
  body[data-page="chapter"] .workspace { width: calc(100% - 28px); padding-bottom: 100px; }
  .reader-shell { padding-top: 14px; }
  .reader-topbar { margin: 0 4px 15px; }
  .reader-topbar > a, .reader-topbar > button { font-size: 11px; }
  .reader-layout { margin: 0; padding: 29px 22px; border-radius: 11px; }
  .chapter-kicker { font-size: 10px; gap: 10px; margin-bottom: 21px; }
  .chapter-kicker > span + span { padding-left: 10px; }
  .chapter-header h1 { font-size: clamp(32px, 8.8vw, 40px); letter-spacing: -1px; }
  .chapter-description { font-size: 15px; line-height: 1.85; }
  .chapter-meta { gap: 10px 13px; font-size: 10px; }
  .reader-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .reader-actions button, .reader-actions .reader-offline-link { min-height: 44px; padding-inline: 8px; font-size: 11px; }
  .lesson-copy { font-size: calc(17px * var(--reader-scale)); line-height: 1.95; }
  .lesson-copy h2 { font-size: 1.32em; }
  .chapter-guide { margin-bottom: 29px; }
  .chapter-guide > summary { padding: 12px; font-size: 11px; gap: 8px; }
  .chapter-guide > summary > small { font-size: 9px; }
  .reading-dock { gap: 2px; bottom: max(10px, env(safe-area-inset-bottom)); width: calc(100% - 24px); max-width: 440px; justify-content: space-between; padding: 7px; border-radius: 11px; }
  .dock-location, .dock-progress, .dock-divider { display: none; }
  .reading-dock button { min-width: 39px; width: 39px; height: 49px; }
  .reading-dock > button { flex-direction: column; gap: 3px; }
  .dock-button-label { display: block; font: 8px var(--sans); }
  .reading-dock .dock-aa { font-size: 20px; line-height: 18px; }
  .dock-navigation { gap: 0; }
  .dock-section-number { min-width: 39px; font-size: 9px; }
  .chapter-outline-dialog { padding: 23px; }
  .chapter-outline-dialog .dialog-head h2 { font-size: 24px; }
  .chapter-end-top > .button { width: 100%; }
  html[data-reading-width="wide"] .reader-layout { padding-inline: 17px; }
  html.focus-mode[data-focus-page="chapter"] .reader-layout { padding: 25px 15px; }
  html.focus-mode[data-focus-page="chapter"] .reader-shell { padding-top: 10px; }
}
@media print {
  .reader-outline, .reading-dock, .chapter-outline-dialog { display: none !important; }
  .reader-stage { display: block; }
  .reader-shell, .reader-layout, html[data-reading-width="wide"] .reader-layout { width: 100%; max-width: none; border: 0; padding: 0; }
  body[data-page="chapter"] .workspace { padding-bottom: 0; }
  .chapter-header h1 { max-width: none; font-size: 28pt; }
  .lesson-copy { max-width: none; font-size: 11pt; }
}
