:root {
  color-scheme: dark;
  --background: #0e1522;
  --surface: #172335;
  --surface-soft: #1b2a3e;
  --text: #eef3fb;
  --muted: #b7c5d7;
  --border: #35465d;
  --accent: #90bfff;
  --accent-soft: #263f61;
  --button: #2164ae;
  --button-hover: #2b76c4;
  --header: #10294f;
  --hero: linear-gradient(125deg, #102d54 0%, #17365f 60%, #142a48 100%);
  --shadow: 0 14px 32px rgb(3 10 20 / 16%);
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #f3f6fb;
  --surface: #fff;
  --surface-soft: #f2f6fb;
  --text: #18243b;
  --muted: #53637a;
  --border: #d7e1ed;
  --accent: #155ca8;
  --accent-soft: #e8f1fc;
  --button: #174f91;
  --button-hover: #0f3f79;
  --header: #10294f;
  --hero: linear-gradient(125deg, #102d54 0%, #193c70 60%, #17335d 100%);
  --shadow: 0 12px 30px rgb(24 48 78 / 7%);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --background: #f3f6fb;
    --surface: #fff;
    --surface-soft: #f2f6fb;
    --text: #18243b;
    --muted: #53637a;
    --border: #d7e1ed;
    --accent: #155ca8;
    --accent-soft: #e8f1fc;
    --button: #174f91;
    --button-hover: #0f3f79;
    --header: #10294f;
    --hero: linear-gradient(125deg, #102d54 0%, #193c70 60%, #17335d 100%);
    --shadow: 0 12px 30px rgb(24 48 78 / 7%);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: .12em; }
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #63a8f4; outline-offset: 3px; }
[hidden] { display: none !important; }
.container { width: min(100% - 3rem, 1280px); margin-inline: auto; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  z-index: 20;
  top: .75rem;
  left: .75rem;
  padding: .6rem 1rem;
  border-radius: .5rem;
  background: #fff;
  color: #10294f;
  transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); }

.site-header { background: var(--header); color: #f6f9ff; border-bottom: 1px solid #34517a; }
.site-header__inner {
  min-height: 94px;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.brand { display: inline-flex; align-items: center; flex-shrink: 0; gap: .75rem; color: inherit; text-decoration: none; }
.brand__mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid #7999c1;
  border-radius: 12px;
  background: #244b7e;
  font-size: .9rem;
  font-weight: 800;
  letter-spacing: .04em;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.3; }
.brand__text strong { font-size: 1.05rem; letter-spacing: -.02em; }
.brand__text span { color: #c3d3e8; font-size: .7rem; }
.primary-nav { display: flex; align-items: center; justify-content: center; flex: 1; gap: 1.5rem; }
.primary-nav a { color: #dce8f8; font-size: .875rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.primary-nav a:hover, .primary-nav a[aria-current="page"] { color: #fff; text-decoration: underline; text-underline-offset: .45em; }
.header-actions { display: flex; align-items: center; gap: .6rem; }
.header-search {
  display: flex;
  align-items: center;
  width: 190px;
  border: 1px solid #577092;
  border-radius: .7rem;
  background: #19385f;
}
.header-search:focus-within { outline: 2px solid #a8cfff; outline-offset: 2px; }
.header-search input { width: 100%; min-width: 0; padding: .6rem 0 .6rem .8rem; border: 0; outline: 0; color: #fff; background: transparent; font-size: .85rem; }
.header-search input::placeholder { color: #bed0e6; }
.header-search button { display: grid; place-items: center; padding: .6rem; border: 0; background: transparent; color: #dceaff; }
.header-search svg { width: 20px; height: 20px; }
.theme-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #577092;
  border-radius: .7rem;
  background: #19385f;
  color: #fff;
  font-size: 1.25rem;
}
.theme-toggle:hover, .header-search button:hover { color: #fff; background: #254c7b; }

main { padding-block: 2.5rem 5rem; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .85fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  padding: clamp(2rem, 5vw, 4.5rem);
  overflow: hidden;
  border: 1px solid #31547e;
  border-radius: 1.4rem;
  background: var(--hero);
  color: #f5f8ff;
  box-shadow: var(--shadow);
}
.hero__eyebrow, .eyebrow, .card-label, .panel-kicker {
  margin: 0 0 .7rem;
  font-size: .7rem;
  font-weight: 750;
  letter-spacing: .1em;
  line-height: 1.4;
  text-transform: uppercase;
}
.eyebrow, .card-label { color: var(--accent); }
.hero__eyebrow { display: flex; align-items: center; gap: .55rem; color: #bddefe; }
.hero__eyebrow span { width: .5rem; height: .5rem; border-radius: 50%; background: #77dfcb; }
.hero h1 { max-width: 14ch; margin: 0; font-size: clamp(2.4rem, 4.5vw, 4.2rem); letter-spacing: -.045em; line-height: 1.08; }
.hero h1 span { color: #a7cffc; }
.hero__description { max-width: 58ch; margin: 1.4rem 0 0; color: #d5e4f6; font-size: 1.05rem; }
.hero__actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.8rem; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  min-height: 46px;
  padding: .65rem 1rem;
  border: 1px solid transparent;
  border-radius: .65rem;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
}
.button--primary { background: #fff; color: #12355f; }
.button--primary:hover { background: #e2efff; }
.button--secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.button--secondary:hover { background: var(--surface-soft); }
.hero .button--secondary { border-color: #80a1c8; background: transparent; color: #fff; }
.hero .button--secondary:hover { background: rgb(255 255 255 / 9%); }
.hero__tags { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 2rem; }
.hero__tags span { padding: .28rem .65rem; border: 1px solid #5b7da5; border-radius: 999px; color: #d9e8f9; font-size: .72rem; }
.hero-panel { padding: 1.35rem; border: 1px solid #51749d; border-radius: 1rem; background: rgb(6 23 48 / 38%); }
.hero-panel__heading { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: .7rem; }
.panel-kicker { color: #aecded; }
.hero-panel h2 { margin: 0; color: #fff; font-size: 1.15rem; line-height: 1.3; }
.hero-panel__symbol { color: #b9d8fa; font-size: 1.3rem; }
.hero-panel__item {
  display: grid;
  grid-template-columns: 2.25rem 1fr auto;
  align-items: center;
  gap: .8rem;
  padding: 1rem 0;
  border-top: 1px solid #426286;
  color: #eaf3ff;
  text-decoration: none;
}
.hero-panel__item:hover strong { text-decoration: underline; text-underline-offset: .2em; }
.hero-panel__number { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: .6rem; background: #284f7f; color: #cbe4ff; font-size: .75rem; font-weight: 700; }
.hero-panel__item strong, .hero-panel__item small { display: block; }
.hero-panel__item strong { font-size: .88rem; line-height: 1.35; }
.hero-panel__item small { margin-top: .15rem; color: #bdd0e6; font-size: .75rem; }

.home-section { margin-top: 4.5rem; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 1.5rem; margin-bottom: 1.5rem; }
.section-heading h2, .library-cta h2 { margin: 0; font-size: clamp(1.7rem, 2.7vw, 2.15rem); letter-spacing: -.035em; line-height: 1.2; }
.section-heading p:not(.eyebrow), .library-cta p:not(.eyebrow) { margin: .55rem 0 0; color: var(--muted); }
.text-link { color: var(--accent); font-size: .88rem; font-weight: 700; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.featured-grid, .topic-grid { display: grid; gap: 1rem; }
.featured-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.featured-card, .topic-card, .search-result {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.featured-card { overflow: hidden; }
.featured-card__image { display: block; height: 190px; overflow: hidden; background: #edf3fa; }
.featured-card__image img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.featured-card__body { padding: 1.4rem; }
.featured-card h3, .topic-card h2, .topic-card h3, .search-result h2 { margin: 0; font-size: 1.15rem; letter-spacing: -.02em; line-height: 1.35; }
.featured-card h3 a, .topic-card h2 a, .topic-card h3 a, .search-result h2 a { color: var(--text); text-decoration: none; }
.featured-card h3 a:hover, .topic-card h2 a:hover, .topic-card h3 a:hover, .search-result h2 a:hover { color: var(--accent); text-decoration: underline; }
.featured-card__body > p:not(.card-label), .topic-card > p:not(.card-label), .search-result p { margin: .7rem 0 1rem; color: var(--muted); font-size: .9rem; }
.topic-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.topic-card { display: flex; flex-direction: column; padding: 1.4rem; }
.topic-card > .text-link { margin-top: auto; }
.topic-card__top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: 1.35rem; }
.topic-number { display: grid; place-items: center; width: 2.35rem; height: 2.35rem; border-radius: .7rem; background: var(--accent-soft); color: var(--accent); font-size: .8rem; font-weight: 750; }
.status-label { padding: .2rem .55rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .7rem; font-weight: 600; }
.topic-card .card-label { margin-bottom: .45rem; }
.topic-sublist { display: flex; flex-wrap: wrap; gap: .45rem; padding: 0; margin: 0 0 1.25rem; list-style: none; }
.topic-sublist a { display: inline-block; padding: .25rem .55rem; border: 1px solid var(--border); border-radius: .45rem; color: var(--text); font-size: .75rem; text-decoration: none; }
.topic-sublist a:hover { color: var(--accent); border-color: var(--accent); }
.library-cta { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; margin-top: 4.5rem; padding: 2rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--surface-soft); }

.page-shell { max-width: 980px; margin-inline: auto; }
.article-header { margin-bottom: 2rem; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 2rem; color: var(--muted); font-size: .83rem; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.article-header h1 { max-width: 23ch; margin: 0; font-size: clamp(2.1rem, 4vw, 3.4rem); letter-spacing: -.04em; line-height: 1.15; overflow-wrap: anywhere; }
.article-subtitle { max-width: 65ch; margin: 1rem 0 0; color: var(--muted); font-size: 1.1rem; }
.article-meta { display: flex; flex-wrap: wrap; gap: .35rem 1.2rem; margin-top: 1.1rem; color: var(--muted); font-size: .83rem; }
.article-image { margin: 0 0 2rem; }
.article-image img { width: 100%; max-height: 620px; border: 1px solid var(--border); border-radius: .8rem; object-fit: contain; background: #fff; }
.article-image figcaption { margin-top: .5rem; color: var(--muted); font-size: .8rem; text-align: right; }
.article-toc { margin: 0 0 2rem; padding: .9rem 1.1rem; border: 1px solid var(--border); border-radius: .8rem; background: var(--surface); }
.article-toc summary { cursor: pointer; font-weight: 700; }
.article-toc ul { margin: .75rem 0 0; padding-left: 1.2rem; }
.article-toc li { margin: .25rem 0; }
.article-toc a { font-size: .9rem; }
.prose { padding: clamp(1.3rem, 3vw, 2.5rem); border: 1px solid var(--border); border-radius: 1rem; background: var(--surface); box-shadow: var(--shadow); overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { color: var(--text); line-height: 1.3; scroll-margin-top: 1.5rem; }
.prose h1 { font-size: 1.8rem; }
.prose h2 { margin: 2.2rem 0 .9rem; font-size: 1.5rem; letter-spacing: -.025em; }
.prose h3 { margin: 1.7rem 0 .7rem; font-size: 1.18rem; }
.prose h4 { margin: 1.3rem 0 .5rem; font-size: 1rem; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table { margin: 0 0 1.15rem; }
.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li { margin: .35rem 0; }
.prose blockquote { padding: .7rem 1rem; border-left: 3px solid var(--accent); background: var(--surface-soft); color: var(--muted); }
.prose blockquote > :last-child { margin-bottom: 0; }
.prose hr { margin: 2rem 0; border: 0; border-top: 1px solid var(--border); }
.prose img { border-radius: .6rem; }
.prose pre { padding: 1rem; overflow-x: auto; border-radius: .6rem; background: var(--surface-soft); }
.prose code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.prose th, .prose td { padding: .6rem .8rem; border: 1px solid var(--border); text-align: left; }
.series-navigation { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1.5rem; }
.series-navigation a { flex: 1 1 240px; padding: 1rem; border: 1px solid var(--border); border-radius: .8rem; background: var(--surface); color: var(--text); text-decoration: none; }
.series-navigation a:hover strong { color: var(--accent); text-decoration: underline; }
.series-navigation span, .series-navigation strong { display: block; }
.series-navigation span { color: var(--muted); font-size: .78rem; }
.series-navigation strong { margin-top: .2rem; font-size: .9rem; }
.series-navigation__next { margin-left: auto; text-align: right; }

.catalogue-intro { max-width: 70ch; margin: 0 0 2rem; color: var(--muted); }
.catalogue-grid { margin-top: 2rem; }
.search-form { display: flex; gap: .6rem; margin-bottom: 1rem; }
.search-form input { flex: 1; min-width: 0; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); color: var(--text); }
.search-form button { border: 0; background: var(--button); color: #fff; }
.search-form button:hover { background: var(--button-hover); }
.search-status { min-height: 1.6em; color: var(--muted); font-size: .9rem; }
.search-results { display: grid; gap: .8rem; margin-top: 1rem; }
.search-result { padding: 1.25rem; }
.search-result p { margin-bottom: 0; }
.search-result__url { margin-top: .5rem; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }

.site-footer { padding: 2rem 0; border-top: 1px solid var(--border); background: var(--surface); }
.site-footer__inner { display: flex; justify-content: space-between; gap: 1.5rem; align-items: center; }
.site-footer p { margin: .2rem 0 0; color: var(--muted); font-size: .85rem; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 1rem; color: var(--muted); font-size: .8rem; }
.site-footer__links a { color: var(--muted); }

@media (max-width: 1080px) {
  .site-header__inner { flex-wrap: wrap; gap: 1rem 1.5rem; padding-block: 1rem; }
  .primary-nav { justify-content: flex-start; order: 3; flex-basis: 100%; }
  .header-actions { margin-left: auto; }
}
@media (max-width: 850px) {
  .hero { grid-template-columns: 1fr; }
  .hero h1 { max-width: 18ch; }
  .topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  .container { width: min(100% - 2rem, 1280px); }
  .site-header__inner { gap: .9rem; }
  .brand { flex-basis: 100%; }
  .primary-nav { order: 0; flex-wrap: wrap; gap: .5rem 1rem; }
  .header-actions { width: 100%; margin-left: 0; }
  .header-search { flex: 1; width: auto; }
  main { padding-block: 1.25rem 3.5rem; }
  .hero { padding: 1.6rem; border-radius: 1rem; }
  .hero h1 { font-size: clamp(2.1rem, 9vw, 3rem); }
  .home-section { margin-top: 3rem; }
  .section-heading, .library-cta, .site-footer__inner { align-items: flex-start; flex-direction: column; }
  .featured-grid, .topic-grid { grid-template-columns: 1fr; }
  .featured-card__image { height: 170px; }
  .library-cta { margin-top: 3rem; padding: 1.4rem; }
  .search-form { flex-wrap: wrap; }
  .search-form input { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
