/* ============================================
   Adventures of the Temple of Elemental Evil
   Campaign Book Stylesheet
   ============================================ */

:root {
  --parchment-bg: #f4e8d1;
  --parchment-dark: #e8d5b5;
  --parchment-edge: #d4c4a0;
  --ink-brown: #3c2415;
  --ink-light: #5a3a24;
  --ink-faded: #7a6a5a;
  --leather-dark: #2a1a0e;
  --leather-mid: #3d2b1a;
  --leather-light: #5c4033;
  --gold-accent: #c4a35a;
  --gold-dim: #a08040;
  --red-accent: #8b2500;
  --sidebar-width: 260px;
  --sidebar-collapsed: 0px;
  --page-max-width: 800px;
  --transition-speed: 0.3s;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Crimson Text', Georgia, 'Times New Roman', serif;
  color: var(--ink-brown);
  background: var(--leather-dark);
  display: flex;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--leather-dark) 0%, var(--leather-mid) 50%, var(--leather-dark) 100%);
  border-right: 3px solid var(--gold-dim);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-speed) ease;
  z-index: 100;
  position: fixed;
  left: 0;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--gold-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-title {
  font-family: 'UnifrakturCook', cursive;
  color: var(--gold-accent);
  font-size: 1.6rem;
  letter-spacing: 2px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--gold-dim);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.2s;
}

.sidebar-toggle:hover {
  color: var(--gold-accent);
}

.sidebar-open-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 99;
  background: var(--leather-mid);
  border: 1px solid var(--gold-dim);
  color: var(--gold-accent);
  font-size: 1.4rem;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
  transition: opacity var(--transition-speed), background 0.2s;
  opacity: 0;
  pointer-events: none;
}

.sidebar-open-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-open-btn:hover {
  background: var(--leather-light);
}

.sidebar-menu {
  list-style: none;
  padding: 8px 0;
  flex: 1;
}

.sidebar-menu > li {
  border-bottom: 1px solid rgba(196, 163, 90, 0.15);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--parchment-edge);
  text-decoration: none;
  font-size: 1.05rem;
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
}

.menu-item:hover {
  background: rgba(196, 163, 90, 0.1);
  color: var(--gold-accent);
}

.menu-item.active {
  color: var(--gold-accent);
  background: rgba(196, 163, 90, 0.15);
  border-left: 3px solid var(--gold-accent);
}

.menu-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.menu-label {
  font-family: 'Crimson Text', serif;
  font-weight: 600;
}

/* Submenu (chapters) */
.submenu {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.submenu.open {
  /* Large enough to never clip the chapter list; the .sidebar is the single
     scroll container, so the submenu must NOT scroll on its own (that nested
     overflow was causing the double-scrollbar). */
  max-height: 5000px;
}

.submenu li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px 6px 18px;
  color: var(--parchment-edge);
  text-decoration: none;
  font-size: 0.88rem;
  opacity: 0.75;
  transition: opacity 0.2s, color 0.2s;
}

.submenu li a .chapter-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Chapters: bold and clearly larger than their entries */
.chapter-link {
  opacity: 0.95;
}
.chapter-link .chapter-name {
  font-weight: 700;
  font-size: calc(0.8rem + 2px);
  letter-spacing: 0.3px;
}

.submenu li a .entry-count {
  font-size: 0.72rem;
  color: var(--gold-dim);
  opacity: 0.6;
  margin-left: 8px;
  flex-shrink: 0;
}

.submenu li a:hover {
  opacity: 1;
  color: var(--gold-accent);
}

.submenu li a.active {
  opacity: 1;
  color: var(--gold-accent);
}

/* Entries nested under each chapter (revealed when the chapter is current) */
.entry-sublist {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.chapter.expanded .entry-sublist {
  max-height: 1600px;
}

.submenu .entry-link {
  display: block;
  padding: 4px 16px 4px 40px;
  font-size: 0.8rem;
  line-height: 1.3;
  white-space: normal;
  opacity: 0.6;
}

.submenu .entry-link.active {
  opacity: 1;
  color: var(--gold-accent);
}

.chapter.active > .chapter-link {
  color: var(--gold-dim);
  opacity: 1;
}

/* Open/close caret on each chapter */
.chapter-caret {
  display: inline-block;
  width: 16px;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.65;
  transition: transform 0.2s;
}
.chapter.expanded .chapter-caret {
  transform: rotate(90deg);
  opacity: 0.95;
}

/* ============================================
   Main Content Area
   ============================================ */

.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  height: 100vh;
  overflow-y: auto;
  transition: margin-left var(--transition-speed) ease;
  background: var(--parchment-bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(210, 180, 140, 0.3) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(180, 150, 110, 0.2) 0%, transparent 60%),
    linear-gradient(180deg, rgba(244, 232, 209, 1) 0%, rgba(232, 213, 181, 1) 50%, rgba(244, 232, 209, 1) 100%);
}

.content.expanded {
  margin-left: 0;
}

.section {
  display: none;
  min-height: 100vh;
}

.section.active {
  display: block;
}

.section-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 30px;
}

#section-characters .section-inner,
#section-npcs .section-inner {
  max-width: none;
  padding-left: 48px;
  padding-right: 48px;
}

.section-heading {
  font-family: 'MedievalSharp', cursive;
  font-size: 2.2rem;
  color: var(--ink-brown);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.section-heading::after {
  content: '';
  display: block;
  width: 200px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
  margin: 12px auto 30px;
}

/* ============================================
   Landing Page
   ============================================ */

.landing-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 60px 30px 40px;
  text-align: center;
}

.landing-heading {
  font-family: 'UnifrakturCook', cursive;
  font-size: 2.4rem;
  color: var(--ink-brown);
  line-height: 1.3;
  letter-spacing: 1px;
}

.landing-ornament {
  color: var(--gold-dim);
  font-size: 1rem;
  letter-spacing: 12px;
  margin: 16px 0 32px;
}

.landing-summary {
  text-align: justify;
  hyphens: auto;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink-brown);
}

.landing-summary p {
  margin-bottom: 1em;
}

.landing-summary p:first-child::first-letter {
  font-family: 'UnifrakturCook', cursive;
  float: left;
  font-size: 3.5em;
  line-height: 0.8;
  padding-right: 8px;
  padding-top: 4px;
  color: var(--red-accent);
}

.landing-meta {
  margin-top: 32px;
  color: var(--ink-faded);
  font-style: italic;
  font-size: 0.95rem;
}

.landing-btn {
  display: inline-block;
  margin-top: 16px;
  font-family: 'MedievalSharp', cursive;
  font-size: 1.1rem;
  padding: 10px 28px;
  background: var(--leather-mid);
  color: var(--gold-accent);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  letter-spacing: 1px;
}

.landing-btn:hover {
  background: var(--leather-light);
}

.landing-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.landing-btns .landing-btn {
  margin-top: 0;
}

.landing-btn-secondary {
  background: transparent;
  color: var(--gold-dim);
}

.landing-btn-secondary:hover {
  background: var(--leather-mid);
  color: var(--gold-accent);
}

/* ============================================
   Book Reader (Story Section)
   ============================================ */

.book-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 20px 10px;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.book-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 60px 8px;
  flex-shrink: 0;
}

.book-header-left {
  text-align: left;
}

.book-header-right {
  flex-shrink: 0;
}

.chapter-title {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.4rem;
  color: var(--ink-brown);
  letter-spacing: 1px;
}

.entry-date {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-faded);
  margin-top: 2px;
  display: block;
  min-height: 1em;
}

.entry-date:empty::before {
  content: '\00a0';
}

/* Story search in header */
.story-search-input {
  font-family: 'Crimson Text', serif;
  font-size: 0.95rem;
  padding: 6px 12px 6px 32px;
  width: 200px;
  background: rgba(244, 232, 209, 0.6) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a6a3a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat 8px center;
  background-size: 14px 14px;
  border: 1px solid var(--parchment-edge);
  color: var(--ink-brown);
  border-radius: 4px;
  outline: none;
}

.story-search-input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 2px rgba(196, 163, 90, 0.2);
  background: var(--parchment-bg);
}

.story-search-input::placeholder {
  color: var(--ink-faded);
  font-style: italic;
}

.story-search {
  position: relative;
  display: flex;
  align-items: center;
}

/* Clear button (X) for search inputs */
.search-clear {
  background: none;
  border: none;
  color: var(--ink-faded);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: -32px;
  z-index: 1;
  transition: color 0.2s;
}

.search-clear:hover {
  color: var(--ink-brown);
}

.search-clear.hidden {
  display: none;
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

/* Story search dropdown results */
.story-search-results {
  position: absolute;
  top: 100%;
  right: 0;
  width: 360px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--parchment-bg);
  border: 1px solid var(--parchment-edge);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 50;
}

.story-search-results .search-result {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(212, 196, 160, 0.4);
  cursor: pointer;
  font-size: 0.9rem;
}

.story-search-results .search-result:hover {
  background: rgba(196, 163, 90, 0.1);
}

.story-search-results .search-result:last-child {
  border-bottom: none;
}

/* Book reader layout with arrows on sides */
.book-reader {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 0;
}

.page-arrow {
  background: none;
  border: none;
  color: var(--ink-faded);
  font-size: 2rem;
  cursor: pointer;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
  border-radius: 4px;
}

.page-arrow:hover {
  color: var(--ink-brown);
  background: rgba(196, 163, 90, 0.1);
}

.page-arrow:disabled {
  opacity: 0.15;
  cursor: default;
}

.page-arrow:disabled:hover {
  background: none;
  color: var(--ink-faded);
}

.book-page {
  flex: 1;
  overflow-y: auto;
  padding: 24px 44px 30px;
  background: var(--parchment-bg);
  border: 1px solid var(--parchment-edge);
  border-radius: 2px;
  box-shadow:
    inset 0 0 40px rgba(0,0,0,0.03),
    0 2px 8px rgba(0,0,0,0.1),
    0 0 0 1px rgba(0,0,0,0.05);
  position: relative;
}

/* Subtle page edge effect */
.book-page::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: linear-gradient(90deg, rgba(0,0,0,0.06), transparent);
  pointer-events: none;
}

.page-content {
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--ink-brown);
}

.page-content h1 {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.8rem;
  margin: 0 0 16px;
  color: var(--ink-brown);
  text-align: center;
}

.page-content h2 {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.4rem;
  margin: 28px 0 12px;
  color: var(--ink-brown);
  border-bottom: 1px solid var(--parchment-edge);
  padding-bottom: 4px;
}

.page-content h3 {
  font-family: 'Crimson Text', serif;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 20px 0 8px;
  color: var(--ink-brown);
}

.page-content p {
  margin-bottom: 1em;
  text-align: justify;
  hyphens: auto;
}

.page-content em {
  color: var(--ink-light);
}

.page-content strong {
  color: var(--ink-brown);
  font-weight: 700;
}

.page-content blockquote {
  border-left: 3px solid var(--gold-dim);
  padding: 8px 16px;
  margin: 16px 0;
  font-style: italic;
  color: var(--ink-light);
  background: rgba(196, 163, 90, 0.06);
}

.page-content hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
  margin: 24px 0;
}

.page-content ul, .page-content ol {
  margin: 0 0 1em 24px;
}

.page-content li {
  margin-bottom: 0.3em;
}

.page-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.95rem;
}

.page-content th {
  background: rgba(60, 36, 21, 0.08);
  font-weight: 700;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--parchment-edge);
}

.page-content td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--parchment-edge);
}

/* Prelude callout (italic lead-in recap) */
.page-content .prelude {
  border-left: 3px solid var(--gold-dim);
  padding: 12px 20px;
  margin: 0 0 24px 0;
  background: rgba(196, 163, 90, 0.08);
  font-style: italic;
  color: var(--ink-light);
}

.page-content .prelude p {
  margin-bottom: 0.6em;
  text-align: left;
}

.page-content .prelude p:last-child {
  margin-bottom: 0;
}

/* Drop cap for first paragraph after prelude, or first paragraph */
.page-content .drop-cap::first-letter {
  font-family: 'UnifrakturCook', cursive;
  float: left;
  font-size: 3.5em;
  line-height: 0.8;
  padding-right: 8px;
  padding-top: 4px;
  color: var(--red-accent);
}

/* Section divider ornament */
.ornament {
  text-align: center;
  margin: 24px 0;
  color: var(--gold-dim);
  font-size: 1.2rem;
  letter-spacing: 8px;
}

/* ============================================
   Page Indicator
   ============================================ */

.page-indicator {
  text-align: center;
  padding: 6px 0 4px;
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-faded);
  flex-shrink: 0;
}

.page-jump {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-faded);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--parchment-edge);
  width: 40px;
  text-align: center;
  outline: none;
  padding: 2px;
  -moz-appearance: textfield;
}

.page-jump::-webkit-outer-spin-button,
.page-jump::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.page-jump:focus {
  border-bottom-color: var(--gold-dim);
  color: var(--ink-brown);
}

/* ============================================
   World Map (Maps section)
   ============================================ */
.maps-subtitle {
  text-align: center;
  font-family: 'Crimson Text', serif;
  font-style: italic;
  color: var(--ink-faded);
  margin: -6px 0 16px;
}

.world-map-wrap {
  max-width: 1100px;
  margin: 0 auto 28px;
}

.world-map-svg {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--parchment-edge);
  border-radius: 6px;
  background: var(--parchment-bg);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

.wm-bg { fill: var(--parchment-bg); }
.wm-sea { fill: #cfe0e0; opacity: 0.55; stroke: #8aa6a6; stroke-width: 1.5; }
.wm-forest { fill: #bcd0a8; opacity: 0.5; stroke: #7f9a6a; stroke-width: 1; }
.wm-tree { fill: #6f8a55; }
.wm-trunk { fill: #5a3a24; }
.wm-lake { fill: #cfe0e0; stroke: #8aa6a6; stroke-width: 1; }
.wm-river { fill: none; stroke: #8aa6a6; stroke-width: 2.5; opacity: 0.7; }
.wm-road { fill: none; stroke: var(--ink-light); stroke-width: 1.6; stroke-dasharray: 2 6; stroke-linecap: round; opacity: 0.55; }
.wm-town { fill: var(--leather-dark); stroke: var(--gold-accent); stroke-width: 1.5; }
.wm-home-ring { fill: none; stroke: var(--gold-accent); stroke-width: 2; }
.wm-home { fill: var(--gold-accent); stroke: var(--ink-brown); stroke-width: 0.5; }
.wm-hill { fill: none; stroke: var(--ink-light); stroke-width: 2; }
.wm-peak { fill: var(--parchment-dark); stroke: var(--ink-light); stroke-width: 1.6; }
.wm-dungeon { fill: var(--leather-dark); stroke: var(--ink-brown); stroke-width: 1; }
.wm-site { fill: var(--red-accent); }

.wm-label {
  fill: var(--ink-brown);
  font-family: 'MedievalSharp', cursive;
  font-size: 16px;
  text-anchor: middle;
}
.wm-label-home { fill: var(--red-accent); font-size: 18px; }
.wm-label-sm {
  fill: var(--ink-faded);
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 12px;
  text-anchor: middle;
}
.wm-water-label {
  fill: #5a7a7a;
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 15px;
  text-anchor: middle;
}

.map-landmark { outline: none; }
.map-landmark.clickable { cursor: pointer; }
.map-landmark.clickable:hover .wm-label,
.map-landmark.clickable:focus .wm-label { fill: var(--red-accent); }
.map-landmark.clickable:hover .wm-town { stroke-width: 2.5; }
.map-landmark.clickable:focus { outline: none; }
.map-landmark.clickable:focus .wm-label { text-decoration: underline; }

.wm-compass-ring { fill: var(--parchment-dark); stroke: var(--ink-light); stroke-width: 1.5; opacity: 0.85; }
.wm-compass-n { fill: var(--red-accent); }
.wm-compass-label { fill: var(--ink-brown); font-family: 'MedievalSharp', cursive; font-size: 16px; text-anchor: middle; }
.wm-cartouche { fill: var(--parchment-dark); stroke: var(--gold-dim); stroke-width: 1.5; opacity: 0.92; }
.wm-title-text { fill: var(--ink-brown); font-family: 'MedievalSharp', cursive; font-size: 26px; text-anchor: middle; }

/* Regional atlas — real surrounding-areas maps, parchment-tinted */
.region-map {
  margin: 0 0 30px;
  text-align: center;
}
.region-map-cap {
  font-family: 'MedievalSharp', cursive;
  color: var(--ink-brown);
  font-size: 1.15rem;
  margin-bottom: 8px;
}
.region-map img {
  width: 100%;
  max-width: 900px;
  height: auto;
  display: block;
  margin: 0 auto;
  border: 2px solid var(--parchment-edge);
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  filter: sepia(0.5) saturate(0.72) brightness(1.03) contrast(0.95);
  cursor: zoom-in;
  transition: filter 0.25s;
}
.region-map img:hover {
  filter: sepia(0.22) saturate(0.92) brightness(1.05) contrast(0.97);
}

/* Town map inside a place drill-down */
.place-map {
  margin: 22px 0;
  text-align: center;
}
.place-map img {
  max-width: 100%;
  max-height: 540px;
  border: 2px solid var(--parchment-edge);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  cursor: zoom-in;
}
.place-map figcaption {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-faded);
  margin-top: 6px;
}

/* "Nearest sessions" note when a date search finds no exact hit */
.search-fuzzy-note {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  color: var(--ink-faded);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--parchment-edge);
}
.search-fuzzy-note strong {
  color: var(--ink-brown);
  font-style: normal;
}

/* Help block under the search bar */
.search-hint {
  margin: 4px 0 18px;
  font-family: 'Crimson Text', serif;
  color: var(--ink-faded);
  font-size: 0.95rem;
}
.search-hint p { margin: 0 0 6px; }
.search-hint ul { list-style: none; margin: 0 0 6px; padding: 0; }
.search-hint li { margin: 3px 0; }
.search-hint code {
  font-family: 'Courier New', monospace;
  background: var(--parchment-dark);
  color: var(--ink-brown);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.88em;
}
.search-hint-note { font-style: italic; font-size: 0.88rem; }

.entry-jump-btn {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-faded);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 8px;
  transition: color 0.2s;
}

.entry-jump-btn:hover {
  color: var(--gold-dim);
}

/* ============================================
   Cards (Characters / Places)
   ============================================ */

.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-select {
  font-family: 'Crimson Text', serif;
  font-size: 1rem;
  padding: 8px 12px;
  background: var(--parchment-bg);
  border: 1px solid var(--parchment-edge);
  color: var(--ink-brown);
  border-radius: 4px;
  cursor: pointer;
}

.filter-search {
  font-family: 'Crimson Text', serif;
  font-size: 1rem;
  padding: 8px 12px 8px 36px;
  background: var(--parchment-bg) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a6a3a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat 10px center;
  background-size: 16px 16px;
  border: 1px solid var(--parchment-edge);
  color: var(--ink-brown);
  border-radius: 4px;
  min-width: 220px;
  flex: 1 1 220px;
  max-width: 360px;
}

.filter-search:focus {
  outline: none;
  border-color: var(--gold-dim);
}

/* Push filter selects to the right of the search input */
.filter-search + .filter-select {
  margin-left: auto;
}

.section-subheading {
  text-align: center;
  font-style: italic;
  color: var(--ink-faded);
  margin-top: -12px;
  margin-bottom: 28px;
}

/* ============================================
   Character (PC) Cards — richer layout
   ============================================ */

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 28px;
}

.character-card {
  display: flex;
  background: var(--parchment-bg);
  border: 1px solid var(--parchment-edge);
  border-radius: 6px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.1);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

a.character-card-clickable {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  position: relative;
}

@media (hover: hover) {
  a.character-card-clickable:hover {
    box-shadow: 0 6px 18px rgba(0,0,0,0.16);
    transform: translateY(-2px);
    border-color: var(--gold-dim);
  }
}

a.character-card-clickable .character-name {
  border-bottom: 1px dotted transparent;
  transition: border-color 0.2s;
}

a.character-card-clickable:hover .character-name {
  border-bottom-color: var(--gold-dim);
}

a.character-card-clickable::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a6a3a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 19.5A2.5 2.5 0 0 1 6.5 17H20'/><path d='M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z'/></svg>") no-repeat center;
  opacity: 0.55;
  transition: opacity 0.2s;
  pointer-events: none;
}

a.character-card-clickable:hover::after {
  opacity: 1;
}

.backstory-back-btn {
  font-family: 'Crimson Text', serif;
  font-size: 1rem;
  background: var(--parchment-bg);
  border: 1px solid var(--parchment-edge);
  color: var(--ink-brown);
  border-radius: 4px;
  padding: 8px 16px;
  cursor: pointer;
  margin-bottom: 24px;
  transition: background 0.15s, border-color 0.15s;
}

.backstory-back-btn:hover {
  background: rgba(196,163,90,0.15);
  border-color: var(--gold-dim);
}

.backstory-content {
  background: var(--parchment-bg);
  border: 1px solid var(--parchment-edge);
  border-radius: 6px;
  padding: 32px 40px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  max-width: 820px;
  margin: 0 auto;
}

.backstory-content h1 {
  font-family: 'MedievalSharp', cursive;
  font-size: 2.2rem;
  color: var(--ink-brown);
  text-align: center;
  margin: 0 0 4px 0;
}

.backstory-content > p:first-of-type em {
  display: block;
  text-align: center;
  color: var(--ink-faded);
  font-size: 1.05rem;
  margin: 0 0 24px 0;
}

.backstory-content p {
  font-family: 'Crimson Text', serif;
  font-size: 1.08rem;
  line-height: 1.7;
  color: var(--ink-brown);
  margin: 0 0 14px 0;
}

.backstory-content hr {
  border: none;
  text-align: center;
  margin: 24px 0;
}

.backstory-content hr::after {
  content: "❦";
  color: var(--gold-dim);
  font-size: 1.4rem;
}

.character-portrait {
  flex: 0 0 180px;
  background: linear-gradient(135deg, rgba(196,163,90,0.15), rgba(120,100,80,0.18));
  border-right: 1px solid var(--parchment-edge);
  display: flex;
  align-items: center;
  justify-content: center;
}

.character-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-portrait-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'UnifrakturCook', 'MedievalSharp', cursive;
  font-size: 3rem;
  color: var(--gold-dim);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.15);
  letter-spacing: 2px;
}

.character-body {
  flex: 1;
  padding: 16px 20px;
  min-width: 0;
}

.character-name {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.5rem;
  color: var(--ink-brown);
  margin: 0 0 2px 0;
  line-height: 1.1;
}

.character-class {
  font-family: 'Crimson Text', serif;
  font-size: 0.95rem;
  color: var(--gold-dim);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.character-title {
  font-size: 0.85rem;
  color: var(--ink-faded);
  font-style: italic;
  margin-top: 2px;
}

.character-status {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(196,163,90,0.12);
  border-left: 3px solid var(--gold-dim);
  font-size: 0.9rem;
  color: var(--ink-brown);
  border-radius: 0 3px 3px 0;
}

.character-status .status-label {
  font-family: 'MedievalSharp', cursive;
  color: var(--gold-dim);
  margin-right: 4px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.character-description {
  margin: 12px 0 0 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-light);
}

.character-deity {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--ink-faded);
  font-style: italic;
  text-align: right;
}

@media (max-width: 600px) {
  .character-card {
    flex-direction: column;
  }
  .character-portrait {
    flex: 0 0 160px;
    border-right: none;
    border-bottom: 1px solid var(--parchment-edge);
  }
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* NPC grid uses the wider character-card width */
#npcs-grid.card-grid {
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 28px;
}

.card {
  background: var(--parchment-bg);
  border: 1px solid var(--parchment-edge);
  border-radius: 4px;
  padding: 16px 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  transition: box-shadow 0.2s, transform 0.2s;
}

.card-name {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.2rem;
  color: var(--ink-brown);
  margin-bottom: 4px;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--ink-faded);
  font-style: italic;
  margin-bottom: 8px;
}

.card-description {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-light);
}

.card-tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 8px;
  margin-right: 4px;
  font-weight: 600;
}

.tag-ally { background: rgba(34, 120, 60, 0.15); color: #1a6030; }
.tag-enemy { background: rgba(139, 37, 0, 0.15); color: var(--red-accent); }
.tag-neutral { background: rgba(120, 100, 80, 0.15); color: var(--ink-faded); }
.tag-party { background: rgba(196, 163, 90, 0.2); color: var(--gold-dim); }
.tag-alive { background: rgba(34, 120, 60, 0.1); color: #1a6030; }
.tag-dead { background: rgba(139, 37, 0, 0.1); color: var(--red-accent); }
.tag-missing { background: rgba(120, 80, 180, 0.1); color: #604090; }

/* ============================================
   Maps Gallery
   ============================================ */

.maps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.map-card {
  cursor: pointer;
  border: 1px solid var(--parchment-edge);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  transition: box-shadow 0.2s, transform 0.2s;
}

.map-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}

.map-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.map-card-caption {
  padding: 10px 12px;
  background: var(--parchment-bg);
  font-family: 'Crimson Text', serif;
  font-size: 0.9rem;
  color: var(--ink-brown);
}

/* Lightbox */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.lightbox.hidden {
  display: none;
}

.lightbox img {
  max-width: 90%;
  max-height: 80%;
  border: 3px solid var(--gold-dim);
  border-radius: 4px;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  background: none;
  border: none;
  color: var(--parchment-bg);
  font-size: 2.5rem;
  cursor: pointer;
}

.lightbox-caption {
  color: var(--parchment-bg);
  font-family: 'Crimson Text', serif;
  font-style: italic;
  margin-top: 12px;
  font-size: 1rem;
}

/* ============================================
   House Rules
   ============================================ */

.rule-category {
  margin-bottom: 32px;
}

.rule-category-title {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.3rem;
  color: var(--ink-brown);
  border-bottom: 1px solid var(--parchment-edge);
  padding-bottom: 4px;
  margin-bottom: 12px;
}

.rule-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(212, 196, 160, 0.4);
  font-size: 1rem;
  line-height: 1.6;
}

.rule-source {
  font-size: 0.8rem;
  color: var(--ink-faded);
  font-style: italic;
}

/* ============================================
   Search
   ============================================ */

.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  align-items: center;
}

.search-input {
  flex: 1;
  font-family: 'Crimson Text', serif;
  font-size: 1.1rem;
  padding: 10px 16px 10px 44px;
  background: var(--parchment-bg) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a6a3a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat 14px center;
  background-size: 18px 18px;
  border: 1px solid var(--parchment-edge);
  color: var(--ink-brown);
  border-radius: 4px;
  outline: none;
}

.search-input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 2px rgba(196, 163, 90, 0.2);
}

.search-input::placeholder {
  color: var(--ink-faded);
  font-style: italic;
}

.search-btn {
  font-family: 'Crimson Text', serif;
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 20px;
  background: var(--leather-mid);
  color: var(--gold-accent);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.search-btn:hover {
  background: var(--leather-light);
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-result {
  padding: 14px 18px;
  background: var(--parchment-bg);
  border: 1px solid var(--parchment-edge);
  border-radius: 4px;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.search-result:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.search-result-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.search-result-chapter {
  font-family: 'MedievalSharp', cursive;
  font-size: 1rem;
  color: var(--ink-brown);
}

.search-result-date {
  font-size: 0.85rem;
  color: var(--ink-faded);
  font-style: italic;
}

.search-result-snippet {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-light);
}

.search-result-snippet mark {
  background: rgba(196, 163, 90, 0.35);
  color: var(--ink-brown);
  padding: 0 2px;
  border-radius: 2px;
}

.no-results {
  text-align: center;
  color: var(--ink-faded);
  font-style: italic;
  padding: 40px 0;
  font-size: 1.1rem;
}

/* ============================================
   Scrollbar Styling
   ============================================ */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--parchment-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--parchment-edge);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dim);
}

.sidebar::-webkit-scrollbar-track {
  background: var(--leather-dark);
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--leather-light);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }

  .sidebar.open-mobile {
    transform: translateX(0);
  }

  .sidebar-open-btn {
    opacity: 1;
    pointer-events: auto;
  }

  .content {
    margin-left: 0;
  }

  .book-page {
    padding: 16px 20px 24px;
  }

  .page-content {
    font-size: 1rem;
  }

  .section-inner {
    padding: 24px 16px;
  }

  .card-grid,
  .character-grid,
  .place-children-grid {
    grid-template-columns: 1fr;
  }

  #section-characters .section-inner,
  #section-npcs .section-inner {
    padding-left: 16px;
    padding-right: 16px;
  }

  #npcs-grid.card-grid {
    grid-template-columns: 1fr;
  }

  .place-detail {
    padding: 20px 16px;
  }

  .place-detail-header {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  .page-arrow {
    font-size: 1.1rem;
    padding: 0 4px;
  }

  .book-header {
    flex-wrap: wrap;
    padding: 10px 16px 6px;
    gap: 8px;
  }

  .book-header-left {
    flex: 1 1 100%;
    min-width: 0;
  }

  .book-header-right {
    flex: 1 1 100%;
  }

  .story-search-input {
    width: 100%;
  }

  .chapter-title {
    font-size: 1.15rem;
    line-height: 1.2;
    word-wrap: break-word;
  }
}

/* ============================================
   Places — Filter chips, type icons, drilldown
   ============================================ */

.place-filter-block {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-label {
  font-family: 'MedievalSharp', cursive;
  color: var(--ink-faded);
  font-size: 0.95rem;
  min-width: 64px;
}

.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Crimson Text', serif;
  font-size: 0.92rem;
  padding: 5px 12px;
  background: var(--parchment-bg);
  border: 1px solid var(--parchment-edge);
  color: var(--ink-brown);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.filter-chip:hover {
  border-color: var(--gold-dim);
}

.filter-chip.active {
  background: rgba(196,163,90,0.25);
  border-color: var(--gold-dim);
}

.filter-chip-empty {
  opacity: 0.35;
  cursor: default;
}

.filter-chip-empty:hover {
  border-color: var(--parchment-edge);
}

.filter-clear-btn {
  font-family: 'Crimson Text', serif;
  font-size: 0.9rem;
  background: transparent;
  border: 1px dotted var(--ink-faded);
  color: var(--ink-faded);
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
  margin-bottom: 16px;
  transition: color 0.15s, border-color 0.15s;
}

.filter-clear-btn:hover {
  color: var(--ink-brown);
  border-color: var(--ink-brown);
}

.chip-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  color: var(--ink-brown);
}

.chip-icon svg {
  width: 100%;
  height: 100%;
}

.place-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.place-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.place-type-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  color: var(--ink-brown);
  flex-shrink: 0;
  opacity: 0.78;
}

.place-type-icon svg {
  width: 100%;
  height: 100%;
}

.place-type-icon-large {
  width: 56px;
  height: 56px;
}

.place-card-title {
  flex: 1;
  min-width: 0;
}

.place-card-meta {
  font-family: 'Crimson Text', serif;
  font-size: 0.85rem;
  color: var(--ink-faded);
  font-style: italic;
  margin-top: 2px;
}

a.place-card-clickable {
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}

@media (hover: hover) {
  a.place-card-clickable:hover {
    box-shadow: 0 6px 18px rgba(0,0,0,0.16);
    transform: translateY(-2px);
    border-color: var(--gold-dim);
  }
  a.place-card-clickable:hover .place-type-icon {
    opacity: 1;
  }
}

/* ---- detail view ---- */

.place-detail {
  background: var(--parchment-bg);
  border: 1px solid var(--parchment-edge);
  border-radius: 6px;
  padding: 28px 36px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  max-width: 920px;
  margin: 0 auto;
}

.place-detail-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--parchment-edge);
}

.place-detail-title {
  font-family: 'MedievalSharp', cursive;
  font-size: 2rem;
  color: var(--ink-brown);
  margin: 0 0 4px 0;
}

.place-detail-meta {
  font-family: 'Crimson Text', serif;
  font-size: 0.95rem;
  color: var(--ink-faded);
  font-style: italic;
}

.place-detail-description {
  font-family: 'Crimson Text', serif;
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--ink-brown);
  margin: 0 0 10px 0;
}

.place-detail-significance {
  font-family: 'Crimson Text', serif;
  color: var(--ink-light);
  margin: 0 0 14px 0;
}

.place-detail-section-heading {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.3rem;
  color: var(--ink-brown);
  margin: 28px 0 12px 0;
  padding-bottom: 4px;
  border-bottom: 1px dotted var(--parchment-edge);
}

.place-children-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.place-child-card {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(244,232,209,0.45);
  border: 1px solid var(--parchment-edge);
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  align-items: flex-start;
  transition: background 0.15s, border-color 0.15s;
}

a.place-child-card.place-card-clickable:hover {
  background: rgba(196,163,90,0.18);
  border-color: var(--gold-dim);
}

.place-child-card .place-type-icon {
  width: 24px;
  height: 24px;
  margin-top: 2px;
}

.place-child-name {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.05rem;
  color: var(--ink-brown);
  margin-bottom: 2px;
}

.place-child-meta {
  font-family: 'Crimson Text', serif;
  font-size: 0.8rem;
  color: var(--ink-faded);
  font-style: italic;
  margin-bottom: 4px;
}

.place-child-desc {
  font-family: 'Crimson Text', serif;
  font-size: 0.9rem;
  color: var(--ink-light);
  line-height: 1.4;
}

/* People-met list inside place detail */
.place-npc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.npc-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(244,232,209,0.45);
  border: 1px solid var(--parchment-edge);
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  font-family: 'Crimson Text', serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.npc-link:hover {
  background: rgba(196,163,90,0.18);
  border-color: var(--gold-dim);
}

.npc-link-name {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.05rem;
  color: var(--ink-brown);
}

.npc-link-role {
  font-style: italic;
  color: var(--ink-light);
  font-size: 0.95rem;
}

.npc-where {
  color: var(--ink-faded);
  font-size: 0.85rem;
  font-style: italic;
}

.npc-met-link {
  color: var(--ink-brown);
  text-decoration: underline dotted;
  text-decoration-color: var(--gold-dim);
}

.npc-met-link:hover {
  color: var(--gold-dim);
}

/* ============================================
   Featured NPC cards (portrait + body)
   ============================================ */

.npc-card-featured {
  display: flex;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.npc-portrait {
  flex: 0 0 160px;
  background: linear-gradient(135deg, rgba(196,163,90,0.15), rgba(120,100,80,0.18));
  border-right: 1px solid var(--parchment-edge);
  display: flex;
  align-items: center;
  justify-content: center;
}

.npc-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.npc-portrait-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'UnifrakturCook', 'MedievalSharp', cursive;
  font-size: 2.4rem;
  color: var(--gold-dim);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.15);
  letter-spacing: 2px;
}

.npc-body {
  flex: 1;
  padding: 16px 20px;
  min-width: 0;
}

@media (max-width: 700px) {
  .npc-card-featured {
    flex-direction: column;
    grid-column: span 1;
  }
  .npc-portrait {
    flex: 0 0 auto;
    width: 100%;
    height: 220px;
    border-right: none;
    border-bottom: 1px solid var(--parchment-edge);
  }
}

/* ============================================
   Journal-mentions drawer
   ============================================ */

.journal-icon-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--ink-brown);
  opacity: 0.5;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
  z-index: 2;
}

.journal-icon-btn:hover {
  opacity: 1;
  background: rgba(196,163,90,0.18);
  border-color: var(--gold-dim);
}

.journal-icon-btn svg {
  width: 100%;
  height: 100%;
}

/* NPC cards need relative positioning to anchor the icon */
.card,
.npc-card-featured {
  position: relative;
}

.journal-icon-btn-inline {
  position: static;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 8px;
  width: 32px;
  height: 32px;
}

.mentions-drawer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

.mentions-drawer.open {
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40,28,18,0);
  transition: background 0.25s ease;
}

.mentions-drawer.open .drawer-backdrop {
  background: rgba(40,28,18,0.45);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(420px, 92vw);
  background: var(--parchment-bg);
  border-left: 1px solid var(--parchment-edge);
  box-shadow: -6px 0 24px rgba(0,0,0,0.18);
  transform: translateX(100%);
  transition: transform 0.28s ease;
  display: flex;
  flex-direction: column;
}

.mentions-drawer.open .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 12px 24px;
  border-bottom: 1px solid var(--parchment-edge);
}

.drawer-title {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.5rem;
  color: var(--ink-brown);
  margin: 0;
  line-height: 1.1;
}

.drawer-subtitle {
  font-family: 'Crimson Text', serif;
  color: var(--ink-faded);
  font-style: italic;
  font-size: 0.9rem;
  margin-top: 4px;
}

.drawer-close {
  font-family: 'Crimson Text', serif;
  font-size: 1.7rem;
  line-height: 1;
  background: transparent;
  border: none;
  color: var(--ink-faded);
  cursor: pointer;
  padding: 0 6px;
  transition: color 0.15s;
}

.drawer-close:hover {
  color: var(--ink-brown);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px 20px;
}

.drawer-entry {
  display: block;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: rgba(244,232,209,0.5);
  border: 1px solid var(--parchment-edge);
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.drawer-entry:hover {
  background: rgba(196,163,90,0.18);
  border-color: var(--gold-dim);
  transform: translateX(-2px);
}

.drawer-entry-title {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.05rem;
  color: var(--ink-brown);
}

.drawer-entry-meta {
  font-family: 'Crimson Text', serif;
  font-size: 0.85rem;
  color: var(--ink-faded);
  font-style: italic;
  margin-top: 2px;
}

.drawer-empty {
  text-align: center;
  color: var(--ink-faded);
  font-style: italic;
  padding: 20px;
}

body.drawer-open {
  overflow: hidden;
}
