:root {
	--bg: #141517;
	--surface: #1c1e21;
	--surface-2: #282b30;
	--border: #373b42;
	--text: #f2f3f5;
	--muted: #b0b6c0;
	--accent: #d4dfed;
	--accent-text: #17212f;
	--highlight: #ff00e6;
	--radius: 6px;
	--panel-radius: 12px;
	--control-border: #727984;
	--focus: #b9d5ff;
	--motion: 140ms;
	--space-1: 4px;
	--space-2: 8px;
	--space-3: 12px;
	--space-4: 16px;
	--space-6: 24px;
	--space-8: 32px;
	--space-12: 48px;
	--text-xs: 12px;
	--text-sm: 13px;
	--text-md: 15px;
	--text-lg: 18px;
	--text-xl: 26px;
	--shell-height: 112px;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--mono: ui-monospace, "Cascadia Code", Consolas, monospace;
	color-scheme: dark;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.55 var(--font);
}

a { color: var(--accent); }
code, pre { font-family: var(--mono); font-size: 0.9em; }

/* One shell for reference pages and the full-width workspace. */
.top { position: sticky; top: 0; z-index: 5; height: var(--shell-height); display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: 62px 50px; align-items: center; gap: 0 var(--space-6); padding: 0 var(--space-8); background: var(--bg); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 650; letter-spacing: -.7px; color: var(--text); text-decoration: none; }
.brand-mark { color: var(--accent); font: italic 32px Georgia, serif; }
.brand-label { font-size: var(--text-sm); color: var(--muted); font-weight: 400; letter-spacing: 0; margin-left: 6px; }
.source-link { color: var(--muted); text-decoration: none; font-size: var(--text-xs); }
.theme-presence { justify-self: end; max-width: min(42vw, 360px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-xs); text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 10px; }
.top-nav { grid-row: 2; grid-column: 1 / -1; display: flex; gap: var(--space-6); height: 100%; overflow-x: auto; scrollbar-width: thin; }
.top-nav a { display: flex; align-items: center; white-space: nowrap; color: var(--muted); text-decoration: none; font-size: var(--text-sm); border-bottom: 2px solid transparent; padding: 0 2px; }
.top-nav a:hover { color: var(--text); }
.top-nav a.on { color: var(--text); border-bottom-color: var(--accent); }
.top-nav a:focus-visible { outline-offset: -4px; }
.nav-label { font-size: 11px; letter-spacing: .1em; font-weight: 600; color: var(--muted); margin: 0 0 18px; }
main { max-width: 1440px; margin: 0 auto; padding: var(--space-8) clamp(20px, 4vw, 64px) 80px; }
.breadcrumb { display: flex; gap: var(--space-3); color: var(--muted); font-size: var(--text-xs); margin-bottom: var(--space-8); }
.breadcrumb > span:last-child { color: var(--text); }
body.studio-mode main { max-width: none; padding: 0; }
body.studio-mode .breadcrumb { display: none; }
.page { display: none; }
.page.on { display: block; }
.muted { color: var(--muted); }
.intro h1 { margin: 0 0 14px; font-size: 40px; line-height: 1.15; letter-spacing: -1.5px; font-weight: 550; }
.intro p { margin: 0 0 var(--space-8); max-width: 760px; line-height: 1.8; }

/* Guide (rendered README) */
.guide-body { max-width: none; }
.hero-copy h1 { margin: var(--space-3) 0 20px; font-size: clamp(34px, 4vw, 52px); line-height: 1.08; font-weight: 550; letter-spacing: -.045em; }
.guide-body h2 { margin: var(--space-12) 0 18px; padding-top: 28px; border-top: 1px solid var(--border); font-size: 25px; font-weight: 550; letter-spacing: -.6px; scroll-margin-top: calc(var(--shell-height) + var(--space-6)); }
.guide-body img { max-width: 100%; border-radius: 6px; }
.guide-body table { border-collapse: collapse; margin: var(--space-3) 0; }
.guide-body th, .guide-body td { border: 1px solid var(--border); padding: 6px 10px; vertical-align: top; }
.guide-body td img { cursor: zoom-in; }

/* tables without a header row are image grids */
.guide-body table:not(:has(thead)) {
	table-layout: fixed;
	width: 100%;
}
.guide-body table:not(:has(thead)) td {
	text-align: center;
	font-size: 13px;
}
.guide-body td code { overflow-wrap: anywhere; }
.guide-body :not(pre) > code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
pre {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 14px;
	overflow: auto;
	tab-size: 4;
}

/* Toolbar */
.toolbar { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-3); }
:where(input[type="search"]):not(.vp *) {
	flex: 1;
	min-width: 220px;
	padding: 9px var(--space-3);
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
}

.check { display: flex; gap: 6px; align-items: center; color: var(--muted); }

/* Shared controls; the phone keeps its Discord-specific styles. */
:where(button, .button):not(.vp *) {
	padding: 7px var(--space-3); border: 1px solid var(--control-border); border-radius: var(--radius);
	background: var(--surface); color: var(--text); font: var(--text-sm)/1.5 var(--font);
	text-decoration: none; cursor: pointer; transition: background var(--motion), border-color var(--motion);
}
:where(button, .button):hover:not(.vp *) { background: var(--surface-2); }
:where(button):disabled:not(.vp *) { opacity: .45; cursor: default; }
:where(input:not([type="checkbox"]):not([type="range"]), select, textarea):not(.vp *) {
	background: var(--surface); color: var(--text); border: 1px solid var(--control-border); border-radius: var(--radius);
	padding: 7px 10px; font: var(--text-sm)/1.5 var(--font); min-width: 0;
}
:where(input[type="checkbox"]):not(.vp *) { accent-color: var(--accent); }
.primary:not(.vp *) { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.primary:hover:not(.vp *) { background: #edf3fc; }

.segmented { display: flex; background: var(--surface-2); border-radius: var(--radius); padding: 3px; }
.segmented button { border: 0; background: transparent; color: var(--muted); padding: 6px 14px; }
.segmented button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px #0002; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.chips button { padding: var(--space-1) 11px; border-radius: 4px; font-size: 12px; }
.chips button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Key cards */
.area-title { margin: 28px 0 var(--space-3); font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 14px; }
.card {
	display: flex;
	gap: var(--space-3);
	padding: var(--space-3);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}
.card img {
	width: 168px;
	height: auto;
	object-fit: contain;
	border-radius: 6px;
	flex: none;
	cursor: zoom-in;
	background: #000;
}
.card-body { padding: var(--space-2) var(--space-1); min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.key {
	font-family: var(--mono);
	font-size: 13px;
	font-weight: 600;
	overflow-wrap: anywhere;
	background: none;
	border: 0;
	padding: 0;
	text-align: left;
	color: var(--text);
}
.key:hover { color: var(--accent); background: none; }
.card p { margin: 0; font-size: 14px; }
.swatches { display: grid; grid-template-columns: auto auto; gap: var(--space-1) var(--space-3); justify-content: start; margin-top: auto; }
.swatch { display: flex; align-items: center; gap: var(--space-1); font-size: 11px; color: var(--muted); }
.dot {
	width: 16px;
	height: 16px;
	border-radius: 4px;
	border: 1px solid var(--border);
	/* checkerboard shows through colours with alpha */
	background: conic-gradient(#bbb 25%, #fff 0 50%, #bbb 0 75%, #fff 0) 0 0 / 8px 8px;
	position: relative;
	overflow: hidden;
	flex: none;
}
.dot i { position: absolute; inset: 0; }
.used-by { font-size: 12px; color: var(--muted); }

/* All keys table */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
#all-table th {
	position: sticky;
	top: 0;
	background: var(--surface-2);
	text-align: left;
	padding: var(--space-2) 10px;
	white-space: nowrap;
}
#all-table td { padding: 6px 10px; border-top: 1px solid var(--border); white-space: nowrap; }
#all-table td:first-child { font-family: var(--mono); font-weight: 600; }
#all-table .cell { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; }
.tag { font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--accent); margin-left: 6px; }

/* Templates */
.preview { width: 100%; border-radius: var(--radius); margin-bottom: 20px; }
.template { margin-bottom: 28px; }
.template-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; }
.template-head h2 { margin: 0; font-size: 18px; }
.template-head p { margin: 2px 0 10px; }
.buttons { display: flex; gap: var(--space-2); margin-bottom: 10px; }
.template pre { max-height: 460px; }

/* Lightbox and toast */
#lightbox {
	position: fixed;
	inset: 0;
	z-index: 10;
	display: grid;
	place-items: center;
	background: #000c;
	cursor: zoom-out;
}
#lightbox:not([open]) { display: none; }
#lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0; padding: 0; }
#lightbox::backdrop { background: #000c; }
.close-image { position: fixed; z-index: 1; top: 18px; right: 18px; }
.image-button { display: block; padding: 0; border: 0; background: none; flex: none; cursor: zoom-in; align-self: start; position: relative; }
.image-button:hover { background: none; }
.image-button img { display: block; }
#lightbox img { width: 100%; display: block; border-radius: 8px; }
.image-detail { display: flex; align-items: center; gap: var(--space-8); max-width: 960px; margin: 50px var(--space-6); cursor: auto; }
.image-frame { position: relative; width: min(36vh, 48vw); flex: none; }
.image-detail figcaption { max-width: 360px; color: var(--text); line-height: 1.7; }
#image-title { font: 17px var(--mono); overflow-wrap: anywhere; }
#image-description { color: var(--muted); }
#image-original { font-size: 13px; }
.focus-outline { position: absolute; border: 2px solid #ffe680; border-radius: 4px; pointer-events: none; box-shadow: 0 0 0 1px #29200a; }
.focus-label { display: flex; gap: 7px; align-items: center; font-size: 11px; color: var(--muted); margin-top: 10px; }
.focus-label i { width: 8px; height: 8px; border-radius: 50%; background: #ff65c5; }
.image-zoom { position: absolute; bottom: 8px; right: 8px; background: #151719e8; color: #fff; border: 1px solid #717777; border-radius: 4px; padding: 2px 7px; font-size: 10px; }

#toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	padding: var(--space-2) var(--space-4);
	background: var(--text);
	color: var(--bg);
	border-radius: 8px;
	font-size: 14px;
	z-index: 11;
}

/* Overview */
.eyebrow { color: var(--accent); font: 11px var(--mono); letter-spacing: .12em; }
.lead { max-width: 560px; font-size: 17px; line-height: 1.8; color: var(--muted); }
.hero-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 28px 0 22px; }
.hero-actions > a { text-decoration: none; }
.hero-actions span { margin-left: var(--space-2); }

.guide-layout { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: var(--space-12); align-items: start; }
.guide-body { min-width: 0; color: var(--muted); line-height: 1.85; }
.guide-body h2, .guide-body h3, .guide-body strong { color: var(--text); }
.guide-body h3 { font-weight: 550; margin-top: 30px; }
.guide-body li { margin: 9px 0; padding-left: var(--space-1); }
.guide-body a { text-underline-offset: 3px; }
.guide-body table { font-size: 12px; line-height: 1.6; }
.guide-body table:not(:has(thead)) td { padding: var(--space-3) 5px; font-size: 10px; }
.contents { position: sticky; top: calc(var(--shell-height) + 24px); margin-top: 76px; }
.contents a { display: block; font-size: 12px; text-decoration: none; color: var(--muted); margin: 14px 0; }
.contents a:hover { color: var(--accent); }
.result-count { font-size: 12px; color: var(--muted); margin: 20px 0; }
.card { transition: border-color var(--motion); }
.card:hover { border-color: #65716c; }
.area-title { border-top: 1px solid var(--border); padding-top: var(--space-6); margin-top: 36px; font-weight: 550; }
#all-table th, #all-table td { padding: var(--space-3) 14px; }
#all-table tr:hover td { background: var(--surface-2); }
:focus-visible:not(.vp *) { outline: 2px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; top: -60px; left: 24px; z-index: 20; background: var(--accent); color: #17212f; padding: 10px 18px; }
.skip-link:focus { top: 12px; }
[hidden] { display: none !important; }
@media (max-width: 1100px) {
    .guide-layout { display: block; }
    .contents { display: none; }
}
@media (max-width: 900px) {
    :root { --shell-height: 108px; }
    .top { padding: 0 var(--space-4); grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 58px 50px; gap: 0 var(--space-3); }
    .brand { font-size: 17px; }
    .brand-label, .source-link { display: none; }
    .theme-presence { font-size: 11px; max-width: 100%; }
    .top-nav { gap: 20px; }
    main { margin: 0; padding: var(--space-6) 20px 60px; }
    .breadcrumb { margin-bottom: 34px; }
    .hero-actions { gap: 18px; flex-wrap: wrap; }
    .guide-body h2 { scroll-margin-top: 135px; }
    .grid { grid-template-columns: 1fr; }
    .card img { width: clamp(125px, 32vw, 180px); height: auto; }
    .image-detail { flex-direction: column; gap: 18px; margin: 64px 20px var(--space-6); }
    .image-frame { width: min(30vh, 70vw); }
    .image-detail figcaption { max-width: 90vw; }
    #lightbox { overflow-y: auto; }
    .toolbar { align-items: stretch; }
    :where(input[type="search"]):not(.vp *) { min-width: 0; width: 100%; flex-basis: 100%; }
    .guide-body table:not(:has(thead)) tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .guide-body table:not(:has(thead)) td { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* Keep every example with its key; the strip scrolls on narrow screens. */
.card { flex-direction: column; gap: var(--space-4); min-width: 0; }
.card-body { gap: var(--space-2); }
.card-body .key { font-size: 14px; }
.card-body .focus-label { margin-top: var(--space-1); }
.swatches { margin-top: 6px; display: flex; flex-wrap: wrap; }
#keys-list .grid > .card:only-child { grid-column: 1 / -1; }
.key-gallery { display: flex; gap: var(--space-3); overflow-x: auto; padding: var(--space-1) 2px var(--space-3); margin-top: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.key-gallery figure { margin: 0; flex: none; }
.key-gallery figcaption { margin-top: var(--space-2); font-size: 11px; color: var(--muted); }
#image-navigation { display: flex; align-items: center; gap: var(--space-4); margin: 20px 0; }
#image-position { font-size: 12px; color: var(--muted); }

.card .card-actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }

/* Landing and reusable live preview. */
.guide-hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); gap: var(--space-12); align-items: center; padding-bottom: var(--space-12); }
.hero-copy h1 { font-size: clamp(42px, 5vw, 68px); max-width: 650px; }
.hero-copy .lead { font-size: var(--text-lg); max-width: 540px; }
.hero-note { color: var(--muted); font-size: var(--text-xs); margin-top: var(--space-8); }
.browse-link { font-size: var(--text-sm); text-underline-offset: 5px; }
.hero-demo, .template-showcase { background: var(--surface); border: 1px solid var(--border); border-radius: var(--panel-radius); }
.demo-label { display: flex; justify-content: space-between; align-items: center; padding: 18px var(--space-6) 0; }
.demo-label a { font-size: var(--text-xs); text-decoration: none; }
.live-preview { min-width: 0; }
.demo-controls { padding: var(--space-4) 20px; display: flex; gap: var(--space-3); justify-content: space-between; align-items: center; font-size: var(--text-xs); color: var(--muted); }
.demo-controls label { display: flex; align-items: center; gap: var(--space-2); }
.demo-controls select { max-width: 175px; }
.demo-theme { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.demo-stage { display: grid; place-items: center; overflow: hidden; padding: var(--space-3) var(--space-4); background: radial-gradient(ellipse at center, var(--surface-2), transparent 70%); }
.demo-phone { position: relative; }
.demo-phone .vp-device { position: absolute; top: 0; left: 0; transform-origin: top left; }
.demo-caption { color: var(--muted); font-size: var(--text-xs); text-align: center; padding: 0 20px; margin: var(--space-3) 0 20px; }
.workflow { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); padding: var(--space-8) 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.workflow a { text-decoration: none; padding: var(--space-3); border-radius: var(--radius); }
.workflow a:hover { background: var(--surface); }
.workflow span { display: block; color: var(--muted); font: 11px var(--mono); margin-bottom: 14px; }
.workflow strong { font-weight: 550; font-size: var(--text-lg); color: var(--text); }
.workflow p { margin: var(--space-2) 0 0; color: var(--muted); font-size: var(--text-sm); }
.template-showcase { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: var(--space-8); padding: var(--space-6) var(--space-8); margin-bottom: var(--space-6); }
.template-showcase h2 { font-size: 32px; line-height: 1.2; font-weight: 550; letter-spacing: -.8px; }
.template-showcase .button { display: inline-block; margin: var(--space-4) 0; }
.small { font-size: var(--text-xs); }
.reference-capture { margin: var(--space-6) 0 40px; color: var(--muted); }
.reference-capture summary { cursor: pointer; margin-bottom: var(--space-4); }
.studio-link { font-size: var(--text-xs); font-weight: 600; text-decoration: none; padding: 5px 9px; border: 1px solid var(--control-border); border-radius: var(--radius); }
.studio-link:hover { background: var(--surface-2); }
.yours { display: flex; gap: 6px; align-items: center; font-size: var(--text-xs); color: var(--text); }
.key-preview-button { font-size: var(--text-xs); }
.key-live { max-width: 460px; width: 100%; align-self: center; border: 1px solid var(--border); border-radius: var(--panel-radius); }
.empty, .st-empty { color: var(--muted); padding: var(--space-8) var(--space-4); text-align: center; font-size: var(--text-sm); }
@media (max-width: 900px) {
	.guide-hero, .template-showcase { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
	.hero-copy h1 { font-size: 46px; }
	.hero-copy .lead { font-size: 16px; }
	.hero-note { margin: 20px 0 0; }
	.workflow { grid-template-columns: 1fr; gap: var(--space-2); padding: 20px 0; }
	.workflow span { margin-bottom: var(--space-2); }
	.template-showcase { padding: 20px var(--space-3); }
	.template-showcase > div:first-child { padding: 0 var(--space-2); }
	.demo-controls { padding: var(--space-3); }
	.demo-controls select { max-width: 150px; }
	.buttons { flex-wrap: wrap; }
}
