/* ============================================================
   Manhattan Reasoning docs, custom theme (dark).
   Palette + fonts mirror manhattanreasoning-web so the two sites
   read as one product: arriving here feels like a dark-mode
   toggle, not a new site. Layout takes cues from modal.com/docs
   (top tabs · grouped left sidebar · right "on this page").
   ============================================================ */

:root {
  --accent: #0072ff;
  --accent-ink: #005fd6;
  --link: #5fb0ff;

  --bg: #05070d;          /* page (marketing site's --die) */
  --surface: #0e1218;     /* cards, code, sidebar wells */
  --surface-2: #10151d;
  --line: #1c2330;
  --line-soft: #161c27;

  --ink: #d7dee9;         /* body text */
  --ink-strong: #f2f5fa;  /* headings */
  --muted: #8b93a1;
  --dim: #6b7c96;

  --accent-tint: #0072ff1f;
  --accent-border: #0072ff55;

  /* routing-field wire palette (matches the animation + CTA glow) */
  --span1: #2f7fb8;   /* blue */
  --span2: #1f9e89;   /* teal */
  --span6: #e8681f;   /* orange */

  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, monospace;

  --header-h: 64px;
  --sidebar-w: 264px;
  --toc-w: 220px;
  --content-max: 52rem;
  --maxw: 1120px;          /* main site's content column; home matches it */
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

/* Note: never put overflow-x: hidden on html/body -- it turns the other axis
   into a scroll container and breaks the sticky header. Use overflow-x: clip,
   which clips without establishing a scroll container. */
html, body { overflow-x: clip; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* ============================================================
   Header
   ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  /* subtle top scrim so the logo/nav stay crisp at the top of the page (a fully
     transparent nav washes out on our dark bg); the routing field still bleeds
     beneath it. Swapped for a solid blurred backdrop once scrolled. */
  background: linear-gradient(to bottom, rgba(5, 7, 13, .78), rgba(5, 7, 13, 0));
  border-bottom: 1px solid transparent;
  transition: background .25s ease, border-color .25s ease, backdrop-filter .25s ease;
}
.site-header.scrolled {
  background: rgba(5, 7, 13, .86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom-color: var(--line);
}
.site-header__inner {
  height: 100%;
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px;
  max-width: 1400px; margin: 0 auto;
}
/* Home: match the main site's narrower 1120 column so the logo + nav sit at
   the exact same inset as manhattanreasoning.com (seamless cross-site feel).
   Doc pages keep the full-width header so the logo aligns above the sidebar. */
.is-home .site-header__inner { max-width: var(--maxw); }

/* Animated wordmark + Docs badge */
.brand { position: relative; display: flex; align-items: center; gap: .55rem; height: 100%; }
.logo {
  position: relative; height: 42px; width: 16em;
  font-weight: 700; font-size: 17px; letter-spacing: -0.012em; white-space: nowrap;
  text-shadow: 0 0 9px var(--bg), 0 0 9px var(--bg), 0 0 4px var(--bg);
}
/* "Docs" sits inline after the second wordmark line, shimmering through the
   routing field's wire palette (span1 blue -> span2 teal -> span6 orange) on
   the same 8s cycle as the CTA glow, so it reads as part of the animation. */
.logo-docs {
  background: linear-gradient(90deg,
    var(--span1), var(--span2), var(--span6), var(--span2), var(--span1));
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  /* the wordmark's dark halo shows through the transparent-filled gradient
     glyphs in Safari and dims "Docs" at the top; it doesn't need the halo. */
  text-shadow: none;
  animation: docs-shimmer 8s linear infinite;
}
@keyframes docs-shimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .logo-docs { animation: none; background-position: 0% 50%; }
}
.site-header.scrolled .logo { text-shadow: none; }
.logo-l1, .logo-l2 {
  position: absolute; left: 0;
  transition: opacity .3s ease, top .35s cubic-bezier(.4,0,.2,1),
    left .35s cubic-bezier(.4,0,.2,1), transform .35s cubic-bezier(.4,0,.2,1), color .3s ease;
}
.logo-l1 { top: 2px; color: var(--ink-strong); }
.logo-l1 .op { color: var(--ink-strong); }
.logo-l2 { top: 21px; left: 1.55em; color: var(--link); }
.logo-l2 .op { color: var(--link); }
.site-header.scrolled .logo-l1 { opacity: 0; transform: translateY(-6px); }
.site-header.scrolled .logo-l2 { top: 50%; left: 50%; transform: translate(-50%, -50%); }
/* collapsed to one line -> the turnstile turns white; blue again when expanded */
.site-header.scrolled .logo-l2 .op { color: var(--ink-strong); }


/* Top-level section tabs, pushed to the right, next to search */
.top-tabs { display: flex; align-items: center; gap: 22px; margin-left: auto; }
.top-tab {
  color: var(--ink); font-size: .95rem; font-weight: 600;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  text-shadow: 0 0 9px var(--bg), 0 0 9px var(--bg), 0 0 3px var(--bg);
}
.site-header.scrolled .top-tab { text-shadow: none; }
.top-tab:hover { color: var(--link); text-decoration: none; }
.top-tab.active { color: var(--ink-strong); border-bottom-color: var(--accent); }
.top-tab--ext { color: var(--muted); font-weight: 500; }
.top-tab--ext:hover { color: var(--link); }

.header-actions { display: flex; align-items: center; gap: 10px; }

.search-open {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 12px; min-width: 210px;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--line); border-radius: 9px;
  font: inherit; font-size: .85rem; cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.search-open:hover { border-color: var(--accent-border); color: var(--ink); }
.search-open__hint { flex: 1; text-align: left; font-weight: 500; }
.search-open__kbd {
  font-family: var(--mono); font-size: .72rem; line-height: 1; color: var(--dim);
  border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px;
  background: var(--bg);
}

.drawer-toggle {
  display: none;
  background: none; border: 0; color: var(--ink); cursor: pointer; padding: 4px;
}

/* ============================================================
   Three-pane doc shell
   ============================================================ */
.doc-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 0;
  max-width: 1400px; margin: 0 auto;
  align-items: start;
}

/* Left sidebar */
.doc-sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--line-soft);
  padding: 1.6rem 1rem 3rem 1.4rem;
}
/* Home has no three-pane doc shell, so its sidebar only exists to give the
   mobile drawer-toggle a menu (.top-tabs is hidden below 820px). Hide it on
   desktop; the 820px breakpoint below turns it into the same slide-in drawer
   used on doc pages. */
.is-home .doc-sidebar { display: none; }
.nav-section-title {
  font-size: .95rem; font-weight: 800; letter-spacing: -0.01em;
  color: var(--ink-strong); margin-bottom: .8rem;
}
.nav-list { list-style: none; }
.nav-list .nav-list { margin-left: 0; }
.nav-group { margin: 1rem 0 .4rem; }
.nav-group__label {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--dim); margin: 0 0 .35rem .1rem;
}
.nav-item { margin: 1px 0; }
.nav-link {
  display: block; padding: 5px 10px; border-radius: 7px;
  color: var(--muted); font-size: .9rem; line-height: 1.4;
  border-left: 2px solid transparent;
  transition: color .12s ease, background .12s ease;
}
.nav-link:hover { color: var(--ink); background: var(--surface); text-decoration: none; }
.nav-link.active {
  color: var(--link); font-weight: 600;
  background: var(--accent-tint);
  border-left-color: var(--accent);
}

/* Content */
.doc-content {
  min-width: 0;
  padding: 2.2rem clamp(1.4rem, 4vw, 3rem) 4rem;
}
.md-content { max-width: var(--content-max); }

.breadcrumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  font-size: .8rem; color: var(--dim); margin-bottom: 1.4rem;
}
.breadcrumbs .sep { opacity: .5; }
.breadcrumbs .current { color: var(--muted); }

/* Right TOC */
.doc-toc {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 2.4rem 1.2rem 3rem 0;
}
.doc-toc__label {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--dim); margin-bottom: .7rem;
}
.toc-list { list-style: none; }
.toc-list--root { border-left: 1px solid var(--line); }
.toc-link {
  display: block; padding: 3px 0 3px 12px; margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--muted); font-size: .82rem; line-height: 1.45;
}
.toc-link:hover { color: var(--ink); text-decoration: none; }
/* current section, driven by scrollspy in js/docs.js. Mirrors the left nav's
   accent left-border indicator. */
.toc-link.active {
  color: var(--link); font-weight: 600;
  border-left-color: var(--accent);
}
.toc-item--l3 .toc-link { padding-left: 24px; }
.toc-item--l4 .toc-link { padding-left: 36px; }

/* Prev / next */
.page-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 3.5rem; padding-top: 1.6rem; border-top: 1px solid var(--line);
  max-width: var(--content-max);
}
.page-nav a {
  display: flex; flex-direction: column; gap: 2px;
  padding: .8rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); min-width: 40%;
  transition: border-color .15s ease, transform .15s ease;
}
.page-nav a:hover { border-color: var(--accent-border); transform: translateY(-2px); text-decoration: none; }
.page-nav__next { text-align: right; margin-left: auto; }
.page-nav__dir { font-size: .72rem; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.page-nav__title { color: var(--ink-strong); font-weight: 600; }

/* ============================================================
   Typography (article content)
   ============================================================ */
.md-content h1, .md-content h2, .md-content h3, .md-content h4 {
  color: var(--ink-strong); font-weight: 800; letter-spacing: -0.025em; line-height: 1.2;
}
.md-content h1 { font-size: 2.1rem; margin: 0 0 1rem; }
.md-content h2 { font-size: 1.5rem; margin: 2.6rem 0 1rem; padding-top: .4rem; }
.md-content h3 { font-size: 1.18rem; margin: 2rem 0 .7rem; }
.md-content h4 { font-size: 1rem; margin: 1.6rem 0 .5rem; }
.md-content p, .md-content li { color: var(--ink); }
.md-content { overflow-wrap: break-word; }
/* long inline code (commands, paths) breaks instead of forcing overflow */
.md-content p code, .md-content li code { overflow-wrap: anywhere; }
.md-content p { margin: 0 0 1.1rem; }
.md-content ul, .md-content ol { margin: 0 0 1.1rem 1.3rem; }
.md-content li { margin: .3rem 0; }
.md-content strong { color: var(--ink-strong); font-weight: 700; }
.md-content hr { border: 0; border-top: 1px solid var(--line); margin: 2.4rem 0; }

/* Header anchor links (toc permalink) */
.md-content .headerlink {
  color: var(--dim); text-decoration: none; margin-left: .4rem;
  opacity: 0; transition: opacity .12s ease;
}
.md-content h1:hover .headerlink,
.md-content h2:hover .headerlink,
.md-content h3:hover .headerlink,
.md-content h4:hover .headerlink { opacity: 1; }

/* Inline + block code */
.md-content code {
  font-family: var(--mono); font-size: .86em;
  background: var(--surface); color: #cdd6e6;
  border: 1px solid var(--line-soft); border-radius: 5px;
  padding: .12em .4em;
}
.md-content pre { margin: 0 0 1.3rem; }
.highlight {
  position: relative;
  background: var(--surface) !important;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.highlight pre { margin: 0; overflow-x: auto; }
.highlight pre > code {
  display: block; background: none; border: 0; border-radius: 0;
  padding: 1rem 1.1rem; font-size: .85rem; line-height: 1.6; color: var(--ink);
}
.highlight .copy-btn {
  position: absolute; top: 8px; right: 8px;
  font: inherit; font-size: .72rem; color: var(--muted);
  background: rgba(5,7,13,.6); border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 9px; cursor: pointer; opacity: 0; transition: opacity .15s ease, color .15s ease;
}
.highlight:hover .copy-btn { opacity: 1; }
.highlight .copy-btn:hover { color: var(--ink); border-color: var(--dim); }
.highlight .copy-btn.copied { color: #4fd1a5; border-color: #2f6f5a; }
/* line-number gutter (anchor_linenums) */
.highlight .linenos { color: var(--dim); user-select: none; }

/* Mermaid diagrams (see docs/javascripts/mermaid-init.js for the matching
   themeVariables). Framed like a code block so it reads as part of the same
   content system, not a foreign embed. */
.md-content pre.mermaid {
  display: flex; justify-content: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 1.4rem; margin: 0 0 1.3rem;
  overflow-x: auto;
}
.md-content pre.mermaid svg { max-width: 100%; }

/* Tables */
.md-content table {
  width: 100%; border-collapse: collapse; margin: 0 0 1.4rem;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  font-size: .9rem;
}
.md-content th, .md-content td { padding: .6rem .9rem; border-bottom: 1px solid var(--line-soft); text-align: left; }
.md-content th { background: var(--surface); color: var(--ink-strong); font-weight: 700; }
.md-content tr:last-child td { border-bottom: 0; }

/* Blockquote */
.md-content blockquote {
  margin: 0 0 1.2rem; padding: .4rem 1.1rem;
  border-left: 3px solid var(--line); color: var(--muted);
}

/* Admonitions (admonition + details) */
.md-content .admonition, .md-content details {
  background: var(--surface); border: 1px solid var(--line);
  border-left-width: 3px; border-radius: 12px;
  padding: .9rem 1.1rem; margin: 0 0 1.3rem;
}
.md-content .admonition-title, .md-content summary {
  font-weight: 700; color: var(--ink-strong); margin: -.2rem 0 .5rem; cursor: default;
}
.md-content details summary { cursor: pointer; }
.md-content .admonition > :last-child, .md-content details > :last-child { margin-bottom: 0; }
.md-content .admonition.note, .md-content .admonition.info { border-left-color: var(--accent); }
.md-content .admonition.warning { border-left-color: #e8681f; }
.md-content .admonition.tip { border-left-color: #1f9e89; }

/* Material-style "grid cards" used in page bodies (Quickstart "What's next",
   Examples overview). Rendered as a <div class="grid cards"><ul>. */
.md-content .grid.cards > ul {
  list-style: none; margin: 1.5rem 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem;
}
.md-content .grid.cards > ul > li {
  margin: 0; padding: 1.15rem 1.25rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.md-content .grid.cards > ul > li:hover {
  transform: translateY(-2px); border-color: var(--accent-border);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .3);
}
.md-content .grid.cards > ul > li > :first-child { margin-top: 0; }
.md-content .grid.cards > ul > li > :last-child { margin-bottom: 0; }
.md-content .grid.cards > ul > li > hr {
  margin: .7rem 0; border: 0; border-top: 1px solid var(--line);
}
.md-content .grid.cards .twemoji { color: var(--link); }
.md-content .grid.cards .twemoji svg {
  width: 1.35em; height: 1.35em; fill: currentColor; vertical-align: -0.28em;
  margin-right: .15rem;
}
/* Title link ("**[The CLI](cli.md)**") would otherwise inherit the global
   blue `a` color; match the homepage cards' white-bold title instead. */
.md-content .grid.cards > ul > li strong > a { color: var(--ink-strong); }

/* ============================================================
   Footer
   ============================================================ */
.site-footer { border-top: 1px solid var(--line); margin-top: 2rem; }
.site-footer__inner {
  max-width: 1400px; margin: 0 auto; padding: 1.6rem 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.site-footer__brand { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .85rem; }
.site-footer__links { display: flex; gap: 1.3rem; flex-wrap: wrap; }
.site-footer__links a { color: var(--muted); font-size: .85rem; }
.site-footer__links a:hover { color: var(--link); }

/* ============================================================
   Search overlay
   ============================================================ */
.search-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5,7,13,.62); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.search-overlay[hidden] { display: none; }
.search-modal {
  width: min(640px, 92vw);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,.55); overflow: hidden;
}
.search-modal__field {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--muted);
}
.search-modal__field input {
  flex: 1; background: none; border: 0; outline: none;
  font: inherit; font-size: 1rem; color: var(--ink);
}
.search-modal__close {
  font: inherit; font-size: .72rem; color: var(--dim);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 7px; cursor: pointer;
}
.search-modal__results { max-height: 56vh; overflow-y: auto; padding: 6px; }
.search-modal__results article { padding: 10px 12px; border-radius: 9px; }
.search-modal__results article:hover { background: var(--surface-2); }
.search-modal__results h3 { font-size: .95rem; margin: 0 0 .2rem; }
.search-modal__results h3 a { color: var(--ink-strong); }
.search-modal__results p { font-size: .82rem; color: var(--muted); margin: 0; }

/* ============================================================
   Home page, clones manhattanreasoning.com's hero in dark, so
   arriving here reads as "dark mode toggled," not a new site.
   ============================================================ */
.home-main { display: block; }

.hero {
  position: relative;
  overflow: hidden;
  /* slide up behind the transparent sticky header so the routing field bleeds
     off the true top edge, under the nav, like the main site */
  margin-top: calc(-1 * var(--header-h));
  padding-top: var(--header-h);
  min-height: 92vh;
  display: flex; flex-direction: column; justify-content: center;
}
/* left scrim keeps the copy legible; field stays vibrant on the right */
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(100deg,
    var(--bg) 34%, rgba(5, 7, 13, 0.86) 52%, rgba(5, 7, 13, 0) 72%);
}
#routing-canvas {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 82%; z-index: 0; display: block; cursor: crosshair;
  -webkit-mask-image:
    radial-gradient(135% 130% at 68% 46%, #000 58%, rgba(0,0,0,0.5) 76%, transparent 95%),
    linear-gradient(to bottom, #000 0%, #000 88%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image:
    radial-gradient(135% 130% at 68% 46%, #000 58%, rgba(0,0,0,0.5) 76%, transparent 95%),
    linear-gradient(to bottom, #000 0%, #000 88%, transparent 100%);
          mask-composite: intersect;
}
.hero-inner {
  position: relative; z-index: 2;
  width: 100%; max-width: var(--maxw); margin: 0 auto;
  padding: 0 24px;
}
.hero-copy { max-width: min(52vw, 44rem); }
.hero h1 {
  font-size: clamp(1.9rem, 6.5vw, 3.2rem);
  line-height: 1.05; letter-spacing: -0.03em; font-weight: 800;
  color: var(--ink-strong); margin: 0;
  text-shadow: 0 0 18px var(--bg), 0 0 18px var(--bg), 0 0 8px var(--bg), 0 0 3px var(--bg);
}
.hero .bio {
  margin: 1.3rem 0 0; font-size: 1.06rem; line-height: 1.6;
  color: var(--muted); max-width: 40rem;
  text-shadow: 0 0 12px var(--bg), 0 0 12px var(--bg), 0 0 5px var(--bg);
}
.hero .bio code {
  background: var(--accent-tint); color: var(--link);
  border-color: transparent;
}
.hero-ctas { margin-top: 1.9rem; display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }

/* CTA button, same glow keyframe as the marketing site's .btn-outline */
.btn {
  display: inline-block; font-weight: 600; font-size: .95rem;
  padding: 10px 22px; border-radius: 10px; cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn.btn-outline {
  background: transparent; color: var(--ink-strong);
  border: 1px solid var(--line);
  animation: cta-outline-glow 8s ease-in-out infinite;
}
.btn.btn-outline:hover { border-color: var(--muted); color: var(--ink-strong); }
@keyframes cta-outline-glow {
  0%   { border-color: rgba(47,127,184,.45); box-shadow: 0 0 8px rgba(47,127,184,.16); }
  33%  { border-color: rgba(31,158,137,.45); box-shadow: 0 0 9px rgba(31,158,137,.16); }
  66%  { border-color: rgba(232,104,31,.45); box-shadow: 0 0 9px rgba(232,104,31,.15); }
  100% { border-color: rgba(47,127,184,.45); box-shadow: 0 0 8px rgba(47,127,184,.16); }
}
@media (prefers-reduced-motion: reduce) { .btn.btn-outline { animation: none; } }
.read-more {
  font-weight: 600; color: var(--link);
  border-bottom: 1.5px solid transparent;
  text-shadow: 0 0 12px var(--bg), 0 0 12px var(--bg);
}
.read-more:hover { border-bottom-color: currentColor; text-decoration: none; }

/* Home content sections */
.home-section {
  max-width: 1120px; margin: 0 auto; padding: 0 24px;
}
.home-section:first-of-type { margin-top: 4.5rem; }
.home-section + .home-section { margin-top: 4rem; }
.home-section:last-of-type { margin-bottom: 5rem; }
.kicker {
  font-family: var(--mono); font-size: .78rem; font-weight: 500;
  color: var(--link); letter-spacing: .08em; text-transform: uppercase;
  margin-bottom: 1.3rem;
}

.feature-grid, .tile-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem;
}
.feature-card, .tile {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 1.5rem;
  color: var(--ink);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.feature-card:hover, .tile:hover {
  transform: translateY(-3px); box-shadow: 0 16px 40px rgba(0,0,0,.35);
  border-color: var(--accent-border); text-decoration: none;
}
.feature-card__icon {
  display: inline-grid; place-items: center; width: 42px; height: 42px;
  border-radius: 11px; background: var(--accent-tint); color: var(--link);
  font-size: 20px; margin-bottom: .9rem;
}
.feature-card__title, .tile__label {
  font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em;
  color: var(--ink-strong); margin-bottom: .5rem;
}
.feature-card__body, .tile__desc {
  font-size: .92rem; line-height: 1.55; color: var(--muted);
}
.feature-card__body code, .tile__desc code { font-size: .85em; }
.tile__links {
  margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: .8rem; color: var(--dim);
}
.tile:hover .tile__links { color: var(--muted); }

@media (max-width: 820px) {
  .feature-grid, .tile-grid { grid-template-columns: 1fr; }
  .hero-copy { max-width: 100%; }
  #routing-canvas { width: 100%; opacity: .5; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .doc-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .doc-toc { display: none; }
}
@media (max-width: 820px) {
  .top-tabs { display: none; }
  .search-open__hint, .search-open__kbd { display: none; }
  .search-open { min-width: 0; padding: 0 9px; }
  .drawer-toggle { display: inline-flex; }
  /* tighten the header so the wordmark + Docs never collide with the actions;
     a bit more left inset than right so the logo isn't flush to the edge */
  .site-header__inner { gap: 10px; padding: 0 16px 0 22px; }
  .header-actions { margin-left: auto; flex: none; }
  .brand { min-width: 0; }
  .logo { width: 12.6em; font-size: 14px; }
  .doc-shell { grid-template-columns: minmax(0, 1fr); }
  .is-home .doc-sidebar { display: block; }
  .doc-sidebar {
    position: fixed; top: var(--header-h); left: 0; z-index: 40;
    width: min(80vw, var(--sidebar-w)); background: var(--bg);
    border-right: 1px solid var(--line);
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .drawer-open .doc-sidebar { transform: translateX(0); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
  body.drawer-open::before {
    content: ""; position: fixed; inset: var(--header-h) 0 0 0; z-index: 39;
    background: rgba(5, 7, 13, .55);
  }
}
