.reader-page { overflow: hidden; }
.reader-page .flash-container { top: 62px; }
.reader-shell { display: grid; grid-template: 60px minmax(0, 1fr) auto / minmax(0, 1fr); height: 100dvh; background: #f4f4f7; }
.reader-toolbar { z-index: 20; display: grid; grid-column: 1 / -1; grid-template-columns: 1fr minmax(220px, 2fr) 1fr; align-items: center; gap: 1rem; padding: 0 1rem; background: var(--brand-blue); color: white; box-shadow: 0 3px 16px rgba(0, 0, 0, 0.16); }
.reader-toolbar__group { display: flex; align-items: center; gap: 0.35rem; }
.reader-toolbar__group:last-child { position: relative; justify-content: flex-end; }
.reader-offline-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.4rem; }
.reader-offline-control__button { min-height: 38px; padding: 0.55rem 0.75rem; border: 1px solid var(--brand-blue); border-radius: 7px; background: white; color: var(--brand-blue); cursor: pointer; font-size: 0.75rem; font-weight: 700; }
.reader-offline-control__button:hover, .reader-offline-control__button:focus-visible { background: rgba(4, 14, 133, 0.07); }
.reader-offline-control__button:focus-visible { outline: 2px solid var(--brand-gold); outline-offset: 2px; }
.reader-offline-control__button:disabled { cursor: default; opacity: 0.65; }
.reader-offline-control__progress { color: var(--brand-gold); font-size: 0.68rem; font-weight: 700; }
.reader-offline-control__status { grid-column: 1 / -1; color: var(--muted); font-size: 0.72rem; line-height: 1.35; }
.reader-offline-control__status:empty { display: none; }
.reader-offline-indicator { padding: 0.22rem 0.5rem; border: 1px solid var(--brand-gold); border-radius: 99px; color: var(--brand-gold); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em; }
.reader-shell.is-offline [aria-disabled="true"] { cursor: not-allowed; opacity: 0.45; }
.reader-toolbar button, .reader-icon-button { display: inline-grid; min-width: 34px; height: 34px; padding: 0 0.4rem; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 6px; background: rgba(255, 255, 255, 0.07); color: white; cursor: pointer; place-items: center; text-decoration: none; }
.reader-toolbar .reader-bookmark-button.is-active { border-color: var(--brand-gold); background: rgba(255, 255, 255, 0.14); color: var(--brand-gold); }
.reader-toolbar .reader-bookmark-button.is-active svg { fill: currentColor; }
.reader-toolbar .reader-bookmark-button.is-active:hover, .reader-toolbar .reader-bookmark-button.is-active:focus-visible { background: rgba(255, 255, 255, 0.22); color: var(--brand-gold); }
.reader-toolbar .reader-bookmark-button:disabled { cursor: wait; opacity: 0.7; }
.reader-toolbar .reader-highlight-button { border-color: rgba(198, 156, 108, 0.72); color: var(--brand-gold); font-size: 1.25rem; }
.reader-toolbar .reader-highlight-button:hover, .reader-toolbar .reader-highlight-button:focus-visible { border-color: var(--brand-gold); background: rgba(255, 255, 255, 0.14); color: white; }
.reader-highlight-status { position: absolute; top: calc(100% + 0.75rem); right: 0; width: max-content; max-width: min(20rem, calc(100vw - 2rem)); padding: 0.65rem 0.8rem; border: 1px solid rgba(198, 156, 108, 0.55); border-radius: 7px; background: white; box-shadow: 0 8px 24px rgba(4, 14, 133, 0.18); color: var(--brand-blue); font-size: 0.78rem; font-weight: 700; line-height: 1.35; }
.reader-highlight-status:empty { display: none; }
.reader-title { overflow: hidden; text-align: center; }
.reader-title strong, .reader-title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-title span { color: rgba(255, 255, 255, 0.68); font-size: 0.75rem; }
.reader-sidebar { z-index: 10; display: none; grid-row: 2 / 4; overflow: hidden; border-right: 1px solid var(--border); background: white; }
.reader-sidebar.is-open { display: flex; flex-direction: column; }
.reader-tabs { position: sticky; z-index: 1; top: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: white; }
.reader-tabs button { padding: 0.8rem 0.35rem; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-size: 0.72rem; font-weight: 700; }
.reader-tabs button.is-active { border-bottom-color: var(--brand-gold); color: var(--brand-blue); }
.reader-sidebar__panels { min-height: 0; overflow: auto; flex: 1; }
.reader-sidebar-footer { display: none; gap: 0.65rem; padding: 0.75rem 1rem; border-top: 1px solid var(--border); background: white; box-shadow: 0 -5px 18px rgba(4, 14, 133, 0.08); }
.reader-sidebar-footer--pdf { display: grid; }
.reader-sidebar-footer__display { display: none; gap: 0.45rem; }
.reader-list { display: grid; }
.reader-list-button { display: block; padding: 0.75rem 1rem; border: 0; border-bottom: 1px solid var(--border); background: white; color: var(--ink); cursor: pointer; text-align: left; text-decoration: none; }
.reader-list-button:hover { background: var(--surface); color: var(--brand-blue); }
.reader-list-button:disabled { cursor: default; opacity: 0.65; }
.reader-empty { padding: 2rem 1rem; color: var(--muted); text-align: center; }
.reader-search-form { padding: 1rem; border-bottom: 1px solid var(--border); }
.reader-search-form label { display: block; margin-bottom: 0.4rem; color: var(--brand-blue); font-size: 0.78rem; font-weight: 700; }
.reader-search-form div { display: flex; gap: 0.4rem; }
.reader-search-form input { min-width: 0; flex: 1; padding: 0.65rem 0.7rem; border: 1px solid var(--border); border-radius: 7px; }
.reader-search-form input:focus { border-color: var(--brand-blue); outline: 2px solid rgba(4, 14, 133, 0.18); }
.reader-search-form button { padding: 0.55rem 0.7rem; border: 0; border-radius: 7px; background: var(--brand-blue); color: white; cursor: pointer; font-weight: 700; }
.reader-search-status { margin: 0; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 0.78rem; }
.reader-search-result { display: grid; gap: 0.3rem; width: 100%; padding: 0.9rem 1rem; border: 0; border-bottom: 1px solid var(--border); background: white; color: var(--ink); cursor: pointer; text-align: left; }
.reader-search-result:hover, .reader-search-result:focus-visible { background: var(--surface); }
.reader-search-result strong { color: var(--brand-blue); font-size: 0.75rem; }
.reader-search-result span { line-height: 1.4; }
.reader-search-highlight { padding: 0.03em 0.12em; border-radius: 0.18em; background: rgba(198, 156, 108, 0.35); color: inherit; }
.annotation-card { padding: 1rem; border-bottom: 1px solid var(--border); }
.annotation-card--highlight { position: relative; }
.annotation-color { position: absolute; top: 1rem; right: 1rem; width: 12px; height: 12px; border: 1px solid rgba(32, 35, 58, 0.2); border-radius: 50%; background: var(--highlight-color); }
.annotation-card p { margin: 0.65rem 0; color: var(--muted); font-size: 0.85rem; }
.annotation-quote { width: 100%; padding: 0 1.5rem 0 0.75rem; border: 0; border-left: 3px solid var(--highlight-color, var(--brand-gold)); background: transparent; color: var(--ink); cursor: pointer; text-align: left; }
.annotation-actions { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.7rem; font-size: 0.75rem; }
.annotation-share-status { margin-left: auto; color: var(--brand-blue); font-size: 0.7rem; font-weight: 700; }
.annotation-share-status:empty { display: none; }
.annotation-share-url { width: 100%; margin-top: 0.65rem; padding: 0.45rem 0.55rem; border: 1px solid var(--brand-blue); border-radius: 6px; color: var(--ink); font-size: 0.72rem; }
.highlight-color-picker { margin: 0.9rem 0 0; padding: 0; border: 0; }
.highlight-color-picker legend { margin-bottom: 0.45rem; color: var(--brand-blue); font-size: 0.78rem; font-weight: 700; }
.highlight-color-picker > div, .highlight-color-filter { display: flex; align-items: center; gap: 0.55rem; }
.highlight-color-swatch { width: 30px; height: 30px; padding: 0; border: 2px solid white; border-radius: 50%; background: var(--highlight-color); box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.highlight-color-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--brand-blue); }
.highlight-color-swatch:focus-visible, .highlight-color-filter__all:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }
.highlight-color-status { min-height: 1.3em; margin: 0.35rem 0 0 !important; color: var(--danger) !important; }
.highlight-color-filter { position: sticky; z-index: 1; top: 0; padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); background: white; }
.highlight-color-filter .highlight-color-swatch { width: 24px; height: 24px; }
.highlight-color-filter__all { padding: 0.3rem 0.55rem; border: 1px solid var(--border); border-radius: 99px; background: white; color: var(--muted); cursor: pointer; font-size: 0.72rem; font-weight: 700; }
.highlight-color-filter__all[aria-pressed="true"] { border-color: var(--brand-blue); color: var(--brand-blue); }
.reader-stage { position: relative; grid-row: 2; grid-column: 1; min-width: 0; background: white; transition: background 160ms ease; }
.reader-shell[data-reader-theme="dark"] .reader-stage { background: #171827; }
.reader-viewport { position: absolute; inset: 0 50px; }
.reader-page-button { position: absolute; z-index: 2; top: 50%; width: 42px; height: 70px; border: 0; border-radius: 8px; background: transparent; color: var(--brand-blue); cursor: pointer; font-size: 2.7rem; transform: translateY(-50%); }
.reader-shell[data-reader-theme="dark"] .reader-page-button { color: #b8bdf8; }
.reader-page-button:hover { background: rgba(4, 14, 133, 0.07); }
.reader-page-button--previous { left: 4px; }
.reader-page-button--next { right: 4px; }
.reader-error { padding: 2rem; color: var(--danger); text-align: center; }
.note-dialog { width: min(520px, calc(100% - 2rem)); padding: 1.5rem; border: 0; border-radius: var(--radius); box-shadow: 0 22px 70px rgba(0, 0, 0, 0.3); }
.note-dialog::backdrop { background: rgba(1, 4, 40, 0.6); }
.note-dialog h2 { font-size: 2rem; }
.note-dialog blockquote { max-height: 100px; overflow: auto; margin: 0 0 1rem; padding-left: 0.8rem; border-left: 3px solid var(--brand-gold); color: var(--muted); }
.note-dialog textarea { width: 100%; min-height: 150px; margin-top: 0.35rem; padding: 0.75rem; border: 1px solid var(--border); border-radius: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }
.dialog-actions__danger { margin-right: auto; }
.selection-dialog .dialog-actions { flex-wrap: wrap; }

.reader-progress-footer { z-index: 3; display: grid; grid-row: 3; grid-column: 1; grid-template-columns: minmax(0, 1fr); align-items: center; min-height: 64px; padding: 0.35rem 1.25rem; border-top: 1px solid var(--border); background: white; box-shadow: 0 -5px 22px rgba(4, 14, 133, 0.08); }
.reader-progress-footer__scrubber { position: relative; min-width: 0; }
.reader-progress-footer__scrubber input { display: block; width: 100%; height: 44px; margin: 0; accent-color: var(--brand-gold); cursor: ew-resize; }
.reader-progress-footer__scrubber input:disabled { cursor: wait; opacity: 0.55; }
.reader-progress-footer__status { position: absolute; right: 0; bottom: -0.15rem; color: var(--muted); font-size: 0.66rem; }
.reader-shell[data-reader-theme="dark"] .reader-progress-footer { border-top-color: #34364d; background: #222337; color: #f1f2f8; }

.pdf-reader-viewport { position: absolute; inset: 0 50px; overflow: auto; background: #e7e7ec; }
.pdf-reader-viewport .pdfViewer { padding: 16px 0; }
.pdf-reader-viewport .pdfViewer .page { margin: 0 auto 16px; border: 0; box-shadow: 0 4px 18px rgba(4, 14, 133, 0.16); }
.pdf-reader-shell[data-reader-theme="dark"] .pdf-reader-viewport { background: #171827; }
.pdf-saved-highlight-layer, .pdf-search-highlight-layer, .pdf-search-results-layer { position: absolute; z-index: 4; inset: 0; pointer-events: none; }
.pdf-saved-highlight-group { position: absolute; inset: 0; opacity: 0.4; pointer-events: none; }
.pdf-saved-highlight { position: absolute; border: 0; background: var(--highlight-color); cursor: pointer; pointer-events: auto; }
.pdf-search-highlight-layer, .pdf-search-results-layer { opacity: 0.4; }
.pdf-search-highlight-layer span, .pdf-search-results-layer span { position: absolute; background: var(--search-highlight-color); }

@media (min-width: 821px) {
  .reader-shell.is-sidebar-open { grid-template-columns: 320px minmax(0, 1fr); }
  .reader-shell.is-sidebar-open .reader-stage, .reader-shell.is-sidebar-open .reader-progress-footer { grid-column: 2; }
}

@media (max-width: 820px) {
  .reader-shell { grid-template-columns: 1fr; }
  .reader-toolbar { grid-template-columns: auto 1fr auto; padding: 0 0.45rem; }
  .reader-toolbar__group { gap: 0.15rem; }
  .reader-toolbar .reader-search-button { display: none; }
  .reader-toolbar .reader-toolbar__scale-control { display: none; }
  .reader-offline-indicator { display: none; }
  .reader-title strong { font-size: 0.82rem; }
  .reader-sidebar { position: fixed; z-index: 30; top: 60px; bottom: 0; left: 0; width: min(88vw, 340px); box-shadow: 16px 0 40px rgba(0, 0, 0, 0.2); transform: translateX(-105%); transition: transform 180ms ease; }
  .reader-sidebar.is-open { transform: translateX(0); }
  .reader-sidebar-footer { display: grid; padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); }
  .reader-sidebar-footer__display { display: grid; }
  .reader-sidebar-footer__label { color: var(--brand-blue); font-size: 0.72rem; font-weight: 700; }
  .reader-sidebar-footer__controls { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 0.5rem; }
  .reader-sidebar-footer__controls button { display: grid; width: 44px; height: 44px; padding: 0; border: 1px solid var(--brand-blue); border-radius: 7px; background: white; color: var(--brand-blue); cursor: pointer; font-weight: 700; place-items: center; }
  .reader-sidebar-footer__controls button:hover, .reader-sidebar-footer__controls button:focus-visible { background: rgba(4, 14, 133, 0.07); }
  .reader-sidebar-footer__controls button:focus-visible { outline: 2px solid var(--brand-gold); outline-offset: 2px; }
  .reader-sidebar-footer__controls output { color: var(--brand-gold); font-size: 0.9rem; font-weight: 700; text-align: center; }
  .reader-stage { grid-column: 1; }
  .reader-viewport { inset: 0 18px; }
  .pdf-reader-viewport { inset: 0 18px; }
  .reader-page-button { width: 28px; opacity: 0.55; }
  .reader-page-button--previous { left: 0; }
  .reader-page-button--next { right: 0; }
  .reader-progress-footer { grid-column: 1; grid-template-columns: 1fr; gap: 0; min-height: 64px; padding: 0.15rem 0.75rem max(0.15rem, env(safe-area-inset-bottom)); }
}
