/* =====================================================================
   Spatial Privacy & Anonymization Engineering — design system
   Light, professional, easy on the eyes. Teal × indigo brand.
   ===================================================================== */

:root {
  /* Brand */
  --brand: #0f766e;
  --brand-700: #0b5e57;
  --brand-600: #0d6b63;
  --brand-300: #5eead4;
  --accent: #4f46e5;
  --accent-600: #4338ca;
  --accent-300: #a5b4fc;

  /* Ink & surfaces */
  --ink: #1f2a37;
  --ink-soft: #41506a;
  --muted: #64748b;
  --bg: #f6f8fb;
  --bg-tint: #eef3f8;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --surface-3: #e6ecf4;
  --border: #e2e8f0;
  --border-strong: #cdd7e5;

  /* Links */
  --link: #0e7490;
  --link-hover: #4f46e5;

  /* Code token palette (light) */
  --code-bg: #f8fafc;
  --code-border: #e4eaf2;
  --tok-comment: #7c8aa0;
  --tok-keyword: #4f46e5;
  --tok-string: #0f766e;
  --tok-number: #b45309;
  --tok-func: #9333ea;
  --tok-builtin: #0e7490;
  --tok-punct: #5b6b85;

  /* Type */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;

  /* Geometry */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --header-h: 60px;
  --container: 1400px;
  --content-max: 1180px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.14);

  --gradient: linear-gradient(120deg, #14b8a6 0%, #0f766e 48%, #4f46e5 100%);
}

@media (min-width: 768px) {
  :root { --header-h: 72px; }
}

/* ----------------------------- Reset ------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, h5 { line-height: 1.2; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }

.site-main { flex: 1 0 auto; width: 100%; }

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 100;
  background: var(--brand);
  color: #fff;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  transition: top 0.18s ease;
}
.skip-link:focus { top: 0.75rem; color: #fff; }

:where(a, button, input, summary):focus-visible {
  outline: 3px solid var(--accent-300);
  outline-offset: 2px;
  border-radius: 4px;
}

.icon { width: 1.25rem; height: 1.25rem; flex: none; }

/* =====================================================================
   Header
   ===================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2.5rem);
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.7rem; margin-right: auto; }
.brand__mark { width: 40px; height: 40px; border-radius: 11px; box-shadow: var(--shadow-sm); transition: transform 0.2s ease; }
.brand:hover .brand__mark { transform: rotate(-4deg) scale(1.04); }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name { font-weight: 750; letter-spacing: -0.01em; color: var(--ink); font-size: 1.06rem; }
.brand__sub { font-size: 0.72rem; color: var(--muted); font-weight: 500; }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem;
  color: var(--ink);
  cursor: pointer;
}
.nav-toggle:hover { background: var(--surface-3); }

.nav-list { list-style: none; display: flex; align-items: center; gap: 0.3rem; margin: 0; padding: 0; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.nav-ico { width: 1.15rem; height: 1.15rem; color: var(--nav-accent, var(--brand)); flex: none; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.is-section { color: var(--ink); }
.nav-link.is-current {
  background: var(--nav-accent, var(--brand));
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}
.nav-link.is-current .nav-ico { color: #fff; }
.nav-link.is-section { box-shadow: inset 0 -2px 0 var(--nav-accent, var(--brand)); border-radius: 999px; }

@media (max-width: 859px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease;
  }
  .site-nav.is-open { max-height: 80vh; }
  .nav-list { flex-direction: column; align-items: stretch; padding: 0.75rem clamp(1rem, 4vw, 2rem) 1.1rem; gap: 0.25rem; }
  .nav-link { font-size: 1.02rem; padding: 0.7rem 0.85rem; border-radius: var(--radius-sm); }
  .nav-link.is-current { border-radius: var(--radius-sm); }
}

/* =====================================================================
   Footer (pinned to bottom via flex column body)
   ===================================================================== */
.site-footer { background: #0c1726; color: #cbd5e1; margin-top: 4rem; }
.footer-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 3rem clamp(1rem, 3vw, 2.5rem) 2rem;
  display: grid;
  grid-template-columns: 1.6fr 1fr 1.4fr;
  gap: 2.5rem;
}
.footer-brand { display: flex; gap: 0.9rem; align-items: flex-start; }
.footer-mark { width: 44px; height: 44px; border-radius: 12px; }
.footer-name { margin: 0 0 0.35rem; font-weight: 700; color: #fff; }
.footer-tagline { margin: 0; font-size: 0.92rem; color: #94a3b8; max-width: 36ch; }
.footer-heading { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: #7c8da6; margin: 0 0 0.8rem; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.footer-nav a { color: #cbd5e1; font-size: 0.94rem; }
.footer-nav a:hover { color: var(--brand-300); }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, 0.08); }
.footer-bottom p { max-width: var(--container); margin: 0 auto; padding: 1.1rem clamp(1rem, 3vw, 2.5rem); font-size: 0.85rem; color: #7c8da6; }

@media (max-width: 859px) {
  .footer-inner { grid-template-columns: 1fr; gap: 1.8rem; }
}

/* =====================================================================
   Buttons / CTAs
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 650;
  font-size: 1rem;
  padding: 0.8rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.btn .icon { width: 1.2rem; height: 1.2rem; }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: var(--shadow-md); }
.btn-primary:hover { color: #fff; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { color: var(--ink); border-color: var(--brand); transform: translateY(-2px); }

/* =====================================================================
   Home / Hero
   ===================================================================== */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 520px at 78% -10%, rgba(79, 70, 229, 0.12), transparent 60%),
    radial-gradient(900px 460px at 12% 8%, rgba(15, 118, 110, 0.14), transparent 60%),
    var(--bg);
  border-bottom: 1px solid var(--border);
}
.hero-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) clamp(1rem, 3vw, 2.5rem) clamp(2rem, 4vw, 3.5rem);
  text-align: center;
}
.hero-logo { width: clamp(116px, 18vw, 168px); height: auto; margin: 0 auto 1.6rem; border-radius: 28px; box-shadow: var(--shadow-lg); }
.hero h1 {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  letter-spacing: -0.02em;
  margin: 0 auto 0.6rem;
  max-width: 18ch;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .eyebrow {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 1.2rem;
  box-shadow: var(--shadow-sm);
}
.hero-lede { font-size: clamp(1.05rem, 1.6vw, 1.22rem); color: var(--ink-soft); max-width: 64ch; margin: 0 auto 1.1rem; }
.hero-lede:last-of-type { margin-bottom: 2rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.9rem; justify-content: center; }

/* Section / generic wrappers */
.section { max-width: var(--container); margin: 0 auto; padding: clamp(2.5rem, 5vw, 4rem) clamp(1rem, 3vw, 2.5rem); }
.section-head { text-align: center; max-width: 60ch; margin: 0 auto 2.4rem; }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 0 0 0.6rem; letter-spacing: -0.01em; }
.section-head p { color: var(--ink-soft); margin: 0; }

/* =====================================================================
   Cards
   ===================================================================== */
.card-grid { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.pillar-card {
  --c: var(--brand);
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.6rem 1.4rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  overflow: hidden;
}
.pillar-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c); opacity: 0.9; }
.pillar-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
.pillar-card__icon {
  width: 54px; height: 54px; border-radius: 15px; display: grid; place-items: center;
  background: var(--c-soft, var(--surface-2)); color: var(--c); margin-bottom: 1rem;
}
.pillar-card__icon .icon { width: 1.7rem; height: 1.7rem; }
.pillar-card h3 { margin: 0 0 0.5rem; font-size: 1.22rem; letter-spacing: -0.01em; }
.pillar-card h3 a { color: var(--ink); }
.pillar-card h3 a:hover { color: var(--c); }
.pillar-card p { margin: 0 0 1.1rem; color: var(--ink-soft); font-size: 0.97rem; }
.pillar-card__topics { list-style: none; margin: 0 0 1.1rem; padding: 0; display: grid; gap: 0.45rem; }
.pillar-card__topics a {
  display: inline-flex; align-items: center; gap: 0.4rem; color: var(--ink-soft); font-size: 0.92rem; font-weight: 500;
}
.pillar-card__topics a .icon { width: 0.95rem; height: 0.95rem; color: var(--c); opacity: 0.8; }
.pillar-card__topics a:hover { color: var(--c); }
.pillar-card__more { margin-top: auto; display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 650; color: var(--c); }
.pillar-card__more .icon { width: 1.05rem; height: 1.05rem; transition: transform 0.16s ease; }
.pillar-card:hover .pillar-card__more .icon { transform: translateX(3px); }

/* Sub-page / child link cards */
.child-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin: 1.6rem 0; }
.child-card {
  display: flex; flex-direction: column; gap: 0.35rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.15rem; box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.child-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--brand-300); }
.child-card__title { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 650; color: var(--ink); }
.child-card__title .icon { width: 1.05rem; height: 1.05rem; color: var(--brand); }
.child-card:hover .child-card__title { color: var(--brand); }
.child-card p { margin: 0; font-size: 0.9rem; color: var(--muted); }

/* =====================================================================
   Document layout: wide content + contextual sidebar
   ===================================================================== */
.doc-wrap { max-width: var(--container); margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 0; }
.doc-grid { display: block; }
@media (min-width: 1024px) {
  .doc-grid { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: clamp(1.5rem, 3vw, 3rem); align-items: start; }
}

.doc-sidebar { display: none; }
@media (min-width: 1024px) {
  .doc-sidebar {
    display: block;
    position: sticky;
    top: calc(var(--header-h) + 1.25rem);
    max-height: calc(100vh - var(--header-h) - 2rem);
    overflow-y: auto;
    padding-right: 0.5rem;
  }
}
.sidebar-heading { font-size: 0.74rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.7rem; }
.sidebar-tree { list-style: none; margin: 0 0 1.4rem; padding: 0; font-size: 0.92rem; }
.sidebar-tree .s-pillar > a { font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 0.45rem; padding: 0.35rem 0; }
.sidebar-tree .s-pillar > a .icon { width: 1rem; height: 1rem; color: var(--s-accent, var(--brand)); }
.sidebar-tree ul { list-style: none; margin: 0.2rem 0 0.8rem; padding: 0 0 0 1.4rem; display: grid; gap: 0.15rem; border-left: 1px solid var(--border); }
.sidebar-tree a { color: var(--ink-soft); display: block; padding: 0.28rem 0.5rem; border-radius: 7px; }
.sidebar-tree a:hover { background: var(--surface-2); color: var(--ink); }
.sidebar-tree a.is-active { background: var(--s-accent-soft, var(--bg-tint)); color: var(--s-accent, var(--brand)); font-weight: 650; }
.sidebar-tree .s-leaf a { font-size: 0.87rem; color: var(--muted); }
.sidebar-tree .s-leaf a.is-active { color: var(--s-accent, var(--brand)); }

/* =====================================================================
   Breadcrumbs
   ===================================================================== */
.breadcrumbs { font-size: 0.86rem; color: var(--muted); margin: 0 0 1rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin: 0; padding: 0; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 0.3rem; }
.breadcrumbs li:not(:last-child)::after { content: "/"; color: var(--border-strong); margin-left: 0.3rem; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--brand); }
.breadcrumbs [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* =====================================================================
   Article content typography
   ===================================================================== */
.article { background: transparent; padding-bottom: 2rem; }
.content { max-width: var(--content-max); }
.content > * + * { margin-top: 1.15rem; }

.content h1 {
  font-size: clamp(1.85rem, 3.6vw, 2.7rem);
  letter-spacing: -0.02em;
  margin: 0.2rem 0 0.4rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.content h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.85rem);
  letter-spacing: -0.01em;
  margin-top: 2.6rem;
  padding-top: 0.6rem;
  color: var(--ink);
  position: relative;
}
.content h2::before {
  content: ""; position: absolute; left: 0; top: 0; width: 2.6rem; height: 3px; border-radius: 3px; background: var(--gradient);
}
.content h3 { font-size: clamp(1.18rem, 1.9vw, 1.4rem); margin-top: 1.9rem; color: var(--brand-700); }
.content h4 { font-size: 1.08rem; margin-top: 1.5rem; color: var(--accent-600); }
.content p { color: var(--ink); }
.content strong { color: var(--ink); font-weight: 700; }
.content :is(h1, h2, h3, h4)[id] { scroll-margin-top: calc(var(--header-h) + 1.1rem); }

.content a { color: var(--link); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); text-underline-offset: 0.18em; transition: color 0.15s ease, text-decoration-color 0.15s ease; }
.content a:hover { color: var(--link-hover); text-decoration-color: var(--link-hover); }
.content a.external-link { white-space: normal; }
.content a.external-link::after {
  content: "";
  display: inline-block;
  width: 0.62em; height: 0.62em;
  margin-left: 0.22em;
  vertical-align: baseline;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M14 3h7v7h-2V6.4l-9.3 9.3-1.4-1.4L17.6 5H14V3zM5 5h5v2H7v10h10v-3h2v5H5V5z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M14 3h7v7h-2V6.4l-9.3 9.3-1.4-1.4L17.6 5H14V3zM5 5h5v2H7v10h10v-3h2v5H5V5z'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.7;
}

.content ul, .content ol { padding-left: 1.4rem; }
.content li + li { margin-top: 0.35rem; }
.content li::marker { color: var(--brand); }

.content hr { border: 0; height: 1px; background: var(--border); margin: 2.5rem 0; }

.content blockquote {
  margin: 1.3rem 0; padding: 0.6rem 1.2rem; border-left: 4px solid var(--brand-300);
  background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-soft);
}

/* Heading anchors */
.heading-anchor { margin-left: 0.4rem; color: var(--border-strong); font-weight: 400; opacity: 0; transition: opacity 0.15s ease, color 0.15s ease; text-decoration: none; }
.content :is(h2, h3, h4):hover .heading-anchor { opacity: 1; }
.heading-anchor:hover { color: var(--accent); }

/* =====================================================================
   Inline code
   ===================================================================== */
.content :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-2);
  color: var(--brand-700);
  padding: 0.12em 0.4em;
  border-radius: 6px;
  border: 0;
  word-break: break-word;
}
.content a code { color: inherit; }

/* =====================================================================
   Code blocks + copy button
   ===================================================================== */
.code-block {
  position: relative;
  margin: 1.5rem 0;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.code-block::before {
  content: attr(data-lang);
  position: absolute;
  top: 0; left: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  padding: 0.28rem 0.7rem;
  border-bottom-right-radius: var(--radius-sm);
  border-right: 1px solid var(--code-border);
  border-bottom: 1px solid var(--code-border);
}
.code-block pre {
  margin: 0;
  padding: 2.4rem 1.15rem 1.15rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.65;
  color: #334155;
  tab-size: 4;
}
.code-block code { font-family: var(--font-mono); background: none; padding: 0; border: 0; color: inherit; }

.code-copy {
  position: absolute;
  top: 0.5rem; right: 0.5rem;
  z-index: 2;
  display: inline-flex; align-items: center; gap: 0.35rem;
  font: 600 0.74rem/1 var(--font-sans);
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.code-block:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.code-copy.is-copied { background: var(--brand); color: #fff; border-color: var(--brand); opacity: 1; }
@media (hover: none) { .code-copy { opacity: 1; } }

/* Prism token theme (light) */
.code-block .token.comment, .code-block .token.prolog, .code-block .token.doctype, .code-block .token.cdata { color: var(--tok-comment); font-style: italic; }
.code-block .token.punctuation { color: var(--tok-punct); }
.code-block .token.property, .code-block .token.tag, .code-block .token.boolean, .code-block .token.number, .code-block .token.constant, .code-block .token.symbol { color: var(--tok-number); }
.code-block .token.selector, .code-block .token.attr-name, .code-block .token.string, .code-block .token.char, .code-block .token.inserted { color: var(--tok-string); }
.code-block .token.operator, .code-block .token.entity, .code-block .token.url { color: var(--tok-punct); }
.code-block .token.atrule, .code-block .token.attr-value, .code-block .token.keyword { color: var(--tok-keyword); font-weight: 600; }
.code-block .token.function, .code-block .token.class-name { color: var(--tok-func); }
.code-block .token.builtin { color: var(--tok-builtin); }
.code-block .token.regex, .code-block .token.important, .code-block .token.variable { color: var(--tok-number); }
.code-block .token.deleted { color: #dc2626; }

/* =====================================================================
   Tables (responsive scroll)
   ===================================================================== */
.table-scroll { overflow-x: auto; margin: 1.5rem 0; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
.table-scroll table { border-collapse: collapse; width: 100%; min-width: 460px; font-size: 0.94rem; }
.table-scroll th, .table-scroll td { text-align: left; padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table-scroll thead th { background: var(--surface-2); color: var(--ink); font-weight: 700; border-bottom: 2px solid var(--border-strong); position: sticky; top: 0; }
.table-scroll tbody tr:nth-child(even) { background: #fafcfe; }
.table-scroll tbody tr:hover { background: var(--bg-tint); }
.table-scroll td code { white-space: nowrap; }

/* =====================================================================
   Task lists (checkboxes)
   ===================================================================== */
.contains-task-list { list-style: none; padding-left: 0.2rem; }
.contains-task-list .contains-task-list { padding-left: 1.4rem; }
.task-list-item { display: flex; align-items: flex-start; gap: 0.6rem; }
.task-list-item::marker { content: ""; }
.task-list-item-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 1.2rem; height: 1.2rem;
  margin: 0.18rem 0 0;
  flex: none;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.task-list-item-checkbox::before {
  content: "";
  width: 0.65rem; height: 0.65rem;
  transform: scale(0);
  transition: transform 0.15s ease;
  background: #fff;
  clip-path: polygon(14% 47%, 0 60%, 40% 100%, 100% 22%, 86% 8%, 38% 72%);
}
.task-list-item-checkbox:checked { background: var(--brand); border-color: var(--brand); }
.task-list-item-checkbox:checked::before { transform: scale(1); }
.task-list-item-checkbox:hover { border-color: var(--brand); }
.task-list-item-checkbox:checked + label,
.task-list-item-checkbox:checked ~ label { text-decoration: line-through; color: var(--muted); }
.task-list-item-label { cursor: pointer; }

/* =====================================================================
   KaTeX
   ===================================================================== */
.content .katex { font-size: 1.04em; }
.math-block { margin: 1.4rem 0; overflow-x: auto; overflow-y: hidden; padding: 0.4rem 0; }
.math-block .katex-display { margin: 0; }
.katex-error { color: #b91c1c; background: #fef2f2; padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 0.85rem; }

/* =====================================================================
   Mermaid diagrams
   ===================================================================== */
figure.diagram { margin: 1.8rem 0; }
figure.diagram pre.mermaid { margin: 0; }
figure.diagram figcaption { margin-top: 0.7rem; text-align: center; font-size: 0.88rem; color: var(--muted); font-style: italic; }
pre.mermaid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  margin: 1.8rem 0;
  text-align: center;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.5;
}
pre.mermaid svg { max-width: 100%; height: auto; display: inline-block; }
/* Graceful loading state: hide raw source until Mermaid renders it */
pre.mermaid:not([data-processed]):not(.mermaid-failed) {
  color: transparent;
  position: relative;
  min-height: 120px;
}
pre.mermaid:not([data-processed]):not(.mermaid-failed)::after {
  content: "Rendering diagram…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}
pre.mermaid[data-processed] { color: inherit; }
/* If the Mermaid bundle fails to load, fall back to readable source text */
pre.mermaid.mermaid-failed { color: var(--ink-soft); text-align: left; }

/* =====================================================================
   Accordions (FAQ via <details>)
   ===================================================================== */
.content details, .faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0.8rem 0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.content details > summary, .faq-item > summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.2rem;
  font-weight: 650;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.content details > summary::-webkit-details-marker { display: none; }
.content details > summary::after {
  content: "";
  width: 0.7rem; height: 0.7rem; flex: none;
  border-right: 2px solid var(--brand); border-bottom: 2px solid var(--brand);
  transform: rotate(45deg); transition: transform 0.2s ease; margin-top: -0.2rem;
}
.content details[open] > summary::after { transform: rotate(-135deg); margin-top: 0.2rem; }
.content details[open] > summary { border-bottom: 1px solid var(--border); }
.content details > *:not(summary) { padding: 0 1.2rem; }
.content details > *:not(summary):last-child { padding-bottom: 1.1rem; }
.content details > summary:hover { color: var(--brand); }

/* =====================================================================
   Related content + prev/next
   ===================================================================== */
.related { margin: 2.5rem 0 0; padding-top: 1.8rem; border-top: 1px solid var(--border); }
.related h2 { font-size: 1.2rem; margin: 0 0 1rem; color: var(--ink); }
.pager { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; margin-top: 1.8rem; }
.pager a {
  display: flex; flex-direction: column; gap: 0.2rem;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1.1rem;
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.pager a:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-300); }
.pager .pager-label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.pager .pager-title { font-weight: 650; color: var(--ink); }
.pager .pager-next { text-align: right; }
@media (max-width: 600px) { .pager { grid-template-columns: 1fr; } }

/* =====================================================================
   Utilities
   ===================================================================== */
.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; }
.lede { font-size: 1.12rem; color: var(--ink-soft); }
