:root {
  --bg: #140b06;
  --wood-dark: #221108;
  --wood-mid: #472814;
  --wood-hi: #7a4b28;
  --wood-edge: #935e34;
  --gold: #d9b45a;
  --gold-hi: #f8e4a8;
  --gold-lo: #8a6928;
  --parch: #f2e6ca;
  --parch-dark: #e2d1aa;
  --ink: #27160b;
  --cream: #efe2c6;
  --muted: #c2a77d;
  --glow: 255, 192, 102;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --caps: "Cinzel", Georgia, serif;
  --disp: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --book-h: 198px;
  --spine-w: 35px;
  --cover-w: 132px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(ellipse 75% 40% at 50% -5%, rgba(var(--glow), 0.18), transparent 70%),
    radial-gradient(ellipse 40% 60% at 0% 55%, rgba(var(--glow), 0.08), transparent 70%),
    radial-gradient(ellipse 40% 60% at 100% 55%, rgba(var(--glow), 0.08), transparent 70%),
    linear-gradient(180deg, #1d0f07 0%, #120905 45%, #0c0603 100%);
  background-attachment: fixed;
  color: var(--cream);
  font: 17px/1.45 var(--serif);
  overflow-x: hidden;
}

::selection { background: var(--gold); color: var(--ink); }

#dust {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.page-shell {
  position: relative;
  z-index: 1;
  max-width: 1520px;
  margin: 0 auto;
  padding: 14px 18px 42px;
}

/* ================= TOP HEADER & CONTROLS ================= */
.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 10px;
  font: 600 12px var(--caps);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.lamp-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffd47a;
  box-shadow: 0 0 10px 3px rgba(var(--glow), 0.75);
  margin-right: 8px;
  vertical-align: 1px;
  animation: candle 3.2s infinite;
}

.spacer { flex: 1; }

.stats-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(38, 21, 11, 0.85);
  border: 1px solid rgba(217, 180, 90, 0.28);
  color: var(--cream);
  font-size: 11px;
}

.stats-pill strong { color: var(--gold-hi); font-weight: 700; }

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.brass-btn {
  appearance: none;
  border: 1px solid rgba(217, 180, 90, 0.45);
  background: linear-gradient(180deg, #3c2212, #251309);
  color: var(--gold-hi);
  font: 700 11px/1 var(--caps);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  text-decoration: none;
}

.brass-btn:hover, .brass-btn:focus-visible {
  border-color: var(--gold-hi);
  background: linear-gradient(180deg, #523018, #311a0c);
  box-shadow: 0 0 14px rgba(var(--glow), 0.25);
  transform: translateY(-1px);
  outline: none;
}

.brass-btn.primary {
  background: linear-gradient(180deg, #e7c673, #b58832 55%, #8b651f);
  color: #211207;
  border-color: #f8e4a8;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.brass-btn.primary:hover {
  background: linear-gradient(180deg, #f6db90, #c89a3e 55%, #9d7427);
  box-shadow: 0 0 18px rgba(var(--glow), 0.45);
}

.brass-btn.danger {
  border-color: rgba(220, 100, 88, 0.5);
  color: #f2a298;
}
.brass-btn.danger:hover {
  border-color: #f28b7e;
  background: linear-gradient(180deg, #531e1a, #32100d);
}

/* ================= HERO & CATALOGUE BAR ================= */
.hero-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 24px;
  margin-bottom: 14px;
}

.title-block h1 {
  margin: 0;
  font: 700 clamp(24px, 3.6vw, 42px)/1.05 var(--disp);
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, var(--gold-hi) 10%, var(--gold) 52%, var(--gold-lo) 96%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(var(--glow), 0.3)) drop-shadow(0 2px 0 rgba(0, 0, 0, 0.7));
}

.title-block .sub {
  margin: 3px 0 0;
  font: italic 500 17px/1.2 var(--serif);
  color: var(--muted);
}

.controls-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  flex: 1;
  justify-content: flex-end;
}

/* Antique Index Card Search */
.catalogue-card {
  position: relative;
  width: 280px;
  max-width: 100%;
  background: var(--parch);
  color: var(--ink);
  border-radius: 3px;
  padding: 5px 12px 6px 32px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), 0 0 0 1px #c7b083 inset;
  background-image:
    repeating-linear-gradient(180deg, transparent 0 20px, rgba(110, 145, 185, 0.32) 20px 21px),
    linear-gradient(90deg, transparent 24px, rgba(190, 60, 60, 0.45) 24px 25px, transparent 25px);
}

.catalogue-card::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: #180d07;
  box-shadow: 0 0 0 1.5px #c5ae80;
}

.catalogue-card label {
  display: block;
  font: 700 9px var(--caps);
  letter-spacing: 0.18em;
  color: #7c5b31;
  text-transform: uppercase;
}

.catalogue-card input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: italic 600 16px/1.2 var(--serif);
  padding: 1px 0 0;
}

.catalogue-card input::placeholder { color: #8c7555; }

/* Filter Pills */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-tab {
  appearance: none;
  border: 1px solid rgba(217, 180, 90, 0.3);
  background: rgba(34, 18, 9, 0.8);
  color: var(--muted);
  font: 700 10.5px/1 var(--caps);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 11px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.filter-tab:hover {
  color: var(--gold-hi);
  border-color: rgba(217, 180, 90, 0.65);
}

.filter-tab.active {
  background: linear-gradient(180deg, #5e381c, #3b200e);
  color: var(--gold-hi);
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(var(--glow), 0.28), inset 0 1px 0 rgba(255, 224, 150, 0.25);
}

/* ================= GRAND ARCHITECTURAL LIBRARY FRAME ================= */
.library-stage {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(217, 180, 90, 0.22);
  background: #140b06;
}

.arch-crown {
  display: block;
  width: 100%;
  height: clamp(54px, 6.2vw, 94px);
  object-fit: cover;
  object-position: center top;
  user-select: none;
  pointer-events: none;
}

.arch-base {
  display: block;
  width: 100%;
  height: clamp(34px, 3.8vw, 56px);
  object-fit: cover;
  object-position: center bottom;
  user-select: none;
  pointer-events: none;
}

.arch-middle {
  display: grid;
  grid-template-columns: clamp(92px, 12.2vw, 185px) minmax(0, 1fr) clamp(92px, 12.2vw, 185px);
  position: relative;
  background: #170c06;
}

.arch-wing {
  position: relative;
  overflow: hidden;
  background-color: #211108;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center top;
  user-select: none;
  pointer-events: none;
}

.arch-wing.left {
  background-image: url('assets/wing-left.jpg');
  box-shadow: inset -10px 0 18px rgba(0, 0, 0, 0.55);
}

.arch-wing.right {
  background-image: url('assets/wing-right.jpg');
  box-shadow: inset 10px 0 18px rgba(0, 0, 0, 0.55);
}

/* Warm flickering brass sconce light halos */
.arch-wing::after {
  content: "";
  position: absolute;
  top: 18%;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 224, 145, 0.42) 0%, rgba(255, 185, 85, 0.14) 45%, transparent 72%);
  pointer-events: none;
  animation: candle 3.8s ease-in-out infinite;
}
.arch-wing.left::after { left: 26%; }
.arch-wing.right::after { right: 24%; animation-delay: -1.4s; }

/* Central Recessed Mahogany Bookcase */
.bookcase-interior {
  position: relative;
  min-height: 640px;
  background:
    radial-gradient(ellipse 30% 80% at 0% 35%, rgba(255, 195, 105, 0.09), transparent 70%),
    radial-gradient(ellipse 30% 80% at 100% 35%, rgba(255, 195, 105, 0.09), transparent 70%),
    linear-gradient(180deg, #160a05 0%, #110804 50%, #0d0603 100%);
  border-left: 5px solid #3c2110;
  border-right: 5px solid #3c2110;
  box-shadow:
    inset 0 12px 24px rgba(0, 0, 0, 0.8),
    inset 0 0 28px rgba(0, 0, 0, 0.72);
  display: flex;
  flex-direction: column;
}

/* ================= INDIVIDUAL SHELF ROW ================= */
.shelf-section {
  position: relative;
  display: flex;
  flex-direction: column;
  padding-top: 10px;
}

.shelf-section::before {
  /* Cast shadow from shelf plank above */
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 18px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent);
  pointer-events: none;
  z-index: 2;
}

.shelf-viewport {
  position: relative;
  display: flex;
  align-items: flex-end;
}

.shelf-track {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 16px 12px 0;
  width: 100%;
  min-height: calc(var(--book-h) + 18px);
  overflow-x: auto;
  overflow-y: visible;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 180, 90, 0.35) transparent;
}

.shelf-track::-webkit-scrollbar { height: 5px; }
.shelf-track::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.25); }
.shelf-track::-webkit-scrollbar-thumb { background: rgba(217, 180, 90, 0.4); border-radius: 3px; }

.shelf-plank-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.shelf-scroll-btn {
  width: 22px;
  height: 17px;
  border: 1px solid rgba(217, 180, 90, 0.55);
  background: linear-gradient(180deg, #523018, #2b1609);
  color: var(--gold-hi);
  font: 700 13px/1 var(--caps);
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 3px;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  transition: opacity 0.16s ease, background 0.16s ease;
}

.shelf-scroll-btn:hover { background: linear-gradient(180deg, #744522, #3e210f); }
.shelf-scroll-btn:disabled { opacity: 0.3; cursor: default; }

/* Mahogany Shelf Plank with Brass Category Plaque */
.shelf-plank {
  position: relative;
  height: 24px;
  background: linear-gradient(180deg,
    #8d5a32 0%,
    #6c4121 18%,
    #4b2b14 58%,
    #2e180a 88%,
    #1c0e05 100%);
  box-shadow:
    0 5px 12px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 224, 165, 0.28),
    inset 0 -2px 3px rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 3;
}

.shelf-plaque {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 1px 10px;
  border-radius: 2px;
  font: 700 9.5px/15px var(--caps);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #2b1808;
  background: linear-gradient(180deg, #f3d98d 0%, #c69a42 52%, #8e6924 100%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 250, 220, 0.55);
}

.shelf-plaque .roman {
  font-weight: 900;
  opacity: 0.85;
}

.shelf-meta {
  font: italic 600 12.5px/1 var(--serif);
  color: rgba(242, 222, 184, 0.78);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

/* ================= SPINE-OUT BOOK ================= */
.book-spine {
  position: relative;
  flex: 1 0 var(--spine-w);
  min-width: 31px;
  max-width: 44px;
  height: var(--book-h);
  border: 0;
  padding: 0;
  cursor: pointer;
  border-radius: 3px 3px 1px 1px;
  color: var(--gold-hi);
  background:
    /* Cylindrical spine shading */
    linear-gradient(90deg,
      rgba(0, 0, 0, 0.58) 0%,
      rgba(255, 255, 255, 0.13) 18%,
      rgba(255, 255, 255, 0.04) 48%,
      rgba(0, 0, 0, 0.24) 82%,
      rgba(0, 0, 0, 0.68) 100%),
    /* Subtle vertical warm shelf-light sheen */
    linear-gradient(180deg,
      rgba(255, 225, 165, 0.08) 0%,
      transparent 20%,
      transparent 82%,
      rgba(0, 0, 0, 0.35) 100%),
    var(--c, #5c261c);
  box-shadow:
    inset 0 1px 1px rgba(255, 232, 185, 0.25),
    inset 0 -3px 6px rgba(0, 0, 0, 0.6),
    1px 0 3px rgba(0, 0, 0, 0.75);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1), box-shadow 0.22s ease, filter 0.2s ease;
  transform-origin: center bottom;
  outline: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  overflow: visible;
}

/* Subtle antique leather grain overlay */
.book-spine::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0.26;
  mix-blend-mode: overlay;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Top & bottom ornate gold-leaf filigree caps + raised bands */
.spine-cap {
  width: 100%;
  height: 21px;
  flex: none;
  position: relative;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spine-cap.top {
  border-bottom: 2px solid rgba(217, 180, 90, 0.65);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.55), inset 0 -1px 0 rgba(255, 232, 165, 0.35);
}

.spine-cap.bottom {
  border-top: 2px solid rgba(217, 180, 90, 0.65);
  box-shadow: 0 -2px 0 rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 232, 165, 0.35);
}

.spine-cap::after {
  content: "❖";
  font-size: 10px;
  color: rgba(235, 198, 106, 0.72);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
}

/* Central antique gold-framed panel with vertical top-to-bottom lettering */
.spine-panel {
  flex: 1;
  width: calc(100% - 7px);
  margin: 3px 0;
  border: 1px solid rgba(217, 180, 90, 0.38);
  border-radius: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 3px 1px;
  position: relative;
}

.spine-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font: 700 9.5px/1 var(--caps);
  letter-spacing: 0.055em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 100%;
  color: #f4d88c;
  text-shadow:
    1px 1px 1px rgba(10, 5, 2, 0.92),
    -0.5px -0.5px 0 rgba(10, 5, 2, 0.65);
  pointer-events: none;
}

/* Slight organic antique height variation */
.book-spine[data-var="1"] { height: calc(var(--book-h) - 4px); }
.book-spine[data-var="2"] { height: calc(var(--book-h) - 2px); }
.book-spine[data-var="3"] { height: var(--book-h); }

/* Hover & Focus: smoothly pull book forward with warm candlelight rim glow */
.book-spine:hover,
.book-spine:focus-visible {
  transform: translateY(-12px) scale(1.06);
  z-index: 15;
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.85),
    0 0 18px rgba(var(--glow), 0.45),
    inset 0 0 0 1px rgba(248, 228, 168, 0.65);
}

.book-spine:hover .spine-title,
.book-spine:focus-visible .spine-title {
  color: #fff2c4;
}

/* In Progress: Silk Gold Bookmark Ribbon draped from the top */
.book-spine.is-building .ribbon-mark {
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 11px;
  height: 22px;
  background: linear-gradient(180deg, #fce296, #d4a135 70%, #9b6f1a);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.65);
  z-index: 6;
  pointer-events: none;
}

/* ================= COVER-OUT BOOK (BUILT APPS!) ================= */
.book-cover {
  position: relative;
  flex: 0 0 var(--cover-w);
  width: var(--cover-w);
  height: var(--book-h);
  margin: 0 6px;
  perspective: 900px;
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.3, 1);
  transform-origin: center bottom;
  outline: none;
}

.book-cover:hover,
.book-cover:focus-visible {
  transform: translateY(-10px) rotate(-1deg);
  z-index: 16;
}

.cover-pages {
  position: absolute;
  inset: 3px -5px 0 7px;
  border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(180deg, #f0e3c6 0 2px, #d8c69f 2px 3px);
  box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.65);
}

.cover-pages span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: italic 600 13px var(--serif);
  color: #6b4e29;
  opacity: 0;
  transition: opacity 0.2s 0.2s;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.16), transparent 32%), #f3e8ce;
}

.cover-face {
  position: absolute;
  inset: 0;
  border-radius: 3px 5px 5px 3px;
  transform-origin: left center;
  transition: transform 0.52s cubic-bezier(0.4, 0.1, 0.3, 1), box-shadow 0.28s ease;
  background:
    linear-gradient(90deg,
      rgba(0, 0, 0, 0.58) 0 6px,
      rgba(255, 255, 255, 0.14) 7px 8px,
      rgba(0, 0, 0, 0.25) 9px 10px,
      transparent 15px),
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.14), transparent 62%),
    var(--c, #68211c);
  box-shadow:
    0 0 18px 2px rgba(var(--glow), 0.32),
    0 0 38px 4px rgba(var(--glow), 0.14),
    inset 0 0 20px rgba(0, 0, 0, 0.52),
    3px 4px 12px rgba(0, 0, 0, 0.7);
}

.cover-face::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0.3;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.book-cover:hover .cover-face {
  box-shadow:
    0 0 26px 6px rgba(var(--glow), 0.52),
    inset 0 0 20px rgba(0, 0, 0, 0.48),
    4px 10px 18px rgba(0, 0, 0, 0.72);
}

.book-cover.opening .cover-face { transform: rotateY(-116deg); }
.book-cover.opening .cover-pages span { opacity: 1; }

.cover-frame {
  position: absolute;
  inset: 8px 7px 8px 14px;
  border: 1.5px solid var(--gold);
  outline: 1px solid rgba(217, 180, 90, 0.42);
  outline-offset: 2px;
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 5px 7px;
  overflow: hidden;
}

.cover-frame::before,
.cover-frame::after {
  content: "❧";
  position: absolute;
  font-size: 9px;
  color: var(--gold);
  line-height: 1;
}
.cover-frame::before { top: 2px; left: 3px; }
.cover-frame::after { bottom: 2px; right: 3px; transform: rotate(180deg); }

.cover-medal {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  flex: none;
  background: radial-gradient(circle at 35% 30%, #f8e4a8, #be943d 62%, #7a581e);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.4), 0 0 9px rgba(var(--glow), 0.45);
}

.cover-title {
  margin: 6px 0 0;
  font: 700 11px/1.15 var(--caps);
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 58%, #ab842e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.75));
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-rule {
  color: var(--gold);
  font-size: 9px;
  margin: 2px 0;
  opacity: 0.85;
}

.cover-desc {
  margin: 0;
  font: italic 500 10.5px/1.18 var(--serif);
  color: rgba(242, 230, 202, 0.86);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-badge {
  margin-top: auto;
  padding-top: 3px;
  font: 700 8px var(--caps);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-hi);
}

.cover-edit-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 8;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(248, 228, 168, 0.65);
  background: rgba(24, 13, 6, 0.88);
  color: var(--gold-hi);
  font-size: 11px;
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.15s ease, background 0.15s ease;
}

.book-cover:hover .cover-edit-btn,
.book-cover:focus-within .cover-edit-btn {
  opacity: 1;
}

.cover-edit-btn:hover {
  background: #523018;
  transform: scale(1.12);
}

/* Search / Filter dimmed or empty states */
.book-dimmed {
  opacity: 0.16;
  filter: grayscale(0.7);
  pointer-events: none;
}

.shelf-empty {
  width: 100%;
  height: var(--book-h);
  display: grid;
  place-items: center;
  font: italic 500 17px var(--serif);
  color: rgba(194, 167, 125, 0.55);
  padding: 0 16px;
  text-align: center;
}

/* ================= FLOATING PARCHMENT TOOLTIP ================= */
.hover-card {
  position: fixed;
  z-index: 60;
  width: 270px;
  pointer-events: none;
  background: linear-gradient(180deg, #f6ebd1, #e8d7b2);
  color: var(--ink);
  border: 1px solid #b5924d;
  border-radius: 4px;
  padding: 10px 13px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.72), inset 0 0 0 2px rgba(181, 146, 77, 0.25);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.hover-card.show {
  opacity: 1;
  transform: translateY(0);
}

.hover-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(122, 90, 50, 0.28);
  padding-bottom: 4px;
  margin-bottom: 5px;
}

.hover-card-title {
  font: 700 13px/1.2 var(--caps);
  color: #3a1d0c;
  letter-spacing: 0.04em;
}

.hover-card-status {
  font: 700 8.5px/1 var(--caps);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 2px;
  white-space: nowrap;
}

.hover-card-status.idea { background: #dfd0ae; color: #5b4020; }
.hover-card-status.building { background: #f2cf7c; color: #47280a; }
.hover-card-status.built { background: #264d34; color: #f6e4aa; }

.hover-card-desc {
  margin: 0;
  font: 500 14.5px/1.3 var(--serif);
  color: #362212;
}

.hover-card-hint {
  margin-top: 6px;
  font: 700 9px var(--caps);
  letter-spacing: 0.12em;
  color: #7c5c32;
  text-transform: uppercase;
}

/* ================= READING DESK MODAL (OPEN ANTIQUE TOME) ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 4, 2, 0.78);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.tome-modal {
  width: min(740px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 8px;
  background: linear-gradient(180deg, #4b2a16, #2d170b);
  padding: 10px;
  border: 1.5px solid rgba(217, 180, 90, 0.55);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.9), 0 0 40px rgba(var(--glow), 0.18);
  transform: scale(0.96) translateY(10px);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.modal-backdrop.open .tome-modal {
  transform: scale(1) translateY(0);
}

.tome-pages {
  background:
    linear-gradient(90deg, rgba(130, 95, 45, 0.12) 0, transparent 16px, transparent calc(100% - 16px), rgba(130, 95, 45, 0.12) 100%),
    linear-gradient(180deg, #f6ebd1, #ebdbb8);
  color: var(--ink);
  border-radius: 4px;
  padding: 20px 24px 18px;
  box-shadow: inset 0 0 0 1px #cbb280;
}

.tome-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1.5px solid rgba(138, 105, 40, 0.35);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.tome-kicker {
  font: 700 10px var(--caps);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #825d2c;
}

.tome-heading {
  margin: 2px 0 0;
  font: 700 24px/1.15 var(--caps);
  color: #361909;
}

.close-x {
  appearance: none;
  border: 1px solid rgba(122, 90, 50, 0.35);
  background: rgba(255, 255, 255, 0.35);
  color: #4a2a14;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.close-x:hover { background: #e0cca0; }

/* 3-State Display Mode Toggle */
.status-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.status-opt {
  appearance: none;
  border: 1.5px solid rgba(122, 90, 50, 0.35);
  background: rgba(255, 252, 242, 0.55);
  color: #4a2e16;
  border-radius: 5px;
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.16s ease;
}

.status-opt strong {
  display: block;
  font: 700 11px/1.2 var(--caps);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-opt small {
  display: block;
  margin-top: 2px;
  font: italic 500 13px/1.2 var(--serif);
  color: #6d4f2c;
}

.status-opt:hover { border-color: #9e742d; background: rgba(255, 252, 242, 0.9); }

.status-opt.active {
  background: linear-gradient(180deg, #4b2814, #2d160a);
  color: var(--gold-hi);
  border-color: var(--gold);
  box-shadow: 0 4px 12px rgba(45, 22, 10, 0.35);
}

.status-opt.active small { color: var(--parch-dark); }

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }

.field label {
  font: 700 10.5px var(--caps);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6e4e26;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid rgba(128, 96, 52, 0.45);
  background: rgba(255, 252, 244, 0.78);
  color: var(--ink);
  border-radius: 4px;
  padding: 8px 10px;
  font: 600 16px/1.35 var(--serif);
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #9a6d23;
  box-shadow: 0 0 0 2px rgba(217, 180, 90, 0.32);
  background: #fffdf7;
}

.field textarea { resize: vertical; min-height: 64px; }

.url-row {
  display: flex;
  gap: 8px;
}
.url-row input { flex: 1; }

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 2px;
}

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.swatch:hover { transform: scale(1.14); }
.swatch.active {
  border-color: #2c1608;
  box-shadow: 0 0 0 2px var(--gold), 0 2px 6px rgba(0, 0, 0, 0.45);
  transform: scale(1.16);
}

.icon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 76px;
  overflow-y: auto;
  padding: 4px;
  background: rgba(255, 252, 244, 0.5);
  border: 1px solid rgba(128, 96, 52, 0.3);
  border-radius: 4px;
}

.icon-opt {
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-opt:hover { background: rgba(217, 180, 90, 0.25); }
.icon-opt.active {
  background: #4b2814;
  border-color: var(--gold);
}

.tome-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(138, 105, 40, 0.3);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tome-footer-right {
  display: flex;
  gap: 8px;
}

/* Poster Lightbox */
.poster-modal {
  width: min(1180px, 96vw);
  background: #1a0e07;
  border: 1.5px solid rgba(217, 180, 90, 0.5);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.92);
}

.poster-modal img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

.poster-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.poster-head h2 {
  margin: 0;
  font: 700 16px var(--caps);
  letter-spacing: 0.1em;
  color: var(--gold-hi);
}

/* Footer */
.page-foot {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 18px;
  font: 600 11.5px var(--caps);
  letter-spacing: 0.08em;
  color: #cbb288;
}

.page-foot kbd {
  font: inherit;
  border: 1px solid #5e4427;
  border-radius: 3px;
  padding: 0 5px;
  color: var(--cream);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  z-index: 150;
  background: linear-gradient(180deg, #4b2a15, #291509);
  color: var(--gold-hi);
  border: 1px solid var(--gold);
  border-radius: 5px;
  padding: 9px 18px;
  font: 700 12px var(--caps);
  letter-spacing: 0.1em;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes candle {
  0%, 100% { opacity: 1; }
  42% { opacity: 0.78; }
  58% { opacity: 0.96; }
  75% { opacity: 0.82; }
}

/* ================= RESPONSIVE ================= */
@media (max-width: 980px) {
  .arch-middle {
    grid-template-columns: 0 minmax(0, 1fr) 0;
  }
  .arch-wing { display: none; }
  .bookcase-interior {
    border-left: 10px solid #4a2a15;
    border-right: 10px solid #4a2a15;
  }
  .controls-cluster { justify-content: flex-start; }
}

@media (max-width: 640px) {
  :root { --book-h: 156px; --spine-w: 32px; --cover-w: 112px; }
  .page-shell { padding: 10px 10px 30px; }
  .form-grid { grid-template-columns: 1fr; }
  .status-selector { grid-template-columns: 1fr; }
  .shelf-meta { display: none; }
  .catalogue-card { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  #dust { display: none; }
  .lamp-dot, .arch-wing::after { animation: none; }
  .book-spine, .book-cover, .cover-face { transition: none; }
}
