:root {
  --bg: #070910;
  --bg-soft: rgba(13, 16, 28, 0.78);
  --panel: rgba(13, 17, 31, 0.84);
  --line: rgba(135, 164, 255, 0.18);
  --line-strong: rgba(160, 188, 255, 0.34);
  --text: #dbe6ff;
  --muted: #92a0c8;
  --accent: #8eb7ff;
  --accent-2: #7b70ff;
  --danger: #ff7ea8;
  --ok: #85f2ca;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, rgba(87, 121, 255, 0.16), transparent 35%),
    radial-gradient(circle at 80% 20%, rgba(123, 112, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #05070c, #0a0f1b 40%, #060810);
  font: 16px/1.6 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

body::selection { background: rgba(142, 183, 255, 0.25); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}
.shell--wide { width: min(1280px, calc(100% - 2rem)); }
.shell--narrow { width: min(860px, calc(100% - 2rem)); }

.site-header,
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
  z-index: 2;
}
.site-header { padding: 1.2rem 0 0; }
.site-footer {
  padding: 1.25rem 0 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
}
.brand strong,
.brand small { display: block; }
.brand small { color: var(--muted); }
.brand__mark {
  width: 2.55rem;
  height: 2.55rem;
  display: inline-grid;
  place-items: center;
  border-radius: 15px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(142,183,255,0.22), rgba(123,112,255,0.1));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 0 35px rgba(122, 129, 255, 0.18);
  font-weight: 800;
}
.brand--stack { align-items: flex-start; }
.header-nav,
.stack-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.header-nav a,
.stack-nav a,
.route,
.button-link,
.text-button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  padding: 0.7rem 1rem;
  border-radius: 999px;
  transition: 180ms ease;
}
.header-nav a:hover,
.stack-nav a:hover,
.route:hover,
.button-link:hover,
.text-button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  background: rgba(255,255,255,0.04);
}
.header-nav--compact { margin-top: 1rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 25%);
  pointer-events: none;
}
.panel--hero,
.panel--terminal,
.panel--split,
.panel--note,
.panel--tight,
.panel--modal,
.spectrum-panel,
.constellation-panel,
.witness-list { padding: 1.5rem; }
.panel--hero { padding: 2.1rem; }
.panel--split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem;
}
.panel--note {
  text-align: center;
  color: var(--muted);
  font-style: italic;
}
.panel--terminal-full { min-height: 72vh; }
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.hero-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.2rem;
  padding: 2.2rem 0 1.25rem;
}
.hero-grid > :nth-child(3),
.hero-grid > :nth-child(4) { grid-column: 1 / -1; }

.eyebrow {
  margin: 0 0 0.5rem;
  letter-spacing: 0.18em;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 0.78rem;
}
.lede {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 56ch;
}
h1, h2 { margin: 0; line-height: 1.08; }
h1 { font-size: clamp(2rem, 5vw, 4.6rem); }
h2 { font-size: clamp(1.1rem, 2.4vw, 1.6rem); }

.glitch {
  position: relative;
  display: inline-block;
  text-shadow: 0 0 30px rgba(142,183,255,0.25);
}
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.3;
}
.glitch::before {
  transform: translate(2px, -1px);
  color: #93baff;
  animation: driftA 5s infinite ease-in-out;
}
.glitch::after {
  transform: translate(-2px, 1px);
  color: #8b78ff;
  animation: driftB 7s infinite ease-in-out;
}
@keyframes driftA { 50% { transform: translate(-1px, 1px); } }
@keyframes driftB { 50% { transform: translate(1px, -1px); } }

.status-cluster {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1.5rem;
}
.status-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.95rem 1rem;
  background: rgba(255,255,255,0.02);
}
.status-card span,
.spectrum-meta span,
.tiny-note,
.badge,
.doc-card__type,
.statement__id { color: var(--muted); font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; }
.status-card strong,
.spectrum-meta strong { display: block; margin-top: 0.35rem; }

.dotline { display: inline-flex; gap: 0.45rem; }
.dotline i {
  width: 0.65rem; height: 0.65rem; border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.35), rgba(255,255,255,0.06));
}

.terminal-window {
  min-height: 18rem;
  padding: 1.1rem 1.15rem;
  border-radius: 18px;
  border: 1px solid rgba(146,160,200,0.18);
  background: linear-gradient(180deg, rgba(3,4,9,0.92), rgba(9,14,26,0.88));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #d3e0ff;
}
.terminal-window p { margin: 0 0 0.42rem; }
.terminal-window--tall { min-height: 28rem; }
.muted { color: var(--muted); }
.prompt { color: var(--accent); font-family: ui-monospace, monospace; }
.command-form {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}
.command-form input {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  color: var(--text);
  background: rgba(255,255,255,0.03);
  outline: none;
}
.command-form input:focus { border-color: var(--line-strong); box-shadow: 0 0 0 4px rgba(142,183,255,0.08); }
.command-form button,
.text-button {
  color: var(--text);
  cursor: pointer;
  background: linear-gradient(180deg, rgba(142,183,255,0.14), rgba(123,112,255,0.08));
}
.response {
  margin-top: 1rem;
  min-height: 4rem;
  color: var(--ok);
  font-family: ui-monospace, monospace;
  white-space: pre-wrap;
}

.feed {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}
.feed li {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.85rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid rgba(146,160,200,0.12);
}
.feed time { color: var(--accent); }
.route-map { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1rem; }
.route.active { border-color: rgba(133,242,202,0.25); }
.route.unstable { border-color: rgba(255,126,168,0.22); }

.archive-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1.2rem;
  padding: 2rem 0;
}
.sidebar { padding: 1.4rem; }
.archive-main { padding: 1.4rem; }
.doc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.doc-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.1rem;
  background: rgba(255,255,255,0.02);
}
.doc-card h2 { margin: 0.35rem 0 0.6rem; }
.archive-terminal {
  margin-top: 1.2rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  font-family: ui-monospace, monospace;
  color: var(--muted);
}

.note-modal {
  width: min(700px, calc(100% - 2rem));
  border: 0;
  background: transparent;
  padding: 0;
}
.note-modal::backdrop { background: rgba(3, 6, 15, 0.76); }
.panel--modal { padding: 1.35rem; }
.modal-copy { color: var(--text); }
.modal-copy p { margin: 0 0 0.95rem; }

.spectrum-panel canvas {
  width: 100%; height: auto; display: block;
  border-radius: 18px;
  border: 1px solid rgba(146,160,200,0.18);
  background: radial-gradient(circle at 50% 20%, rgba(255,255,255,0.03), transparent 40%), #05070d;
}
.spectrum-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}
.quote {
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--text);
}
.mono { font-family: ui-monospace, monospace; }

.witness-list {
  display: grid;
  gap: 0.9rem;
}
.statement {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.1rem;
  background: rgba(255,255,255,0.02);
}
.statement__id { display: block; margin-bottom: 0.4rem; }
.corrupted::after {
  content: attr(data-glitch-text);
  position: absolute;
  top: 1rem;
  right: 1rem;
  color: rgba(255,126,168,0.55);
  font-family: ui-monospace, monospace;
}

.constellation-panel { padding: 1.6rem; }
.constellation {
  position: relative;
  min-height: 26rem;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 20% 20%, rgba(142,183,255,0.1), transparent 25%),
    radial-gradient(circle at 80% 70%, rgba(123,112,255,0.12), transparent 30%),
    linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,255,255,0));
  overflow: hidden;
}
.node {
  position: absolute;
  z-index: 2;
  border-radius: 999px;
  padding: 0.9rem 1.15rem;
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: rgba(8, 12, 24, 0.9);
  box-shadow: 0 0 35px rgba(123,112,255,0.14);
  cursor: pointer;
}
.node--ghost { border-color: rgba(255,126,168,0.28); }
.link {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, rgba(142,183,255,0.12), rgba(142,183,255,0.42), rgba(123,112,255,0.18));
  transform-origin: left center;
}
.link--pulse { animation: pulseLink 3s infinite ease-in-out; }
@keyframes pulseLink { 50% { opacity: 0.35; } }

.bg-grid,
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.bg-grid {
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.04;
}
.vignette { box-shadow: inset 0 0 200px rgba(0,0,0,0.65); }
.scanlines::before,
.grain::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.scanlines::before {
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.03) 1px, transparent 1px, transparent 3px);
  opacity: 0.05;
}
.grain::after {
  background-image: url('../img/noise.svg');
  opacity: 0.055;
  mix-blend-mode: soft-light;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
}
.badge--warn { border-color: rgba(255,126,168,0.26); color: #ffb8cf; }
.microcopy,
.tiny-note { color: var(--muted); margin-top: 1rem; }
.center-stage {
  display: grid;
  min-height: 100vh;
  align-items: center;
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (max-width: 980px) {
  .hero-grid,
  .archive-layout,
  .panel--split,
  .doc-grid,
  .status-cluster,
  .spectrum-meta {
    grid-template-columns: 1fr;
  }
  .site-header,
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
