/* relay-docs styles — aligned to relay.md design tokens */

@font-face {
  font-family: 'geist-sans';
  src: url('/assets/fonts/geist.woff2') format('woff2');
  font-display: swap;
}

*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --shell-max: 1280px;
  --sidebar-width: 260px;
  --content-max: 720px;
  --toc-width: 240px;

  /* Tokens aligned to relay-marketing */
  --color-bg: #ffffff;
  --color-text: #09090b;
  --color-muted: #71717a;
  --color-border: #e4e4e7;
  --color-accent: #0D9373;
  --color-active-bg: #f0fdf4;
  --color-code-bg: #f4f4f5;
  --radius: 0.5rem;

  --font-sans: 'geist-sans', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
}

[data-theme="dark"] {
  --color-bg: #09090b;
  --color-text: #fafafa;
  --color-muted: #a1a1aa;
  --color-border: #27272a;
  --color-active-bg: #052e1c;
  --color-code-bg: #18181b;
}

html {
  scroll-padding-top: 56px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis-weight: none;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* Screen-reader-only utility — matches Tailwind preflight's .sr-only.
   Used by footer link affordances ("(opens in new tab)" hint) and
   wherever else assistive-text-only spans are needed. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================
   Header — full-width bar, content centered in shell
   ============================================================ */

.site-header {
  border-bottom: 1px solid rgba(228, 228, 231, 0.6);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
}

[data-theme="dark"] .site-header {
  background: rgba(9, 9, 11, 0.95);
  border-bottom-color: rgba(39, 39, 42, 0.6);
}

/* Two-tier container shape — empirical match to marketing's actual
   rendering (not what marketing's tailwind.config.ts implies).
   Because marketing's container.screens declares only '2xl': '1400px',
   the sm/lg/xl entries in container.padding are dead code at the
   render layer. Marketing actually has TWO tiers: 1rem default + 6rem
   at 1400+, with max-width 1400 (container cap) overridden to 1536
   on header by `max-w-screen-2xl` utility class. Footer has no
   override so it stays at the 1400 container cap. Result: header is
   136px wider than footer at 1536+ viewports — intentional asymmetry. */
.site-header-inner {
  margin: 0 auto;
  height: 56px;
  width: 100%;
  max-width: 1536px;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

@media (min-width: 1400px) {
  .site-header-inner {
    padding-left: 6rem;
    padding-right: 6rem;
  }
}

.site-logo {
  display: flex;
  align-items: center;
  color: var(--color-text);
  text-decoration: none;
  line-height: 0;
}

.logo-wordmark {
  height: 24px;
  width: auto;
  display: block;
  color: var(--color-text);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-nav a {
  color: rgba(9, 9, 11, 0.7);
  text-decoration: none;
  font-size: 0.875rem;
}

.header-nav a:hover {
  color: var(--color-text);
}

.header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: calc(var(--radius) - 2px);
  color: rgba(9, 9, 11, 0.7);
  transition: background 0.1s, color 0.1s;
  /* reset button defaults */
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.header-icon-btn:hover {
  background: var(--color-active-bg);
  color: var(--color-text);
}

.header-icon-btn svg {
  width: 1.125rem;
  height: 1.125rem;
  display: block;
}

/* Dark mode: header nav link + icon button colors */
[data-theme="dark"] .header-nav a {
  color: rgba(250, 250, 250, 0.7);
}

[data-theme="dark"] .header-icon-btn {
  color: rgba(250, 250, 250, 0.7);
}

/* Theme toggle — show moon in light mode, sun in dark mode */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ============================================================
   Main nav — desktop (visible ≥ md)
   ============================================================ */

.main-nav {
  display: none;
  align-items: center;
  gap: 1.5rem;
}

.main-nav .site-logo {
  display: flex;
  align-items: center;
  line-height: 0;
  color: var(--color-text);
  text-decoration: none;
}

.main-nav-list {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.875rem;
}

.main-nav-item {
  position: relative;
  display: flex;
  align-items: center;
}

.main-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: rgba(9, 9, 11, 0.8);
  text-decoration: none;
  transition: color 0.1s;
  white-space: nowrap;
}

.main-nav-link:hover,
.main-nav-link--active {
  color: var(--color-text);
}

[data-theme="dark"] .main-nav-link {
  color: rgba(250, 250, 250, 0.8);
}

[data-theme="dark"] .main-nav-link:hover,
[data-theme="dark"] .main-nav-link--active {
  color: var(--color-text);
}

@media (prefers-reduced-motion: reduce) {
  .main-nav-link {
    transition: none;
  }
}

/* Dropdown — CSS-only :hover + :focus-within pattern (no JS) */
.main-nav-item--has-dropdown .dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: -0.75rem;
  margin-top: 0.5rem;
  min-width: 12rem;
  padding: 0.25rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  z-index: 20;
}

.main-nav-item--has-dropdown:hover .dropdown-menu,
.main-nav-item--has-dropdown:focus-within .dropdown-menu {
  display: block;
}

.dropdown-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.6rem;
  border-radius: calc(var(--radius) - 4px);
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.875rem;
  width: 100%;
  white-space: nowrap;
}

.dropdown-link:hover {
  background: var(--color-active-bg);
}

.external-link-icon {
  opacity: 0.6;
}

/* Push the right-side header-nav cluster to the right edge */
.site-header-inner > .header-nav {
  margin-left: auto;
}

/* Consult CTA — hidden below md, inline-flex at md+ */
.consult-cta {
  display: none;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.6rem;
  border-radius: calc(var(--radius) - 2px);
  color: rgba(9, 9, 11, 0.8);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.consult-cta:hover {
  background: var(--color-active-bg);
  color: var(--color-text);
}

[data-theme="dark"] .consult-cta {
  color: rgba(250, 250, 250, 0.8);
}

[data-theme="dark"] .consult-cta:hover {
  color: var(--color-text);
}

@media (prefers-reduced-motion: reduce) {
  .consult-cta {
    transition: none;
  }
}

/* ============================================================
   Mobile cluster — burger trigger, mobile-only logo, dialog sheet
   ============================================================ */

.mobile-nav-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: calc(var(--radius) - 2px);
  color: var(--color-text);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.mobile-nav-trigger:hover {
  background: var(--color-active-bg);
}

.site-logo--mobile {
  display: inline-flex;
  align-items: center;
  color: var(--color-text);
  text-decoration: none;
  line-height: 0;
  margin-right: auto;
}

.site-logo--mobile .logo-wordmark {
  height: 24px;
  width: auto;
  display: block;
}

.mobile-nav-dialog {
  position: fixed;
  inset: 0 auto 0 0;
  width: 80vw;
  max-width: 320px;
  height: 100vh;
  margin: 0;
  padding: 0;
  border: none;
  background: var(--color-bg);
  color: var(--color-text);
  overflow-y: auto;
}

.mobile-nav-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.logo-wordmark--small {
  height: 20px;
  width: auto;
  display: block;
  color: var(--color-text);
}

.mobile-nav-close {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 2px);
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  padding: 0;
}

.mobile-nav-close:hover {
  background: var(--color-active-bg);
}

.mobile-nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.25rem;
}

.mobile-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.mobile-nav-link:hover {
  background: var(--color-active-bg);
}

.mobile-nav-link--active {
  color: var(--color-accent);
  font-weight: 600;
}

.mobile-nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0 0 0.5rem 1rem;
}

.mobile-nav-sublink {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.5rem;
  border-radius: calc(var(--radius) - 4px);
  color: rgba(9, 9, 11, 0.8);
  text-decoration: none;
  font-size: 0.875rem;
}

[data-theme="dark"] .mobile-nav-sublink {
  color: rgba(250, 250, 250, 0.8);
}

.mobile-nav-sublink:hover {
  background: var(--color-active-bg);
  color: var(--color-text);
}

/* Responsive switches: at md+, show main-nav + consult CTA, hide mobile cluster */
@media (min-width: 768px) {
  .main-nav {
    display: flex;
  }
  .consult-cta {
    display: inline-flex;
  }
  .mobile-nav-trigger,
  .site-logo--mobile {
    display: none;
  }
}

/* ============================================================
   Two-column doc layout — centered in shell
   ============================================================ */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width);
  max-width: var(--shell-max);
  margin: 0 auto;
  min-height: calc(100vh - 56px);
}

body.no-toc .layout {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.nav-group {
  margin-bottom: 1.5rem;
}

.nav-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text);
  margin: 0 0 0.35rem 0.5rem;
}

.nav-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-group li a {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.4;
}

.nav-group li a:hover {
  background: var(--color-active-bg);
}

.nav-group li a.active {
  background: var(--color-active-bg);
  color: var(--color-accent);
  font-weight: 500;
}

/* ============================================================
   Main doc content
   ============================================================ */

.doc-content {
  padding: 2rem 2.5rem;
  max-width: calc(var(--content-max) + 5rem);
  min-width: 0;
}

.doc-content h1 {
  margin-top: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.doc-content h2 {
  margin-top: 2.5rem;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.doc-content h3 {
  margin-top: 1.75rem;
  margin-bottom: 0.4rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.doc-content h4 {
  margin-top: 1.25rem;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.doc-content p {
  margin-top: 0;
  margin-bottom: 1rem;
}

.doc-content li {
  margin-bottom: 0.25rem;
}

.doc-content a {
  color: var(--color-accent);
  text-decoration: none;
}

.doc-content a:hover {
  text-decoration: underline;
}

/* Code */
.doc-content code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: var(--color-code-bg);
  padding: 0.1em 0.35em;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--color-border);
}

.doc-content pre {
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.25rem 0;
}

.doc-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
}

/* Images */
.doc-content img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  display: block;
  margin: 1.25rem 0;
}

/* Image captions — italic-only paragraph following an image */
.doc-content p:has(> em:only-child) {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-top: -0.75rem;
  text-align: center;
}

/* Callout blockquotes (Note / Tip / Info) */
.doc-content blockquote {
  border-left: 3px solid var(--color-accent);
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  background: var(--color-active-bg);
  border-radius: 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0;
  color: var(--color-text);
}

.doc-content blockquote p:first-child {
  margin-top: 0;
}

.doc-content blockquote p:last-child {
  margin-bottom: 0;
}

.copy-agent-instructions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.copy-agent-button {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 0.55rem 0.8rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.copy-agent-button:hover {
  opacity: 0.88;
}

.copy-agent-status {
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* Tables */
.doc-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  display: block;
  overflow-x: auto;
}

.doc-content th,
.doc-content td {
  border: 1px solid var(--color-border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  white-space: normal;
}

.doc-content th {
  background: var(--color-code-bg);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Horizontal rule */
.doc-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

/* ============================================================
   Footer — full-width bar, content centered in shell
   ============================================================ */

/* Outer footer element — vertical padding always 2rem, horizontal
   padding 2rem at md+. F1 per Design's spec. Matches marketing's
   `py-8 md:px-8` exactly. */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 2rem 0;
}

@media (min-width: 768px) {
  .site-footer {
    padding: 2rem 2rem;
  }
}

/* Two-tier container shape — same as .site-header-inner BUT no
   max-width: 1536px override. Marketing's footer doesn't have
   `max-w-screen-2xl`, so it stays at the container plugin's 1400 cap.
   At 1400+ viewports, footer content is 136px narrower than header
   (1400 - 192 = 1208 vs header's 1536 - 192 = 1344). Intentional
   asymmetry, matches marketing exactly. */
.site-footer-inner {
  margin: 0 auto;
  width: 100%;
  padding: 0 1rem;
}

@media (min-width: 1400px) {
  .site-footer-inner {
    max-width: 1400px;
    padding-left: 6rem;
    padding-right: 6rem;
  }
}

/* 5-col grid at lg (≥ 1024), 2-col at md (≥ 768), 1-col below.
   Matches marketing's md:grid-cols-2 lg:grid-cols-5. */
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .footer-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Column heading — text-sm font-semibold per marketing.
   Previously was 0.7rem uppercase + letter-spacing; revised to match
   marketing's 0.875rem weight 600 sentence-case. */
.footer-col-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 0.75rem 0;
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-col li {
  margin-bottom: 0.5rem;
}

.footer-col a {
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.875rem;
}

.footer-col a:hover {
  color: var(--color-text);
}

.footer-col-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Brand column — logo (centered), tagline (centered), System 3 lockup. */
.footer-brand {
  text-align: center;
}

.footer-brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: var(--color-text);
  text-decoration: none;
}

.logo-wordmark-footer {
  height: 3rem;
  width: auto;
  display: block;
  color: var(--color-text);
}

.footer-brand-tagline {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin: 0 0 0.75rem 0;
}

.footer-brand-attr {
  display: inline-flex;
  color: var(--color-muted);
  text-decoration: none;
}

.footer-brand-attr:hover {
  color: var(--color-text);
}

/* System 3 lockup — match marketing's h-10 w-24 (40px × 96px box).
   The SVG's intrinsic viewBox is 1191×220 (5.4:1), but the rendered
   box is 2.4:1. Default preserveAspectRatio="xMidYMid meet" letterboxes
   the content inside the box: scaled to fit width 96, vertically
   centered with ~22px top/bottom of empty space. Matches marketing's
   compact lockup rendering. */
.system3-lockup {
  height: 2.5rem;
  width: 6rem;
  display: block;
  color: currentColor;
}

/* Bottom bar — copyright on the left, Discord on the right.
   Stacked on mobile, side-by-side at md+. */
.footer-bottom {
  border-top: 1px solid var(--color-border);
  padding-top: 2rem;
  margin-top: 2rem;
  font-size: 0.875rem;
  color: var(--color-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

@media (min-width: 768px) {
  .footer-bottom {
    flex-direction: row;
  }
}

.footer-copyright {
  margin: 0;
}

.footer-bottom a {
  color: var(--color-muted);
  text-decoration: none;
}

.footer-bottom a:hover {
  color: var(--color-text);
}

.footer-bottom-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* ============================================================
   Right rail — page outline (desktop)
   ============================================================ */

.toc-rail {
  border-left: 1px solid var(--color-border);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 56px;
  /* Size to content with a viewport cap. Combined with align-self:start,
     short TOCs (3-5 entries) only occupy what they need — when .layout's
     bottom enters the viewport and the rail un-sticks, a short rail
     pops up a short distance instead of dragging a full viewport's
     worth of empty rail across the screen. Long TOCs still cap at the
     viewport and overflow-scroll internally as before. */
  max-height: calc(100vh - 56px);
  align-self: start;
  overflow-y: auto;
  font-size: 0.875rem;
}

.toc-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin: 0 0 0.5rem 0;
}

.toc-rail .toc ol,
.toc-disclosure .toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-rail .toc li,
.toc-disclosure .toc li {
  margin: 0;
}

.toc-rail .toc a,
.toc-disclosure .toc a {
  display: block;
  position: relative;       /* containing block for the active ::before */
  padding: 0.3rem 0.5rem;
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.4;
  border-radius: calc(var(--radius) - 2px);
}

.toc-rail .toc ol ol a,
.toc-disclosure .toc ol ol a {
  padding-left: 1.5rem;
  font-size: 0.8125rem;
}

.toc-rail .toc a:hover,
.toc-disclosure .toc a:hover {
  color: var(--color-text);
}

.toc-rail .toc a.active,
.toc-disclosure .toc a.active {
  color: var(--color-accent);
  font-weight: 500;
}

/* Left accent bar on the active entry — 2px solid, near-full entry height. */
.toc-rail .toc a.active::before,
.toc-disclosure .toc a.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 0.3rem;
  bottom: 0.3rem;
  width: 2px;
  background: var(--color-accent);
  border-radius: 1px;
  opacity: 1;
  transition: opacity 0.15s ease-out;
}

.toc-rail .toc code,
.toc-disclosure .toc code {
  font-size: inherit;
  background: none;
  border: none;
  padding: 0;
}

/* Keyboard users following an anchor link see where they landed. */
.doc-content h2:focus-visible,
.doc-content h3:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .toc-rail .toc a.active::before,
  .toc-disclosure .toc a.active::before {
    transition: none;
  }
}

/* ============================================================
   Mobile disclosure — inline page outline
   ============================================================ */

.toc-disclosure {
  display: none;
  margin: 1rem 0 1.5rem 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
}

.toc-disclosure summary {
  padding: 0.6rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toc-disclosure summary::after {
  content: '▾';
  font-size: 0.7rem;
  color: var(--color-muted);
  transition: transform 0.15s ease-out;
}

.toc-disclosure[open] summary::after {
  transform: rotate(180deg);
}

.toc-disclosure summary::-webkit-details-marker {
  display: none;
}

.toc-disclosure > nav.toc-nav {
  padding: 0 0.85rem 0.75rem 0.85rem;
  border-top: 1px solid var(--color-border);
  padding-top: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
  .toc-disclosure summary::after {
    transition: none;
  }
}

/* ============================================================
   Mobile / tablet
   ============================================================ */

/* Tablet and below: drop the right rail, show the inline disclosure */
@media (max-width: 1023.98px) {
  .layout {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }
  body.no-toc .layout {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }
  .toc-rail {
    display: none;
  }
  .toc-disclosure {
    display: block;
  }
}

/* Phone and below: collapse left sidebar above content */
@media (max-width: 768px) {
  .layout {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
  }
  body.no-toc .layout {
    grid-template-columns: none;
  }
  .sidebar {
    width: 100%;
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  .doc-content {
    padding: 1.5rem 1rem;
  }
  .doc-content th,
  .doc-content td {
    white-space: normal;
  }
}

/* ============================================================
   Print
   ============================================================ */

@media print {
  .toc-rail,
  .toc-disclosure {
    display: none;
  }
  .layout {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }
}
