:root {
  color-scheme: dark;
  --void: #070916;
  --deep: #0d1125;
  --surface: #121730;
  --ink: #eef1ff;
  --muted: #8f96b4;
  --dim: #555d7a;
  --synapse: #a9a5ff;
  --pulse: #74e7ed;
  --memory: #efc777;
  --alert: #ff8b82;
  --line: rgba(173, 181, 225, 0.16);
  --edge: clamp(20px, 3.2vw, 58px);
  --sans: "Avenir Next", Avenir, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--void);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(circle at 54% 42%, rgba(70, 76, 153, 0.2), transparent 31%),
    radial-gradient(circle at 75% 78%, rgba(25, 114, 128, 0.11), transparent 26%),
    #070916;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0.13;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
}

button, a { font: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  color: var(--void);
  background: var(--pulse);
  transform: translateY(-160%);
}

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

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

.topbar {
  min-height: 88px;
  padding: 20px var(--edge);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  animation: enter 700ms cubic-bezier(.2,.8,.2,1) both;
}

.brand {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.brand-mark {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(169, 165, 255, 0.6);
  border-radius: 50%;
  color: var(--synapse);
  font-size: 12px;
  box-shadow: 0 0 28px rgba(169, 165, 255, 0.14), inset 0 0 18px rgba(169, 165, 255, 0.08);
}

.brand-slash { color: var(--dim); padding-inline: 4px; }

.system-state {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.system-state strong { color: var(--pulse); font-weight: 600; }

.state-orbit {
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(116, 231, 237, 0.28);
  border-radius: 50%;
  animation: breathe 3s ease-in-out infinite;
}

.state-orbit i,
.stream-label i,
.privacy-note i {
  width: 5px;
  height: 5px;
  display: block;
  border-radius: 50%;
  background: var(--pulse);
  box-shadow: 0 0 12px var(--pulse);
}

.top-time {
  justify-self: end;
  margin: 0;
  display: grid;
  gap: 3px;
  text-align: right;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.top-time span { color: var(--dim); font-size: 8px; letter-spacing: 0.2em; }

.brain-layout {
  min-height: calc(100vh - 166px);
  display: grid;
  grid-template-columns: minmax(235px, 0.72fr) minmax(520px, 1.7fr) minmax(250px, 0.78fr);
}

.manifesto,
.memory-panel,
.cortex {
  min-width: 0;
  padding: clamp(34px, 4vw, 70px) var(--edge);
}

.manifesto {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  animation: enter 800ms 100ms cubic-bezier(.2,.8,.2,1) both;
}

.eyebrow {
  margin: 0 0 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow span { color: var(--synapse); }

.manifesto h1 {
  max-width: 420px;
  margin: 0;
  font-size: clamp(39px, 4.2vw, 68px);
  font-weight: 500;
  line-height: 0.96;
  letter-spacing: -0.055em;
}

.manifesto-lead {
  margin: 12px 0 0;
  color: var(--synapse);
  font-size: clamp(19px, 1.6vw, 27px);
  font-weight: 400;
  letter-spacing: -0.025em;
}

.manifesto-copy {
  max-width: 350px;
  margin: 34px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.mind-index {
  margin-top: auto;
  padding-top: 50px;
  display: grid;
  border-bottom: 1px solid var(--line);
}

.mind-link {
  position: relative;
  padding: 13px 0;
  display: grid;
  grid-template-columns: 68px 1fr 16px;
  align-items: center;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.mind-link span {
  color: var(--dim);
  font-size: 8px;
  letter-spacing: 0.15em;
}

.mind-link strong { font-size: 12px; font-weight: 500; }

.mind-link i {
  width: 5px;
  height: 5px;
  justify-self: end;
  border-radius: 50%;
  border: 1px solid var(--dim);
  transition: 250ms ease;
}

.mind-link:hover strong,
.mind-link.is-active strong { color: var(--pulse); }

.mind-link.is-active i {
  border-color: var(--pulse);
  background: var(--pulse);
  box-shadow: 0 0 14px var(--pulse);
}

.cortex {
  padding-inline: clamp(18px, 2.4vw, 42px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: enter 900ms 180ms cubic-bezier(.2,.8,.2,1) both;
}

.cortex-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.cortex-header .eyebrow { margin-bottom: 9px; }

.cortex-header h2,
.memory-heading h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.privacy-note {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--dim);
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.privacy-note i { background: var(--memory); box-shadow: 0 0 10px rgba(239, 199, 119, 0.7); }

.cortex-stage {
  position: relative;
  flex: 1;
  min-height: 500px;
  margin-top: 12px;
  isolation: isolate;
}

#neural-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: manipulation;
}

.axis-label {
  position: absolute;
  top: 50%;
  z-index: -1;
  color: rgba(143, 150, 180, 0.28);
  font-size: 7px;
  letter-spacing: 0.32em;
  writing-mode: vertical-rl;
}

.axis-input { left: 0; transform: translateY(-50%) rotate(180deg); }
.axis-output { right: 0; transform: translateY(-50%); }

.selected-thought {
  position: absolute;
  right: 1%;
  bottom: 4%;
  width: min(240px, 42%);
  padding: 12px 0 12px 18px;
  border-left: 1px solid rgba(116, 231, 237, 0.55);
  background: linear-gradient(90deg, rgba(7, 9, 22, 0.84), rgba(7, 9, 22, 0));
  pointer-events: none;
}

.selected-thought span {
  display: block;
  color: var(--pulse);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.selected-thought strong {
  display: block;
  margin-top: 5px;
  font-size: 21px;
  font-weight: 500;
}

.selected-thought p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.interaction-hint {
  position: absolute;
  left: 2%;
  bottom: 4%;
  margin: 0;
  color: var(--dim);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

.interaction-hint span { color: var(--synapse); margin-right: 5px; }

.node-controls {
  padding-top: 13px;
  display: flex;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.node-control {
  width: 27px;
  height: 27px;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--dim);
  background: transparent;
  font-size: 8px;
  cursor: pointer;
}

.node-control:hover { color: var(--ink); }
.node-control.is-current { color: var(--pulse); border-color: rgba(116, 231, 237, 0.35); }

.memory-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  animation: enter 800ms 260ms cubic-bezier(.2,.8,.2,1) both;
}

.memory-heading .eyebrow { margin-bottom: 9px; }
.memory-heading h2 { max-width: 230px; }

.memory-totals {
  margin: 38px 0 0;
  display: grid;
}

.memory-totals > div {
  position: relative;
  padding: 17px 0 18px;
  display: flex;
  flex-direction: column-reverse;
  border-top: 1px solid var(--line);
}

.metric-label {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.metric-number {
  margin: 0 0 2px;
  font-size: clamp(27px, 2.4vw, 40px);
  font-weight: 300;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.metric-signal {
  position: absolute;
  top: -2px;
  left: 0;
  width: 28%;
  height: 2px;
  background: var(--synapse);
  box-shadow: 0 0 15px rgba(169, 165, 255, 0.5);
  transform-origin: left;
  animation: scan 4.8s ease-in-out infinite;
}

.memory-totals > div:nth-child(2) .metric-signal { animation-delay: -1.5s; background: var(--pulse); }
.memory-totals > div:nth-child(3) .metric-signal { animation-delay: -3s; background: var(--memory); }

.truth-meter {
  margin-top: 22px;
  padding-top: 24px;
  display: grid;
  grid-template-columns: 78px 1fr;
  align-items: center;
  gap: 15px;
  border-top: 1px solid var(--line);
}

.truth-orbit { position: relative; width: 76px; height: 76px; }
.truth-orbit svg { width: 100%; transform: rotate(-90deg); }
.truth-orbit circle { fill: none; stroke-width: 2; }
.truth-track { stroke: rgba(143, 150, 180, 0.15); }
.truth-value {
  stroke: var(--pulse);
  stroke-linecap: round;
  stroke-dasharray: 320.44;
  stroke-dashoffset: 57.7;
  filter: drop-shadow(0 0 5px rgba(116, 231, 237, 0.6));
  transition: stroke-dashoffset 900ms cubic-bezier(.2,.8,.2,1);
}

.truth-orbit strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 500;
}

.truth-meter p { margin: 0 0 4px; font-size: 11px; }
.truth-meter span { display: block; color: var(--dim); font-size: 9px; line-height: 1.5; }

.next-synapse {
  margin-top: auto;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.next-synapse p { margin: 0; color: var(--memory); font-size: 7px; letter-spacing: 0.2em; }
.next-synapse h3 { margin: 7px 0 5px; font-size: 20px; font-weight: 500; }
.next-synapse span { display: block; max-width: 250px; color: var(--dim); font-size: 9px; line-height: 1.55; }

.signal-stream {
  height: 78px;
  padding: 0 var(--edge);
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  align-items: center;
  gap: 26px;
  border-top: 1px solid var(--line);
  background: rgba(5, 7, 17, 0.7);
}

.stream-label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.signal-stream ol {
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.signal-stream li {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 42px;
  gap: 12px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
}

.signal-stream li:not(:first-child) { display: none; }
.signal-stream time { color: var(--dim); font-variant-numeric: tabular-nums; }
.signal-stream li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal-stream b { color: var(--pulse); font-size: 8px; letter-spacing: 0.08em; }

.system-signature {
  margin: 0;
  color: var(--dim);
  font-size: 7px;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.system-signature span { color: var(--synapse); padding-inline: 5px; }
.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; }

@keyframes enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes breathe {
  0%, 100% { transform: scale(.88); opacity: .7; }
  50% { transform: scale(1.08); opacity: 1; }
}

@keyframes scan {
  0%, 100% { transform: scaleX(.1); opacity: .35; }
  50% { transform: scaleX(1); opacity: 1; }
}

@media (max-width: 1180px) {
  .brain-layout { grid-template-columns: minmax(230px, .72fr) minmax(480px, 1.4fr); }
  .memory-panel {
    grid-column: 1 / -1;
    padding-block: 28px;
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr;
    align-items: center;
    gap: 28px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
  .memory-totals { margin: 0; grid-template-columns: repeat(3, 1fr); }
  .memory-totals > div { padding-inline: 14px; border-left: 1px solid var(--line); }
  .truth-meter, .next-synapse { margin-top: 0; padding-top: 0; border-top: 0; }
}

@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; min-height: 72px; }
  .system-state { justify-self: end; }
  .top-time { display: none; }
  .brain-layout { display: flex; flex-direction: column; }
  .manifesto { min-height: 620px; border-right: 0; border-bottom: 1px solid var(--line); }
  .manifesto h1 { max-width: 650px; font-size: clamp(46px, 12vw, 76px); }
  .manifesto-copy { max-width: 560px; font-size: 14px; }
  .cortex { min-height: 710px; }
  .cortex-stage { min-height: 560px; }
  .memory-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .memory-totals { grid-column: 1 / -1; order: 3; }
  .next-synapse { align-self: center; }
}

@media (max-width: 560px) {
  .topbar { padding-block: 14px; }
  .brand { font-size: 11px; }
  .brand-mark { width: 30px; height: 30px; }
  .system-state { gap: 6px; }
  .system-state #health-label { display: none; }
  .manifesto { min-height: 570px; }
  .manifesto h1 { font-size: clamp(44px, 14vw, 66px); }
  .manifesto-lead { font-size: 21px; }
  .mind-link { grid-template-columns: 62px 1fr 16px; }
  .cortex { min-height: 620px; padding-block: 34px 24px; }
  .cortex-header { align-items: end; }
  .cortex-stage { min-height: 455px; }
  .selected-thought { right: 0; bottom: 2%; width: 68%; }
  .interaction-hint { display: none; }
  .memory-panel { display: flex; padding-block: 42px; }
  .memory-heading h2 { font-size: 25px; }
  .memory-totals { width: 100%; margin-top: 34px; display: grid; grid-template-columns: 1fr; order: initial; }
  .memory-totals > div { padding-inline: 0; border-left: 0; }
  .metric-number { font-size: 44px; }
  .truth-meter, .next-synapse { width: 100%; margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--line); }
  .signal-stream { height: auto; min-height: 74px; grid-template-columns: 1fr; gap: 8px; padding-block: 16px; }
  .system-signature { display: none; }
}

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