/* ==========================================================================
   Foreground UI — documentation site styles
   Built on the same tokens as the components (injected by core.js).
   ========================================================================== */

:root {
  --topbar-h: 56px;
  --sidebar-w: 264px;
  --content-w: 1080px;

  /* Code theme */
  --code-bg: #fbfbfc;
  --tk-comment: #8a94a3;
  --tk-tag: #2b45bb;
  --tk-attr: #8a4bd6;
  --tk-string: #0e7c50;
  --tk-keyword: #c02a6a;
  --tk-number: #b4580a;
  --tk-fn: #1f6fb2;
  --tk-prop: #2b45bb;
  --tk-var: #8a4bd6;
  --tk-selector: #9a2f8f;
  --tk-punct: #6b7280;
}
[data-theme='dark'] {
  --code-bg: #0f141b;
  --tk-comment: #6b7787;
  --tk-tag: #8fa3f7;
  --tk-attr: #c49bf2;
  --tk-string: #7fd4a8;
  --tk-keyword: #f28bb6;
  --tk-number: #f0b27a;
  --tk-fn: #7dbbf0;
  --tk-prop: #93a7f7;
  --tk-var: #c49bf2;
  --tk-selector: #e59bdc;
  --tk-punct: #7d8b9a;
}

html {
  scroll-padding-top: calc(var(--topbar-h) + 16px);
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--c-ink);
  background: var(--c-canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--c-brand-text); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
kbd {
  display: inline-block;
  padding: 1px 5px;
  font: 500 var(--fs-2xs) / 1.4 var(--font-mono);
  color: var(--c-ink-3);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-bottom-width: 2px;
  border-radius: 4px;
}
svg { flex: none; }
[hidden] { display: none !important; }

.skip {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 8px 12px;
  color: var(--c-brand-ink);
  background: var(--c-brand);
  border-radius: var(--r-md);
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* ---------------------------------------------------------------- Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: color-mix(in srgb, var(--c-canvas) 82%, transparent);
  border-bottom: 1px solid var(--c-line);
  backdrop-filter: saturate(1.5) blur(14px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--c-ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand__mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background:
    linear-gradient(#fff, #fff) 6px 6px / 9px 6px no-repeat,
    linear-gradient(rgb(255 255 255 / 0.55), rgb(255 255 255 / 0.55)) 6px 14px / 9px 6px no-repeat,
    linear-gradient(rgb(255 255 255 / 0.8), rgb(255 255 255 / 0.8)) 17px 6px / 4px 14px no-repeat,
    #3452d9;
}
.brand__name { font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.015em; }
.brand__name b { font-weight: 600; color: var(--c-brand-text); }
.brand__ver {
  padding: 2px 6px;
  font: 500 var(--fs-2xs) / 1.4 var(--font-mono);
  color: var(--c-ink-3);
  background: var(--c-surface-3);
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
}

.topbar__search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(360px, 100%);
  margin-left: auto;
}
.topbar__search svg {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--c-ink-4);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.topbar__search input {
  width: 100%;
  height: 34px;
  padding: 0 34px 0 32px;
  font: var(--fs-sm) / 1 var(--font-sans);
  color: var(--c-ink);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.topbar__search input::placeholder { color: var(--c-ink-4); }
.topbar__search input::-webkit-search-cancel-button { display: none; }
.topbar__search input:focus { outline: none; border-color: var(--c-brand); box-shadow: var(--focus-ring); }
.topbar__search kbd { position: absolute; right: 8px; pointer-events: none; }
.topbar__actions { display: flex; gap: 4px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--c-ink-2);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { color: var(--c-ink); background: var(--c-surface-3); }
.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i-moon { display: none; }
[data-theme='dark'] .i-sun { display: none; }
[data-theme='dark'] .i-moon { display: block; }
.topbar__menu { display: none; }

/* ---------------------------------------------------------------- Layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  padding: 20px 12px 40px;
  border-right: 1px solid var(--c-line);
  scrollbar-width: thin;
}
.nav-section + .nav-section { margin-top: 18px; }
.nav-section__title {
  display: flex;
  justify-content: space-between;
  margin: 0 0 4px;
  padding: 0 10px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--c-ink-4);
}
.nav-section ul { margin: 0; padding: 0; list-style: none; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: var(--fs-sm);
  color: var(--c-ink-2);
  text-decoration: none;
  border-radius: var(--r-md);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-link:hover { color: var(--c-ink); background: var(--c-surface-3); }
.nav-link[aria-current='page'] {
  font-weight: 500;
  color: var(--c-brand-text);
  background: var(--c-brand-soft);
}
.nav-link__js {
  margin-left: auto;
  font: 500 9px / 1 var(--font-mono);
  color: var(--c-ink-4);
}
.nav-link--home svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.nav-empty { padding: 8px 10px; font-size: var(--fs-sm); color: var(--c-ink-3); }

.main {
  min-width: 0;
  padding: 36px 40px 80px;
}
.main:focus { outline: none; box-shadow: none; }
.page { max-width: var(--content-w); margin: 0 auto; animation: page-in var(--dur-slow) var(--ease-out); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------------------------------------- Page header */
.crumb {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--c-ink-4);
}
.crumb a { color: var(--c-ink-3); text-decoration: none; }
.crumb a:hover { color: var(--c-ink); }
.page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: var(--fs-3xl);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
}
.lede {
  max-width: 68ch;
  margin: 12px 0 0;
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--c-ink-2);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--c-ink-2);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
}
.chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--c-ink-4); }
.chip--html i { background: #e34c26; }
.chip--css i { background: #2965f1; }
.chip--js i { background: #e8b600; }
.chip--status { color: var(--c-success); background: var(--c-success-soft); border-color: var(--c-success-line); }
.chip--status i { background: currentColor; }
.chip--muted { color: var(--c-ink-4); }

/* ---------------------------------------------------------------- Example block */
.example {
  margin-top: 28px;
  overflow: hidden;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xs);
}
.example__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 6px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
}
.ex-tabs { display: flex; gap: 2px; }
.ex-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  font: 500 var(--fs-sm) / 1 var(--font-sans);
  color: var(--c-ink-3);
  background: none;
  border: 0;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.ex-tab:hover { color: var(--c-ink); background: var(--c-surface-3); }
.ex-tab[aria-selected='true'] { color: var(--c-ink); background: var(--c-surface-3); box-shadow: inset 0 0 0 1px var(--c-line); }
.ex-tab svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ex-tab__dot { width: 7px; height: 7px; border-radius: 2px; }
.ex-tab__n { font: var(--fs-2xs) / 1 var(--font-mono); color: var(--c-ink-4); }

.ex-tools { display: flex; align-items: center; gap: 4px; }
.ex-tools .sep { width: 1px; height: 20px; margin: 0 4px; background: var(--c-line); }
.vp {
  display: inline-flex;
  padding: 2px;
  background: var(--c-surface-3);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
}
.vp button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 26px;
  color: var(--c-ink-3);
  background: none;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.vp button:hover { color: var(--c-ink); }
.vp button[aria-pressed='true'] { color: var(--c-ink); background: var(--c-surface); box-shadow: var(--shadow-xs), 0 0 0 1px var(--c-line); }
.vp svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  font: 500 var(--fs-xs) / 1 var(--font-sans);
  color: var(--c-ink-2);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
}
.tool-btn:hover { color: var(--c-ink); background: var(--c-surface-3); }
.tool-btn--icon { width: 30px; padding: 0; justify-content: center; }
.tool-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn.is-done { color: var(--c-success); }
.ex-tools [hidden] { display: none; }

.stage {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 0;
  background-color: var(--c-canvas);
  background-image: radial-gradient(var(--c-line) 1px, transparent 1px);
  background-size: 16px 16px;
  transition: padding var(--dur) var(--ease);
}
.stage.is-device { padding: 24px 16px; }
.frame {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background: var(--c-canvas);
  transition: width var(--dur-slow) var(--ease-out), border-radius var(--dur) var(--ease);
}
.stage.is-device .frame {
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
}
.frame iframe {
  display: block;
  width: 100%;
  height: 240px;
  border: 0;
  background: transparent;
  transition: height var(--dur) var(--ease);
}
.stage__size {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font: var(--fs-2xs) / 1 var(--font-mono);
  color: var(--c-ink-4);
  pointer-events: none;
}

.code {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  max-height: 560px;
  overflow: auto;
  font: 12.5px / 1.7 var(--font-mono);
  background: var(--code-bg);
  tab-size: 2;
}
.code__gutter {
  position: sticky;
  left: 0;
  padding: 16px 12px 16px 16px;
  text-align: right;
  color: var(--c-ink-4);
  background: var(--code-bg);
  border-right: 1px solid var(--c-line-soft);
  user-select: none;
  white-space: pre;
}
.code pre {
  margin: 0;
  padding: 16px 20px;
  color: var(--c-ink);
  white-space: pre;
}
.code__empty {
  padding: 40px 20px;
  font-size: var(--fs-sm);
  text-align: center;
  color: var(--c-ink-3);
  background: var(--code-bg);
}
.tk-comment { color: var(--tk-comment); font-style: italic; }
.tk-tag { color: var(--tk-tag); }
.tk-attr { color: var(--tk-attr); }
.tk-string { color: var(--tk-string); }
.tk-keyword { color: var(--tk-keyword); }
.tk-number { color: var(--tk-number); }
.tk-fn { color: var(--tk-fn); }
.tk-prop { color: var(--tk-prop); }
.tk-var { color: var(--tk-var); }
.tk-selector { color: var(--tk-selector); }
.tk-punct,
.tk-op { color: var(--tk-punct); }
.tk-entity { color: var(--tk-number); }

/* ---------------------------------------------------------------- Doc sections */
.doc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 32px;
  margin-top: 40px;
}
.doc-section h2 {
  margin: 0 0 12px;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.api {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  overflow: hidden;
  border-spacing: 0;
}
.api th,
.api td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--c-line-soft); }
.api tr:last-child td { border-bottom: 0; }
.api th { font-size: var(--fs-xs); font-weight: 500; color: var(--c-ink-3); background: var(--c-surface-2); border-bottom-color: var(--c-line); }
.api code {
  font: 12px / 1.5 var(--font-mono);
  color: var(--c-brand-text);
  word-break: break-word;
}
.api td:last-child { color: var(--c-ink-2); }
.checklist { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.checklist li {
  position: relative;
  padding: 12px 14px 12px 40px;
  font-size: var(--fs-sm);
  color: var(--c-ink-2);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
}
.checklist li::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 14px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background:
    linear-gradient(45deg, transparent 45%, var(--c-success) 45%, var(--c-success) 58%, transparent 58%) 7px 3px / 4px 8px no-repeat,
    var(--c-success-soft);
  box-shadow: inset 0 0 0 1px var(--c-success-line);
}

.usage {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 40px;
  counter-reset: usage;
}
.usage__step {
  padding: 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  counter-increment: usage;
}
.usage__step b { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--fs-sm); }
.usage__step b::before {
  content: counter(usage);
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: var(--fs-2xs);
  color: var(--c-brand-text);
  background: var(--c-brand-soft);
  border-radius: 50%;
}
.usage__step p { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--c-ink-3); }

.pager-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--c-line);
}
.pager-nav a {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  text-decoration: none;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-fast) var(--ease);
}
.pager-nav a:hover { border-color: var(--c-brand-line); }
.pager-nav small { font-size: var(--fs-xs); color: var(--c-ink-4); }
.pager-nav span { font-weight: 500; color: var(--c-ink); }
.pager-nav .next { text-align: right; grid-column: 2; }

/* ---------------------------------------------------------------- Home */
.hero { padding: 24px 0 8px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 4px 10px 4px 4px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--c-ink-2);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-full);
}
.eyebrow b {
  padding: 2px 8px;
  font-size: var(--fs-2xs);
  color: var(--c-brand-ink);
  background: var(--c-brand);
  border-radius: var(--r-full);
}
.hero h1 {
  max-width: 18ch;
  margin: 0;
  font-size: var(--fs-4xl);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.hero h1 span { color: var(--c-brand-text); }
.hero .lede { font-size: var(--fs-lg); }
.hero__cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  font: 500 var(--fs-sm) / 1 var(--font-sans);
  color: var(--c-ink);
  text-decoration: none;
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-md);
  cursor: pointer;
}
.cta:hover { background: var(--c-surface-3); }
.cta--primary { color: var(--c-brand-ink); background: var(--c-brand); border-color: transparent; }
.cta--primary:hover { background: var(--c-brand-hover); }
.cta svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 40px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
}
.stats-row div { padding: 18px 20px; }
.stats-row div + div { border-left: 1px solid var(--c-line); }
.stats-row b { display: block; font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.02em; }
.stats-row span { font-size: var(--fs-xs); color: var(--c-ink-3); }

.home-section { margin-top: 56px; }
.home-section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.home-section__head h2 { margin: 0; font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.02em; }
.home-section__head p { margin: 0; font-size: var(--fs-sm); color: var(--c-ink-3); }

.start {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.start__card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
}
.start__card h3 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: var(--fs-md); }
.start__card h3 span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  font-size: var(--fs-xs);
  color: var(--c-brand-text);
  background: var(--c-brand-soft);
  border-radius: var(--r-sm);
}
.start__card p { flex: 1; margin: 0; font-size: var(--fs-sm); color: var(--c-ink-3); }
.start__card pre {
  margin: 4px 0 0;
  padding: 10px 12px;
  overflow-x: auto;
  font: 12px / 1.6 var(--font-mono);
  background: var(--code-bg);
  border: 1px solid var(--c-line-soft);
  border-radius: var(--r-md);
}
.start__card .tool-btn { align-self: flex-start; margin: 4px 0 0 -10px; color: var(--c-brand-text); }

.cat-block + .cat-block { margin-top: 32px; }
.cat-block h3 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 12px;
  font-size: var(--fs-md);
  font-weight: 600;
}
.cat-block h3 small { font-size: var(--fs-sm); font-weight: 400; color: var(--c-ink-3); }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.comp-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  color: inherit;
  text-decoration: none;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.comp-card:hover { border-color: var(--c-brand-line); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.comp-card b { font-size: var(--fs-base); font-weight: 600; }
.comp-card p {
  display: -webkit-box;
  flex: 1;
  margin: 0;
  overflow: hidden;
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--c-ink-3);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.comp-card .chips { margin-top: 6px; gap: 4px; }
.comp-card .chip { height: 20px; padding: 0 6px; font-size: var(--fs-2xs); }

/* ---------------------------------------------------------------- Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 300;
  padding: 9px 14px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--c-ink-inv);
  background: var(--c-ink);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1100px) {
  .doc-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar__menu { display: inline-grid; }
  .topbar__search { width: auto; flex: 1; max-width: 360px; }
  .brand__ver { display: none; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    z-index: 55;
    width: min(300px, 85vw);
    height: auto;
    background: var(--c-canvas);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease-out);
  }
  .sidebar.is-open { transform: none; }
  .scrim { position: fixed; inset: var(--topbar-h) 0 0; z-index: 54; background: var(--c-scrim); }
  .main { padding: 24px 16px 64px; }
  .start, .usage { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-row div:nth-child(3) { border-left: 0; }
  .stats-row div:nth-child(n + 3) { border-top: 1px solid var(--c-line); }
}
@media (max-width: 600px) {
  .brand__name { display: none; }
  .topbar__search kbd { display: none; }
  .page-title { font-size: var(--fs-2xl); }
  .hero h1 { font-size: var(--fs-3xl); }
  .ex-tab { padding: 0 9px; }
  .ex-tab__n { display: none; }
  .vp { display: none; }
  .ex-tools .sep { display: none; }
  .pager-nav { grid-template-columns: 1fr; }
  .pager-nav .next { grid-column: 1; }
}

/* ---------------------------------------------------------------- Libraries */
.lib-switch {
  display: inline-flex;
  gap: 2px;
  margin-left: 8px;
  padding: 3px;
  background: var(--c-surface-3);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
}
.lib-switch a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 12px;
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  color: var(--c-ink-3);
  text-decoration: none;
  border-radius: var(--r-md);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.lib-switch a i { width: 8px; height: 8px; border-radius: 50%; background: var(--lib); opacity: 0.6; }
.lib-switch a small { font: 500 var(--fs-2xs) / 1 var(--font-mono); color: var(--c-ink-4); }
.lib-switch a:hover { color: var(--c-ink); }
.lib-switch a[aria-current='true'] {
  color: var(--c-ink);
  background: var(--c-surface);
  box-shadow: var(--shadow-xs), 0 0 0 1px var(--c-line);
}
.lib-switch a[aria-current='true'] i { opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--lib) 22%, transparent); }
@media (max-width: 1100px) {
  .lib-switch a small { display: none; }
}
@media (max-width: 700px) {
  .lib-switch { margin-left: 0; }
  .lib-switch a { padding: 0 8px; font-size: var(--fs-xs); gap: 5px; }
  .topbar__search { display: none; }
}

.chip--lib i { background: var(--lib); }
.eyebrow[style] b { color: #fff; background: var(--lib); }

.lib-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 36px;
}
.lib-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.lib-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--lib);
}
.lib-card:hover {
  border-color: color-mix(in srgb, var(--lib) 45%, var(--c-line));
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.lib-card__mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 6px;
  font-size: var(--fs-lg);
  font-weight: 700;
  color: #fff;
  background: var(--lib);
  border-radius: var(--r-lg);
}
.lib-card__ver {
  position: absolute;
  top: 22px;
  right: 22px;
  font: 500 var(--fs-2xs) / 1.4 var(--font-mono);
  color: var(--c-ink-3);
  padding: 2px 6px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
}
.lib-card b { font-size: var(--fs-lg); font-weight: 650; letter-spacing: -0.01em; }
.lib-card p { flex: 1; margin: 0; font-size: var(--fs-sm); line-height: 1.55; color: var(--c-ink-3); }
.lib-card__meta { display: flex; gap: 14px; font-size: var(--fs-xs); color: var(--c-ink-4); }
.lib-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c-ink);
}
.lib-card__cta svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur) var(--ease); }
.lib-card:hover .lib-card__cta svg { transform: translateX(3px); }

.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--c-line);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
}
.feature { padding: 20px; background: var(--c-surface); }
.feature b { font-size: var(--fs-sm); font-weight: 600; }
.feature p { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--c-ink-3); }

@media (max-width: 1000px) {
  .lib-cards, .features { grid-template-columns: 1fr; }
}

.sidebar__search { display: none; }
@media (max-width: 700px) {
  .sidebar__search {
    display: block;
    width: 100%;
    height: 36px;
    margin-bottom: 16px;
    padding: 0 12px;
    font: var(--fs-sm) / 1 var(--font-sans);
    color: var(--c-ink);
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--r-md);
  }
  .sidebar__search:focus { outline: none; border-color: var(--c-brand); box-shadow: var(--focus-ring); }
}

/* ---------------------------------------------------------------- Style variants */
.chip--var i { background: linear-gradient(135deg, #6366f1, #ec4899); }
.nav-link__var {
  margin-left: auto;
  padding: 1px 6px;
  font: 600 9px / 1.4 var(--font-mono);
  color: var(--c-brand-text);
  background: var(--c-brand-soft);
  border-radius: var(--r-full);
}
.nav-link__var + .nav-link__js { margin-left: 6px; }
.variants {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 20px;
}
.variants__label {
  flex: none;
  padding-top: 7px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-ink-4);
}
.variants__list { display: flex; flex-wrap: wrap; gap: 6px; }
.variant {
  height: 30px;
  padding: 0 12px;
  font: 500 var(--fs-sm) / 1 var(--font-sans);
  color: var(--c-ink-2);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.variant:hover { color: var(--c-ink); border-color: var(--c-line-strong); }
.variant[aria-checked='true'] { color: var(--c-brand-ink); background: var(--c-brand); border-color: transparent; }
.variants__desc { min-height: 1.5em; margin: 8px 0 0; font-size: var(--fs-sm); color: var(--c-ink-3); }
