:root {
  --bg: #141414;
  --surface: #181818;
  --elevated: #1e1e1e;
  --text: #e4e4e4;
  --text2: #e4e4e48d;
  --text3: #e4e4e45e;
  --stroke: #e4e4e433;
  --accent: #599ce7;
  --orange: #d08770;
  --cyan: #81a1c1;
  --blue: #7bafe9;
  --green: #3fa266;
  --purple: #9386f2;
  --yellow: #f1b467;
  --gray: #888;
  --warn: #f1b467;
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
  margin-bottom: 16px;
}

.subtitle {
  color: var(--text2);
  margin-top: 8px;
  font-size: 15px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--elevated);
  border: 1px solid var(--stroke);
  color: var(--text2);
}

.badge-accent { background: #599ce722; border-color: var(--accent); color: var(--accent); }
.badge-green { background: #3fa26622; border-color: var(--green); color: var(--green); }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 24px 0 0;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--stroke);
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text2);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.tab:hover { background: var(--elevated); color: var(--text); }
.tab.active { background: var(--accent); color: #191c22; font-weight: 600; }

.panel { display: none; padding-top: 20px; }
.panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text2);
}

.legend span { display: flex; align-items: center; gap: 6px; }

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--stroke);
}

.dot.orange { background: var(--orange); }
.dot.cyan { background: var(--cyan); }
.dot.blue { background: var(--blue); }
.dot.purple { background: var(--purple); }
.dot.green { background: var(--green); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.hint { font-size: 13px; color: var(--text3); margin-top: 12px; }

.flow-svg, .schematic-svg, .power-svg {
  width: 100%;
  height: auto;
  display: block;
}

.flow-svg .n { fill: var(--elevated); stroke-width: 2; }
.flow-svg .n.orange { stroke: var(--orange); }
.flow-svg .n.cyan { stroke: var(--cyan); }
.flow-svg .n.blue { stroke: var(--blue); }
.flow-svg .n.green { stroke: var(--green); }
.flow-svg .n.purple { stroke: var(--purple); }

.nt { fill: var(--text); font-size: 13px; font-weight: 600; }
.ns { fill: var(--text3); font-size: 10px; }

.wire { stroke: var(--accent); stroke-width: 2; }
.wire.usb { stroke: var(--purple); stroke-dasharray: 6 4; }

.zone { fill: none; stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.45; }
.orange-zone { stroke: var(--orange); }
.blue-zone { stroke: var(--blue); }

.zone-label { fill: var(--text3); font-size: 11px; font-weight: 600; }

.blk rect { fill: #e4e4e411; }
.orange-b { stroke: var(--orange); stroke-width: 1.5; fill: none; }
.cyan-b { stroke: var(--cyan); stroke-width: 1.5; fill: none; }
.blue-b { stroke: var(--blue); stroke-width: 1.5; fill: none; }
.green-b { stroke: var(--green); stroke-width: 1.5; fill: none; }
.purple-b { stroke: var(--purple); stroke-width: 1.5; fill: none; }
.gray-b { stroke: var(--gray); stroke-width: 1.5; fill: none; }

.bt { font-size: 11px; font-weight: 700; font-family: ui-monospace, monospace; }
.orange-t { fill: var(--orange); }
.cyan-t { fill: var(--cyan); }
.blue-t { fill: var(--blue); }
.green-t { fill: var(--green); }
.purple-t { fill: var(--purple); }
.gray-t { fill: var(--gray); }

.bl { fill: var(--text2); font-size: 10px; font-family: ui-monospace, monospace; }

.wire-l { stroke-width: 2; fill: none; }
.orange-w { stroke: var(--orange); }
.cyan-w { stroke: var(--cyan); }
.blue-w { stroke: var(--blue); }
.green-w { stroke: var(--green); }
.purple-w { stroke: var(--purple); }
.yellow-w { stroke: var(--yellow); }
.dashed { stroke-dasharray: 5 3; }

.pblk { stroke-width: 1.5; fill: var(--elevated); }
.yellow-b { stroke: var(--yellow); }
.pt { fill: var(--text); font-size: 11px; font-weight: 600; }
.ps { fill: var(--text3); font-size: 9px; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--stroke);
}

th {
  color: var(--text2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td { color: var(--text); }
td:first-child { font-family: ui-monospace, monospace; color: var(--accent); }

.callout {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text2);
  margin-top: 12px;
  border-left: 3px solid var(--accent);
  background: #e4e4e40a;
}

.callout.warn { border-left-color: var(--warn); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  background: var(--elevated);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.stat.accent .sv { color: var(--accent); }

.sv { display: block; font-size: 22px; font-weight: 600; }
.sl { display: block; font-size: 11px; color: var(--text3); margin-top: 4px; }

.dsp-chain {
  list-style: none;
  counter-reset: dsp;
}

.dsp-chain li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 4px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--stroke);
  align-items: start;
}

.dsp-chain li::before {
  counter-increment: dsp;
  content: counter(dsp);
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: #191c22;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dsp-chain strong { grid-column: 2; font-size: 14px; }
.dsp-chain span { grid-column: 2; font-size: 13px; color: var(--text2); }
.dsp-chain em { grid-column: 3; grid-row: 1 / 3; font-size: 11px; color: var(--text3); font-style: normal; align-self: center; }

.code-details {
  margin-top: 20px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  overflow: hidden;
}

.code-details summary {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  background: var(--elevated);
}

.code-details pre {
  padding: 16px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  color: var(--text2);
  overflow-x: auto;
  background: #e4e4e40a;
}

.footer {
  margin-top: 32px;
  font-size: 12px;
  color: var(--text3);
  text-align: center;
}

@media (max-width: 900px) {
  .flow-svg { overflow-x: auto; min-width: 900px; }
}
