/* =========================================================
   MemState Documentation — styles.css
   ========================================================= */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap");

/* ---------------------------------------------------------
   Design tokens — dark (default)
   --------------------------------------------------------- */
:root {
  /* Backgrounds — neutral slate, no blue wash */
  --bg:            #0c0d10;
  --bg-subtle:     #12141a;
  --surface:       #16181f;
  --surface-raised:#1c1f28;
  --sidebar-bg:    #0f1117;

  /* Text */
  --text:          #eceef2;
  --text-secondary:#a8adb8;
  --text-dim:      #6b7280;
  --text-tertiary: #525862;

  /* Borders */
  --border:        #2a2f3a;
  --border-subtle: #1e222b;

  /* Accent — single restrained blue (documentation, not marketing) */
  --accent:        #3d6db8;
  --accent-bright: #5b8fd4;
  --accent-bg:     rgba(91, 143, 212, 0.07);
  --accent-border: rgba(91, 143, 212, 0.18);

  /* Semantic */
  --green:         #4ade80;
  --green-bg:      rgba(74, 222, 128, 0.08);
  --green-border:  rgba(74, 222, 128, 0.2);
  --amber:         #fbbf24;
  --amber-bg:      rgba(251, 191, 36, 0.08);
  --amber-border:  rgba(251, 191, 36, 0.22);
  --red:           #f87171;
  --red-bg:        rgba(248, 113, 113, 0.08);
  --red-border:    rgba(248, 113, 113, 0.2);
  --purple:        #c084fc;
  --purple-bg:     rgba(192, 132, 252, 0.08);
  --purple-border: rgba(192, 132, 252, 0.2);

  /* HTTP method badges */
  --m-get-bg:    rgba(74, 222, 128, 0.1);  --m-get-fg:    #4ade80;  --m-get-bd:    rgba(74, 222, 128, 0.18);
  --m-post-bg:   rgba(96, 165, 250, 0.1);  --m-post-fg:   #60a5fa;  --m-post-bd:   rgba(96, 165, 250, 0.18);
  --m-delete-bg: rgba(248, 113, 113, 0.1); --m-delete-fg: #f87171;  --m-delete-bd: rgba(248, 113, 113, 0.18);
  --m-put-bg:    rgba(251, 191, 36, 0.1);  --m-put-fg:    #fbbf24;  --m-put-bd:    rgba(251, 191, 36, 0.18);
  --m-patch-bg:  rgba(192, 132, 252, 0.1); --m-patch-fg:  #c084fc;  --m-patch-bd:  rgba(192, 132, 252, 0.18);

  /* Typefaces */
  --font:      "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", "Cascadia Code", ui-monospace, monospace;

  /* Layout */
  --sidebar-width: 252px;
  --toc-width:     212px;
  --content-max:   54rem;
  --header-h:      56px;

  /* Misc */
  --radius:    6px;
  --radius-sm: 4px;
  --radius-lg: 10px;
  --ease:      cubic-bezier(0.4, 0, 0.2, 1);

  color-scheme: dark;
}

/* ---------------------------------------------------------
   Light theme overrides
   --------------------------------------------------------- */
[data-theme="light"] {
  color-scheme: light;

  --bg:            #ffffff;
  --bg-subtle:     #f6f7f9;
  --surface:       #f0f2f5;
  --surface-raised:#e8eaef;
  --sidebar-bg:    #fafbfc;

  --text:          #111827;
  --text-secondary:#4b5563;
  --text-dim:      #6b7280;
  --text-tertiary: #9ca3af;

  --border:        #e5e7eb;
  --border-subtle: #f3f4f6;

  --accent:        #1e4a8e;
  --accent-bright: #2563c4;
  --accent-bg:     rgba(37, 99, 196, 0.06);
  --accent-border: rgba(37, 99, 196, 0.15);

  --green:         #16a34a;
  --green-bg:      rgba(22, 163, 74, 0.07);
  --green-border:  rgba(22, 163, 74, 0.2);
  --amber:         #d97706;
  --amber-bg:      rgba(217, 119, 6, 0.07);
  --amber-border:  rgba(217, 119, 6, 0.22);
  --red:           #dc2626;
  --red-bg:        rgba(220, 38, 38, 0.07);
  --red-border:    rgba(220, 38, 38, 0.2);

  --m-get-bg:    rgba(22, 163, 74, 0.1);  --m-get-fg:    #15803d;  --m-get-bd:    rgba(22, 163, 74, 0.2);
  --m-post-bg:   rgba(37, 99, 235, 0.1);  --m-post-fg:   #1d4ed8;  --m-post-bd:   rgba(37, 99, 235, 0.2);
  --m-delete-bg: rgba(220, 38, 38, 0.1);  --m-delete-fg: #b91c1c;  --m-delete-bd: rgba(220, 38, 38, 0.2);
  --m-put-bg:    rgba(217, 119, 6, 0.1);  --m-put-fg:    #b45309;  --m-put-bd:    rgba(217, 119, 6, 0.2);
  --m-patch-bg:  rgba(124, 58, 237, 0.1); --m-patch-fg:  #6d28d9;  --m-patch-bd:  rgba(124, 58, 237, 0.2);
}

/* ---------------------------------------------------------
   Reset
   --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  /* Smooth theme transition — fast enough to avoid FOUC on dark default */
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.has-sidebar { min-height: 100vh; }

/* ---------------------------------------------------------
   Links
   --------------------------------------------------------- */
a {
  color: var(--accent-bright);
  text-decoration: none;
  text-underline-offset: 2px;
  transition: color 100ms var(--ease);
}
a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------------------------------------------------------
   Outer layout shell  (sidebar + doc-inner)
   --------------------------------------------------------- */
.doc-layout {
  display: flex;
  min-height: 100vh;
}

/* ---------------------------------------------------------
   Left sidebar
   --------------------------------------------------------- */
#doc-sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#doc-sidebar::-webkit-scrollbar       { width: 4px; }
#doc-sidebar::-webkit-scrollbar-track { background: transparent; }
#doc-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-inner { padding: 0 0 2.5rem; }

/* Brand */
.sidebar-brand {
  padding: 1.1rem 1rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.4rem;
}
.sidebar-brand a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: -0.015em;
  text-decoration: none;
}
.sidebar-logo-mark {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--accent);
  flex-shrink: 0;
  display: inline-block;
}
.sidebar-brand a:hover { color: var(--text); text-decoration: none; }

.sidebar-tag {
  padding: 0.4rem 1rem 0.6rem;
  font-size: 0.71rem;
  color: var(--text-dim);
  margin: 0;
}

/* Nav sections */
.nav-section { padding: 0 0.5rem; margin-bottom: 0.15rem; }
.nav-section-title {
  display: block;
  padding: 0.6rem 0.55rem 0.25rem;
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dim);
  user-select: none;
}
.nav-section ul { list-style: none; margin: 0; padding: 0; }
.nav-link {
  display: block;
  padding: 0.31rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  color: var(--text-secondary);
  transition: color 100ms var(--ease), background 100ms var(--ease);
  line-height: 1.45;
}
.nav-link:hover {
  background: rgba(127, 127, 127, 0.08);
  color: var(--text);
  text-decoration: none;
}
.nav-link.is-active {
  background: rgba(127, 127, 127, 0.06);
  color: var(--text);
  font-weight: 500;
  border-left: 2px solid var(--accent);
  padding-left: calc(0.6rem - 2px);
}

/* ---------------------------------------------------------
   Right column (header + body + footer)
   --------------------------------------------------------- */
.doc-inner {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------
   Sticky page header
   --------------------------------------------------------- */
.page-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  background: var(--bg);
  transition: background 120ms var(--ease);
}
[data-theme="light"] .page-header {
  background: var(--bg);
}
.page-header h1 {
  margin: 0;
  font-size: 1.0rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Theme toggle button */
#theme-toggle {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms var(--ease), border-color 120ms var(--ease), color 120ms var(--ease);
}
#theme-toggle:hover {
  background: var(--surface-raised);
  border-color: var(--accent-border);
  color: var(--text);
}
#theme-toggle svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
}

/* ---------------------------------------------------------
   Page body — flex row: main content + TOC
   --------------------------------------------------------- */
.doc-body {
  flex: 1;
  display: flex;
  align-items: flex-start;
  min-width: 0;
}

/* ---------------------------------------------------------
   Main content
   --------------------------------------------------------- */
.page-main {
  flex: 1;
  min-width: 0;
  max-width: var(--content-max);
  padding: 1.75rem 2rem 3.5rem;
}

/* ---------------------------------------------------------
   Right TOC panel
   --------------------------------------------------------- */
#toc-panel {
  flex-shrink: 0;
  width: var(--toc-width);
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
  max-height: calc(100vh - var(--header-h) - 2rem);
  overflow-y: auto;
  padding: 0.1rem 1.25rem 2rem 1rem;
  border-left: 1px solid var(--border-subtle);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#toc-panel::-webkit-scrollbar       { width: 3px; }
#toc-panel::-webkit-scrollbar-track { background: transparent; }
#toc-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.toc-title {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dim);
  margin: 0 0 0.55rem;
  padding: 0 0.4rem;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-item { margin: 0; }

.toc-link {
  display: block;
  padding: 0.26rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  line-height: 1.42;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 100ms var(--ease), background 100ms var(--ease);
}
.toc-link:hover {
  color: var(--text-secondary);
  background: rgba(127, 127, 127, 0.07);
  text-decoration: none;
}
.toc-link.is-active {
  color: var(--text);
  background: rgba(127, 127, 127, 0.08);
  font-weight: 500;
}

/* h3 items are indented */
.toc-item--h3 .toc-link {
  padding-left: 1rem;
  font-size: 0.77rem;
}

/* ---------------------------------------------------------
   Page footer
   --------------------------------------------------------- */
.page-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 0.85rem 2rem;
  color: var(--text-dim);
  font-size: 0.79rem;
  background: var(--sidebar-bg);
}

/* ---------------------------------------------------------
   Typography
   --------------------------------------------------------- */
h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 2.25rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
  letter-spacing: -0.01em;
  color: var(--text);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
h2:first-of-type { margin-top: 0.2rem; }

h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
  color: var(--text);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

p { color: var(--text-secondary); margin: 0 0 0.85rem; line-height: 1.7; }
li, dd { color: var(--text-secondary); line-height: 1.65; }
li + li  { margin-top: 0.22rem; }
ul, ol   { padding-left: 1.3rem; margin: 0.35rem 0 0.85rem; }
strong   { color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------
   Inline code
   --------------------------------------------------------- */
code {
  font-family: var(--font-mono);
  font-size: 0.83em;
  background: var(--surface-raised);
  padding: 0.16em 0.38em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

/* ---------------------------------------------------------
   Code blocks
   --------------------------------------------------------- */
pre {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  overflow-x: auto;
  color: #c9d1d9;
  line-height: 1.58;
  margin: 0.65rem 0 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
pre::-webkit-scrollbar       { height: 4px; }
pre::-webkit-scrollbar-track { background: transparent; }
pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
pre code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; white-space: pre; }
pre.sequence { background: #0a0f17; border-color: #1e2936; color: #94a3b8; }

[data-theme="light"] pre         { background: #f6f8fa; border-color: var(--border); color: #24292f; }
[data-theme="light"] pre.sequence{ background: #f0f4f8; border-color: var(--border); color: #576071; }
[data-theme="light"] pre code    { color: inherit; }

/* ---------------------------------------------------------
   Tables
   --------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 0.65rem 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
thead { background: var(--surface); }
th {
  padding: 0.6rem 0.9rem;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  color: var(--text-secondary);
  line-height: 1.55;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 80ms var(--ease); }
tbody tr:hover { background: rgba(127, 127, 127, 0.04); }

/* ---------------------------------------------------------
   Callouts
   --------------------------------------------------------- */
.callout {
  display: flex;
  gap: 0.7rem;
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--accent-bg);
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-secondary);
}
.callout::before {
  content: "ℹ";
  font-size: 0.9rem;
  color: var(--accent-bright);
  flex-shrink: 0;
  line-height: 1.65;
}
.callout strong { color: var(--text); }
.callout.warn                { border-color: var(--amber-border); background: var(--amber-bg); }
.callout.warn::before        { content: "⚠"; color: var(--amber); }

/* ---------------------------------------------------------
   Diagram / figure blocks
   (keep dark even in light mode so SVG fills stay correct)
   --------------------------------------------------------- */
.figure-block {
  margin: 1.25rem 0;
  padding: 1.25rem;
  background: #12181f;
  border: 1px solid #30363d;
  border-radius: var(--radius-lg);
}
[data-theme="light"] .figure-block { background: #161b22; border-color: #30363d; }

.diagram-svg {
  width: 100%;
  max-width: 860px;
  height: auto;
  display: block;
  margin: 0 auto;
}
.diagram-caption { font-size: 0.81rem; color: #8b949e; margin: 0.65rem 0 0; text-align: center; }

/* ---------------------------------------------------------
   HTTP method badges
   --------------------------------------------------------- */
.method {
  display: inline-block;
  padding: 0.17em 0.52em;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.73em;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}
.method-get    { background: var(--m-get-bg);    color: var(--m-get-fg);    border: 1px solid var(--m-get-bd);    }
.method-post   { background: var(--m-post-bg);   color: var(--m-post-fg);   border: 1px solid var(--m-post-bd);   }
.method-delete { background: var(--m-delete-bg); color: var(--m-delete-fg); border: 1px solid var(--m-delete-bd); }
.method-put    { background: var(--m-put-bg);    color: var(--m-put-fg);    border: 1px solid var(--m-put-bd);    }
.method-patch  { background: var(--m-patch-bg);  color: var(--m-patch-fg);  border: 1px solid var(--m-patch-bd);  }

/* ---------------------------------------------------------
   Hero section (product landing, top of a page)
   --------------------------------------------------------- */
.hero {
  position: relative;
  margin: 0 0 2rem;
  padding: 1.75rem 1.75rem 1.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
}

/* Split hero: copy on the left, illustration or code on the right */
.hero.hero--split {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
  padding: 2rem 1.75rem 1.85rem;
}
@media (max-width: 960px) {
  .hero.hero--split { grid-template-columns: 1fr; gap: 1.5rem; padding: 1.65rem 1.35rem; }
}
.hero > * { position: relative; }

@keyframes ms-wordmark-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hero-wordmark {
  margin: 0 0 0.35rem;
  padding: 0;
  font-size: clamp(1.85rem, 5.5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--text);
  animation: ms-wordmark-in 0.88s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.hero.hero--split .hero-wordmark {
  font-size: clamp(2rem, 6vw, 3.35rem);
  margin-bottom: 0.45rem;
}
@media (prefers-reduced-motion: reduce) {
  .hero-wordmark {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

.hero .eyebrow {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.65rem;
  padding: 0;
  border: none;
  background: none;
}
.hero .eyebrow::before { content: none; }
.hero h1.hero-title {
  margin: 0 0 0.75rem;
  font-size: 1.85rem;
  line-height: 1.18;
  letter-spacing: -0.028em;
  font-weight: 600;
  color: var(--text);
  max-width: 26ch;
}
.hero.hero--split h1.hero-title {
  font-size: 2rem;
  max-width: 20ch;
}
.hero .hero-title em {
  font-style: italic;
  font-weight: 600;
  color: var(--text);
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
}
.hero .hero-sub {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.62;
  color: var(--text-secondary);
  max-width: 56ch;
}
@media (max-width: 720px) {
  .hero h1.hero-title { font-size: 1.55rem; }
  .hero.hero--split h1.hero-title { font-size: 1.65rem; }
}
.hero .hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.15rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  transition: background 100ms var(--ease), border-color 100ms var(--ease);
}
.btn:hover { background: var(--surface-raised); border-color: var(--border); text-decoration: none; color: var(--text); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #f8fafc;
}
.btn-primary:hover { background: #325fa3; border-color: #325fa3; color: #f8fafc; }
[data-theme="light"] .btn-primary:hover { background: #163a72; border-color: #163a72; }

/* ---------------------------------------------------------
   Code preview card (terminal chrome)
   --------------------------------------------------------- */
.code-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1118;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}
[data-theme="light"] .code-card {
  background: #0d1117;
  box-shadow: none;
}
.code-card .code-card__head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
}
.code-card .code-card__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #475569;
  opacity: 0.7;
}
.code-card .code-card__dot:nth-child(1) { background: #ef4444; }
.code-card .code-card__dot:nth-child(2) { background: #f59e0b; }
.code-card .code-card__dot:nth-child(3) { background: #22c55e; }
.code-card .code-card__title {
  margin-left: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: #64748b;
  letter-spacing: 0.02em;
}
.code-card pre {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 1rem 1.15rem 1.1rem;
  font-size: 0.82rem;
  line-height: 1.65;
  color: #cbd5e1;
}
.code-card .tok-k { color: #c084fc; }
.code-card .tok-s { color: #fbbf24; }
.code-card .tok-p { color: #64748b; }
.code-card .tok-c { color: #475569; font-style: italic; }
.code-card .tok-n { color: #60a5fa; }
.code-card .tok-ok { color: #4ade80; }

/* ---------------------------------------------------------
   Section eyebrow (before a section heading for rhythm)
   --------------------------------------------------------- */
.section-eyebrow {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 2.5rem 0 0.2rem;
}
.section-eyebrow + h2 {
  margin-top: 0.3rem;
  border-bottom: none;
  padding-bottom: 0;
  font-size: 1.28rem;
  letter-spacing: -0.02em;
  font-weight: 600;
  line-height: 1.25;
}
.section-lede {
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 62ch;
  margin: 0.3rem 0 1.4rem;
}

/* ---------------------------------------------------------
   Numbered principle block (large, narrative)
   --------------------------------------------------------- */
.principle {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  gap: 1rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--border-subtle);
}
.principle:first-of-type { border-top: none; padding-top: 0.35rem; }
.principle .principle__num {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  padding-top: 0.2rem;
}
.principle h3 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  letter-spacing: -0.015em;
  color: var(--text);
}
.principle p {
  margin: 0;
  max-width: 62ch;
  line-height: 1.68;
}
.principle p + p { margin-top: 0.55rem; }

/* ---------------------------------------------------------
   Tabbed code block (Write / Read / History)
   --------------------------------------------------------- */
.code-tabs {
  margin: 1.25rem 0 1.5rem;
}
.code-tabs__nav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  padding: 0 0.25rem;
}
.code-tabs__tab {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0.65rem 0.95rem;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms var(--ease), border-color 120ms var(--ease);
}
.code-tabs__tab:hover { color: var(--text-secondary); }
.code-tabs__tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--text-dim);
  font-weight: 500;
}
.code-tabs__panels { position: relative; }
.code-tabs__panel { display: none; }
.code-tabs__panel[data-active="true"] { display: block; }
.code-tabs__panel pre {
  margin: 0.75rem 0 0;
  border-radius: var(--radius);
}

/* ---------------------------------------------------------
   Compact capability list (replaces repeated feature grids)
   --------------------------------------------------------- */
.capability-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 1.25rem;
  display: grid;
  grid-template-columns: 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
/* Block + absolute marker: avoids grid placing <strong>, text, and .tag in separate columns (overlap bug). */
.capability-list li {
  display: block;
  position: relative;
  padding: 0.7rem 1rem 0.7rem 1.35rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}
.capability-list li:first-child { border-top: none; }
.capability-list li::before {
  content: "";
  position: absolute;
  left: 0.55rem;
  top: 0.95rem;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--text-dim);
  border: none;
  background-image: none;
}
.capability-list li.is-future::before {
  background: var(--text-tertiary);
  border: none;
  background-image: none;
}
.capability-list li strong { color: var(--text); font-weight: 600; }
.capability-list li .tag {
  display: inline-block;
  margin-left: 0.4rem;
  vertical-align: 0.08em;
}

/* Capability rows with left “snapshot” SVG (< 3s scan) */
.capability-list.capability-list--with-snaps li {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.85rem 1rem;
}
.capability-list.capability-list--with-snaps li::before {
  content: none;
  display: none;
}
.capability-list__snap,
.steps__snap {
  flex: 0 0 104px;
  width: 104px;
  align-self: flex-start;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-dim);
}
.capability-list__snap svg,
.steps__snap svg {
  display: block;
  width: 100%;
  height: auto;
}
.capability-list__snap .snap-accent,
.steps__snap .snap-accent {
  color: var(--accent-bright);
}
.capability-list__text,
.steps__text {
  flex: 1;
  min-width: 0;
}
@media (max-width: 560px) {
  .capability-list.capability-list--with-snaps li {
    flex-direction: column;
    gap: 0.65rem;
  }
  .capability-list__snap,
  .steps.steps--with-snaps .steps__snap {
    flex: 0 0 auto;
    width: 100%;
    max-width: 160px;
  }
  .steps.steps--with-snaps > li {
    flex-wrap: wrap;
  }
  .steps.steps--with-snaps .steps__text {
    flex: 1 1 100%;
    min-width: 100%;
  }
}

/* ---------------------------------------------------------
   Kbd (keyboard-like inline element, for shortcuts / commands)
   --------------------------------------------------------- */
kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75em;
  padding: 0.1em 0.45em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--text);
  line-height: 1.4;
}

/* ---------------------------------------------------------
   Feature card grid (product landing)
   --------------------------------------------------------- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
  margin: 1rem 0 1.5rem;
}
.feature-card {
  position: relative;
  padding: 1rem 1.05rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-subtle);
  transition: border-color 100ms var(--ease), background 100ms var(--ease);
}
.feature-card:hover {
  border-color: var(--border);
  background: var(--surface);
}
.feature-card .feature-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-raised);
  color: var(--text-dim);
  border: 1px solid var(--border);
  margin-bottom: 0.65rem;
  font-size: 0.95rem;
}
.feature-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.94rem;
  color: var(--text);
}
.feature-card p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ---------------------------------------------------------
   Step list (pipeline / how it works)
   --------------------------------------------------------- */
.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 0.65rem 0 1.2rem;
  display: grid;
  gap: 0.6rem;
}
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0.75rem 1rem 0.8rem 3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0.85rem;
  top: 0.72rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
}
.steps > li strong { color: var(--text); }

/* Numbered steps + optional snapshot (same scan pattern as capability-list--with-snaps) */
.steps.steps--with-snaps > li {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 1rem 0.85rem 1rem;
}
.steps.steps--with-snaps > li::before {
  position: static;
  flex: 0 0 1.5rem;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.32rem;
  top: auto;
  left: auto;
}

/* ---------------------------------------------------------
   Concept block (plain-language paper concepts, replaces .definition)
   --------------------------------------------------------- */
.concept {
  margin: 1rem 0 1.25rem;
  padding: 0.95rem 1.15rem 1rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  font-size: 0.92rem;
  line-height: 1.68;
  color: var(--text-secondary);
}
.concept .concept-label {
  display: block;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}
.concept strong { color: var(--text); }

/* ---------------------------------------------------------
   Pill tag
   --------------------------------------------------------- */
.tag {
  display: inline-block;
  padding: 0.12em 0.55em;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-secondary);
  vertical-align: middle;
}

/* ---------------------------------------------------------
   Status badges (implementation status, etc.)
   --------------------------------------------------------- */
.status-impl,
.status-future,
.status-partial {
  display: inline-block;
  padding: 0.16em 0.55em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
}
.status-impl {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}
.status-future {
  background: var(--surface-raised);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-weight: 500;
}
.status-partial {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}

/* ---------------------------------------------------------
   Definition blocks (formal definitions from the paper)
   --------------------------------------------------------- */
.definition {
  margin: 1rem 0 1.25rem;
  padding: 0.9rem 1.1rem 0.95rem;
  border: 1px solid var(--accent-border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-bg);
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-secondary);
}
.definition .definition-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-bright);
  margin-bottom: 0.35rem;
}
.definition strong { color: var(--text); }

.algorithm {
  margin: 1rem 0 1.25rem;
  padding: 0.85rem 1.1rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.86rem;
}
.algorithm .algorithm-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}
.algorithm ol {
  margin: 0.35rem 0 0;
  padding-left: 1.3rem;
  counter-reset: algo;
  list-style: decimal;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.algorithm ol li { line-height: 1.6; }
.algorithm ol ol { padding-left: 1.1rem; margin-top: 0.15rem; }

/* ---------------------------------------------------------
   Grid + cards
   --------------------------------------------------------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  background: var(--surface);
  transition: border-color 120ms var(--ease);
}
.card:hover { border-color: var(--accent-border); }
.card h3    { margin-top: 0; }

/* ---------------------------------------------------------
   Mermaid
   --------------------------------------------------------- */
.mermaid-wrap {
  margin: 1rem 0;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */
@media (max-width: 1280px) {
  #toc-panel { display: none; }
}

/* ---------------------------------------------------------
   Topic-card illustration (product hero, no code)
   --------------------------------------------------------- */
.hero-illustration {
  position: relative;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.hero-illustration::before,
.hero-illustration::after {
  content: "";
  position: absolute;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-subtle);
  box-shadow: none;
  opacity: 0.5;
}
.hero-illustration::before {
  inset: 20px 64px 56px 12px;
  transform: rotate(-2deg);
}
.hero-illustration::after {
  inset: 12px 12px 72px 56px;
  transform: rotate(1.5deg);
  opacity: 0.35;
}

.topic-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  font-family: var(--font);
}
.topic-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
}
.topic-card__title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.topic-card__title::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--accent);
  box-shadow: none;
}
.topic-card__ver {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-tertiary);
  padding: 0.18rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-subtle);
}
.topic-card__summary {
  padding: 0.7rem 1.1rem 0.9rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}
.topic-card__fields {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0;
}
.topic-card__fields li {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-subtle);
}
.topic-card__fields li:last-child { border-bottom: none; }
.topic-card__fields .k {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}
.topic-card__fields .v {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-weight: 500;
  min-width: 0;
}
.topic-card__fields .was {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-tertiary);
  text-decoration: line-through;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}
.topic-card__fields .pulse {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: none;
  flex-shrink: 0;
}
.topic-card__links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.1rem 0.9rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}
.topic-card__links-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-right: 0.25rem;
}
.topic-card__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-raised);
}
.topic-card__chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--text-tertiary);
}

@media (max-width: 960px) {
  .hero-illustration { min-height: 300px; }
  .topic-card { max-width: 100%; }
}

/* ---------------------------------------------------------
   CTA panel (product index — does not replace .callout info boxes)
   --------------------------------------------------------- */
.cta-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1.5rem;
  margin: 2.25rem 0;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
}
.cta-panel__eyebrow {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin-bottom: 0.45rem;
}
.cta-panel h3 {
  margin: 0 0 0.3rem;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
.cta-panel p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  max-width: 56ch;
}
@media (max-width: 720px) {
  .cta-panel { grid-template-columns: 1fr; }
}

/* Product capability list — same marker treatment (layout inherited from .capability-list li) */
.capability-list.capability-list--plain li::before {
  background: var(--text-dim);
  box-shadow: none;
}
.capability-list.capability-list--plain.capability-list--with-snaps li::before {
  content: none;
  display: none;
}

/* Audience switcher (injected under page header) */
.audience-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
  margin: 0 0 1rem;
  padding: 0.5rem 0;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  background: transparent;
  font-size: 0.8125rem;
}
.audience-strip__tag {
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.65rem;
  color: var(--text-dim);
}
.audience-strip__link {
  font-weight: 500;
  color: var(--accent-bright);
}

/* Developer-only implementation note (injected at end of main) */
.dev-impl-note {
  margin-top: 2.5rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  background: var(--bg-subtle);
}
.dev-impl-note h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
  font-weight: 600;
}
.dev-impl-note p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-tertiary);
}

@media (max-width: 1060px) {
  :root { --sidebar-width: 220px; }
  .page-main { max-width: none; }
}

@media (max-width: 768px) {
  .doc-layout { display: block; }

  #doc-sidebar {
    position: static;
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .page-header,
  .page-main,
  .page-footer {
    padding-left: 1.1rem;
    padding-right: 1.1rem;
  }

  .page-header { position: static; }
  .grid-2      { grid-template-columns: 1fr; }
}
