/* neuronengineering.dev — design system
   Palette: bg #0A0E14 · panel #11161F · green #7EE787 (steering) · red #FF7B72 (adversarial) · neutral #9AA4B2 */

:root {
  --bg: #0A0E14;
  --panel: #11161F;
  --panel-2: #161D29;
  --line: #232C3B;
  --text: #E6EDF3;
  --muted: #9AA4B2;
  --green: #7EE787;
  --green-dim: rgba(126, 231, 135, 0.14);
  --red: #FF7B72;
  --red-dim: rgba(255, 123, 114, 0.12);
  --blue: #79C0FF;
  --font-sans: "Inter", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --max: 1240px;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(126, 231, 135, 0.25); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #232C3B; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2E3949; }

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }

code, kbd, pre, .mono { font-family: var(--font-mono); font-size: 0.92em; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10, 14, 20, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.header-inner {
  max-width: var(--max); margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 64px;
}
.wordmark {
  display: flex; align-items: center; gap: 10px;
  font-weight: 650; letter-spacing: -0.01em; color: var(--text);
  font-size: 1.02rem; white-space: nowrap;
}
.wordmark:hover { text-decoration: none; }
.wordmark svg { flex: none; }
.site-nav { display: flex; align-items: center; gap: 4px; font-size: 0.94rem; }
.site-nav a {
  color: var(--muted); padding: 8px 12px; border-radius: 8px; line-height: 1;
}
.site-nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.site-nav a.active { color: var(--green); }
.nav-cta {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px !important;
  color: var(--text) !important;
}
.nav-cta:hover { border-color: var(--green); }

/* ---------- reading progress ---------- */
.progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--green), #B7F7C0);
  z-index: 100;
}

/* ---------- layout ---------- */
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
section { padding: 88px 0; }
section.tight { padding: 56px 0; }
.eyebrow {
  font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--green); margin: 0 0 14px;
}
h1, h2, h3, h4 { line-height: 1.18; letter-spacing: -0.02em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2.4rem, 5vw, 3.8rem); font-weight: 750; }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); font-weight: 700; }
h3 { font-size: 1.22rem; font-weight: 650; }
p { margin: 0 0 1.1em; color: var(--text); }
.lead { font-size: 1.13rem; color: var(--muted); max-width: 46em; }
.section-head { max-width: 760px; margin-bottom: 44px; }
.section-head .lead { margin-top: 10px; }

/* ---------- hero ---------- */
.hero { position: relative; padding: 96px 0 80px; overflow: clip; }
.hero-glow { position: absolute; inset: 0; pointer-events: none; }
.hero-glow::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(720px 420px at 16% -6%, rgba(126, 231, 135, 0.08), transparent 62%),
    radial-gradient(620px 420px at 88% 12%, rgba(255, 123, 114, 0.055), transparent 62%);
}
.hero-glow::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(154, 164, 178, 0.11) 1px, transparent 1.3px);
  background-size: 26px 26px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.6), transparent 78%);
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.6), transparent 78%);
}
.hero-grid {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: 60px; align-items: center;
}
.hero h1 { max-width: 12em; }
.hero .lead { max-width: 34em; margin-top: 18px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 0.98rem; border-radius: 10px; padding: 13px 22px;
  border: 1px solid transparent; cursor: pointer; transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--green); color: #06130A; }
.btn-primary:hover { background: #95f09e; }
.btn-ghost { border-color: var(--line); color: var(--text); background: rgba(17, 22, 31, 0.6); }
.btn-ghost:hover { border-color: var(--green); }
.hero-meta { margin-top: 24px; font-size: 0.9rem; color: var(--muted); display: flex; gap: 22px; flex-wrap: wrap; }
.hero-meta span { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.green { background: var(--green); box-shadow: 0 0 10px rgba(126,231,135,0.8); }
.dot.red { background: var(--red); box-shadow: 0 0 10px rgba(255,123,114,0.8); }

.stat-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-top: 42px;
}
.stat { background: var(--panel); padding: 16px 18px 14px; }
.stat-num {
  display: block; font-family: var(--font-mono); font-size: 1.45rem; font-weight: 700;
  color: var(--green); line-height: 1.2;
}
.stat.red .stat-num { color: var(--red); }
.stat-label { font-size: 0.79rem; color: var(--muted); line-height: 1.35; display: block; margin-top: 2px; }

/* ---------- hero console card ---------- */
.console-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.console-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  font-size: 0.78rem; color: var(--muted);
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none;
  box-shadow: 0 0 8px var(--green); animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.console-layer { margin-left: auto; color: #48556A; }
.console-viz { position: relative; padding: 10px 14px 6px; }
.console-viz > svg { width: 100%; height: auto; display: block; }
.console-viz > canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.console-foot {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.mode-chip {
  --c: var(--green);
  font-family: var(--font-mono); font-size: 0.72rem; padding: 4px 10px; border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--c) 42%, transparent);
  color: var(--c);
  background: color-mix(in srgb, var(--c) 9%, transparent);
}
.flow { stroke-dasharray: 5 6; animation: dashflow 1.1s linear infinite; }
@keyframes dashflow { to { stroke-dashoffset: -22; } }

/* ---------- cards & grid ---------- */
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px;
}
.card h3 { margin-bottom: 8px; }
.card p { color: var(--muted); font-size: 0.96rem; margin-bottom: 0; }
.card .mono { color: var(--green); font-size: 0.85rem; }

.paper-card { display: flex; flex-direction: column; gap: 14px; padding: 30px; position: relative; overflow: hidden; }
.paper-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(180deg, var(--green), transparent 85%);
}
.paper-card h3 { font-size: 1.35rem; }
.paper-card h3 a { color: var(--text); }
.paper-card h3 a:hover { color: var(--green); text-decoration: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--font-mono); font-size: 0.76rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px;
}
.chip.green { color: var(--green); border-color: rgba(126,231,135,0.35); background: var(--green-dim); }
.chip.red { color: var(--red); border-color: rgba(255,123,114,0.35); background: var(--red-dim); }

.badge {
  display: inline-block; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; padding: 4px 10px; border-radius: 6px;
  background: var(--green-dim); color: var(--green); border: 1px solid rgba(126,231,135,0.3);
}
.badge.red { background: var(--red-dim); color: var(--red); border-color: rgba(255,123,114,0.3); }
.badge.neutral { background: var(--panel-2); color: var(--muted); border-color: var(--line); }

/* ---------- positioning statement ---------- */
.positioning {
  border-left: 3px solid var(--green); background: var(--panel);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 26px 30px; font-size: 1.12rem; max-width: 52em;
}
.positioning strong { color: var(--green); font-weight: 650; }

/* ---------- intervention widget ---------- */
.widget-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.widget-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 30px; align-items: stretch; }
.slider-row { margin-bottom: 18px; }
.slider-row label { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 6px; }
.slider-row label .mono { font-size: 0.8rem; }
.slider-row output { color: var(--green); font-family: var(--font-mono); font-size: 0.82rem; }
input[type="range"] {
  width: 100%; appearance: none; height: 4px; border-radius: 2px;
  background: var(--line); cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--green); border: 2px solid #06130A; box-shadow: 0 0 0 1px var(--green);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--green); border: 2px solid #06130A;
}
.mode-scale input[type="range"]::-webkit-slider-thumb { background: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.mode-clamp input[type="range"]::-webkit-slider-thumb { background: #D2A8FF; box-shadow: 0 0 0 1px #D2A8FF; }
.mode-zero input[type="range"]::-webkit-slider-thumb { background: var(--red); box-shadow: 0 0 0 1px var(--red); }
.chart-cell {
  background: #090C12; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; display: flex; align-items: center;
}
.widget-canvas { width: 100%; height: auto; display: block; }
.widget-note { font-size: 0.85rem; color: var(--muted); margin-top: 16px; }

/* ---------- code card & copy ---------- */
.code-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 20px; }
.code-card-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: #0C1017; border-bottom: 1px solid var(--line);
}
.code-card-head .fname { font-family: var(--font-mono); font-size: 0.76rem; color: #48556A; }
.code-card pre { margin: 0; padding: 14px 16px; background: #090C12; overflow-x: auto; font-size: 0.8rem; color: var(--muted); }
.copy-btn {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; cursor: pointer; transition: color 0.15s ease, border-color 0.15s ease;
}
.copy-btn:hover { color: var(--green); border-color: rgba(126,231,135,0.4); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 56px 0 40px; margin-top: 40px; background: #090C12; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 36px; }
.site-footer h4 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; font-size: 0.94rem; }
.site-footer li a { color: var(--muted); }
.site-footer li a:hover { color: var(--text); }
.footer-brand p { color: var(--muted); font-size: 0.92rem; max-width: 34em; margin-top: 12px; }
.credit {
  margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  font-size: 0.86rem; color: var(--muted);
}
.credit a { color: var(--muted); }
.credit a:hover { color: var(--green); }
.credit .agency { font-family: var(--font-mono); font-size: 0.8rem; }

/* ---------- paper page ---------- */
.paper-hero { padding: 72px 0 40px; border-bottom: 1px solid var(--line); }
.paper-hero h1 { font-size: clamp(1.9rem, 4.4vw, 3rem); max-width: 22em; }
.paper-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 18px 0; font-size: 0.92rem; color: var(--muted); }
.paper-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 56px; padding: 48px 0 80px; }
.toc { position: sticky; top: 88px; align-self: start; font-size: 0.9rem; }
.toc .toc-title { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.toc a { display: block; color: var(--muted); padding: 7px 12px; border-left: 2px solid var(--line); }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--green); border-left-color: var(--green); background: var(--green-dim); border-radius: 0 6px 6px 0; }
.paper-body { max-width: 780px; min-width: 0; }
.paper-body section { padding: 34px 0; border-bottom: 1px solid var(--line); }
.paper-body section:last-of-type { border-bottom: 0; }
.paper-body h2 { display: flex; align-items: center; gap: 12px; }
.paper-body h2 .sec-num { font-family: var(--font-mono); font-size: 0.85rem; color: var(--green); font-weight: 500; }
.paper-body h3 { margin-top: 28px; }
.paper-body .lead { font-size: 1.06rem; }

.formula {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 28px; margin: 22px 0; overflow-x: auto; text-align: center;
  font-size: 1.25rem;
}
.formula math { font-size: 1.25em; }
.formula-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; font-size: 0.88rem; color: var(--muted); justify-content: center; }
.formula-legend .mono { color: var(--green); margin-right: 5px; }

.symbol-tip { border-bottom: 1px dashed rgba(126,231,135,0.5); cursor: help; }

.figure { margin: 26px 0; }
.figure svg { width: 100%; height: auto; display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.figure figcaption { font-size: 0.86rem; color: var(--muted); margin-top: 10px; }
.figure figcaption .mono { color: var(--green); }

.pull-quote {
  border-left: 3px solid var(--red); background: var(--red-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 20px 26px; margin: 20px 0; color: var(--text); font-size: 1.02rem;
}
.pull-quote strong { color: var(--red); font-weight: 650; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; margin: 20px 0; display: block; overflow-x: auto; }
caption { text-align: left; font-weight: 650; font-size: 0.95rem; padding-bottom: 10px; color: var(--text); }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { font-family: var(--font-mono); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); border-bottom: 1px solid #2E3949; }
tbody tr:hover { background: var(--panel); }
td.desc, th.desc { white-space: normal; min-width: 220px; color: var(--muted); }
td .mono { color: var(--green); font-size: 0.82rem; }

.crate-tree { font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.9; margin: 22px 0; overflow-x: auto; }
.crate-tree .crate { color: var(--green); font-weight: 600; }
.crate-tree .dep { color: var(--muted); }
.crate-item { margin-bottom: 18px; }
.crate-item h4 { font-family: var(--font-mono); font-size: 0.95rem; color: var(--green); margin-bottom: 4px; }
.crate-item p { color: var(--muted); font-size: 0.93rem; margin: 0; }

.refs { font-size: 0.92rem; color: var(--muted); padding-left: 20px; display: grid; gap: 10px; }
.refs li::marker { color: var(--green); }
.refs a { overflow-wrap: anywhere; }

.callout {
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 20px 24px; margin: 22px 0; font-size: 0.95rem; color: var(--muted);
}
.callout strong { color: var(--text); }

/* ---------- papers index ---------- */
.paper-row {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 30px; margin-bottom: 18px;
  transition: border-color 0.15s ease;
}
.paper-row:hover { border-color: rgba(126,231,135,0.4); text-decoration: none; }
.paper-row .row-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.paper-row h2 { font-size: 1.3rem; color: var(--text); margin-bottom: 10px; }
.paper-row:hover h2 { color: var(--green); }
.paper-row p { color: var(--muted); font-size: 0.96rem; margin-bottom: 14px; }
.paper-row .row-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.85rem; color: #48556A; }

/* ---------- 404 ---------- */
.nf { min-height: 60vh; display: flex; align-items: center; }
.nf .code { font-family: var(--font-mono); font-size: 5rem; color: var(--green); line-height: 1; margin-bottom: 10px; }

/* ---------- reveal on scroll (JS adds .reveal, then .in) ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.55s ease, transform 0.55s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .hero .lead { max-width: 40em; }
}
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .widget-grid { grid-template-columns: 1fr; }
  .paper-layout { grid-template-columns: 1fr; }
  .toc { position: static; display: none; }
  .footer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stat-strip { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 15.5px; }
  section { padding: 60px 0; }
  .hero { padding: 64px 0 56px; }
  .site-nav a:not(.nav-cta) { padding: 8px 8px; }
  .paper-hero { padding: 48px 0 28px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- print (paper page) ---------- */
@media print {
  .site-header, .site-footer, .toc, .progress, .hero-actions, .btn, .copy-btn { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  .paper-hero { padding: 0 0 16px; }
  .paper-layout { display: block; padding: 0; }
  .paper-body { max-width: none; }
  .paper-body section { padding: 14px 0; border-bottom-color: #ccc; }
  h1, h2, h3, p, li, td, th, caption { color: #000 !important; }
  a { color: #000; text-decoration: underline; }
  .formula, .card, .callout, .pull-quote, .figure svg, .paper-card, table {
    background: #fff !important; border-color: #bbb !important;
  }
  .pull-quote strong, .badge, .chip { color: #000 !important; border-color: #999 !important; background: #fff !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
}
