:root {
  color-scheme: light;
  --reader-ink: #17221e;
  --reader-muted: #68726d;
  --reader-paper: #eee8dc;
  --reader-bar: #173c31;
  --reader-gold: #d7aa6c;
}

* { box-sizing: border-box; }

html { background: var(--reader-paper); }

body.document-reader {
  margin: 0;
  color: var(--reader-ink);
  background: var(--reader-paper);
  font-family: Arial, Helvetica, sans-serif;
}

.reader-toolbar {
  position: sticky;
  z-index: 1000;
  top: var(--global-nav-height, 0px);
  display: grid;
  grid-template-columns: minmax(130px, auto) minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 76px;
  padding: 12px clamp(14px, 3vw, 34px);
  color: white;
  background: rgba(23, 60, 49, 0.97);
  box-shadow: 0 8px 30px rgba(24, 32, 28, 0.22);
  backdrop-filter: blur(12px);
}

.reader-toolbar a { color: white; text-decoration: none; }
.reader-back { font-size: 0.86rem; font-weight: 800; }
.reader-title { min-width: 0; text-align: center; }
.reader-title strong { display: block; overflow: hidden; font-family: Georgia, "Times New Roman", serif; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.reader-title span { display: block; margin-top: 2px; color: #c8d9d2; font-size: 0.7rem; }
.reader-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }

.reader-actions button,
.reader-download {
  min-height: 36px;
  padding: 7px 11px;
  color: white;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 7px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.reader-actions button:hover,
.reader-download:hover { background: rgba(255, 255, 255, 0.2); }
.reader-zoom-value { min-width: 46px; color: #dce9e4; font-size: 0.72rem; text-align: center; }

.reader-pages {
  width: 100%;
  padding: 24px 12px 60px;
  overflow-x: auto;
}

.reader-pages > div[id^="page"] {
  margin: 0 auto 24px;
  background: white;
  box-shadow: 0 12px 38px rgba(35, 39, 31, 0.16);
  transform-origin: top center;
}

.reader-pages > div[id^="page"] > img:first-child { pointer-events: none; }

.reader-noscript {
  display: block;
  padding: 16px;
  color: #702e22;
  background: #ffe8df;
  text-align: center;
}

@media (max-width: 760px) {
  .reader-toolbar { position: relative; top: auto; grid-template-columns: 1fr; gap: 9px; text-align: center; }
  .reader-title { order: -1; }
  .reader-actions { justify-content: center; flex-wrap: wrap; }
  .reader-back { justify-self: center; }
  .reader-pages { padding: 12px 6px 40px; }
}

@media print {
  .reader-toolbar { display: none; }
  .reader-pages { padding: 0; }
  .reader-pages > div[id^="page"] { margin: 0; box-shadow: none; }
}
