.textbook-page {
  --reader-paper: #fff;
  --reader-yellow: #ffeb00;
  --reader-muted: #677364;
  margin: 0;
  overflow: hidden;
  background: var(--bg-color);
  font-family: var(--font-main);
  color: var(--text-main);
  font-size: 14px;
}
.textbook-page *, .textbook-page *::before, .textbook-page *::after { box-sizing: border-box; }
.textbook-page button, .textbook-page select { font: inherit; }
.textbook-page button { cursor: pointer; }
.textbook-page button:disabled { cursor: default; opacity: .45; }
.textbook-page button:focus-visible, .textbook-page a:focus-visible, .textbook-page select:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 3px; }
.textbook-page [hidden] { display: none !important; }
.reader-shell { display: grid; grid-template-columns: 244px minmax(0,1fr); height: 100vh; height: 100dvh; }
.reader-shell.is-sidebar-closed { grid-template-columns: 0 minmax(0,1fr); }
.reader-sidebar { display: flex; flex-direction: column; min-width: 0; padding: 24px 16px 16px; background: var(--panel-bg); border-right: 1px solid var(--border-color); overflow: auto; }
.is-sidebar-closed .reader-sidebar { visibility: hidden; padding: 0; }
.reader-brand { display: flex; align-items: center; gap: 10px; color: var(--text-main); text-decoration: none; font-size: 20px; font-weight: 750; white-space: nowrap; }
.reader-brand img { width: 36px; height: 36px; object-fit: contain; }
.reader-brand small { display: block; color: var(--reader-muted); font-size: 12px; font-weight: 500; margin-top: 2px; }
.reader-book-name { font-size: 19px; font-weight: 700; margin: 35px 10px 26px; }
.reader-directory-label { margin: 0 10px 13px; color: var(--reader-muted); font-size: 13px; }
.reader-chapter { display: flex; align-items: center; gap: 10px; margin: 0 10px 14px; font-size: 15px; }
.reader-chapter > span { font-size: 12px; color: var(--primary-color); background: var(--primary-light); padding: 4px 6px; border-radius: 4px; }
.reader-pairs { display: grid; gap: 5px; }
.reader-pair-button { border: 0; background: transparent; color: var(--text-main); text-align: left; padding: 13px 12px; border-radius: 5px; transition: background 160ms ease, transform 120ms ease; }
.reader-pair-button:hover { background: var(--bg-color); }
.reader-pair-button[aria-current="page"] { background: var(--primary-light); color: var(--primary-color); }
.reader-pair-button:active { transform: translateX(2px); }
.reader-pair-button strong { display: block; font-size: 14px; font-weight: 600; }
.reader-pair-button small { display: block; margin-top: 6px; color: var(--reader-muted); font-size: 12px; }
.reader-sidebar-bottom { margin-top: auto; padding: 24px 10px 8px; display: grid; gap: 10px; color: var(--reader-muted); font-size: 12px; line-height: 1.6; }
.reader-layer-key { display: flex; align-items: center; gap: 7px; }
.reader-layer-key i { width: 12px; height: 12px; display: inline-block; background: var(--reader-yellow); border-radius: 2px; }
.reader-main { display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; min-width: 0; min-height: 0; }
/* 阅读器沿用全站缩放值，但用完整舞台缩放，避免 Safari 的 body zoom 撑宽页面。 */
html body.textbook-page { zoom: 1 !important; width: 100vw !important; min-width: 100vw !important; max-width: 100vw !important; height: 100dvh !important; min-height: 100dvh !important; overflow: hidden !important; overscroll-behavior: none !important; }
.textbook-page .reader-shell { position: fixed; top: 0; left: 0; width: calc(100vw / var(--study-page-zoom,1)); height: calc(100dvh / var(--study-page-zoom,1)); transform: scale(var(--study-page-zoom,1)); transform-origin: top left; overflow: hidden; }
.textbook-page > .account-sync-panel,.textbook-page > .account-sync-backdrop { zoom: 1; }
.reader-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px; background: var(--panel-bg); }
.reader-heading { display: flex; align-items: center; gap: 13px; min-width: 0; }
.reader-heading h1 { font-size: 22px; font-weight: 750; line-height: 1.2; margin: 0; }
.reader-heading p { font-size: 13px; color: var(--reader-muted); line-height: 1.5; margin: 5px 0 0; }
.reader-icon-button { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 7px; border: 0; background: transparent; border-radius: 5px; color: var(--text-main); transition: background 140ms ease, transform 100ms ease; flex: 0 0 auto; }
.reader-icon-button:hover { background: var(--primary-light); }
.reader-icon-button:active { transform: scale(.96); }
.reader-icon-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.reader-site-nav { display: flex; gap: 4px; }
.reader-site-nav a { text-decoration: none; color: var(--reader-muted); padding: 9px 13px; border-radius: 5px; font-weight: 550; }
.reader-site-nav a:hover { color: var(--primary-color); background: var(--bg-color); }
.reader-site-nav a.is-active { background: var(--primary-light); color: var(--primary-color); }
.reader-toolbar { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; min-height: 66px; padding: 12px 24px; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); background: var(--panel-bg); }
.reader-segmented { position: relative; display: flex; gap: 2px; padding: 3px; background: var(--bg-color); border-radius: 5px; flex: 0 0 auto; }
.reader-segmented button { position: relative; z-index: 1; border: 0; background: transparent; color: var(--reader-muted); padding: 8px 12px; border-radius: 3px; font-size: 13px; white-space: nowrap; }
.reader-segmented button[aria-pressed="true"] { color: var(--primary-color); font-weight: 650; }
.reader-segment-indicator { position: absolute; top: 3px; bottom: 3px; left: 3px; background: var(--panel-bg); border-radius: 3px; box-shadow: 0 1px 3px rgba(35,51,34,.08); transition: transform 180ms ease-out, width 180ms ease-out; }
.reader-checkbox { display: flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 13px; cursor: pointer; }
.reader-checkbox input { accent-color: var(--primary-color); width: 15px; height: 15px; margin: 0; }
.reader-toolbar-right { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.reader-quality-label { color: var(--reader-muted); font-size: 12px; }
.reader-toolbar select { border: 1px solid var(--border-color); border-radius: 4px; padding: 7px 9px; background: var(--panel-bg); color: var(--text-main); font-size: 13px; min-height: 34px; }
.reader-enlarge-button { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border-color); background: var(--panel-bg); color: var(--primary-color); border-radius: 4px; padding: 8px 10px; font-size: 13px; white-space: nowrap; }
.reader-enlarge-button svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; }
.reader-enlarge-button:hover { background: var(--primary-light); }
.reader-highlight-button { background: var(--primary-color); color: white; border: 0; border-radius: 4px; padding: 9px 13px; transition: background 140ms ease, transform 100ms ease; white-space: nowrap; font-size: 13px; }
.reader-highlight-button:hover { background: var(--primary-hover); }
.reader-highlight-button:active { transform: scale(.97); }
.reader-scroller { overflow: auto; padding: 24px 24px 32px; min-height: 0; position: relative; background: #eef2eb; scrollbar-gutter: stable; }
.reader-spread { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px; align-items: start; margin: 0 auto; width: max-content; min-width: 100%; }
.reader-spread.is-single { grid-template-columns: minmax(0,1fr); min-width: min(100%,860px); }
.reader-page-column { min-width: 0; }
.reader-page-label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; font-size: 14px; color: var(--text-main); }
.reader-page-label strong { font-weight: 650; }
.reader-page-label span { color: var(--reader-muted); font-size: 12px; }
.reader-page-window { position: relative; overflow: hidden; background: var(--reader-paper); box-shadow: 0 2px 10px rgba(31,52,25,.07); }
.reader-page-surface { position: relative; background: var(--reader-paper); }
.reader-page-surface canvas { display: block; }
.reader-page-surface .textLayer { position: absolute; inset: 0; z-index: 2; }
.reader-page-surface .textLayer ::selection { background: rgba(88,153,218,.32); }
.reader-highlight-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.reader-mark { position: absolute; background: rgba(251,213,59,.42); mix-blend-mode: multiply; border-radius: 1px; }
.reader-mark:not(.personal) { background: rgba(255,235,0,.72); }
.reader-mark.is-subtle { background: rgba(162,166,160,.17); }
.reader-change-range { position: absolute; border: 2px solid #e5c900; background: rgba(255,235,0,.14); border-radius: 1px; }
.reader-change-range.is-selected { background: rgba(255,235,0,.24); }
.reader-change-range.is-removed { border-color: #8e958b; border-style: dashed; background: rgba(162,166,160,.06); }
.reader-change-range-label {
  position: absolute;
  top: 0;
  right: 0;
  transform: translateX(calc(100% + 4px));
  padding: 1px 6px;
  background: rgba(255, 235, 0, 0.4);
  color: rgba(81, 71, 0, 0.8);
  font-size: 11px;
  line-height: 16px;
  white-space: nowrap;
  border-radius: 3px;
  border: 1px solid rgba(229, 201, 0, 0.5);
  pointer-events: auto;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 180ms ease, background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  z-index: 2;
  user-select: none;
}
.reader-change-range-label:hover,
.reader-change-range.is-selected .reader-change-range-label {
  opacity: 1;
  background: #ffeb00;
  color: #514700;
  border-color: #e5c900;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.reader-change-range.is-near-right .reader-change-range-label {
  transform: none;
}
.is-removed .reader-change-range-label {
  background: rgba(238, 240, 237, 0.6);
  color: #606b5c;
  border-color: rgba(142, 149, 139, 0.4);
}
.reader-change-range.is-removed .reader-change-range-label:hover,
.reader-change-range.is-removed.is-selected .reader-change-range-label {
  opacity: 1;
  background: #eef0ed;
  color: #606b5c;
  border-color: #8e958b;
}
body.textbook-page.dark-theme .reader-change-range-label {
  background: rgba(255, 235, 0, 0.3);
  color: #ffe853;
  border-color: rgba(229, 201, 0, 0.4);
}
body.textbook-page.dark-theme .reader-change-range-label:hover,
body.textbook-page.dark-theme .reader-change-range.is-selected .reader-change-range-label {
  background: #ffeb00;
  color: #352d00;
}
body.textbook-page.dark-theme .is-removed .reader-change-range-label {
  background: rgba(60, 75, 70, 0.6);
  color: #cbd5d1;
  border-color: rgba(142, 149, 139, 0.4);
}
body.textbook-page.dark-theme .reader-change-range.is-removed .reader-change-range-label:hover,
body.textbook-page.dark-theme .reader-change-range.is-removed.is-selected .reader-change-range-label {
  background: #465a54;
  color: #eef2f0;
}
.reader-fragment-page { position: absolute; bottom: 5px; right: 10px; color: #677364; font-size: 11px; padding: 2px 5px; background: rgba(255,255,255,.85); }
.reader-mark.personal { background: rgba(251,221,71,.36); border-bottom: 1px solid rgba(179,135,11,.25); animation: reader-mark-in 180ms ease-out; }
.reader-spread.is-entering { animation: reader-page-in 230ms ease-out both; }
@keyframes reader-page-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes reader-mark-in { from { opacity: .2; } to { opacity: 1; } }
.reader-difference-note { margin: 22px auto 0; color: var(--text-main); font-size: 14px; line-height: 1.8; max-width: 850px; }
.reader-difference-note strong { display: block; margin-bottom: 4px; }
.reader-difference-note mark { background: var(--reader-yellow); padding: 1px 3px; }
.reader-loading, .reader-error { text-align: center; padding: 70px 20px; color: var(--reader-muted); font-size: 15px; }
.reader-loading span { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--primary-light); border-top-color: var(--primary-color); border-radius: 50%; vertical-align: -3px; margin-right: 9px; animation: reader-spin 900ms linear infinite; }
@keyframes reader-spin { to { transform: rotate(360deg); } }
.reader-error button { border: 1px solid var(--border-color); border-radius: 4px; background: var(--panel-bg); padding: 9px 15px; color: var(--primary-color); }
.reader-selection-toolbar { position: fixed; z-index: 80; display: flex; gap: 1px; background: var(--text-main); border-radius: 5px; box-shadow: 0 4px 16px rgba(0,0,0,.16); padding: 4px; }
.reader-selection-toolbar button { border: 0; background: transparent; color: #fff; padding: 8px 12px; font-size: 13px; border-radius: 3px; }
.reader-selection-toolbar button:hover { background: rgba(255,255,255,.15); }
.reader-toast { position: fixed; left: 50%; bottom: 75px; transform: translateX(-50%); max-width: calc(100% - 32px); z-index: 90; background: var(--text-main); color: #fff; font-size: 13px; line-height: 1.6; padding: 10px 16px; border-radius: 5px; box-shadow: 0 3px 12px rgba(0,0,0,.1); }
.reader-main { grid-template-rows: auto auto auto minmax(0,1fr) auto; }
.reader-sidebar { overflow: hidden; }
.reader-chapters { display: grid; gap: 4px; margin: 0 2px 22px; }
.reader-chapter-button { border: 0; background: transparent; text-align: left; padding: 11px 9px; color: var(--text-main); font-weight: 650; border-radius: 4px; line-height: 1.5; }
.reader-chapter-button[aria-current="true"] { background: var(--primary-light); color: var(--primary-color); }
.reader-pairs { flex: 1; min-height: 0; overflow: auto; display: block; }
.reader-pair-button { width: 100%; margin-bottom: 5px; }
.reader-pair-button[aria-current="true"] { background: var(--primary-light); }
.reader-workspace { min-height: 0; overflow: hidden; position: relative; background: #eef2eb; }
.reader-spread { width: 100%; min-width: 0; height: 100%; gap: 2px; padding: 0; align-items: stretch; }
.reader-spread.is-single { min-width: 0; }
.reader-page-column { min-height: 0; height: 100%; overflow: hidden; display: grid; grid-template-rows: auto minmax(0,1fr); }
.reader-page-label { min-height: 44px; margin: 0; padding: 4px 9px 8px; }
.reader-pane-controls { display: flex; align-items: center; gap: 7px; }
.reader-pane-controls button { border: 1px solid var(--border-color); background: var(--panel-bg); color: var(--primary-color); width: 30px; height: 30px; border-radius: 4px; font-size: 22px; line-height: 1; }
.reader-pane-controls select { border: 1px solid var(--border-color); background: var(--panel-bg); border-radius: 4px; height: 30px; font-size: 12px; color: var(--text-main); padding: 3px 6px; }
.reader-pane-scroll { min-height: 0; overflow: auto; padding: 0; overscroll-behavior: contain; scrollbar-gutter: stable; border: 0; background: #e9eee5; }
.reader-page-window { margin: 0 auto; }
.reader-page-slot { position: relative; background: white; margin-inline: auto; overflow: hidden; }
.reader-page-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--reader-muted); font-size: 13px; background: #fff; }
.reader-ink-surface { position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; pointer-events: none; touch-action: none; }
.reader-ink-surface.is-writing { pointer-events: auto; cursor: crosshair; }
.reader-ink-surface[data-tool="eraser"] { cursor: cell; }
.reader-ink-toolbar { display: flex; align-items: center; gap: 14px; min-height: 49px; padding: 7px 24px; background: var(--panel-bg); border-bottom: 1px solid var(--border-color); }
.reader-ink-tools { display: flex; gap: 2px; }
.reader-ink-toolbar button, .reader-import-label { border: 0; border-radius: 4px; background: transparent; color: var(--reader-muted); padding: 7px 9px; font-size: 13px; white-space: nowrap; transition: background 120ms ease; }
.reader-ink-tools button[aria-pressed="true"] { background: var(--primary-light); color: var(--primary-color); font-weight: 650; }
.reader-ink-toolbar button:hover { background: var(--bg-color); }
.reader-colors { display: flex; align-items: center; gap: 5px; }
.reader-colors button { background: var(--ink-color); border: 3px solid var(--panel-bg); outline: 1px solid transparent; padding: 0; width: 21px; height: 21px; border-radius: 50%; }
.reader-colors button[aria-pressed="true"] { outline-color: var(--ink-color); }
.reader-colors button:hover { background: var(--ink-color); }
.reader-ink-toolbar select { border: 1px solid var(--border-color); border-radius: 4px; background: var(--panel-bg); color: var(--text-main); padding: 5px; font-size: 12px; }
.reader-backup-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.reader-import-label { position: relative; overflow: hidden; cursor: pointer; }
.reader-import-label input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.reader-save-status { color: var(--reader-muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.reader-save-status[data-state="failed"] { color: #b22a25; }
@media(max-width:768px) {
  .reader-ink-toolbar { gap: 9px; padding: 6px 14px; flex-wrap: wrap; }
  .reader-ink-toolbar .reader-checkbox { font-size: 11px; }
  .reader-backup-tools { margin-left: auto; }
  .reader-ink-toolbar button, .reader-import-label { font-size: 12px; padding: 6px 7px; }
  .reader-colors button { padding: 0; }
  .reader-pane-scroll { padding: 0; scrollbar-gutter: stable; }
  .reader-spread { padding: 0; gap: 2px; }
  .reader-page-label { padding: 4px 4px 8px; font-size: 12px; }
  .reader-pane-controls { gap: 4px; }
  .reader-pane-controls button { width: 27px; }
  .reader-pane-controls select { max-width: 96px; }
}
.reader-sidebar-scrim { position: fixed; inset: 0; border: 0; background: rgba(20,32,19,.22); z-index: 59; }
.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; }
@media (max-width: 1100px) {
  .reader-shell { grid-template-columns: 205px minmax(0,1fr); }
  .reader-sidebar { padding-inline: 12px; }
  .reader-header, .reader-toolbar { padding-inline: 18px; }
  .reader-toolbar { gap: 12px; }
  .reader-toolbar-right { gap: 7px; }
  .reader-quality-label { display: none; }
  .reader-scroller { padding: 18px; }
}
@media (max-width: 768px) {
  .reader-shell, .reader-shell.is-sidebar-closed { grid-template-columns: minmax(0,1fr); }
  .reader-sidebar, .is-sidebar-closed .reader-sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 268px; padding: 24px 16px 16px; z-index: 60; transform: translateX(-100%); visibility: hidden; transition: transform 190ms ease-out, visibility 190ms; }
  .reader-shell.is-mobile-sidebar-open .reader-sidebar { transform: translateX(0); visibility: visible; }
  .reader-header { padding: 14px 14px 12px; gap: 10px; flex-wrap: wrap; }
  .reader-heading { gap: 9px; }
  .reader-heading h1 { font-size: 19px; }
  .reader-heading p { font-size: 12px; }
  .reader-site-nav { margin-left: auto; }
  .reader-site-nav a { padding: 8px 9px; font-size: 13px; }
  .reader-toolbar { padding: 10px 14px; gap: 10px 14px; }
  .reader-toolbar-right { margin-left: 0; flex: 1 0 auto; }
  .reader-enlarge-button { width: 32px; height: 34px; padding: 7px; justify-content: center; }
  .reader-enlarge-button span { display: none; }
  .reader-segmented button { padding: 7px 10px; font-size: 12px; }
  .reader-checkbox { font-size: 12px; }
  .reader-toolbar select { font-size: 12px; }
  .reader-scroller { padding: 16px 12px 25px; scrollbar-gutter: auto; }
  .reader-spread { gap: 14px; }
  .reader-page-label { font-size: 13px; margin-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .textbook-page *, .textbook-page *::before, .textbook-page *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.reader-main { grid-template-rows: auto minmax(0,1fr) auto; }
.reader-header { position: relative; min-height: 60px; padding: 9px 14px; gap: 12px; justify-content: flex-start; flex-wrap: wrap; }
.reader-heading { gap: 7px; }
.reader-heading h1 { font-size: 17px; white-space: nowrap; }
.reader-header .reader-segmented button { padding: 7px 10px; }
.reader-main-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.reader-main-actions select { border: 1px solid var(--border-color); border-radius: 4px; background: var(--panel-bg); color: var(--text-main); padding: 6px 7px; font-size: 12px; height: 32px; }
.reader-annotation-button,.reader-more-button { border: 0; border-radius: 4px; background: var(--bg-color); color: var(--reader-muted); padding: 7px 10px; min-height: 32px; font-size: 13px; }
.reader-annotation-button.is-active { color: var(--primary-color); background: var(--primary-light); }
.reader-more-button { font-size: 22px; line-height: .7; width: 32px; padding: 5px; }
.reader-popover { position: absolute; top: calc(100% + 5px); right: 12px; z-index: 70; padding: 9px; background: var(--panel-bg); border: 1px solid var(--border-color); border-radius: 6px; box-shadow: 0 5px 18px rgba(30,45,25,.12); max-width: calc(100vw - 24px); animation: reader-popover-in 140ms ease-out; }
@keyframes reader-popover-in { from { opacity: .3; transform: translateY(-3px); } to { opacity: 1; transform: translateY(0); } }
.reader-annotation-popover { width: 340px; }
.reader-popover .reader-ink-toolbar { padding: 1px; gap: 10px; min-height: 0; flex-wrap: wrap; border: 0; }
.reader-more-popover { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; width: 245px; font-size: 13px; }
.reader-more-popover select { max-width: 125px; padding: 6px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--panel-bg); }
.reader-more-popover .reader-backup-tools { width: 100%; justify-content: flex-start; }
.reader-layer-options { display: flex; gap: 12px; width: 100%; grid-column: 1 / -1; padding: 5px 0; }
.reader-more-popover button { border: 0; color: var(--reader-muted); background: var(--bg-color); padding: 7px; border-radius: 4px; font-size: 12px; }
.reader-sidebar-bottom { margin-top: auto; }
.reader-sidebar-bottom .reader-site-nav { display: flex; gap: 0; }
.reader-sidebar-bottom .reader-site-nav a { font-size: 12px; padding: 7px 8px; }
.reader-sidebar-bottom .reader-site-nav a:first-child { padding-left: 0; }
@media(max-width:768px){
  .reader-header { gap: 8px; padding: 7px 9px; }
  .reader-heading h1 { font-size: 15px; }
  .reader-heading { flex: 1; }
  .reader-header .reader-checkbox { font-size: 12px; }
  .reader-header .reader-segmented button { padding: 6px 8px; font-size: 12px; }
  .reader-main-actions { margin-left: 0; }
}
.reader-main { grid-template-rows: auto auto minmax(0,1fr) auto; }
.reader-header { min-height: 75px; padding: 14px 24px; justify-content: space-between; }
.reader-heading h1 { font-size: 22px; }
.reader-header .reader-site-nav { margin-left: auto; }
.reader-controls-bar { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 16px; min-height: 48px; padding: 7px 20px; background: var(--panel-bg); border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); }
.reader-page-column { display: block; position: relative; }
.reader-pane-scroll { position: relative; z-index: 0; width: 100%; height: 100%; }
.reader-edition-watermark { position: absolute; top: 8px; left: 10px; z-index: 10; color: rgba(40,55,34,.43); font-weight: 600; font-size: 17px; line-height: 1; pointer-events: none; user-select: none; padding: 4px 5px; background: rgba(255,255,255,.38); border-radius: 3px; }
@media(max-width:768px){
  .reader-header { padding: 10px 12px; min-height: 66px; }
  .reader-heading h1 { font-size: 19px; }
  .reader-header .reader-heading { flex: 0 1 auto; }
  .reader-header .reader-site-nav { margin-left: auto; }
  .reader-controls-bar { padding: 6px 10px; gap: 8px 10px; }
  .reader-controls-bar .reader-main-actions { margin-left: auto; }
  .reader-edition-watermark { font-size: 15px; }
}

/* 导航、品牌和章节条目直接使用全站样式；这里仅约束阅读器的可滚动区域。 */
.reader-shell { grid-template-columns: var(--study-sidebar-width,292px) minmax(0,1fr); }
.textbook-page .reader-sidebar.sidebar { width: var(--study-sidebar-width,292px) !important; flex-basis: var(--study-sidebar-width,292px) !important; padding: 0; overflow: visible; min-height: 0; position: relative; }
.reader-sidebar-header { flex: 0 0 auto; }
.textbook-page .reader-sidebar-close { display: none !important; }
.reader-sidebar .study-navigation { flex: 0 0 auto; }
.reader-sidebar .subject-toggle-btn { text-decoration: none; }
.reader-directory { min-height: 0; }
.reader-directory #reader-chapters { flex: 0 0 auto; display: grid; gap: 2px; }
.reader-directory .reader-chapter-button { width: 100%; background: transparent; border: 0; text-align: left; }
.reader-directory .reader-pairs { margin-top: 7px; }
.reader-directory .reader-directory-label { margin: 18px 10px 8px; }
.reader-sidebar .reader-sidebar-bottom { flex: 0 0 auto; padding: 12px 24px; border-top: 1px solid var(--border-color); }
.textbook-top-bar { min-width: 0; gap: 10px; padding: 0 14px; }
.textbook-top-bar .top-mode-tabs { flex: 0 0 auto; min-width: 0; }
.textbook-top-bar .top-bar-left { flex: 1 1 0; min-width: 0; }
.textbook-top-bar .current-chapter-info { min-width: 0; }
.textbook-top-bar .current-chapter-info h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.textbook-top-bar .top-bar-right { flex: 0 0 auto; }
.reader-more-popover #reader-help { grid-column: 1 / -1; justify-self: start; padding: 5px 0; border: 0; background: transparent; color: var(--primary-color); }
.reader-page-warning { position: absolute; z-index: 5; bottom: 4px; left: 6px; right: 6px; padding: 5px 8px; border-radius: 5px; color: var(--text-main); background: var(--panel-bg); font-size: 12px; line-height: 1.5; }
.reader-help-popover { width: 320px; font-size: 13px; line-height: 1.7; }
.reader-help-popover p { margin: 8px 0 0; }
.textbook-top-bar .reader-menu-button { width: 34px; height: 34px; display: none; align-items: center; justify-content: center; padding: 7px; }
.reader-menu-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
#reader-mobile-chapter { display: none; }
.is-sidebar-closed #reader-menu, .is-sidebar-closed .textbook-top-bar .reader-menu-button { display: inline-flex !important; }
@media (min-width:769px) and (max-width:1180px) {
  .reader-shell { grid-template-columns: var(--study-sidebar-tablet-width,246px) minmax(0,1fr); }
  .textbook-page .reader-sidebar.sidebar { width: var(--study-sidebar-tablet-width,246px) !important; flex-basis: var(--study-sidebar-tablet-width,246px) !important; }
  .textbook-top-bar .current-chapter-info { display: none; }
  .textbook-top-bar .top-bar-left { flex: 0 0 auto; }
  .textbook-top-bar .top-mode-tabs { flex: 1 1 auto; overflow-x: auto; }
}
@media (min-width:769px) {
  .reader-shell.is-sidebar-closed { grid-template-columns: 0 minmax(0,1fr); }
}
@media (max-width:768px) {
  .reader-shell,.reader-shell.is-sidebar-closed { grid-template-columns: minmax(0,1fr); }
  .textbook-page .reader-sidebar.sidebar { position: fixed; width: min(86vw,320px) !important; flex-basis: auto !important; }
  .reader-sidebar .sidebar-toggle-trigger { display: none !important; }
  .textbook-page .reader-sidebar-close { display: inline-flex !important; align-items: center; justify-content: center; margin-left: auto; width: 30px; height: 30px; padding: 5px; border: 0; background: transparent; color: var(--text-muted); }
  .textbook-top-bar .current-chapter-info { display: none; }
  .textbook-top-bar .top-bar-left { flex: 0 0 auto; }
  .textbook-top-bar .top-mode-tabs { flex: 1 1 auto; }
  .textbook-top-bar .reader-menu-button { display: inline-flex; }
  .reader-controls-bar > #reader-enlarge { position: absolute; top: calc(100% + 10px); right: 12px; z-index: 20; width: 40px; height: 40px; background: var(--panel-bg); border: 1px solid var(--border-color); border-radius: 50%; box-shadow: 0 2px 6px rgba(30,45,25,.10); }
  .reader-controls-bar > #reader-enlarge[aria-pressed="true"] { color: var(--primary-color); background: var(--primary-light); }
  .reader-controls-bar { flex-wrap: nowrap; gap: 8px; }
  .reader-controls-bar .reader-main-actions { gap: 5px; }
  .reader-more-popover { display: grid; grid-template-columns: 42px minmax(0,1fr); }
  .reader-more-popover select { width: 100%; max-width: none; }
  .reader-more-popover .reader-backup-tools { grid-column: 1 / -1; }
}

/* 说明收在书页上方，底部全部留给可连续滚动的教材。 */
.reader-main { grid-template-rows: auto auto auto minmax(0,1fr); }
.reader-workspace { grid-row: 4; }
.reader-context-bar { grid-row: 3; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 5px 20px; background: var(--panel-bg); color: var(--reader-muted); font-size: 12px; }
#reader-change-filter { flex: 0 0 auto; max-width: 122px; height: 28px; padding: 3px 5px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--panel-bg); color: var(--text-main); font-size: 12px; }
#reader-diff-count { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
#reader-change-summary { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.6; }
.reader-slot-content { position: relative; }
.reader-fragment-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 32px; padding: 0 10px 0 42px; color: var(--reader-muted); background: var(--panel-bg); font-size: 12px; line-height: 1.4; }
.reader-fragment-heading span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-fragment-heading span:last-child { flex-shrink: 0; font-size: 11px; }
.reader-more-popover .reader-save-status { margin: 0; grid-column: 1 / -1; }
@media(max-width:768px) {
  .reader-context-bar { flex-wrap: wrap; gap: 4px 8px; padding: 4px 10px 6px; }
  #reader-change-summary { flex: 1 1 100%; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 11px; line-height: 1.5; }
  .reader-fragment-heading { padding-left: 38px; gap: 6px; font-size: 11px; }
  .reader-controls-bar:has(+ .reader-context-bar:not([hidden])) > #reader-enlarge { top: calc(100% + 88px); }
}

/* 白纸与淡青色工作台：书页保持原色，控件使用同一组轻量颜色。 */
body.textbook-page {
  --bg-color: #f5faf9; --panel-bg: #fff; --primary-color: #137c70;
  --primary-light: #e5f5ef; --primary-hover: #10675d;
  --text-main: #263d3c; --text-muted: #667f7c; --reader-muted: #667f7c;
  --border-color: #e2ece9; --reader-desk: #edf3f4;
  --glass-bg: rgba(255,255,255,.94); --glass-border: #e2ece9;
  --shadow-sm: 0 1px 3px rgba(25,66,57,.035);
  --shadow-md: 0 6px 18px rgba(25,66,57,.05);
}
body.textbook-page.dark-theme {
  --bg-color: #162625; --panel-bg: #1d302e; --primary-color: #7ad8bd;
  --primary-light: #2a443c; --primary-hover: #9be4ce;
  --text-main: #e4efeb; --text-muted: #a2b9b2; --reader-muted: #a2b9b2;
  --border-color: #334b45; --reader-desk: #14211f;
  --glass-bg: rgba(29,48,46,.96); --glass-border: #334b45;
}
.textbook-page .reader-sidebar.sidebar { background: var(--panel-bg); border-radius: 0; box-shadow: none; }
.textbook-top-bar .top-mode-tab { font-weight: 600; }
.textbook-top-bar .current-chapter-info h2 { font-size: 17px; font-weight: 650; letter-spacing: .02em; }
.reader-controls-bar { gap: 14px; padding-block: 7px; border-top: 0; }
.reader-segmented { background: var(--bg-color); padding: 3px; border-radius: 7px; }
.reader-segment-indicator { display: none; }
.reader-segmented button { min-width: 34px; border-radius: 5px; transition: background 130ms ease, color 130ms ease; }
.reader-segmented button[aria-pressed="true"] { background: var(--panel-bg); box-shadow: 0 1px 4px rgba(32,72,61,.08); }
.reader-segmented button:active,.reader-main-actions button:active { transform: translateY(1px); }
.reader-main-actions select { background: var(--bg-color); border-color: transparent; border-radius: 6px; }
.reader-annotation-button,.reader-more-button,.reader-fullscreen-button { background: transparent; color: var(--text-muted); border: 0; border-radius: 6px; min-height: 34px; }
.reader-annotation-button:hover,.reader-more-button:hover,.reader-fullscreen-button:hover { background: var(--bg-color); color: var(--primary-color); }
.reader-annotation-button.is-active,.reader-fullscreen-button[aria-pressed="true"] { background: var(--primary-light); color: var(--primary-color); }
.reader-fullscreen-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 6px 8px; white-space: nowrap; font-size: 13px; }
.reader-fullscreen-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.reader-workspace,.reader-pane-scroll { background: var(--reader-desk); }
.reader-spread { gap: 8px; }
.reader-page-window { box-shadow: none; }
.reader-context-bar { padding-top: 4px; padding-bottom: 6px; }
#reader-change-filter { background: var(--bg-color); border-color: transparent; border-radius: 5px; }
.reader-fragment-heading { background: var(--panel-bg); color: var(--text-muted); }
.reader-edition-watermark { background: rgba(255,255,255,.75); color: #698780; font-weight: 600; }
.reader-popover { border-radius: 12px; padding: 16px; box-shadow: 0 10px 32px rgba(32,66,57,.13); }
.reader-annotation-popover { width: 330px; }
.reader-annotation-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.reader-annotation-heading strong { font-size: 15px; font-weight: 650; }
.reader-annotation-heading button { border: 0; background: var(--primary-light); color: var(--primary-color); border-radius: 5px; padding: 5px 10px; font-size: 12px; }
.reader-annotation-popover .reader-ink-tools { display: grid; grid-template-columns: repeat(4,1fr); gap: 3px; padding: 3px; background: var(--bg-color); border-radius: 7px; }
.reader-annotation-popover .reader-ink-tools button { border: 0; border-radius: 5px; background: transparent; color: var(--reader-muted); min-height: 34px; padding: 5px; font-size: 13px; }
.reader-annotation-popover .reader-ink-tools button[aria-pressed="true"] { background: var(--panel-bg); color: var(--primary-color); box-shadow: 0 1px 4px rgba(32,72,61,.08); }
.reader-color-heading { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 10px; font-size: 12px; color: var(--reader-muted); }
.reader-custom-color { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.reader-custom-color input { width: 19px; height: 19px; padding: 0; background: transparent; border: 0; cursor: pointer; }
.reader-colors { display: grid; grid-template-columns: repeat(8,1fr); justify-items: center; gap: 6px; padding: 1px 0 3px; }
.reader-colors button { width: 26px; height: 26px; border: 3px solid var(--panel-bg); outline-offset: 1px; outline: 1.5px solid transparent; }
.reader-colors button[aria-pressed="true"] { outline-color: var(--ink-color); }
.reader-colors button[aria-pressed="true"]::after { content: ''; display: block; width: 5px; height: 5px; border-radius: 50%; background: #fff; margin: auto; box-shadow: 0 0 1px #365448; }
.reader-pen-control { display: flex; align-items: center; gap: 12px; margin-top: 15px; font-size: 12px; color: var(--reader-muted); }
.reader-pen-control label { flex: 0 0 28px; }
.reader-pen-control input { flex: 1; min-width: 0; accent-color: var(--primary-color); height: 16px; }
.reader-pen-control output { flex: 0 0 31px; text-align: right; font-variant-numeric: tabular-nums; }
.reader-annotation-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-color); }
.reader-annotation-bottom button { border: 0; border-radius: 5px; background: var(--bg-color); color: var(--text-main); font-size: 12px; padding: 6px 10px; }
.reader-annotation-bottom .reader-checkbox { font-size: 12px; }
.reader-storage-info { width: 100%; grid-column: 1 / -1; color: var(--reader-muted); font-size: 11px; line-height: 1.6; margin: 0; }
body.is-reader-fullscreen .reader-shell { grid-template-columns: minmax(0,1fr); }
body.is-reader-fullscreen .reader-sidebar,body.is-reader-fullscreen .textbook-top-bar,body.is-reader-fullscreen .reader-sidebar-scrim { display: none !important; }
body.is-reader-fullscreen .reader-main { grid-template-rows: 0 auto auto minmax(0,1fr); }
body.is-reader-fullscreen .reader-controls-bar { grid-row: 2; padding-top: max(7px,env(safe-area-inset-top)); }
@media(max-width:768px) {
  .reader-controls-bar { gap: 6px; padding-inline: 8px; }
  .reader-segmented button { min-width: 29px; padding-inline: 8px; }
  .reader-controls-bar .reader-main-actions { gap: 3px; }
  .reader-fullscreen-button { width: 32px; padding-inline: 5px; }
  .reader-fullscreen-button span { display: none; }
  .reader-annotation-button { padding-inline: 7px; }
  .reader-spread { gap: 4px; }
  .reader-annotation-popover { width: min(330px,calc(100vw - 20px)); right: 8px; }
  .reader-more-popover { padding: 12px; }
  body.is-reader-fullscreen .reader-controls-bar { padding-inline: max(8px,env(safe-area-inset-left)); }
}

.reader-annotation-button.is-active { display: inline-flex; align-items: center; gap: 5px; }
.reader-annotation-button.is-active::before { content: ''; flex: 0 0 6px; width: 6px; height: 6px; background: var(--active-ink-color); border-radius: 50%; }
.reader-colors button { position: relative; }
.reader-colors button[aria-pressed="true"] { outline-color: var(--primary-color); }
.reader-colors button[aria-pressed="true"]::after { content: ''; position: absolute; width: 5px; height: 9px; top: 4px; left: 7px; background: transparent; border: 0; border-bottom: 2px solid var(--swatch-check); border-right: 2px solid var(--swatch-check); border-radius: 0; box-shadow: none; transform: rotate(45deg); }

/* 紫红色只提示本次对照定位，不改变连续阅读，也不写入个人批注。 */
.reader-locator-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.reader-location-mark { position: absolute; background: rgba(199,21,133,.15); border: 1.5px solid #c71585; border-radius: 2px; }
.reader-location-mark.has-version-mark { background: transparent; border: 0; outline: 1.5px solid #c71585; outline-offset: 1px; }
.reader-location-mark.is-reference-range { background: transparent; border-style: dashed; }
.reader-location-mark.is-insertion { min-height: 3px; height: 0 !important; background: transparent; border: 0; border-top: 2px dashed #c71585; border-radius: 0; }
.reader-location-mark.is-insertion::before { content: '+'; position: absolute; right: 100%; top: -10px; width: 17px; height: 17px; color: #c71585; background: white; border: 1.5px solid #c71585; border-radius: 50%; font-size: 13px; line-height: 14px; text-align: center; }
