/* Astrum Arcana — shared layout and component system */
:root {
  --font-display: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --content-width: 1480px;
  --reading-width: 760px;
  --header-height: 76px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --ease: 180ms ease;
  --gold: #c9a84c;
  --cyan: #4ec9b0;
  --purple: #9b7fbf;
  --domain-gnostic: #c9a84c;
  --domain-ufo: #4ec9b0;
  --domain-astrological: #9b7fbf;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.6 var(--font-body);
  text-rendering: optimizeLegibility;
  transition: background-color var(--ease), color var(--ease);
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  background-image:
    radial-gradient(circle at 14% 18%, var(--ambient-gold), transparent 27%),
    radial-gradient(circle at 87% 12%, var(--ambient-cyan), transparent 24%),
    radial-gradient(circle at 72% 78%, var(--ambient-purple), transparent 28%),
    radial-gradient(circle at 20% 30%, var(--star) 0 0.7px, transparent 0.8px),
    radial-gradient(circle at 75% 65%, var(--star) 0 0.6px, transparent 0.7px);
  background-position: center, center, center, 0 0, 17px 13px;
  background-size: auto, auto, auto, 47px 47px, 61px 61px;
  content: "";
  pointer-events: none;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button {
  border: 0;
}

input::placeholder {
  color: var(--text-faint);
  opacity: 1;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--link-hover);
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p,
dl,
dd,
figure,
blockquote {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--heading);
  font-family: var(--font-display);
  font-weight: 650;
  line-height: 1.12;
  text-wrap: balance;
}

h1 {
  margin-bottom: 0.55rem;
  font-size: clamp(2.25rem, 4vw, 4.6rem);
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0.7rem;
  font-size: clamp(1.65rem, 2.5vw, 2.6rem);
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.15rem, 1.6vw, 1.45rem);
}

::selection {
  background: var(--selection);
  color: var(--selection-text);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  transform: translateY(-160%);
  transition: transform var(--ease);
}

.skip-link:focus {
  color: var(--bg);
  transform: translateY(0);
}

.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  display: flex;
  min-height: var(--header-height);
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.65rem max(1.25rem, calc((100vw - var(--content-width)) / 2));
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  box-shadow: 0 1px 0 var(--header-highlight) inset;
  backdrop-filter: blur(18px) saturate(130%);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
  color: var(--heading);
  text-decoration: none;
}

.brand:hover {
  color: var(--heading);
}

.brand-mark {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border: 1px solid var(--gold-border);
  border-radius: 50%;
  background: var(--gold-wash);
  box-shadow: 0 0 24px var(--gold-glow);
  color: var(--gold);
  font-size: 1rem;
}

.brand-copy {
  display: grid;
  min-width: 0;
  line-height: 1.08;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.015em;
}

.brand-subtitle {
  max-width: 680px;
  margin-top: 0.25rem;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.35;
}

.header-actions,
.primary-nav,
.tab-list {
  display: flex;
  align-items: center;
}

.header-actions {
  min-width: 0;
  gap: 0.8rem;
}

.primary-nav {
  min-width: 0;
}

.tab-list {
  gap: 0.15rem;
}

.nav-tab {
  position: relative;
  padding: 0.65rem 0.76rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.015em;
  transition: color var(--ease), background var(--ease);
}

.nav-tab::after {
  position: absolute;
  right: 0.8rem;
  bottom: 0.12rem;
  left: 0.8rem;
  height: 1px;
  background: var(--gold);
  content: "";
  opacity: 0;
  transform: scaleX(0.3);
  transition: opacity var(--ease), transform var(--ease);
}

.nav-tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-tab.is-active {
  color: var(--heading);
}

.nav-tab.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.icon-button {
  display: inline-grid;
  width: 2.45rem;
  height: 2.45rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--button-bg);
  color: var(--text-muted);
  transition: border-color var(--ease), background var(--ease), color var(--ease), transform var(--ease);
}

.icon-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}

.icon-button:active {
  transform: scale(0.95);
}

.theme-toggle {
  position: relative;
}

.theme-icon {
  position: absolute;
  width: 1.08rem;
  height: 1.08rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  transition: opacity var(--ease), transform var(--ease);
}

[data-theme="dark"] .theme-icon-sun,
[data-theme="light"] .theme-icon-moon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

[data-theme="dark"] .theme-icon-moon,
[data-theme="light"] .theme-icon-sun {
  opacity: 0;
  transform: rotate(30deg) scale(0.55);
}

main {
  width: min(100%, var(--content-width));
  min-height: calc(100vh - var(--header-height));
  margin: 0 auto;
  padding: clamp(2.25rem, 5vw, 5.5rem) clamp(1rem, 3vw, 2rem) 5rem;
}

.app-view[hidden] {
  display: none;
}

.app-view.is-active {
  animation: reveal-view 320ms ease both;
}

@keyframes reveal-view {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.app-status {
  display: flex;
  width: max-content;
  max-width: 100%;
  align-items: center;
  gap: 0.6rem;
  margin: -1rem 0 1.5rem;
  padding: 0.42rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.app-status.is-ready {
  display: none;
}

.app-status.is-error {
  border-color: var(--danger-border);
  color: var(--danger);
}

.loading-orbit {
  display: inline-block;
  width: 0.86rem;
  height: 0.86rem;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: orbit 700ms linear infinite;
}

@keyframes orbit { to { transform: rotate(360deg); } }

.view-heading {
  display: flex;
  max-width: 1120px;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: clamp(1.6rem, 3vw, 2.8rem);
}

.view-heading-wide {
  max-width: none;
}

.eyebrow {
  margin-bottom: 0.72rem;
  color: var(--gold-text);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.view-intro {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: clamp(0.98rem, 1.5vw, 1.13rem);
}

.atlas-tagline {
  max-width: 900px;
  margin: 0.85rem 0 0;
  color: var(--text-faint);
  font-size: 0.88rem;
  line-height: 1.6;
}

.view-stats {
  display: flex;
  flex: 0 0 auto;
  gap: clamp(1.15rem, 3vw, 2.8rem);
  margin-bottom: 0.25rem;
}

.view-stats div {
  display: grid;
}

.view-stats dt {
  color: var(--heading);
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1;
}

.view-stats dd {
  margin: 0.35rem 0 0;
  color: var(--text-faint);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.panel-surface {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--panel-shadow), 0 1px 0 var(--surface-highlight) inset;
}

.graph-shell {
  overflow: hidden;
}

.graph-toolbar,
.question-controls,
.reference-controls,
.timeline-controls {
  display: flex;
  min-height: 66px;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
}

.graph-toolbar {
  border-bottom: 1px solid var(--border);
}

.search-field {
  display: flex;
  min-width: min(360px, 100%);
  flex: 1 1 330px;
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.8rem;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  background: var(--input-bg);
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

.search-field:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-wash);
}

.search-field svg {
  width: 1rem;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--text-faint);
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search-field input {
  width: 100%;
  min-width: 0;
  padding: 0.63rem 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 0.84rem;
}

.domain-filters,
.type-filters {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0;
  border: 0;
  margin: 0;
}

.domain-filters legend,
.type-filters legend {
  float: left;
  margin-right: 0.45rem;
  color: var(--text-faint);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.filter-chip {
  position: relative;
  display: inline-flex;
}

.filter-chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.filter-chip span {
  padding: 0.4rem 0.64rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--button-bg);
  color: var(--text-faint);
  font-size: 0.69rem;
  font-weight: 700;
  transition: border-color var(--ease), background var(--ease), color var(--ease), opacity var(--ease);
}

.filter-chip input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.filter-chip input:checked + span {
  background: var(--chip-active-bg);
}

.filter-chip.domain-gnostic input:checked + span { border-color: var(--gnostic-border); color: var(--gnostic-text); }
.filter-chip.domain-ufo input:checked + span { border-color: var(--ufo-border); color: var(--ufo-text); }
.filter-chip.domain-astrological input:checked + span { border-color: var(--astrological-border); color: var(--astrological-text); }

.type-filters .filter-chip span {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.type-filters .filter-chip span::before {
  width: 0.48rem;
  height: 0.48rem;
  flex: 0 0 auto;
  border: 1px solid currentColor;
  background: currentColor;
  content: "";
  opacity: 0.72;
}

.type-filters .filter-chip.type-being span::before { border-radius: 50%; }
.type-filters .filter-chip.type-concept span::before { transform: rotate(45deg) scale(0.78); }
.type-filters .filter-chip.type-structure span::before { clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.type-filters .filter-chip.type-person span::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.type-filters .filter-chip input:checked + span { border-color: var(--border-strong); color: var(--text); }

.text-button {
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.text-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.result-count {
  flex: 0 0 auto;
  color: var(--text-faint);
  font-size: 0.72rem;
  white-space: nowrap;
}

.graph-stage {
  position: relative;
  height: clamp(510px, 65vh, 770px);
  overflow: hidden;
  background:
    linear-gradient(var(--graph-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--graph-grid) 1px, transparent 1px),
    radial-gradient(circle at center, var(--graph-center), transparent 62%);
  background-size: 44px 44px, 44px 44px, auto;
}

.graph-stage svg {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.graph-stage .graph-link {
  stroke: var(--graph-link);
  stroke-linecap: round;
  transition: opacity var(--ease), stroke var(--ease);
}

.graph-stage .graph-node {
  cursor: pointer;
  outline: none;
}

.graph-stage .graph-node .node-hit-area {
  fill: transparent;
  stroke: none;
}

.graph-stage .graph-node .node-halo {
  fill: none;
  stroke: var(--node-halo);
  stroke-width: 5px;
  opacity: 0;
  transition: opacity var(--ease);
}

.graph-stage .graph-node .node-core {
  stroke: var(--node-stroke);
  stroke-width: 1.5px;
  filter: drop-shadow(0 3px 8px var(--node-shadow));
  transition: stroke-width var(--ease), opacity var(--ease);
}

.graph-stage .graph-node.node-type-concept .node-core {
  fill-opacity: 0.84;
}

.graph-stage .graph-node.node-type-structure .node-core {
  stroke-width: 3px;
}

.graph-stage .graph-node.node-type-person .node-core {
  fill-opacity: 0.9;
  stroke-width: 2px;
}

.graph-stage .graph-node:hover .node-halo,
.graph-stage .graph-node:focus .node-halo,
.graph-stage .graph-node.is-connected .node-halo {
  opacity: 0.32;
}

.graph-stage .graph-node:focus .node-core {
  stroke: var(--focus);
  stroke-width: 3px;
}

.graph-stage .node-label {
  fill: var(--graph-label);
  font: 600 11px var(--font-body);
  paint-order: stroke;
  pointer-events: none;
  stroke: var(--graph-label-stroke);
  stroke-linejoin: round;
  stroke-width: 3px;
}

.graph-stage .is-dimmed {
  opacity: 0.12;
}

.view-placeholder {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 2rem;
  color: var(--text-faint);
  font-size: 0.82rem;
  text-align: center;
}

.graph-stage > .view-placeholder {
  position: absolute;
  z-index: 2;
  inset: 0;
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  padding: 2rem;
  color: var(--text-muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--heading);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.graph-footer {
  display: flex;
  min-height: 52px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
}

.domain-legend,
.type-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  padding: 0;
  margin: 0;
  color: var(--text-faint);
  font-size: 0.67rem;
  list-style: none;
}

.domain-legend li,
.type-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--swatch-ring);
}

.domain-gnostic-bg { background: var(--domain-gnostic); }
.domain-ufo-bg { background: var(--domain-ufo); }
.domain-astrological-bg { background: var(--domain-astrological); }
.domain-multiple-bg { background: linear-gradient(135deg, var(--domain-gnostic), var(--domain-ufo) 50%, var(--domain-astrological)); }

.type-legend {
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.legend-shape {
  display: inline-block;
  width: 0.58rem;
  height: 0.58rem;
  border: 1px solid var(--node-stroke);
  background: var(--text-faint);
  box-shadow: 0 0 0 2px var(--swatch-ring);
}

.legend-shape.type-being { border-radius: 50%; }
.legend-shape.type-concept { transform: rotate(45deg) scale(0.78); }
.legend-shape.type-structure {
  width: 0.66rem;
  height: 0.66rem;
  border-width: 2px;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.legend-shape.type-person { clip-path: polygon(50% 0, 100% 100%, 0 100%); }

.graph-hint {
  margin: 0 0 0 auto;
  color: var(--text-faint);
  font-size: 0.67rem;
}

.graph-tooltip {
  position: fixed;
  z-index: 250;
  max-width: 260px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--tooltip-bg);
  box-shadow: var(--floating-shadow);
  color: var(--text-muted);
  font-size: 0.7rem;
  line-height: 1.4;
  pointer-events: none;
}

.graph-tooltip strong {
  display: block;
  color: var(--heading);
  font-size: 0.78rem;
}

/* Timeline */
.timeline-controls {
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.zoom-control {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: auto;
  color: var(--text-faint);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.zoom-control input {
  width: 105px;
  accent-color: var(--gold);
}

.scroll-buttons {
  display: flex;
  gap: 0.35rem;
}

.scroll-buttons .icon-button {
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1rem;
}

.timeline-viewport {
  position: relative;
  height: min(610px, 69vh);
  min-height: 500px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
}

.timeline-track {
  --timeline-step: 235px;
  position: relative;
  display: grid;
  width: max-content;
  height: 100%;
  min-width: 100%;
  grid-auto-columns: var(--timeline-step);
  grid-auto-flow: column;
  align-items: stretch;
  padding: 2.6rem calc(var(--timeline-step) / 2);
}

.timeline-track::before {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: calc(var(--timeline-step) / 2);
  left: calc(var(--timeline-step) / 2);
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--cyan) 55%, var(--purple));
  box-shadow: 0 0 16px var(--timeline-glow);
  content: "";
  pointer-events: none;
}

.timeline-era-range {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed var(--border);
  background: linear-gradient(90deg, var(--era-wash), transparent 70%);
  pointer-events: none;
}

.timeline-era-label {
  position: sticky;
  top: 0.85rem;
  display: inline-block;
  margin: 0.75rem;
  color: var(--text-faint);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.timeline-event {
  position: relative;
  z-index: 2;
  display: flex;
  height: 50%;
  justify-content: center;
  scroll-snap-align: center;
}

.timeline-event.is-above {
  align-items: flex-end;
  padding-bottom: 2.25rem;
}

.timeline-event.is-below {
  align-self: end;
  align-items: flex-start;
  padding-top: 2.25rem;
}

.timeline-event-marker {
  position: absolute;
  left: 50%;
  width: 0.72rem;
  height: 0.72rem;
  border: 2px solid var(--surface-solid);
  border-radius: 50%;
  background: var(--event-color, var(--gold));
  box-shadow: 0 0 0 3px var(--event-ring), 0 0 18px var(--event-color, var(--gold));
  transform: translate(-50%, 50%);
}

.timeline-event.is-above .timeline-event-marker { bottom: 0; }
.timeline-event.is-below .timeline-event-marker { top: 0; transform: translate(-50%, -50%); }

.timeline-event-card {
  width: calc(var(--timeline-step) - 28px);
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  box-shadow: 0 10px 32px var(--card-shadow);
  color: inherit;
  text-align: left;
  transition: border-color var(--ease), background var(--ease), transform var(--ease);
}

.timeline-event-card:hover {
  border-color: var(--event-color, var(--gold));
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.timeline-date {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--event-color, var(--gold));
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.timeline-name {
  display: block;
  color: var(--heading);
  font-family: var(--font-display);
  font-size: 1.04rem;
  font-weight: 600;
  line-height: 1.2;
}

.timeline-summary {
  display: -webkit-box;
  margin-top: 0.45rem;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 0.69rem;
  font-weight: 400;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.mini-domains {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  margin-top: 0.65rem;
}

.mini-domain {
  width: 0.34rem;
  height: 0.34rem;
  border-radius: 50%;
  background: var(--domain-color);
}

/* Three-domain comparison */
.comparison-container {
  display: grid;
  gap: 1rem;
}

.comparison-domain-header,
.correlation-domains {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.comparison-domain-header {
  position: sticky;
  z-index: 5;
  top: calc(var(--header-height) + 0.5rem);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--header-bg);
  box-shadow: var(--small-shadow);
  backdrop-filter: blur(14px);
}

.comparison-domain-header div {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.78rem 1rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.comparison-domain-header div + div {
  border-left: 1px solid var(--border);
}

.domain-symbol {
  display: grid;
  width: 1.35rem;
  height: 1.35rem;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 0.72rem;
}

.gnostic-color { color: var(--gnostic-text) !important; }
.ufo-color { color: var(--ufo-text) !important; }
.astrological-color { color: var(--astrological-text) !important; }

.correlation-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--panel-shadow);
}

.correlation-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.correlation-index {
  margin: 0;
  color: var(--text-faint);
  font: 700 0.65rem/1 var(--font-mono);
  letter-spacing: 0.08em;
}

.correlation-title {
  flex: 1;
  margin: 0;
  font-size: 1.25rem;
}

.correlation-open {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.correlation-open:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.correlation-cell {
  min-height: 145px;
  padding: clamp(1rem, 2vw, 1.45rem);
}

.correlation-cell + .correlation-cell {
  border-left: 1px solid var(--border);
}

.correlation-cell p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.correlation-cell-label {
  display: none;
}

.correlation-synthesis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border);
  background: var(--subtle-surface);
}

.synthesis-item {
  padding: 0.9rem 1.2rem;
}

.synthesis-item + .synthesis-item {
  border-left: 1px solid var(--border);
}

.synthesis-item span {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--text-faint);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.synthesis-item p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.76rem;
}

/* Existential questions */
.question-controls {
  position: sticky;
  z-index: 7;
  top: calc(var(--header-height) + 0.5rem);
  flex-wrap: wrap;
  margin-bottom: 1rem;
  backdrop-filter: blur(16px);
}

.question-list {
  display: grid;
  gap: 0.8rem;
}

.question-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--panel-shadow);
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.question-card:hover {
  border-color: var(--border-strong);
}

.question-card.is-open {
  border-color: var(--border-strong);
  box-shadow: var(--panel-shadow), 0 0 0 1px var(--surface-highlight) inset;
}

.question-card-toggle {
  display: grid;
  width: 100%;
  grid-template-columns: 2.3rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 1.05rem 1.2rem;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background var(--ease);
}

.question-card-heading,
.question-answer-heading {
  margin: 0;
  font: inherit;
  letter-spacing: normal;
  line-height: inherit;
}

.question-card-toggle:focus-visible,
.question-answer-toggle:focus-visible {
  outline-offset: -3px;
}

.question-card-toggle:hover {
  background: var(--surface-hover);
}

.question-number {
  display: grid;
  width: 2.3rem;
  height: 2.3rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-faint);
  font: 650 0.69rem/1 var(--font-mono);
  transition: border-color var(--ease), color var(--ease), background var(--ease);
}

.question-card.is-open .question-number {
  border-color: var(--gold-border);
  background: var(--gold-wash);
  color: var(--gold-text);
}

.question-header-copy {
  display: grid;
  min-width: 0;
  justify-items: start;
  gap: 0.38rem;
}

.question-category {
  display: inline-flex;
  padding: 0.23rem 0.48rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--button-bg);
  color: var(--text-faint);
  font-size: 0.58rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  line-height: 1.2;
  text-transform: uppercase;
}

.question-category-creation,
.question-category-purpose { border-color: var(--gold-border); color: var(--gold-text); }
.question-category-consciousness,
.question-category-nature_of_reality { border-color: var(--astrological-border); color: var(--astrological-text); }
.question-category-liberation,
.question-category-afterlife { border-color: var(--ufo-border); color: var(--ufo-text); }
.question-category-deception,
.question-category-cosmic_war { border-color: var(--danger-border); color: var(--danger); }

.question-title {
  color: var(--heading);
  font-family: var(--font-display);
  font-size: clamp(1.02rem, 1.6vw, 1.28rem);
  font-weight: 650;
  line-height: 1.3;
  text-wrap: balance;
}

.question-card-action,
.question-answer-action {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.question-chevron {
  display: grid;
  width: 1.75rem;
  height: 1.75rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--button-bg);
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
}

.question-card-reveal,
.question-answer-reveal {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 260ms ease;
}

.question-card-reveal-inner,
.question-answer-reveal-inner {
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
  transition: visibility 0s linear 260ms;
}

.question-card.is-open > .question-card-reveal,
.question-answer.is-open > .question-answer-reveal {
  grid-template-rows: 1fr;
}

.question-card.is-open > .question-card-reveal > .question-card-reveal-inner,
.question-answer.is-open > .question-answer-reveal > .question-answer-reveal-inner {
  visibility: visible;
  transition-delay: 0s;
}

.question-answers {
  display: grid;
  grid-template-columns: 1fr;
  border-top: 1px solid var(--border);
}

.question-answer {
  min-width: 0;
  border-bottom: 1px solid var(--border);
}

.question-answer-toggle {
  display: flex;
  width: 100%;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.82rem 1rem;
  background: var(--subtle-surface);
  color: var(--text);
  text-align: left;
  transition: background var(--ease);
}

.question-answer-toggle:hover,
.question-answer.is-open .question-answer-toggle {
  background: var(--surface-hover);
}

.question-answer-identity {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--heading);
  font-size: 0.77rem;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.question-answer-symbol {
  display: grid;
  width: 1.55rem;
  height: 1.55rem;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 0.72rem;
}

.question-answer-gnostic .question-answer-symbol { color: var(--gnostic-text); }
.question-answer-ufo .question-answer-symbol { color: var(--ufo-text); }
.question-answer-astrological .question-answer-symbol { color: var(--astrological-text); }
.question-answer-composite .question-answer-symbol { color: var(--gold-text); }

.question-answer-copy {
  padding: 1.05rem 1.15rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.86rem;
  line-height: 1.72;
}

.question-answer-copy p,
.question-answer-copy li {
  max-width: 920px;
}

.question-inline-source {
  display: inline-flex;
  min-width: 1.55rem;
  min-height: 1.55rem;
  align-items: center;
  justify-content: center;
  padding: 0.06rem 0.3rem;
  border: 1px solid var(--gold-border);
  border-radius: 999px;
  background: var(--gold-wash);
  color: var(--gold-text);
  font: 700 0.68rem/1 var(--font-mono);
  text-decoration: none;
  vertical-align: 0.08em;
}

.question-inline-source:hover {
  background: var(--chip-active-bg);
  color: var(--gold-text);
}

.question-synthesis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--subtle-surface);
}

.question-synthesis > div {
  padding: 1rem 1.2rem;
}

.question-synthesis > div + div {
  border-left: 1px solid var(--border);
}

.question-synthesis span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--gold-text);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.question-synthesis p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.question-related,
.question-sources {
  padding: 1rem 1.2rem;
  border-top: 1px solid var(--border);
}

.question-related h3,
.question-sources h3 {
  margin: 0 0 0.7rem;
  color: var(--text-faint);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.question-related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.question-related-link {
  padding: 0.42rem 0.66rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--button-bg);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}

.question-related-entity::before { content: "✦ "; color: var(--gold-text); }
.question-related-event::before { content: "↝ "; color: var(--ufo-text); }

.question-related-link:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}

.question-sources ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 1.3rem;
  padding-left: 1.4rem;
  margin: 0;
  color: var(--text-faint);
  font: 650 0.68rem/1.5 var(--font-mono);
}

.question-sources li {
  padding-left: 0.15rem;
}

.question-sources a {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 650;
  text-decoration: none;
}

.question-sources a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.question-sources li > span {
  display: block;
  margin-top: 0.08rem;
  color: var(--text-faint);
  font-family: var(--font-body);
  font-weight: 400;
}

/* Reference library */
.reference-total {
  display: grid;
  flex: 0 0 auto;
  text-align: right;
}

.reference-total strong {
  color: var(--heading);
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
}

.reference-total span {
  margin-top: 0.35rem;
  color: var(--text-faint);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.reference-controls {
  position: sticky;
  z-index: 7;
  top: calc(var(--header-height) + 0.5rem);
  flex-wrap: wrap;
  margin-bottom: 1rem;
  backdrop-filter: blur(16px);
}

.select-field {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.select-field select {
  min-width: 160px;
  padding: 0.54rem 2rem 0.54rem 0.7rem;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  font-size: 0.75rem;
  text-transform: none;
}

.reference-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.reference-group-heading {
  grid-column: 1 / -1;
  margin: 0.8rem 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.reference-group-heading:first-child {
  margin-top: 0;
}

.reference-item {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.9rem;
  align-items: start;
  padding: 1.05rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color var(--ease), background var(--ease), transform var(--ease), box-shadow var(--ease);
}

.reference-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.reference-item.is-targeted {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-wash), var(--panel-shadow);
}

.reference-number {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-faint);
  font: 600 0.65rem/1 var(--font-mono);
}

.reference-copy {
  min-width: 0;
}

.reference-type {
  display: inline-block;
  margin-bottom: 0.35rem;
  color: var(--gold-text);
  font-size: 0.6rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.reference-copy h2 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 680;
  line-height: 1.35;
}

.reference-meta {
  margin: 0.35rem 0 0;
  color: var(--text-faint);
  font-size: 0.7rem;
}

.reference-description {
  display: -webkit-box;
  margin: 0.55rem 0 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.76rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.reference-open {
  align-self: center;
  padding: 0.45rem;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  font-size: 1.1rem;
}

.reference-open:hover {
  background: var(--button-bg);
  color: var(--text);
}

/* Shared rich content and citations */
.rich-text {
  color: var(--text-muted);
}

.rich-text > :last-child {
  margin-bottom: 0;
}

.rich-text h2,
.rich-text h3 {
  margin-top: 1.6em;
}

.rich-text p,
.rich-text li {
  max-width: var(--reading-width);
}

.rich-text blockquote {
  padding-left: 1.1rem;
  border-left: 2px solid var(--gold);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.rich-text code {
  padding: 0.12rem 0.3rem;
  border-radius: 4px;
  background: var(--code-bg);
  font: 0.85em var(--font-mono);
}

.citation {
  position: relative;
  top: -0.15em;
  margin-left: 0.12em;
  font-size: 0.65em;
  font-weight: 700;
  line-height: 0;
}

.citation a {
  padding: 0.08em 0.22em;
  border-radius: 3px;
  color: var(--gold-text);
  text-decoration: none;
}

.citation a:hover {
  background: var(--gold-wash);
  color: var(--gold-text);
}

.source-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.source-list li {
  display: grid;
  grid-template-columns: 1.45rem 1fr;
  gap: 0.55rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.76rem;
}

.source-list li:last-child {
  border-bottom: 0;
}

.source-list-index {
  color: var(--gold-text);
  font: 700 0.67rem/1.5 var(--font-mono);
}

.source-list a {
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
}

.source-note {
  display: block;
  margin-top: 0.16rem;
  color: var(--text-faint);
}

.domain-tags,
.alias-list,
.detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.domain-tag,
.alias-tag,
.category-tag,
.type-tag,
.confidence-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--button-bg);
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: capitalize;
}

.type-tag {
  border-color: var(--border-strong);
  color: var(--text);
}

.type-tag::before {
  width: 0.42rem;
  height: 0.42rem;
  flex: 0 0 auto;
  border: 1px solid currentColor;
  background: currentColor;
  content: "";
  opacity: 0.72;
}

.type-tag[data-entity-type="being"]::before { border-radius: 50%; }
.type-tag[data-entity-type="concept"]::before { transform: rotate(45deg) scale(0.78); }
.type-tag[data-entity-type="structure"]::before { clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.type-tag[data-entity-type="person"]::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }

.confidence-tag {
  white-space: nowrap;
  text-transform: none;
}

.confidence-strong {
  border-color: color-mix(in srgb, var(--cyan-text) 42%, transparent);
  background: color-mix(in srgb, var(--cyan-text) 9%, transparent);
  color: var(--cyan-text);
}

.confidence-moderate {
  border-color: var(--gold-border);
  background: var(--gold-wash);
  color: var(--gold-text);
}

.confidence-speculative {
  border-style: dashed;
  color: var(--text-faint);
}

.domain-tag::before {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 50%;
  background: var(--tag-color, var(--text-faint));
  content: "";
}

.domain-tag[data-domain="gnostic"] { --tag-color: var(--domain-gnostic); }
.domain-tag[data-domain="ufo"] { --tag-color: var(--domain-ufo); }
.domain-tag[data-domain="astrological"] { --tag-color: var(--domain-astrological); }

/* Dialogs */
dialog {
  color: var(--text);
}

dialog::backdrop {
  background: var(--dialog-backdrop);
  backdrop-filter: blur(3px);
}

.detail-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: clamp(420px, 50vw, 520px);
  max-width: calc(100vw - 1rem);
  height: 100dvh;
  max-height: none;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border-strong);
  margin: 0;
  overflow: hidden;
  background: var(--dialog-bg);
  box-shadow: var(--dialog-shadow);
}

.detail-panel[open] {
  display: grid;
  grid-template-rows: auto 1fr auto;
  animation: panel-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: translateX(0); }
}

.detail-panel-header {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.15rem 0.65rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.detail-panel-header .eyebrow {
  margin: 0;
}

.dialog-close {
  font-size: 1.45rem;
  font-weight: 300;
  line-height: 1;
}

.detail-panel-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.5rem clamp(1.25rem, 5vw, 2.25rem) 2.5rem;
}

.detail-panel-footer {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--dialog-footer);
}

.detail-title {
  margin-bottom: 0.65rem;
  font-size: clamp(2rem, 6vw, 3.25rem);
}

.detail-lede {
  margin: 1.3rem 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.12rem;
  line-height: 1.55;
}

.detail-section {
  padding-top: 1.3rem;
  border-top: 1px solid var(--border);
  margin-top: 1.3rem;
}

.detail-section h3 {
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.relationship-list,
.mapping-list {
  display: grid;
  gap: 0.45rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.relationship-list li,
.mapping-list li {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--subtle-surface);
  color: var(--text-muted);
  font-size: 0.78rem;
}

.relationship-list strong,
.mapping-list strong {
  color: var(--text);
  font-weight: 650;
}

.mapping-label {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--text-faint);
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.report-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  font-size: 0.7rem;
  font-weight: 700;
}

.report-button svg {
  width: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.report-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.report-button.is-sent {
  color: var(--cyan-text);
}

.report-status {
  color: var(--text-faint);
  font-size: 0.65rem;
  text-align: right;
}

.reference-modal {
  width: min(620px, calc(100vw - 2rem));
  max-height: min(760px, calc(100dvh - 2rem));
  overflow-y: auto;
  padding: clamp(1.35rem, 4vw, 2.3rem);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--dialog-bg);
  box-shadow: var(--dialog-shadow);
}

.reference-modal.has-scripture {
  width: min(980px, calc(100vw - 2rem));
}

.reference-modal[open] {
  animation: modal-in 200ms ease both;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.reference-modal .dialog-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
}

.reference-modal h2 {
  max-width: calc(100% - 2.5rem);
  margin: 0.7rem 0 1rem;
}

.reference-modal-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  padding: 1rem 0;
  border-block: 1px solid var(--border);
  margin: 1.2rem 0;
}

.reference-modal-meta div {
  display: grid;
}

.reference-modal-meta span {
  color: var(--text-faint);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.reference-modal-meta strong {
  margin-top: 0.2rem;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
}

.reference-modal-url {
  min-width: 0;
  margin-top: 0.2rem;
  overflow-wrap: anywhere;
  color: var(--link);
  font-size: 0.76rem;
}

.scripture-translations,
.scripture-readings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.scripture-translations section,
.scripture-readings section {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--subtle-surface);
}

.scripture-translations h3,
.scripture-readings h3,
.scripture-related h3,
.scripture-support h3 {
  margin: 0 0 0.65rem;
  color: var(--heading);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scripture-translations blockquote {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.98rem;
  line-height: 1.7;
  white-space: pre-line;
}

.scripture-translation-reference {
  margin: -0.35rem 0 0.75rem;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 700;
}

.scripture-readings {
  margin-top: 1rem;
}

.scripture-readings p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.65;
}

.scripture-editorial-note,
.scripture-related,
.scripture-support {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.scripture-editorial-note p {
  margin: 0;
  font-size: 0.78rem;
}

.scripture-related > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.scripture-related-link {
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--button-bg);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.scripture-related-link:hover {
  border-color: var(--gold-border);
  color: var(--gold-text);
}

.scripture-support ul {
  padding-left: 1.2rem;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.65;
}

.scripture-support a {
  color: var(--link);
}

.external-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-sm);
  background: var(--gold-wash);
  color: var(--gold-text);
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
}

.external-link:hover {
  color: var(--gold-text);
}

.toast {
  position: fixed;
  z-index: 500;
  right: 1rem;
  bottom: 1rem;
  max-width: min(360px, calc(100vw - 2rem));
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--tooltip-bg);
  box-shadow: var(--floating-shadow);
  color: var(--text);
  font-size: 0.76rem;
  animation: toast-in 180ms ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(5px); }
}

.prose-view {
  max-width: 960px;
  margin-inline: auto;
}

.changelog {
  padding: clamp(1.25rem, 5vw, 3rem);
}

.changelog h1:first-child,
.changelog h2:first-child {
  display: none;
}

.changelog ul {
  padding-left: 1.15rem;
}

.changelog li::marker {
  color: var(--gold);
}

.site-footer {
  display: flex;
  width: min(100%, var(--content-width));
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 2.5rem;
  border-top: 1px solid var(--border);
  margin: 0 auto;
  color: var(--text-faint);
  font-size: 0.7rem;
}

.site-footer p {
  margin: 0;
}

.site-footer p span {
  margin-right: 0.35rem;
  color: var(--gold);
}

.site-footer a {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-weight: 700;
}

@media (min-width: 1200px) {
  .detail-panel {
    width: clamp(520px, 40vw, 600px);
  }
}

@media (max-width: 1050px) {
  :root { --header-height: 118px; }

  .site-header {
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-block: 0.55rem;
  }

  .header-actions {
    width: 100%;
  }

  .primary-nav {
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .primary-nav::-webkit-scrollbar { display: none; }
  .tab-list { min-width: max-content; }
  .graph-toolbar { flex-wrap: wrap; }
  .graph-toolbar .search-field { flex-basis: 100%; }
  .compact-filters { flex: 1; }
}

@media (max-width: 768px) {
  :root { --header-height: 136px; }

  body { font-size: 0.94rem; }
  h1 { font-size: clamp(1.85rem, 9vw, 2.6rem); }
  h2 { font-size: clamp(1.45rem, 7vw, 2rem); }
  .site-header { align-items: stretch; padding-inline: 0.75rem; }
  .brand { width: 100%; }
  .brand-mark { width: 2.25rem; height: 2.25rem; }
  .brand-subtitle { display: block; max-width: none; font-size: 0.62rem; }
  .header-actions { gap: 0.45rem; }
  .nav-tab { min-height: 44px; padding: 0.55rem 0.65rem; font-size: 0.74rem; }
  .icon-button,
  .theme-toggle,
  .scroll-buttons .icon-button { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .text-button,
  .correlation-open,
  .reference-open,
  .report-button,
  .external-link { min-height: 44px; }
  .correlation-open,
  .reference-open { min-width: 44px; }
  .filter-chip span { display: inline-flex; min-height: 44px; align-items: center; }
  .search-field input,
  .select-field select { min-height: 44px; }
  #timeline-zoom { min-height: 44px; }
  .citation { top: 0; display: inline-flex; margin: 0.12rem 0.08rem 0.12rem 0.3rem; vertical-align: middle; }
  .citation a { display: inline-grid; min-width: 44px; min-height: 44px; place-items: center; border: 1px solid var(--gold-border); border-radius: 999px; background: var(--gold-wash); font-size: 0.7rem; }
  .source-list a,
  .reference-modal-url { display: inline-flex; min-height: 44px; align-items: center; }
  main { width: 100%; padding: 1.8rem 0.75rem 3.5rem; }
  .view-heading { display: block; }
  .view-stats { margin-top: 1.5rem; }
  .atlas-tagline { font-size: 0.82rem; }
  .graph-shell,
  .timeline-viewport,
  .comparison-container,
  .reference-list { width: 100%; }
  .graph-stage { height: min(68vh, 620px); min-height: 440px; }
  .graph-footer { align-items: flex-start; }
  .graph-hint { display: none; }
  .domain-filters legend { width: 100%; margin: 0 0 0.35rem; }
  .timeline-controls .domain-filters { width: 100%; flex-wrap: wrap; }
  .zoom-control { margin-left: 0; }
  .timeline-viewport { height: min(560px, 68vh); min-height: 480px; scroll-snap-type: none; }
  .comparison-domain-header { display: none; }
  .correlation-domains { display: block; }
  .correlation-cell { min-height: 0; padding: 1rem; }
  .correlation-cell + .correlation-cell { border-top: 1px solid var(--border); border-left: 0; }
  .correlation-cell-label { display: block; margin-bottom: 0.4rem; font-size: 0.62rem; font-weight: 750; letter-spacing: 0.1em; text-transform: uppercase; }
  .correlation-synthesis { grid-template-columns: 1fr; }
  .synthesis-item + .synthesis-item { border-top: 1px solid var(--border); border-left: 0; }
  .reference-controls { position: static; flex-wrap: wrap; }
  .question-controls { position: static; flex-wrap: wrap; }
  .question-controls .search-field { min-width: 0; flex-basis: 100%; }
  .question-controls .select-field { flex: 1 1 auto; }
  .question-answers { grid-template-columns: 1fr; }
  .question-answer:nth-child(odd) { border-right: 0; }
  .question-synthesis { grid-template-columns: 1fr; }
  .question-synthesis > div + div { border-top: 1px solid var(--border); border-left: 0; }
  .question-sources ol { grid-template-columns: 1fr; }
  .question-related-link { display: inline-flex; min-height: 44px; align-items: center; }
  .question-inline-source { min-width: 44px; min-height: 44px; vertical-align: middle; }
  .reference-controls .search-field { min-width: 0; flex-basis: 100%; }
  .reference-controls .select-field { flex: 1 1 100%; justify-content: space-between; }
  .reference-controls .select-field select { min-width: 0; flex: 1; }
  .reference-list { grid-template-columns: 1fr; }
  .scripture-translations,
  .scripture-readings { grid-template-columns: 1fr; }
  .detail-panel {
    inset: 0.5rem 0.5rem 0.5rem auto;
    width: calc(100vw - 1rem);
    min-width: 0;
    height: auto;
    max-height: calc(100dvh - 1rem);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
  }
  .detail-panel-scroll { padding-inline: 1.15rem; }
  .detail-title { font-size: clamp(1.75rem, 8vw, 2.4rem); }
  .reference-modal {
    width: calc(100vw - 1rem);
    max-width: none;
    max-height: calc(100dvh - 1rem);
    padding: 1.25rem;
  }
  .reference-modal-meta { grid-template-columns: 1fr; }
  .site-footer { display: block; padding-inline: 0.75rem; }
  .site-footer a { display: inline-block; min-height: 44px; margin-top: 0.75rem; }
}

@media (max-width: 480px) {
  .brand-name { font-size: 1.08rem; }
  .graph-toolbar, .question-controls, .reference-controls, .timeline-controls { padding: 0.75rem; }
  .compact-filters { width: 100%; }
  .compact-filters .filter-chip span { padding-inline: 0.5rem; font-size: 0.62rem; }
  .view-stats { justify-content: space-between; }
  .correlation-card-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.55rem;
  }
  .correlation-index { grid-column: 1; grid-row: 1; margin-top: 0.35rem; }
  .correlation-title { grid-column: 2; grid-row: 1; min-width: 0; overflow-wrap: anywhere; }
  .correlation-open { grid-column: 3; grid-row: 1; }
  .correlation-card-header .confidence-tag {
    grid-column: 2 / 4;
    grid-row: 2;
    justify-self: start;
  }
  .correlation-open span { display: none; }
  .question-card-toggle { grid-template-columns: 2rem minmax(0, 1fr) auto; gap: 0.7rem; padding: 0.9rem 0.75rem; }
  .question-number { width: 2rem; height: 2rem; }
  .question-card-action > span:first-child,
  .question-answer-action > span:first-child { display: none; }
  .question-answer-copy { padding-inline: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
