:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #1c2430;
  --muted: #5f6b7a;
  --accent: #0f766e;
  --accent-soft: #d5f0ec;
  --boot: #7c3aed;
  --boot-soft: #ede5fd;
  --deploy: #b45309;
  --deploy-soft: #fdf0dc;
  --warn: #9a3412;
  --warn-soft: #ffedd5;
  --code-bg: #f3f5f8;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --surface: #161c24;
    --surface-2: #1d2530;
    --border: #2a3441;
    --text: #e4e9ef;
    --muted: #93a0b0;
    --accent: #2dd4bf;
    --accent-soft: #123b37;
    --boot: #b79cfb;
    --boot-soft: #2a2140;
    --deploy: #f5b45c;
    --deploy-soft: #3a2a14;
    --warn: #fdba74;
    --warn-soft: #3b2312;
    --code-bg: #11161d;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.9rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.95rem; color: var(--muted); margin-top: 1.2em; text-transform: uppercase; letter-spacing: 0.04em; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 0.85em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Header */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand .dot { color: var(--accent); }
.brand-mark { width: 20px; height: 20px; border-radius: 5px; background: var(--accent); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 6px; background: var(--surface); border-radius: 2px; }
.topbar nav { display: flex; gap: 4px 16px; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); font-weight: 500; padding: 4px 0; }
.topbar nav a:hover { color: var(--text); text-decoration: none; }

main { padding: 24px 16px 48px; }
.footer { color: var(--muted); font-size: 0.85rem; padding-bottom: 32px; }

/* Hero */
.hero { padding: 16px 0 24px; }
.hero.compact { padding-bottom: 8px; }
.lede { font-size: 1.05rem; color: var(--muted); max-width: 70ch; margin: 0 0 1em; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .num { display: block; font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: 0.85rem; }

/* Explorer */
.explorer { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; align-items: start; }
.filters { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 12px; }
.search input {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.search input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.facet { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.facet summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.facet select {
  width: 100%; margin-top: 8px; padding: 6px 8px; font: inherit; font-size: 0.9rem;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
}
.btn {
  font: inherit; font-size: 0.85rem; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.count { color: var(--muted); margin: 0 0 8px; font-size: 0.9rem; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.boards { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.boards tbody tr:hover { background: var(--surface-2); }
.boards td:first-child { white-space: nowrap; }
.vars td:first-child { white-space: nowrap; width: 1%; }
.vars code { word-break: break-word; }

/* Chips, badges */
.chips { line-height: 2; }
.chip {
  display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 0.78rem; line-height: 1.7;
  font-family: var(--mono); white-space: nowrap;
}
a.chip:hover { text-decoration: none; filter: brightness(0.95); }
.chip-boot { background: var(--boot-soft); color: var(--boot); }
.chip-deploy { background: var(--deploy-soft); color: var(--deploy); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.badge { font-size: 0.8rem; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Device page */
.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; }
.dev-head { margin-bottom: 20px; }
.dev-head h1 { word-break: break-all; }
.note { background: var(--warn-soft); color: var(--warn); padding: 10px 14px; border-radius: 8px; }
.links { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0;
}
.grid > .card { margin-bottom: 0; }
.card-link { color: var(--text); display: block; }
.card-link:hover { text-decoration: none; border-color: var(--accent); }
.chain { margin: 0; padding-left: 1.2em; }
.chain li { margin: 2px 0; }
.chain li::marker { color: var(--muted); }
.inline-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.88rem; }
.facts dd { margin: 0; word-break: break-word; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; flex-wrap: wrap; }
.tabs [role="tab"] {
  font: inherit; font-weight: 600; font-size: 0.9rem; background: none; border: 0; color: var(--muted);
  padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .copy { margin-left: auto; align-self: center; }
.code {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px;
  overflow: auto; max-height: 640px; font-size: 0.82rem; line-height: 1.5; margin: 0;
}
.code code { font-size: inherit; }

/* Lists */
.toc { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.cols { columns: 260px auto; column-gap: 24px; padding-left: 0; list-style: none; margin: 0; }
.cols li { break-inside: avoid; padding: 2px 0; }
details > summary { cursor: pointer; color: var(--muted); }
.prose { max-width: 80ch; }

@media (max-width: 820px) {
  .explorer { grid-template-columns: 1fr; }
  .filters { position: static; }
  h1 { font-size: 1.5rem; }
  .boards th:nth-child(4), .boards td:nth-child(4),
  .boards th:nth-child(5), .boards td:nth-child(5) { display: none; }
}
.boards .desc { font-size: 0.8rem; color: var(--muted); white-space: normal; max-width: 40ch; }
.stat-link { color: var(--text); }
.stat-link:hover { text-decoration: none; border-color: var(--accent); }
a.badge:hover { text-decoration: none; filter: brightness(0.95); }
.guess { color: var(--deploy); font-weight: 700; margin-left: 2px; cursor: help; }

/* Inheritance tree */
.tree { list-style: none; margin: 0; padding-left: 18px; border-left: 1px dashed var(--border); margin-left: 6px; }
.tree li { padding: 2px 0; }
.tree-node > summary { color: var(--text); padding: 2px 0; }
.tree-node > summary .muted { margin-left: 6px; }
.tree-leaf { display: inline-block; padding-left: 14px; }
.tree-controls { display: flex; gap: 8px; margin: 0 0 12px; }
.tpl-link { font-style: italic; }

/* Current section in the menu */
.topbar nav a.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar nav a.active:hover { color: var(--accent); }
.tree-toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; }
.tree-toolbar .search { flex: 1 1 260px; max-width: 420px; }
.tree-toolbar .tree-controls { margin: 0; }
.tree-root { border-left: 0; padding-left: 0; margin-left: 0; }
.tree a.hit { background: var(--accent-soft); border-radius: 3px; padding: 0 3px; font-weight: 600; }

/* Product page link */
.product-name { font-size: 1.1rem; font-weight: 600; margin: -4px 0 8px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.links .btn { display: inline-block; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
