/* Study Answers: colour-coded subjects, highlighter headings */
:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --ink: #17153a;
  --muted: #5c5a80;
  --line: #e3e3f1;
  --brand: #2a2570;
  --brand-ink: #ffffff;
  --hero: #1e1a5e;
  --hit: #ffd23f;          /* highlighter yellow */
  --hit-ink: #17153a;
  --code: #14123a;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --wrap: 1180px;
  --h: 252;                /* category hue, overridden per category */
  --cat: hsl(var(--h) 62% 42%);
  --cat-soft: hsl(var(--h) 80% 94%);
  --cat-ink: hsl(var(--h) 65% 26%);
  --cat-solid: hsl(var(--h) 62% 36%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg:#0f0e24; --surface:#18173a; --ink:#ecebfb; --muted:#a9a7cf; --line:#2a2956; --brand:#8f86ff; --brand-ink:#0f0e24; --hero:#171552; --hit:#ffd23f; --code:#0b0a1f;
    --cat:hsl(var(--h) 80% 72%); --cat-soft:hsl(var(--h) 38% 20%); --cat-ink:hsl(var(--h) 90% 86%); --cat-solid:hsl(var(--h) 62% 36%); color-scheme: dark; }
}
:root[data-theme="dark"] { --bg:#0f0e24; --surface:#18173a; --ink:#ecebfb; --muted:#a9a7cf; --line:#2a2956; --brand:#8f86ff; --brand-ink:#0f0e24; --hero:#171552; --hit:#ffd23f; --code:#0b0a1f;
  --cat:hsl(var(--h) 80% 72%); --cat-soft:hsl(var(--h) 38% 20%); --cat-ink:hsl(var(--h) 90% 86%); --cat-solid:hsl(var(--h) 62% 36%); color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1.0625rem/1.65 var(--font-body); text-rendering: optimizeLegibility; overflow-x: hidden; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--cat); text-underline-offset: .18em; }
:focus-visible { outline: 3px solid var(--hit); outline-offset: 2px; border-radius: 4px; box-shadow: 0 0 0 5px var(--brand); }
::selection { background: var(--hit); color: var(--hit-ink); }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.12; letter-spacing: -0.02em; margin: 0; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 18px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--hit); color: var(--hit-ink); padding: 8px 14px; z-index: 60; font-weight: 700; }
.skip:focus { left: 8px; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 18px; min-height: 66px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.brand img { height: 40px; width: auto; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--hero); color: var(--hit); font: 800 15px/1 var(--font-head); letter-spacing: 0; }
.brand-name { font: 800 1.25rem/1 var(--font-head); letter-spacing: -0.03em; }
.main-nav { margin-left: auto; }
.main-nav ul { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.main-nav a { display: flex; align-items: center; gap: 8px; padding: 9px 13px; color: var(--ink); text-decoration: none; border-radius: 999px; font-weight: 600; font-size: .95rem; }
.main-nav .dot { width: 9px; height: 9px; border-radius: 50%; background: hsl(var(--h) 70% 52%); flex-shrink: 0; }
.main-nav a:hover { background: var(--cat-soft); }
.main-nav a[aria-current="page"] { background: var(--cat-soft); color: var(--cat-ink); }
.header-tools { display: flex; gap: 2px; }
.icon-btn { display: grid; place-items: center; width: 42px; height: 42px; border: 0; background: none; color: var(--ink); border-radius: 50%; cursor: pointer; }
.icon-btn:hover { background: var(--cat-soft); }
.menu-btn { display: none; }
.search-panel { border-top: 1px solid var(--line); padding: 12px 0; background: var(--surface); }
.search-form, .hero-search { display: flex; gap: 8px; }
.search-form input, .hero-search input { flex: 1; min-width: 0; font: inherit; color: var(--ink); background: var(--surface); border: 2px solid var(--line); border-radius: 999px; padding: 12px 20px; }
.search-form input:focus, .hero-search input:focus { border-color: var(--brand); outline: none; }
.search-form button, .hero-search button { font: 700 1rem var(--font-body); background: var(--hit); color: var(--hit-ink); border: 0; border-radius: 999px; padding: 0 26px; cursor: pointer; }
.search-form button:hover, .hero-search button:hover { filter: brightness(.95); }
@media (max-width: 900px) {
  .menu-btn { display: grid; }
  .header-tools { margin-left: auto; }
  .main-nav { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--line); display: none; margin: 0; }
  .main-nav.open { display: block; }
  .main-nav ul { flex-direction: column; padding: 8px 18px 16px; }
  .main-nav a { padding: 13px 12px; }
}

/* ---------- Hero ---------- */
.hero { position: relative; background: var(--hero); color: #fff; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.12) 1.2px, transparent 1.4px); background-size: 24px 24px; mask-image: linear-gradient(100deg, #000 10%, transparent 70%); -webkit-mask-image: linear-gradient(100deg, #000 10%, transparent 70%); }
.hero-inner { position: relative; display: grid; gap: 36px; padding-top: 48px; padding-bottom: 56px; align-items: center; }
@media (min-width: 960px) { .hero-inner { grid-template-columns: 1.2fr .8fr; gap: 56px; padding-top: 72px; padding-bottom: 80px; } }
.hero-title { font-size: clamp(2.5rem, 6vw, 4.2rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1.02; max-width: 14ch; }
.hero-intro { font-size: 1.2rem; color: #c9c6f5; max-width: 50ch; margin: 18px 0 28px; }
.hero .hero-search { max-width: 560px; }
.hero .hero-search input { background: #fff; color: #17153a; border-color: #fff; padding: 16px 22px; font-size: 1.05rem; }
.hero .hero-search input::placeholder { color: #6a678f; }
.hero .hero-search button { padding: 0 28px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { display: flex; flex-direction: column; justify-content: space-between; gap: 22px; min-height: 124px; padding: 18px; border-radius: 18px; background: hsl(var(--h) 58% 38%); color: #fff; text-decoration: none; position: relative; overflow: hidden; }
.tile::after { content: ""; position: absolute; right: -26px; bottom: -34px; width: 96px; height: 96px; border-radius: 50%; background: hsl(var(--h) 80% 70% / .35); }
.tile-name { font: 700 1.15rem/1.2 var(--font-head); letter-spacing: -0.01em; position: relative; z-index: 1; }
.tile-count { font-size: .9rem; color: rgba(255,255,255,.82); position: relative; z-index: 1; }
.tile:hover { background: hsl(var(--h) 58% 33%); }

/* ---------- Cards ---------- */
.chip { display: inline-block; font: 700 .78rem/1 var(--font-body); padding: 6px 11px; border-radius: 999px; text-decoration: none; background: var(--cat-soft); color: var(--cat-ink); }
.chip:hover { text-decoration: underline; }
.thumb { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; background: linear-gradient(135deg, hsl(var(--h) 68% 52%), hsl(calc(var(--h) + 38) 62% 36%)); }
.thumb-label { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; color: rgba(255,255,255,.9); font: 800 1.5rem/1.1 var(--font-head); letter-spacing: -0.02em; }
.thumb img { position: relative; width: 100%; height: 100%; object-fit: cover; }
.thumb .chip { position: absolute; left: 12px; bottom: 12px; z-index: 2; background: #fff; color: hsl(var(--h) 65% 26%); }
.grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 680px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1020px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 24px; } }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.card:hover { border-color: var(--cat); box-shadow: 0 10px 28px -14px hsl(var(--h) 60% 30% / .45); }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 18px 20px 20px; }
.card-title { font-size: 1.22rem; line-height: 1.25; margin-bottom: 8px; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a:hover { text-decoration: underline; text-decoration-color: var(--cat); text-decoration-thickness: 2px; }
.card-excerpt { margin: 0 0 14px; color: var(--muted); font-size: .98rem; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: auto 0 0; font-size: .875rem; color: var(--muted); }

.lead { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; overflow: hidden; margin: -28px 0 0; position: relative; z-index: 2; box-shadow: 0 24px 48px -28px rgba(30,26,94,.5); }
@media (min-width: 900px) { .lead { grid-template-columns: 1.15fr 1fr; margin-top: -44px; } }
.lead .thumb { aspect-ratio: 16 / 10; }
@media (min-width: 900px) { .lead .thumb { aspect-ratio: auto; min-height: 380px; height: 100%; } }
.lead .thumb-label { font-size: 2.2rem; }
.lead-body { padding: 26px 24px 28px; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; justify-content: center; }
@media (min-width: 900px) { .lead-body { padding: 40px 44px; } }
.lead-title { font-size: clamp(1.7rem, 3.4vw, 2.5rem); font-weight: 800; letter-spacing: -0.03em; }
.lead-title a { color: var(--ink); text-decoration: none; }
.lead-title a:hover { text-decoration: underline; text-decoration-color: var(--cat); text-decoration-thickness: 3px; }
.lead-excerpt { margin: 0; color: var(--muted); max-width: 52ch; }
.btn { display: inline-block; background: var(--brand); color: var(--brand-ink); text-decoration: none; font-weight: 700; padding: 12px 22px; border-radius: 999px; }
.btn:hover { filter: brightness(1.12); }

.section-title { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; letter-spacing: -0.03em; margin: 56px 0 22px; }
.empty { padding: 40px 0; color: var(--muted); }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 36px 0 64px; }
.pg-num, .pg-step { display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding: 0 14px; border: 2px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 700; background: var(--surface); }
.pg-num[aria-current] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
a.pg-num:hover, .pg-step:hover { border-color: var(--brand); }
.pg-gap { padding: 0 4px; color: var(--muted); }

/* ---------- Archive ---------- */
.archive { padding-top: 22px; padding-bottom: 8px; }
.crumbs ol { display: flex; flex-wrap: wrap; list-style: none; margin: 0 0 16px; padding: 0; font-size: .875rem; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin: 0 8px; opacity: .5; }
.crumbs a { color: var(--muted); }
.crumbs span[aria-current] { display: inline-block; max-width: 36ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.archive-head { position: relative; overflow: hidden; background: var(--cat-soft); border-radius: 24px; padding: 34px clamp(22px, 4vw, 52px) 36px; margin: 0 0 32px; }
.archive-head::after { content: ""; position: absolute; right: -70px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: hsl(var(--h) 75% 60% / .22); }
.archive-head h1 { position: relative; z-index: 1; font-size: clamp(2.1rem, 5.5vw, 3.6rem); font-weight: 800; letter-spacing: -0.04em; color: var(--cat-ink); margin-bottom: 8px; }
.archive-intro, .archive-count { position: relative; z-index: 1; color: var(--cat-ink); margin: 0; max-width: 60ch; opacity: .9; }
.archive-head .hero-search { position: relative; z-index: 1; margin: 18px 0 10px; max-width: 560px; }

/* ---------- Single post ---------- */
.single { --link: hsl(var(--h) 70% 38%); }
:root[data-theme="dark"] .single { --link: hsl(var(--h) 90% 78%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .single { --link: hsl(var(--h) 90% 78%); } }
.single-head { padding-top: 26px; max-width: 980px; }
.single-title { font-size: clamp(2.1rem, 5.4vw, 3.5rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1.04; margin: 14px 0 20px; }
.single-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin: 0 0 26px; color: var(--muted); font-size: .95rem; }
.byline { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--hero); color: var(--hit); font: 800 .95rem var(--font-head); }
.single-figure { margin: 0 auto 12px; max-width: 980px; }
.single-figure img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 22px; border: 1px solid var(--line); }

.sheet { display: grid; padding-top: 22px; padding-bottom: 36px; max-width: 980px; }
@media (min-width: 1100px) { .sheet.has-toc { max-width: var(--wrap); grid-template-columns: 250px minmax(0, 1fr); gap: 64px; } }
.prose { min-width: 0; max-width: 70ch; font-size: 1.125rem; line-height: 1.75; }
.sheet:not(.has-toc) .prose { margin: 0 auto; }

.toc { margin-bottom: 22px; }
.toc details { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 12px 18px; }
.toc summary { cursor: pointer; font: 700 1rem var(--font-head); }
.toc ol { list-style: none; margin: 10px 0 0; padding: 0; font-size: .93rem; line-height: 1.4; }
.toc a { display: block; padding: 6px 0 6px 12px; color: var(--muted); text-decoration: none; border-left: 3px solid var(--line); }
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--ink); border-left-color: var(--cat); font-weight: 700; }
.toc .toc-l3 a { padding-left: 26px; font-size: .88rem; }
@media (min-width: 1100px) {
  .toc { margin: 0; }
  .toc details { position: sticky; top: 88px; max-height: calc(100vh - 110px); overflow: auto; border: 0; background: none; padding: 0; }
  .toc summary { list-style: none; color: var(--muted); font-size: .9rem; pointer-events: none; margin-bottom: 4px; }
  .toc summary::-webkit-details-marker { display: none; }
}

.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose .table-wrap, .prose figure { margin: 0 0 1.2em; }
.prose a { color: var(--link); font-weight: 500; }
.prose h2 { font-size: clamp(1.6rem, 3vw, 2rem); font-weight: 800; margin: 2.2em 0 .8em; scroll-margin-top: 84px; width: fit-content; max-width: 100%; padding-bottom: .05em; background: linear-gradient(var(--hit), var(--hit)) no-repeat 0 92% / 100% .36em; color: var(--ink); }
:root[data-theme="dark"] .prose h2 { background-image: linear-gradient(hsl(var(--h) 60% 38%), hsl(var(--h) 60% 38%)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .prose h2 { background-image: linear-gradient(hsl(var(--h) 60% 38%), hsl(var(--h) 60% 38%)); } }
.prose h3 { font-size: 1.35rem; font-weight: 700; margin: 1.8em 0 .5em; scroll-margin-top: 84px; }
.prose h4 { font-size: 1.12rem; margin: 1.5em 0 .4em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .35em 0; padding-left: .2em; }
.prose li::marker { color: var(--cat); font-weight: 700; }
.prose strong { font-weight: 700; }
.prose mark { background: var(--hit); color: var(--hit-ink); padding: 0 .2em; border-radius: 3px; }
.prose hr { border: 0; border-top: 2px dashed var(--line); margin: 2.4em 0; }
.prose blockquote { margin-left: 0; padding: 16px 20px; background: var(--cat-soft); color: var(--cat-ink); border-radius: 14px; border-left: 5px solid var(--cat); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code { font-family: var(--font-mono); font-size: .88em; background: var(--cat-soft); color: var(--cat-ink); padding: .12em .4em; border-radius: 6px; }
.prose pre { background: var(--code); color: #ecebfb; padding: 18px 20px; border-radius: 14px; overflow-x: auto; font-size: .92rem; line-height: 1.6; }
.prose pre code { background: none; color: inherit; padding: 0; }
.prose img { border-radius: 14px; border: 1px solid var(--line); }
.prose figcaption { font-size: .875rem; color: var(--muted); text-align: center; margin-top: 8px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.prose table { border-collapse: collapse; width: 100%; font-size: .96rem; min-width: 480px; }
.prose th, .prose td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { background: var(--cat-soft); color: var(--cat-ink); font-weight: 700; }
.prose tr:last-child td { border-bottom: 0; }

.share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 44px 0 16px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; font-size: 1rem; }
.share-label { font-weight: 700; margin-right: 6px; }
.share a, .share button { font: 700 .875rem var(--font-body); color: var(--ink); border: 2px solid var(--line); background: var(--bg); padding: 7px 14px; border-radius: 999px; text-decoration: none; cursor: pointer; }
.share a:hover, .share button:hover { border-color: var(--brand); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 12px 0 0; }
.tags a { display: inline-block; padding: 5px 12px; border-radius: 999px; background: var(--cat-soft); color: var(--cat-ink); font-size: .9rem; text-decoration: none; font-weight: 500; }
.tags a:hover { text-decoration: underline; }

.adjacent { display: grid; gap: 12px; margin-top: 8px; max-width: 980px; }
@media (min-width: 720px) { .adjacent { grid-template-columns: 1fr 1fr; } }
.adjacent a { display: block; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); text-decoration: none; font: 700 1.05rem/1.35 var(--font-head); background: var(--surface); }
.adjacent a span { display: block; font: 500 .85rem var(--font-body); color: var(--muted); margin-bottom: 4px; }
.adjacent a:hover { border-color: var(--brand); }
.adj-next { text-align: right; }
.related { margin-bottom: 48px; }
.is-page .sheet { max-width: 860px; }
.preview-bar { background: var(--hit); color: var(--hit-ink); text-align: center; padding: 8px 16px; font-weight: 700; }
.notfound { padding: 60px 18px 24px; }
.notfound h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); font-weight: 800; margin-bottom: 12px; }
.notfound p { color: var(--muted); max-width: 52ch; }
.notfound .hero-search { margin: 22px 0 8px; max-width: 520px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--hero); color: #c9c6f5; margin-top: 56px; padding: 52px 0 26px; font-size: .96rem; }
.footer-grid { display: grid; gap: 32px; }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr; } }
.footer-brand { font: 800 1.5rem var(--font-head); color: #fff; margin: 0 0 6px; letter-spacing: -0.02em; }
.footer-note { margin: 0 0 14px; max-width: 34ch; }
.footer-head { font: 700 1rem var(--font-head); color: #fff; margin: 0 0 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 6px 0; }
.site-footer a { color: #c9c6f5; text-decoration: none; }
.site-footer a:hover { color: var(--hit); text-decoration: underline; }
.footer-social { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.footer-bottom { margin-top: 36px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.14); font-size: .875rem; color: #9a97d0; }

@media print {
  .site-header, .site-footer, .share, .adjacent, .related, .toc { display: none !important; }
  body { background: #fff; color: #000; }
}