/* ---------- tokens ---------- */

:root {
	--brand: #e8414e;
	--brand-soft: #fdecee;
	--bg: #ffffff;
	--bg-soft: #f7f7f8;
	--surface: #ffffff;
	--border: #e7e7ea;
	--text: #18181b;
	--text-muted: #5b5b66;
	--text-faint: #8a8a96;
	--link: #c92a38;
	--code-inline-bg: #f2f2f4;
	--code-bg: #16171d;
	--code-head: #1e2028;
	--code-text: #e6e6ea;
	--code-border: #2a2c36;
	--tok-key: #8ab4ff;
	--tok-string: #9be1a6;
	--tok-number: #ffb877;
	--tok-keyword: #ff8fa3;
	--tok-variable: #d6a6ff;
	--tok-comment: #7c7f8e;
	--query: #1f7a4d;
	--query-bg: #e3f5ea;
	--mutation: #9a4b00;
	--mutation-bg: #fdf0dd;
	--type-c: #3b5bdb;
	--type-bg: #e8edff;
	--shadow: 0 1px 2px rgba(16, 16, 24, 0.04), 0 4px 16px rgba(16, 16, 24, 0.06);
	--radius: 10px;
	--sidebar: 272px;
	--topbar: 68px;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--brand: #ff5a66;
		--brand-soft: #3a1d21;
		--bg: #0f1014;
		--bg-soft: #15161c;
		--surface: #15161c;
		--border: #262833;
		--text: #ececf1;
		--text-muted: #a5a6b3;
		--text-faint: #747684;
		--link: #ff7a85;
		--code-inline-bg: #1f2029;
		--code-bg: #0b0c10;
		--code-head: #14151b;
		--code-border: #262833;
		--query: #5fd39a;
		--query-bg: #16301f;
		--mutation: #ffb36b;
		--mutation-bg: #33240f;
		--type-c: #9db1ff;
		--type-bg: #1c2340;
		--shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.3);
		color-scheme: dark;
	}
}

:root[data-theme="dark"] {
	--brand: #ff5a66;
	--brand-soft: #3a1d21;
	--bg: #0f1014;
	--bg-soft: #15161c;
	--surface: #15161c;
	--border: #262833;
	--text: #ececf1;
	--text-muted: #a5a6b3;
	--text-faint: #747684;
	--link: #ff7a85;
	--code-inline-bg: #1f2029;
	--code-bg: #0b0c10;
	--code-head: #14151b;
	--code-border: #262833;
	--query: #5fd39a;
	--query-bg: #16301f;
	--mutation: #ffb36b;
	--mutation-bg: #33240f;
	--type-c: #9db1ff;
	--type-bg: #1c2340;
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.3);
	color-scheme: dark;
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

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

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15.5px/1.65 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
	-webkit-font-smoothing: antialiased;
}

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

code, pre { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }

:not(pre) > code {
	background: var(--code-inline-bg);
	border-radius: 5px;
	padding: 0.1em 0.38em;
	font-size: 0.86em;
}

/* ---------- top bar ---------- */

.topbar {
	position: sticky;
	top: 0;
	z-index: 30;
	height: var(--topbar);
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 0 20px;
	background: color-mix(in srgb, var(--bg) 85%, transparent);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand span {
	font-size: 13px;
	padding: 2px 8px;
	border-radius: 999px;
	background: var(--brand-soft);
	color: var(--brand);
}

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.theme-toggle, .menu-toggle {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface);
	color: var(--text-muted);
	cursor: pointer;
}
.theme-toggle:hover, .menu-toggle:hover { color: var(--text); }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
	:root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}
.menu-toggle { display: none; }

/* ---------- layout ---------- */

.layout { display: flex; }

.sidebar {
	position: sticky;
	top: var(--topbar);
	flex: 0 0 var(--sidebar);
	height: calc(100vh - var(--topbar));
	overflow-y: auto;
	padding: 20px 14px 40px;
	border-right: 1px solid var(--border);
	background: var(--bg);
	font-size: 14px;
}

.search {
	width: 100%;
	height: 36px;
	padding: 0 12px;
	margin-bottom: 14px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--bg-soft);
	color: var(--text);
	font: inherit;
}
.search:focus { outline: 2px solid var(--brand); outline-offset: -1px; }

.nav-group {
	margin: 18px 10px 6px;
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--text-faint);
}

.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar ul ul { padding-left: 8px; }
.sidebar a, .sidebar summary {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 10px;
	border-radius: 7px;
	color: var(--text-muted);
	cursor: pointer;
}
.sidebar a:hover, .sidebar summary:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.sidebar a.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.sidebar summary { list-style: none; font-weight: 500; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::after { content: "›"; margin-left: auto; transition: transform 0.15s; }
.sidebar details[open] > summary::after { transform: rotate(90deg); }
.sidebar .hidden { display: none; }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot.query { background: var(--query); }
.dot.mutation { background: var(--mutation); }

.content {
	flex: 1;
	min-width: 0;
	max-width: 880px;
	padding: 8px 48px 40px;
}

/* ---------- typography ---------- */

.section { padding: 28px 0 36px; border-bottom: 1px solid var(--border); }
.section:last-of-type { border-bottom: 0; }

h1 { font-size: 30px; line-height: 1.25; letter-spacing: -0.02em; margin: 12px 0 14px; }
h2 { position: relative; font-size: 20px; letter-spacing: -0.01em; margin: 34px 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin: 16px 0 6px; }

.anchor { position: absolute; left: -22px; color: var(--text-faint); opacity: 0; font-weight: 400; }
h2:hover .anchor { opacity: 1; text-decoration: none; }

p, ul, ol { margin: 0 0 14px; }
.lead, .section > p:first-of-type { font-size: 17px; color: var(--text-muted); }
strong { font-weight: 600; }

/* ---------- tables ---------- */

.table-wrap { width: 100%; overflow-x: auto; margin: 8px 0 20px; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 9px 14px; border-bottom: 1px solid var(--border); }
th { font-size: 12.5px; font-weight: 600; color: var(--text-faint); background: var(--bg-soft); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg-soft); }
td code { white-space: nowrap; }
td:first-child { width: 1%; white-space: nowrap; }
td:first-child:has(code + code), td:first-child:has(code ~ code) { white-space: normal; min-width: 200px; }

/* ---------- code ---------- */

.code, .tabs {
	margin: 10px 0 20px;
	border: 1px solid var(--code-border);
	border-radius: var(--radius);
	background: var(--code-bg);
	overflow: hidden;
	box-shadow: var(--shadow);
}

.code-head, .tab-list {
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 0 6px 0 14px;
	min-height: 40px;
	background: var(--code-head);
	border-bottom: 1px solid var(--code-border);
	color: #a6a8b6;
	font-size: 12.5px;
	font-weight: 500;
}
.code-head span { flex: 1; }

.tab-bar { display: flex; align-items: center; gap: 8px; padding-right: 8px; background: var(--code-head); border-bottom: 1px solid var(--code-border); }
.tab-bar .tab-list { flex: 1; min-width: 0; border-bottom: 0; }
.tab-list { padding-left: 6px; overflow-x: auto; scrollbar-width: none; }
.tab-list button {
	position: relative;
	height: 40px;
	padding: 0 12px;
	border: 0;
	background: none;
	color: #a6a8b6;
	font: inherit;
	cursor: pointer;
	white-space: nowrap;
}
.tab-list button:hover { color: #fff; }
.tab-list button[aria-selected="true"] { color: #fff; }
.tab-list button[aria-selected="true"]::after {
	content: "";
	position: absolute;
	left: 10px;
	right: 10px;
	bottom: -1px;
	height: 2px;
	border-radius: 2px;
	background: var(--brand);
}


pre {
	margin: 0;
	padding: 14px 16px;
	overflow-x: auto;
	color: var(--code-text);
	font-size: 13px;
	line-height: 1.6;
}

.copy {
	padding: 4px 10px;
	border: 1px solid #343745;
	border-radius: 6px;
	background: #1f2129;
	color: #c5c7d3;
	font: 500 12px Inter, system-ui, sans-serif;
	cursor: pointer;
}
.copy:hover { color: #fff; border-color: #4a4e60; }
.copy.done { color: #9be1a6; border-color: #3c6b45; }

.tok-key { color: var(--tok-key); }
.tok-string { color: var(--tok-string); }
.tok-number { color: var(--tok-number); }
.tok-keyword { color: var(--tok-keyword); }
.tok-variable { color: var(--tok-variable); }
.tok-flag { color: var(--tok-key); }
.tok-comment { color: var(--tok-comment); font-style: italic; }

/* ---------- blocks ---------- */

.steps ol {
	counter-reset: step;
	list-style: none;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 12px;
	margin: 18px 0 22px;
}
.steps li {
	counter-increment: step;
	position: relative;
	padding: 16px 16px 14px 52px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--shadow);
	font-size: 14.5px;
}
.steps li::before {
	content: counter(step);
	position: absolute;
	left: 14px;
	top: 14px;
	display: grid;
	place-items: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--brand);
	color: #fff;
	font-weight: 600;
	font-size: 13px;
}

.callout {
	margin: 16px 0 20px;
	padding: 12px 16px 12px 44px;
	position: relative;
	border: 1px solid var(--border);
	border-left: 3px solid var(--brand);
	border-radius: 8px;
	background: var(--bg-soft);
	font-size: 14.5px;
}
.callout::before {
	content: "💡";
	position: absolute;
	left: 14px;
	top: 11px;
}
.callout p:last-child { margin-bottom: 0; }

/* ---------- reference ---------- */

.ref {
	padding: 18px 20px 6px;
	margin: 14px 0;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}
.ref:target { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.ref h3 code { background: none; padding: 0; font-size: 16px; }

.pill {
	font: 600 11px Inter, system-ui, sans-serif;
	letter-spacing: 0.03em;
	padding: 3px 8px;
	border-radius: 999px;
	text-transform: uppercase;
	background: var(--type-bg);
	color: var(--type-c);
}
.pill.query { background: var(--query-bg); color: var(--query); }
.pill.mutation { background: var(--mutation-bg); color: var(--mutation); }

.badge {
	display: inline-block;
	margin-left: 4px;
	padding: 0 6px;
	border-radius: 4px;
	background: var(--brand-soft);
	color: var(--brand);
	font-size: 11px;
	font-weight: 600;
}

a.type:hover { text-decoration: none; }
a.type code { color: var(--type-c); }
code.type { color: var(--text-muted); }
.returns { color: var(--text-muted); font-size: 14px; }
.enum { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.footer { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 13px; }

/* ---------- small screens ---------- */

@media (max-width: 900px) {
	.menu-toggle { display: inline-grid; }
	.sidebar {
		position: fixed;
		z-index: 40;
		top: var(--topbar);
		left: 0;
		bottom: 0;
		width: 290px;
		height: auto;
		transform: translateX(-100%);
		transition: transform 0.2s ease;
		box-shadow: var(--shadow);
	}
	.sidebar.open { transform: none; }
	.scrim { position: fixed; inset: var(--topbar) 0 0 0; z-index: 35; background: rgba(0, 0, 0, 0.35); }
	.content { padding: 4px 16px 32px; }
	.brand img { height: 38px; width: auto; }
	h1 { font-size: 26px; }
	.anchor { display: none; }
}
