/* MotionFX docs */

:root {
	--bg: #0B0A10;
	--surface: #15121D;
	--border: #2A2536;
	--text: #ECE8F4;
	--muted: #A79FB8;
	--accent: #B28AFF;
	--accent-2: #FF6FA8;
	--accent-3: #FF8A5C;
	--brand-gradient: linear-gradient(135deg, #7D05C7 0%, #C21E9E 100%);
	--info: #FF6FA8;
	--danger: #FFA94D;

	--accent-soft: rgba(178, 138, 255, 0.12);
	--info-soft: rgba(255, 111, 168, 0.12);
	--danger-soft: rgba(255, 169, 77, 0.12);

	--sidebar: 272px;
	--topbar: 56px;
	--radius: 8px;
	--mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	--sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

	color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--topbar) + 16px); }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.65 var(--sans);
	-webkit-font-smoothing: antialiased;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: rgba(178, 138, 255, 0.3); }

/* ---------- Top bar ---------- */

.topbar {
	position: fixed;
	inset: 0 0 auto 0;
	height: var(--topbar);
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 0 20px;
	background: rgba(11, 10, 16, 0.88);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--border);
	z-index: 30;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--text);
	font-weight: 700;
	letter-spacing: -0.01em;
	white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand img { flex: none; display: block; height: 30px; width: auto; }
.brand small {
	font: 500 11px var(--mono);
	color: var(--muted);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 1px 8px;
}

.search {
	position: relative;
	margin-left: auto;
	width: min(320px, 100%);
}
.search input {
	width: 100%;
	height: 34px;
	padding: 0 12px 0 34px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	color: var(--text);
	font: inherit;
	font-size: 14px;
	outline: none;
}
.search input:focus { border-color: var(--accent); }
.search > svg {
	position: absolute;
	left: 11px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--muted);
	pointer-events: none;
}
.search kbd {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
}
.search input:focus ~ kbd, .search input:not(:placeholder-shown) ~ kbd { display: none; }

.results {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	max-height: 60vh;
	overflow-y: auto;
	margin: 0;
	padding: 6px;
	list-style: none;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.results[hidden] { display: none; }
.results a {
	display: block;
	padding: 7px 10px;
	border-radius: 6px;
	color: var(--text);
}
.results a:hover, .results a.active { background: var(--border); text-decoration: none; }
.results .r-title { font-family: var(--mono); font-size: 13px; }
.results .r-page { display: block; font-size: 12px; color: var(--muted); }
.results .empty { padding: 8px 10px; color: var(--muted); font-size: 14px; }

.menu-toggle {
	display: none;
	background: none;
	border: 1px solid var(--border);
	border-radius: 6px;
	color: var(--text);
	width: 34px;
	height: 34px;
	padding: 0;
	cursor: pointer;
}

/* ---------- Layout ---------- */

.sidebar {
	position: fixed;
	top: var(--topbar);
	bottom: 0;
	left: 0;
	width: var(--sidebar);
	overflow-y: auto;
	padding: 24px 16px 40px;
	border-right: 1px solid var(--border);
	background: var(--bg);
	z-index: 20;
}

.sidebar h4 {
	margin: 22px 10px 6px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--muted);
}
.sidebar h4:first-child { margin-top: 0; }

.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a {
	display: block;
	padding: 5px 10px;
	border-radius: 6px;
	color: var(--muted);
	font-size: 14px;
}
.sidebar a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.sidebar a.current {
	color: var(--accent);
	background: var(--accent-soft);
	font-weight: 500;
}
/* A link worth trying first (the effect builder) */
.sidebar a.featured {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	color: var(--text);
	border: 1px solid rgba(178, 138, 255, 0.35);
	background: linear-gradient(135deg, rgba(125, 5, 199, 0.16), rgba(194, 30, 158, 0.12));
}
.sidebar a.featured:hover { border-color: var(--accent); }
.sidebar a.featured.current { color: var(--text); border-color: var(--accent); }
.sidebar .badge {
	flex: none;
	padding: 1px 7px;
	border-radius: 999px;
	background: var(--brand-gradient);
	color: #FFFFFF;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.02em;
}
.sidebar ul ul a { padding-left: 22px; font-size: 13px; font-family: var(--mono); }

.main {
	margin-left: var(--sidebar);
	padding: calc(var(--topbar) + 40px) 48px 80px;
	display: grid;
	grid-template-columns: minmax(0, 780px) 200px;
	gap: 48px;
	justify-content: center;
}

.toc {
	position: sticky;
	top: calc(var(--topbar) + 40px);
	align-self: start;
	max-height: calc(100vh - var(--topbar) - 80px);
	overflow-y: auto;
	font-size: 13px;
}
.toc h5 {
	margin: 0 0 8px;
	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--muted);
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 3px 0 3px 12px; margin-left: -1px; color: var(--muted); border-left: 1px solid transparent; }
.toc a.sub { padding-left: 24px; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }

/* ---------- Content ---------- */

article { min-width: 0; }

article h1 {
	margin: 0 0 8px;
	font-size: 34px;
	line-height: 1.2;
	letter-spacing: -0.02em;
}
.lead { margin: 0 0 32px; font-size: 17px; color: var(--muted); }

article h2 {
	margin: 56px 0 16px;
	padding-top: 24px;
	border-top: 1px solid var(--border);
	font-size: 22px;
	letter-spacing: -0.01em;
}
article h3 { margin: 36px 0 12px; font-size: 17px; }
article h2 + h3 { margin-top: 20px; }

.anchor { color: inherit; }
.anchor:hover { text-decoration: none; }
.anchor:hover::after { content: " #"; color: var(--muted); font-weight: 400; }

p, ul, ol { margin: 0 0 16px; }
li { margin: 4px 0; }
strong { color: var(--text); font-weight: 600; }

code, pre, .sig, kbd {
	font-variant-ligatures: none;
}

code {
	font-family: var(--mono);
	font-size: 0.86em;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 1px 5px;
	overflow-wrap: anywhere;
}

kbd {
	font: 500 11px var(--mono);
	color: var(--muted);
	background: var(--bg);
	border: 1px solid var(--border);
	border-bottom-width: 2px;
	border-radius: 4px;
	padding: 1px 6px;
}

/* Code blocks */

.code {
	position: relative;
	margin: 0 0 20px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}
.code .label {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 6px 12px;
	border-bottom: 1px solid var(--border);
	font: 12px var(--mono);
	color: var(--muted);
}
.code pre {
	margin: 0;
	padding: 14px 16px;
	overflow-x: auto;
	font: 13px/1.6 var(--mono);
	tab-size: 4;
}
.code pre code { background: none; border: 0; padding: 0; font-size: inherit; overflow-wrap: normal; }

.copy {
	position: absolute;
	top: 6px;
	right: 6px;
	padding: 3px 8px;
	font: 12px var(--sans);
	color: var(--muted);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 5px;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.15s;
}
.code:hover .copy, .copy:focus-visible { opacity: 1; }
.copy:hover { color: var(--text); }
.copy.done { color: var(--accent); border-color: var(--accent); }
.code .label + pre + .copy, .code .label ~ .copy { top: 40px; }

/* Syntax tokens */
.tk-kw { color: var(--danger); }
.tk-str { color: #9BE38B; }
.tk-num { color: var(--accent-3); }
.tk-com { color: #857D9C; font-style: italic; }
.tk-type { color: var(--info); }
.tk-fn { color: #FFD27A; }
.tk-builtin { color: var(--info); }

/* API entries */

.api {
	margin: 0 0 28px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	overflow: hidden;
}
.api > header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 12px;
	padding: 14px 18px;
	border-bottom: 1px solid var(--border);
	background: rgba(42, 37, 54, 0.35);
}
.api > header h3 {
	margin: 0;
	font: 600 15px var(--mono);
	overflow-wrap: anywhere;
}
.api > header h3 a { color: var(--text); }
.api .body { padding: 16px 18px 4px; }
.api .body > .code { background: var(--bg); }
.sig {
	margin: 0 0 14px;
	padding: 10px 12px;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 6px;
	font: 13px/1.6 var(--mono);
	overflow-x: auto;
	white-space: pre;
}

.tag {
	display: inline-block;
	padding: 1px 8px;
	border-radius: 999px;
	font: 600 11px var(--mono);
	letter-spacing: 0.02em;
	border: 1px solid;
}
.tag.method { color: var(--accent); border-color: rgba(178, 138, 255, 0.4); background: var(--accent-soft); }
.tag.prop { color: var(--info); border-color: rgba(255, 111, 168, 0.4); background: var(--info-soft); }
.tag.type { color: var(--muted); border-color: var(--border); }
.tag.fn { color: #FFD27A; border-color: rgba(255, 210, 122, 0.35); }
.tag.warn { color: var(--danger); border-color: rgba(255, 169, 77, 0.4); background: var(--danger-soft); }
.tag.yields { color: var(--muted); border-color: var(--border); }

/* Tables */

.table-wrap { overflow-x: auto; margin: 0 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
td:first-child { white-space: nowrap; }
td code { white-space: nowrap; }
td .opt { color: var(--muted); font-size: 12px; }
tr:last-child td { border-bottom: 0; }

/* Callouts */

.callout {
	display: flex;
	gap: 12px;
	margin: 0 0 20px;
	padding: 12px 16px;
	border: 1px solid var(--border);
	border-left: 3px solid var(--info);
	border-radius: 6px;
	background: var(--info-soft);
	font-size: 14px;
}
.callout p:last-child { margin: 0; }
.callout strong:first-child { white-space: nowrap; }
.callout.tip { border-left-color: var(--accent); background: var(--accent-soft); }
.callout.warn { border-left-color: var(--danger); background: var(--danger-soft); }
.callout > div > :last-child { margin-bottom: 0; }

/* Driver curves (drive.html) */

.curve {
	margin: 0 0 16px;
	padding: 12px 14px 10px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--bg);
}
.curve svg { display: block; width: 100%; height: auto; overflow: visible; }
.curve polyline {
	fill: none;
	stroke-width: 2;
	stroke-linejoin: round;
	stroke-linecap: round;
	vector-effect: non-scaling-stroke;
}
.curve polyline.c1 { stroke: var(--accent); }
.curve polyline.c2 { stroke: var(--accent-2); }
.curve polyline.c3 { stroke: var(--muted); }
.curve polyline.dash { stroke-width: 1.5; stroke-dasharray: 5 4; }
.curve .axis { stroke: var(--border); }
.curve .tick { stroke: var(--border); stroke-dasharray: 2 4; }
.curve text { fill: var(--muted); font: 11px var(--mono); }
.curve figcaption {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 6px 16px;
	margin-top: 8px;
	font: 12px var(--mono);
	color: var(--muted);
}
.curve .legend i {
	display: inline-block;
	width: 14px;
	height: 2px;
	margin: 0 6px 3px 12px;
	vertical-align: middle;
}
.curve .legend i:first-child { margin-left: 0; }
.curve .legend i.c1 { background: var(--accent); }
.curve .legend i.c2 { background: var(--accent-2); }
.curve .legend i.c3 { background: var(--muted); }

/* Driver × primitive table (primitives.html) */

.fit .yes { color: var(--accent); font-weight: 600; }
.fit .via { color: var(--accent-3); }
.fit .no { color: var(--muted); }
.recipes td code { white-space: normal; }

/* The three ways to build an effect: "you are here" bar and the home page list */

.path {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 8px;
	margin: 0 0 10px;
	counter-reset: none;
}
.path a {
	position: relative;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--muted);
}
.path a:hover { text-decoration: none; border-color: var(--muted); color: var(--text); }
.path a + a::before {
	content: "";
	position: absolute;
	left: -9px;
	top: 50%;
	width: 8px;
	border-top: 1px solid var(--border);
}
.path strong { display: block; font-size: 13px; font-weight: 600; color: inherit; }
.path small { display: block; font-size: 12px; color: var(--muted); }
.path .n, .ways .n {
	flex: none;
	display: inline-grid;
	place-items: center;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: 1px solid var(--border);
	font: 600 12px var(--mono);
	color: var(--muted);
}
.path a.current { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.path a.current .n { background: var(--brand-gradient); border-color: transparent; color: #FFFFFF; }
.path-note { margin: 0 0 28px; font-size: 14px; color: var(--muted); }
.path-note strong { color: var(--text); }

.ways { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 10px; }
.ways li {
	margin: 0;
	padding: 14px 16px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}
.ways li > a { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--text); }
.ways li > a:hover { text-decoration: none; }
.ways li > a:hover strong { color: var(--accent); }
.ways strong { font-size: 15px; }
.ways small { font-size: 13px; color: var(--muted); }
.ways li:first-child .n { background: var(--brand-gradient); border-color: transparent; color: #FFFFFF; }
.ways p { margin: 6px 0 0 32px; font-size: 14px; color: var(--muted); }

@media (max-width: 640px) {
	.path { grid-template-columns: minmax(0, 1fr); }
	.path a + a::before { display: none; }
	.ways p { margin-left: 0; }
}

/* Ready-made tracks (tracks.html) */

.built { font-size: 13px; color: var(--muted); }
.built code { overflow-wrap: anywhere; }

/* Effect builder (builder.html) */

#builder input, #builder select, #overlay-maker input:not([type="file"]), #overlay-maker select {
	font: 14px var(--sans);
	color: var(--text);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 6px 8px;
}
#builder input:focus-visible, #builder select:focus-visible, #builder button:focus-visible,
#overlay-maker input:focus-visible, #overlay-maker select:focus-visible, #overlay-maker button:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}
.b-settings {
	display: flex;
	flex-wrap: wrap;
	gap: 12px 20px;
	margin: 0 0 8px;
	padding: 14px 16px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}
.b-settings label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.b-settings label[hidden] { display: none; }
.b-settings input[type="text"] { width: 180px; font-family: var(--mono); }
.b-settings input[type="number"] { width: 90px; }

.b-settings .share { align-self: flex-end; margin-left: auto; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.b-settings select { min-width: 150px; }

/* The builder page is wider than the others, and on wide screens the preview sits beside the tracks */
.main:has(#builder) { grid-template-columns: minmax(0, 1240px); }
.main:has(#builder) .toc { display: none; }
@media (min-width: 1240px) {
	.b-layout {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
		gap: 28px;
		align-items: start;
	}
	.b-side { order: 2; position: sticky; top: calc(var(--topbar) + 16px); }
	.b-sticky { max-height: calc(100vh - var(--topbar) - 32px); overflow-y: auto; scrollbar-width: thin; }
	.b-layout h2 { margin-top: 32px; }
	/* narrower track cards: controls above the curve */
	.b-main .bt-body { grid-template-columns: minmax(0, 1fr); }
}

.b-transport .scene-pick { display: flex; align-items: center; gap: 6px; color: var(--muted); }
#builder .b-transport select { padding: 3px 6px; font-size: 13px; }

.b-preview {
	margin: 0 0 8px;
	padding: 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}
.stage {
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	border-radius: 6px;
	background: #000000;
}
.stage canvas, .stage .tint { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage .tint { mix-blend-mode: multiply; pointer-events: none; }
.stage .sound-chip, .stage .stage-note {
	position: absolute;
	padding: 3px 8px;
	border-radius: 999px;
	font: 12px var(--mono);
	color: #FFFFFF;
	background: rgba(11, 10, 16, 0.65);
}
.stage .sound-chip { top: 10px; left: 10px; }
.stage .sound-chip[hidden] { display: none; }
.stage .stage-note { right: 10px; bottom: 10px; color: rgba(255, 255, 255, 0.75); }
.b-transport {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 14px;
	margin: 10px 0;
	font-size: 13px;
}
.b-transport .btn { padding: 6px 14px; font-size: 13px; cursor: pointer; }
.b-transport .btn:disabled { opacity: 0.4; cursor: default; }
.b-transport .check { display: flex; align-items: center; gap: 6px; }
.b-transport .intensity { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.b-transport .intensity input { width: 110px; padding: 0; border: 0; background: none; accent-color: var(--accent); }
.b-transport output { font: 12px var(--mono); color: var(--text); min-width: 2.5em; }
.b-transport .clock { margin-left: auto; font: 12px var(--mono); color: var(--muted); }

.timeline { display: block; width: 100%; cursor: pointer; touch-action: none; user-select: none; }
.timeline .grid { stroke: var(--border); stroke-dasharray: 2 4; }
.timeline .tick { fill: var(--muted); font: 10px var(--mono); }
.timeline .lane-label { fill: var(--text); font: 12px var(--mono); }
.timeline .lane-line { stroke: var(--border); }
.timeline .area { stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.timeline .area.c1 { fill: rgba(178, 138, 255, 0.25); stroke: var(--accent); }
.timeline .area.c2 { fill: rgba(255, 111, 168, 0.22); stroke: var(--accent-2); }
.timeline .area.c3 { fill: rgba(255, 138, 92, 0.22); stroke: var(--accent-3); }
.timeline .dot.c1 { fill: var(--accent); }
.timeline .dot.c2 { fill: var(--accent-2); }
.timeline .dot.c3 { fill: var(--accent-3); }
.timeline .held { stroke: var(--muted); stroke-dasharray: 4 4; }
.timeline .held-label { fill: var(--muted); font: 10px var(--sans); }
.timeline .playhead { stroke: #FFFFFF; stroke-width: 1.5; }

.add { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.add .btn.custom { border-style: dashed; border-color: var(--accent); color: var(--accent); }
.bt.custom { border-color: rgba(178, 138, 255, 0.45); }
.controls .hint { font-size: 12px; color: var(--muted); }
.add .btn { padding: 6px 12px; font-size: 13px; cursor: pointer; }

.bt-list .empty { color: var(--muted); }
.bt {
	margin: 0 0 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}
.bt > header {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 12px;
	padding: 10px 14px;
	border-bottom: 1px solid var(--border);
}
.bt > header h3 { margin: 0; font: 600 14px var(--mono); }
.bt > header span { flex: 1; font-size: 13px; color: var(--muted); }
.bt > header em { font-style: normal; font: 11px var(--mono); padding: 1px 6px; margin-left: 4px; border: 1px solid var(--border); border-radius: 4px; }
.bt .remove, .bt .duplicate {
	font: 12px var(--sans);
	color: var(--muted);
	background: none;
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 3px 8px;
	cursor: pointer;
}
.bt .remove:hover { color: var(--danger); border-color: var(--danger); }
.bt .duplicate:hover { color: var(--accent); border-color: var(--accent); }
.bt-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 14px; }
.bt .curve { margin: 0; align-self: start; }
.controls {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) 4.5em;
	align-items: center;
	gap: 8px 10px;
	font-size: 13px;
}
.controls > label { color: var(--muted); }
.controls input[type="range"] { width: 100%; padding: 0; border: 0; background: none; accent-color: var(--accent); }
.controls input:disabled { opacity: 0.4; }
.controls output { font: 12px var(--mono); text-align: right; color: var(--text); }
.controls .check { display: flex; align-items: center; gap: 6px; color: var(--text); }
.controls .color-row { display: flex; align-items: center; gap: 8px; }
.controls input[type="color"] { width: 44px; height: 28px; padding: 2px; cursor: pointer; }

.code-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 0 0 8px; }
.code-bar .style-tabs { margin: 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
	position: relative;
	width: 32px;
	height: 18px;
	border-radius: 9px;
	background: var(--border);
	transition: background 0.15s;
}
.switch .track::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--muted);
	transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .track { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); background: var(--accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.style-tabs { display: inline-flex; margin: 0 0 8px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.style-tabs button {
	font: 600 13px var(--sans);
	color: var(--muted);
	background: var(--bg);
	border: 0;
	padding: 7px 14px;
	cursor: pointer;
}
.style-tabs button[aria-pressed="true"] { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 -2px 0 var(--accent); }
.style-note { font-size: 13px; color: var(--muted); }
#builder .copy-live { opacity: 1; }

@media (max-width: 860px) {
	.bt-body { grid-template-columns: minmax(0, 1fr); }
}

/* Overlay maker (overlay-maker.html) */

.o-drop {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	margin: 0 0 16px;
	padding: 28px 16px;
	border: 1px dashed var(--accent);
	border-radius: var(--radius);
	background: var(--accent-soft);
	text-align: center;
	cursor: pointer;
}
.o-drop.over { background: rgba(178, 138, 255, 0.22); }
.o-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.o-drop small { color: var(--muted); }
.o-error { color: var(--danger); }
.o-error[hidden], .o-warn[hidden], #o-controls[hidden], #o-results[hidden] { display: none; }
.o-source video { display: block; width: 100%; max-height: 320px; margin: 0 0 8px; border-radius: 6px; background: #000000; }
.o-settings { margin: 0 0 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.o-settings input[type="text"] { font-family: var(--mono); }
.o-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.o-stats strong { color: var(--text); }
.o-warn { display: block; }
#o-make { cursor: pointer; }
#o-make:disabled { opacity: 0.45; cursor: default; }
#o-progress { width: 100%; height: 8px; accent-color: var(--accent); }
#o-progress[hidden] { display: none; }
.hint { font-size: 13px; color: var(--muted); }

/* transparency shows as a checkerboard */
.checker, .o-preview-box canvas, .o-sheet img {
	background-color: #2a2536;
	background-image:
		linear-gradient(45deg, #3a3448 25%, transparent 25%, transparent 75%, #3a3448 75%),
		linear-gradient(45deg, #3a3448 25%, transparent 25%, transparent 75%, #3a3448 75%);
	background-size: 16px 16px;
	background-position: 0 0, 8px 8px;
}
.o-result-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; margin: 0 0 12px; }
.o-preview-box { margin: 0; }
.o-preview-box canvas { display: block; width: 100%; height: auto; border-radius: 6px; image-rendering: auto; }
.o-preview-box figcaption { margin-top: 6px; font-size: 12px; color: var(--muted); }
.o-steps { margin: 0; padding-left: 20px; font-size: 14px; }
.o-sheets { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 0 0 20px; }
.o-sheet { margin: 0; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.o-sheet img { display: block; width: 100%; height: auto; border-radius: 4px; }
.o-sheet figcaption { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font: 12px var(--mono); color: var(--muted); }
.o-sheet .btn { padding: 4px 10px; font-size: 12px; }
#overlay-maker .copy-live { opacity: 1; }

@media (max-width: 720px) {
	.o-result-top { grid-template-columns: minmax(0, 1fr); }
}

/* Home */

.hero {
	margin: 0 0 40px;
	padding: 36px 32px;
	border: 1px solid var(--border);
	border-radius: 12px;
	background:
		radial-gradient(600px 220px at 100% 0%, rgba(178, 138, 255, 0.14), transparent 70%),
		radial-gradient(500px 220px at 0% 100%, rgba(255, 111, 168, 0.12), transparent 70%),
		var(--surface);
}
.hero h1 { margin: 0 0 16px; line-height: 0; }
.hero h1 img { display: block; width: 100%; max-width: 480px; height: auto; aspect-ratio: 1067 / 400; object-fit: cover; border-radius: 8px; }
.hero .lead { margin-bottom: 24px; max-width: 560px; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	border-radius: 6px;
	font-weight: 600;
	font-size: 14px;
	border: 1px solid var(--border);
	color: var(--text);
	background: var(--bg);
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--brand-gradient); border-color: transparent; color: #FFFFFF; }
.btn.primary:hover { filter: brightness(1.08); }

.cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
	gap: 14px;
	margin: 0 0 24px;
}
.card {
	display: block;
	padding: 16px 18px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	transition: border-color 0.15s, transform 0.15s;
}
.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card p { margin: 0; font-size: 13px; color: var(--muted); }
.card .icon { color: var(--accent); margin-bottom: 8px; }

/* Concept diagram */

.flow {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 0 0 20px;
	font: 13px var(--mono);
}
.flow span {
	padding: 6px 12px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--surface);
}
.flow span.hl { border-color: var(--accent); color: var(--accent); }
.flow i { color: var(--muted); font-style: normal; }

/* Pager */

.pager {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	margin-top: 64px;
	padding-top: 24px;
	border-top: 1px solid var(--border);
}
.pager a {
	flex: 1;
	padding: 12px 16px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	color: var(--text);
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a small { display: block; color: var(--muted); font-size: 12px; }
.pager a.next { text-align: right; }

footer.site {
	margin-top: 40px;
	font-size: 13px;
	color: var(--muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
	.main { grid-template-columns: minmax(0, 780px); }
	.toc { display: none; }
}

@media (max-width: 860px) {
	.menu-toggle { display: inline-grid; place-items: center; }
	.sidebar {
		transform: translateX(-100%);
		transition: transform 0.2s;
		width: min(300px, 86vw);
		box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
	}
	body.nav-open .sidebar { transform: none; }
	.main { margin-left: 0; padding: calc(var(--topbar) + 24px) 16px 60px; }
	.brand small { display: none; }
	.search { width: auto; flex: 1; }
	.search kbd { display: none; }
	article h1 { font-size: 28px; }
	.hero { padding: 24px 20px; }
	.hero h1 { font-size: 30px; }
	.api .body { padding: 14px 14px 2px; }
	.api > header { padding: 12px 14px; }
	.pager { flex-direction: column; }
}
