:root {
  color-scheme: light;
  --paper: #f6f1e7;
  --paper-deep: #e8decd;
  --ink: #17232b;
  --muted: #68737a;
  --rule: #cabda9;
  --accent: #a33a2b;
  --teal: #164f56;
  --chrome: rgba(246, 241, 231, 0.94);
  --shadow: 0 24px 70px rgba(27, 37, 42, 0.17);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: #dcd3c5;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 253, 247, 0.94), transparent 36rem),
    linear-gradient(135deg, #ded6ca 0%, #cbc0b1 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

button,
a { -webkit-tap-highlight-color: transparent; }

.reader-toolbar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(280px, 2fr) minmax(300px, 1fr);
  align-items: center;
  gap: 20px;
  min-height: 78px;
  padding: 12px clamp(18px, 3vw, 46px);
  border-bottom: 1px solid rgba(131, 112, 88, 0.32);
  background: var(--chrome);
  box-shadow: 0 8px 28px rgba(45, 46, 43, 0.08);
  backdrop-filter: blur(18px) saturate(120%);
}

.reader-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.reader-brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--teal);
  color: var(--teal);
  font: 600 16px/1 Georgia, serif;
  letter-spacing: -0.08em;
  transform: rotate(-3deg);
}

.reader-brand-copy { min-width: 0; }

.reader-brand-copy strong,
.reader-brand-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-brand-copy strong {
  font: 600 15px/1.2 Georgia, "Times New Roman", serif;
  letter-spacing: 0.04em;
}

.reader-brand-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reader-title {
  min-width: 0;
  text-align: center;
}

.reader-title strong,
.reader-title span { display: block; }

.reader-title strong {
  overflow: hidden;
  font: 500 clamp(15px, 1.5vw, 20px)/1.25 Georgia, "Times New Roman", serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-title span {
  margin-top: 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.reader-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.reader-control,
.reader-language button {
  min-height: 36px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: rgba(255, 253, 247, 0.78);
  color: var(--ink);
  cursor: pointer;
  font: 700 11px/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.reader-control {
  display: inline-grid;
  min-width: 38px;
  padding: 0 10px;
  place-items: center;
}

.reader-control:hover,
.reader-language button:hover,
.reader-language button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.reader-language {
  display: flex;
  gap: 3px;
  padding-left: 7px;
  border-left: 1px solid var(--rule);
}

.reader-language button {
  min-width: 34px;
  padding: 0 7px;
}

.reader-page-status {
  min-width: 74px;
  color: var(--muted);
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}

.reader-notice {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  width: min(980px, calc(100% - 36px));
  margin: 28px auto 4px;
  padding: 15px 18px;
  border: 1px solid rgba(163, 58, 43, 0.32);
  border-radius: 6px;
  background: rgba(255, 253, 247, 0.76);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  backdrop-filter: blur(8px);
}

.reader-notice strong {
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.reader-pages {
  position: relative;
  z-index: 3;
  display: grid;
  justify-items: center;
  gap: clamp(22px, 4vw, 48px);
  padding: 28px 20px 100px;
}

.reader-page {
  position: relative;
  width: min(calc(100vw - 40px), calc(860px * var(--reader-zoom, 1)));
  aspect-ratio: 1240 / 1754;
  overflow: hidden;
  border: 1px solid rgba(104, 92, 74, 0.32);
  background: var(--paper);
  box-shadow: var(--shadow);
  transition: width 180ms ease, filter 140ms ease, opacity 140ms ease;
}

.reader-page::before {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  place-items: center;
  color: #9a8d7c;
  content: attr(data-loading-label);
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.reader-page.loaded::before { content: none; }

.reader-page canvas {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.session-watermarks {
  position: fixed;
  z-index: 20;
  inset: -12vh -16vw;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12vh 8vw;
  align-content: space-around;
  pointer-events: none;
  transform: rotate(-21deg);
}

.session-watermarks span {
  color: rgba(25, 72, 76, 0.13);
  font: 700 clamp(10px, 1.05vw, 15px)/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.reader-toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 28px;
  width: min(520px, calc(100% - 36px));
  padding: 13px 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  background: rgba(23, 35, 43, 0.94);
  color: white;
  font-size: 12px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 16px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.reader-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.privacy-curtain {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(19, 34, 39, 0.96);
  color: white;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transition: opacity 80ms linear;
}

.privacy-curtain div { max-width: 520px; }

.privacy-curtain strong {
  display: block;
  font: 500 clamp(28px, 5vw, 50px)/1.1 Georgia, "Times New Roman", serif;
}

.privacy-curtain span {
  display: block;
  margin-top: 16px;
  color: #d8cdbb;
  font-size: 13px;
  line-height: 1.6;
}

body[data-shielded="true"] .privacy-curtain {
  opacity: 1;
  pointer-events: auto;
}

body[data-shielded="true"] .reader-pages,
body[data-shielded="true"] .reader-notice {
  filter: blur(28px);
  opacity: 0.16;
}

noscript {
  display: block;
  max-width: 680px;
  margin: 80px auto;
  padding: 30px;
  background: white;
  color: var(--ink);
}

@media (max-width: 900px) {
  .reader-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 68px;
    gap: 10px;
    padding: 10px 14px;
  }

  .reader-title { display: none; }
  .reader-brand-mark { width: 36px; height: 36px; }
  .reader-brand-copy span { display: none; }
  .reader-page-status { min-width: 58px; }
  .reader-control { display: none; }
}

@media (max-width: 520px) {
  .reader-brand-copy strong { font-size: 13px; }
  .reader-language { padding-left: 4px; }
  .reader-language button { min-width: 30px; padding: 0 5px; }
  .reader-notice { grid-template-columns: 1fr; gap: 5px; margin-top: 18px; }
  .reader-pages { padding-right: 10px; padding-left: 10px; }
  .reader-page { width: min(calc(100vw - 20px), calc(860px * var(--reader-zoom, 1))); }
}

@media print {
  body { background: white !important; }
  body > * { display: none !important; }
  body::before {
    display: block;
    padding: 20mm;
    color: #111;
    content: "Printing is unavailable in the online research reader.";
    font: 18pt/1.5 sans-serif;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
