:root {
  --ink: #f4f2ed;
  --muted: #9a9b96;
  --surface: #191a18;
  --surface-2: #232421;
  --line: rgba(255, 255, 255, .12);
  --accent: #d1ff3f;
  --page-ratio: 0.7222;
  --zoom: 1;
  --toolbar-h: 68px;
  --bottom-h: 64px;
  --ease-page: cubic-bezier(.2, .68, .12, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 42%, #30322e 0, #1b1c1a 36%, #111210 78%),
    #111210;
  font-family: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 900;
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 clamp(14px, 2.5vw, 36px);
  border-bottom: 1px solid var(--line);
  background: rgba(15, 16, 14, .82);
  backdrop-filter: blur(18px) saturate(130%);
}







.toolbar { display: flex; align-items: center; gap: 4px; }
.tool {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #d7d8d3;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.tool:hover { color: white; background: rgba(255,255,255,.08); border-color: var(--line); }
.tool svg, .round-button svg, .search-box svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool-wide { width: auto; padding: 0 14px; }
.tool-wide span { font-size: 12px; font-weight: 650; letter-spacing: .02em; }
.divider { width: 1px; height: 22px; margin: 0 5px; background: var(--line); }

.viewer { position: fixed; inset: var(--toolbar-h) 0 0; overflow: hidden; }
.ambient-glow { position: absolute; width: 60vw; height: 60vw; left: 20vw; top: -15vw; border-radius: 50%; background: rgba(255,255,255,.025); filter: blur(50px); pointer-events: none; }

.book-viewport {
  position: absolute;
  inset: 0 0 var(--bottom-h);
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 28px 38px;
  scrollbar-color: rgba(255,255,255,.25) transparent;
}

.book-scale {
  position: relative;
  width: min(calc((100vh - var(--toolbar-h) - var(--bottom-h) - 56px) * 1.4444), calc(100vw - 100px));
  aspect-ratio: 1.4444;
  flex: none;
  transform: scale(var(--zoom));
  transform-origin: center;
  transition: transform .22s ease;
}

.book {
  position: absolute;
  inset: 0;
  perspective: 2600px;
  perspective-origin: 50% 45%;
  filter: drop-shadow(0 26px 38px rgba(0,0,0,.46));
}

.book::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(90deg, #e5e3df 0 49.94%, #f1f0ec 50.06% 100%);
  box-shadow: 0 2px 0 rgba(255,255,255,.45) inset, 0 -2px 0 rgba(0,0,0,.08) inset;
}

.book::after {
  content: "";
  position: absolute;
  z-index: 500;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 16px;
  transform: translateX(-50%);
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.22) 42%, rgba(255,255,255,.16) 51%, rgba(0,0,0,.15) 58%, transparent);
  opacity: .7;
  mix-blend-mode: multiply;
}

.sheet {
  position: absolute;
  left: 50%;
  top: 0;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform 1.6s var(--ease-page), filter 1.6s var(--ease-page);
  will-change: transform;
}

.sheet.no-transition { transition: none !important; }
.sheet.dragging { filter: drop-shadow(-14px 14px 18px rgba(0,0,0,.28)); }

.page-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
}

.page-face.front { transform: rotateY(0deg) translateZ(.2px); }
.page-face.back { transform: rotateY(180deg) translateZ(.2px); }

.page-face::after, .mobile-turn-front::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--fold-shadow, 0);
  background: linear-gradient(90deg, rgba(0,0,0,.42), transparent 14%, transparent 68%, rgba(255,255,255,.2) 92%, rgba(0,0,0,.12));
  transition: opacity .12s linear;
  mix-blend-mode: multiply;
}

.page-face.back::after { background: linear-gradient(90deg, rgba(0,0,0,.12), transparent 24%, transparent 78%, rgba(0,0,0,.34)); }

.page-image, .mobile-page-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.page-placeholder { position: absolute; inset: 0; display: grid; place-items: center; background: #efeee9; color: #aaa; font-size: 12px; }

.hotspots { position: absolute; inset: 0; z-index: 10; }
.page-hotspot {
  position: absolute;
  border: 0;
  border-radius: 2px;
  padding: 0;
  cursor: pointer;
  color: transparent;
  background: transparent;
  box-shadow: 0 0 0 0 rgba(177, 226, 34, 0);
  transition: background .18s ease, box-shadow .18s ease;
}
.page-hotspot:hover, .page-hotspot:focus-visible {
  color: transparent;
  background: rgba(205, 255, 53, .12);
  box-shadow: 0 0 0 1.5px rgba(205, 255, 53, .9), 0 0 20px rgba(205, 255, 53, .2);
  outline: 0;
}
.page-hotspot.external::after { content: "↗"; position: absolute; right: 2px; top: -16px; color: white; font-size: 10px; border-radius: 10px; padding: 2px 5px; background: rgba(18,18,16,.82); opacity: 0; transition: opacity .18s; }
.page-hotspot.external:hover::after { opacity: 1; }

.mobile-book { display: none; }

.corner-zone {
  position: absolute;
  z-index: 750;
  bottom: 0;
  width: clamp(64px, 7vw, 100px);
  height: clamp(64px, 7vw, 100px);
  overflow: hidden;
  border: 0;
  padding: 0;
  color: transparent;
  background: transparent;
  cursor: grab;
  touch-action: none;
}
.corner-zone:active { cursor: grabbing; }
.corner-back { left: 0; }
.corner-forward { right: 0; }
.corner-zone[disabled] { pointer-events: none; opacity: 0; }
.corner-paper {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 100%;
  opacity: .12;
  transition: opacity .25s ease, transform .32s var(--ease-page);
  filter: drop-shadow(0 0 8px rgba(0,0,0,.35));
}
.corner-forward .corner-paper { right: 0; transform-origin: right bottom; transform: translate(48%, 48%) rotate(-2deg); background: linear-gradient(135deg, transparent 49%, rgba(255,255,255,.92) 50%, rgba(170,170,165,.7) 76%, rgba(50,50,48,.25)); clip-path: polygon(0 100%,100% 0,100% 100%); }
.corner-back .corner-paper { left: 0; transform-origin: left bottom; transform: translate(-48%, 48%) rotate(2deg); background: linear-gradient(225deg, transparent 49%, rgba(255,255,255,.92) 50%, rgba(170,170,165,.7) 76%, rgba(50,50,48,.25)); clip-path: polygon(0 0,100% 100%,0 100%); }
.corner-zone:hover .corner-paper, .corner-zone:focus-visible .corner-paper, .corner-zone.is-active .corner-paper { opacity: .95; transform: translate(0,0) rotate(0); }
.corner-label { position: absolute; bottom: 10px; color: #161714; font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .09em; opacity: 0; transition: opacity .2s ease .05s; }
.corner-forward .corner-label { right: 10px; transform: rotate(-45deg) translate(5px,-4px); }
.corner-back .corner-label { left: 10px; transform: rotate(45deg) translate(-5px,-4px); }
.corner-zone:hover .corner-label, .corner-zone:focus-visible .corner-label { opacity: .75; }

.bottombar {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 800;
  height: var(--bottom-h);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
}
.round-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(31,32,29,.78);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.round-button:hover { background: #30312e; border-color: rgba(255,255,255,.25); transform: scale(1.04); }
.round-button:disabled { opacity: .3; cursor: default; transform: none; }
.page-status { position: relative; min-width: 112px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 999px; color: #d1d2cd; background: rgba(31,32,29,.78); backdrop-filter: blur(12px); font-size: 12px; font-variant-numeric: tabular-nums; cursor: text; }
.page-status input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: text; text-align: center; border: 0; border-radius: inherit; }
.page-status:focus-within input { opacity: 1; color: #111; background: white; outline: 2px solid var(--accent); }
.gesture-help { position: absolute; left: calc(100% + 18px); width: 160px; color: #777873; font-size: 10px; letter-spacing: .04em; white-space: nowrap; }

.side-panel {
  position: fixed;
  z-index: 1100;
  inset: 0 auto 0 0;
  width: min(430px, calc(100vw - 28px));
  overflow: hidden;
  color: #1c1d1a;
  background: #f5f3ed;
  box-shadow: 24px 0 60px rgba(0,0,0,.34);
  transform: translateX(-104%);
  transition: transform .42s var(--ease-page);
}
.side-panel.open { transform: translateX(0); }
.panel-scrim { position: fixed; z-index: 1050; inset: 0; border: 0; visibility: hidden; opacity: 0; background: rgba(0,0,0,.48); backdrop-filter: blur(2px); transition: opacity .32s ease, visibility .32s; }
.panel-scrim.open { visibility: visible; opacity: 1; }
.panel-head { height: 70px; display: flex; align-items: center; justify-content: center; padding: 0 22px 0 30px; border-bottom: 1px solid rgba(0,0,0,.1); }
.panel-tabs { display: flex; gap: 20px; }
.panel-tab { border: 0; padding: 24px 0 20px; color: #85857e; background: none; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; border-bottom: 2px solid transparent; }
.panel-tab.active { color: #161714; border-color: #161714; }
.panel-close { width: 36px; height: 36px; border: 0; border-radius: 50%; color: #444; background: rgba(0,0,0,.06); font-size: 25px; font-weight: 300; line-height: 1; cursor: pointer; }
.panel-view { display: none; height: calc(100% - 70px); overflow-y: auto; padding: 30px; }
.panel-view.active { display: block; }
.panel-kicker { margin: 0 0 8px; color: #777872; font-size: 10px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.panel-view h1 { margin: 0 0 30px; max-width: 330px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(28px, 5vw, 38px); font-weight: 400; line-height: 1.05; letter-spacing: -.035em; }
.toc-section { margin: 28px 0 9px; padding-top: 15px; border-top: 1px solid rgba(0,0,0,.14); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.toc-item { width: 100%; display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: start; border: 0; padding: 10px 4px; border-bottom: 1px solid rgba(0,0,0,.08); color: inherit; background: transparent; text-align: left; cursor: pointer; }
.toc-item:hover { background: rgba(0,0,0,.035); }
.toc-num { color: #73746e; font-family: Georgia, serif; font-size: 15px; font-variant-numeric: tabular-nums; }
.toc-copy b { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 15px; font-weight: 400; line-height: 1.2; }
.toc-copy small { display: block; margin-top: 3px; color: #74756f; font-size: 11px; line-height: 1.35; }
.toc-arrow { margin-top: 1px; color: #8a8b85; }

.search-box { height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid rgba(0,0,0,.2); border-radius: 6px; background: white; }
.search-box svg { flex: none; color: #777; }
.search-box input { width: 100%; border: 0; outline: 0; color: #191a18; background: transparent; }
.search-hint { margin: 16px 2px; color: #777872; font-size: 12px; line-height: 1.5; }
.search-result { width: 100%; display: grid; grid-template-columns: 38px 1fr; gap: 12px; border: 0; padding: 14px 4px; border-top: 1px solid rgba(0,0,0,.1); color: #22231f; background: none; text-align: left; cursor: pointer; }
.search-result:hover { background: rgba(0,0,0,.035); }
.search-page { color: #75766f; font-family: Georgia, serif; font-size: 15px; }
.search-snippet { font-size: 12px; line-height: 1.5; }
.search-snippet mark { background: rgba(196, 237, 64, .48); color: inherit; }

.toast { position: fixed; z-index: 1300; left: 50%; bottom: 82px; transform: translate(-50%, 15px); padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; color: white; background: rgba(22,23,20,.92); box-shadow: 0 10px 35px rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }



















@media (max-width: 840px) {
  :root { --toolbar-h: 58px; --bottom-h: 62px; }
  
  .topbar { padding: 0 10px 0 16px; }
  
  .toolbar { gap: 0; }
  .tool { width: 38px; height: 38px; }
  .tool-wide { padding: 0; }
  .book-viewport { padding: 18px 16px; }
  .book-scale { width: min(calc((100vh - var(--toolbar-h) - var(--bottom-h) - 36px) * .7222), calc(100vw - 32px)); aspect-ratio: .7222; }
  .book { display: none; }
  .mobile-book { position: absolute; inset: 0; display: block; perspective: 1800px; filter: drop-shadow(0 20px 28px rgba(0,0,0,.45)); background: #f2f1ed; }
  .mobile-base, .mobile-turn { position: absolute; inset: 0; }
  .mobile-base { overflow: hidden; background: white; }
  .mobile-turn { display: none; transform-origin: left center; transform-style: preserve-3d; will-change: transform; }
  .mobile-turn.active { display: block; }
  .mobile-turn.settling { transition: transform 1.35s var(--ease-page); }
  .mobile-turn-front, .mobile-turn-back { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
  .mobile-turn-front { background: white; transform: rotateY(0deg) translateZ(.2px); }
  .mobile-turn-back { transform: rotateY(180deg); background: linear-gradient(90deg,#ddd,#f5f4f0); }
  .mobile-hotspots { position: absolute; z-index: 20; inset: 0; }
  .corner-zone { width: 82px; height: 82px; }
  .gesture-help { display: none; }
  .side-panel { width: min(390px, calc(100vw - 18px)); }
}

@media (max-width: 430px) {
  .tool { width: 36px; }
  .panel-view { padding: 24px 22px; }
  
  
  
  
  
  
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Natural page-curl engine ------------------------------------------------ */
.book-scale {
  transform: none;
  zoom: var(--zoom);
  transition: zoom .22s ease;
}

.book {
  position: relative;
  inset: auto;
  width: 100% !important;
  height: 100%;
  perspective: none;
  filter: drop-shadow(0 26px 38px rgba(0,0,0,.46));
  cursor: grab;
}

.book:active,
.book.is-turning { cursor: grabbing; }
.book::before,
.book::after { content: none; }

.book .stf__wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.book .stf__block {
  overflow: visible;
  perspective: 2400px;
}

.magazine-page {
  position: relative;
  overflow: hidden;
  color: #151613;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(20,20,18,.06) inset;
  user-select: none;
  -webkit-user-select: none;
}

.magazine-page.--left::after,
.magazine-page.--right::after {
  content: "";
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
}

.magazine-page.--left::after {
  background: linear-gradient(90deg, transparent 77%, rgba(0,0,0,.045) 94%, rgba(0,0,0,.16));
}

.magazine-page.--right::after {
  background: linear-gradient(90deg, rgba(0,0,0,.14), rgba(0,0,0,.035) 6%, transparent 23%);
}

.magazine-page .page-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  pointer-events: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.magazine-page .hotspots { z-index: 20; }

@media (max-width: 840px) {
  .book { display: block; }
  .book-scale { transform: none; }
}

@media (max-width: 840px) { .topbar { padding: 0 6px; } .toolbar { gap: 0; } }
@media (max-width: 840px) { .toolbar .tool-wide span, .toolbar .divider { display: none; } }
