:root {
  --night: #00191d;
  --night-deep: #000d10;
  --panel: #05272b;
  --teal: #72ddd7;
  --teal-soft: #aadfda;
  --gold: #d9ad5b;
  --gold2: #f5d894;
  --ink: #f7f1e5;
  --muted: #a9bebd;
  --line: rgba(114, 221, 215, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--night-deep);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 50% 28%, rgba(34, 139, 139, 0.2), transparent 36rem),
    linear-gradient(180deg, var(--night) 0%, var(--night-deep) 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.reader-page {
  min-height: 100vh;
  padding: 0 20px 28px;
}

.site-header {
  width: min(1180px, 100%);
  min-height: 74px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(114, 221, 215, 0.62);
  border-radius: 8px;
  color: var(--teal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  letter-spacing: 0.12em;
}

.brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-copy strong {
  overflow: hidden;
  color: var(--gold2);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 600;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small,
.prototype-badge {
  color: var(--teal-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.prototype-badge {
  flex: 0 0 auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--gold2);
  text-decoration: none;
}

.reader-heading {
  width: min(1180px, 100%);
  margin: 22px auto 18px;
  text-align: center;
}

.reader-heading p {
  margin: 0 0 5px;
  color: var(--teal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.reader-heading h1 {
  margin: 0;
  color: var(--gold2);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 500;
  line-height: 1;
}

.reader-heading span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(13px, 1.8vw, 17px);
  font-style: italic;
}

.reader-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.reader-stage {
  position: relative;
  min-height: min(72vh, 780px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(114, 221, 215, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(217, 173, 91, 0.06) 50%, transparent 50.2%),
    radial-gradient(ellipse at center, rgba(22, 88, 89, 0.33), transparent 65%),
    linear-gradient(150deg, rgba(10, 46, 49, 0.96), rgba(0, 12, 15, 0.98));
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.03),
    0 28px 70px rgba(0, 0, 0, 0.38);
}

.reader-stage::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: 12%;
  right: 12%;
  bottom: 4%;
  height: 12%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.48);
  filter: blur(28px);
  pointer-events: none;
}

.book-mount {
  position: relative;
  z-index: 2;
  width: 100%;
  height: min(70vh, 760px);
  display: grid;
  place-items: center;
  touch-action: pan-y pinch-zoom;
}

.flipbook-root,
.stf__parent {
  margin: auto !important;
}

.catalogue-page {
  position: relative;
  overflow: hidden;
  background: #e9dfc8;
  border: 1px solid rgba(92, 73, 50, 0.28);
  box-shadow:
    inset 7px 0 12px rgba(73, 55, 35, 0.08),
    inset -2px 0 3px rgba(73, 55, 35, 0.14);
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.catalogue-page::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 3px;
  background: linear-gradient(90deg, rgba(78, 59, 35, 0), rgba(78, 59, 35, 0.24));
  pointer-events: none;
}

.catalogue-page img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.catalogue-board {
  border: 2px solid rgba(77, 37, 29, 0.78);
  border-radius: 2px 5px 5px 2px;
  box-shadow:
    inset 0 0 0 2px rgba(226, 173, 95, 0.1),
    3px 2px 1px rgba(50, 24, 17, 0.75),
    8px 5px 15px rgba(0, 0, 0, 0.34);
}

.catalogue-board::after {
  width: 7px;
  background: linear-gradient(90deg, rgba(43, 18, 13, 0), rgba(43, 18, 13, 0.62));
}

.stf__block {
  border-radius: 3px;
  box-shadow:
    0 2px 1px rgba(255, 255, 255, 0.07),
    0 24px 54px rgba(0, 0, 0, 0.52);
}

.loading-note {
  position: absolute;
  z-index: 3;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.reader-status {
  min-height: 45px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.reader-status span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-status span:last-child {
  flex: 0 0 auto;
  color: var(--gold2);
}

.reader-controls {
  min-height: 64px;
  padding: 10px 8px 0;
  display: grid;
  grid-template-columns: auto auto auto 1fr auto auto;
  align-items: center;
  gap: 8px;
}

.control-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid rgba(114, 221, 215, 0.26);
  border-radius: 9px;
  background: rgba(5, 39, 43, 0.72);
  color: var(--ink);
  cursor: pointer;
}

.control-button:hover,
.control-button:focus-visible {
  border-color: rgba(114, 221, 215, 0.6);
  background: rgba(114, 221, 215, 0.12);
  color: var(--teal);
  outline: none;
}

.control-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(114, 221, 215, 0.2);
}

.control-button:disabled {
  cursor: default;
  opacity: 0.28;
}

.control-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.reader-controls p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.reader-footer {
  width: min(1180px, 100%);
  margin: 22px auto 0;
  color: rgba(169, 190, 189, 0.72);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

.zoom-overlay[hidden] {
  display: none;
}

.zoom-overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(34, 139, 139, 0.2), transparent 42rem),
    var(--night-deep);
  overscroll-behavior: contain;
}

.zoom-toolbar {
  min-height: 70px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 13, 16, 0.94);
}

.zoom-toolbar span {
  overflow: hidden;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zoom-toolbar-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.zoom-toolbar-actions .control-button {
  min-width: 40px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(114, 221, 215, 0.28);
  border-radius: 9px;
  background: rgba(5, 39, 43, 0.88);
}

.zoom-toolbar-actions .control-button:last-child {
  margin-left: 4px;
  border-color: rgba(217, 173, 91, 0.42);
  color: var(--gold2);
}

.zoom-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 18px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.zoom-stage.dragging {
  cursor: grabbing;
}

.zoom-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  border-radius: 3px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.62);
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
  pointer-events: none;
}

.zoom-hint {
  margin: 0;
  padding: 10px 14px 14px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-align: center;
}

body.zoom-open {
  overflow: hidden;
}

.reader-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
  background: var(--night-deep);
}

.reader-stage:fullscreen .book-mount {
  height: 96vh;
}

@media (max-width: 700px) {
  .reader-page {
    padding-inline: 10px;
  }

  .site-header {
    min-height: 64px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 14px;
  }

  .brand-copy small,
  .prototype-badge {
    font-size: 8px;
  }

  .prototype-badge {
    padding: 6px 8px;
  }

  .reader-heading {
    margin-block: 8px 8px;
  }

  .reader-heading h1 {
    font-size: 28px;
  }

  .reader-heading span {
    font-size: 12px;
  }

  .reader-stage {
    width: 100%;
    height: clamp(300px, calc(100dvh - 188px), 860px);
    min-height: 300px;
    border-radius: 12px;
  }

  .book-mount {
    height: 100%;
    touch-action: pan-y;
  }

  .reader-controls {
    position: fixed;
    z-index: 50;
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 10px;
    min-height: 58px;
    max-width: 520px;
    margin-inline: auto;
    padding: 8px;
    grid-template-columns: 1fr 1.25fr 1fr;
    border: 1px solid rgba(114, 221, 215, 0.32);
    border-radius: 13px;
    background: rgba(0, 20, 23, 0.94);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.52);
    backdrop-filter: blur(12px);
  }

  .reader-controls p,
  #return-cover,
  #fullscreen {
    display: none;
  }

  .reader-controls .icon-button,
  .reader-controls #zoom-page {
    width: 100%;
  }

  #previous-page {
    grid-column: 1;
  }

  #zoom-page {
    grid-column: 2;
  }

  #next-page {
    grid-column: 3;
  }

  .reader-status {
    font-size: 9px;
  }

  .reader-page {
    padding-bottom: 92px;
  }

  .zoom-toolbar {
    min-height: 62px;
    padding: 8px 10px;
    gap: 8px;
  }

  .zoom-toolbar span {
    font-size: 13px;
  }

  .zoom-toolbar-actions {
    gap: 4px;
  }

  .zoom-toolbar-actions .control-button {
    min-width: 36px;
    min-height: 38px;
    padding-inline: 7px;
  }

  .zoom-stage {
    padding: 10px;
  }

  .zoom-hint {
    display: none;
  }
}

@media (max-width: 430px) {
  .prototype-badge {
    display: none;
  }

  .brand-copy strong {
    font-size: 17px;
  }

  .reader-heading p {
    display: none;
  }

  .reader-heading h1 {
    font-size: 24px;
  }

  .reader-heading span {
    font-size: 11px;
  }

  .reader-stage {
    height: clamp(320px, calc(100dvh - 176px), 860px);
  }

  .book-mount {
    height: 100%;
  }
}

@media (max-height: 550px) and (orientation: landscape) {
  .site-header {
    min-height: 52px;
  }

  .reader-heading {
    margin-block: 8px;
  }

  .reader-heading h1 {
    font-size: 28px;
  }

  .reader-heading span {
    display: none;
  }

  .reader-stage {
    height: calc(100dvh - 150px);
    min-height: 220px;
  }
}

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