:root {
	--bg: #f4f7fb;
	--surface: #ffffff;
	--surface-2: #eef3f9;
	--text: #0f1b2d;
	--muted: #5b6b80;
	--line: #dbe3ee;
	--accent: #1aa7e8;
	--accent-ink: #075985;
	--accent-soft: #e2f4fd;
	--mark: #ff3d6e;
	--shadow: 0 1px 2px rgba(15, 27, 45, 0.06), 0 8px 24px rgba(15, 27, 45, 0.06);
	--radius: 16px;
	--topbar: 64px;
	--toc: 300px;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #0b121c;
		--surface: #121b27;
		--surface-2: #182332;
		--text: #e7edf5;
		--muted: #93a3b8;
		--line: #243244;
		--accent: #38bdf8;
		--accent-ink: #7dd3fc;
		--accent-soft: #0c2a3b;
		--shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
		color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--bg: #0b121c;
	--surface: #121b27;
	--surface-2: #182332;
	--text: #e7edf5;
	--muted: #93a3b8;
	--line: #243244;
	--accent: #38bdf8;
	--accent-ink: #7dd3fc;
	--accent-soft: #0c2a3b;
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

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

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
	font-size: 15px;
	line-height: 1.7;
	-webkit-font-smoothing: antialiased;
}

svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

a {
	color: var(--accent-ink);
}

:focus-visible {
	outline: 3px solid var(--accent);
	outline-offset: 2px;
	border-radius: 8px;
}

.skip {
	position: absolute;
	inset-inline-start: 16px;
	top: -100px;
	z-index: 100;
	background: var(--surface);
	padding: 8px 14px;
	border-radius: 10px;
}
.skip:focus {
	top: 12px;
}

/* ── Top bar ── */
.topbar {
	position: sticky;
	top: 0;
	z-index: 20;
	height: var(--topbar);
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 0 20px;
	background: color-mix(in srgb, var(--surface) 88%, transparent);
	backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--line);
}

.brand {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
}
.brand strong {
	display: block;
	font-size: 16px;
	line-height: 1.3;
}
.brand-sub {
	display: block;
	color: var(--muted);
	font-size: 12px;
}
.brand-mark {
	width: 34px;
	height: 34px;
	flex: none;
	border-radius: 10px;
	background: linear-gradient(135deg, #38bdf8, #0284c7);
	clip-path: polygon(0 30%, 100% 0, 62% 100%, 48% 58%);
}

.search {
	margin-inline-start: auto;
	display: flex;
	align-items: center;
	gap: 8px;
	width: min(440px, 46vw);
	height: 42px;
	padding: 0 12px;
	background: var(--surface-2);
	border: 1px solid var(--line);
	border-radius: 12px;
	color: var(--muted);
}
.search:focus-within {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}
.search input {
	flex: 1;
	min-width: 0;
	border: 0;
	background: transparent;
	color: var(--text);
	font: inherit;
	outline: none;
}
.search kbd {
	font-family: ui-monospace, monospace;
	font-size: 12px;
	padding: 1px 7px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--surface);
}

.icon-btn {
	display: inline-grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--surface);
	color: var(--text);
	cursor: pointer;
}
.icon-btn:hover {
	background: var(--surface-2);
}
.menu-btn {
	display: none;
}

/* ── Layout ── */
.layout {
	display: grid;
	grid-template-columns: var(--toc) minmax(0, 1fr);
	max-width: 1440px;
	margin: 0 auto;
}

.toc {
	position: sticky;
	top: var(--topbar);
	height: calc(100vh - var(--topbar));
	overflow-y: auto;
	padding: 20px 16px 40px;
	border-inline-end: 1px solid var(--line);
}
.toc-module {
	margin-bottom: 6px;
}
.toc-module > a {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 10px;
	border-radius: 10px;
	color: var(--text);
	font-weight: 600;
	text-decoration: none;
}
.toc-module > a:hover {
	background: var(--surface-2);
}
.toc-module > a.active {
	background: var(--accent-soft);
	color: var(--accent-ink);
}
.toc-count {
	margin-inline-start: auto;
	font-size: 12px;
	font-weight: 500;
	color: var(--muted);
}
.toc-subs {
	list-style: none;
	margin: 2px 0 8px;
	padding: 0 18px 0 0;
}
.toc-subs a {
	display: block;
	padding: 4px 10px;
	border-radius: 8px;
	color: var(--muted);
	font-size: 13.5px;
	text-decoration: none;
}
.toc-subs a:hover {
	color: var(--text);
	background: var(--surface-2);
}

.content {
	padding: 28px 32px 80px;
	min-width: 0;
}

/* ── Intro ── */
.intro {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 24px 28px;
	margin-bottom: 32px;
}
.intro h1 {
	margin: 0 0 6px;
	font-size: 28px;
	line-height: 1.3;
}
.intro p {
	margin: 0 0 12px;
	color: var(--muted);
}
.legend {
	list-style: none;
	margin: 0 0 12px;
	padding: 0;
	display: grid;
	gap: 6px;
	font-size: 14px;
}
.legend li {
	display: flex;
	align-items: center;
	gap: 10px;
}
.swatch {
	width: 18px;
	height: 12px;
	border-radius: 4px;
	flex: none;
}
.swatch-mark {
	border: 2px solid var(--mark);
}
.swatch-path {
	background: var(--accent-soft);
	border: 1px solid var(--accent);
}
.swatch-zoom {
	background: var(--surface-2);
	border: 1px solid var(--line);
}
.settings summary {
	cursor: pointer;
	color: var(--accent-ink);
	font-weight: 500;
	font-size: 14px;
}
.settings label {
	display: grid;
	gap: 4px;
	margin-top: 10px;
	max-width: 420px;
	font-size: 13px;
	color: var(--muted);
}
.settings input {
	height: 40px;
	padding: 0 12px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--surface-2);
	color: var(--text);
	font: inherit;
}
.hint {
	font-size: 13px;
	margin-top: 8px !important;
}

/* ── Modules ── */
.module {
	margin-bottom: 48px;
}
.module-head {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 6px 14px;
	padding-bottom: 12px;
	margin-bottom: 18px;
	border-bottom: 2px solid var(--line);
}
.module-head h2 {
	margin: 0;
	font-size: 24px;
	line-height: 1.35;
}
.module-head p {
	margin: 0;
	color: var(--muted);
	flex-basis: 100%;
}
.module-head .pill {
	font-size: 12.5px;
}

.sub-title {
	margin: 28px 0 14px;
	font-size: 17px;
	color: var(--accent-ink);
}

.pill {
	display: inline-flex;
	align-items: center;
	padding: 2px 10px;
	border-radius: 999px;
	background: var(--surface-2);
	border: 1px solid var(--line);
	color: var(--muted);
	font-size: 12px;
	font-weight: 500;
	white-space: nowrap;
}

/* ── Feature card ── */
.feature {
	display: grid;
	grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
	gap: 24px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 22px;
	margin-bottom: 18px;
	scroll-margin-top: calc(var(--topbar) + 16px);
}
.feature:target {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}
.feature-head {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 4px;
}
.feature-id {
	font-family: ui-monospace, "SF Mono", monospace;
	font-size: 13px;
	font-weight: 600;
	color: var(--accent-ink);
	background: var(--accent-soft);
	padding: 2px 8px;
	border-radius: 8px;
	direction: ltr;
	text-decoration: none;
}
.feature h4 {
	margin: 0;
	font-size: 18px;
	line-height: 1.45;
}
.feature-desc {
	margin: 4px 0 14px;
	color: var(--muted);
}
.label {
	display: block;
	margin: 14px 0 6px;
	font-size: 12.5px;
	font-weight: 700;
	letter-spacing: 0.02em;
	color: var(--muted);
}
.where {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	background: var(--accent-soft);
	border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
	border-radius: 12px;
	font-size: 14px;
	font-weight: 500;
}
.where-path {
	flex: 1 1 200px;
}
.open-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border-radius: 8px;
	background: var(--surface);
	border: 1px solid var(--line);
	font-size: 13px;
	text-decoration: none;
	white-space: nowrap;
}
.open-link svg {
	width: 15px;
	height: 15px;
}
.open-link:hover {
	border-color: var(--accent);
}
.steps {
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: step;
}
.steps li {
	position: relative;
	padding: 6px 38px 6px 0;
	counter-increment: step;
}
.steps li::before {
	content: counter(step);
	position: absolute;
	inset-inline-start: 0;
	top: 7px;
	width: 26px;
	height: 26px;
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: var(--accent);
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
}

.shot {
	margin: 0;
	align-self: start;
}
.shot button {
	display: block;
	width: 100%;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 12px;
	overflow: hidden;
	background: var(--surface-2);
	cursor: zoom-in;
	aspect-ratio: 16 / 10;
}
.shot img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: top center;
	transition: transform 0.25s ease;
}
.shot button:hover img {
	transform: scale(1.02);
}
.shot figcaption {
	margin-top: 6px;
	font-size: 12px;
	color: var(--muted);
}
.shot-missing {
	display: grid;
	place-items: center;
	aspect-ratio: 16 / 10;
	border: 1px dashed var(--line);
	border-radius: 12px;
	color: var(--muted);
	font-size: 13px;
}

.no-results {
	padding: 40px;
	text-align: center;
	color: var(--muted);
	background: var(--surface);
	border: 1px dashed var(--line);
	border-radius: var(--radius);
}

mark.hit {
	background: color-mix(in srgb, #facc15 45%, transparent);
	color: inherit;
	border-radius: 3px;
	padding: 0 1px;
}

/* ── Lightbox ── */
.lightbox {
	width: 100vw;
	height: 100vh;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 56px 72px 24px;
	border: 0;
	background: rgba(6, 10, 18, 0.92);
	color: #fff;
}
.lightbox::backdrop {
	background: transparent;
}
.lightbox figure {
	margin: 0;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
}
.lightbox img {
	max-width: 100%;
	max-height: calc(100% - 40px);
	border-radius: 10px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lightbox figcaption {
	font-size: 15px;
	text-align: center;
}
.lightbox .icon-btn {
	position: absolute;
	background: rgba(255, 255, 255, 0.1);
	border-color: rgba(255, 255, 255, 0.2);
	color: #fff;
}
.lb-close {
	top: 12px;
	inset-inline-end: 16px;
}
.lb-prev {
	top: 50%;
	inset-inline-start: 16px;
}
.lb-next {
	top: 50%;
	inset-inline-end: 16px;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
	.feature {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 860px) {
	.menu-btn {
		display: inline-grid;
	}
	.layout {
		grid-template-columns: 1fr;
	}
	.toc {
		position: fixed;
		inset-block: var(--topbar) 0;
		inset-inline-start: 0;
		z-index: 15;
		width: min(320px, 86vw);
		height: auto;
		background: var(--surface);
		box-shadow: var(--shadow);
		transform: translateX(100%);
		transition: transform 0.2s ease;
	}
	.toc.open {
		transform: none;
	}
	.brand-sub {
		display: none;
	}
	.search kbd {
		display: none;
	}
}

@media (max-width: 600px) {
	.topbar {
		padding: 0 16px;
		gap: 10px;
	}
	.brand div {
		display: none;
	}
	.search {
		width: auto;
		flex: 1;
	}
	.content {
		padding: 16px 16px 60px;
	}
	.intro {
		padding: 18px;
	}
	.intro h1 {
		font-size: 22px;
	}
	.feature {
		padding: 16px;
	}
	.lightbox {
		padding: 56px 8px 16px;
	}
	.lb-prev,
	.lb-next {
		top: auto;
		bottom: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
	.shot img,
	.toc {
		transition: none;
	}
}

@media print {
	.topbar,
	.toc,
	.settings,
	.open-link {
		display: none !important;
	}
	.layout {
		display: block;
	}
	.feature {
		break-inside: avoid;
		box-shadow: none;
	}
}
