.ps-themed,
.ps-themed body,
body.ps-themed {
  background: var(--ps-bg, #e8e4dc);
  color: var(--ps-text, #1c1a17);
  font-family: var(--ps-font-mono, system-ui, sans-serif);
  transition: background var(--ps-transition, 0.25s ease), color var(--ps-transition, 0.25s ease);
}

.ps-reader.reader {
  max-width: var(--ps-reader-max, 680px);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4rem;
}

.ps-prose.prose {
  font-family: var(--ps-font-body, Georgia, serif);
  font-size: var(--ps-font-size, 1.1rem);
  line-height: var(--ps-line-height, 1.75);
  background: var(--ps-prose-bg, transparent);
}

.ps-prose p {
  margin: 0 0 1em;
}

.ps-prose hr {
  border: 0;
  border-top: 1px solid var(--ps-border, rgba(0, 0, 0, 0.12));
  margin: 2rem 0;
}

.ps-chapter-title {
  font-family: var(--ps-font-heading, Georgia, serif);
  font-weight: var(--ps-heading-weight, 600);
  font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.4rem);
  line-height: 1.15;
  margin-bottom: 0.35em;
}

.ps-chapter-when,
.ps-toc-status {
  color: var(--ps-muted, #5c574f);
  font-size: 0.95rem;
}

.ps-epigraph {
  margin: 1.25rem 0 2rem;
  padding-left: 1rem;
  border-left: 2px solid var(--ps-accent, #8b1e1e);
  color: var(--ps-text-secondary, #3a3630);
  font-style: italic;
}

.ps-epigraph cite {
  display: block;
  margin-top: 0.5rem;
  font-style: normal;
  font-size: 0.85em;
  color: var(--ps-muted, #5c574f);
}

.ps-term.term {
  appearance: none;
  border: 0;
  background: var(--ps-term-bg, rgba(26, 77, 122, 0.08));
  color: var(--ps-term, #1a4d7a);
  font: inherit;
  cursor: pointer;
  border-radius: 0.2em;
  padding: 0 0.15em;
  text-decoration: underline dotted;
}

.ps-toc ol {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.ps-toc li {
  margin: 0.75rem 0;
}

.ps-toc a {
  color: var(--ps-accent, #8b1e1e);
  text-decoration: none;
  font-family: var(--ps-font-heading, Georgia, serif);
  font-size: 1.25rem;
}

.ps-toc a:hover {
  text-decoration: underline;
}

.ps-toc-progress {
  display: block;
  height: 3px;
  margin-top: 0.35rem;
  background: var(--ps-border, rgba(0, 0, 0, 0.1));
  border-radius: 999px;
  overflow: hidden;
}

.ps-toc-progress i {
  display: block;
  height: 100%;
  background: var(--ps-accent, #8b1e1e);
}

.ps-read-progress-track,
.read-progress-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 40;
  background: transparent;
}

.ps-read-progress,
.read-progress {
  height: 100%;
  width: 0;
  background: var(--ps-accent, #8b1e1e);
}

/* Footnotes — specificity must allow .tooltip-visible to win over base opacity */
.tooltip.ps-tooltip,
.tooltip {
  z-index: 200;
  font-family: var(--ps-font-sans, system-ui, sans-serif);
  line-height: 1.5;
  opacity: 0;
  transition: opacity var(--ps-transition, 0.2s ease), transform var(--ps-transition, 0.2s ease);
}

.tooltip.tooltip-visible,
.tooltip.ps-tooltip.tooltip-visible {
  opacity: 1;
}

.tooltip-float {
  position: absolute;
  max-width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--ps-surface, #f4f1ea);
  color: var(--ps-text, #1c1a17);
  border: 1px solid var(--ps-border, rgba(0, 0, 0, 0.1));
  border-radius: var(--ps-radius, 12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  font-size: 0.85rem;
  transform: translateX(8px);
  opacity: 0;
}

.tooltip-float.tooltip-visible {
  transform: translateX(0);
  opacity: 1;
}

.tooltip-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 40vw);
  overflow-y: auto;
  padding: 28px 32px;
  background: var(--ps-surface, #f4f1ea);
  color: var(--ps-text, #1c1a17);
  border-left: 1px solid var(--ps-border, rgba(0, 0, 0, 0.1));
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.12);
  font-size: 0.9rem;
  transform: translateX(100%);
  border-radius: 0;
  max-width: none;
}

.tooltip-panel.tooltip-visible {
  transform: translateX(0);
  opacity: 1;
}

.tooltip-panel .t-term {
  font-size: 1.25rem;
}

.tooltip-panel .t-body {
  font-size: 0.92rem;
  line-height: 1.6;
}

.tooltip-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  max-width: none;
  max-height: min(52vh, 380px);
  padding: 10px 16px 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--ps-surface, #f4f1ea);
  color: var(--ps-text, #1c1a17);
  border-radius: var(--ps-radius, 12px) var(--ps-radius, 12px) 0 0;
  border: 1px solid var(--ps-border, rgba(0, 0, 0, 0.1));
  border-bottom: none;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
  font-size: 0.85rem;
  transform: translateY(100%);
  z-index: 200;
  opacity: 0;
}

.tooltip-sheet.tooltip-visible {
  transform: translateY(0);
  opacity: 1;
}

.tooltip-sheet .t-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1;
  min-height: 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--ps-border, rgba(0, 0, 0, 0.2));
  border-radius: 2px;
  margin: 0 auto 10px;
  flex-shrink: 0;
}

.tooltip .t-term {
  display: block;
  font-weight: 600;
  font-size: 1.15rem;
  margin-bottom: 8px;
  color: var(--ps-term, #1a4d7a);
  font-family: var(--ps-font-heading, Georgia, serif);
}

.tooltip-sheet .t-term {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-bottom: 6px;
}

.tooltip .t-body {
  color: var(--ps-text, #1c1a17);
  font-size: 0.9rem;
}

.tooltip .t-body p {
  margin: 0 0 0.85em;
}

.tooltip .t-body p:last-child {
  margin-bottom: 0;
}

body.tooltip-open::after,
body.ps-tooltip-open::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.25);
}

body.tooltip-open-light::after,
body.ps-tooltip-open-light::after {
  display: none;
}

body.tooltip-panel-open::after,
body.ps-tooltip-panel-open::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.18);
}

@media (max-width: 600px) {
  .tooltip-sheet {
    left: 8px;
    right: 8px;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    max-height: min(42dvh, 320px);
    border-radius: 12px;
    border-bottom: 1px solid var(--ps-border, rgba(0, 0, 0, 0.1));
    padding: 8px 14px 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .tooltip-sheet .t-term {
    font-size: 1rem;
  }

  .tooltip-sheet .t-body {
    font-size: 0.8rem;
    line-height: 1.42;
  }

  .tooltip-sheet .t-body p {
    margin-bottom: 0.6em;
  }

  .tooltip-panel {
    width: min(100vw, 100%);
  }
}

.exhibit-wrap,
.ps-exhibit {
  margin: 1.75rem 0;
}

.exhibit-sheet {
  background: var(--ps-surface, #f4f1ea);
  border: 1px solid var(--ps-border, rgba(0, 0, 0, 0.12));
  border-radius: var(--ps-radius, 12px);
  padding: 1rem 1.1rem;
  font-family: var(--ps-font-typewriter, ui-monospace, monospace);
  font-size: 0.95em;
}

.ex-meta-stamp {
  display: inline-block;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--ps-accent, #8b1e1e);
  margin-bottom: 0.5rem;
}

.exhibit-hand {
  margin-top: 1rem;
  font-style: italic;
  color: var(--ps-text-secondary, #3a3630);
}

.chapter-figure,
.ps-figure {
  margin: 1.75rem 0;
}

.chapter-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: calc(var(--ps-radius, 12px) - 4px);
}

.chapter-figure-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: zoom-in;
  width: 100%;
}

.figure-credit,
.figure-tag,
figcaption {
  color: var(--ps-muted, #5c574f);
  font-size: 0.85rem;
  margin-top: 0.4rem;
}

.ps-home {
  max-width: var(--ps-reader-max, 680px);
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.ps-site-title {
  font-family: var(--ps-font-heading, Georgia, serif);
  font-size: clamp(2rem, 1.6rem + 1.5vw, 2.8rem);
}

body.ps-in-reader,
body.in-reader {
  padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px));
}

body.chrome-hidden .ps-reader-bar,
body.chrome-hidden .reader-bar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(100%);
}

body.chrome-hidden.in-reader,
body.chrome-hidden.ps-in-reader {
  padding-bottom: 0;
}

body.chrome-hidden .reader-reveal-zone {
  display: block;
}

.reader-reveal-zone {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28px;
  z-index: 190;
}

.ps-reader-bar,
.reader-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding: 6px 10px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--ps-surface, #f4f1ea) 94%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--ps-border, rgba(0,0,0,.1));
  transition: opacity var(--ps-transition, .25s ease), transform var(--ps-transition, .25s ease);
}

.reader-bar-compact {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-width: 280px;
  margin: 0 auto;
}

.reader-bar-compact > button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--ps-border, rgba(0,0,0,.1));
  border-radius: 50%;
  background: var(--ps-surface, #f4f1ea);
  color: var(--ps-text, #1c1a17);
  font-size: 0.78rem;
  cursor: pointer;
}

.reader-bar-compact > button:hover,
.reader-bar-compact > button.active,
.reader-popover-item.active,
[data-spacing].active {
  background: var(--ps-accent-soft, rgba(139,30,30,.12));
  border-color: var(--ps-accent, #8b1e1e);
  color: var(--ps-accent, #8b1e1e);
}

.reader-size-label {
  font-size: 0.65rem;
  color: var(--ps-muted, #5c574f);
  min-width: 28px;
  text-align: center;
}

.reader-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 8px;
  width: min(240px, calc(100vw - 24px));
  padding: 12px;
  background: var(--ps-surface, #f4f1ea);
  border: 1px solid var(--ps-border, rgba(0,0,0,.1));
  border-radius: var(--ps-radius, 12px);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

.reader-popover-label {
  font-size: 0.75rem;
  color: var(--ps-muted, #5c574f);
  margin-bottom: 0.5rem;
}

.reader-popover-row {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.reader-popover-row button,
.reader-popover-item {
  flex: 1;
  border: 1px solid var(--ps-border, rgba(0,0,0,.1));
  background: var(--ps-bg, #e8e4dc);
  color: var(--ps-text, #1c1a17);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}

.reader-popover-item {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  text-align: left;
}

body.reader-narrow .ps-reader,
body.reader-narrow .reader {
  max-width: var(--ps-reader-narrow, 38rem);
}

.ps-figure-lightbox,
.figure-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.ps-figure-lightbox[hidden],
.figure-lightbox[hidden] {
  display: none;
}

.ps-figure-lightbox img,
.figure-lightbox img {
  max-width: min(960px, 100%);
  max-height: 90vh;
  object-fit: contain;
}

.figure-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
}

.ps-continue-prompt,
.continue-prompt {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(0,0,0,.25);
  opacity: 0;
  transition: opacity var(--ps-transition, .25s ease);
}

.ps-continue-prompt.visible,
.continue-prompt.visible {
  opacity: 1;
}

.continue-card {
  width: min(360px, 100%);
  background: var(--ps-surface, #f4f1ea);
  color: var(--ps-text, #1c1a17);
  border-radius: var(--ps-radius, 12px);
  padding: 1rem 1.1rem;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
}

.continue-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.continue-actions button {
  flex: 1;
  border: 1px solid var(--ps-border, rgba(0,0,0,.1));
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: var(--ps-bg, #e8e4dc);
  color: var(--ps-text, #1c1a17);
  cursor: pointer;
  font: inherit;
}

.continue-yes {
  background: var(--ps-accent-soft, rgba(139,30,30,.12)) !important;
  border-color: var(--ps-accent, #8b1e1e) !important;
  color: var(--ps-accent, #8b1e1e) !important;
}

.ps-nav-zone,
.nav-zone {
  position: fixed;
  top: 20%;
  bottom: 20%;
  width: 28px;
  z-index: 120;
  border: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0;
}

.nav-zone-prev { left: 0; }
.nav-zone-next { right: 0; }

@media (hover: hover) {
  .ps-nav-zone:hover,
  .nav-zone:hover { opacity: 0.08; background: var(--ps-accent, #8b1e1e); }
}

.ps-chapter-nav,
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.5rem 0 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ps-border, rgba(0,0,0,.12));
  font-size: 0.95rem;
}

.ps-chapter-nav a,
.chapter-nav a {
  color: var(--ps-accent, #8b1e1e);
  text-decoration: none;
}

.ps-nav-ghost {
  color: var(--ps-text-muted, #7a736a);
  font-style: italic;
}

.ps-toc-locked .ps-toc-title {
  color: var(--ps-text-muted, #7a736a);
}

.ps-toc-status {
  margin-left: 0.5rem;
  font-style: italic;
  color: var(--ps-text-muted, #7a736a);
}

.ps-toc-progress-label {
  margin-left: 0.5rem;
  font-size: 0.85em;
  color: var(--ps-text-secondary, #4a453e);
}

.ps-locked-page,
.locked-page {
  max-width: var(--ps-max-width, 42rem);
  margin: 3rem auto;
  padding: 0 1.25rem;
}

.ps-eyebrow,
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--ps-accent, #8b1e1e);
}

.ps-chapter-era,
.chapter-era {
  color: var(--ps-text-muted, #7a736a);
  font-size: 0.9rem;
}

.ps-chapter-number,
.chapter-badge {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--ps-text-secondary, #4a453e);
}

.ps-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 1rem 2rem;
  background: rgba(0, 0, 0, 0.35);
}

.ps-search-overlay[hidden] {
  display: none !important;
}

.ps-search-dialog {
  width: min(32rem, 100%);
  background: var(--ps-surface, #f4f1ea);
  color: var(--ps-text, #1c1a17);
  border: 1px solid var(--ps-border, rgba(0, 0, 0, 0.12));
  border-radius: var(--ps-radius, 12px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  padding: 0.75rem;
}

.ps-search-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--ps-border, rgba(0, 0, 0, 0.15));
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 1rem;
  background: var(--ps-bg, #e8e4dc);
  color: inherit;
}

.ps-search-status {
  min-height: 1.25rem;
  margin: 0.5rem 0.25rem 0;
  font-size: 0.85rem;
  color: var(--ps-text-muted, #7a736a);
}

.ps-search-results {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  max-height: min(50vh, 22rem);
  overflow: auto;
}

.ps-search-hit {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}

.ps-search-hit strong {
  font-size: 0.95rem;
}

.ps-search-hit span {
  font-size: 0.82rem;
  color: var(--ps-text-muted, #7a736a);
  line-height: 1.35;
}

.ps-search-hit.is-active,
.ps-search-hit:hover {
  background: var(--ps-accent-soft, rgba(139, 30, 30, 0.12));
}

.ps-search-hint {
  margin: 0.5rem 0.25rem 0;
  font-size: 0.75rem;
  color: var(--ps-text-muted, #7a736a);
}

