/* ==========================================================================
   Wikitechy theme
   Brand accent comes from the logo (pink #ED1A72 → orange #F04C34 gradient).
   Category "tones" are code syntax colours: violet, green, amber, rose.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
	--paper: #ffffff;
	--surface: #f3f4f7;
	--surface-2: #e9ebf0;
	--line: #dfe2e8;
	--ink: #1a1d24;
	--muted: #5b6170;
	--accent: #d4145f;
	--accent-ink: #ffffff;
	--accent-bg: #fde7ef;
	--brand-grad: linear-gradient(135deg, #ed1a72 0%, #f04c34 100%);

	--t1: #5b3fd1; --t1-bg: #efebfd;
	--t2: #17805a; --t2-bg: #e3f4ec;
	--t3: #a85604; --t3-bg: #fcefdf;
	--t4: #b4246a; --t4-bg: #fbe6ef;

	--code-bg: #1e1f29;
	--code-ink: #e7e8ef;
	--code-inline-bg: #efebfd;
	--code-inline-ink: #4a2fb8;

	--font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--font-head: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

	/* Type scale (1.25 ratio) */
	--fs-xs: 0.8125rem;
	--fs-sm: 0.9rem;
	--fs-md: 1.0625rem;
	--fs-lg: 1.3125rem;
	--fs-xl: 1.625rem;
	--fs-2xl: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem);
	--fs-3xl: clamp(2.125rem, 1.4rem + 3vw, 3.75rem);

	--wrap: 1240px;
	--gutter: clamp(1rem, 0.6rem + 1.6vw, 2rem);
	--radius-s: 6px;
	--radius: 10px;
	--header-h: 64px;
	color-scheme: light;
}

[data-theme="dark"] {
	--paper: #15171c;
	--surface: #1c1f26;
	--surface-2: #252932;
	--line: #2e333d;
	--ink: #e6e8ee;
	--muted: #9aa1b0;
	--accent: #ff6b9d;
	--accent-ink: #15171c;
	--accent-bg: #3c1f2e;
	--t1: #a594ff; --t1-bg: #262243;
	--t2: #4fd1a0; --t2-bg: #17332a;
	--t3: #f2a65a; --t3-bg: #3a2a17;
	--t4: #f080b4; --t4-bg: #3c1f2e;
	--code-bg: #0f1014;
	--code-inline-bg: #262243;
	--code-inline-ink: #c9bfff;
	color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--paper: #15171c;
		--surface: #1c1f26;
		--surface-2: #252932;
		--line: #2e333d;
		--ink: #e6e8ee;
		--muted: #9aa1b0;
		--accent: #ff6b9d;
		--accent-ink: #15171c;
		--accent-bg: #3c1f2e;
		--t1: #a594ff; --t1-bg: #262243;
		--t2: #4fd1a0; --t2-bg: #17332a;
		--t3: #f2a65a; --t3-bg: #3a2a17;
		--t4: #f080b4; --t4-bg: #3c1f2e;
		--code-bg: #0f1014;
		--code-inline-bg: #262243;
		--code-inline-ink: #c9bfff;
		color-scheme: dark;
	}
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--font-body);
	font-size: var(--fs-md);
	line-height: 1.6;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
}
img, svg, video, iframe { max-width: 100%; height: auto; display: block; }
iframe { border: 0; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4, h5, h6 {
	font-family: var(--font-head);
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.012em;
	margin: 0 0 0.5em;
	text-wrap: balance;
}
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--accent-bg); color: var(--ink); }

.screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
	position: absolute; left: 1rem; top: -100px; z-index: 1000;
	background: var(--accent); color: var(--accent-ink);
	padding: 0.6rem 1rem; border-radius: var(--radius-s); font-weight: 700;
}
.skip-link:focus { top: 1rem; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.wrap--narrow { max-width: calc(760px + 2 * var(--gutter)); }
.site-main { min-height: 60vh; outline: none; }

/* ---------- Buttons & chips ---------- */
.button, .search-form__btn, .hero-search__btn, input[type="submit"] {
	display: inline-flex; align-items: center; justify-content: center;
	gap: 0.5em; border: 0; cursor: pointer;
	background: var(--accent); color: var(--accent-ink);
	font-weight: 700; text-decoration: none;
	padding: 0.7em 1.2em; border-radius: var(--radius-s);
	transition: filter 0.15s;
}
.button:hover, .search-form__btn:hover, .hero-search__btn:hover, input[type="submit"]:hover { filter: brightness(1.08); }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
	--c: var(--t1); --cb: var(--t1-bg);
	display: inline-block;
	font-size: var(--fs-xs); font-weight: 700; line-height: 1;
	padding: 0.5em 0.75em;
	border-radius: 999px;
	color: var(--c); background: var(--cb);
	text-decoration: none;
	white-space: nowrap;
}
.chip:hover { box-shadow: inset 0 0 0 1px var(--c); }
.chip--plain { --c: var(--muted); --cb: var(--surface); }
.tone-1 { --c: var(--t1); --cb: var(--t1-bg); }
.tone-2 { --c: var(--t2); --cb: var(--t2-bg); }
.tone-3 { --c: var(--t3); --cb: var(--t3-bg); }
.tone-4 { --c: var(--t4); --cb: var(--t4-bg); }

/* ---------- Header ---------- */
.site-header {
	position: sticky; top: 0; z-index: 100;
	background: var(--paper);
	border-bottom: 1px solid var(--line);
}
/* Translucent header only on desktop: backdrop-filter would trap the fixed mobile menu. */
@media (min-width: 1024px) {
	.site-header {
		background: color-mix(in srgb, var(--paper) 92%, transparent);
		-webkit-backdrop-filter: saturate(1.4) blur(10px);
		backdrop-filter: saturate(1.4) blur(10px);
	}
}
.admin-bar .site-header { top: 32px; }
@media (max-width: 782px) { .admin-bar .site-header { top: 46px; } }
@media (max-width: 600px) { .admin-bar .site-header { top: 0; } }

.site-header__inner { display: flex; align-items: center; gap: 1.5rem; height: var(--header-h); }
.brand { flex-shrink: 0; }
.brand__link { display: inline-flex; align-items: center; }
.brand__logo { height: 34px; width: auto; }
.brand__logo--dark { display: none; }
[data-theme="dark"] .brand__logo--light { display: none; }
[data-theme="dark"] .brand__logo--dark { display: block; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .brand__logo--light { display: none; }
	:root:not([data-theme="light"]) .brand__logo--dark { display: block; }
}
.site-footer .brand__logo { height: 32px; }

.header-actions { display: flex; align-items: center; gap: 0.25rem; margin-left: auto; }
.icon-btn {
	display: inline-grid; place-items: center;
	width: 40px; height: 40px; border: 0; border-radius: var(--radius-s);
	background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--surface); }
.theme-toggle .i-sun { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: block; }
[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
	:root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

.nav-toggle__bars, .nav-toggle__bars::before, .nav-toggle__bars::after {
	display: block; width: 20px; height: 2px; background: currentColor; border-radius: 2px;
	transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle__bars { position: relative; }
.nav-toggle__bars::before, .nav-toggle__bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle__bars::before { top: -6px; }
.nav-toggle__bars::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after { transform: translateY(-6px) rotate(-45deg); }

.header-search { border-top: 1px solid var(--line); padding: 0.875rem 0; background: var(--paper); }

/* Primary navigation */
.primary-nav .menu, .primary-nav .sub-menu { list-style: none; margin: 0; padding: 0; }
.primary-nav a {
	display: block; color: var(--ink); text-decoration: none;
	font-weight: 700; font-size: 0.95rem;
}
.primary-nav .current-menu-item > a,
.primary-nav .current-menu-ancestor > a { color: var(--accent); }
.submenu-toggle {
	border: 0; background: transparent; color: var(--muted); cursor: pointer;
	display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 4px;
}
.submenu-toggle svg { transition: transform 0.2s; }
.submenu-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

@media (min-width: 1024px) {
	.nav-toggle { display: none; }
	.primary-nav { flex: 1; }
	.primary-nav > .menu { display: flex; align-items: center; gap: 0.25rem; }
	.primary-nav .menu-item { position: relative; display: flex; align-items: center; }
	.primary-nav > .menu > .menu-item > a { padding: 0.5rem 0.6rem; border-radius: var(--radius-s); }
	.primary-nav > .menu > .menu-item > a:hover { background: var(--surface); }
	.primary-nav .menu-item-has-children > a { padding-right: 0.15rem; }

	.primary-nav .sub-menu {
		position: absolute; top: calc(100% + 6px); left: 0; z-index: 10;
		min-width: 240px; padding: 0.5rem;
		background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
		box-shadow: 0 12px 32px -12px rgba(20, 22, 40, 0.25);
		display: none;
	}
	.primary-nav .sub-menu.is-flipped { left: auto; right: 0; }
	.primary-nav .sub-menu .sub-menu.is-flipped { left: auto; right: calc(100% + 0.5rem); }
	.primary-nav .sub-menu::before { content: ""; position: absolute; inset: -8px 0 auto 0; height: 8px; }
	.primary-nav .sub-menu.is-long { columns: 2; min-width: 460px; }
	.primary-nav .sub-menu .menu-item { break-inside: avoid; justify-content: space-between; }
	.primary-nav .sub-menu a { padding: 0.5rem 0.65rem; border-radius: var(--radius-s); font-weight: 400; flex: 1; }
	.primary-nav .sub-menu a:hover { background: var(--surface); }
	.primary-nav .sub-menu .sub-menu { top: -0.5rem; left: calc(100% + 0.5rem); }
	.primary-nav .sub-menu .submenu-toggle svg { transform: rotate(-90deg); }

	.primary-nav .menu-item:hover > .sub-menu,
	.primary-nav .menu-item:focus-within > .sub-menu,
	.primary-nav .menu-item.is-open > .sub-menu { display: block; }
	.primary-nav .sub-menu.is-long { display: none; }
	.primary-nav .menu-item:hover > .sub-menu.is-long,
	.primary-nav .menu-item:focus-within > .sub-menu.is-long,
	.primary-nav .menu-item.is-open > .sub-menu.is-long { display: block; }
}

@media (max-width: 1023.98px) {
	.primary-nav {
		position: fixed; inset: var(--header-h) 0 0 0; z-index: 99;
		background: var(--paper);
		overflow-y: auto; overscroll-behavior: contain;
		padding: 1rem var(--gutter) 3rem;
		display: none;
	}
	.admin-bar .primary-nav { top: calc(var(--header-h) + 46px); }
	.nav-open .primary-nav { display: block; }
	.nav-open { overflow: hidden; }
	.primary-nav .menu-item { display: flex; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--line); }
	.primary-nav .menu-item > a { flex: 1; padding: 0.85rem 0; font-size: 1.05rem; }
	.primary-nav .submenu-toggle { width: 44px; height: 44px; }
	.primary-nav .sub-menu { display: none; width: 100%; padding-left: 1rem; border-left: 2px solid var(--line); margin-bottom: 0.75rem; }
	.primary-nav .menu-item.is-open > .sub-menu { display: block; }
	.primary-nav .sub-menu .menu-item { border-bottom: 0; }
	.primary-nav .sub-menu a { font-weight: 400; padding: 0.6rem 0; }
}

/* Reading progress */
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; pointer-events: none; }
.progress__bar { display: block; height: 100%; width: 100%; background: var(--brand-grad); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- Search forms ---------- */
.search-form { display: flex; gap: 0.5rem; width: 100%; }
.search-form__input {
	flex: 1; min-width: 0;
	padding: 0.7em 0.9em;
	border: 1px solid var(--line); border-radius: var(--radius-s);
	background: var(--paper);
}
.search-form__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.search-form--wide { max-width: 640px; margin-top: 1rem; }

/* ---------- Hero (home) ---------- */
.hero { background: var(--surface); border-bottom: 1px solid var(--line); }
.hero__inner { padding-block: clamp(2.5rem, 2rem + 4vw, 5rem) clamp(2rem, 1.5rem + 2vw, 3rem); }
.hero__title {
	font-size: var(--fs-3xl); font-weight: 800; letter-spacing: -0.03em; line-height: 1.02;
	max-width: 14ch; margin-bottom: 0.35em;
}
.hero__text { color: var(--muted); font-size: var(--fs-lg); max-width: 46ch; margin-bottom: 1.75rem; }

.hero-search-wrap { position: relative; max-width: 760px; margin-right: 8px; }
.hero-search-wrap::before {
	content: ""; position: absolute; inset: 0;
	transform: translate(6px, 6px);
	background: var(--brand-grad); border-radius: var(--radius);
	transition: transform 0.15s;
}
.hero-search-wrap:focus-within::before { transform: translate(8px, 8px); }
.hero-search {
	position: relative;
	display: flex; align-items: center;
	background: var(--paper);
	border: 2px solid var(--ink);
	border-radius: var(--radius);
	padding: 0.375rem 0.375rem 0.375rem 1rem;
	transition: transform 0.15s;
}
.hero-search-wrap:focus-within .hero-search { transform: translate(-2px, -2px); }
.hero-search__prompt { font-family: var(--font-mono); font-weight: 600; color: var(--accent); margin-right: 0.6rem; font-size: 1.15rem; }
.hero-search__input {
	flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
	font-family: var(--font-mono); font-size: clamp(0.95rem, 0.85rem + 0.5vw, 1.15rem);
	padding: 0.7rem 0;
}
.hero-search__input::placeholder { color: var(--muted); opacity: 1; }
.hero-search__input::-webkit-search-cancel-button { display: none; }
.hero-search__btn { padding: 0.85em 1.4em; font-size: 1rem; }
.hero__chips { margin-top: 1.75rem; max-width: 760px; }
.hero__chips .chip { font-size: var(--fs-sm); }

/* ---------- Feed layout ---------- */
.layout-feed { display: grid; gap: 3rem; padding-block: 2.5rem 4rem; }
@media (min-width: 1024px) { .layout-feed { grid-template-columns: minmax(0, 1fr) 320px; } }
.feed__heading { font-size: var(--fs-lg); margin-bottom: 1.25rem; }

.thumb { display: block; position: relative; overflow: hidden; border-radius: var(--radius); background: var(--surface); aspect-ratio: 16 / 10; }
.thumb__img { width: 100%; height: 100%; object-fit: cover; }
.thumb__fallback {
	position: absolute; inset: 0; display: flex; align-items: flex-end;
	padding: 0.75rem 0.9rem; background: var(--cb, var(--t1-bg)); color: var(--c, var(--t1));
	font-family: var(--font-head); font-weight: 800; letter-spacing: -0.02em;
	font-size: clamp(1rem, 0.8rem + 1vw, 1.6rem); line-height: 1;
}
.thumb__fallback span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Lead story */
.lead { display: grid; gap: 1.25rem; padding-bottom: 2rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--line); }
@media (min-width: 760px) { .lead { grid-template-columns: 1.2fr 1fr; gap: 2rem; align-items: center; } }
.lead__title { font-size: var(--fs-2xl); letter-spacing: -0.02em; margin: 0.6rem 0 0.5rem; }
.lead__title a, .card__title a, .tile__title a, .mini__title { color: var(--ink); text-decoration: none; }
.lead__title a:hover, .card__title a:hover, .tile__title a:hover, .mini__title:hover { color: var(--accent); }
.lead__excerpt { color: var(--muted); }

/* Post row */
.card {
	display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 1rem;
	padding-block: 1.5rem; border-bottom: 1px solid var(--line);
}
.card__thumb { order: 2; aspect-ratio: 1; }
.card__title { font-size: var(--fs-md); margin: 0.5rem 0 0.35rem; }
.card__excerpt { display: none; color: var(--muted); font-size: var(--fs-sm); margin-bottom: 0.6rem; }
@media (min-width: 640px) {
	.card { grid-template-columns: 220px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
	.card__thumb { order: 0; aspect-ratio: 16 / 10; }
	.card__title { font-size: var(--fs-lg); }
	.card__excerpt { display: block; }
}

.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.9rem; font-size: var(--fs-xs); color: var(--muted); }
.post-meta a { color: inherit; text-decoration: none; font-weight: 700; }
.post-meta a:hover { color: var(--accent); }
.post-meta__avatar { border-radius: 50%; width: 28px; height: 28px; }

/* Rail */
.rail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; align-content: start; min-width: 0; }
@media (min-width: 1024px) { .rail { position: sticky; top: calc(var(--header-h) + 1.5rem); } }
.widget-title { font-size: var(--fs-md); margin-bottom: 1rem; padding-bottom: 0.6rem; border-bottom: 2px solid var(--ink); }
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget li { padding: 0.35rem 0; }
.widget a { color: var(--ink); text-decoration: none; }
.widget a:hover { color: var(--accent); }
.mini-list { display: grid; gap: 1rem; }
.mini { display: grid; grid-template-columns: 72px 1fr; gap: 0.85rem; align-items: start; padding: 0 !important; }
.mini__thumb { aspect-ratio: 1; border-radius: var(--radius-s); }
.mini__thumb .thumb__fallback { font-size: 0.7rem; padding: 0.4rem; }
.mini__title { display: block; font-weight: 700; font-size: var(--fs-sm); line-height: 1.35; }
.mini__date { font-size: var(--fs-xs); color: var(--muted); }

/* Block widgets (Search, Latest posts, Categories…) */
.widget .wp-block-heading, .widget h2:not(.widget-title) { font-size: var(--fs-md); margin-bottom: 1rem; padding-bottom: 0.6rem; border-bottom: 2px solid var(--ink); }
.site-footer .widget .wp-block-heading { border-bottom: 1px solid var(--line); }
.wp-block-search__label { font-family: var(--font-head); font-weight: 700; display: block; margin-bottom: 0.5rem; }
.wp-block-search__inside-wrapper { display: flex; gap: 0.5rem; }
.wp-block-search__input { flex: 1; min-width: 0; padding: 0.65em 0.85em; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--paper); }
.wp-block-search__button { border: 0; border-radius: var(--radius-s); background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 0.65em 1em; cursor: pointer; margin: 0; }
.wp-block-latest-comments { padding: 0; }
.wp-block-latest-comments__comment { font-size: var(--fs-sm); margin-bottom: 0.75rem; }
.wp-block-latest-comments__comment-meta, .wp-block-latest-comments__comment-excerpt { margin-left: 0 !important; }

/* Pagination */
.pagination { margin-top: 2.5rem; }
.pagination ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0; margin: 0; }
.pagination a, .pagination span {
	display: inline-grid; place-items: center; min-width: 42px; height: 42px; padding: 0 0.8rem;
	border: 1px solid var(--line); border-radius: var(--radius-s);
	color: var(--ink); text-decoration: none; font-weight: 700; font-size: var(--fs-sm);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pagination .dots { border: 0; }

/* Archive header */
.breadcrumbs { font-size: var(--fs-xs); color: var(--muted); padding-top: 1.25rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0; padding: 0; }
.breadcrumbs li:not(:last-child)::after { content: "/"; margin-left: 0.4rem; opacity: 0.5; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs [aria-current] { color: var(--ink); }
.breadcrumbs li:last-child { max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.archive-head { display: flex; gap: 1.25rem; align-items: flex-start; padding-top: 1.5rem; }
.archive-head__title { font-size: var(--fs-2xl); letter-spacing: -0.02em; margin-bottom: 0.4rem; }
.archive-head.tone-1 .archive-head__title, .archive-head.tone-2 .archive-head__title,
.archive-head.tone-3 .archive-head__title, .archive-head.tone-4 .archive-head__title { color: var(--c); }
.archive-head__desc { color: var(--muted); max-width: 65ch; }
.archive-head__count { font-size: var(--fs-sm); color: var(--muted); margin: 0; }
.archive-head__avatar { border-radius: 50%; }
.archive-sub { margin-top: 1.25rem; }

/* ---------- Article layout ---------- */
.layout-article { display: grid; gap: 2rem; padding-block: 1.5rem 3rem; }
.layout-article__right { display: none; }
.layout-article__left .lessons__box:not([open]) { border-radius: var(--radius); }

@media (min-width: 1024px) {
	.layout-article { grid-template-columns: minmax(0, 1fr) 240px; gap: 3rem; }
	.layout-article.has-lessons .layout-article__left { grid-column: 1 / -1; }
	.layout-article__right { display: block; }
	.toc--inline { display: none; }
}
@media (min-width: 1280px) {
	.layout-article.has-lessons { grid-template-columns: 250px minmax(0, 1fr) 230px; gap: 2.5rem; }
	.layout-article.has-lessons .layout-article__left { grid-column: auto; }
	.layout-article__left .lessons { position: sticky; top: calc(var(--header-h) + 1.5rem); }
}
.sticky-col { position: sticky; top: calc(var(--header-h) + 1.5rem); display: grid; gap: 1.5rem; }

.article { min-width: 0; }
.article__head { max-width: 72ch; margin-bottom: 1.5rem; }
.article__title { font-size: var(--fs-2xl); letter-spacing: -0.025em; line-height: 1.12; margin: 0.75rem 0 0.75rem; }
.article__dek { font-size: var(--fs-lg); color: var(--muted); line-height: 1.45; }
.article__hero { margin: 0 0 2rem; }
.article__hero img { width: 100%; border-radius: var(--radius); }
.article__hero figcaption { font-size: var(--fs-xs); color: var(--muted); margin-top: 0.5rem; }
.article--page { padding-block: 1.5rem 3rem; }

/* Lessons (tutorial navigation) */
.lessons__box { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.lessons__head {
	display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem;
	padding: 0.9rem 1rem; cursor: pointer; list-style: none;
	border-bottom: 1px solid var(--line);
}
.lessons__head::-webkit-details-marker { display: none; }
.lessons__box:not([open]) .lessons__head { border-bottom: 0; }
.lessons__title { font-family: var(--font-head); font-weight: 700; }
.lessons__count { font-size: var(--fs-xs); color: var(--muted); }
.lessons__list {
	list-style: none; counter-reset: lesson; margin: 0; padding: 0.4rem;
	max-height: min(60vh, 560px); overflow-y: auto; overscroll-behavior: contain;
}
.lessons__list li { counter-increment: lesson; }
.lessons__list a {
	display: grid; grid-template-columns: 1.75rem 1fr; gap: 0.25rem;
	padding: 0.45rem 0.6rem; border-radius: var(--radius-s);
	color: var(--ink); text-decoration: none; font-size: var(--fs-sm); line-height: 1.35;
}
.lessons__list a::before { content: counter(lesson); color: var(--muted); font-size: var(--fs-xs); padding-top: 0.1em; font-variant-numeric: tabular-nums; }
.lessons__list a:hover { background: var(--surface); }
.lessons__list a[aria-current="page"] { background: var(--accent-bg); color: var(--accent); font-weight: 700; }
.lessons__list a[aria-current="page"]::before { color: inherit; }
.lessons__all { display: block; padding: 0.75rem 1rem; border-top: 1px solid var(--line); font-size: var(--fs-sm); font-weight: 700; text-decoration: none; }

/* TOC */
.toc details > summary { list-style: none; cursor: pointer; }
.toc details > summary::-webkit-details-marker { display: none; }
.toc__title { font-family: var(--font-head); font-weight: 700; font-size: var(--fs-sm); margin-bottom: 0.75rem; }
.toc__list { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc__item a {
	display: block; margin-left: -2px; padding: 0.3rem 0 0.3rem 0.9rem;
	border-left: 2px solid transparent;
	color: var(--muted); text-decoration: none; font-size: var(--fs-sm); line-height: 1.35;
}
.toc__item--h3 a { padding-left: 1.7rem; font-size: var(--fs-xs); }
.toc__item a:hover { color: var(--ink); }
.toc__item a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 700; }
.toc--inline { margin-bottom: 1.5rem; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; background: var(--surface); }
.toc--inline .toc__title { margin: 0; display: flex; justify-content: space-between; }
.toc--inline .toc__title::after { content: "+"; font-family: var(--font-mono); color: var(--muted); }
.toc--inline details[open] .toc__title { margin-bottom: 0.75rem; }
.toc--inline details[open] .toc__title::after { content: "−"; }

/* ---------- Prose ---------- */
.prose { max-width: 72ch; font-size: 1.0938rem; line-height: 1.75; overflow-wrap: break-word; }
.prose > * + * { margin-top: 1.15em; }
.prose > * { margin-bottom: 0; }
.prose h2 { font-size: var(--fs-xl); margin-top: 2.2em; padding-top: 0.2em; }
.prose h3 { font-size: var(--fs-lg); margin-top: 1.8em; }
.prose h4 { font-size: var(--fs-md); margin-top: 1.6em; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: 0.6em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.35em; }
.prose li::marker { color: var(--muted); }
.prose img { border-radius: var(--radius-s); height: auto; }
.prose figure { margin-inline: 0; }
.prose figcaption, .prose .wp-element-caption { font-size: var(--fs-xs); color: var(--muted); margin-top: 0.5rem; text-align: left; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin-block: 2.5em; }
.prose blockquote {
	margin-inline: 0; padding: 0.25em 0 0.25em 1.25em;
	border-left: 3px solid var(--accent); color: var(--ink); font-size: 1.05em;
}
.prose blockquote cite { display: block; font-size: var(--fs-sm); color: var(--muted); font-style: normal; margin-top: 0.5em; }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); line-height: 1.5; }
.prose .wp-block-table, .prose .table-scroll { overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 0.6em 0.8em; text-align: left; vertical-align: top; }
.prose thead th, .prose tr:first-child th { background: var(--surface); font-family: var(--font-head); }
.prose tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface) 50%, transparent); }
.prose .alignwide { max-width: none; }
.prose .aligncenter { margin-inline: auto; }
.prose .alignleft { float: left; margin: 0.3em 1.5em 1em 0; max-width: 50%; }
.prose .alignright { float: right; margin: 0.3em 0 1em 1.5em; max-width: 50%; }

/* Callout boxes: add class "note", "tip" or "warning" to a Group/Paragraph block */
.prose .note, .prose .tip, .prose .warning {
	--c: var(--t1); --cb: var(--t1-bg);
	padding: 1em 1.2em; border-radius: var(--radius); background: var(--cb); border-left: 4px solid var(--c);
}
.prose .tip { --c: var(--t2); --cb: var(--t2-bg); }
.prose .warning { --c: var(--t3); --cb: var(--t3-bg); }

/* Code */
code, kbd, samp, pre { font-family: var(--font-mono); }
:not(pre) > code {
	font-size: 0.86em; padding: 0.12em 0.38em; border-radius: 4px;
	background: var(--code-inline-bg); color: var(--code-inline-ink);
	overflow-wrap: anywhere;
}
kbd {
	font-size: 0.82em; padding: 0.1em 0.4em; border-radius: 4px;
	border: 1px solid var(--line); border-bottom-width: 2px; background: var(--paper);
}
.code-block { position: relative; margin-top: 1.15em; }
.prose > .code-block + * { margin-top: 1.15em; }
.code-block__bar {
	display: flex; justify-content: space-between; align-items: center;
	background: color-mix(in srgb, var(--code-bg) 85%, #fff 15%); color: #b9bccb;
	border-radius: var(--radius) var(--radius) 0 0;
	padding: 0.35rem 0.5rem 0.35rem 1rem; font-size: var(--fs-xs); font-family: var(--font-mono);
}
.code-block__copy {
	border: 0; background: transparent; color: #e7e8ef; cursor: pointer;
	padding: 0.3rem 0.6rem; border-radius: var(--radius-s); font-size: var(--fs-xs); font-family: var(--font-body); font-weight: 700;
}
.code-block__copy:hover { background: rgba(255, 255, 255, 0.1); }
.code-block__copy.is-done { color: #7ee2b8; }
.prose pre, pre.wp-block-code, .wp-block-code {
	margin: 0; background: var(--code-bg); color: var(--code-ink);
	border: 0;
	padding: 1rem 1.25rem; border-radius: var(--radius);
	font-size: 0.875rem; line-height: 1.65; tab-size: 4;
	overflow-x: auto; white-space: pre;
}
.code-block pre, .code-block .wp-block-code { border-radius: 0 0 var(--radius) var(--radius); margin: 0; }
pre code { background: none; color: inherit; padding: 0; font-size: inherit; }

/* ---------- Article footer ---------- */
.article__foot { max-width: 72ch; margin-top: 2.5rem; display: grid; gap: 2rem; }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.share__label { font-weight: 700; font-size: var(--fs-sm); margin-right: 0.25rem; }
.share__link {
	font-size: var(--fs-xs); font-weight: 700; color: var(--ink); text-decoration: none;
	border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 0.45em 0.9em; cursor: pointer;
}
.share__link:hover { border-color: var(--accent); color: var(--accent); }

.post-nav { display: grid; gap: 1rem; }
@media (min-width: 640px) { .post-nav { grid-template-columns: 1fr 1fr; } }
.post-nav__link {
	display: grid; gap: 0.3rem; padding: 1rem 1.15rem;
	border: 1px solid var(--line); border-radius: var(--radius);
	color: var(--ink); text-decoration: none;
}
.post-nav__link:hover { border-color: var(--accent); }
.post-nav__link--next { text-align: right; grid-column: -2; }
.post-nav__dir { font-size: var(--fs-xs); color: var(--muted); }
.post-nav__title { font-family: var(--font-head); font-weight: 700; line-height: 1.3; }

.author-box { display: flex; gap: 1rem; align-items: flex-start; padding: 1.25rem; background: var(--surface); border-radius: var(--radius); }
.author-box img { border-radius: 50%; flex-shrink: 0; }
.author-box__name { font-family: var(--font-head); font-weight: 700; margin: 0 0 0.25rem; }
.author-box__name a { color: var(--ink); text-decoration: none; }
.author-box__bio { margin: 0; color: var(--muted); font-size: var(--fs-sm); }

.related { background: var(--surface); border-top: 1px solid var(--line); padding-block: 3rem; }
.related__title { font-size: var(--fs-xl); margin-bottom: 1.5rem; }
.related__grid { display: grid; gap: 1.5rem; }
@media (min-width: 640px) { .related__grid { grid-template-columns: repeat(3, 1fr); } }
.tile__title { font-size: var(--fs-md); margin: 0.85rem 0 0.25rem; line-height: 1.3; }
.tile__meta { font-size: var(--fs-xs); color: var(--muted); }

/* ---------- Ads ---------- */
.ad-area { margin-block: 1.5rem; text-align: center; overflow: hidden; }
.ad-area--ad-below-header { margin: 0; padding-block: 0.75rem; border-bottom: 1px solid var(--line); }
.ad-slot { min-height: 90px; display: grid; place-items: center; }
.ad-area--ad-sidebar-article .ad-slot { min-height: 250px; }

/* ---------- Comments ---------- */
.comments { padding-block: 2rem 4rem; border-top: 1px solid var(--line); }
.comments__title, .comment-reply-title { font-size: var(--fs-xl); }
.comment-list, .comment-list .children { list-style: none; padding: 0; margin: 0; }
.comment-list .children { padding-left: 1.5rem; border-left: 2px solid var(--line); }
.comment-body { padding: 1.25rem 0; border-bottom: 1px solid var(--line); }
.comment-author { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; }
.comment-author img { border-radius: 50%; }
.comment-author .says { display: none; }
.comment-metadata { font-size: var(--fs-xs); }
.comment-metadata a { color: var(--muted); text-decoration: none; }
.comment-content { margin-top: 0.6rem; }
.reply a { font-size: var(--fs-sm); font-weight: 700; text-decoration: none; }
.comment-form label { display: block; font-weight: 700; font-size: var(--fs-sm); margin-bottom: 0.3rem; }
.comment-form input:not([type="submit"]):not([type="checkbox"]), .comment-form textarea {
	width: 100%; padding: 0.7em 0.9em; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--paper);
}
.comment-form .comment-form-cookies-consent { display: flex; gap: 0.5rem; align-items: start; }
.comment-form .comment-form-cookies-consent label { font-weight: 400; }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); margin-top: 0; }
.site-footer__grid { display: grid; gap: 2.5rem; padding-block: 3.5rem 2.5rem; }
@media (min-width: 760px) { .site-footer__grid { grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr)); } }
.site-footer__col ul { columns: 1; }
.site-footer__about p { color: var(--muted); font-size: var(--fs-sm); max-width: 44ch; margin-top: 1rem; }
.site-footer .widget-title { border-bottom-color: var(--line); border-bottom-width: 1px; }
.site-footer__col ul { list-style: none; margin: 0; padding: 0; }
.site-footer__col li { padding: 0.3rem 0; }
.site-footer__col a { color: var(--ink); text-decoration: none; font-size: var(--fs-sm); }
.site-footer__col a:hover { color: var(--accent); }
.social-links { list-style: none; display: flex; gap: 0.25rem; padding: 0; margin: 1rem 0 0; }
.social-links a { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-s); color: var(--ink); }
.social-links a:hover { background: var(--surface-2); color: var(--accent); }
.site-footer__bottom { border-top: 1px solid var(--line); }
.site-footer__bottom-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; padding-block: 1.25rem; font-size: var(--fs-xs); color: var(--muted); }
.copyright { margin: 0; }
.footer-menu { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: 0; padding: 0; }
.footer-menu a { color: var(--muted); text-decoration: none; }
.footer-menu a:hover { color: var(--accent); }

.to-top {
	position: fixed; right: 1rem; bottom: 1rem; z-index: 50;
	display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
	background: var(--ink); color: var(--paper);
	opacity: 0; visibility: hidden; transform: translateY(8px);
	transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }

/* ---------- 404 / empty ---------- */
.notfound { padding-block: 4rem 5rem; }
.notfound__code { font-family: var(--font-mono); font-size: clamp(4rem, 3rem + 6vw, 8rem); font-weight: 600; color: var(--accent); line-height: 1; margin-bottom: 1rem; letter-spacing: -0.05em; }
.notfound__title { font-size: var(--fs-2xl); }
.notfound .chips { margin-block: 1.5rem; }
.empty { padding: 2rem 0; }
.empty__title { font-size: var(--fs-xl); }
.empty .chips { margin-top: 1.25rem; }

.full-width-content > * { max-width: none; }

/* WordPress core classes */
.sticky { position: relative; }
.bypostauthor { display: block; }
.wp-caption, .gallery-caption { font-size: var(--fs-xs); color: var(--muted); }
.page-links { margin-top: 2rem; display: flex; gap: 0.5rem; font-weight: 700; }

/* ---------- Motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-motion: no-preference) {
	html { scroll-behavior: smooth; }
}
@media print {
	.site-header, .site-footer, .layout-article__left, .layout-article__right, .ad-area, .share, .post-nav, .related, .comments, .to-top, .toc { display: none !important; }
	.layout-article { display: block; }
	.prose { max-width: none; }
	.prose pre { white-space: pre-wrap; border: 1px solid #ccc; background: #fff; color: #000; }
}
