/* Gurbanov Boys — shared styles. Warm library feel, no external assets. */

:root {
  --gold: #d4a94e;
  --gold-dim: #a8813a;
  --cream: #f7f1e3;
  --ink: #2e2418;
  --paper: #faf5e9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--cream);
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 214, 150, 0.10), transparent 55%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.14) 0 2px, transparent 2px 110px),
    linear-gradient(#3b2b1c, #251a0f 65%, #170f07);
  background-attachment: fixed;
}

.hidden { display: none !important; }

a { color: var(--gold); }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(212, 169, 78, 0.35);
  backdrop-filter: blur(4px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  letter-spacing: 1px;
  color: var(--gold);
  text-decoration: none;
}
.topbar .spacer { flex: 1; }
.topbar .who { opacity: 0.85; font-size: 0.95rem; }

/* "Your access" panel — plain-words explanation of what this account can do */
.access-panel {
  position: fixed; top: 64px; right: 16px; z-index: 200;
  max-width: 360px; width: calc(100vw - 32px);
  background: rgba(12, 8, 4, 0.97);
  border: 1px solid rgba(212, 169, 78, 0.5); border-radius: 12px;
  padding: 18px 20px; color: var(--cream);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
.access-panel h3 { margin: 0 0 10px; font-family: Georgia, serif; color: var(--gold); }
.access-panel ul { margin: 0; padding-left: 20px; }
.access-panel li { margin: 8px 0; line-height: 1.45; font-size: .95rem; }
.access-panel .access-close { float: right; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-block;
  background: linear-gradient(#e2b95c, #b98c34);
  color: #241a08;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }
.btn.ghost {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  box-shadow: none;
}
.btn.danger { background: linear-gradient(#c0564d, #93352e); color: #fff; }
.btn.small { padding: 5px 11px; font-size: 0.82rem; }
/* double-confirmation delete: armed state pulses red */
.btn.danger.armed {
  background: linear-gradient(#e04030, #a02015);
  animation: armPulse 0.7s ease-in-out infinite alternate;
  font-weight: bold;
}
@keyframes armPulse {
  from { box-shadow: 0 0 0 0 rgba(224, 64, 48, 0.7); }
  to { box-shadow: 0 0 0 6px rgba(224, 64, 48, 0); }
}

input[type="text"], input[type="password"], input[type="color"],
textarea, select {
  background: #fbf7ec;
  color: var(--ink);
  border: 1px solid #cbb98f;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.95rem;
  width: 100%;
}
input[type="color"] { width: 64px; height: 40px; padding: 4px; cursor: pointer; }
textarea { min-height: 90px; resize: vertical; font-family: inherit; }
label { display: block; margin: 10px 0 4px; font-size: 0.9rem; opacity: 0.9; }

.error {
  background: rgba(160, 40, 30, 0.25);
  border: 1px solid #a02818;
  color: #ffd9d2;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 12px 0;
}
.ok-msg {
  background: rgba(40, 130, 60, 0.25);
  border: 1px solid #2c7a3f;
  color: #d6f5dc;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 12px 0;
}

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: rgba(20, 13, 7, 0.82);
  border: 1px solid rgba(212, 169, 78, 0.5);
  border-radius: 16px;
  padding: 40px 44px;
  width: 380px;
  max-width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
}
.login-card h1 {
  font-family: Georgia, serif;
  color: var(--gold);
  margin: 0 0 4px;
  font-size: 2rem;
  letter-spacing: 1px;
}
.login-card .tagline { opacity: 0.75; margin-bottom: 22px; font-style: italic; }
.login-card form { text-align: left; }
.login-card .btn { width: 100%; margin-top: 16px; padding: 12px; }

/* ---------- bookshelf ---------- */
.shelves { max-width: 1080px; margin: 0 auto; padding: 30px 20px 80px; }
.shelf { margin-bottom: 56px; }
.shelf-plaque {
  display: inline-block;
  font-family: Georgia, serif;
  font-size: 1.6rem;
  letter-spacing: 3px;
  color: #2b1d0c;
  background: linear-gradient(#e8c56e, #c49a45 60%, #a37c2e);
  padding: 8px 34px;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  margin: 0 0 22px 8px;
  border: 1px solid #7d5f22;
}
.books-row {
  display: flex;
  align-items: flex-end;
  align-content: flex-end; /* wrapped lines stack at the bottom so every book sits on the shelf board */
  gap: 16px;
  flex-wrap: wrap;
  padding: 6px 34px 0;
  min-height: 210px;
}
.shelf-empty { opacity: 0.6; font-style: italic; padding: 20px 34px; }

.book {
  --cover: #2b6cb0;
  width: 132px;
  height: 192px;
  border-radius: 3px 8px 8px 3px;
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  /* spine on the left, cover face, sheen */
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.45) 0, rgba(0, 0, 0, 0.45) 13px,
      rgba(255, 255, 255, 0.10) 15px, rgba(255, 255, 255, 0) 22px),
    var(--cover);
  box-shadow:
    inset 3px 0 6px rgba(0, 0, 0, 0.35),
    7px 9px 18px rgba(0, 0, 0, 0.55);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 16px 12px 16px 24px;
  overflow: hidden;
}
.book:hover {
  transform: translateY(-14px) rotate(-1.2deg);
  box-shadow:
    inset 3px 0 6px rgba(0, 0, 0, 0.35),
    10px 18px 28px rgba(0, 0, 0, 0.65);
}
/* page edges peeking out on the right */
.book::after {
  content: "";
  position: absolute;
  top: 5px; bottom: 5px; right: 0;
  width: 6px;
  background: repeating-linear-gradient(to bottom, #f3ecdb 0 2px, #cfc4a8 2px 3px);
  border-radius: 0 5px 5px 0;
}
.book .book-title {
  font-family: Georgia, serif;
  font-size: 1.02rem;
  line-height: 1.3;
  color: #f8ecd2;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.book .book-sub {
  margin-top: 8px;
  font-size: 0.72rem;
  color: rgba(248, 236, 210, 0.75);
  font-style: italic;
}
.book .book-band {
  position: absolute;
  left: 0; right: 6px;
  height: 26px;
  top: 22px;
  background: rgba(212, 169, 78, 0.85);
}
.shelf-board {
  height: 26px;
  margin-top: -2px;
  background: linear-gradient(#8f5f34, #5f3c1d 55%, #38220f);
  border-radius: 4px;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.65), inset 0 2px 0 rgba(255, 225, 170, 0.25);
  position: relative;
}
.shelf-board::before, .shelf-board::after {
  /* wooden brackets */
  content: "";
  position: absolute;
  top: 26px;
  width: 34px; height: 44px;
  background: linear-gradient(135deg, #4c3016, #2c1c0b);
  clip-path: polygon(0 0, 100% 0, 100% 35%, 0 100%);
}
.shelf-board::before { left: 40px; }
.shelf-board::after { right: 40px; transform: scaleX(-1); }

/* ---------- reader ---------- */
.reader-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
}
/* full-viewport reader: the book always fits the screen, no page scrolling */
.reader-body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Account for mobile browser chrome / system nav overlapping the bottom */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.reader-body .reader-top { flex: 0 0 auto; }
.reader-body .reader-stage {
  flex: 1 1 auto;
  min-height: 0;
  padding: 8px 16px;
}
.reader-body #flipbook {
  width: min(1100px, 100%);
  height: 100%;
  max-width: 100%;
  max-height: 100%; /* belt-and-suspenders: never exceed the stage even if JS mis-measures */
  flex: 0 0 auto; /* JS sets the exact fitted px size; keep flex from shrinking it */
}
.reader-body .reader-controls { flex: 0 0 auto; padding: 8px 20px 14px; }
@media (max-width: 720px) {
  .reader-body .reader-controls {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
}
#flipbook .simple-page { max-height: 100%; overflow-y: auto; }
/* Mobile scroll mode: continuous reading like the Teke tribe page.
   Pages stack vertically with natural flow — no fixed heights, no clipping. */
#flipbook.scroll-mode {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#flipbook.scroll-mode .scroll-pages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px 40px;
}
#flipbook.scroll-mode .scroll-page {
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  margin: 0 auto 18px;
  max-width: 640px;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  overflow: visible;
  height: auto;
}
#flipbook.scroll-mode .scroll-page .page-inner {
  height: auto;
  padding: 36px 28px;
}
#reader-dbg {
  position: fixed; top: 4px; left: 4px; z-index: 9999;
  background: rgba(0,0,0,.85); color: #0f0;
  font: 11px/1.5 monospace; padding: 6px 8px; border-radius: 6px;
  max-width: 94vw; pointer-events: none; white-space: pre-wrap;
}
.reader-stage {
  display: flex;
  justify-content: center;
  padding: 10px 16px 30px;
}
#flipbook { width: min(1100px, 96vw); }
.flip-page {
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}
.page-inner {
  padding: 54px 56px;
  height: 100%;
  overflow: hidden; /* never scroll inside a page — content is fit by fitPageContent */
  font-family: Georgia, "Times New Roman", serif;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center; /* balance whitespace top/bottom on shorter pages */
}
.page-inner h2 {
  text-align: center;
  font-size: 1.6rem;
  margin: 0 0 22px;
  color: #3a2c17;
}
.page-inner p {
  font-size: 1rem;
  line-height: 1.75;
  text-align: justify;
  margin: 0 0 18px;
  color: #3d3222;
}
.page-inner figure { margin: 6px 0 20px; text-align: center; }
.page-inner figure img {
  max-width: 100%;
  max-height: 340px; /* fixed px so it scales with the page zoom (vh units ignore zoom) */
  border-radius: 4px;
  border: 8px solid #fff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}
.page-inner figcaption {
  margin-top: 10px;
  font-style: italic;
  color: #7a6a4e;
  font-size: 0.95rem;
}
/* Collage pages: several framed photos arranged on one page (scrapbook
   layouts). Panels are background divs in a height-filling grid, so the
   arrangement is exact and the page-fit code (which measures <img>s)
   leaves it alone. Frames are polaroid-style: white border, deeper chin,
   soft shadow, gentle tips and tilts. */
.page-inner .collage {
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: grid; gap: 14px;
}
.page-inner .collage .ph {
  background: #fff; padding: 8px 8px 22px; border-radius: 6px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.30);
  display: flex; min-height: 0; min-width: 0;
}
.page-inner .collage .im {
  flex: 1; background-size: contain; background-repeat: no-repeat;
  background-position: center; background-color: #f5efe0;
  border-radius: 3px; min-height: 0; min-width: 0;
}
.page-inner .collage-cap {
  margin-top: 12px; text-align: center; font-style: italic;
  color: #7a6a4e; font-size: 0.95rem;
}
/* duo — two side by side, tipped toward each other */
.collage.lay-duo { grid-template-columns: 1fr 1fr; align-items: center; }
.collage.lay-duo .ph { height: 78%; }
.collage.lay-duo .ph:nth-child(1) { transform: rotate(-2.5deg); }
.collage.lay-duo .ph:nth-child(2) { transform: rotate(2.5deg); }
/* trio — one wide on top, two below */
.collage.lay-trio { grid-template-columns: 1fr 1fr; grid-template-rows: 1.25fr 1fr; }
.collage.lay-trio .ph:nth-child(1) { grid-column: 1 / -1; transform: rotate(-1deg); }
.collage.lay-trio .ph:nth-child(2) { transform: rotate(1.5deg); }
.collage.lay-trio .ph:nth-child(3) { transform: rotate(-1.5deg); }
/* grid — 2 x 2 with gentle alternating tips */
.collage.lay-grid { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
/* A 2-photo "grid" is the builder's common case (520 collages site-wide):
   with two rows, half the collage height was wasted on an empty second
   row and the two photos collapsed into thin strips (New York Trip,
   "Underground: The Subway", 2026-10-24). Two photos get one row. */
.collage.lay-grid:has(.ph:nth-child(2):last-child) { grid-template-rows: 1fr; }
/* Phones (continuous scroll): the page height is auto, so a grid collage
   has no height to fill and its background photos collapse to strips.
   Give it a definite height there so the photos actually show. */
#flipbook.scroll-mode .collage { height: 320px; flex: 0 0 auto; }
.collage.lay-grid .ph:nth-child(odd) { transform: rotate(-1.2deg); }
.collage.lay-grid .ph:nth-child(even) { transform: rotate(1.2deg); }
/* fan — three panels fanned out, the middle one on top */
.collage.lay-fan { display: flex; align-items: center; justify-content: center; }
.collage.lay-fan .ph { flex: 0 0 46%; height: 72%; }
.collage.lay-fan .ph:nth-child(1) { transform: rotate(-7deg); margin-right: -13%; }
.collage.lay-fan .ph:nth-child(2) { transform: rotate(0deg); z-index: 2; }
.collage.lay-fan .ph:nth-child(3) { transform: rotate(7deg); margin-left: -13%; }
/* hero — one big moment on top, one wide strip below */
.collage.lay-hero { grid-template-rows: 2.6fr 1fr; }
.collage.lay-hero .ph:nth-child(1) { transform: rotate(-0.8deg); }
.collage.lay-hero .ph:nth-child(2) { transform: rotate(0.8deg); }
.page-num {
  position: absolute;
  bottom: 22px;
  left: 0; right: 0;
  text-align: center;
  font-size: 0.85rem;
  color: #9a8a68;
}
.cover-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
  color: #f8ecd2;
  font-family: Georgia, serif;
}
.cover-page .cover-frame {
  border: 2px solid rgba(212, 169, 78, 0.8);
  outline: 1px solid rgba(212, 169, 78, 0.4);
  outline-offset: 8px;
  padding: 44px 30px;
  max-width: 80%;
}
.cover-page h1 { font-size: 2.1rem; margin: 0 0 12px; text-shadow: 0 2px 6px rgba(0,0,0,.5); }
.cover-page .sub { font-style: italic; opacity: 0.85; }
.cover-page .series { margin-top: 26px; letter-spacing: 4px; font-size: 0.85rem; color: var(--gold); }
.reader-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 0 20px 40px;
  position: relative;
  z-index: 10;
}
#page-indicator { min-width: 120px; text-align: center; opacity: 0.85; }
/* simple pager fallback (when the flip library can't load) */
.simple-page { max-width: 760px; margin: 0 auto; }
.simple-nav { display: flex; justify-content: space-between; max-width: 760px; margin: 18px auto 0; }

/* ---------- admin ---------- */
.admin-wrap { max-width: 1080px; margin: 0 auto; padding: 26px 20px 90px; }
.admin-wrap h2 {
  font-family: Georgia, serif; color: var(--gold);
  border-bottom: 1px solid rgba(212, 169, 78, 0.35);
  padding-bottom: 8px; margin-top: 38px;
}
.admin-wrap h2.collapsible { cursor: pointer; user-select: none; }
.admin-wrap h2.collapsible::before {
  content: '▾ '; font-size: .8em; color: var(--gold);
}
.admin-wrap h2.collapsible.is-collapsed::before { content: '▸ '; }
.admin-wrap h2.collapsible:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.panel {
  background: rgba(15, 10, 5, 0.72);
  border: 1px solid rgba(212, 169, 78, 0.35);
  border-radius: 12px;
  padding: 20px 22px;
  margin: 16px 0;
}
.panel h3 { margin: 0 0 10px; font-family: Georgia, serif; color: var(--cream); }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid rgba(212, 169, 78, 0.18);
}
.list-item .grow { flex: 1; }
.list-item .meta { opacity: 0.65; font-size: 0.85rem; }
.list-item .actions { display: flex; gap: 8px; }
.block-row {
  border: 1px dashed rgba(212, 169, 78, 0.45);
  border-radius: 10px;
  padding: 12px;
  margin: 12px 0;
  background: rgba(255, 255, 255, 0.03);
}
.block-row .block-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.block-row .block-head select { width: 170px; }
.block-row img.preview { max-width: 220px; border-radius: 6px; margin-top: 8px; display: block; }
.notice {
  background: rgba(212, 169, 78, 0.14);
  border: 1px solid var(--gold-dim);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 16px 0;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

/* ---------- photo inbox ---------- */
.inbox-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px; margin-top: 10px;
}
.inbox-card {
  background: rgba(0,0,0,.25); border: 1px solid rgba(212,169,78,.3);
  border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 8px;
}
.inbox-card img { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; }
.inbox-meta { font-size: .8rem; color: #e8d5a8; }
.inbox-card select {
  width: 100%; background: #171008; border: 1px solid rgba(212,169,78,.4);
  color: #f8ecd2; border-radius: 8px; padding: 6px 8px; font-size: .85rem;
}
.inbox-actions { display: flex; gap: 6px; }
.danger-text { color: #e88; }

/* ---------- reader: narration, autoplay, prompts ---------- */
.narrate-btn {
  display: block; margin: 14px auto 4px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid rgba(212,169,78,.55); background: rgba(212,169,78,.12);
  color: #f8ecd2; font-size: .9rem; cursor: pointer; font-family: inherit;
}
.narrate-btn.playing { background: rgba(212,169,78,.32); }
.btn.active, #autoplay-btn.active, #listen-btn.active {
  background: rgba(212,169,78,.3); border-color: #d4a94e;
}
.prompts-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 92vw); z-index: 60;
  background: #171008; border-left: 1px solid rgba(212,169,78,.4);
  padding: 16px; overflow-y: auto; box-shadow: -12px 0 40px rgba(0,0,0,.5);
}
.prompts-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.prompts-hint { opacity: .65; font-size: .85rem; margin: 0 0 12px; }
.prompt-card {
  background: rgba(0,0,0,.28); border: 1px solid rgba(212,169,78,.3);
  border-radius: 12px; padding: 12px; margin-bottom: 12px;
}
.prompt-q { font-size: 1.02rem; font-style: italic; color: #f3e3bb; }
.prompt-by { opacity: .55; font-size: .78rem; margin: 4px 0 8px; }
.prompt-r { border-top: 1px dashed rgba(212,169,78,.3); padding: 8px 0; }
.prompt-r p { margin: 0 0 4px; line-height: 1.5; }
.prompt-r-form { display: flex; gap: 6px; margin-top: 8px; }
.prompt-r-form input, .prompt-add input {
  flex: 1; background: #0d0903; border: 1px solid rgba(212,169,78,.4);
  color: #f8ecd2; border-radius: 8px; padding: 8px 10px; font-size: .9rem;
}
.prompt-add { display: flex; gap: 6px; margin-top: 10px; }

/* ---------- reader: small screens ---------- */
@media (max-width: 720px) {
  .reader-top { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .reader-top .brand { flex: 1 1 100%; order: -1; font-size: 1.05rem !important; }
  .reader-top .btn.small { padding: 6px 10px; font-size: .8rem; }
  .page-inner { padding: 20px 16px 40px; }
  .page-inner h2 { font-size: 1.6rem; margin-bottom: 14px; }
  .page-inner p { font-size: 1rem; line-height: 1.75; margin-bottom: 16px; }
  .page-inner figure img { max-height: 260px; border-width: 4px; }
  .page-num { bottom: 10px; }
  .cover-page h1 { font-size: 1.6rem; }
  .reader-body .reader-stage { padding: 6px 8px; }
  .reader-body .reader-controls { padding: 6px 12px 12px; gap: 12px; }
}

/* Collage pages in scroll mode (phones): the page grows with content there,
   so the arrangement gets an explicit stage height instead of filling. */
#flipbook.scroll-mode .collage { height: 540px; flex: none; }
@media (max-width: 720px) {
  #flipbook.scroll-mode .collage { height: 430px; }
  .page-inner .collage { gap: 9px; }
  .page-inner .collage .ph { padding: 5px 5px 14px; }
}

/* ---- Send photos dialog (signed-in contributors → admin inbox) ---- */
.sp-dlg { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.sp-dlg.hidden { display: none; }
.sp-card { position: relative; width: min(560px, 100%); max-height: calc(100vh - 60px); overflow-y: auto;
  background: rgba(14, 10, 5, .98); border: 1px solid rgba(212,169,78,.5); border-radius: 14px;
  padding: 22px 22px 18px; color: var(--cream); box-shadow: 0 24px 60px rgba(0,0,0,.65); }
.sp-card h3 { margin: 0 0 6px; font-family: Georgia, serif; color: var(--gold); }
.sp-sub { margin: 0 0 14px; font-size: .9rem; opacity: .75; line-height: 1.45; }
.sp-close { position: absolute; top: 12px; right: 12px; }
.sp-pick { display: inline-block; margin-bottom: 12px; cursor: pointer; }
.sp-thumbs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.sp-row { display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.04);
  border: 1px solid rgba(212,169,78,.2); border-radius: 10px; padding: 8px; }
.sp-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; background: #222; }
.sp-meta { flex: 1; min-width: 0; }
.sp-date-wrap { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.date-fix { background: none; border: none; color: #d6b26a; font-size: 12px;
  cursor: pointer; text-decoration: underline; padding: 2px 4px; flex: none; }
.date-edit { display: flex; gap: 6px; margin-top: 6px; }
.date-edit select { background: #171008; border: 1px solid rgba(212,169,78,.4);
  color: #f8ecd2; border-radius: 8px; padding: 8px; font-size: 14px; }
.sp-bulkdate { margin: 12px 0; padding: 12px; background: rgba(212,169,78,.08);
  border: 1px solid rgba(212,169,78,.3); border-radius: 10px; }
.sp-bulkdate select { background: #171008; border: 1px solid rgba(212,169,78,.4);
  color: #f8ecd2; border-radius: 8px; padding: 10px; font-size: 15px; }
.sp-meta input { width: 100%; box-sizing: border-box; background: rgba(255,255,255,.07); color: var(--cream);
  border: 1px solid rgba(212,169,78,.3); border-radius: 8px; padding: 7px 10px; font-size: .85rem; }
.sp-stat { font-size: .78rem; opacity: .65; margin-top: 4px; }
.sp-stat.done { color: #9fd48a; opacity: 1; }
.sp-prog { height: 10px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.sp-bar { height: 100%; width: 0; background: linear-gradient(90deg, #b98a2e, #e8c26a); border-radius: 999px;
  transition: width .2s ease; }
.sp-status { font-size: .9rem; line-height: 1.5; margin: 8px 0; }
.sp-status .phase { color: var(--gold); font-weight: 600; }
.sp-status .ok { color: #9fd48a; font-weight: 600; }
.sp-status .bad { color: #ff9d8a; }
.sp-actions { margin-top: 10px; text-align: right; }
.sp-dest { margin: 4px 0 12px; }
.sp-dest label { display: block; margin-bottom: 8px; font-weight: bold; font-size: .9rem; color: var(--cream); }
.sp-dest select, .sp-dest input[type="text"] { width: 100%; box-sizing: border-box; padding: 10px 12px;
  background: #171008; border: 1px solid rgba(212,169,78,.4); color: var(--cream);
  border-radius: 8px; font-size: .9rem; }
#sp-newbook-wrap { margin-top: 8px; }

/* ---------- mobile topbar: wrap instead of overflow ---------- */
@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .topbar .brand { font-size: 1.15rem; }
  .topbar .who, .topbar .spacer { display: none; }
}

/* ---- page threads: bar, chips, glow (2026-10-20) ---- */
.thread-bar {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 8px 12px 2px; flex-wrap: wrap;
  position: relative; z-index: 30;
}
.thread-bar-btn { position: relative; z-index: 31; pointer-events: auto; }
.thread-bar-btn { display: inline-flex; gap: 8px; align-items: center; }
.tb-new { color: #6ec1ff; font-size: .8rem; }
.tb-pin {
  opacity: .85; font-size: .85rem; font-style: italic; max-width: 520px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@keyframes glowPulseQ {
  0%, 100% { text-shadow: 0 0 2px rgba(246,196,83,.2); }
  50% { text-shadow: 0 0 14px rgba(246,196,83,.95), 0 0 26px rgba(246,196,83,.5); }
}
@keyframes glowPulseC {
  0%, 100% { text-shadow: 0 0 2px rgba(110,193,255,.2); }
  50% { text-shadow: 0 0 14px rgba(110,193,255,.95), 0 0 26px rgba(110,193,255,.5); }
}
.glow-q { animation: glowPulseQ 1.8s ease-in-out infinite; color: #ffd97a; font-weight: 600; }
.glow-c { animation: glowPulseC 1.8s ease-in-out infinite; color: #a8d8ff; font-weight: 600; }
.page-chip {
  display: flex; gap: 16px; align-items: center; justify-content: center;
  width: 100%; margin: 10px 0 4px; padding: 9px 10px; cursor: pointer;
  background: rgba(0,0,0,.25); border: 1px solid rgba(212,169,78,.35);
  border-radius: 999px; color: #f3e3bb; font-size: .92rem;
}
.page-chip .chip-pin { opacity: .8; font-style: italic; }
.thread-status { font-size: .75rem; padding: 1px 8px; border-radius: 999px; margin-left: 6px; }
.thread-status.wait { background: rgba(246,196,83,.18); color: #ffd97a; border: 1px solid rgba(246,196,83,.5); }
.thread-status.done { background: rgba(110,220,150,.15); color: #8fe3ae; border: 1px solid rgba(110,220,150,.45); }
.thread-actions { display: flex; gap: 6px; margin: 4px 0 2px; }
.thread-act { font-size: .75rem; padding: 2px 8px; }
#thread-add-form textarea {
  width: 100%; box-sizing: border-box; background: rgba(0,0,0,.3); color: #fff;
  border: 1px solid rgba(212,169,78,.4); border-radius: 10px; padding: 10px;
  font: inherit; resize: vertical;
}
.thread-add-btns { display: flex; gap: 8px; margin-top: 8px; }
