/* styles.css */
:root {
  --bg: #0a1525;
  --bg-deep: #060d18;
  --panel: rgba(20, 32, 50, 0.70);
  --panel-strong: rgba(24, 36, 56, 0.92);
  --line: rgba(232, 185, 51, 0.30);
  --line-soft: rgba(232, 185, 51, 0.14);
  --gold: #e8b933;
  --gold-bright: #ffd86f;
  --gold-deep: #7d5a12;
  --text: #f3f5f9;
  --muted: rgba(220, 228, 240, 0.58);
  --muted-strong: rgba(220, 228, 240, 0.78);
  --soft: rgba(255, 255, 255, 0.07);
  --shadow: rgba(0, 0, 0, 0.72);
  --zoom: 1;
  --reader-width: min(92vw, 1180px);
  --radius-page: 18px;
  --transition-fast: 0.18s ease;
  --transition-med: 0.32s ease;
  --mono: 'JetBrains Mono', 'Consolas', ui-monospace, monospace;
  --display: 'Bebas Neue', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(ellipse at 60% -8%, rgba(232, 185, 51, 0.10) 0%, transparent 38%),
    radial-gradient(ellipse at -4% 18%, rgba(80, 130, 200, 0.08) 0%, transparent 36%),
    linear-gradient(150deg, #060d18 0%, #0c1830 46%, #060d18 100%);
  font-family: var(--mono);
}

button, input { font: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }

/* ── AMBIENT LAYERS ── */
#starfield, .spotlight, .grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
#starfield { z-index: 0; opacity: 0.40; }
.spotlight {
  z-index: 1;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 24%), rgba(232, 185, 51, 0.10) 0%, transparent 30rem);
  mix-blend-mode: screen;
  transition: background 0.05s linear;
}
.grain {
  z-index: 2;
  opacity: 0.05;
  background-image:
    repeating-radial-gradient(circle at 17% 29%, rgba(255,255,255,.28) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(255,255,255,.08) 2px 3px);
}

/* ── LOADING SCREEN ── */
.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(4, 9, 17, 0.96);
  backdrop-filter: blur(18px);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.loading.done { opacity: 0; visibility: hidden; pointer-events: none; }

.loading-card {
  width: min(90vw, 460px);
  padding: 40px 36px 34px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(155deg, rgba(22, 34, 54, 0.98) 0%, rgba(8, 14, 24, 0.96) 100%);
  box-shadow:
    0 32px 100px rgba(0, 0, 0, 0.72),
    0 0 60px rgba(232, 185, 51, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  text-align: center;
}

.loading-mark {
  display: inline-grid;
  place-items: center;
  width: 80px;
  height: 80px;
  margin-bottom: 22px;
  border: 2px solid var(--gold);
  border-radius: 4px;
  color: var(--gold-bright);
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: 0.06em;
  text-shadow: 0 0 24px rgba(255, 216, 111, 0.5);
  box-shadow: 0 0 32px rgba(232, 185, 51, 0.14), inset 0 0 20px rgba(232, 185, 51, 0.05);
  animation: markPulse 2.4s ease-in-out infinite;
}
@keyframes markPulse {
  0%, 100% { box-shadow: 0 0 32px rgba(232,185,51,.14), inset 0 0 20px rgba(232,185,51,.05); }
  50% { box-shadow: 0 0 48px rgba(232,185,51,.26), inset 0 0 28px rgba(232,185,51,.10); }
}

.loading-title {
  margin-bottom: 24px;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.loading-bar {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}
.loading-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold), var(--gold-bright), #fff);
  box-shadow: 0 0 24px rgba(255, 216, 111, 0.55);
  border-radius: 999px;
  transition: width 0.38s ease;
}

.loading-text {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
}

/* ── MASTHEAD ── */
.masthead {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px clamp(16px, 3vw, 42px);
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(6, 12, 22, 0.92) 0%, rgba(6, 12, 22, 0.55) 100%);
  backdrop-filter: blur(24px) saturate(150%);
}

.brand { display: flex; align-items: center; gap: 14px; text-align: left; transition: opacity var(--transition-fast); }
.brand:hover { opacity: 0.88; }

.brand-logo {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 50px;
  border: 2px solid var(--gold);
  border-radius: 4px;
  color: var(--gold-bright);
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  box-shadow: 0 0 28px rgba(232, 185, 51, 0.14), inset 0 0 24px rgba(232, 185, 51, 0.06);
  flex-shrink: 0;
}

.brand strong {
  display: block;
  font-size: clamp(0.92rem, 2vw, 1.20rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.1;
  font-family: var(--mono);
}
.brand em {
  display: block;
  margin-top: 3px;
  color: var(--gold);
  font-style: normal;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ── TOP NAV BUTTONS ── */
.top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.top-actions button {
  border: 1px solid var(--line-soft);
  color: var(--text);
  background: linear-gradient(180deg, rgba(28, 40, 60, 0.85) 0%, rgba(10, 16, 28, 0.85) 100%);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 24px rgba(0, 0, 0, 0.24);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.top-actions button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 216, 111, 0.56);
  background: linear-gradient(180deg, rgba(38, 44, 30, 0.90) 0%, rgba(16, 18, 10, 0.90) 100%);
  box-shadow: 0 0 24px rgba(232, 185, 51, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.top-actions button:active { transform: translateY(0); }

/* ── LAYOUT GRID ── */
.masthead, .layout, .footer-note { position: relative; z-index: 5; }

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: clamp(16px, 2.5vw, 32px);
  max-width: 1640px;
  margin: 0 auto;
  padding: 28px clamp(14px, 3vw, 42px) 16px;
}

/* ── THUMBNAIL PANEL ── */
.thumb-panel {
  align-self: start;
  position: sticky;
  top: 96px;
  padding: 16px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  background: linear-gradient(170deg, rgba(20, 32, 50, 0.74) 0%, rgba(6, 12, 22, 0.50) 100%);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 64px rgba(0, 0, 0, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.panel-title {
  margin-bottom: 12px;
  padding: 0 4px;
  color: var(--gold);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.thumb-rail { display: grid; gap: 7px; }

.thumb {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 9px;
  align-items: center;
  width: 100%;
  padding: 9px 11px;
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  text-align: left;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}
.thumb:hover { transform: translateX(2px); border-color: rgba(255, 216, 111, 0.32); background: rgba(232, 185, 51, 0.05); }
.thumb.active {
  transform: translateX(4px);
  border-color: rgba(255, 216, 111, 0.60);
  background: rgba(232, 185, 51, 0.09);
  box-shadow: 0 0 18px rgba(232, 185, 51, 0.08);
}
.thumb .num { font-size: 0.62rem; font-weight: 800; color: var(--gold-bright); letter-spacing: 0.04em; }
.thumb .name { display: block; font-size: 0.74rem; line-height: 1.25; color: var(--muted-strong); }
.thumb.active .name { color: var(--text); }

/* ── READER AREA ── */
.reader { min-width: 0; padding-bottom: 36px; }

.reader-topline {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin: 0 auto 20px;
  max-width: calc(var(--reader-width) + 112px);
}

.eyebrow {
  color: var(--gold);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

h1 {
  font-family: var(--display);
  font-size: clamp(1.7rem, 4vw, 3.4rem);
  line-height: 0.96;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.reader-topline p { color: var(--muted); font-size: 0.86rem; line-height: 1.5; font-family: var(--mono); }

.page-count {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-family: var(--mono);
}
.page-count #pageNow { font-size: 2.1rem; color: var(--gold-bright); line-height: 1; text-shadow: 0 0 24px rgba(255, 216, 111, 0.20); }
.page-count span:not(#pageNow) { color: rgba(255, 255, 255, 0.26); }

/* ── BOOK SHELL ── */
.book-shell {
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: start;
  gap: 16px;
}

.book-viewport {
  max-height: calc(100vh - 220px);
  min-height: 600px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(232, 185, 51, 0.05) 0%, transparent 34rem),
    rgba(6, 12, 22, 0.55);
  box-shadow:
    0 36px 100px rgba(0, 0, 0, 0.50),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 -1px 0 rgba(0, 0, 0, 0.30);
  backdrop-filter: blur(12px);
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 185, 51, 0.34) rgba(255, 255, 255, 0.03);
  transition: box-shadow var(--transition-med);
}
.book-viewport::-webkit-scrollbar { width: 6px; }
.book-viewport::-webkit-scrollbar-track { background: rgba(255,255,255,.03); border-radius: 999px; }
.book-viewport::-webkit-scrollbar-thumb { background: rgba(232,185,51,.32); border-radius: 999px; }
.book-viewport:focus { outline: 2px solid rgba(255, 216, 111, 0.36); outline-offset: 3px; }

.book {
  position: relative;
  width: min(calc(var(--reader-width) * var(--zoom)), 100%);
  margin: 0 auto;
  perspective: 2000px;
  transform-style: preserve-3d;
  transition: width var(--transition-fast);
}

/* ── PAGE STAGE (the live, interactive "page image" replacement) ── */
.page-stage {
  position: relative;
  width: 100%;
  min-height: 600px;
  border-radius: var(--radius-page);
  background: linear-gradient(165deg, rgba(14, 22, 38, 0.96) 0%, rgba(8, 14, 24, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.64),
    0 0 0 1px rgba(232, 185, 51, 0.08),
    0 0 80px rgba(232, 185, 51, 0.05);
  overflow: hidden;
  transition: opacity 0.22s ease;
  padding: clamp(24px, 4vw, 56px);
}
.page-stage.fading { opacity: 0; }

/* ── PAGE FX ── */
.page-glow {
  position: absolute;
  inset: 0% -6% auto;
  height: 18%;
  background: radial-gradient(ellipse at 50% 0%, rgba(232, 185, 51, 0.14) 0%, transparent 70%);
  filter: blur(32px);
  opacity: 0.55;
  z-index: -1;
  pointer-events: none;
}

.page-shine {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-page);
  background: linear-gradient(112deg, transparent 18%, rgba(255,255,255,0.08) 40%, transparent 56%);
  mix-blend-mode: screen;
  pointer-events: none;
  transform: translateX(-150%);
}
.book.turning .page-shine { animation: shineSweep 0.76s ease; }
@keyframes shineSweep { to { transform: translateX(150%); } }

/* ── PAGE TURN FLIP SHEET ── */
.flip-sheet {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  display: none;
  background-size: 200% 100%;
  background-repeat: no-repeat;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.flip-sheet.next {
  display: block; right: 0; border-radius: 0 var(--radius-page) var(--radius-page) 0;
  background-position: right top; transform-origin: left center;
  animation: flipNext 0.76s cubic-bezier(0.18, 0.80, 0.14, 1) forwards;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.50);
}
.flip-sheet.prev {
  display: block; left: 0; border-radius: var(--radius-page) 0 0 var(--radius-page);
  background-position: left top; transform-origin: right center;
  animation: flipPrev 0.76s cubic-bezier(0.18, 0.80, 0.14, 1) forwards;
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.50);
}
@keyframes flipNext { 0% { transform: rotateY(0deg); filter: brightness(1); } 45% { filter: brightness(0.72); } 100% { transform: rotateY(-172deg); filter: brightness(0.28); } }
@keyframes flipPrev { 0% { transform: rotateY(0deg); filter: brightness(1); } 45% { filter: brightness(0.72); } 100% { transform: rotateY(172deg); filter: brightness(0.28); } }

/* ── TURN BUTTONS ── */
.turn-btn {
  position: sticky;
  top: 46%;
  z-index: 10;
  width: 54px;
  height: 76px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--gold-bright);
  background: linear-gradient(180deg, rgba(28, 38, 56, 0.95) 0%, rgba(6, 10, 18, 0.95) 100%);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.38), 0 0 30px rgba(232, 185, 51, 0.06);
  font-size: 3rem;
  line-height: 1;
  transition: transform var(--transition-fast), opacity var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.turn-btn:hover:not(:disabled) { transform: scale(1.07); border-color: rgba(255, 216, 111, 0.62); box-shadow: 0 0 40px rgba(232, 185, 51, 0.20), 0 16px 48px rgba(0, 0, 0, 0.40); }
.turn-btn:active:not(:disabled) { transform: scale(0.97); }
.turn-btn:disabled { opacity: 0.16; cursor: not-allowed; }

/* ── CONTROL STRIP ── */
.control-strip {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  gap: 14px;
  align-items: center;
  max-width: calc(var(--reader-width) + 112px);
  margin: 20px auto 0;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  background: rgba(10, 16, 28, 0.66);
  backdrop-filter: blur(18px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
}
.control-strip button {
  border: 1px solid var(--line-soft);
  color: var(--text);
  background: linear-gradient(180deg, rgba(28, 40, 60, 0.85) 0%, rgba(10, 16, 28, 0.85) 100%);
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 0.76rem;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 8px 24px rgba(0,0,0,.22);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.control-strip button:hover { transform: translateY(-1px); border-color: rgba(255, 216, 111, 0.56); box-shadow: 0 0 20px rgba(232, 185, 51, 0.12), inset 0 1px 0 rgba(255,255,255,.07); }
.control-strip button:disabled { opacity: 0.20; cursor: not-allowed; transform: none; }

input[type="range"] {
  appearance: none; width: 100%; height: 5px; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold) var(--progress, 0%), rgba(255,255,255,.08) var(--progress, 0%));
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 18px; height: 18px; border: 2px solid #0a1119; border-radius: 50%;
  background: var(--gold-bright); box-shadow: 0 0 20px rgba(255,216,111,.40); transition: transform var(--transition-fast);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.14); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border: 2px solid #0a1119; border-radius: 50%;
  background: var(--gold-bright); box-shadow: 0 0 20px rgba(255,216,111,.40);
}

/* ── FOOTER ── */
.footer-note {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 14px;
  padding: 12px 20px 32px; color: rgba(255, 255, 255, 0.24); font-size: 0.66rem;
  letter-spacing: 0.10em; text-transform: uppercase;
}
.footer-note span { display: flex; align-items: center; gap: 10px; }
.footer-note span::before {
  content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 10px rgba(255, 216, 111, 0.70); flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════
   PAGE TEMPLATES (rendered into .page-stage by script.js)
   ════════════════════════════════════════════════════════════ */

.tpl-divider { height: 1px; background: var(--line); margin: 0 0 32px; }
.tpl-divider.bottom { margin: 40px 0 0; }
.tpl-tag { color: var(--gold); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; text-align: center; display: block; margin-bottom: 28px; }
.tpl-tag.split { text-align: left; display: flex; gap: 12px; justify-content: flex-start; margin-bottom: 0; }
.tpl-tag.split em { color: var(--muted); font-style: normal; opacity: 0.5; }

/* — COVER TEMPLATE — */
.tpl-cover { display: flex; flex-direction: column; min-height: 560px; }
.tpl-cover-headline {
  background: rgba(255,255,255,0.025);
  border-radius: 14px;
  padding: clamp(28px, 5vw, 56px) clamp(20px, 4vw, 48px);
  text-align: center;
  margin-bottom: 32px;
}
.tpl-cover-headline h2 {
  font-family: var(--display);
  font-size: clamp(1.6rem, 4.4vw, 3.4rem);
  line-height: 1.08;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.tpl-cover-sub { text-align: center; color: var(--muted-strong); font-size: clamp(0.82rem, 1.4vw, 1rem); line-height: 1.7; margin-bottom: 30px; }
.tpl-cover-body { max-width: 880px; margin: 0 auto; text-align: center; color: var(--muted-strong); font-size: clamp(0.84rem, 1.2vw, 0.96rem); line-height: 1.8; }
.tpl-cover-body p { margin-bottom: 18px; }
.tpl-cover-body p:last-child { margin-bottom: 0; }
.tpl-cover-spacer { flex: 1; }

/* — PLAYER PROFILE TEMPLATE — */
.tpl-profile-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 28px; flex-wrap: wrap; gap: 8px; }
.tpl-profile-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 40px);
  align-items: start;
}
.tpl-photo-wrap { position: relative; border-radius: 12px; overflow: hidden; background: #050a12; box-shadow: 0 18px 50px rgba(0,0,0,0.5); }
.tpl-photo-wrap img { display: block; width: 100%; height: auto; }
.tpl-name { font-family: var(--display); font-size: clamp(1.8rem, 3.2vw, 2.8rem); line-height: 1.0; text-transform: uppercase; margin: 4px 0 8px; }
.tpl-meta { color: var(--gold); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; margin-bottom: 16px; display: block; }
.tpl-meta span { color: var(--muted); font-weight: 500; }
.tpl-body p { color: var(--muted-strong); font-size: 0.86rem; line-height: 1.75; margin-bottom: 16px; }
.tpl-body p:last-child { margin-bottom: 0; }

.tpl-stat-ring { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 22px; }
.ring-outer {
  position: relative;
  width: 132px; height: 132px;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  background: conic-gradient(var(--gold) calc(var(--ring-pct, 0) * 1%), rgba(255,255,255,0.06) 0);
  transition: transform var(--transition-fast);
}
.ring-outer:hover { transform: scale(1.04); }
.ring-outer::before {
  content: ""; position: absolute; inset: 10px; border-radius: 50%;
  background: radial-gradient(circle, rgba(20,30,46,0.95) 60%, rgba(20,30,46,0.7) 100%);
}
.ring-value { position: relative; font-family: var(--display); font-size: 2.1rem; color: var(--gold-bright); z-index: 1; }
.ring-label { font-size: 0.74rem; font-weight: 700; color: var(--text); text-align: center; }
.ring-sub { font-size: 0.68rem; color: var(--muted); text-align: center; }

.tpl-callout {
  border-top: 1px dashed rgba(255,255,255,0.10);
  padding-top: 18px;
  margin-top: 22px;
}
.tpl-callout-tag { color: var(--gold); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase; margin-bottom: 8px; display: block; }
.tpl-callout p { color: var(--muted); font-size: 0.80rem; line-height: 1.7; }

.tpl-advanced {
  margin-top: 22px;
  border-top: 1px dashed rgba(255,255,255,0.10);
  padding-top: 18px;
}
.tpl-advanced-toggle {
  display: flex; align-items: center; gap: 8px;
  color: var(--gold); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase;
  cursor: pointer; user-select: none; width: 100%; text-align: left;
}
.tpl-advanced-toggle .chev { transition: transform var(--transition-fast); font-size: 0.7rem; }
.tpl-advanced-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.tpl-advanced-body {
  max-height: 0; overflow: hidden;
  transition: max-height 0.32s ease;
}
.tpl-advanced-body.open { max-height: 600px; }
.tpl-advanced-body p { color: var(--muted); font-size: 0.78rem; line-height: 1.75; margin-top: 12px; }

.tpl-qa { margin-top: 20px; border-top: 1px dashed rgba(255,255,255,0.10); padding-top: 18px; }
.tpl-qa-q { color: var(--gold-bright); font-size: 0.80rem; font-style: italic; line-height: 1.65; margin-bottom: 12px; }
.tpl-qa-a { color: var(--muted-strong); font-size: 0.80rem; line-height: 1.65; }

/* — GM RESPONSES TEMPLATE (two-column) — */
.tpl-gm-head { display: flex; justify-content: center; gap: 14px; margin-bottom: 30px; }
.tpl-gm-grid {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: clamp(20px, 3vw, 40px);
}
.tpl-gm-divider { background: rgba(255,255,255,0.08); }
.tpl-gm-col-head { margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.tpl-gm-name { font-family: var(--display); font-size: clamp(1.5rem, 2.6vw, 2.2rem); text-transform: uppercase; line-height: 1; }
.tpl-gm-role { color: var(--gold); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; margin-top: 4px; display: block; }
.tpl-gm-role span { color: var(--muted); font-weight: 500; }

.tpl-quote-block { margin-bottom: 24px; cursor: pointer; }
.tpl-quote-block:last-child { margin-bottom: 0; }
.tpl-quote-prompt { color: var(--gold); font-size: 0.78rem; font-weight: 600; margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline; }
.tpl-quote-prompt .chev { font-size: 0.66rem; transition: transform var(--transition-fast); flex-shrink: 0; margin-top: 2px; }
.tpl-quote-block[aria-expanded="true"] .chev { transform: rotate(90deg); }
.tpl-quote-text {
  color: var(--muted-strong); font-size: 0.82rem; line-height: 1.7;
  max-height: 0; overflow: hidden; transition: max-height 0.32s ease, opacity 0.32s ease;
  opacity: 0;
}
.tpl-quote-text.open { max-height: 400px; opacity: 1; }
.tpl-quote-preview { color: var(--muted); font-size: 0.76rem; font-style: italic; opacity: 0.6; }
.tpl-quote-block[aria-expanded="true"] .tpl-quote-preview { display: none; }

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .tpl-profile-grid { grid-template-columns: 1fr; }
  .tpl-photo-wrap { max-width: 280px; }
  .tpl-gm-grid { grid-template-columns: 1fr; }
  .tpl-gm-divider { display: none; }
}

@media (max-width: 1060px) {
  .layout { grid-template-columns: 1fr; }
  .thumb-panel { position: relative; top: auto; overflow-x: auto; padding: 12px; }
  .thumb-rail { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
  .thumb { min-width: 170px; flex-shrink: 0; }
  .book-shell { grid-template-columns: 42px minmax(0, 1fr) 42px; gap: 10px; }
  .turn-btn { width: 42px; height: 62px; font-size: 2.4rem; }
}

@media (max-width: 680px) {
  .masthead { flex-direction: column; align-items: flex-start; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .reader-topline { flex-direction: column; align-items: flex-start; }
  .book-shell { grid-template-columns: 1fr; }
  .turn-btn { position: fixed; top: 50%; transform: translateY(-50%); }
  .turn-left { left: 8px; }
  .turn-right { right: 8px; }
  .turn-btn:hover:not(:disabled) { transform: translateY(-50%) scale(1.07); }
  .page-stage { padding: 18px 14px; min-height: 520px; }
  .control-strip { grid-template-columns: 1fr; }
  :root { --reader-width: 96vw; }
}

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


/* ── FINISHING PATCH: readable zoom, page print, utility cards ── */
body:not(.fit-width) .book {
  width: calc(var(--reader-width) * var(--zoom));
  max-width: none;
}
body.fit-width .book { width: 100%; max-width: 100%; }

.tpl-mini-kicker {
  color: var(--gold);
  font-size: 0.70rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  margin: 20px 0 8px;
}
.tpl-small-note {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.65;
}
.tpl-profile-grid.compact-photo { grid-template-columns: minmax(220px, 360px) minmax(0, 1fr) minmax(230px, 0.72fr); }
.tpl-photo-caption {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.45;
  border-top: 1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.24);
}
.tpl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.tpl-pill {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted-strong);
  background: rgba(255,255,255,.035);
  font-size: 0.68rem;
}
.tpl-cover-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 30px auto 0;
  max-width: 760px;
}
.tpl-cover-meta .metric {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
  padding: 14px 12px;
  text-align: center;
}
.tpl-cover-meta strong {
  display: block;
  font-family: var(--display);
  font-size: 1.9rem;
  color: var(--gold-bright);
  line-height: 1;
}
.tpl-cover-meta span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.tpl-page-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: center;
  color: var(--gold);
  font-size: 0.66rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.tpl-gm-note {
  margin-top: 28px;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: rgba(255,255,255,.025);
  color: var(--muted-strong);
  font-size: .80rem;
  line-height: 1.7;
}

@media (max-width: 900px) {
  .tpl-cover-meta { grid-template-columns: 1fr; }
  .tpl-profile-grid.compact-photo { grid-template-columns: 1fr; }
}

@media print {
  body { background: #0a1525; }
  .masthead, .thumb-panel, .turn-btn, .control-strip, .footer-note, .loading { display: none !important; }
  .layout { display: block; padding: 0; }
  .book-viewport { max-height: none; overflow: visible; border: 0; box-shadow: none; }
  .book, body.fit-width .book, body:not(.fit-width) .book { width: 100%; max-width: 100%; }
  .page-stage { min-height: auto; box-shadow: none; page-break-after: always; }
}

/* ── FINAL POLISH EFFECTS ── */
.book {
  will-change: transform, width;
}

.page-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 216, 111, 0.00) 32%,
    rgba(255, 216, 111, 0.18) 44%,
    rgba(255, 255, 255, 0.18) 50%,
    rgba(255, 216, 111, 0.10) 56%,
    transparent 70%
  );
  transform: translateX(-130%);
  opacity: 0;
}

.page-stage.reveal-sweep::after {
  animation: pageRevealSweep 0.9s ease forwards;
}

@keyframes pageRevealSweep {
  0% {
    opacity: 0;
    transform: translateX(-130%);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(130%);
  }
}

.ring-outer::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 216, 111, 0.18);
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.ring-outer:hover::after {
  opacity: 1;
  transform: scale(1);
}

.ring-outer:hover .ring-value {
  text-shadow: 0 0 22px rgba(255, 216, 111, 0.55);
}
