:root {
  --bg: #0e0f12;
  --panel: #16181d;
  --line: #262931;
  --text: #e6e3dc;
  --muted: #8d8a83;
  --accent: #f4a43a;
  --accent-2: #d4485a;
  font-family: ui-sans-serif, -apple-system, "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.6; }
main, .hero { max-width: 1180px; margin: 0 auto; padding: 0 28px; }
section { padding: 56px 0 24px; border-top: 1px solid var(--line); }
p { max-width: 74ch; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88em; color: var(--accent); }
h1 { font-size: clamp(42px, 6vw, 72px); letter-spacing: -.02em; margin: 8px 0 12px; line-height: 1; }
h2 { font-size: 28px; letter-spacing: -.01em; margin: 0 0 16px; }
h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; }
h3 small { text-transform: none; letter-spacing: 0; font-weight: normal; }
.num { color: var(--accent); font-variant-numeric: tabular-nums; margin-right: 6px; }
.kicker { color: var(--accent); font: 13px ui-monospace, Menlo, monospace; letter-spacing: .06em; margin-top: 56px; }
.lede { font-size: 19px; color: #cfcbc2; }
.note { color: var(--muted); font-size: 14px; }
canvas, img { image-rendering: auto; }
.pixelated { image-rendering: pixelated; }

button, .button {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 14px; font: inherit; font-size: 14px; cursor: pointer;
}
button:hover:not(:disabled), .button:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button[type=submit] { background: var(--accent); color: #1b1408; border-color: var(--accent); font-weight: 600; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

.status { display: flex; align-items: center; gap: 14px; margin: 26px 0 40px; color: var(--muted); font-size: 14px; }
.bar { width: 240px; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
#progress { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.status.ready .bar { display: none; }

/* 1 — architecture */
.arch-strip { display: flex; align-items: center; gap: 3px; overflow-x: auto; padding: 20px 0; min-height: 190px; }
.arch-strip .blk { border-radius: 3px; cursor: pointer; flex: none; position: relative; transition: transform .15s; }
.arch-strip .conv { background: linear-gradient(180deg, #f4a43a, #c8642a); }
.arch-strip .pool { background: #3a3e48; width: 6px; }
.arch-strip .fc { background: linear-gradient(180deg, #d4485a, #8e2a4a); width: 18px; }
.arch-strip .blk:hover, .arch-strip .blk.active { transform: scaleY(1.06); outline: 2px solid var(--text); }
.arch-strip .gap { width: 14px; flex: none; }
.arch-info { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 18px;
  font: 14px ui-monospace, Menlo, monospace; color: #cfcbc2; min-height: 54px; }
.arch-info b { color: var(--accent); }

/* 2 — filters */
.filters { display: grid; grid-template-columns: repeat(16, 1fr); gap: 6px; max-width: 760px; margin: 22px 0; }
.filters canvas { width: 100%; aspect-ratio: 1; image-rendering: pixelated; border-radius: 2px; }

/* 3 — dissect */
.dissect-top { display: grid; grid-template-columns: 300px 1fr; gap: 36px; margin: 24px 0; }
.dropzone { position: relative; width: 300px; height: 300px; border: 1px dashed var(--line); border-radius: 8px; overflow: hidden; }
.dropzone.over { border-color: var(--accent); }
.dropzone canvas { width: 100%; height: 100%; display: block; }
.dropzone .hint { position: absolute; bottom: 6px; right: 10px; font-size: 12px; color: var(--muted); text-shadow: 0 0 4px #000; }
.samples { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 8px; }
.samples img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 3px; cursor: pointer; opacity: .75; }
.samples img:hover { opacity: 1; }
#webcam { width: 300px; border-radius: 6px; margin-top: 8px; }
.preds { list-style: none; padding: 0; margin: 0; max-width: 520px; }
.preds li { display: grid; grid-template-columns: 1fr 60px; gap: 10px; padding: 5px 8px; border-radius: 5px; cursor: pointer; position: relative; }
.preds li .fill { position: absolute; inset: 0 auto 0 0; background: rgba(244, 164, 58, .16); border-radius: 5px; z-index: -1; }
.preds li.active { outline: 1px solid var(--accent); }
.preds li span:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.preds { position: relative; z-index: 0; }
.cam-wrap canvas { width: 300px; height: 300px; border-radius: 8px; }

.layer-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 18px 0 10px; }
.layer-tabs button { font: 12px ui-monospace, Menlo, monospace; padding: 5px 9px; }
.layer-tabs button.active { border-color: var(--accent); color: var(--accent); }
.grid-controls { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.dissect-bottom { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--cell, 64px), 1fr)); gap: 3px;
  max-height: 720px; overflow-y: auto; padding-right: 4px; }
.channel-grid .cell { position: relative; cursor: pointer; }
.channel-grid canvas { width: 100%; aspect-ratio: 1; display: block; border-radius: 2px; }
.channel-grid .cell span { position: absolute; left: 2px; top: 0; font: 10px ui-monospace, Menlo, monospace; color: #fff; text-shadow: 0 0 3px #000; }
.channel-grid .cell.sel canvas { outline: 2px solid var(--accent); }
.channel-detail { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; position: sticky; top: 16px; }
.channel-detail canvas, .channel-detail img { width: 100%; border-radius: 6px; display: block; }
.channel-detail .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.channel-detail .pair div { font-size: 12px; color: var(--muted); }
.channel-detail .stats { font: 12px ui-monospace, Menlo, monospace; color: #cfcbc2; margin: 8px 0; }

/* 4 — dream */
.dream-layout { display: grid; grid-template-columns: 280px 1fr 260px; gap: 28px; margin-top: 22px; align-items: start; }
.dream-form label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; margin: 7px 0; color: #cfcbc2; }
.dream-form input, .dream-form select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px; font: inherit; font-size: 13px; width: 130px; }
.dream-form input[type=checkbox] { width: auto; }
.dream-form label:has(input[type=checkbox]) { justify-content: flex-start; }
.dream-out canvas { width: 100%; max-width: 520px; aspect-ratio: 1; border-radius: 8px; background: var(--panel); display: block; }
.dream-ref img { width: 100%; border-radius: 8px; background: var(--panel); aspect-ratio: 1; display: block; }

/* 5 — gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin: 22px 0; }
.gallery.small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.gallery figure { margin: 0; cursor: pointer; }
.gallery img { width: 100%; aspect-ratio: 1; border-radius: 6px; display: block; transition: transform .15s; }
.gallery img:hover { transform: scale(1.03); }
.gallery figcaption { font-size: 13px; margin-top: 6px; color: #cfcbc2; }
.gallery figcaption small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: 2px; }

footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 24px 0 60px; color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .dissect-top, .dissect-bottom, .dream-layout { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(8, 1fr); }
}

[hidden] { display: none !important; }

/* site navigation + overview */
.site-nav { position: sticky; top: 0; z-index: 10; display: flex; gap: 2px; flex-wrap: wrap; padding: 8px 28px;
  background: rgba(14, 15, 18, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); font-size: 14px; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 5px; }
.site-nav a:hover { color: var(--text); }
.site-nav a.active { color: var(--bg); background: var(--accent); }
.status.error { color: var(--accent-2); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin: 24px 0 64px; }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px;
  color: var(--text); text-decoration: none; transition: border-color .15s; }
.card:hover { border-color: var(--accent); }
.card h2 { font-size: 22px; margin: 0 0 2px; }
.card .meta { color: var(--accent); font: 12px ui-monospace, Menlo, monospace; letter-spacing: .04em; }
.card p { font-size: 14px; color: #cfcbc2; margin: 10px 0 0; }

/* layer-by-layer tables (js/layers.js) */
.layers { margin-top: 26px; }
.layers details { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; background: var(--panel); }
.layers summary { cursor: pointer; padding: 10px 14px; list-style-position: outside; }
.layers summary b { color: var(--text); }
.layers .lt-meta { font: 12px ui-monospace, Menlo, monospace; color: var(--accent); margin-left: 8px; }
.layers .lt-sum { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; max-width: 90ch; }
.layer-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.layer-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  padding: 6px 10px; border-top: 1px solid var(--line); }
.layer-table td { padding: 6px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.layer-table td:nth-child(1) { white-space: nowrap; }
.layer-table td:nth-child(2) { color: #cfcbc2; min-width: 120px; }
.layer-table td.num { font: 12px ui-monospace, Menlo, monospace; color: var(--muted); white-space: nowrap; }
.layer-table td:last-child { color: #cfcbc2; line-height: 1.45; }

/* architecture diagrams (js/diagram.js) */
.diagram { margin: 26px 0 8px; }
.diagram .d-scroll { overflow-x: auto; }
.arch-diagram { max-width: 100%; height: auto; display: block; font-family: ui-sans-serif, -apple-system, system-ui, sans-serif; }
.arch-diagram .d-label { fill: var(--text); font-size: 13px; font-weight: 600; }
.arch-diagram .d-sub { fill: #a9a59c; font-size: 11px; font-family: ui-monospace, Menlo, monospace; }
.arch-diagram .d-elabel { fill: #a9a59c; font-size: 11px; }
.arch-diagram .d-frame { fill: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.diagram .d-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.diagram .d-legend i { display: inline-block; width: 14px; height: 10px; border: 1.5px solid; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.diagram figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; max-width: 90ch; }

/* overview comparison (js/overview.js) */
.cmp-legend { display: flex; gap: 18px; font-size: 13px; color: #cfcbc2; margin: 14px 0 4px; }
.cmp-legend .sw, .cmp-table .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.cmp-chart { position: relative; max-width: 820px; }
.cmp-svg { width: 100%; height: auto; display: block; font-family: ui-sans-serif, -apple-system, system-ui, sans-serif; }
.cmp-svg .grid { stroke: #2c2f37; stroke-width: 1; }
.cmp-svg .grid.minor { stroke: #1f2228; }
.cmp-svg .tick { fill: var(--muted); font-size: 11px; font-family: ui-monospace, Menlo, monospace; }
.cmp-svg .name { fill: var(--text); font-size: 13px; }
.cmp-svg a:hover .name { fill: var(--accent); text-decoration: underline; }
.cmp-svg .guide { stroke: #24272e; stroke-width: 1; stroke-dasharray: 2 4; }
.cmp-svg .dot { stroke: var(--bg); stroke-width: 2; }
.cmp-svg .hit { fill: transparent; }
.cmp-svg .cmp-row.on .hit { fill: rgba(255, 255, 255, .04); }
.cmp-svg .cmp-row.on .dot { r: 8; }
.cmp-tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 10px; font-size: 12px; color: #cfcbc2; max-width: 260px; line-height: 1.45; }
.cmp-tip b { color: var(--text); }
.cmp-table-wrap { overflow-x: auto; }
.cmp-table { border-collapse: collapse; font-size: 13px; width: 100%; margin: 8px 0; }
.cmp-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600;
  padding: 6px 10px; border-bottom: 1px solid var(--line); }
.cmp-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); color: #cfcbc2; vertical-align: top; }
.cmp-table td:first-child a { color: var(--text); }
.cmp-table .num { text-align: right; font-family: ui-monospace, Menlo, monospace; white-space: nowrap; }
