/* ============================================================
   Actuarial Validation & Filing Automation — Design System
   Light, professional palette · elegant · responsive · wide.
   ============================================================ */

:root {
  /* Palette */
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e8eef7;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --primary-deep: #1e3a8a;
  --primary: #1d4ed8;
  --primary-600: #2563eb;
  --primary-300: #93c5fd;
  --primary-050: #eff5ff;

  --teal: #0d9488;
  --teal-600: #0f766e;
  --teal-050: #ecfdf9;

  --gold: #f59e0b;
  --gold-600: #d97706;
  --gold-050: #fff8eb;

  --violet: #7c3aed;
  --rose: #e11d48;

  /* Typography */
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-head: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    ui-serif, serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Code",
    Menlo, Consolas, monospace;

  /* Scale */
  --step--1: clamp(0.83rem, 0.8rem + 0.15vw, 0.92rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.08rem);
  --step-1: clamp(1.2rem, 1.12rem + 0.4vw, 1.4rem);
  --step-2: clamp(1.45rem, 1.32rem + 0.65vw, 1.85rem);
  --step-3: clamp(1.75rem, 1.55rem + 1vw, 2.45rem);
  --step-4: clamp(2.1rem, 1.78rem + 1.6vw, 3.25rem);

  /* Space + shape */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06),
    0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow: 0 6px 18px rgba(15, 23, 42, 0.08),
    0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 24px 60px -20px rgba(30, 58, 138, 0.35);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.28);

  --header-h: 68px;
  --container: 1320px;
  --measure: 1180px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.7;
  color: var(--ink-soft);
  background: var(--bg);
  background-image: radial-gradient(
      1200px 600px at 110% -5%,
      var(--primary-050),
      transparent 60%
    ),
    radial-gradient(900px 500px at -10% 0%, var(--teal-050), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img,
svg {
  max-width: 100%;
  height: auto;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-head);
  color: var(--ink);
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.01em;
}
a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.18s var(--ease);
}
a:hover {
  color: var(--primary-deep);
}
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 4px;
}

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1rem, 3vw, 2.5rem);
}
.site-main {
  flex: 1 0 auto;
  width: 100%;
  padding-block: clamp(1.75rem, 3vw, 3rem);
}
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  z-index: 100;
  transition: top 0.2s var(--ease);
}
.skip-link:focus {
  top: 0.5rem;
  color: #fff;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .container {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brand:hover {
  color: var(--ink);
}
.brand img {
  width: 38px;
  height: 38px;
  filter: drop-shadow(0 3px 6px rgba(30, 58, 138, 0.25));
  transition: transform 0.3s var(--ease);
}
.brand:hover img {
  transform: rotate(-6deg) scale(1.06);
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-text b {
  font-size: 1.02rem;
}
.brand-text span {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-600);
}

.main-nav {
  margin-left: auto;
}
.main-nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
}
.main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  position: relative;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.main-nav a svg {
  width: 18px;
  height: 18px;
}
.main-nav a:hover {
  background: var(--primary-050);
  color: var(--primary-deep);
}
.main-nav a[aria-current="page"],
.main-nav a.is-active {
  background: linear-gradient(120deg, var(--primary), var(--primary-600));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.main-nav a[aria-current="page"]::after,
.main-nav a.is-active::after {
  content: "";
}

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}
.nav-toggle svg {
  width: 22px;
  height: 22px;
}

@media (max-width: 820px) {
  .nav-toggle {
    display: inline-flex;
  }
  .main-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateY(-130%);
    transition: transform 0.32s var(--ease);
    margin: 0;
  }
  .main-nav.open {
    transform: translateY(0);
  }
  .main-nav ul {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
    gap: 0.25rem;
  }
  .main-nav a {
    padding: 0.8rem 1rem;
    font-size: 1.02rem;
  }
}

/* ============================================================
   Hero (homepage)
   ============================================================ */
.hero {
  text-align: center;
  padding-block: clamp(1.5rem, 4vw, 3rem) clamp(2rem, 5vw, 4rem);
}
.hero-logo {
  display: block;
  width: clamp(120px, 22vw, 188px);
  height: auto;
  margin: 0 auto clamp(1.2rem, 3vw, 1.8rem);
  filter: drop-shadow(0 18px 36px rgba(30, 58, 138, 0.28));
  animation: floaty 6s ease-in-out infinite;
}
@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}
.hero h1 {
  font-size: var(--step-4);
  margin: 0 0 0.6rem;
  background: linear-gradient(110deg, var(--primary-deep), var(--primary-600) 45%, var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .lede {
  font-size: var(--step-1);
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0 auto 0.75rem;
}
.hero .sub {
  max-width: 72ch;
  margin: 0 auto;
  color: var(--muted);
}
.eyebrow {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-600);
  background: var(--teal-050);
  border: 1px solid #cdeee6;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  margin-bottom: 1.1rem;
}

/* CTA buttons with colorful icons */
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
  margin-top: 1.8rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.3rem;
  border-radius: 12px;
  font-weight: 650;
  font-size: 0.98rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease),
    border-color 0.2s var(--ease);
}
.btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn .btn-ico {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: #fff;
}
.btn .btn-ico svg {
  width: 18px;
  height: 18px;
}
.btn-primary {
  background: linear-gradient(120deg, var(--primary), var(--primary-600));
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover {
  color: #fff;
}
.btn-primary .btn-ico {
  background: rgba(255, 255, 255, 0.22);
}
.ico-blue {
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
}
.ico-teal {
  background: linear-gradient(135deg, var(--teal), var(--teal-600));
}
.ico-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-600));
}
.ico-violet {
  background: linear-gradient(135deg, var(--violet), #6d28d9);
}

/* ============================================================
   Section cards (homepage)
   ============================================================ */
.section-head {
  text-align: center;
  max-width: 64ch;
  margin: clamp(2rem, 5vw, 3.5rem) auto 1.8rem;
}
.section-head h2 {
  font-size: var(--step-3);
  margin: 0 0 0.5rem;
}
.section-head p {
  color: var(--muted);
  margin: 0;
}
.card-grid {
  display: grid;
  gap: 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease),
    border-color 0.25s var(--ease);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--teal), var(--gold));
  opacity: 0.9;
}
.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-300);
}
.card-ico {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.card-ico svg {
  width: 26px;
  height: 26px;
}
.card h3 {
  margin: 0 0 0.5rem;
  font-size: var(--step-1);
}
.card h3 a {
  color: var(--ink);
}
.card h3 a:hover {
  color: var(--primary);
}
.card p {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.96rem;
}
.card .card-links {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--line);
}
.card .card-links a {
  font-size: 0.88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.card .card-links a::before {
  content: "→";
  color: var(--teal);
  transition: transform 0.2s var(--ease);
  display: inline-block;
}
.card .card-links a:hover::before {
  transform: translateX(3px);
}

/* ============================================================
   Content pages
   ============================================================ */
.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
@media (min-width: 1080px) {
  .content-layout.has-toc {
    grid-template-columns: minmax(0, 1fr) 250px;
  }
}
.article {
  min-width: 0;
  max-width: var(--measure);
}
.article-header {
  margin-bottom: 1.5rem;
}
.article-title {
  font-size: var(--step-4);
  margin: 0.4rem 0 0.6rem;
  background: linear-gradient(115deg, var(--primary-deep), var(--primary-600) 55%, var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.article-lede {
  color: var(--muted);
  font-size: var(--step-1);
}

/* Prose */
.prose {
  font-size: var(--step-0);
}
.prose > * + * {
  margin-top: 1.15em;
}
.prose h2 {
  font-size: var(--step-2);
  margin-top: 2.2em;
  padding-bottom: 0.3em;
  border-bottom: 2px solid var(--line);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
.prose h2::before {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-right: 0.5em;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  vertical-align: middle;
}
.prose h3 {
  font-size: var(--step-1);
  margin-top: 1.8em;
  color: var(--primary-deep);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
.prose h4 {
  font-size: var(--step-0);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal-600);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
.prose p {
  color: var(--ink-soft);
}
.prose a {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--primary-300);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  transition: color 0.18s var(--ease), text-decoration-color 0.18s var(--ease);
}
.prose a:hover {
  text-decoration-color: var(--primary);
}
.heading-anchor {
  margin-left: 0.4rem;
  color: var(--line-strong);
  opacity: 0;
  font-weight: 400;
  text-decoration: none;
  transition: opacity 0.18s var(--ease), color 0.18s var(--ease);
}
.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.prose h4:hover .heading-anchor {
  opacity: 1;
}
.heading-anchor:hover {
  color: var(--primary);
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}
.prose li {
  margin-top: 0.4em;
}
.prose li::marker {
  color: var(--teal);
}
.prose blockquote {
  margin: 1.4em 0;
  padding: 0.6em 1.2em;
  border-left: 4px solid var(--primary);
  background: var(--primary-050);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
  font-style: italic;
}
.prose hr {
  border: none;
  height: 1px;
  background: var(--line);
  margin: 2.5em 0;
}
.prose strong {
  color: var(--ink);
}

/* Inline code — subtle, borderless, blends in */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-3);
  color: var(--primary-deep);
  padding: 0.12em 0.4em;
  border-radius: 6px;
  word-break: break-word;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 1.4em 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  min-width: 480px;
}
.prose thead {
  background: linear-gradient(120deg, var(--primary-deep), var(--primary-600));
  color: #fff;
}
.prose th,
.prose td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.prose tbody tr:nth-child(even) {
  background: var(--surface-2);
}
.prose tbody tr:hover {
  background: var(--primary-050);
}

/* Task lists — interactive checkboxes, no bullet, strike when done */
.prose .task-list-item {
  list-style: none;
}
.prose ul.contains-task-list {
  padding-left: 0.2em;
}
.prose .task-list-item-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 1.15em;
  height: 1.15em;
  margin-right: 0.55em;
  border: 2px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  vertical-align: -0.18em;
  cursor: pointer;
  position: relative;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.prose .task-list-item-checkbox:hover {
  border-color: var(--primary);
}
.prose .task-list-item-checkbox:checked {
  background: linear-gradient(135deg, var(--teal), var(--teal-600));
  border-color: var(--teal-600);
}
.prose .task-list-item-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 0.32em;
  top: 0.08em;
  width: 0.3em;
  height: 0.6em;
  border: solid #fff;
  border-width: 0 0.16em 0.16em 0;
  transform: rotate(45deg);
}
.prose .task-list-item.is-checked {
  text-decoration: line-through;
  color: var(--muted);
  text-decoration-color: var(--line-strong);
}

/* ============================================================
   Code blocks (Prism light theme) + copy button
   ============================================================ */
.code-block {
  position: relative;
  margin: 1.5em 0;
}
.code-block .code-lang {
  position: absolute;
  top: 0;
  left: 1rem;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(120deg, var(--primary), var(--teal));
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.32rem 0.6rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s var(--ease), background 0.18s var(--ease),
    color 0.18s var(--ease);
  z-index: 2;
}
.copy-btn svg {
  width: 14px;
  height: 14px;
}
.code-block:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}
.copy-btn:hover {
  background: var(--primary-050);
  color: var(--primary-deep);
  border-color: var(--primary-300);
}
.copy-btn.copied {
  background: var(--teal-050);
  color: var(--teal-600);
  border-color: #a7e8da;
  opacity: 1;
}

pre[class*="language-"] {
  margin: 0;
  padding: 1.25rem 1.25rem;
  overflow: auto;
  border-radius: var(--radius);
  background: #fbfcfe;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.65;
  tab-size: 4;
  color: #334155;
}
code[class*="language-"] {
  font-family: var(--font-mono);
  color: #334155;
  text-shadow: none;
  white-space: pre;
}
/* Token colors — light scheme matched to site */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #8a98ab;
  font-style: italic;
}
.token.punctuation {
  color: #64748b;
}
.token.keyword,
.token.control,
.token.important {
  color: #7c3aed;
  font-weight: 600;
}
.token.boolean,
.token.number,
.token.constant {
  color: #d97706;
}
.token.string,
.token.char,
.token.attr-value {
  color: #0f766e;
}
.token.function,
.token.method,
.token.class-name {
  color: #2563eb;
}
.token.builtin,
.token.tag {
  color: #1e3a8a;
}
.token.operator,
.token.entity,
.token.url {
  color: #475569;
}
.token.decorator,
.token.annotation {
  color: #be185d;
}
.token.parameter {
  color: #b45309;
}

/* Mermaid */
.mermaid {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-align: center;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  margin: 1.6em 0;
  position: relative;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.mermaid:not([data-viz-ready]) {
  min-height: 60px;
  color: transparent;
}
.mermaid.viz-enabled {
  cursor: zoom-in;
}
.mermaid.viz-enabled:hover {
  border-color: var(--primary-300);
  box-shadow: var(--shadow);
}
.mermaid svg {
  max-width: 100%;
  height: auto;
}
.viz-hint {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s var(--ease);
}
.viz-hint svg {
  width: 14px;
  height: 14px;
}
.mermaid.viz-enabled:hover .viz-hint {
  opacity: 1;
}

/* Diagram lightbox / full-screen */
.viz-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 2.5rem);
  /* Fully opaque so the underlying page diagram can't bleed through */
  background: #0b1220;
  background-image: radial-gradient(120% 100% at 50% 0%, #16213b, #0b1220 70%);
  animation: viz-fade 0.18s var(--ease);
}
.viz-modal.open {
  display: flex;
}
@keyframes viz-fade {
  from {
    opacity: 0;
  }
}
.viz-stage {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: clamp(1rem, 3vw, 2rem);
  max-width: 96vw;
  max-height: 92vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.viz-stage svg {
  display: block;
  margin: auto;
  width: auto;
  height: auto;
  max-width: 90vw;
  max-height: 84vh;
}
.viz-close {
  position: fixed;
  top: clamp(0.75rem, 2vw, 1.25rem);
  right: clamp(0.75rem, 2vw, 1.25rem);
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.18s var(--ease);
}
.viz-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: rotate(90deg);
}
.viz-close svg {
  width: 22px;
  height: 22px;
}

/* KaTeX block spacing */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.4em 0;
}

/* ============================================================
   Breadcrumbs + related nav
   ============================================================ */
.breadcrumbs {
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
}
.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  color: var(--muted);
}
.breadcrumbs li {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.breadcrumbs li + li::before {
  content: "/";
  color: var(--line-strong);
}
.breadcrumbs a {
  color: var(--muted);
  font-weight: 600;
}
.breadcrumbs a:hover {
  color: var(--primary);
}
.breadcrumbs [aria-current="page"] {
  color: var(--ink-soft);
}

.related {
  margin-top: 3rem;
  padding-top: 1.6rem;
  border-top: 2px solid var(--line);
}
.related h2 {
  font-size: var(--step-1);
  margin: 0 0 1rem;
}
.related-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}
.related-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease),
    border-color 0.2s var(--ease);
}
.related-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--primary-300);
}
.related-card .kicker {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-600);
}
.related-card strong {
  display: block;
  color: var(--ink);
  margin-top: 0.2rem;
}

/* Prev / next pager */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.6rem;
}
.pager a {
  flex: 1 1 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease);
}
.pager a:hover {
  transform: translateY(-2px);
  border-color: var(--primary-300);
}
.pager .kicker {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pager strong {
  color: var(--ink);
}
.pager .next {
  text-align: right;
}

/* TOC sidebar */
.toc {
  position: sticky;
  top: calc(var(--header-h) + 1.2rem);
  font-size: 0.9rem;
}
.toc-inner {
  border-left: 2px solid var(--line);
  padding-left: 1rem;
}
.toc .kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.toc a {
  display: block;
  padding: 0.28rem 0;
  color: var(--muted);
  font-weight: 500;
  border-left: 2px solid transparent;
  margin-left: -1rem;
  padding-left: 1rem;
}
.toc a:hover {
  color: var(--primary);
}
.toc a.active {
  color: var(--primary-deep);
  border-left-color: var(--primary);
  font-weight: 650;
}
@media (max-width: 1079px) {
  .toc {
    display: none;
  }
}

/* FAQ accordion */
.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-top: 0.7rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.faq-q {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--ink);
  padding: 1rem 1.2rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}
.faq-q:hover {
  color: var(--primary);
}
.faq-q .chev {
  transition: transform 0.25s var(--ease);
  color: var(--primary);
  flex: none;
}
.faq-item.open .faq-q .chev {
  transform: rotate(180deg);
}
.faq-a {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s var(--ease);
}
.faq-item.open .faq-a {
  grid-template-rows: 1fr;
}
.faq-a > div {
  overflow: hidden;
  padding: 0 1.2rem;
}
.faq-item.open .faq-a > div {
  padding-bottom: 1.1rem;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  flex-shrink: 0;
  margin-top: 3rem;
  background: linear-gradient(160deg, #0b1220, var(--primary-deep));
  color: #cbd5e1;
}
.site-footer .container {
  padding-block: clamp(2rem, 4vw, 3rem);
}
.footer-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(240px, 1.2fr) repeat(auto-fit, minmax(180px, 1fr));
}
.footer-brand {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
}
.footer-brand img {
  width: 46px;
  height: 46px;
}
.footer-brand b {
  color: #fff;
  font-family: var(--font-head);
  font-size: 1.1rem;
}
.footer-brand p {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  color: #94a3b8;
  max-width: 40ch;
}
.footer-col h4 {
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 0.8rem;
}
.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.footer-col a {
  color: #cbd5e1;
  font-size: 0.92rem;
}
.footer-col a:hover {
  color: #fff;
  padding-left: 4px;
}
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin-top: 2rem;
  padding-top: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  font-size: 0.84rem;
  color: #94a3b8;
}

/* Utilities */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
