/* Mermaid Preview — shared design system (content pages + editor chrome) */

:root {
  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-3: #667085;
  --accent: #0e9f6e;
  --accent-strong: #057a55;
  --accent-soft: #e7f8f0;
  --accent-ring: rgba(14, 159, 110, .28);
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --code-bg: #f7f8fa;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 32px -8px rgba(16, 24, 40, .16), 0 4px 8px -4px rgba(16, 24, 40, .06);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --header-h: 56px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b0e13;
  --bg-subtle: #0f131a;
  --surface: #12161e;
  --surface-2: #181d27;
  --border: #232a36;
  --border-strong: #303846;
  --text: #edf0f5;
  --text-2: #aab2c0;
  --text-3: #7d8696;
  --accent: #34d399;
  --accent-strong: #6ee7b7;
  --accent-soft: rgba(52, 211, 153, .12);
  --accent-ring: rgba(52, 211, 153, .3);
  --danger: #f97066;
  --danger-soft: rgba(249, 112, 102, .12);
  --code-bg: #0f131a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, .5);
  --shadow-lg: 0 16px 32px -8px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent-strong); }
[data-theme="dark"] a { color: var(--accent); }
code, pre, kbd { font-family: var(--font-mono); font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font: 500 13.5px/1 var(--font-sans);
  text-decoration: none; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn-primary, a.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
[data-theme="dark"] .btn-primary, [data-theme="dark"] a.btn-primary { color: #052e1c; }
[data-theme="dark"] .btn-primary:hover { background: #6ee7b7; border-color: #6ee7b7; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .i-sun { display: none; }
[data-theme="dark"] .icon-btn .i-sun { display: block; }
[data-theme="dark"] .icon-btn .i-moon { display: none; }

/* ── Header ── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header-inner {
  height: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 28px;
}
.site-header.full .site-header-inner { max-width: none; padding: 0 16px; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text) !important; font-weight: 650; font-size: 15.5px; letter-spacing: -.01em; flex: none; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand b { color: var(--accent); font-weight: 650; }
.site-nav { display: flex; align-items: center; gap: 2px; }
.site-nav a {
  color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 6px 10px; border-radius: 7px; transition: background .15s, color .15s;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current] { color: var(--text); }
.header-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
@media (max-width: 720px) {
  .site-header-inner { gap: 12px; padding: 0 14px; }
  .site-nav a.hide-sm { display: none; }
  .site-nav a { padding: 6px 7px; font-size: 13.5px; }
  .header-end .btn-open-editor { display: none; }
}
@media (max-width: 420px) {
  .site-nav a.hide-xs { display: none; }
  .site-header-inner { gap: 6px; padding: 0 10px; }
  .site-nav { gap: 0; }
  .site-nav a { padding: 6px 5px; font-size: 13px; }
  .brand { font-size: 14.5px; gap: 7px; }
  .brand-mark { width: 24px; height: 24px; }
  .header-end { gap: 2px; }
}

/* ── Footer ── */
.site-footer { margin-top: auto; border-top: 1px solid var(--border); background: var(--bg-subtle); }
.site-footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 40px 20px 28px;
  display: grid; grid-template-columns: 1.5fr repeat(4, 1fr); gap: 28px;
}
.site-footer p { margin: 10px 0 0; color: var(--text-3); font-size: 14px; max-width: 300px; }
.site-footer h2 { font-size: 13px; font-weight: 600; margin: 0 0 12px; color: var(--text); letter-spacing: 0; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.site-footer ul a { color: var(--text-2); text-decoration: none; font-size: 14px; }
.site-footer ul a:hover { color: var(--accent); }
.site-footer-bottom { width: calc(100% - 40px); max-width: 1160px; margin: 0 auto; padding: 16px 0 28px; color: var(--text-3); font-size: 13px; border-top: 1px solid var(--border); }
@media (max-width: 860px) { .site-footer-inner { grid-template-columns: 1fr 1fr; } .site-footer-inner > div:first-child { grid-column: 1 / -1; } }

/* ── Page layout ── */
.page { width: 100%; max-width: 760px; margin: 0 auto; padding: 48px 20px 72px; }
.page-wide { max-width: 1120px; }
.crumbs, .breadcrumb { font-size: 13px; color: var(--text-3); margin-bottom: 20px; }
.crumbs a, .breadcrumb a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover, .breadcrumb a:hover { color: var(--accent); }
.eyebrow { display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--accent-strong); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; margin-bottom: 14px; }
[data-theme="dark"] .eyebrow { color: var(--accent); }

/* ── Prose (articles, docs, legal) ── */
.prose { color: var(--text-2); font-size: 16.5px; line-height: 1.75; }
.prose h1 { color: var(--text); font-size: clamp(30px, 4.4vw, 42px); line-height: 1.15; letter-spacing: -.025em; font-weight: 700; margin: 0 0 14px; }
.prose h2 { color: var(--text); font-size: 23px; line-height: 1.3; letter-spacing: -.015em; font-weight: 650; margin: 44px 0 12px; }
.prose h3 { color: var(--text); font-size: 18px; line-height: 1.4; font-weight: 600; margin: 30px 0 8px; }
.prose p, .prose ul, .prose ol { margin: 0 0 18px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--text-3); }
.prose strong { color: var(--text); font-weight: 600; }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: currentColor; }
.prose :not(pre) > code { font-size: .86em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; color: var(--text); }
.prose pre, pre.code {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; overflow: auto; font-size: 13.5px; line-height: 1.65; color: var(--text); margin: 0 0 22px;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; margin: 0 0 22px; }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { color: var(--text); font-weight: 600; background: var(--bg-subtle); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }
.prose blockquote { margin: 0 0 20px; padding: 2px 0 2px 18px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.lede, .subtitle, .meta, .updated { color: var(--text-3); }
.prose .lede, .prose .subtitle { font-size: 19px; line-height: 1.6; color: var(--text-2); margin-bottom: 28px; }
.prose .meta, .prose .updated { font-size: 14px; margin: -4px 0 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }

.note, .contact-box, .tip-box, .callout {
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius); padding: 14px 18px; margin: 0 0 24px; color: var(--text);
}
.note p, .contact-box p, .tip-box p, .callout p { margin: 0; color: var(--text); }

.article-cta {
  margin: 40px 0; padding: 22px 24px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.article-cta p { margin: 0; flex: 1 1 320px; color: var(--text-2); }
.article-cta a {
  display: inline-flex; align-items: center; height: 38px; padding: 0 16px; border-radius: 8px;
  background: var(--accent); color: #fff !important; font-weight: 600; font-size: 14px; text-decoration: none !important;
}
[data-theme="dark"] .article-cta a { color: #052e1c !important; }
.article-cta a:hover { background: var(--accent-strong); }

/* ── Cards / listings ── */
.page-head { margin-bottom: 36px; }
.page-head h1 { font-size: clamp(30px, 4.4vw, 44px); line-height: 1.12; letter-spacing: -.028em; font-weight: 700; margin: 0 0 12px; color: var(--text); }
.page-head p { font-size: 18px; color: var(--text-2); margin: 0; max-width: 720px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.article-card, .card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.article-card:hover, .card.link:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.article-card h2, .card h3 { font-size: 18px; line-height: 1.35; letter-spacing: -.01em; font-weight: 650; margin: 0; }
.article-card h2 a, .card h3 a { color: var(--text); text-decoration: none; }
.article-card h2 a::after, .card.link h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.article-card p, .card p { margin: 0; color: var(--text-2); font-size: 15px; line-height: 1.6; }
.tag { align-self: flex-start; font-size: 12px; font-weight: 600; color: var(--accent-strong); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; }
[data-theme="dark"] .tag { color: var(--accent); }
.read-more { margin-top: auto; padding-top: 4px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--accent-strong); }
[data-theme="dark"] .read-more { color: var(--accent); }

/* ── Examples ── */
.chip-nav { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 32px; }
.chip-nav a {
  display: inline-flex; align-items: center; height: 32px; padding: 0 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  text-decoration: none; font-size: 13.5px; font-weight: 500; transition: all .15s;
}
.chip-nav a:hover { border-color: var(--border-strong); color: var(--text); }
.chip-nav a[aria-current] { background: var(--text); border-color: var(--text); color: var(--bg); }
.example-list { display: grid; gap: 22px; }
.example-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); gap: 22px; }
@media (max-width: 560px) { .example-grid { grid-template-columns: 1fr; } }
.example {
  position: relative; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column;
}
.example-head { padding: 20px 22px 0; }
.example h2, .example h3 { font-size: 17.5px; line-height: 1.35; letter-spacing: -.01em; font-weight: 650; margin: 0 0 6px; color: var(--text); }
.example-head p { margin: 0; color: var(--text-2); font-size: 15px; }
.example-head code { font-size: .86em; background: var(--surface-2); border: 1px solid var(--border); padding: 0 5px; border-radius: 5px; color: var(--text); }
.example .diagram {
  margin: 16px 22px 0; min-height: 200px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); padding: 18px; overflow: auto;
  background-color: var(--bg-subtle);
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 16px 16px;
  color: var(--text-3); font-size: 13px; border: 1px solid var(--border);
}
.example .diagram svg { max-width: 100%; max-height: 400px; height: auto; }
.example .diagram.ready { min-height: 0; }
.example .code-wrap { position: relative; margin: 14px 22px 0; }
.example pre { margin: 0; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; overflow: auto; font-size: 13px; line-height: 1.6; color: var(--text); max-height: 340px; }
.example .copy-code {
  position: absolute; top: 8px; right: 8px; height: 26px; padding: 0 9px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font: 500 12px var(--font-sans); cursor: pointer; opacity: .9;
}
.example .copy-code:hover { color: var(--text); border-color: var(--border-strong); }
.example .actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 22px 20px; margin-top: auto; }
.example .actions a.more { font-size: 14px; font-weight: 600; text-decoration: none; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px 26px; box-shadow: var(--shadow-sm); }
.panel h2 { font-size: 20px; letter-spacing: -.01em; font-weight: 650; margin: 0 0 12px; color: var(--text); }
.panel h3 { font-size: 16px; margin: 20px 0 6px; color: var(--text); }
.panel p, .panel li { color: var(--text-2); }
.panel p:last-child, .panel ul:last-child { margin-bottom: 0; }
.panel table { width: 100%; border-collapse: collapse; font-size: 14px; }
.panel th, .panel td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text-2); }
.panel th { color: var(--text-3); font-weight: 500; font-size: 13px; }
.panel tr:last-child td { border-bottom: 0; }
.panel td:first-child { white-space: nowrap; }
.panel code { font-size: .86em; background: var(--surface-2); border: 1px solid var(--border); padding: 0 5px; border-radius: 5px; color: var(--text); }
.table-wrap { overflow-x: auto; }
.section-gap { margin-top: 22px; }
@media (max-width: 640px) { .panel td:first-child { white-space: normal; } .page { padding-top: 32px; } }

/* FAQ accordion */
.faq details { border-bottom: 1px solid var(--border); }
.faq details:first-of-type { border-top: 1px solid var(--border); }
.faq summary { cursor: pointer; list-style: none; padding: 16px 32px 16px 0; position: relative; font-weight: 600; color: var(--text); font-size: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: ""; position: absolute; right: 6px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: translateY(-70%) rotate(45deg); transition: transform .2s; }
.faq details[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.faq details > div { padding: 0 0 18px; color: var(--text-2); }

/* Live examples and code labels inside articles */
.prose .example { margin: 8px 0 30px; font-size: 16px; }
.prose .code-label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); margin: 0 0 6px; }
.prose .code-label + pre { margin-bottom: 18px; }
