/* =========================================================================
   BuyTech Sniper — Docs design system
   Stripe-docs-inspired layout, BuyTech green brand.
   ========================================================================= */

/* ---------- Tokens ---------- */
:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", "JetBrains Mono", Menlo,
    Consolas, "Liberation Mono", monospace;

  /* light theme */
  --bg: #ffffff;
  --bg-subtle: #f6f9fc;          /* Stripe signature off-white blue */
  --bg-subtle-2: #eef3f8;
  --bg-panel: #ffffff;
  --bg-code: #f6f8fa;
  --bg-code-block: #0a1f2e;      /* dark code blocks even in light */
  --border: #e3e8ee;
  --border-strong: #d5dbe1;
  --text: #3c4257;
  --text-strong: #0a2540;        /* Stripe navy headings */
  --text-muted: #697386;
  --text-faint: #616a79; /* AA on white and on --bg-subtle */
  --link: #0a7d54;
  --link-hover: #0a2540;
  --brand: #00c46a;
  --brand-bright: #00e676;
  --brand-ink: #063d28;
  --brand-tint: #e6faf0;
  --brand-tint-2: #d6f6e4;
  --navy: #0a2540;
  --navy-2: #14385c;
  --warn: #9a5b00;
  --warn-bg: #fdf5e9;
  --warn-border: #f2d8a8;
  --danger: #b3261e;
  --code-tag: #0a7d54;

  --shadow-xs: 0 1px 1px rgba(10, 37, 64, .05);
  --shadow-sm: 0 2px 5px -1px rgba(10, 37, 64, .08), 0 1px 3px -1px rgba(10, 37, 64, .06);
  --shadow-md: 0 6px 16px -4px rgba(10, 37, 64, .12), 0 2px 6px -2px rgba(10, 37, 64, .08);
  --shadow-lg: 0 18px 40px -12px rgba(10, 37, 64, .22);
  --ring: 0 0 0 3px rgba(0, 196, 106, .28);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --nav-h: 62px;
  --sidebar-w: 272px;
  --toc-w: 236px;
  --content-max: 768px;
  --shell-max: 1480px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0a0e13;
  --bg-subtle: #0e141c;
  --bg-subtle-2: #121a24;
  --bg-panel: #0f1620;
  --bg-code: #0d141d;
  --bg-code-block: #0b1119;
  --border: #1d2733;
  --border-strong: #2b3745;
  --text: #bcc6d4;
  --text-strong: #f0f5fa;
  --text-muted: #8b97a7;
  --text-faint: #7c8898; /* AA on --bg and panels */
  --link: #35e58c;
  --link-hover: #a8ffcf;
  --brand: #00e676;
  --brand-bright: #4dff9e;
  --brand-ink: #b9ffd8;
  --brand-tint: #0f2a1d;
  --brand-tint-2: #113524;
  --navy: #eaf1f8;
  --navy-2: #cdd9e6;
  --warn: #e8b46a;
  --warn-bg: #241a0d;
  --warn-border: #453413;
  --danger: #ff8078;
  --code-tag: #35e58c;

  --shadow-xs: 0 1px 1px rgba(0, 0, 0, .4);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, .5);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, .55);
  --shadow-lg: 0 22px 48px rgba(0, 0, 0, .6);
  --ring: 0 0 0 3px rgba(0, 230, 118, .3);

  color-scheme: dark;
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
::selection { background: var(--brand-tint-2); color: var(--text-strong); }
hr { border: none; border-top: 1px solid var(--border); margin: 2.4rem 0; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand:hover { color: var(--text-strong); }
.brand__mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  object-fit: cover;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(255,255,255,.06);
}
.brand__name { font-size: 15.5px; }
.brand__badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: .02em;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
}
.topnav a {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 7px 11px;
  border-radius: 7px;
}
.topnav a:hover { color: var(--text-strong); background: var(--bg-subtle); }
.topnav a.is-active { color: var(--text-strong); }

.topbar__spacer { flex: 1; }

/* search trigger */
.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 210px;
  height: 38px;
  padding: 0 10px 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 13.5px;
}
.search-btn:hover { border-color: var(--brand); box-shadow: var(--shadow-xs); }
.search-btn svg { flex: none; color: var(--text-faint); }
.search-btn .kbd { margin-left: auto; }
.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 3px 5px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
}
.icon-btn:hover { color: var(--text-strong); border-color: var(--border-strong); background: var(--bg-subtle); }

/* theme-toggle icon: show exactly one icon per effective theme, decided in CSS
   (data-theme is set pre-paint by the inline head script) so there is no double-icon flash */
.ic-sun { display: none; }
.ic-moon { display: inline-block; }
:root[data-theme="dark"] .ic-sun { display: inline-block; }
:root[data-theme="dark"] .ic-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ic-sun { display: inline-block; }
  :root:not([data-theme="light"]) .ic-moon { display: none; }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: transform .06s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: linear-gradient(180deg, var(--brand-bright), var(--brand));
  color: #04241a;
  box-shadow: 0 1px 0 rgba(255,255,255,.35) inset, var(--shadow-sm);
}
.btn--primary:hover { color: #04241a; box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, var(--shadow-md); }
.btn--ghost { background: var(--bg); color: var(--text-strong); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--bg-subtle); color: var(--text-strong); }
.btn--lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 11px; }

.hamburger { display: none; }

/* ---------- Shell / layout ---------- */
.shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 14px 60px 22px;
  border-right: 1px solid var(--border);
}
.sidebar::-webkit-scrollbar { width: 9px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9px; border: 2px solid var(--bg); }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.nav-group { margin-bottom: 22px; }
.nav-group__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 10px;
  margin: 0 0 8px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 7px 10px;
  border-radius: 8px;
  position: relative;
  line-height: 1.35;
}
.nav-link:hover { color: var(--text-strong); background: var(--bg-subtle); }
.nav-link.is-active {
  color: var(--brand-ink);
  background: var(--brand-tint);
  font-weight: 600;
}
[data-theme="dark"] .nav-link.is-active { color: var(--brand-bright); }
.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.nav-link__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border-strong);
  flex: none;
}
.nav-link.is-active .nav-link__dot { background: var(--brand); }

/* ---------- Content ---------- */
.content {
  min-width: 0;
  padding: 40px 56px 96px;
}
.content__inner { max-width: var(--content-max); margin: 0 auto; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--text-muted); font-weight: 500; }
.breadcrumb a:hover { color: var(--text-strong); }
.breadcrumb .sep { color: var(--border-strong); }

.page-title {
  font-size: 2.15rem;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text-strong);
  margin: 0 0 14px;
}
.page-lede {
  font-size: 1.12rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 8px;
}

/* prose */
.prose { font-size: 15.5px; }
.prose > * + * { margin-top: 1.05rem; }
.prose > p:first-child { font-size: 1.14rem; line-height: 1.66; color: var(--text-muted); }
.prose > p:first-child strong { color: var(--text); }
.prose h2 {
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -.015em;
  color: var(--text-strong);
  margin: 2.6rem 0 .2rem;
  padding-top: .4rem;
  scroll-margin-top: calc(var(--nav-h) + 20px);
  position: relative;
}
.prose h3 {
  font-size: 1.16rem;
  font-weight: 650;
  color: var(--text-strong);
  margin: 1.9rem 0 .1rem;
  scroll-margin-top: calc(var(--nav-h) + 20px);
  position: relative;
}
.prose h2 .anchor, .prose h3 .anchor {
  position: absolute;
  left: -1.35em;
  padding-right: .35em;
  color: var(--text-faint);
  opacity: 0;
  font-weight: 400;
  transition: opacity .12s ease;
}
.prose h2:hover .anchor, .prose h3:hover .anchor { opacity: 1; }
.prose p { color: var(--text); line-height: 1.72; }
.prose strong { color: var(--text-strong); font-weight: 650; }
.prose a { font-weight: 550; border-bottom: 1px solid color-mix(in srgb, var(--link) 30%, transparent); }
.prose a:hover { border-bottom-color: var(--link-hover); }
.prose ul, .prose ol { padding-left: 1.35rem; margin-top: .9rem; }
.prose li { margin: .42rem 0; line-height: 1.68; color: var(--text); }
.prose li::marker { color: var(--brand); }
.prose ol li::marker { color: var(--text-faint); font-weight: 600; }
.prose code {
  font-family: var(--font-mono);
  font-size: .86em;
  color: var(--code-tag);
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .12em .38em;
  white-space: nowrap;
}

/* fenced code block */
.prose .code-block {
  background: var(--bg-code-block);
  color: #d7e3f2;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 18px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.62;
  margin: 1.4rem 0;
  box-shadow: var(--shadow-xs);
}
.prose .code-block code {
  background: none; border: none; padding: 0; color: inherit;
  white-space: pre; font-family: var(--font-mono); font-size: inherit;
}

/* callout / aside */
.callout {
  display: flex;
  gap: 13px;
  padding: 15px 17px;
  border-radius: var(--radius);
  background: var(--brand-tint);
  border: 1px solid color-mix(in srgb, var(--brand) 26%, var(--border));
  border-left-width: 3px;
  border-left-color: var(--brand);
  margin: 1.4rem 0;
}
.callout__icon {
  flex: none;
  width: 20px; height: 20px;
  color: var(--brand);
  margin-top: 1px;
}
.callout__body { font-size: 14.5px; line-height: 1.62; color: var(--text); }
.callout__body p { margin: 0; }
.callout__body strong { color: var(--text-strong); }
.callout--warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  border-left-color: var(--warn);
}
.callout--warn .callout__icon { color: var(--warn); }

/* tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 1.4rem 0;
  box-shadow: var(--shadow-xs);
}
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prose thead th {
  background: var(--bg-subtle);
  color: var(--text-strong);
  font-weight: 650;
  text-align: left;
  font-size: 12.5px;
  letter-spacing: .01em;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
}
.prose tbody td { padding: 11px 15px; border-bottom: 1px solid var(--border); color: var(--text); }
.prose tbody tr:last-child td { border-bottom: none; }
.prose tbody tr:hover td { background: var(--bg-subtle); }

/* pager */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 56px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}
.pager__card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  transition: border-color .15s ease, box-shadow .15s ease, transform .08s ease;
}
.pager__card:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.pager__card--next { text-align: right; align-items: flex-end; }
.pager__eyebrow { font-size: 12px; color: var(--text-faint); font-weight: 500; }
.pager__title { font-size: 15px; font-weight: 650; color: var(--text-strong); }
.pager__card:hover .pager__title { color: var(--brand-ink); }
[data-theme="dark"] .pager__card:hover .pager__title { color: var(--brand-bright); }

.edit-line { margin-top: 34px; font-size: 13px; color: var(--text-faint); }

/* ---------- Right rail / TOC ---------- */
.toc {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  padding: 40px 22px 60px 8px;
}
.toc__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 12px;
}
.toc__list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc__list a {
  display: block;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
  padding: 5px 0 5px 14px;
  margin-left: -1px;
  border-left: 2px solid transparent;
}
.toc__list a:hover { color: var(--text-strong); }
.toc__list a.is-active { color: var(--brand-ink); border-left-color: var(--brand); font-weight: 600; }
[data-theme="dark"] .toc__list a.is-active { color: var(--brand-bright); }
.toc__list a.lvl-3 { padding-left: 26px; font-size: 12.5px; }
.toc__foot { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.toc__foot a { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.toc__foot a:hover { color: var(--text-strong); }

/* ---------- Home / landing ---------- */
.home { max-width: var(--shell-max); margin: 0 auto; padding: 0 40px 100px; }
.hero {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 48px;
  align-items: center;
  padding: 68px 0 40px;
}
.hero__eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  color: var(--brand-ink);
  background: var(--brand-tint);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
  padding: 5px 12px; border-radius: 999px;
  margin-bottom: 20px;
}
[data-theme="dark"] .hero__eyebrow { color: var(--brand-bright); }
.hero h1 {
  font-size: clamp(2.2rem, 4.2vw, 3.25rem);
  line-height: 1.06;
  letter-spacing: -.03em;
  font-weight: 750;
  color: var(--text-strong);
  margin: 0 0 20px;
}
.hero h1 .grad {
  background: linear-gradient(100deg, var(--brand) 10%, #12b1ff 120%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p.sub { font-size: 1.16rem; line-height: 1.6; color: var(--text-muted); margin: 0 0 28px; max-width: 34ch; }
.hero__cta { display: flex; flex-wrap: wrap; gap: 12px; }
.hero__art {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  aspect-ratio: 1 / 1;
}
.hero__art img { width: 100%; height: 100%; object-fit: cover; }
.hero__art::after {
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), inset 0 -80px 90px -40px rgba(0,196,106,.25);
  pointer-events: none;
}
.hero__glow {
  position: absolute; inset: -12% -12% auto auto; width: 62%; aspect-ratio: 1; z-index: -1;
  background: radial-gradient(circle, rgba(0,230,118,.32), transparent 62%);
  filter: blur(8px);
}

.hero-search { position: relative; max-width: 620px; margin: 6px 0 8px; }
.hero-search .search-btn {
  width: 100%;
  height: 52px;
  border-radius: 12px;
  font-size: 15px;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 8px 0 60px;
}
.stat { background: var(--bg-panel); padding: 22px 24px; }
.stat__num { font-size: 1.9rem; font-weight: 750; color: var(--text-strong); letter-spacing: -.02em; line-height: 1; }
.stat__num .u { color: var(--brand); }
.stat__label { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

.section-head { margin: 56px 0 22px; }
.section-head h2 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; color: var(--text-strong); margin: 0 0 6px; }
.section-head p { color: var(--text-muted); margin: 0; font-size: 1rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.card-grid--2 { grid-template-columns: repeat(2, 1fr); }
.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  transition: border-color .16s ease, box-shadow .16s ease, transform .1s ease;
  position: relative;
  overflow: hidden;
}
.card::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), transparent);
  transform: scaleX(0); transform-origin: left; transition: transform .2s ease;
}
.card:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.card:hover::after { transform: scaleX(1); }
.card__icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-tint); color: var(--brand-ink);
  border: 1px solid color-mix(in srgb, var(--brand) 24%, transparent);
}
[data-theme="dark"] .card__icon { color: var(--brand-bright); }
.card__icon svg { width: 21px; height: 21px; }
.card h3 { margin: 4px 0 0; font-size: 1.02rem; font-weight: 650; color: var(--text-strong); }
.card p { margin: 0; font-size: 14px; color: var(--text-muted); line-height: 1.55; }
.card__more { margin-top: auto; font-size: 13px; font-weight: 600; color: var(--link); display: inline-flex; align-items: center; gap: 5px; }
.card:hover .card__more { gap: 8px; }

.cta-band {
  margin-top: 66px;
  border-radius: var(--radius-xl);
  padding: 44px;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(0,230,118,.16), transparent 55%),
    linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #eaf3ff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}
[data-theme="dark"] .cta-band { background: radial-gradient(120% 140% at 100% 0%, rgba(0,230,118,.14), transparent 55%), linear-gradient(180deg, #10202f, #0b1826); }
.cta-band h2 { margin: 0 0 8px; font-size: 1.7rem; letter-spacing: -.02em; color: #fff; }
.cta-band p { margin: 0; color: #b9c9db; max-width: 46ch; }
.cta-band .btn--ghost { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.2); color: #fff; }
.cta-band .btn--ghost:hover { background: rgba(255,255,255,.16); color: #fff; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}
.footer__inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 48px 40px 40px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 32px;
}
.footer__brand .brand { margin-bottom: 12px; }
.footer__brand p { color: var(--text-muted); font-size: 13.5px; max-width: 34ch; margin: 0; }
.footer__col-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin: 4px 0 14px; font-weight: 600; }
.footer__col a { display: block; font-size: 13.5px; color: var(--text-muted); padding: 5px 0; }
.footer__col a:hover { color: var(--text-strong); }
.footer__bar {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 18px 40px 40px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-faint);
  border-top: 1px solid var(--border);
}

/* ---------- Search modal ---------- */
.search-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 37, 64, .38);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px;
  opacity: 0; pointer-events: none; visibility: hidden;
  transition: opacity .14s ease, visibility .14s ease;
}
[data-theme="dark"] .search-overlay { background: rgba(0,0,0,.6); }
.search-overlay.open { opacity: 1; pointer-events: auto; visibility: visible; }
.search-modal {
  width: 100%; max-width: 620px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(-8px) scale(.99);
  transition: transform .16s ease;
}
.search-overlay.open .search-modal { transform: none; }
.search-modal__head { display: flex; align-items: center; gap: 11px; padding: 15px 17px; border-bottom: 1px solid var(--border); }
.search-modal__head svg { color: var(--text-faint); flex: none; }
.search-modal input {
  flex: 1; border: none; background: none; outline: none;
  font-family: inherit; font-size: 16px; color: var(--text-strong);
}
.search-modal input::placeholder { color: var(--text-faint); }
.search-results { max-height: 56vh; overflow-y: auto; padding: 8px; }
.search-empty { padding: 34px 20px; text-align: center; color: var(--text-faint); font-size: 14px; }
.sr-group__label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); padding: 12px 12px 6px; }
.sr-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 9px; cursor: pointer;
  color: var(--text); text-decoration: none;
}
.sr-item:hover, .sr-item.is-active { background: var(--bg-subtle); color: var(--text-strong); }
.sr-item__ic { width: 30px; height: 30px; border-radius: 7px; background: var(--bg-subtle); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-faint); flex: none; }
.sr-item.is-active .sr-item__ic { background: var(--brand-tint); border-color: var(--brand); color: var(--brand); }
.sr-item__title { font-size: 14.5px; font-weight: 600; color: var(--text-strong); }
.sr-item__crumb { font-size: 12px; color: var(--text-faint); margin-top: 1px; }
.sr-item__title .hl { background: var(--brand-tint-2); color: var(--brand-ink); border-radius: 3px; padding: 0 2px; }
.search-modal__foot { display: flex; gap: 16px; padding: 10px 15px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-faint); }
.search-modal__foot .kbd { font-size: 10px; padding: 2px 5px; }
.search-modal__foot span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- Mobile drawer scrim ---------- */
.scrim {
  position: fixed; inset: var(--nav-h) 0 0 0; z-index: 45;
  background: rgba(10,37,64,.36);
  opacity: 0; pointer-events: none; transition: opacity .16s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
  .content { padding: 36px 44px 90px; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topnav { display: none; }
  .hamburger { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: var(--nav-h); left: 0;
    width: min(320px, 86vw);
    height: calc(100vh - var(--nav-h));
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-102%);
    transition: transform .2s ease, visibility .2s ease;
    visibility: hidden;               /* off-canvas drawer leaves the tab order when closed */
    z-index: 50;
  }
  .sidebar.open { transform: none; visibility: visible; }
  .content { padding: 28px 22px 80px; }
  /* top-bar search collapses to an icon; the primary CTA becomes icon-only too (no 641-720 overflow) */
  .topbar .search-btn { min-width: 0; width: 38px; padding: 0; justify-content: center; }
  .topbar .search-btn .search-btn__label, .topbar .search-btn .kbd { display: none; }
  .topbar .btn--primary span { display: none; }
  .topbar .btn--primary { padding: 0 12px; }
  /* homepage hero search stays a full-width, labelled field */
  .hero-search .search-btn { width: 100%; padding: 0 16px; justify-content: flex-start; }
  .hero-search .search-btn .search-btn__label { display: inline; }
  .hero-search .search-btn .kbd { display: none; }
  .hero { grid-template-columns: 1fr; gap: 30px; padding: 40px 0 20px; }
  .hero__art { max-width: 380px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .card-grid, .card-grid--2 { grid-template-columns: 1fr; }
  .home { padding: 0 22px 80px; }
  .footer__inner { grid-template-columns: 1fr 1fr; gap: 26px; padding: 40px 22px 30px; }
  .cta-band { padding: 30px; }
}
@media (max-width: 640px) {
  .topbar { gap: 10px; padding: 0 13px; }
}
@media (max-width: 560px) {
  .brand__badge { display: none; }
  .pager { grid-template-columns: 1fr; }
  .footer__inner { grid-template-columns: 1fr; }
  .page-title { font-size: 1.8rem; }
  .footer__bar { padding: 18px 22px 30px; }
}
@media (max-width: 430px) {
  .brand__name { display: none; }
}

/* 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; }
.no-scroll { overflow: hidden; }
