:root {
  --bg-1: #0a0a2a;
  --bg-2: #1a0a3a;
  --cyan: #00ffff;
  --pink: #ff77ff;
  --text: #f4f4ff;
  --muted: rgba(244,244,255,0.55);
  --line: rgba(255,119,255,0.22);
  --panel: rgba(0,0,40,0.78);
  --orange: #f60;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%) fixed;
  /* overflow is set later: scrollable by default, hidden only when map is shown */
}
body.show-map {
  overflow: hidden;
  height: 100%;
}

/* Perspective grid backdrop */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,119,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,119,255,0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  transform: perspective(800px) rotateX(60deg) translateY(80px);
  transform-origin: center bottom;
  pointer-events: none;
  z-index: -1;
}

/* TOP BAR */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--pink);
  background: rgba(0,0,40,0.6); backdrop-filter: blur(6px);
}
.brand {
  font-family: 'Orbitron', sans-serif; font-weight: 700;
  letter-spacing: 0.18em; color: var(--cyan);
  text-shadow: 0 0 10px rgba(0,255,255,0.45);
}
.brand-meta { color: var(--pink); text-shadow: 0 0 8px rgba(255,119,255,0.4); }
.stat { font-family: 'Orbitron', sans-serif; font-size: 11px; letter-spacing: 0.15em; color: var(--muted); }
.stat span { color: var(--cyan); font-weight: 700; }

/* SEARCH + FACETS */
.searchbar {
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: rgba(0,0,40,0.45); display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
}
#q {
  flex: 1; min-width: 280px;
  background: rgba(0,0,40,0.85); color: var(--cyan); font-size: 16px;
  border: 1px solid var(--cyan); padding: 10px 14px; outline: none;
  font-family: 'Orbitron', sans-serif; letter-spacing: 0.05em;
  box-shadow: 0 0 10px rgba(0,255,255,0.25) inset, 0 0 16px rgba(0,255,255,0.18);
}
#q::placeholder { color: rgba(0,255,255,0.45); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips-divider { width: 1px; background: var(--line); margin: 0 6px; }
.chips button {
  border: 1px solid var(--pink); color: var(--pink); background: transparent;
  padding: 4px 10px; font: 600 10px/1 'Orbitron', sans-serif; letter-spacing: 0.12em;
  cursor: pointer; transition: all 0.18s;
}
.chips button:hover { background: rgba(255,119,255,0.12); }
.chips button.is-active { background: var(--pink); color: var(--bg-1); box-shadow: 0 0 10px rgba(255,119,255,0.55); }
/* Reset / "ALL" buttons (data-val="") get a softer treatment so users see them as the off-state */
.chips button[data-val=""] {
  border-color: rgba(0,255,255,0.4);
  color: var(--cyan);
  letter-spacing: 0.08em;
}
.chips button[data-val=""]:hover { background: rgba(0,255,255,0.12); }
.chips button[data-val=""].is-active {
  background: rgba(0,255,255,0.18);
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0,255,255,0.35);
}

/* DISCOVER SECTION — default homepage discovery layer */
#discover {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,30,0.5);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}
body.has-active-filter #discover { display: none; }

/* Starter chips */
.starter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.starter-chips button {
  background: rgba(255,119,255,0.08);
  color: var(--pink);
  border: 1px solid var(--pink);
  padding: 5px 12px;
  font: 600 11px/1 'Orbitron', sans-serif;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.18s;
}
.starter-chips button:hover { background: var(--pink); color: var(--bg-1); box-shadow: 0 0 8px rgba(255,119,255,0.5); }

/* Featured hero cards */
.featured {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.featured .hero-card {
  position: relative;
  aspect-ratio: 4/3;
  background: #050518;
  border: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s;
}
.featured .hero-card:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(0,255,255,0.4);
  transform: translateY(-2px);
}
.featured .hero-card img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.3s;
}
.featured .hero-card:hover img { transform: scale(1.04); }
.featured .hero-card .label {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(0deg, rgba(0,0,40,0.95), transparent);
  padding: 24px 12px 10px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}
.featured .hero-card .label strong {
  display: block;
  font: 700 9px/1 'Orbitron', sans-serif;
  color: var(--cyan);
  letter-spacing: 0.15em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

/* WORD CLOUD */
#wordcloud {
  padding: 20px;
  border-top: 1px solid var(--line);
  background: rgba(0,0,30,0.5);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
  line-height: 1.6;
  max-height: 220px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, black 60%, transparent);
  mask-image: linear-gradient(180deg, black 60%, transparent);
}
body.has-active-filter #wordcloud { display: none; }
#wordcloud span {
  font-family: 'Orbitron', sans-serif;
  cursor: pointer;
  transition: text-shadow 0.18s, opacity 0.18s;
  opacity: 0.85;
}
#wordcloud span:hover {
  text-shadow: 0 0 12px currentColor;
  opacity: 1;
}

/* ATLAS LAYOUT */
.atlas {
  display: grid;
  grid-template-columns: 1fr;
  height: auto;
  min-height: 0;
}
body.show-map .atlas {
  grid-template-columns: 1fr 1fr;
  height: calc(100vh - 56px - 60px);
}
/* When the map is showing, collapse everything else above the atlas so the
   map+results pair fills the viewport below the topbar+searchbar. */
body.show-map #discover { display: none; }
body.show-map .results-top { grid-template-columns: 1fr; }
body.show-map .results-top #wordcloud { display: none; }
/* When map hidden, results take full width and the WHOLE PAGE scrolls naturally */
body:not(.show-map) .atlas { height: auto; }
body:not(.show-map) #results { height: auto; max-height: none; overflow: visible; }
body:not(.show-map) #results-list { overflow: visible; max-height: none; }

/* The whole-page scrollability rule must hold whenever we're not in fixed-map view —
   this means with or without an active filter (search/agency/mode/realm). The earlier
   rule that forced overflow: hidden on body when has-active-filter was the bug behind
   "I cannot scroll on /?q=hovering". Keep body scrollable unless map is shown. */
body { overflow-y: auto; overflow-x: hidden; }
body.show-map { overflow: hidden; }

@media (max-width: 900px) {
  body.show-map .atlas { grid-template-columns: 1fr; grid-template-rows: 50vh auto; }
}

/* 50/50 split for the pills row + word cloud at the top of the result panel */
.results-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}
.results-top #results-header { border-bottom: none; padding-right: 14px; }
.results-top #wordcloud {
  border-top: none;
  padding: 10px 14px;
  max-height: 220px;
  margin: 0;
  border-left: 1px solid var(--line);
}
/* When filters are active the wordcloud is hidden — collapse the strip back to single column */
body.has-active-filter .results-top { grid-template-columns: 1fr; }
body.has-active-filter .results-top #results-header { padding-right: 14px; }
@media (max-width: 900px) {
  .results-top { grid-template-columns: 1fr; }
  .results-top #wordcloud { border-left: none; border-top: 1px solid var(--line); max-height: 160px; }
}

#map { background: #050518; border-right: 1px solid var(--pink); }
body:not(.show-map) #map { display: none; }
.mapboxgl-popup-content { background: var(--panel); color: var(--text); border: 1px solid var(--pink); font-family: inherit; }
.mapboxgl-popup-tip { border-top-color: var(--pink) !important; }

/* RESULT LIST */
#results { display: flex; flex-direction: column; overflow: hidden; }
#results-header {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--line); font-family: 'Orbitron', sans-serif; font-size: 11px;
  letter-spacing: 0.1em; color: var(--muted);
}
#results-count { color: var(--cyan); }

/* Clear-filters banner — full-width, prominent, only visible with active filters */
#clear-filters {
  display: none;
  width: 100%;
  background: transparent;
  color: #ff5050;
  border: 0;
  border-bottom: 1px solid rgba(255,80,80,0.5);
  padding: 12px 14px;
  font: 700 13px/1 'Orbitron', sans-serif;
  letter-spacing: 0.2em;
  cursor: pointer;
  text-align: center;
  transition: all 0.18s;
  text-shadow: 0 0 10px rgba(255,80,80,0.4);
}
#clear-filters:hover {
  background: rgba(255,80,80,0.18);
  color: #ff8080;
  text-shadow: 0 0 14px rgba(255,80,80,0.7);
}
#clear-filters-summary { color: var(--muted); font-weight: 500; letter-spacing: 0.15em; }
#clear-filters:hover #clear-filters-summary { color: var(--text); }
body.has-active-filter #clear-filters { display: block; }
#realm-pills {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.pill {
  background: transparent; color: var(--pink); border: 1px solid var(--pink);
  padding: 8px 14px;
  font: 700 12px/1 'Orbitron', sans-serif;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.pill:hover { background: rgba(255,119,255,0.15); box-shadow: 0 0 10px rgba(255,119,255,0.4); }
.pill.is-active {
  background: var(--pink); color: var(--bg-1);
  box-shadow: 0 0 14px rgba(255,119,255,0.6);
  text-shadow: none;
}
@media (max-width: 700px) {
  .pill { padding: 6px 10px; font-size: 11px; letter-spacing: 0.1em; }
}

/* Density toggle — shown only when a grid mode is active */
#grid-density-toggle {
  display: flex; gap: 4px; align-items: center;
  padding: 8px 14px; border-bottom: 1px solid var(--line);
  font: 600 10px/1 'Orbitron', sans-serif; letter-spacing: 0.12em;
}
#grid-density-toggle[hidden] { display: none; }
.density-label { color: var(--muted); margin-right: 6px; }
.density-btn {
  background: transparent; color: var(--cyan); border: 1px solid var(--cyan);
  padding: 4px 10px; font: inherit; cursor: pointer;
}
.density-btn:hover { background: rgba(0,255,255,0.15); }
.density-btn.is-active { background: var(--cyan); color: var(--bg-1); }

/* Gallery/Videos grid view — shown when #results-grid is non-empty */
#results-grid {
  display: none;
  grid-template-columns: repeat(var(--grid-cols, 6), 1fr);
  gap: 8px;
  padding: 10px 12px;
  overflow-y: auto;
  flex: 1;
}
#results-grid.is-active { display: grid; }
#results-grid .tile {
  position: relative; aspect-ratio: 1;
  background: #050518; border: 1px solid var(--line);
  cursor: pointer; overflow: hidden;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}
#results-grid .tile:hover {
  border-color: var(--cyan); transform: scale(1.03); z-index: 2;
  box-shadow: 0 0 14px rgba(0,255,255,0.45);
}
#results-grid .tile img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
#results-grid .tile .meta {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(180deg, transparent, rgba(10,10,42,0.92) 60%);
  color: var(--text); padding: 18px 8px 6px;
  font-size: 10px; line-height: 1.3; pointer-events: none;
}
#results-grid .tile .meta strong {
  display: block; font-family: 'Orbitron', sans-serif;
  color: var(--cyan); font-size: 9px; letter-spacing: 0.1em; margin-bottom: 2px;
}
#results-grid .tile .meta .loc {
  color: var(--pink); font-size: 9px; letter-spacing: 0.05em; margin-top: 2px;
}
#results-grid .tile .play-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--cyan); text-shadow: 0 0 10px rgba(0,0,0,0.85);
  pointer-events: none; background: rgba(0,0,0,0.22);
  font-family: 'Orbitron', sans-serif;
}
@media (max-width: 600px) {
  #results-grid { grid-template-columns: repeat(min(var(--grid-cols, 6), 4), 1fr); }
}

#realm-banner {
  padding: 10px 14px;
  background: rgba(255,119,255,0.10);
  border-bottom: 1px solid var(--pink);
  color: var(--text); font-size: 12px; line-height: 1.45;
}
#realm-banner strong {
  color: var(--pink); font-family: 'Orbitron',sans-serif; letter-spacing: 0.1em; font-size: 11px;
  display: inline-block; margin-bottom: 2px;
}

#results-list {
  list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));  /* 2-column rows by default */
}
@media (max-width: 800px) {
  #results-list { grid-template-columns: 1fr; }
}
#results-list li {
  padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer;
  display: flex; flex-direction: row; gap: 12px; align-items: flex-start;
}
/* Add a vertical separator between the two columns to make the split obvious */
#results-list li:nth-child(odd) { border-right: 1px solid var(--line); }
@media (max-width: 800px) {
  #results-list li:nth-child(odd) { border-right: none; }
}
#results-list li:hover, #results-list li.is-active { background: rgba(255,119,255,0.08); }
.r-thumb {
  flex: 0 0 80px;
  width: 80px; height: 80px;
  background: #050518;
  border: 1px solid var(--line);
  object-fit: cover;
  display: block;
}
.r-thumb-wrap {
  flex: 0 0 80px; width: 80px; height: 80px;
  position: relative;
}
.r-thumb-wrap .play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--cyan); text-shadow: 0 0 8px rgba(0,0,0,0.85);
  background: rgba(0,0,0,0.22); pointer-events: none;
}
.r-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.r-title {
  color: var(--text); font-weight: 500; font-size: 13px;
  line-height: 1.35; word-break: break-word; overflow-wrap: break-word;
}
.r-snippet { color: var(--muted); font-size: 12px; line-height: 1.45; }
.r-snippet mark { background: rgba(255,119,255,0.35); color: var(--text); padding: 0 2px; }
.r-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.r-pill {
  display: inline-block;
  padding: 2px 8px;
  font: 600 9px/1.4 'Orbitron', sans-serif;
  letter-spacing: 0.1em;
  border-radius: 2px;
  white-space: nowrap;
}
.r-pill.agency  { background: rgba(0,255,255,0.15);   color: var(--cyan); border: 1px solid rgba(0,255,255,0.4); }
.r-pill.type    { background: rgba(255,119,255,0.15); color: var(--pink); border: 1px solid rgba(255,119,255,0.4); }
.r-pill.loc     { background: rgba(244,244,255,0.06); color: var(--muted); border: 1px solid var(--line); }
.r-pill.date    { background: rgba(244,244,255,0.06); color: var(--muted); border: 1px solid var(--line); }

#results-pager {
  padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: center;
}
#results-pager button {
  background: transparent; color: var(--cyan); border: 1px solid var(--cyan);
  padding: 4px 10px; font: 600 11px/1 'Orbitron', sans-serif; cursor: pointer; letter-spacing: 0.1em;
}
#results-pager button:disabled { opacity: 0.3; cursor: not-allowed; }
#results-pager button.is-current { background: var(--cyan); color: var(--bg-1); }

/* IMAGE MODAL (embedded mode) */
#image-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,15,0.92); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; cursor: zoom-out;
}
#image-modal[hidden] { display: none; }
.im-shell {
  position: relative; max-width: min(1100px, 96vw); max-height: 94vh;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: default;
}
.im-image {
  max-width: 100%; max-height: 82vh;
  object-fit: contain; border: 1px solid var(--cyan);
  box-shadow: 0 0 40px rgba(0,255,255,0.25);
  background: #050518;
}
.im-caption {
  color: var(--text); font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.1em; text-align: center; padding: 0 8px;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.im-caption-row {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  align-items: baseline; font-size: 11px;
}
.im-caption-agency { color: var(--cyan); font-weight: 700; }
.im-caption-title  { color: var(--text); font-weight: 400; max-width: 70ch; overflow: hidden; text-overflow: ellipsis; }
.im-caption-page   { color: var(--pink); font-weight: 700; }
.im-caption-actions {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
}
.im-caption-link {
  font: 600 10px/1 'Orbitron', sans-serif; letter-spacing: 0.1em;
  padding: 6px 12px; text-decoration: none;
  border: 1px solid var(--cyan); color: var(--cyan);
  transition: all 0.18s;
}
.im-caption-link:hover { background: var(--cyan); color: var(--bg-1); }
.im-caption-link.is-primary {
  background: var(--cyan); color: var(--bg-1);
  box-shadow: 0 0 12px rgba(0,255,255,0.6);
}
.im-caption-link.is-primary:hover {
  background: var(--pink); color: var(--bg-1); border-color: var(--pink);
  box-shadow: 0 0 14px rgba(255,119,255,0.7);
}

/* Pulse the OCR page heading when it's the jump-to target */
.dualpane-text .ocr-page.jump-target {
  background: rgba(0,255,255,0.18);
  border-color: var(--cyan);
  text-shadow: 0 0 14px rgba(0,255,255,0.7);
  animation: jumpPulse 2.4s ease;
}
@keyframes jumpPulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,255,255,0.6); }
  50%  { box-shadow: 0 0 0 8px rgba(0,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,255,255,0); }
}
.im-close {
  position: absolute; top: -28px; right: 0;
  background: transparent; color: var(--cyan); border: none;
  font-size: 28px; cursor: pointer; line-height: 1;
}

/* VIDEO MODAL (DVIDS mode) */
#video-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,15,0.94); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; cursor: zoom-out;
}
#video-modal[hidden] { display: none; }
.vm-shell {
  position: relative; width: min(960px, 96vw);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: default;
}
.vm-video {
  width: 100%; max-height: 80vh;
  border: 1px solid var(--cyan);
  box-shadow: 0 0 40px rgba(0,255,255,0.25);
  background: #050518;
}
.vm-caption {
  color: var(--muted); font: 500 11px/1 'Orbitron', sans-serif;
  letter-spacing: 0.12em; text-align: center; padding: 0 8px;
}
.vm-close {
  position: absolute; top: -28px; right: 0;
  background: transparent; color: var(--cyan); border: none;
  font-size: 28px; cursor: pointer; line-height: 1;
}

/* MODAL */
#modal { position: fixed; inset: 0; background: rgba(0,0,20,0.85); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 100; }
#modal[hidden] { display: none; }
.modal-shell { width: min(900px, 92vw); max-height: 88vh; background: var(--panel); border: 1px solid var(--pink); padding: 24px; overflow-y: auto; position: relative; box-shadow: 0 0 40px rgba(255,119,255,0.4); }
#modal-close { position: absolute; top: 8px; right: 12px; background: transparent; color: var(--cyan); border: none; font-size: 28px; cursor: pointer; line-height: 1; }
.modal-title { font-family: 'Orbitron', sans-serif; color: var(--cyan); font-size: 22px; letter-spacing: 0.1em; text-shadow: 0 0 10px rgba(0,255,255,0.4); margin: 0 0 6px; }
.modal-meta { display: flex; gap: 14px; flex-wrap: wrap; font: 600 11px/1 'Orbitron', sans-serif; color: var(--pink); letter-spacing: 0.1em; margin-bottom: 16px; }
.modal-redacted { color: #ff5050; font-style: italic; font-size: 13px; margin: 8px 0; }
.modal-desc { line-height: 1.6; color: var(--text); white-space: pre-wrap; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions a, .modal-actions button {
  background: transparent; color: var(--cyan); border: 1px solid var(--cyan);
  padding: 8px 14px; font: 600 11px/1 'Orbitron', sans-serif; letter-spacing: 0.1em;
  text-decoration: none; cursor: pointer;
}
.modal-actions a:hover { background: var(--cyan); color: var(--bg-1); }
.modal-media { margin: 16px 0; }
.modal-media img, .modal-media video { width: 100%; max-height: 60vh; object-fit: contain; background: #050518; }
.modal-media iframe { width: 100%; height: 60vh; border: 1px solid var(--cyan); background: #050518; }

/* Wide modal for dual-pane PDFs */
#modal.is-wide .modal-shell { width: min(1400px, 96vw); max-height: 92vh; }

/* Dual-pane PDF + OCR text view */
.dualpane { margin: 16px 0; border: 1px solid var(--pink); background: rgba(0,0,40,0.5); }
.dualpane-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: rgba(0,0,40,0.7);
}
.dualpane-meta {
  font: 600 10px/1 'Orbitron', sans-serif; color: var(--cyan);
  letter-spacing: 0.1em; text-shadow: 0 0 6px rgba(0,255,255,0.3);
  white-space: nowrap;
}
.dualpane-search-input {
  flex: 1; min-width: 200px; max-width: 480px;
  background: rgba(0,0,40,0.7); color: var(--cyan);
  border: 1px solid var(--cyan); padding: 6px 10px;
  font: 500 11px/1 'IBM Plex Mono', monospace;
  letter-spacing: 0.04em;
  outline: none; margin: 0 12px;
}
.dualpane-search-input::placeholder { color: rgba(0,255,255,0.45); }
.dualpane-search-input:focus { box-shadow: 0 0 12px rgba(0,255,255,0.5); }
.dualpane-toolbar { gap: 8px; flex-wrap: wrap; }
.dualpane-toggles { display: flex; gap: 4px; }
.dualpane-toggles button {
  background: transparent; color: var(--pink); border: 1px solid var(--pink);
  padding: 4px 10px; font: 600 10px/1 'Orbitron', sans-serif;
  letter-spacing: 0.1em; cursor: pointer; transition: all 0.18s;
}
.dualpane-toggles button:hover { background: rgba(255,119,255,0.15); }
.dualpane-toggles button.is-active { background: var(--pink); color: var(--bg-1); }

.dualpane-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  height: min(70vh, 720px);
}
.dualpane[data-view="text"] .dualpane-body { grid-template-columns: 1fr; }
.dualpane[data-view="text"] .dualpane-pdf { display: none; }
.dualpane[data-view="pdf"]  .dualpane-body { grid-template-columns: 1fr; }
.dualpane[data-view="pdf"]  .dualpane-text { display: none; }

.dualpane-text {
  overflow-y: auto; padding: 16px 18px;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 12px; line-height: 1.55; color: var(--text);
  background: #050518;
  white-space: pre-wrap; word-wrap: break-word;
  border-right: 1px solid var(--line);
}
.dualpane[data-view="text"] .dualpane-text,
.dualpane[data-view="pdf"]  .dualpane-text { border-right: none; }
.dualpane-text .ocr-page {
  font-family: 'Orbitron', sans-serif; font-weight: 700;
  color: var(--pink); letter-spacing: 0.2em;
  font-size: 11px; margin: 18px 0 10px;
  border-bottom: 1px dashed rgba(255,119,255,0.4); padding-bottom: 6px;
  text-shadow: 0 0 8px rgba(255,119,255,0.4);
}

/* Reader page search-term highlights */
.dualpane-text mark.search-hit {
  background: rgba(255,119,255,0.4);
  color: var(--text);
  padding: 1px 3px;
  border-radius: 2px;
  scroll-margin-top: 80px;
  scroll-margin-bottom: 80px;
}
.dualpane-text mark.search-hit.first {
  background: var(--cyan);
  color: var(--bg-1);
  outline: 2px solid var(--cyan);
  box-shadow: 0 0 14px rgba(0,255,255,0.7);
}
.dualpane-search-badge {
  margin-left: 8px;
  color: var(--pink);
  font-weight: 700;
}

/* SITE FOOTER */
.site-footer {
  margin-top: 32px;
  padding: 24px 20px 0;
  border-top: 1px solid var(--pink);
  background: rgba(0,0,30,0.6);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
body.show-map .site-footer { display: none; }   /* fixed-viewport map mode hides it */
.footer-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}
.footer-col strong {
  display: block;
  font: 700 11px/1 'Orbitron', sans-serif;
  letter-spacing: 0.18em;
  color: var(--cyan);
  margin-bottom: 8px;
  text-shadow: 0 0 6px rgba(0,255,255,0.3);
}
.footer-col p { margin: 0; }
.footer-col a { color: var(--pink); text-decoration: none; border-bottom: 1px dashed var(--pink); }
.footer-col a:hover { color: var(--cyan); border-color: var(--cyan); }

.footer-bar {
  margin-top: 28px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  font: 500 10px/1.4 'Orbitron', sans-serif;
  letter-spacing: 0.15em; color: var(--muted);
  max-width: 1200px;
  margin-left: auto; margin-right: auto;
}
.footer-bar a { color: var(--cyan); text-decoration: none; }
.footer-bar a:hover { text-shadow: 0 0 8px rgba(0,255,255,0.5); }

/* Per-record word cloud (in reader page) */
.record-wordcloud-shell {
  border: 1px solid var(--line);
  background: rgba(0,0,40,0.4);
  padding: 12px 16px;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.record-wordcloud-label {
  font: 600 10px/1 'Orbitron', sans-serif;
  letter-spacing: 0.18em;
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(0,255,255,0.35);
}
.record-wordcloud {
  display: flex; flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  line-height: 1.5;
  font-family: 'Orbitron', sans-serif;
}
.record-wordcloud a {
  text-decoration: none;
  transition: text-shadow 0.18s, transform 0.15s;
  white-space: nowrap;
}
.record-wordcloud a:hover {
  text-shadow: 0 0 10px currentColor;
  transform: translateY(-1px);
}

/* AI Synopsis block (reader page) */
.reader-synopsis {
  border: 1px solid var(--cyan);
  background: rgba(0,255,255,0.06);
  padding: 16px 18px;
  margin: 0 0 16px;
  box-shadow: 0 0 12px rgba(0,255,255,0.15) inset;
}
.reader-synopsis-label {
  display: block;
  font: 700 10px/1 'Orbitron', sans-serif;
  letter-spacing: 0.2em;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0,255,255,0.4);
  margin-bottom: 12px;
}
.reader-synopsis p {
  margin: 0 0 10px;
  line-height: 1.6;
  color: var(--text);
}
.reader-synopsis p:last-child { margin-bottom: 0; }

.dualpane-text .ocr-page:first-child { margin-top: 0; }

.dualpane-pdf { background: #050518; }
.dualpane-pdf iframe {
  width: 100%; height: 100%; border: 0; background: #050518;
}

@media (max-width: 900px) {
  .dualpane-body { grid-template-columns: 1fr; height: auto; }
  .dualpane[data-view="split"] .dualpane-text { border-right: none; border-bottom: 1px solid var(--line); height: 50vh; }
  .dualpane[data-view="split"] .dualpane-pdf  { height: 50vh; }
}

/* ── VIEW TOGGLE (atlas topbar) ─────────────────────────────────────────── */
.view-toggle { display: flex; gap: 4px; margin-left: 18px; }
.view-tab {
  font: 600 10px/1 'Orbitron', sans-serif; letter-spacing: 0.18em;
  padding: 6px 12px; border: 1px solid var(--pink); color: var(--pink);
  text-decoration: none; transition: all 0.18s; cursor: default;
  user-select: none;
}
a.view-tab { cursor: pointer; }
a.view-tab:hover { background: rgba(255,119,255,0.12); }
.view-tab.is-active { background: var(--pink); color: var(--bg-1); }
.view-tab[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }

/* ── READER PAGE ─────────────────────────────────────────────────────────── */
body.reader-page { overflow: hidden; }
.reader { display: flex; flex-direction: column; height: 100vh; }

.reader-topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  border-bottom: 1px solid var(--pink); background: rgba(0,0,40,0.6);
  backdrop-filter: blur(6px); flex-shrink: 0;
}
.reader-topbar .brand { font-size: 14px; }

.reader-current-title {
  flex: 1; min-width: 0; color: var(--text); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.reader-nav { display: flex; gap: 4px; }
.reader-nav a {
  font: 600 10px/1 'Orbitron', sans-serif; letter-spacing: 0.12em;
  color: var(--pink); border: 1px solid var(--pink); padding: 6px 10px;
  text-decoration: none; transition: background 0.18s;
}
.reader-nav a:hover { background: rgba(255,119,255,0.15); }
.reader-nav a[aria-disabled="true"] { opacity: 0.3; pointer-events: none; }

.reader-meta-strip {
  padding: 10px 20px; border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: rgba(0,0,40,0.45); flex-shrink: 0;
}
.reader-meta-strip .r-pill { font-size: 10px; }

.reader-body {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  max-width: 1600px; margin: 0 auto; width: 100%;
}

.reader-title {
  font-family: 'Orbitron', sans-serif; color: var(--cyan); font-size: 20px;
  letter-spacing: 0.08em; text-shadow: 0 0 10px rgba(0,255,255,0.35);
  margin: 0 0 12px; line-height: 1.35;
}

.reader-redacted {
  color: #ff5050; font-style: italic; font-size: 13px; margin: 8px 0 14px;
}

.reader-desc {
  line-height: 1.6; color: var(--text); white-space: pre-wrap;
  margin: 0 0 16px; font-size: 14px;
}

.reader-body .dualpane { margin-top: 0; }
.reader-body .dualpane-body { height: calc(100vh - 230px); }

.reader-image-full {
  display: flex; align-items: center; justify-content: center;
  height: calc(100vh - 260px); min-height: 300px; background: #050518;
  border: 1px solid var(--line); margin-bottom: 16px;
}
.reader-image-full img { max-width: 100%; max-height: 100%; object-fit: contain; }

.reader-video-full { margin-bottom: 16px; }
.reader-video-full video {
  width: 100%; max-height: calc(100vh - 260px);
  background: #050518; border: 1px solid var(--line); display: block;
}

.reader-actions {
  display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; padding-bottom: 20px;
}
.reader-action-btn {
  background: transparent; color: var(--cyan); border: 1px solid var(--cyan);
  padding: 8px 14px; font: 600 11px/1 'Orbitron', sans-serif; letter-spacing: 0.1em;
  text-decoration: none; cursor: pointer; transition: background 0.18s;
  display: inline-block;
}
.reader-action-btn:hover { background: var(--cyan); color: var(--bg-1); }

@media (max-width: 768px) {
  .reader-topbar { gap: 10px; padding: 10px 14px; }
  .reader-topbar .brand { display: none; } /* hide brand on small — saves space */
  .reader-current-title { font-size: 11px; }
  .reader-body { padding: 12px 14px; }
  .reader-title { font-size: 16px; }
  .reader-body .dualpane-body { height: auto; }
  .reader-image-full { height: 60vw; min-height: 240px; }
}
