/* ============================================================
   NEUROPAPER — style.css
   Dark premium theme. Cormorant Garamond + Inter.
   Gold #b59a6a. Background #08090a.
   No scrollbars. Mobile first.
============================================================ */

/* ============================================================
   RESET
============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; }
html, body { min-height: 100%; background: #07080a; overflow: hidden; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color: var(--text);
  display: grid;
  place-items: center;
}
button { font: inherit; border: 0; background: none; color: inherit; cursor: pointer; }
a { text-decoration: none; color: inherit; }
svg { display: block; }

/* ============================================================
   TOKENS
============================================================ */
:root {
  --bg:           #08090a;
  --bg2:          #111315;
  --panel:        rgba(255,255,255,.045);
  --panel2:       rgba(255,255,255,.07);
  --line:         rgba(255,255,255,.105);
  --text:         #f3f1ec;
  --soft:         #aaa49a;
  --muted:        #6f6b65;
  --gold:         #b59a6a;
  --gold-soft:    rgba(181,154,106,.22);
  --shadow:       rgba(0,0,0,.55);
  --dock-height:  88px;
}

/* ============================================================
   UTILITY
============================================================ */
.hidden { display: none !important; }
.serif { font-family: 'Cormorant Garamond', serif; font-weight: 600; letter-spacing: -.025em; }
.eyebrow {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .34em;
  font-size: 10px;
  font-weight: 700;
}

/* ============================================================
   SHARED SHELL BACKGROUNDS
============================================================ */
.shell-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  opacity: .36;
  background-image:
    linear-gradient(rgba(255,255,255,.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.017) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(circle at 50% 35%, black, transparent 80%);
}

.glow-top {
  position: absolute;
  top: 15%;
  left: 50%;
  width: 300px;
  height: 280px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(181,154,106,.105);
  filter: blur(64px);
}

.grain {
  position: absolute;
  inset: 0;
  opacity: .12;
  mix-blend-mode: overlay;
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,.035) 0 1px, transparent 1px 4px);
}

.ambient { position: absolute; border-radius: 999px; filter: blur(44px); opacity: .7; }
.ambient-gold { width: 210px; height: 210px; top: 120px; left: 110px; background: rgba(181,154,106,.1); }
.ambient-ink  { width: 260px; height: 260px; right: -150px; bottom: 160px; background: rgba(64,82,90,.18); }
.ambient-one  { width: 240px; height: 240px; right: -120px; top: -50px; background: radial-gradient(circle, rgba(181,154,106,.16), transparent 70%); filter: blur(30px); }
.ambient-two  { width: 320px; height: 320px; left: -180px; top: 320px; background: radial-gradient(circle, rgba(91,101,95,.18), transparent 70%); filter: blur(30px); }
.light-source { position: absolute; top: -90px; left: 46%; width: 300px; height: 220px; transform: translateX(-50%); background: rgba(181,154,106,.14); filter: blur(58px); }

/* ============================================================
   SCREEN SYSTEM
============================================================ */
.screen {
  display: none;
  flex-direction: column;
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 18%, rgba(181,154,106,.12), transparent 34%),
    radial-gradient(circle at 94% 78%, rgba(54,72,78,.18), transparent 32%),
    linear-gradient(160deg, #181a1c 0%, #101214 48%, #08090a 100%);
  border-inline: 1px solid rgba(255,255,255,.045);
}
.screen.active { display: flex; }
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 38%, rgba(0,0,0,.58) 100%);
  z-index: 0;
}

/* ============================================================
   FLOATING DOCK
============================================================ */
.floating-dock {
  position: absolute;
  z-index: 50;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(316px, calc(100vw - 52px));
  height: 76px;
  border-radius: 999px;
  display: grid;
  grid-template-columns: 1fr 76px 1fr;
  align-items: center;
  padding: 8px 13px;
  background: rgba(22,24,27,.72);
  border: 1px solid rgba(255,255,255,.11);
  backdrop-filter: blur(22px);
  box-shadow: 0 22px 70px rgba(0,0,0,.48), inset 0 1px 0 rgba(255,255,255,.07);
}

.dock-item {
  display: grid;
  place-items: center;
  gap: 4px;
  color: rgba(243,241,236,.38);
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: 9px;
  font-weight: 700;
}
.dock-item svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.dock-item.active { color: var(--gold); }

.dock-action {
  width: 58px; height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  justify-self: center;
  color: #151618;
  background: linear-gradient(145deg, #d1b77c, #a98952);
  box-shadow: 0 16px 40px rgba(181,154,106,.22), inset 0 1px 0 rgba(255,255,255,.3);
}
.dock-action svg {
  width: 24px; height: 24px;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

/* ============================================================
   SHARED COMPONENTS
============================================================ */
.btn-icon {
  width: 46px; height: 46px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.045);
  backdrop-filter: blur(18px);
  display: grid;
  place-items: center;
  box-shadow: 0 18px 45px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.06);
}
.btn-icon svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.section-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 11px;
}
.section-line span { color: var(--muted); text-transform: uppercase; letter-spacing: .2em; font-weight: 700; font-size: 10px; }
.section-line em { font-style: normal; color: rgba(181,154,106,.65); font-size: 11px; }

/* ============================================================
   BOOK OBJECTS
============================================================ */
.book {
  position: relative;
  border-radius: 4px 10px 10px 4px;
  overflow: hidden;
  box-shadow: 18px 22px 40px rgba(0,0,0,.52), inset -12px 0 22px rgba(0,0,0,.28), inset 2px 0 0 rgba(255,255,255,.08);
  transform: rotateY(-13deg) rotateZ(-1deg);
}
.book::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, rgba(255,255,255,.08), transparent 32%, rgba(0,0,0,.24)); }
.book-spine { position: absolute; inset: 0 auto 0 0; width: 18%; background: rgba(255,255,255,.065); border-right: 1px solid rgba(255,255,255,.1); z-index: 2; }
.book-spine span { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%) rotate(-90deg); font-size: calc(var(--book-h, 76px) * 0.068); letter-spacing: .2em; text-transform: uppercase; color: rgba(243,241,236,.45); white-space: nowrap; }
.book-emboss { position: absolute; inset: 20% 12% auto 28%; display: grid; gap: 5px; place-items: center; z-index: 3; color: rgba(243,241,236,.56); text-align: center; }
.book-emboss small { font-size: 5px; letter-spacing: .15em; text-transform: uppercase; }
.book-emboss-qr { width: 58px; height: 58px; }
.book-emboss-qr svg { width: 100%; height: 100%; }

/* Hero book */
.hero-book { width: 114px; height: 160px; border-radius: 6px 15px 15px 6px; transform: rotateY(-15deg) rotateZ(-1.5deg); box-shadow: 30px 36px 70px rgba(0,0,0,.62), 0 0 80px rgba(181,154,106,.08), inset -18px 0 30px rgba(0,0,0,.34), inset 2px 0 0 rgba(255,255,255,.08); --book-h: 160px; }

/* Cover colours */
.black-book  { background: linear-gradient(135deg, #080808, #151515 62%, #050505); }
.navy-book   { background: linear-gradient(135deg, #182738, #20374c 60%, #0d1723); }
.forest-book { background: linear-gradient(135deg, #17291f, #244231 60%, #0c1811); }
.oxblood-book { background: linear-gradient(135deg, #321010, #4a1717 60%, #170606); }
.slate-book  { background: linear-gradient(135deg, #1c1e28, #252838 60%, #111318); }
.moss-book   { background: linear-gradient(135deg, #1a2318, #253021 60%, #101610); }

/* ============================================================
   AUTH SCREEN
============================================================ */
#screen-auth {
  background:
    radial-gradient(circle at 50% 12%, rgba(181,154,106,.16), transparent 34%),
    radial-gradient(circle at 100% 78%, rgba(55,72,78,.18), transparent 34%),
    linear-gradient(160deg, #181a1c 0%, #111315 46%, #090a0b 100%);
  align-items: center;
  justify-content: center;
}

.entry-card {
  position: relative;
  z-index: 2;
  width: calc(100% - 32px);
  max-width: 398px;
  padding: 34px 28px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 34px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.07), transparent 38%),
    linear-gradient(145deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
  border: 1px solid var(--line);
  box-shadow: 0 34px 100px rgba(0,0,0,.46), inset 0 1px 0 rgba(255,255,255,.08);
  overflow: hidden;
}
.entry-card::before {
  content: "";
  position: absolute;
  left: 32px; right: 32px; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(181,154,106,.58), transparent);
}

.brand-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  margin-bottom: 50px;
}

.qr-seal {
  width: 48px; height: 48px;
  position: relative;
  display: grid;
  place-items: center;
  background: transparent;
}
.qr-seal svg {
  width: 100%; height: 100%;
}

.brand-word { font-size: 28px; letter-spacing: -.06em; font-weight: 500; }
.brand-paper { color: rgba(243,241,236,.48); }

.entry-card .eyebrow { text-align: center; margin-bottom: 18px; }
.entry-card h1 { text-align: center; font-size: 46px; line-height: .93; margin-bottom: 20px; }
.caption { max-width: 280px; text-align: center; color: var(--soft); font-size: 15px; line-height: 1.65; margin-bottom: 52px; }

.google-button {
  width: 100%; height: 58px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 19px;
  background: rgba(255,255,255,.055);
  display: flex; align-items: center; justify-content: center; gap: 13px;
  font-size: 15px; font-weight: 600;
  backdrop-filter: blur(18px);
  box-shadow: 0 22px 55px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.08);
  transition: transform .18s, background .18s, border-color .18s;
}
.google-button:active { transform: scale(.985); background: rgba(255,255,255,.08); border-color: rgba(181,154,106,.3); }
.google-mark { width: 21px; height: 21px; }
.google-mark svg { width: 100%; height: 100%; }
.legal { max-width: 290px; text-align: center; color: rgba(243,241,236,.2); font-size: 11px; line-height: 1.55; margin-top: 18px; }

/* ============================================================
   LIBRARY SCREEN
============================================================ */
.library-scroll {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  padding: calc(28px + env(safe-area-inset-top)) 24px calc(var(--dock-height) + 32px);
}

.archive-header { margin-bottom: 34px; }

.brand-lockup-library { text-align: center; margin-bottom: 28px; }
.brand-lockup-library .eyebrow { margin-bottom: 14px; }
.library-title { font-size: 35px; line-height: .92; text-transform: uppercase; letter-spacing: .1em; }
.library-title span { color: var(--gold); }
.archive-whisper { color: var(--muted); font-size: 12px; margin-top: 14px; letter-spacing: .04em; }

.command-bar {
  width: 100%; height: 58px;
  padding: 0 18px;
  border-radius: 18px;
  display: flex; align-items: center; gap: 13px;
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 22px 50px rgba(0,0,0,.22);
  backdrop-filter: blur(18px);
  color: var(--muted);
}
.command-bar svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.command-bar span { flex: 1; text-align: left; font-size: 15px; }
.command-bar kbd { color: rgba(243,241,236,.42); border: 1px solid rgba(255,255,255,.1); border-radius: 7px; padding: 3px 6px; font-size: 10px; }

/* Hero card */
.hero-section { margin-bottom: 38px; }

.hero-card {
  position: relative;
  min-height: 390px;
  padding: 26px 26px 25px;
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 14%, rgba(238,220,178,.1), transparent 35%),
    linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.035));
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 30px 90px rgba(0,0,0,.38);
  cursor: pointer;
}
.hero-card::after {
  content: "";
  position: absolute;
  inset: auto 24px 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(181,154,106,.45), transparent);
}

.spotlight {
  position: absolute;
  top: -80px; left: 50%;
  width: 280px; height: 260px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(181,154,106,.18), transparent 66%);
  filter: blur(10px);
  pointer-events: none;
}

.book-stage { height: 200px; display: grid; place-items: center; perspective: 700px; }

.hero-copy { position: relative; z-index: 3; margin-top: 12px; }
.mini-label { color: rgba(181,154,106,.75); text-transform: uppercase; letter-spacing: .27em; font-size: 10px; font-weight: 700; margin-bottom: 9px; }
.hero-copy h2 { font-size: 32px; margin-bottom: 6px; }
.hero-copy p { color: var(--soft); font-size: 14px; margin-bottom: 22px; }
.hero-action {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .25em;
  font-size: 11px;
  font-weight: 700;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* Shelf cards */
.collection-section { padding-bottom: 20px; }

.shelf-card {
  position: relative;
  min-height: 112px;
  padding: 14px 16px 14px 98px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  border-radius: 22px;
  background: rgba(255,255,255,.033);
  border: 1px solid rgba(255,255,255,.075);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.045), 0 20px 55px rgba(0,0,0,.2);
  overflow: hidden;
  cursor: pointer;
}
.shelf-card .book {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%) rotateY(-12deg) rotateZ(-1deg);
  width: 56px; height: 76px;
  border-radius: 4px 10px 10px 4px;
  z-index: 3;
  --book-h: 76px;
}
.shelf-info h3 { font-size: 18px; font-weight: 650; letter-spacing: -.03em; margin-bottom: 4px; }
.shelf-info p { color: var(--muted); font-size: 13px; margin-bottom: 9px; }
.shelf-state { display: inline-block; text-transform: uppercase; letter-spacing: .18em; font-size: 9px; font-weight: 700; color: rgba(243,241,236,.45); }
.shelf-state.gold { color: var(--gold); }
.row-light { position: absolute; inset: 0; background: radial-gradient(circle at 0 50%, rgba(181,154,106,.06), transparent 44%); pointer-events: none; }

/* ============================================================
   BOOK SCREEN
============================================================ */
.book-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: calc(28px + env(safe-area-inset-top)) 24px 20px;
}
.back-button {
  width: 46px; height: 46px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.045);
  backdrop-filter: blur(18px);
  display: grid; place-items: center;
  box-shadow: 0 18px 45px rgba(0,0,0,.28);
  flex-shrink: 0;
}
.back-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.book-identity { flex: 1; }
.book-identity .eyebrow { margin-bottom: 4px; }
.book-identity h1 { font-size: 32px; letter-spacing: -.04em; font-weight: 650; }
.subline { margin-top: 3px; color: var(--soft); font-size: 14px; }

.volume-hero {
  position: relative;
  z-index: 2;
  margin: 0 24px 24px;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 28px 24px 20px;
  background:
    radial-gradient(circle at 58% 20%, rgba(255,255,255,.08), transparent 38%),
    radial-gradient(circle at 52% 0%, rgba(181,154,106,.12), transparent 48%),
    linear-gradient(145deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
  box-shadow: 0 38px 90px rgba(0,0,0,.38), inset 0 1px 0 rgba(255,255,255,.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.volume-hero::after {
  content: "";
  position: absolute;
  inset: auto 24px 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(181,154,106,.45), transparent);
}
.book-stage-book {
  display: grid;
  place-items: center;
  perspective: 700px;
}
.book-hero-large {
  width: 100px; height: 142px;
  border-radius: 5px 14px 14px 5px;
  box-shadow: 26px 32px 60px rgba(0,0,0,.58), inset -16px 0 28px rgba(0,0,0,.32), inset 2px 0 0 rgba(255,255,255,.08);
  transform: rotateY(-15deg) rotateZ(-1.5deg);
  --book-h: 142px;
}

.contents-section {
  position: relative;
  z-index: 2;
  padding: 0 24px;
  overflow-y: auto;
  flex: 1;
  padding-bottom: calc(var(--dock-height) + 20px);
}
.entry-toolbar { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; }
.entry-toolbar h3 { font-size: 18px; letter-spacing: -.02em; margin-top: 5px; }
.entry-toolbar span { color: var(--muted); font-size: 12px; }

.index-list { border-top: 1px solid var(--line); }
.index-entry {
  min-height: 100px;
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 14px;
  align-items: start;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  position: relative;
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: none;
  border-radius: 0;
}
.index-entry::before { content: ""; position: absolute; left: 0; top: 20px; bottom: 20px; width: 2px; background: transparent; border-radius: 99px; transition: background .2s; }
.index-entry.active::before { background: var(--gold); box-shadow: 0 0 24px rgba(181,154,106,.45); }

.entry-number { font-family: 'Newsreader', serif; color: var(--gold); font-size: 27px; line-height: 1; opacity: .92; padding-left: 13px; }
.entry-main { display: flex; flex-direction: column; gap: 6px; }
.entry-title { font-size: 18px; font-weight: 600; letter-spacing: -.015em; }
.entry-preview { color: var(--soft); font-size: 14px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry-meta { color: var(--muted); text-transform: uppercase; letter-spacing: .16em; font-size: 10px; font-weight: 650; }
.index-entry.quiet { opacity: .62; }

/* ============================================================
   PAGE VIEW SCREEN
============================================================ */
#screen-page {
  background: radial-gradient(circle at 50% -10%, rgba(181,154,106,.18), transparent 32%),
    linear-gradient(180deg, #17191b 0%, #101214 43%, #070808 100%);
}
#screen-page::after { background: radial-gradient(circle at 50% 18%, transparent 0%, rgba(0,0,0,.32) 70%, rgba(0,0,0,.72) 100%); }

.reader-head {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding: calc(34px + env(safe-area-inset-top)) 28px 24px;
  flex-shrink: 0;
}
.reader-title { font-size: 44px; line-height: .88; max-width: 8ch; text-shadow: 0 22px 58px rgba(0,0,0,.55); }

/* Swipe area */
.swipe-area { position: relative; z-index: 2; flex: 1; overflow: hidden; }
.swipe-track { display: flex; height: 100%; will-change: transform; }

.page-slide {
  width: 100vw;
  max-width: 430px;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  padding: 0 0 calc(var(--dock-height) + 20px);
}

/* Source card */
.source-card {
  display: flex;
  align-items: center;
  gap: 17px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 27px;
  background: rgba(255,255,255,.045);
  box-shadow: 0 24px 60px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.06);
  margin: 0 28px 32px;
  overflow: hidden;
  cursor: pointer;
}
.manuscript-window {
  width: 116px; height: 60px;
  border-radius: 16px;
  overflow: hidden;
  flex-shrink: 0;
  background: #111;
  box-shadow: 0 14px 34px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.05);
}
.manuscript-window img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.source-card h2 { font-size: 15px; letter-spacing: -.025em; margin-bottom: 4px; }
.source-card p { font-size: 12px; color: var(--muted); }

/* Reading area */
.reading {
  padding: 0 28px;
}
.entry-meta-line {
  color: rgba(243,241,236,.72);
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: 10px;
  font-weight: 750;
  margin-bottom: 24px;
}
.reading p {
  font-size: 20px;
  line-height: 1.66;
  letter-spacing: -.018em;
  color: #eee9e1;
  margin-bottom: 24px;
}
.reading blockquote {
  font-family: 'Cormorant Garamond', serif;
  color: var(--gold);
  font-size: 34px;
  line-height: 1.14;
  font-weight: 500;
  margin: 32px 0 36px;
  padding-left: 22px;
  border-left: 2px solid rgba(181,154,106,.55);
  text-shadow: 0 18px 44px rgba(0,0,0,.42);
}

/* Page rail */
.page-rail {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 9px;
  padding: 10px 0;
  flex-shrink: 0;
}
.page-rail span { width: 5px; height: 5px; border-radius: 99px; background: rgba(255,255,255,.22); transition: all .2s; }
.page-rail .active { width: 28px; background: var(--gold); }

/* ============================================================
   SEARCH SCREEN
============================================================ */
.search-inner {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-header {
  padding: calc(34px + env(safe-area-inset-top)) 24px 20px;
  flex-shrink: 0;
}
.search-title { font-size: 40px; line-height: .92; margin: 14px 0 20px; }

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 18px;
  border-radius: 18px;
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 18px 45px rgba(0,0,0,.22);
  backdrop-filter: blur(18px);
}
.search-input-wrap svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; flex-shrink: 0; }
#search-input { flex: 1; background: none; border: none; outline: none; font: inherit; font-size: 15px; color: var(--text); }
#search-input::placeholder { color: var(--muted); }
.search-clear { width: 20px; height: 20px; background: rgba(255,255,255,.15); border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.search-clear svg { width: 11px; height: 11px; fill: none; stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; }

.search-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px calc(var(--dock-height) + 20px);
}

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; gap: 0; }
.empty-state svg { width: 44px; height: 44px; fill: none; stroke: rgba(255,255,255,.15); stroke-width: 1.5; stroke-linecap: round; margin-bottom: 20px; }
.empty-title { font-size: 26px; margin-bottom: 10px; }
.empty-sub { font-size: 14px; color: var(--muted); line-height: 1.6; }

.results-meta { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: .18em; text-transform: uppercase; margin-bottom: 14px; }

.result-card {
  padding: 16px 18px;
  margin-bottom: 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.033);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.045), 0 18px 50px rgba(0,0,0,.2);
  cursor: pointer;
}
.result-book-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.result-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.result-book-name { font-size: 10px; font-weight: 700; color: var(--soft); letter-spacing: .1em; text-transform: uppercase; }
.result-page-num { font-size: 11px; color: var(--muted); margin-left: auto; }
.result-excerpt { font-size: 15px; color: var(--soft); line-height: 1.6; }
.result-excerpt mark { background: none; color: var(--gold); font-weight: 600; }

/* ============================================================
   SCAN MODAL
============================================================ */
.modal-scan {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 18%, rgba(181,154,106,.12), transparent 34%),
    radial-gradient(circle at 94% 78%, rgba(54,72,78,.18), transparent 32%),
    linear-gradient(160deg, #181a1c 0%, #101214 48%, #08090a 100%);
  border-inline: 1px solid rgba(255,255,255,.045);
  max-width: 430px;
  margin: 0 auto;
}
.modal-scan::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 38%, rgba(0,0,0,.58) 100%);
  z-index: 0;
}

#scan-initial {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(34px + env(safe-area-inset-top)) 26px calc(30px + env(safe-area-inset-bottom));
}

.close {
  position: absolute;
  z-index: 10;
  right: 24px;
  top: calc(28px + env(safe-area-inset-top));
  width: 52px; height: 52px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.055);
  backdrop-filter: blur(18px);
  display: grid; place-items: center;
  box-shadow: 0 22px 55px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,255,255,.07);
}
.close svg { width: 23px; height: 23px; fill: none; stroke: var(--soft); stroke-width: 1.9; stroke-linecap: round; }

.scan-header { position: relative; z-index: 2; padding-top: 60px; margin-bottom: 30px; }
.scan-header h1 { font-size: 52px; line-height: .9; margin: 14px 0 12px; }
.scan-header p:not(.eyebrow) { color: var(--soft); font-size: 15px; line-height: 1.55; }

.capture-zone {
  position: relative;
  z-index: 2;
  height: 300px;
  border-radius: 32px;
  border: 1px solid rgba(255,255,255,.12);
  background:
    radial-gradient(circle at 50% 12%, rgba(181,154,106,.12), transparent 45%),
    linear-gradient(145deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  box-shadow: 0 38px 95px rgba(0,0,0,.46), inset 0 1px 0 rgba(255,255,255,.08);
  overflow: hidden;
  flex-shrink: 0;
}
.frame-glass { position: absolute; inset: 18px; border-radius: 24px; border: 1px solid rgba(255,255,255,.055); background: rgba(0,0,0,.08); }
.corner { position: absolute; width: 40px; height: 40px; border-color: rgba(243,241,236,.62); }
.corner.tl { left: 26px; top: 26px; border-top: 3px solid; border-left: 3px solid; }
.corner.tr { right: 26px; top: 26px; border-top: 3px solid; border-right: 3px solid; }
.corner.bl { left: 26px; bottom: 26px; border-bottom: 3px solid; border-left: 3px solid; }
.corner.br { right: 26px; bottom: 26px; border-bottom: 3px solid; border-right: 3px solid; }
.camera-icon { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; transform: translate(-50%,-50%); fill: none; stroke: rgba(243,241,236,.22); stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; }
.scan-beam {
  position: absolute;
  left: 32px; right: 32px; top: 46px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(181,154,106,.85), transparent);
  box-shadow: 0 0 28px rgba(181,154,106,.35);
  animation: scanBeam 3.5s ease-in-out infinite;
}
@keyframes scanBeam {
  0%,100% { transform: translateY(0); opacity: .18; }
  45%,55% { transform: translateY(210px); opacity: .95; }
}

.scan-instruction { position: relative; z-index: 2; margin: 24px auto 20px; max-width: 290px; text-align: center; color: var(--soft); font-size: 15px; line-height: 1.65; }

.scan-actions { position: relative; z-index: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: auto; }
.scan-actions button {
  height: 88px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.045);
  color: var(--soft);
  display: grid; place-items: center; gap: 8px;
  box-shadow: 0 20px 45px rgba(0,0,0,.23), inset 0 1px 0 rgba(255,255,255,.07);
  backdrop-filter: blur(18px);
  font-size: 14px; font-weight: 650;
  transition: transform .15s;
}
.scan-actions button:active { transform: scale(.985); }
.scan-actions svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

/* ============================================================
   SCAN PROCESSING / LOADER
============================================================ */
.scan-processing {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 52% 18%, rgba(181,154,106,.12), transparent 34%),
    linear-gradient(160deg, #181a1c 0%, #101214 48%, #08090a 100%);
}

.loader { position: relative; z-index: 2; width: 100%; display: grid; place-items: center; text-align: center; padding: 40px 26px; }
.loader h1 { font-size: 48px; line-height: .9; margin: 18px 0 44px; }

.book-system { position: relative; width: 320px; height: 220px; display: grid; place-items: center; perspective: 1000px; }
.open-book {
  position: relative;
  width: 236px; height: 144px;
  display: grid; grid-template-columns: 1fr 1fr;
  transform: rotateX(20deg);
  transform-style: preserve-3d;
  filter: drop-shadow(0 38px 45px rgba(0,0,0,.52));
}
.open-book::before {
  content: "";
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 22px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.38), transparent);
  z-index: 5;
}
.open-book::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -28px;
  width: 270px; height: 24px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(181,154,106,.27), transparent 66%);
  filter: blur(7px);
  z-index: -1;
}
.left-page, .right-page {
  position: relative; overflow: hidden;
  border: 1px solid rgba(243,241,236,.34);
  background: linear-gradient(145deg, rgba(243,241,236,.13), rgba(243,241,236,.055));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.13);
}
.left-page { border-right: 0; }
.right-page {
  border-left: 0;
  padding: 26px 18px;
  color: rgba(243,241,236,.64);
  font-size: 7.5px;
  line-height: 1.55;
  text-align: left;
}
.left-page span {
  display: block; height: 3px;
  margin: 12px 16px 0 18px;
  background: rgba(243,241,236,.48);
  border-radius: 99px;
  animation: readline 1.9s ease-in-out infinite;
}
.left-page span:nth-child(2) { width: 72%; animation-delay: .12s; }
.left-page span:nth-child(3) { width: 84%; animation-delay: .24s; }
.left-page span:nth-child(4) { width: 58%; animation-delay: .36s; }
@keyframes readline { 0%,100%{opacity:.22;transform:translateX(0)} 50%{opacity:.8;transform:translateX(4px)} }

.np-phrase-window { position: relative; width: 84px; height: 50px; overflow: hidden; }
.np-phrase { position: absolute; inset: 0; margin: 0; opacity: 0; transform: translateY(6px); filter: blur(1.5px); animation: npPhraseCycle 22.4s ease-in-out infinite; font-size: 7px; line-height: 1.45; }
.phrase-2 { animation-delay: 2.8s; }
.phrase-3 { animation-delay: 5.6s; }
.phrase-4 { animation-delay: 8.4s; }
.phrase-5 { animation-delay: 11.2s; }
.phrase-6 { animation-delay: 14.0s; }
.phrase-7 { animation-delay: 16.8s; }
.phrase-8 { animation-delay: 19.6s; }
@keyframes npPhraseCycle {
  0% { opacity:0; transform:translateY(6px); filter:blur(1.5px); }
  4%,10% { opacity:1; transform:translateY(0); filter:blur(0); }
  14%,100% { opacity:0; transform:translateY(-6px); filter:blur(1.5px); }
}
.right-page em { position: absolute; bottom: 18px; left: 18px; font-style: normal; text-transform: uppercase; letter-spacing: .22em; font-size: 6px; color: rgba(181,154,106,.8); }

.flipping-pages { position: absolute; left: 50%; top: 0; width: 118px; height: 144px; transform-style: preserve-3d; transform-origin: left center; z-index: 8; }
.flipping-pages i { position: absolute; inset: 0; border: 1px solid rgba(243,241,236,.25); border-left: 0; background: linear-gradient(145deg, rgba(243,241,236,.16), rgba(243,241,236,.065)); transform-origin: left center; animation: flip 2.8s cubic-bezier(.55,.05,.32,.98) infinite; }
.flipping-pages i:nth-child(2) { animation-delay: .25s; }
.flipping-pages i:nth-child(3) { animation-delay: .5s; }
.flipping-pages i:nth-child(4) { animation-delay: .75s; }
@keyframes flip { 0% { transform:rotateY(0deg); opacity:.98; } 42%,100% { transform:rotateY(-164deg); opacity:.35; } }

.loader-caption { display: flex; gap: 9px; margin-top: 28px; }
.loader-caption span { width: 5px; height: 5px; border-radius: 50%; background: rgba(181,154,106,.75); animation: pulse 1.3s ease-in-out infinite; }
.loader-caption span:nth-child(2) { animation-delay: .18s; }
.loader-caption span:nth-child(3) { animation-delay: .36s; }
@keyframes pulse { 0%,100%{opacity:.22;transform:scale(.8)} 45%{opacity:1;transform:scale(1.08)} }

/* ============================================================
   BOOK SELECTOR MODAL
============================================================ */
.modal-book-select {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: flex-end;
  max-width: 430px;
  margin: 0 auto;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(3px); }

.volume-sheet {
  position: relative;
  z-index: 2;
  left: 0; right: 0; bottom: 0;
  width: 100%;
  padding: 30px 24px calc(30px + env(safe-area-inset-bottom));
  border-radius: 34px 34px 0 0;
  border: 1px solid rgba(255,255,255,.115);
  border-bottom: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(181,154,106,.13), transparent 32%),
    linear-gradient(145deg, rgba(31,33,35,.96), rgba(15,17,18,.96));
  box-shadow: 0 -32px 100px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.08);
  overflow: hidden;
  max-height: 80vh;
  overflow-y: auto;
}
.volume-sheet::before { content: ""; position: absolute; left: 50%; top: 10px; width: 54px; height: 3px; transform: translateX(-50%); border-radius: 999px; background: rgba(243,241,236,.22); }

.sheet-close { position: absolute; right: 24px; top: 28px; }
.volume-sheet header { max-width: 300px; margin-bottom: 24px; padding-top: 10px; }
.volume-sheet header .eyebrow { margin-bottom: 10px; }
.volume-sheet header h1 { font-size: 36px; line-height: .93; margin-bottom: 12px; }
.volume-sheet header p { color: var(--soft); font-size: 14px; }

.volume-list { display: grid; gap: 14px; }
.volume {
  width: 100%; min-height: 108px;
  padding: 14px 16px;
  display: grid; grid-template-columns: 76px 1fr; gap: 16px;
  align-items: center;
  text-align: left;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.04);
  color: var(--text);
  overflow: hidden;
  box-shadow: 0 18px 55px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.055);
  transition: border-color .2s, background .2s;
}
.volume.selected { border-color: rgba(181,154,106,.38); background: linear-gradient(145deg, rgba(181,154,106,.105), rgba(255,255,255,.045)); }
.volume.dimmed { opacity: .62; }
.volume .book { width: 56px; height: 76px; border-radius: 4px 10px 10px 4px; --book-h: 76px; }
.volume .copy h2 { font-size: 19px; font-weight: 650; letter-spacing: -.03em; margin-bottom: 5px; }
.volume .copy p { color: var(--soft); font-size: 13px; line-height: 1.35; margin-bottom: 8px; }
.volume .copy span { text-transform: uppercase; letter-spacing: .18em; color: var(--gold); font-size: 9px; font-weight: 700; }

/* ============================================================
   TOAST
============================================================ */
.toast {
  position: fixed;
  top: calc(-80px - env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 48px);
  max-width: 382px;
  background: rgba(31,33,35,.92);
  border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(22px);
  color: var(--text);
  padding: 14px 20px;
  border-radius: 18px;
  display: flex; align-items: center; gap: 12px;
  z-index: 200;
  transition: top 0.3s cubic-bezier(.25,.46,.45,.94);
  box-shadow: 0 22px 60px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.07);
}
.toast.show { top: calc(20px + env(safe-area-inset-top)); }
.toast svg { width: 18px; height: 18px; fill: none; stroke: var(--gold); stroke-width: 2.5; stroke-linecap: round; flex-shrink: 0; }
.toast span { font-size: 14px; font-weight: 500; }

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 370px) {
  .reader-title { font-size: 38px; }
  .scan-header h1 { font-size: 44px; }
  .entry-card h1 { font-size: 40px; }
  .entry-number { font-size: 24px; }
}