
:root {
  --ink: #143e3a;
  --deep: #082f2c;
  --deepest: #041f1d;
  --paper: #fffdf7;
  --paper2: #f4efe4;
  --muted: #b8cbc5;
  --ochre: #e2a335;
  --coral: #e36b4f;
  --line: rgba(255,255,255,.18);
  --shadow: rgba(0,0,0,.36);
  --bar-bg: rgba(4,31,29,.91);
  --focus: #f2bd55;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 100%;
  margin: 0;
}
html { background: var(--deepest); }
body {
  overflow: hidden;
  color: var(--paper2);
  background: radial-gradient(circle at 50% 32%, #315b55 0, var(--deep) 48%, var(--deepest) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
button, a { font: inherit; }
button { appearance: none; }
button, a { -webkit-tap-highlight-color: transparent; }
.viewer-app {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  overflow: hidden;
}
.viewer-header {
  position: relative;
  z-index: 10;
  min-width: 0;
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: calc(.38rem + env(safe-area-inset-top)) max(.65rem, env(safe-area-inset-right)) .38rem max(.65rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: var(--bar-bg);
  box-shadow: 0 4px 18px rgba(0,0,0,.16);
  backdrop-filter: blur(14px);
}
.viewer-back,
.viewer-button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.075);
  color: var(--paper2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
.viewer-back:hover,
.viewer-button:hover { background: var(--coral); }
.viewer-back:focus-visible,
.viewer-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.viewer-button:disabled {
  opacity: .34;
  cursor: not-allowed;
}
.viewer-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.viewer-brand {
  min-width: 0;
  margin-right: auto;
}
.viewer-brand strong,
.viewer-brand span {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewer-brand strong {
  font: 500 clamp(.96rem,2vw,1.1rem)/1.15 Georgia, "Times New Roman", serif;
}
.viewer-brand span {
  margin-top: .16rem;
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .045em;
}
.viewer-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--coral) transparent;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.viewer-stage-inner {
  width: 100%;
  min-width: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.viewer-deck {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  filter: drop-shadow(0 24px 26px var(--shadow));
  transition: opacity .16s ease, transform .16s ease;
  transform-origin: center center;
}
.viewer-deck.turning { opacity: .72; transform: scale(.992); }
.viewer-page {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(20,62,58,.14);
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(255,255,255,.04);
}
.viewer-page.left {
  box-shadow: inset -18px 0 24px -23px rgba(0,0,0,.65);
}
.viewer-page.right {
  box-shadow: inset 18px 0 24px -23px rgba(0,0,0,.65);
}
.viewer-page img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.viewer-page-number {
  position: absolute;
  right: .45rem;
  bottom: .35rem;
  min-width: 1.45rem;
  padding: .12rem .26rem;
  background: rgba(4,31,29,.72);
  color: #fff;
  font-size: .66rem;
  line-height: 1;
  text-align: center;
  pointer-events: none;
}
.viewer-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: linear-gradient(145deg,#f9f4e9,#fffdf7);
  color: var(--ink);
  text-align: center;
  font-size: .78rem;
}
.viewer-loading[hidden] { display: none; }
.viewer-hint {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: .5rem;
  max-width: calc(100% - 1rem);
  transform: translateX(-50%);
  padding: .42rem .65rem;
  background: rgba(4,31,29,.8);
  color: #e5efec;
  font-size: .7rem;
  line-height: 1.25;
  white-space: nowrap;
  pointer-events: none;
  opacity: .92;
  transition: opacity .25s ease;
}
.viewer-hint.is-hidden { opacity: 0; }
.viewer-footer {
  position: relative;
  z-index: 10;
  min-width: 0;
  display: grid;
  gap: .35rem;
  padding: .38rem max(.55rem, env(safe-area-inset-right)) calc(.38rem + env(safe-area-inset-bottom)) max(.55rem, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: var(--bar-bg);
  backdrop-filter: blur(14px);
}
.viewer-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .38rem;
}
.viewer-toolbar-group {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .38rem;
}
.viewer-button {
  padding: 0 .66rem;
  font-weight: 750;
  font-size: .75rem;
  line-height: 1;
}
.viewer-button .label { white-space: nowrap; }
.viewer-counter {
  min-width: 82px;
  padding: 0 .3rem;
  color: #d2dfdb;
  font-size: .75rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.viewer-zoom {
  min-width: 52px;
  color: #d2dfdb;
  font-size: .72rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.viewer-online-note {
  margin: 0;
  color: #a9beb8;
  font-size: .67rem;
  line-height: 1.25;
  text-align: center;
}
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
@media (max-width: 760px) {
  .viewer-header { gap: .45rem; padding-left: max(.45rem,env(safe-area-inset-left)); padding-right: max(.45rem,env(safe-area-inset-right)); }
  .viewer-brand span { font-size: .66rem; }
  .viewer-stage-inner { padding: 8px; }
  .viewer-hint { bottom: .3rem; font-size: .66rem; }
  .viewer-button .label { display: none; }
  .viewer-button { padding: 0 .45rem; }
}
@media (max-width: 480px) and (orientation: portrait) {
  .viewer-header { min-height: 50px; }
  .viewer-brand strong { font-size: .92rem; }
  .viewer-footer { gap: .28rem; padding-top: .3rem; }
  .viewer-toolbar { display: grid; grid-template-columns: 1fr; gap: .28rem; }
  .viewer-toolbar-group { justify-content: center; }
  .viewer-counter { min-width: 66px; }
  .viewer-online-note { font-size: .62rem; }
}
@media (orientation: landscape) and (max-height: 430px) {
  .viewer-header {
    min-height: 48px;
    padding-top: max(.15rem,env(safe-area-inset-top));
    padding-bottom: .15rem;
  }
  .viewer-brand span { display: none; }
  .viewer-stage-inner { padding: 5px 8px; }
  .viewer-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .28rem;
    padding-top: .18rem;
    padding-bottom: max(.18rem,env(safe-area-inset-bottom));
  }
  .viewer-toolbar { gap: .25rem; }
  .viewer-toolbar-group { gap: .25rem; }
  .viewer-button { min-width: 44px; min-height: 44px; }
  .viewer-counter { min-width: 62px; padding-inline: .1rem; }
  .viewer-zoom { min-width: 44px; }
  .viewer-online-note, .viewer-hint { display: none; }
}
@media (max-width: 360px) and (orientation: portrait) {
  .viewer-brand span { display: none; }
  .viewer-toolbar-group { gap: .22rem; }
  .viewer-button { min-width: 44px; }
  .viewer-counter { min-width: 58px; font-size: .7rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
