/* databull.net: one stylesheet, no framework. Tokens on :root, dark mode via prefers-color-scheme. */
:root {
  --bg: #ffffff;
  --bg-subtle: #f6f7f8;
  --bg-raised: #ffffff;
  --ink: #16181d;
  --ink-2: #444a55;
  --muted: #646b77;
  --rule: #e2e5e9;
  --rule-strong: #c5cad1;
  --accent: #1f3fb5;
  --accent-soft: #eef1fb;
  --hl: #fff6d6;
  --amber: #8a5300;
  --amber-rule: #d48a00;
  --amber-soft: #fdf7ea;
  --red: #b42318;
  --red-rule: #d9483b;
  --code-bg: #f7f8fa;
  --t-key: #6b3fa0;
  --t-el: #1f3fb5;
  --t-str: #0f6b3a;
  --t-num: #9a4a00;
  --t-ref: #a3266b;
  --t-kw: #1f3fb5;
  --t-com: #6b7280;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 8px;
  --ctx-h: 46px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --bg-subtle: #161a1f;
    --bg-raised: #13161a;
    --ink: #e7e9ec;
    --ink-2: #bcc2cc;
    --muted: #949ba7;
    --rule: #2a2f37;
    --rule-strong: #434a55;
    --accent: #9db2ff;
    --accent-soft: #1b2340;
    --hl: #3a3211;
    --amber: #f2b65a;
    --amber-rule: #c98a1e;
    --amber-soft: #241c0e;
    --red: #ff9a8f;
    --red-rule: #e0645a;
    --code-bg: #14171b;
    --t-key: #c9a3f5;
    --t-el: #9db2ff;
    --t-str: #8bd8a6;
    --t-num: #f2b65a;
    --t-ref: #f59ac8;
    --t-kw: #9db2ff;
    --t-com: #8c94a0;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--ctx-h) + 12px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); }
h1, h2, h3, p, dl, dd, ul, ol, figure { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd, pre { font-family: var(--mono); font-size: 0.88em; }
code { overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
img { max-width: 100%; height: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); font-weight: 400; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 50; background: var(--bg); padding: 8px 12px; border: 1px solid var(--accent); }

/* ---------- header ---------- */
.site-header { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--rule); max-width: 1480px; margin: 0 auto; }
.brand img { display: block; height: 26px; width: auto; }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; order: 3; width: 100%; }
.site-nav a { color: var(--ink-2); padding: 8px 10px; border-radius: 6px; min-height: 40px; display: inline-flex; align-items: center; }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--bg-subtle); font-weight: 600; }
.finder-trigger { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--rule-strong); border-radius: 8px; padding: 6px 12px; min-height: 40px; color: var(--muted); background: var(--bg); font-size: 14px; }
.finder-trigger:hover { text-decoration: none; border-color: var(--accent); }
.finder-icon { font-family: var(--mono); border: 1px solid var(--rule-strong); border-radius: 4px; padding: 0 5px; font-size: 12px; color: var(--ink-2); }
@media (min-width: 768px) {
  .site-nav { order: 0; width: auto; }
  .finder-trigger { min-width: 240px; }
}

/* ---------- context bar ---------- */
.context-bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--rule); font-size: 13px; }
.context-inner { max-width: 1480px; margin: 0 auto; padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; min-height: var(--ctx-h); }
.crumbs ol { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0 6px; font-family: var(--mono); font-size: 13px; }
.crumbs li + li::before { content: "/"; color: var(--muted); margin-right: 6px; }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.context-meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; color: var(--muted); }
.ctx-path code { font-size: 12.5px; color: var(--ink-2); }
.tree-toggle { border: 1px solid var(--rule-strong); border-radius: 6px; padding: 4px 10px; min-height: 32px; display: inline-flex; align-items: center; color: var(--ink); font-size: 13px; }
@media (min-width: 1100px) { .tree-toggle { display: none; } }

/* ---------- three-column frame ---------- */
.layout { max-width: 1480px; margin: 0 auto; padding: 0 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 28px; }
.main { min-width: 0; padding: 24px 0 48px; }
.main:focus { outline: none; }
.tree { order: 2; border-top: 1px solid var(--rule); padding: 24px 0; font-size: 13.5px; }
.rail { display: none; }
@media (min-width: 1100px) {
  .layout.has-tree { grid-template-columns: 236px minmax(0, 1fr); }
  .tree { order: 0; border-top: 0; padding: 20px 0; }
  .tree-inner { position: sticky; top: calc(var(--ctx-h) + 12px); max-height: calc(100vh - var(--ctx-h) - 24px); overflow-y: auto; padding-right: 8px; }
}
@media (min-width: 1280px) {
  .rail-ready .layout.has-tree.has-rail { grid-template-columns: 236px minmax(0, 1fr) minmax(340px, 400px); }
  .rail-ready .layout.has-rail:not(.has-tree) { grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); }
  .rail-ready .rail { display: block; padding: 20px 0; }
  .rail-ready .rail-inner { position: sticky; top: calc(var(--ctx-h) + 12px); }
  /* Inline copies are hidden visually only once the rail is live; screen readers still read them in place. */
  .rail-ready .has-rail .main .excerpt-inline { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- tree ---------- */
.tree ul { list-style: none; padding: 0; margin: 0 0 8px; }
.tree-repo a { font-family: var(--mono); font-weight: 600; color: var(--ink); font-size: 14px; }
.tree-repo a[aria-current] { color: var(--accent); }
.tree-meta { color: var(--muted); font-size: 12.5px; margin: 2px 0 12px; }
.tree-h { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; margin: 14px 0 4px; }
.tree li a { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; padding: 4px 8px; border-radius: 6px; color: var(--ink-2); }
.tree li a:hover { background: var(--bg-subtle); text-decoration: none; }
.tree li a.current { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.tree .dot { color: var(--muted); font-size: 11px; width: 12px; }
.tree .t-name { font-family: var(--mono); font-size: 12.5px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tree .t-prose { font-family: var(--sans); font-size: 13px; }
.tree .t-sub { flex-basis: 100%; padding-left: 18px; font-size: 11.5px; color: var(--muted); font-family: var(--mono); overflow-wrap: anywhere; }
.tree .wc { font-size: 11px; color: var(--amber); border: 1px solid var(--amber-rule); border-radius: 999px; padding: 0 6px; line-height: 16px; }
.tree-legend, .tree-other { font-size: 12px; color: var(--muted); margin-top: 12px; }
@media (max-width: 1099px) {
  .js .tree.drawer { position: fixed; inset: 0 auto 0 0; width: min(86vw, 340px); z-index: 40; background: var(--bg); border-right: 1px solid var(--rule); padding: 16px; overflow-y: auto; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35); }
  .tree li a { min-height: 44px; align-content: center; }
}

/* ---------- page head and toc ---------- */
.page-head { margin-bottom: 16px; max-width: 920px; }
.page-head h1 { font-size: 24px; line-height: 1.3; font-weight: 650; letter-spacing: -0.01em; margin-top: 4px; }
.eyebrow { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.lede { color: var(--ink-2); margin-top: 10px; max-width: 760px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.toc { margin: 0 0 20px; border-bottom: 1px solid var(--rule); padding-bottom: 12px; }
.toc ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 4px; font-size: 13px; }
.toc a { display: inline-flex; align-items: center; min-height: 32px; padding: 2px 10px; border-radius: 999px; color: var(--ink-2); border: 1px solid var(--rule); }
.toc a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ---------- cards ---------- */
.card { background: var(--bg-raised); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
@media (min-width: 768px) { .card { padding: 18px 20px; } }
.card.active { border-color: var(--rule-strong); box-shadow: inset 3px 0 0 var(--accent); }
.card p + p, .card p + .excerpt-inline, .card .kv + p { margin-top: 8px; }
.card-head { display: flex; align-items: baseline; gap: 8px 10px; flex-wrap: wrap; margin-bottom: 8px; }
.card-title { font-size: 16px; font-weight: 600; line-height: 1.35; }
.card-head .trust { margin-left: auto; }
.section { margin: 28px 0 8px; }
.section-title { font-size: 18px; font-weight: 650; margin-bottom: 12px; }
.sub-title { font-size: 14px; font-weight: 600; margin: 14px 0 8px; }
.big { font-size: 16.5px; }
.empty { color: var(--muted); }
.kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd .fref { display: inline-block; max-width: 100%; margin-right: 8px; }

/* glance */
.glance { border-color: var(--rule-strong); }
.glance-rows { display: grid; gap: 0; }
.glance-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-top: 1px solid var(--rule); }
.glance-row:first-child { border-top: 0; padding-top: 2px; }
.glance-row dt { font-size: 12.5px; font-weight: 650; color: var(--muted); padding-top: 2px; }
.glance-row dd { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.glance-row dd .trust { flex: none; margin-top: 2px; }

/* trust badges: border style and label carry meaning, not color alone */
.trust { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600; line-height: 18px; padding: 0 7px; border-radius: 4px; border: 1px solid var(--rule-strong); color: var(--ink-2); background: var(--bg); white-space: nowrap; }
.trust-source { border-style: solid; }
.trust-inferred { border-style: dashed; }
.trust-suggested { border-style: dotted; border-width: 2px; color: var(--accent); }
.trust-missing { border-style: double; border-width: 3px; line-height: 14px; }
.trust-translated { border-style: solid; border-left-width: 4px; }

/* chips */
.chip { display: inline-flex; align-items: center; font-size: 12.5px; line-height: 20px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--rule); background: var(--bg-subtle); color: var(--ink-2); white-space: nowrap; }
a.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip-warn { border-color: var(--amber-rule); color: var(--amber); background: var(--amber-soft); }
.chip-tag { font-size: 11.5px; line-height: 17px; padding: 0 6px; margin: 1px 2px 1px 0; }
.chip-miss { border-style: dashed; }

/* warnings */
.warning { border: 1px solid var(--rule); border-left: 3px solid var(--rule-strong); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; background: var(--bg-raised); }
.warning.sev-caution { border-left-color: var(--amber-rule); }
.warning.sev-blocker { border-left-color: var(--red-rule); }
.warning.active { box-shadow: inset 3px 0 0 var(--accent); }
.sev-icon { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid currentColor; display: inline-flex; align-items: center; justify-content: center; font: 700 11px/1 var(--sans); color: var(--muted); align-self: center; }
.sev-caution .sev-icon, .sev-caution .sev-label { color: var(--amber); }
.sev-blocker .sev-icon, .sev-blocker .sev-label { color: var(--red); }
.sev-label { font-weight: 650; color: var(--ink-2); }
.warning p + p, .warning p + .excerpt-inline { margin-top: 8px; }
.consequence { font-size: 14px; color: var(--ink-2); }
.warning-guide { font-size: 14px; }

/* ---------- code excerpts ---------- */
.excerpt-inline { margin-top: 12px; }
.excerpt-inline > summary { cursor: pointer; font-size: 13px; color: var(--ink-2); padding: 4px 0; min-height: 32px; }
.excerpt { border: 1px solid var(--rule); border-radius: 6px; background: var(--code-bg); overflow: hidden; margin-top: 6px; }
.ex-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--rule); font-size: 12px; color: var(--muted); }
.ex-path { font-family: var(--mono); color: var(--ink-2); overflow-wrap: anywhere; }
.ex-lines { font-family: var(--mono); }
.ex-ctx { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; margin-left: auto; }
.ex-copy { display: none; font: inherit; color: var(--ink-2); background: var(--bg); border: 1px solid var(--rule-strong); border-radius: 5px; padding: 2px 8px; cursor: pointer; min-height: 26px; }
.js .ex-copy { display: inline-block; margin-left: auto; }
.ex-ctx + .ex-copy { margin-left: 0; }
.excerpt pre { margin: 0; padding: 8px 0; overflow-x: auto; font-size: 12.5px; line-height: 1.6; }
.excerpt pre code { display: block; min-width: max-content; overflow-wrap: normal; font-size: inherit; }
.excerpt .l { display: block; padding-right: 14px; white-space: pre; }
.excerpt .l.ctx { display: none; opacity: 0.6; }
.excerpt:has([data-ctx]:checked) .l.ctx { display: block; }
.excerpt .l.hl { background: var(--hl); }
.excerpt .n { display: inline-block; width: 3.4em; padding-right: 1em; text-align: right; color: var(--muted); user-select: none; }
.ex-prov { font-size: 11.5px; color: var(--muted); padding: 6px 10px; border-top: 1px solid var(--rule); overflow-wrap: anywhere; }
.excerpt-suggested { border-style: dashed; border-color: var(--rule-strong); background: var(--bg); }
.excerpt-suggested .c { padding-left: 12px; }
.ex-mark { font-weight: 650; color: var(--accent); font-size: 12px; }
.excerpt-sql > pre .c { padding-left: 12px; }
.excerpt-sql .ex-mark { color: var(--ink-2); }
.ex-notes { font-size: 12px; color: var(--ink-2); padding: 6px 10px 6px 28px; border-top: 1px solid var(--rule); }
.ex-original { border-top: 1px solid var(--rule); padding: 0 10px 8px; }
.dialect-note { font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.ex-original > summary { cursor: pointer; font-size: 12.5px; color: var(--ink-2); padding: 6px 0; min-height: 32px; }
.t-key { color: var(--t-key); }
.t-el { color: var(--t-el); font-weight: 600; }
.t-name { color: var(--ink); font-weight: 600; }
.t-str { color: var(--t-str); }
.t-num, .t-bool { color: var(--t-num); }
.t-ref { color: var(--t-ref); }
.t-kw { color: var(--t-kw); }
.t-com { color: var(--t-com); font-style: italic; }
.t-punct { color: var(--muted); }

/* source rail */
.rail-head { font-size: 12px; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.rail-body .excerpt { margin-top: 0; }
.rail-body .excerpt pre { max-height: calc(100vh - var(--ctx-h) - 170px); overflow: auto; }
.rail-for { font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: 6px; }
table.fields { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 13px; }
.fields td:nth-child(2) code { overflow-wrap: normal; }
.fields th, .fields td { text-align: left; vertical-align: top; padding: 6px 10px; border-bottom: 1px solid var(--rule); }
.fields thead th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg-subtle); position: sticky; top: 0; }
.fields tbody tr:last-child > * { border-bottom: 0; }
.fields tbody th { font-weight: 500; white-space: nowrap; }
.fields tbody th code { font-size: 12.5px; }
.fields tr:target, .fields tr.flash { background: var(--hl); }
.fields td code { font-size: 12px; }
.ln-ref { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tf { display: block; font-size: 11.5px; color: var(--muted); white-space: normal; }
.filt { display: block; font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.used { display: block; font-size: 12.5px; }
.sql-more summary { cursor: pointer; list-style: none; }
.sql-more summary::-webkit-details-marker { display: none; }
.sql-more[open] summary { display: none; }
.field-group > summary { cursor: pointer; list-style: none; }
.field-group > summary::-webkit-details-marker { display: none; }
.field-group > summary h3::before { content: "+ "; color: var(--muted); font-family: var(--mono); }
.field-group[open] > summary h3::before { content: "- "; }
.field-group > summary h3 { display: inline-block; }
.view-head { overflow-wrap: anywhere; font-size: 15px; margin: 20px 0 4px; padding-top: 12px; border-top: 1px solid var(--rule); }
.dt-note { font-size: 13px; color: var(--ink-2); margin: 4px 0 8px; }
.missing-ref { text-decoration: line-through dotted; text-decoration-color: var(--muted); color: var(--ink-2); }
.join-item { display: block; margin-bottom: 2px; }
.wiring .none { color: var(--amber); }
.example caption { text-align: left; font-size: 13px; color: var(--ink-2); padding: 8px 10px; }

/* ---------- diagrams ---------- */
.diagram { margin: 4px 0 0; }
.diagram-title { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.diagram-scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: 6px; background: var(--bg-subtle); }
.diagram-scroll svg { display: block; width: 100%; min-width: calc(var(--vbw) * 0.9px); max-width: calc(var(--vbw) * 1px); height: auto; font-family: var(--sans); }
.diagram .n rect { fill: var(--bg); stroke: var(--rule-strong); stroke-width: 1.2; }
.diagram .n-explore rect { fill: var(--bg-subtle); }
.diagram .n-dashboard rect { stroke: var(--ink-2); }
.diagram .n-current rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.diagram .n-missing rect { fill: transparent; stroke-dasharray: 4 3; }
.diagram .n-missing .n-label { fill: var(--muted); }
.diagram a.n:hover rect, .diagram a.n:focus rect { stroke: var(--accent); stroke-width: 2; }
.diagram .n-label { font-family: var(--mono); font-size: 13.5px; fill: var(--ink); }
.diagram .n-sub { font-size: 13.5px; fill: var(--muted); }
.diagram .col-head, .diagram .lane-head { font-size: 13.5px; font-weight: 650; fill: var(--muted); }
.diagram .lane-head { font-family: var(--mono); font-size: 13.5px; fill: var(--ink-2); }
.diagram .lane-sub { font-size: 13.5px; fill: var(--muted); }
.diagram .e { fill: none; stroke: var(--ink-2); stroke-width: 1.3; }
.diagram .e-dashed { stroke-dasharray: 5 4; }
.diagram .e-reads { stroke: var(--muted); }
.diagram .e-arrow { fill: var(--ink-2); }
.diagram .e-label { font-size: 13.5px; fill: var(--ink-2); font-family: var(--mono); }
.diagram .e-label-bg { fill: var(--bg-subtle); }
.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 26px; height: 12px; }
.lg-join { border-top: 2px solid var(--ink-2); height: 0; }
.lg-dashed { border-top: 2px dashed var(--ink-2); height: 0; }
.lg-reads { border-top: 2px solid var(--muted); height: 0; }
.lg-missing { border: 1.5px dashed var(--rule-strong); border-radius: 3px; width: 20px; }
.lg-current { border: 2px solid var(--accent); background: var(--accent-soft); border-radius: 3px; width: 20px; }
.diagram-text { margin-top: 6px; font-size: 13px; }
.diagram-text summary { cursor: pointer; color: var(--ink-2); min-height: 32px; display: flex; align-items: center; }
.diagram-text ul { padding-left: 18px; color: var(--ink-2); font-family: var(--mono); font-size: 12px; }

/* ---------- dashboards ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--rule); border-radius: 6px; padding: 10px 12px; background: var(--bg); font-size: 13px; }
.tile:target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tile header { display: flex; gap: 8px; align-items: baseline; }
.tile h3 { font-size: 14px; font-weight: 600; line-height: 1.35; }
.tile-n { font-family: var(--mono); font-size: 11.5px; color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 0 4px; }
.tile-meta { margin: 6px 0; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.tile-dl { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 3px 8px; }
.tile-dl dt { color: var(--muted); font-size: 12px; }
.tile-dl dd code { font-size: 11.5px; }
.tile-dl .fref { display: inline-block; margin-right: 4px; }
.tile-foot { margin-top: 8px; font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.tile-foot .ln-ref { display: inline; }

/* ---------- cross links and grids ---------- */
.xlinks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 8px; }
.xlink { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; background: var(--bg-raised); color: var(--ink); min-height: 44px; }
.xlink:hover { border-color: var(--accent); text-decoration: none; }
.xlink-kind { font-size: 11.5px; font-weight: 650; color: var(--muted); }
.xlink-title { font-weight: 600; color: var(--accent); line-height: 1.35; overflow-wrap: anywhere; }
.xlink-sub { font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.xlink-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.block-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; }
.block-card { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); font-size: 13px; background: var(--bg-raised); }
div.block-card { border-style: dashed; color: var(--ink-2); }
a.block-card:hover { border-color: var(--accent); text-decoration: none; }
.bc-file code { font-size: 12.5px; font-weight: 600; }
.bc-meta, .bc-reason { color: var(--muted); }
.bc-title { color: var(--accent); font-weight: 600; font-size: 14px; }
.domain-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.domain { margin-bottom: 0; }
.check-list { padding-left: 0; list-style: none; font-size: 13px; }
.check-list > li { margin-top: 8px; }
.check-list ul { padding-left: 18px; color: var(--ink-2); }
.checks details > summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; font-size: 13.5px; color: var(--accent); }

/* patterns and guides */
/* ---------- guides: answer first, evidence after ---------- */
.article { max-width: 1180px; }
.dek { font-size: 17px; color: var(--ink-2); margin-top: 10px; max-width: 760px; }
.answer { border-left: 3px solid var(--accent); }
.answer p:first-child { font-size: 16px; }
.prov-box { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--bg-subtle); padding: 12px 14px; margin: 0 0 16px; font-size: 13.5px; }
.prov-box > * + * { margin-top: 8px; }
.prov-h { font-size: 12px; font-weight: 650; color: var(--muted); letter-spacing: 0.02em; }
.prov-repo a { font-weight: 600; }
.prov-files summary, .trust-key summary { cursor: pointer; color: var(--ink-2); min-height: 32px; display: flex; align-items: center; }
.prov-files ul { padding-left: 18px; }
.prov-note { color: var(--ink-2); font-size: 12.5px; }
.trust-key dl > div { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 4px 0; font-size: 12.5px; color: var(--ink-2); }
.prov-box .toc { display: none; }
@media (max-width: 1099px) {
  /* A compact strip under the dek: the essentials on one or two lines, the rest a tap away. */
  .prov-box { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 8px 12px; }
  .prov-box > * + * { margin-top: 0; }
  .prov-box .prov-h, .prov-box .prov-note, .prov-box .prov-more { display: none; }
  .prov-box .toc { display: block; flex-basis: 100%; min-width: 0; max-width: 100%; margin: 4px 0 0; padding: 8px 0 0; border-bottom: 0; border-top: 1px solid var(--rule); }
  .prov-files[open], .trust-key[open] { flex-basis: 100%; }
}
@media (min-width: 1100px) {
  .article { display: grid; grid-template-columns: minmax(0, 1fr) 290px; column-gap: 32px; align-items: start; }
  .article > * { grid-column: 1; }
  /* Spans every row so it can stay in view for the length of the article. */
  .article > .prov-box { grid-column: 2; grid-row: 1 / span 40; position: sticky; top: calc(var(--ctx-h) + 16px); max-height: calc(100vh - var(--ctx-h) - 32px); overflow-y: auto; margin-top: 24px; }
  .prov-box .toc { display: block; border-bottom: 0; border-top: 1px solid var(--rule); padding: 10px 0 0; margin: 4px 0 0; }
  .prov-box .toc ul { flex-direction: column; gap: 2px; }
  .prov-box .toc a { border: 0; padding: 2px 0; min-height: 28px; border-radius: 0; }
}
.metric-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.metric-def { font-size: 13px; }
.metric-expr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-top: 8px; }
.metric-expr code { font-size: 12.5px; background: var(--code-bg); border: 1px solid var(--rule); border-radius: 5px; padding: 3px 7px; overflow-wrap: anywhere; }
.metric-row.interp { border-style: dashed; }
.q-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .q-grid { grid-template-columns: 1fr 1fr; } }
.q-card { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; background: var(--bg-raised); color: var(--ink); }
.q-card:hover { border-color: var(--accent); text-decoration: none; }
.q-hook { font-size: 16.5px; font-weight: 650; line-height: 1.35; }
.q-title { font-size: 13px; color: var(--ink-2); }
.q-card .chips { margin-top: 2px; }
.card.suggested { border-style: dashed; background: var(--bg-subtle); }
.checklist { padding-left: 22px; }
.checklist li { padding: 4px 0; }
.consequence-card { border-left: 3px solid var(--amber-rule); }
.produces { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--rule-strong); }
.produces .sub-title { font-size: 14px; margin-bottom: 4px; }

/* ---------- home ---------- */
.home-hero { padding: 24px 0 8px; max-width: 860px; }
.audience { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.home-hero h1 { font-size: 32px; line-height: 1.2; letter-spacing: -0.015em; margin-top: 8px; font-weight: 700; }
.finder-field { display: flex; align-items: center; gap: 10px; margin-top: 20px; padding: 12px 14px; border: 1px solid var(--rule-strong); border-radius: 10px; color: var(--muted); max-width: 620px; min-height: 48px; }
.finder-field span { font-family: var(--mono); border: 1px solid var(--rule-strong); border-radius: 4px; padding: 0 6px; font-size: 12px; color: var(--ink-2); }
.finder-field:hover { border-color: var(--accent); text-decoration: none; }
.hero-points { margin-top: 14px; padding-left: 20px; color: var(--ink-2); }
.hero-points li { padding: 2px 0; }
.more { margin-top: 10px; font-size: 14px; }
.topic-cards { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .topic-cards { grid-template-columns: 1fr 1fr; } }
.topic-card { display: flex; flex-direction: column; gap: 6px; color: var(--ink); margin: 0; }
.topic-card:hover { border-color: var(--accent); text-decoration: none; }
.topic-title { font-size: 16.5px; font-weight: 650; }
.topic-lede { font-size: 14px; color: var(--ink-2); }
.topic-hooks { padding-left: 18px; font-size: 13.5px; color: var(--accent); }
.bp-list { list-style: none; padding: 0; border-top: 1px solid var(--rule); }
.bp-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.bp-list .muted { font-size: 13.5px; }
.topic-metrics { columns: 2 260px; padding-left: 18px; }
.topic-metrics li { padding: 3px 0; break-inside: avoid; }
.repo-cards { display: grid; gap: 12px; }
@media (min-width: 768px) { .repo-cards { grid-template-columns: 1fr 1fr; } }
.repo-card { display: flex; flex-direction: column; gap: 8px; color: var(--ink); }
.repo-card:hover { border-color: var(--accent); text-decoration: none; }
.repo-title { font-size: 18px; font-weight: 650; color: var(--accent); line-height: 1.3; }
.tool-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-top: 12px; }
.tool-list li { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 8px; border: 1px solid var(--rule); border-radius: 8px; font-size: 12px; color: var(--ink-2); text-align: center; }
.tool-list img { height: 26px; width: auto; max-width: 84px; object-fit: contain; filter: grayscale(1); opacity: 0.75; background: #fff; border-radius: 4px; padding: 2px 4px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.filter-chips .chip { min-height: 32px; font-size: 13px; }

/* ---------- finder ---------- */
.finder { position: fixed; inset: 0; z-index: 60; background: rgba(10, 12, 16, 0.45); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.finder[hidden] { display: none; }
.finder-panel { width: min(680px, 100%); background: var(--bg); border: 1px solid var(--rule-strong); border-radius: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); overflow: hidden; }
#finder-input { width: 100%; font: 16px var(--sans); padding: 14px 16px; border: 0; border-bottom: 1px solid var(--rule); background: var(--bg); color: var(--ink); outline: none; }
#finder-input:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
#finder-list { list-style: none; padding: 6px; margin: 0; max-height: 56vh; overflow-y: auto; }
#finder-list li { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 6px; cursor: pointer; min-height: 44px; }
#finder-list li[aria-selected="true"] { background: var(--accent-soft); }
#finder-list .fk { flex: none; width: 64px; font-size: 11.5px; font-weight: 650; color: var(--muted); }
#finder-list .ft { font-family: var(--mono); font-size: 13.5px; color: var(--ink); overflow-wrap: anywhere; }
#finder-list .fs { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; }
.finder-hint { font-size: 12px; color: var(--muted); padding: 8px 14px; border-top: 1px solid var(--rule); }
kbd { border: 1px solid var(--rule-strong); border-radius: 4px; padding: 0 4px; font-size: 11px; margin-right: 2px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--rule); margin-top: 32px; }
.footer-inner { max-width: 1480px; margin: 0 auto; padding: 20px 16px 32px; font-size: 13px; color: var(--muted); display: grid; gap: 8px; }
.footer-inner a { margin-right: 14px; display: inline-block; min-height: 32px; }

@media (pointer: coarse) {
  .toc a, .chip-link, .filter-chips .chip, .excerpt-inline > summary, .ex-original > summary, .diagram-text summary { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print {
  .site-header, .context-bar, .tree, .rail, .finder, .toc { display: none !important; }
  .excerpt .l.ctx { display: none; }
  .card, .warning { break-inside: avoid; }
}

/* ---------- phone tuning: keep the verdict in the first viewport ---------- */
@media (max-width: 767px) {
  .context-bar { position: static; }
  .ctx-path { display: none; }
  .context-inner { padding: 6px 16px; }
  .site-header { padding: 8px 16px; gap: 6px 12px; }
  .site-nav { flex-wrap: nowrap; overflow-x: auto; gap: 0; }
  .site-nav a { padding: 6px 6px; font-size: 14.5px; white-space: nowrap; min-height: 44px; }
  .finder-trigger .finder-text { font-size: 13px; }
  .page-head h1 { font-size: 21px; }
  .main { padding-top: 16px; }
  .toc ul { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .toc a { white-space: nowrap; }
  .glance-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .glance-row { position: relative; }
  .glance-row dd { display: block; }
  .glance-row dd .trust { position: absolute; top: 8px; right: 0; margin: 0; }
  .glance-row:first-child dd .trust { top: 0; }
}
.wiring .tl { display: inline-block; min-width: 2.4em; }
