:root {
	--ink: #111418;
	--muted: #5c6773;
	--line: #e4e8ec;
	--bg: #fff;
	--panel: #fafbfc;
	--accent: #2f6df6;
	--warn: #c2410c;
	--ok: #15803d;
	--sa: #2f6df6;
	--sb: #0f766e;
	--sc: #b45309;
	--sd: #7c3aed;
	--mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

html[data-theme='dark'] {
	--ink: #e8ecf1;
	--muted: #8b97a5;
	--line: #232a33;
	--bg: #0d1117;
	--panel: #131920;
	--accent: #5b8dff;
	--warn: #fb923c;
	--ok: #4ade80;
	--sa: #5b8dff;
	--sb: #2dd4bf;
	--sc: #fbbf24;
	--sd: #c4b5fd;
}

* {
	box-sizing: border-box;
}

html {
	scroll-behavior: smooth;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 400 17px/1.6 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	-webkit-font-smoothing: antialiased;
	transition: background 0.2s, color 0.2s;
}

.wrap {
	max-width: 720px;
	margin: 0 auto;
	padding: 0 24px;
}

/* Theme toggle */
.theme {
	position: fixed;
	top: 20px;
	right: 20px;
	z-index: 10;
	font-family: var(--mono);
	font-size: 12px;
	color: var(--ink);
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 6px 12px;
	cursor: pointer;
}

.theme:hover {
	border-color: var(--accent);
	color: var(--accent);
}

[data-dark] {
	display: none;
}

html[data-theme='dark'] [data-light] {
	display: none;
}

html[data-theme='dark'] [data-dark] {
	display: inline;
}

/* Hero */
.hero {
	padding: 120px 0 72px;
	border-bottom: 1px solid var(--line);
}

.avatar {
	display: block;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	object-fit: cover;
	margin: 0 0 24px;
}

.eyebrow {
	margin: 0 0 20px;
	font-family: var(--mono);
	font-size: 13px;
	color: var(--muted);
}

h1 {
	margin: 0 0 20px;
	font-size: clamp(40px, 8vw, 60px);
	font-weight: 700;
	letter-spacing: -0.03em;
	line-height: 1.05;
}

.lede {
	margin: 0 0 32px;
	font-size: 20px;
	line-height: 1.5;
	color: var(--muted);
	max-width: 34em;
}

.links {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.links a,
.copy {
	font-family: var(--mono);
	font-size: 13px;
	text-decoration: none;
	color: var(--ink);
	background: none;
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 7px 14px;
	cursor: pointer;
	transition: border-color 0.15s, color 0.15s;
}

.links a:hover,
.copy:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.copy.done {
	border-color: var(--ok);
	color: var(--ok);
}

/* Sections */
main {
	padding: 8px 24px 0;
}

section {
	padding: 64px 0;
	border-bottom: 1px solid var(--line);
}

h2 {
	margin: 0 0 12px;
	font-family: var(--mono);
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--muted);
}

h3 {
	margin: 0 0 6px;
	font-size: 17px;
	font-weight: 600;
	letter-spacing: -0.01em;
}

.note {
	margin: 0 0 24px;
	font-size: 15px;
	color: var(--muted);
}

.disclaimer {
	margin: 16px 0 0;
	font-family: var(--mono);
	font-size: 11px;
	color: var(--muted);
}

/* Focus cards */
.grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 28px;
	margin-top: 20px;
}

.card p {
	margin: 0;
	font-size: 15px;
	color: var(--muted);
}

/* Chips */
.chip {
	font-family: var(--mono);
	font-size: 12px;
	color: var(--muted);
	background: none;
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: 5px 13px;
	cursor: pointer;
	transition: all 0.15s;
}

.chip:hover {
	color: var(--accent);
	border-color: var(--accent);
}

.chip.on {
	color: var(--bg);
	background: var(--ink);
	border-color: var(--ink);
}

.tabs,
.filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 20px 0 24px;
}

/* Diagrams */
.diagram {
	margin: 0;
	position: relative;
	left: 50%;
	transform: translateX(-50%);
	width: min(96vw, 1060px);
}

.dgscroll {
	overflow-x: auto;
}

.dgscroll svg {
	min-width: 680px;
}

.diagram.hidden {
	display: none;
}

.diagram svg {
	width: 100%;
	height: auto;
	overflow: visible;
}

.node rect {
	fill: var(--panel);
	stroke: var(--line);
	stroke-width: 1.5;
	transition: stroke 0.15s, fill 0.15s;
}

.node text {
	fill: var(--ink);
	font-family: 'Inter', sans-serif;
	font-size: 13px;
	font-weight: 500;
	text-anchor: middle;
}

.node text.sub {
	fill: var(--muted);
	font-family: var(--mono);
	font-size: 10px;
	font-weight: 400;
}

.node {
	cursor: pointer;
}

.node:hover rect,
.node:focus rect {
	stroke: var(--accent);
}

.node:focus {
	outline: none;
}

.node.sel rect {
	stroke: var(--accent);
	stroke-width: 2.5;
}

.node.hot rect {
	fill: color-mix(in srgb, var(--accent) 9%, var(--panel));
	stroke: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.node.ok rect {
	stroke: var(--ok);
}

.node.bad rect {
	stroke: var(--warn);
}

.node.alt rect {
	stroke-dasharray: 4 3;
}

.edge {
	stroke: var(--muted);
	stroke-width: 1.5;
	fill: none;
}

.edge.dash {
	stroke-dasharray: 4 4;
}

.head {
	fill: var(--muted);
}

.elabel {
	fill: var(--muted);
	font-family: var(--mono);
	font-size: 10px;
	text-anchor: middle;
}

figcaption {
	margin: 16px auto 0;
	max-width: 672px;
	font-size: 14px;
	color: var(--muted);
	min-height: 2.8em;
}

figcaption strong {
	color: var(--ink);
	font-weight: 600;
}

/* Demos */
.demo {
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 22px;
	background: var(--panel);
}

.stages {
	display: grid;
	gap: 20px;
}

.stage {
	display: grid;
	grid-template-columns: 92px 1fr 70px;
	grid-template-areas:
		'nm bar ct'
		'nm sld kp';
	gap: 7px 12px;
	align-items: center;
}

.stage .nm {
	grid-area: nm;
	font-family: var(--mono);
	font-size: 12px;
	color: var(--muted);
}

.stage .bar {
	grid-area: bar;
}

.stage .ct {
	grid-area: ct;
	font-family: var(--mono);
	font-size: 12px;
	text-align: right;
	color: var(--ink);
}

.stage .kp {
	grid-area: kp;
	font-family: var(--mono);
	font-size: 10px;
	text-align: right;
	color: var(--muted);
}

.bar {
	position: relative;
	height: 22px;
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 5px;
	overflow: hidden;
}

.fill {
	position: absolute;
	inset: 0 auto 0 0;
	background: color-mix(in srgb, var(--accent) 22%, transparent);
	border-right: 2px solid var(--accent);
	transition: width 0.18s ease;
}

.stage input[type='range'] {
	grid-area: sld;
	width: 100%;
	margin: 0;
	accent-color: var(--accent);
	cursor: pointer;
}

.dgscroll {
	overflow-x: auto;
}

.readout {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 12px;
	margin-top: 20px;
	padding-top: 18px;
	border-top: 1px solid var(--line);
}

.readout .k {
	display: block;
	font-family: var(--mono);
	font-size: 17px;
	color: var(--ink);
}

.readout .l {
	display: block;
	font-family: var(--mono);
	font-size: 10px;
	color: var(--muted);
	margin-top: 3px;
}

.readout .k.over {
	color: var(--warn);
}

.readout .k.under {
	color: var(--ok);
}

/* IWRR */
.iwrr {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 24px;
}

.qhead {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	font-family: var(--mono);
	font-size: 11px;
	color: var(--muted);
	margin-bottom: 6px;
}

.qrow {
	margin-bottom: 14px;
}

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 3px;
	align-content: flex-start;
}

.out {
	min-height: 108px;
	padding: 8px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--bg);
}

.it {
	font-family: var(--mono);
	font-size: 10px;
	line-height: 1;
	padding: 4px 5px;
	border-radius: 3px;
	border: 1px solid var(--line);
	background: var(--bg);
	color: var(--muted);
}

.it.a {
	border-color: var(--sa);
	color: var(--sa);
}

.it.b {
	border-color: var(--sb);
	color: var(--sb);
}

.it.c {
	border-color: var(--sc);
	color: var(--sc);
}

.out .it.a {
	background: color-mix(in srgb, var(--sa) 14%, transparent);
}

.out .it.b {
	background: color-mix(in srgb, var(--sb) 14%, transparent);
}

.out .it.c {
	background: color-mix(in srgb, var(--sc) 14%, transparent);
}

.it.new {
	outline: 2px solid var(--ink);
	outline-offset: 1px;
}

.it.gone {
	opacity: 0.28;
	text-decoration: line-through;
}

.it.re {
	border-style: dashed;
	font-style: italic;
}

.it.miss {
	border-bottom-width: 3px;
	border-bottom-color: var(--warn);
}

.legend {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	margin-top: 12px;
	font-family: var(--mono);
	font-size: 10px;
	color: var(--muted);
}

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

.readout.five {
	grid-template-columns: repeat(5, 1fr);
}

.wctrls {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 16px;
	margin-top: 20px;
	padding-top: 18px;
	border-top: 1px solid var(--line);
}

.wctrls label,
.wactions label {
	display: grid;
	gap: 5px;
	font-family: var(--mono);
	font-size: 11px;
	color: var(--muted);
}

.wctrls output,
.wactions output {
	color: var(--accent);
}

.wctrls input[type='range'],
.wactions input[type='range'] {
	width: 100%;
	margin: 0;
	accent-color: var(--accent);
	cursor: pointer;
}

.wactions {
	display: flex;
	flex-wrap: wrap;
	align-items: end;
	gap: 10px;
	margin-top: 16px;
}

.wactions label {
	min-width: 130px;
}

/* Top-K buffer */
.tkhead,
.tkbar {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	font-family: var(--mono);
	font-size: 11px;
	color: var(--muted);
}

.tkhead {
	margin-bottom: 10px;
}

.tkbar {
	margin-top: 12px;
}

.tkbar strong {
	color: var(--ink);
	font-weight: 500;
}

.tkPhase {
	color: var(--accent);
}

.tkslots {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

.slot {
	width: 38px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--mono);
	font-size: 10px;
	border-radius: 4px;
	border: 1px dashed var(--line);
	color: var(--muted);
	background: var(--bg);
}

.slot.fill {
	border-style: solid;
	border-color: var(--line);
	color: var(--ink);
}

.slot.keep {
	border-color: var(--accent);
	color: var(--accent);
	background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.slot.hot {
	outline: 2px solid var(--ink);
	outline-offset: 1px;
}

.slot.cut {
	border-color: var(--warn);
	color: var(--warn);
	opacity: 0.5;
}

/* Fused kernel optimization stack */
.ladhead {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	font-family: var(--mono);
	font-size: 11px;
	color: var(--muted);
	margin-bottom: 8px;
}

.ladTot {
	font-size: 20px;
	color: var(--accent);
}

.ladder {
	display: flex;
	height: 36px;
	border: 1px solid var(--line);
	border-radius: 5px;
	overflow: hidden;
	background: var(--bg);
}

.rung {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	font-family: var(--mono);
	font-size: 9px;
	color: #fff;
	white-space: nowrap;
	overflow: hidden;
	transition: width 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.rung.base {
	background: var(--muted);
}

.rung.k0 {
	background: var(--sa);
}

.rung.k1 {
	background: var(--warn);
}

.rung.k2 {
	background: var(--sd);
}

.rung.k3 {
	background: var(--sb);
}

.rung.k4 {
	background: var(--sc);
}

.rung.k5 {
	background: var(--ok);
}

.tricks {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	margin-top: 16px;
}

.trick {
	display: inline-flex;
	align-items: baseline;
	gap: 7px;
	text-align: left;
}

.trick em {
	font-style: normal;
	opacity: 0.65;
}

.trick .dot {
	width: 7px;
	height: 7px;
	border-radius: 2px;
	flex: none;
	background: currentColor;
	opacity: 0.35;
}

.trick.on .dot {
	opacity: 1;
}

.trickwhy {
	margin: 14px 0 0;
	font-size: 14px;
	color: var(--muted);
	min-height: 2.6em;
}

.trickwhy strong {
	color: var(--ink);
	font-weight: 600;
}

/* Bloom filter */
.picker {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-top: 12px;
}

.pk {
	font-family: var(--mono);
	font-size: 11px;
	color: var(--muted);
	min-width: 96px;
}

.bits {
	display: flex;
	flex-wrap: wrap;
	gap: 3px;
}

.bit {
	width: 18px;
	height: 18px;
	border-radius: 3px;
	border: 1px solid var(--line);
	background: var(--bg);
	transition: background 0.15s, border-color 0.15s;
}

.bit.set {
	background: var(--accent);
	border-color: var(--accent);
}

.bit.touch {
	outline: 2px solid var(--ink);
	outline-offset: 1px;
}

.bit.hitfp {
	background: var(--warn);
	border-color: var(--warn);
}

.bit.clear {
	border-color: var(--ok);
	border-width: 2px;
}

.bloomsay {
	margin: 14px 0 0;
	font-size: 14px;
	color: var(--muted);
	min-height: 2.6em;
}

.bloomsay strong {
	color: var(--ink);
	font-weight: 600;
}

.bloomsay .bad {
	color: var(--warn);
}

.bloomsay .good {
	color: var(--ok);
}

/* Request slicing */
.slgrid {
	display: grid;
	grid-template-columns: repeat(24, 1fr);
	gap: 3px;
}

.cell {
	aspect-ratio: 1;
	border-radius: 3px;
	border: 1px solid var(--line);
	background: var(--bg);
}

.cell.ok1 {
	background: color-mix(in srgb, var(--accent) 55%, transparent);
	border-color: var(--accent);
}

.cell.dup {
	background: var(--warn);
	border-color: var(--warn);
}

.cell.gap {
	background: transparent;
	border: 2px dashed var(--warn);
}

.sw {
	display: inline-block;
	width: 10px;
	height: 10px;
	border-radius: 2px;
	flex: none;
}

.sw.ok1 {
	background: color-mix(in srgb, var(--accent) 55%, transparent);
	border: 1px solid var(--accent);
}

.sw.dup {
	background: var(--warn);
}

.sw.gap {
	border: 2px dashed var(--warn);
	background: transparent;
}

.slVerdict.bad {
	color: var(--warn);
}

.slVerdict.good {
	color: var(--ok);
}

/* Selected work */
.work {
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: w;
}

.work li {
	counter-increment: w;
	position: relative;
	padding: 0 0 4px 44px;
	border-bottom: 1px solid var(--line);
}

.work li:first-child {
	border-top: 1px solid var(--line);
}

.work li.out {
	display: none;
}

.work li::before {
	content: counter(w, decimal-leading-zero);
	position: absolute;
	left: 0;
	top: 20px;
	font-family: var(--mono);
	font-size: 12px;
	color: var(--accent);
}

.wtoggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	gap: 12px;
	padding: 16px 0;
	background: none;
	border: 0;
	color: inherit;
	text-align: left;
	cursor: pointer;
	font: inherit;
}

.caret {
	flex: none;
	width: 8px;
	height: 8px;
	border-right: 1.5px solid var(--muted);
	border-bottom: 1.5px solid var(--muted);
	transform: rotate(45deg);
	transition: transform 0.2s;
}

.wtoggle[aria-expanded='true'] .caret {
	transform: rotate(-135deg);
}

.wbody {
	display: grid;
	grid-template-rows: 0fr;
	transition: grid-template-rows 0.25s ease;
}

.wbody.open {
	grid-template-rows: 1fr;
}

.wbody>p {
	overflow: hidden;
	margin: 0;
	font-size: 15px;
	color: var(--muted);
}

.wbody.open>p {
	padding-bottom: 18px;
}

/* Timeline */
.timeline {
	margin: 20px 0 0;
	display: grid;
	gap: 16px;
}

.timeline div {
	display: grid;
	grid-template-columns: 150px 1fr;
	gap: 16px;
	align-items: baseline;
}

dt {
	font-family: var(--mono);
	font-size: 13px;
	color: var(--muted);
}

dd {
	margin: 0;
	font-size: 15px;
}

/* Footer */
footer {
	padding: 40px 24px 64px;
}

footer p {
	margin: 0;
	font-family: var(--mono);
	font-size: 12px;
	color: var(--muted);
}

@media (max-width: 620px) {
	.hero {
		padding: 84px 0 56px;
	}

	section {
		padding: 48px 0;
	}

	.timeline div {
		grid-template-columns: 1fr;
		gap: 2px;
	}

	.readout,
	.readout.five {
		grid-template-columns: repeat(2, 1fr);
		gap: 16px;
	}

	.iwrr {
		grid-template-columns: 1fr;
	}

	.wctrls {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	.stage {
		grid-template-columns: 72px 1fr 58px;
		gap: 6px 8px;
	}

	.demo {
		padding: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		transition: none !important;
		scroll-behavior: auto !important;
	}
}
