:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --ink: #14161a;
  --sub: #55585f;
  --line: #14161a;
  --line-soft: #c7c8c4;
  --accent: #b3491d;
  --accent-2: #1d4e89;
  --removed: #b3491d;
  --added: #1d6b3f;
  --grid: #e3e3df;
  --mono: "IBM Plex Mono", "Consolas", "SFMono-Regular", monospace;
  --sans: "IBM Plex Sans", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
}

*, *::before, *::after { border-radius: 0 !important; }

a { color: var(--accent-2); text-decoration: none; }

/* -------------------------------------------------- layout */

#shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

#nav {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 20px 0 40px;
}

#nav .brand {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sub);
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 10px;
}

#nav .brand strong {
  display: block;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: 0;
  margin-bottom: 4px;
}

#nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

#nav li { border-bottom: 1px solid transparent; }

#nav a {
  display: flex;
  gap: 10px;
  padding: 7px 20px;
  color: var(--sub);
  font-size: 12.5px;
  border-left: 2px solid transparent;
}

#nav a:hover { color: var(--ink); background: var(--grid); }

#nav a.active {
  color: var(--ink);
  border-left-color: var(--accent);
  background: var(--grid);
  font-weight: 600;
}

#nav .idx { font-family: var(--mono); color: var(--sub); min-width: 20px; }

#nav .group-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sub);
  padding: 14px 20px 4px;
}

main { padding: 32px 40px 120px; max-width: 1280px; }

header.top {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 22px 26px;
  margin-bottom: 28px;
}

header.top h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

header.top p {
  margin: 0;
  color: var(--sub);
  font-size: 13px;
  max-width: 900px;
}

header.top .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 12px;
}

header.top .meta-row span b { color: var(--ink); }
header.top .meta-row span { color: var(--sub); }

/* -------------------------------------------------- sections */

section.step {
  border: 1px solid var(--line);
  background: var(--panel);
  margin-bottom: 28px;
  scroll-margin-top: 18px;
}

section.step .step-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

section.step .step-head .num {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--sub);
  border: 1px solid var(--line-soft);
  padding: 2px 8px;
}

section.step .step-head h2 {
  margin: 0;
  font-size: 17px;
  flex: 1;
}

section.step .step-head .tag {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sub);
}

section.step .step-head .tag.v1 { border-color: var(--accent); color: var(--accent); }
section.step .step-head .tag.v2 { border-color: var(--accent-2); color: var(--accent-2); }

.step-body {
  display: grid;
  grid-template-columns: 320px 1fr;
}

.step-body.stacked { grid-template-columns: 1fr; }

.text-panel {
  border-right: 1px solid var(--line);
  padding: 18px 22px;
}

.step-body.stacked .text-panel { border-right: none; border-bottom: 1px solid var(--line-soft); }

.text-panel p { margin: 0 0 10px; color: var(--ink); font-size: 13.2px; }
.text-panel p:last-child { margin-bottom: 0; }
.text-panel .label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--sub); margin: 12px 0 4px; }
.text-panel .label:first-child { margin-top: 0; }
.text-panel ul { margin: 4px 0 0; padding-left: 18px; }
.text-panel li { font-size: 12.6px; margin-bottom: 4px; color: var(--sub); }
.text-panel code { font-family: var(--mono); font-size: 11.5px; background: var(--grid); padding: 1px 4px; }

.viz-panel {
  padding: 18px 22px;
  overflow: auto;
}

.viz-panel svg { display: block; background: var(--panel); max-width: 100%; height: auto; }
.viz-panel .caption { font-family: var(--mono); font-size: 11px; color: var(--sub); margin-top: 8px; }

.note-box {
  border: 1px dashed var(--line-soft);
  padding: 8px 10px;
  font-size: 11.6px;
  color: var(--sub);
  margin-top: 10px;
  background: var(--bg);
}

/* -------------------------------------------------- operator grid */

.op-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
}

.op-grid .op-card {
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 16px 20px;
}

.op-grid .op-card:nth-child(2n) { border-right: none; }

.op-card .op-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.op-card .op-title h3 {
  margin: 0;
  font-size: 14px;
}

.op-card .op-title .key {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--sub);
}

.op-card .op-desc { font-size: 12.4px; color: var(--sub); margin: 0 0 10px; }
.op-card svg { display: block; max-width: 100%; height: auto; margin-top: 6px; }

.delta-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  margin-bottom: 8px;
}

.delta-bar {
  flex: 1;
  height: 14px;
  background: var(--grid);
  position: relative;
  border: 1px solid var(--line-soft);
}

.delta-bar .fill { position: absolute; top: 0; bottom: 0; left: 0; }
.delta-bar .fill.removed { background: var(--removed); }
.delta-bar .fill.added { background: var(--added); }

.sample-list { font-family: var(--mono); font-size: 11px; margin: 0; padding: 0; list-style: none; max-height: 130px; overflow-y: auto; border-top: 1px solid var(--line-soft); }
.sample-list li { padding: 4px 0; border-bottom: 1px solid var(--grid); color: var(--sub); }
.sample-list li b { color: var(--ink); }
.sample-list .rm { color: var(--removed); }
.sample-list .ad { color: var(--added); }

/* -------------------------------------------------- legend / misc */

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-family: var(--mono); font-size: 11px; color: var(--sub); margin-bottom: 10px; }
.legend .sw { display: inline-block; width: 9px; height: 9px; margin-right: 5px; vertical-align: -1px; border: 1px solid var(--line); }

.stat-strip { display: flex; gap: 0; border: 1px solid var(--line-soft); margin-bottom: 14px; }
.stat-strip .stat { flex: 1; padding: 8px 12px; border-right: 1px solid var(--line-soft); }
.stat-strip .stat:last-child { border-right: none; }
.stat-strip .stat .v { font-family: var(--mono); font-size: 16px; display: block; }
.stat-strip .stat .k { font-size: 10.5px; color: var(--sub); text-transform: uppercase; letter-spacing: 0.04em; }

table.data-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 11.5px; }
table.data-table th, table.data-table td { border: 1px solid var(--line-soft); padding: 5px 8px; text-align: left; }
table.data-table th { background: var(--grid); font-weight: 600; }

.schematic-flow { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }
.schematic-flow .box { border: 1px solid var(--line); padding: 10px 14px; font-size: 12px; min-width: 120px; text-align: center; background: var(--panel); }
.schematic-flow .arrow { display: flex; align-items: center; padding: 0 8px; font-family: var(--mono); color: var(--sub); }
.schematic-flow .box .t { font-weight: 600; margin-bottom: 3px; }
.schematic-flow .box .s { font-size: 10.5px; color: var(--sub); }
.schematic-flow .box.accent { border-color: var(--accent); }
.schematic-flow .box.accent2 { border-color: var(--accent-2); }

footer.foot {
  border: 1px solid var(--line-soft);
  padding: 14px 22px;
  font-size: 11.5px;
  color: var(--sub);
  font-family: var(--mono);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-soft); }
::-webkit-scrollbar-track { background: transparent; }
