/* === CORTEX.LAB — design system === */
:root {
  --void: #06080c;
  --panel: #0d1117;
  --raised: #131923;
  --hairline: rgba(255, 255, 255, 0.06);
  --hairline-strong: rgba(255, 255, 255, 0.12);
  --accent: #ffd400;
  --accent-dim: rgba(255, 212, 0, 0.14);
  --magenta: #ff3366;
  --magenta-dim: rgba(255, 51, 102, 0.14);
  --cyan: #4dd0ff;
  --text: #f1f3f5;
  --text-2: #9aa3b2;
  --text-3: #5a6271;
  --grid: rgba(255, 212, 0, 0.035);
  --ok: #2ee68b;
  --warn: #ff9d3a;
  --fail: #ff3366;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Menlo", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--void);
  color: var(--text);
  font-family: var(--font-display);
  font-feature-settings: "ss01", "cv11";
  font-weight: 400;
  letter-spacing: -0.005em;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* technical grid background */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 64px 64px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 90%);
}
body::after {
  content: "";
  position: fixed; inset: 0;
  background: radial-gradient(ellipse 60% 40% at 80% -10%, rgba(255, 212, 0, 0.06), transparent 70%),
              radial-gradient(ellipse 50% 40% at 10% 100%, rgba(255, 51, 102, 0.05), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ─── LIGHT THEME ─── */
html[data-theme="light"] {
  --void: #ecebe4;
  --panel: #ffffff;
  --raised: #f2f0e8;
  --hairline: rgba(20,22,26,0.10);
  --hairline-strong: rgba(20,22,26,0.20);
  --accent: #a87b00;
  --accent-dim: rgba(168,123,0,0.14);
  --magenta: #d11f55;
  --magenta-dim: rgba(209,31,85,0.14);
  --text: #15171c;
  --text-2: #4c5563;
  --text-3: #8a909c;
  --grid: rgba(168,123,0,0.05);
}
html[data-theme="light"] body::after {
  background: radial-gradient(ellipse 60% 40% at 80% -10%, rgba(168,123,0,0.05), transparent 70%),
              radial-gradient(ellipse 50% 40% at 10% 100%, rgba(209,31,85,0.04), transparent 70%);
}
html[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(242,240,232,0.9));
}
html[data-theme="light"] .topbar {
  background: rgba(255,255,255,0.8);
}
html[data-theme="light"] .brand-mark::after { background: var(--void); }
html[data-theme="light"] .toggle-group button.on { color: #fff; }

/* ─── layout shell ─── */
.shell { position: relative; z-index: 1; min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.shell > main { min-width: 0; }

/* ─── sidebar ─── */
.sidebar {
  border-right: 1px solid var(--hairline);
  background: linear-gradient(180deg, rgba(13,17,23,0.6), rgba(6,8,12,0.6));
  backdrop-filter: blur(8px);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 20px 0;
  z-index: 10;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline-strong) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.brand {
  padding: 0 20px 18px 20px;
  border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 10px;
}
.brand-mark {
  width: 26px; height: 26px;
  border: 1.5px solid var(--accent);
  position: relative;
  transform: rotate(45deg);
}
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; background: var(--accent);
}
.brand-mark::before { inset: 4px; }
.brand-mark::after  { inset: 9px; background: var(--void); }
.brand-text { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.08em; }
.brand-text b { color: var(--accent); font-weight: 600; }

.nav-section {
  padding: 14px 0 0;
}
.nav-section h4 {
  margin: 0 20px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 2px solid transparent;
  transition: color .15s, background .15s, border-color .15s;
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.02); }
.nav-link.active { color: var(--text); border-left-color: var(--accent); background: rgba(255, 212, 0, 0.04); }
.nav-link .idx {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-3);
  width: 18px; flex-shrink: 0;
}
.nav-link.active .idx { color: var(--accent); }

.sidebar-foot {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--hairline);
  font-family: var(--font-mono); font-size: 10px; color: var(--text-3);
  line-height: 1.6;
}
.sidebar-foot .dot { display: inline-block; width: 6px; height: 6px; background: var(--ok); border-radius: 50%; vertical-align: middle; margin-right: 6px; box-shadow: 0 0 6px var(--ok); }

/* ─── topbar ─── */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--hairline);
  background: rgba(6, 8, 12, 0.7);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 5;
}
.crumbs { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); letter-spacing: 0.06em; }
.crumbs b { color: var(--text); font-weight: 500; }
.topbar-spacer { flex: 1; }
.kbd { font-family: var(--font-mono); font-size: 10px; padding: 2px 6px; border: 1px solid var(--hairline-strong); border-radius: 3px; color: var(--text-2); }
.toggle-group { display: flex; gap: 0; border: 1px solid var(--hairline-strong); border-radius: 4px; overflow: hidden; }
.toggle-group button { background: transparent; border: 0; color: var(--text-2); padding: 6px 12px; font-family: var(--font-mono); font-size: 11px; cursor: pointer; letter-spacing: 0.05em; }
.toggle-group button.on { background: var(--accent); color: var(--void); }
.toggle-group button:not(.on):hover { color: var(--text); background: rgba(255,255,255,0.03); }

/* ─── module hero ─── */
.module-head { padding: 36px 40px 28px; border-bottom: 1px solid var(--hairline); position: relative; }
.module-head .eyebrow {
  font-family: var(--font-mono); font-size: 11px; color: var(--accent); letter-spacing: 0.18em;
  display: inline-flex; gap: 10px; align-items: center; margin-bottom: 14px;
}
.module-head .eyebrow::before {
  content: ""; width: 10px; height: 1px; background: var(--accent);
}
.module-head h1 { margin: 0 0 12px; font-size: 44px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.05; max-width: 880px; }
.module-head h1 em { font-style: normal; color: var(--accent); }
.module-head p.lede { margin: 0; max-width: 720px; color: var(--text-2); font-size: 16px; line-height: 1.55; }
.module-head .meta { display: flex; gap: 20px; margin-top: 22px; font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
.module-head .meta span b { color: var(--text); font-weight: 500; }

/* ─── content wrap ─── */
.content { padding: 32px 40px 80px; }
.section-title {
  display: flex; align-items: baseline; gap: 14px;
  margin: 40px 0 20px;
}
.section-title .num { font-family: var(--font-mono); font-size: 11px; color: var(--accent); letter-spacing: 0.1em; }
.section-title h2 { margin: 0; font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
.section-title .line { flex: 1; height: 1px; background: var(--hairline); }

/* ─── panel ─── */
.panel {
  background: var(--panel);
  border: 1px solid var(--hairline);
  position: relative;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-2);
  letter-spacing: 0.08em;
}
.panel-head .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.panel-head .tag { font-family: var(--font-mono); font-size: 10px; padding: 2px 6px; border: 1px solid var(--hairline-strong); color: var(--text-3); letter-spacing: 0.06em; }
.panel-head .right { margin-left: auto; color: var(--text-3); }
.panel-body { padding: 18px; }

/* corner ticks */
.panel.ticks::before, .panel.ticks::after,
.panel.ticks > .tl, .panel.ticks > .tr, .panel.ticks > .bl, .panel.ticks > .br {
  content: ""; position: absolute; width: 10px; height: 10px; border: 1px solid var(--accent); pointer-events: none;
}
.panel.ticks::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel.ticks::after  { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.panel.ticks .bl { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.panel.ticks .br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* ─── controls ─── */
.ctrl-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--hairline); }
.ctrl-row:last-child { border-bottom: 0; }
.ctrl-row .label { flex: 0 0 130px; font-family: var(--font-mono); font-size: 11px; color: var(--text-2); letter-spacing: 0.06em; text-transform: uppercase; }
.ctrl-row .value { font-family: var(--font-mono); font-size: 12px; color: var(--accent); min-width: 60px; text-align: right; font-variant-numeric: tabular-nums; }
.ctrl-row input[type="range"] { flex: 1; -webkit-appearance: none; appearance: none; background: transparent; height: 16px; }
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--hairline-strong); }
input[type="range"]::-moz-range-track { height: 1px; background: var(--hairline-strong); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 12px; height: 12px; background: var(--accent); border: 0; border-radius: 0; margin-top: -6px; box-shadow: 0 0 8px var(--accent-dim); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; background: var(--accent); border: 0; border-radius: 0; cursor: pointer; }

select, input[type="text"], input[type="number"] {
  background: var(--void); color: var(--text); border: 1px solid var(--hairline-strong);
  font-family: var(--font-mono); font-size: 12px; padding: 6px 10px; border-radius: 0;
  outline: none;
}
select:focus, input:focus { border-color: var(--accent); }

button.btn {
  background: transparent; color: var(--text); border: 1px solid var(--hairline-strong);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 8px 14px; cursor: pointer; transition: all .15s;
}
button.btn:hover { border-color: var(--accent); color: var(--accent); }
button.btn.primary { background: var(--accent); color: var(--void); border-color: var(--accent); }
button.btn.primary:hover { background: #fff8c2; }
button.btn.danger:hover { border-color: var(--magenta); color: var(--magenta); }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em;
  padding: 3px 8px; border: 1px solid var(--hairline-strong); color: var(--text-2);
}
.chip.accent { color: var(--accent); border-color: var(--accent-dim); }
.chip.magenta { color: var(--magenta); border-color: var(--magenta-dim); }

/* readouts */
.readout { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text); }
.readout .k { color: var(--text-3); }
.readout .v { color: var(--accent); }

/* tensor shape labels */
.shape { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }
.shape b { color: var(--accent); font-weight: 500; }

/* canvas wrapper */
.canvas-wrap { position: relative; display: inline-block; }
.canvas-wrap canvas { display: block; image-rendering: pixelated; }

/* small text */
.small { font-size: 12px; color: var(--text-2); line-height: 1.6; }
.muted { color: var(--text-3); }
.mono  { font-family: var(--font-mono); }

/* === landing page === */
.hero {
  position: relative;
  padding: 80px 40px 100px;
  border-bottom: 1px solid var(--hairline);
  overflow: hidden;
}
.hero-grid { position: absolute; inset: 0; pointer-events: none; }
.hero .eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.2em; color: var(--accent); margin-bottom: 22px; display: inline-flex; align-items: center; gap: 12px;}
.hero .eyebrow::before { content: ""; width: 24px; height: 1px; background: var(--accent); }
.hero h1 {
  font-size: clamp(48px, 7vw, 96px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 0.96;
  margin: 0 0 28px;
  max-width: 1100px;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero h1 .strike { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--magenta); text-decoration-thickness: 2px; }
.hero .sub { font-size: 18px; color: var(--text-2); max-width: 640px; line-height: 1.55; margin: 0 0 36px; }
.hero-cta { display: flex; gap: 14px; align-items: center; }

.stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.stats-strip .stat { padding: 22px 28px; border-right: 1px solid var(--hairline); }
.stats-strip .stat:last-child { border-right: 0; }
.stats-strip .stat .v { font-family: var(--font-mono); font-size: 28px; color: var(--accent); font-variant-numeric: tabular-nums; }
.stats-strip .stat .k { font-family: var(--font-mono); font-size: 10px; color: var(--text-3); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 6px; }

/* module grid (landing) */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--hairline);
}
.module-card {
  grid-column: span 4;
  padding: 28px;
  border-right: 1px solid var(--hairline);
  border-top: 1px solid var(--hairline);
  text-decoration: none;
  color: var(--text);
  position: relative;
  transition: background .2s;
  min-height: 280px;
  display: flex; flex-direction: column;
}
.module-card:nth-child(3n) { border-right: 0; }
.module-card:hover { background: rgba(255, 212, 0, 0.025); }
.module-card .id { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); letter-spacing: 0.12em; }
.module-card .vis { flex: 1; margin: 18px 0; display: flex; align-items: center; justify-content: center; min-height: 120px; }
.module-card h3 { margin: 0 0 8px; font-size: 19px; font-weight: 500; letter-spacing: -0.01em; }
.module-card p { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.55; }
.module-card .arrow { position: absolute; top: 28px; right: 28px; color: var(--text-3); transition: color .2s, transform .2s; }
.module-card:hover .arrow { color: var(--accent); transform: translate(2px, -2px); }

@media (max-width: 1100px) {
  .module-card { grid-column: span 6; }
  .module-card:nth-child(3n) { border-right: 1px solid var(--hairline); }
  .module-card:nth-child(2n) { border-right: 0; }
}
@media (max-width: 700px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .module-card, .module-card:nth-child(3n), .module-card:nth-child(2n) { grid-column: span 12; border-right: 0; }
}

/* generic grid utils */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }

/* badge */
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* tooltip-ish callout */
.callout {
  border-left: 2px solid var(--accent);
  padding: 12px 16px;
  background: rgba(255, 212, 0, 0.03);
  font-size: 13px; color: var(--text-2);
  font-family: var(--font-display);
}
.callout b { color: var(--text); font-weight: 500; }

/* matrix cell */
.mat { display: inline-grid; gap: 2px; font-family: var(--font-mono); font-size: 12px; }
.mat .c {
  width: 32px; height: 32px; display: grid; place-items: center;
  background: var(--raised); border: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums;
}
.mat .c.hi { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.mat .c.hi2 { background: var(--magenta-dim); border-color: var(--magenta); color: var(--magenta); }

/* kbd hints row */
.hint-row { display: flex; gap: 16px; font-family: var(--font-mono); font-size: 11px; color: var(--text-3); margin-top: 18px; }
.hint-row span b { color: var(--text-2); font-weight: 400; }

/* progress bar */
.prog { height: 2px; background: var(--hairline); position: relative; overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* scanline accent line */
.scan { position: relative; height: 1px; background: var(--hairline); overflow: hidden; }
.scan::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 25%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan 3.4s linear infinite;
}
@keyframes scan { from { left: -25%; } to { left: 100%; } }

/* utility */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.items-center { align-items: center; }
.between { justify-content: space-between; }
.w-full { width: 100%; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
