/* =========================================================================
   addressable.wiki
   Hand-written, no framework. Tokens are documented in /design.md.

   Theming contract: the complete palette is defined on bare :root (light).
   Dark overrides only the tokens, twice — once under prefers-color-scheme for
   the default "system" state, once under [data-theme="dark"] so an explicit
   toggle wins in both directions. No colour is ever defined ONLY inside a
   media query.
   ========================================================================= */

:root {
  /* ── neutrals ─────────────────────────────────────────────────────── */
  --bg:            #fbfbfa;
  --bg-raised:     #ffffff;
  --bg-sunken:     #f4f4f2;
  --bg-hover:      #f0f0ee;
  --hairline:      #e4e4e0;
  --hairline-firm: #d2d2cc;

  --ink:           #16171a;
  --ink-soft:      #5b5f66;
  --ink-faint:     #6e747d;

  /* ── accent: drawn from an actual LED, used sparingly ─────────────── */
  --led-r:         #ff2d2d;
  --led-g:         #24d05a;
  --led-b:         #3d7bff;
  --accent:        #0f62d6;
  --accent-soft:   color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-ink:    #ffffff;

  /* white-channel tints, so an RGBW chip shows its actual temperature */
  --w-warm:        #ffc98a;
  --w-neutral:     #fff3df;
  --w-cool:        #dcecff;

  /* ── LED package plastic (the header strip) ───────────────────────── */
  --led-body:      #eceae5;
  --led-edge:      #c9c6c0;
  --led-pad:       #b0b4ba;
  --led-lens:      #b3b7ba;
  --led-lens-edge: #93989c;

  /* ── semantic ─────────────────────────────────────────────────────── */
  --ok:            #15803d;
  --warn:          #b45309;
  --danger:        #b91c1c;
  --muted-fill:    color-mix(in srgb, var(--ink) 8%, transparent);

  /* ── type ─────────────────────────────────────────────────────────── */
  --sans: "Inter var", "Inter", ui-sans-serif, system-ui, -apple-system,
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular,
          "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --t-xs:   11px;
  --t-sm:   12px;
  --t-base: 13.5px;
  --t-md:   15px;
  --t-lg:   19px;
  --t-xl:   26px;
  --t-2xl:  34px;

  /* ── space (4px base) ─────────────────────────────────────────────── */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  /* ── radii & elevation ────────────────────────────────────────────── */
  --r-sm: 3px; --r-md: 5px; --r-lg: 8px; --r-full: 999px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 12px rgb(0 0 0 / .05);

  /* ── table metrics ────────────────────────────────────────────────── */
  --row-h: 34px;
  --row-pad-y: 5px;

  color-scheme: light;
}

/* Dark by default when the reader has expressed no preference. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0c0d10;
    --bg-raised:     #131519;
    --bg-sunken:     #090a0c;
    --bg-hover:      #1a1d23;
    --hairline:      #24272e;
    --hairline-firm: #333741;

    --ink:           #eceef2;
    --ink-soft:      #9aa1ad;
    --ink-faint:     #7b828f;

    --led-r:         #ff4d4d;
    --led-g:         #35e26c;
    --led-b:         #5b90ff;
    --accent:        #5b90ff;
    --accent-soft:   color-mix(in srgb, var(--accent) 16%, transparent);
    --accent-ink:    #08090b;

    --w-warm:        #ffb45c;
    --w-neutral:     #ffeccd;
    --w-cool:        #bcd9ff;

  --led-body:      #cfccc6;
  --led-edge:      #a5a29c;
  --led-pad:       #8b9096;
  --led-lens:      #8d9296;
  --led-lens-edge: #6e7378;

    --led-body:      #cfccc6;
    --led-edge:      #a5a29c;
    --led-pad:       #8b9096;
    --led-lens:      #8d9296;
    --led-lens-edge: #6e7378;

    --ok:            #4ade80;
    --warn:          #fbbf24;
    --danger:        #f87171;
    --muted-fill:    color-mix(in srgb, var(--ink) 10%, transparent);

    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

/* An explicit choice wins over the system preference, both ways. */
:root[data-theme="dark"] {
  --bg:            #0c0d10;
  --bg-raised:     #131519;
  --bg-sunken:     #090a0c;
  --bg-hover:      #1a1d23;
  --hairline:      #24272e;
  --hairline-firm: #333741;
  --ink:           #eceef2;
  --ink-soft:      #9aa1ad;
  --ink-faint:     #7b828f;
  --led-r:         #ff4d4d;
  --led-g:         #35e26c;
  --led-b:         #5b90ff;
  --accent:        #5b90ff;
  --accent-soft:   color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-ink:    #08090b;
  --w-warm:        #ffb45c;
  --w-neutral:     #ffeccd;
  --w-cool:        #bcd9ff;
  --ok:            #4ade80;
  --warn:          #fbbf24;
  --danger:        #f87171;
  --muted-fill:    color-mix(in srgb, var(--ink) 10%, transparent);
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .3);
  color-scheme: dark;
}

/* ── reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Any author-level `display` beats the UA stylesheet's [hidden] rule, so an
   element given `display: flex` here would ignore el.hidden entirely. The JS
   toggles `hidden` on the chip bar, the filter-count badge and every row, so
   this has to win. */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--t-base)/1.5 var(--sans);
  font-feature-settings: "cv05" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 590; letter-spacing: -0.015em; line-height: 1.2; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

.mono { font-family: var(--mono); font-size: 0.94em; font-variant-ligatures: none; }
/* Tabular figures everywhere a number sits in a column. */
.num, .num *, td.mono, th.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-faint); }

.skip {
  position: absolute; left: -9999px; top: var(--s-2);
  background: var(--accent); color: var(--accent-ink);
  padding: var(--s-2) var(--s-4); border-radius: var(--r-md); z-index: 100;
}
.skip:focus { left: var(--s-4); }

/* ── header ────────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
}
.wordmark {
  /* No gap: "addressable" and ".wiki" are one word, split only by colour.
     The 8px gap here was left over from the status dot that used to sit
     between them. */
  display: inline-flex; align-items: baseline;
  color: var(--ink); font-weight: 600; letter-spacing: -0.02em;
}
.wordmark:hover { text-decoration: none; }
.wordmark-tld { color: var(--ink-faint); font-weight: 450; }
/* The header LED strip, drawn as real 5050 packages.
   An unlit NeoPixel is not a black dot: it is a light plastic square with four
   grey solder pads and a slightly darker grey circular lens. Modelling that
   means the strip reads as a row of components when idle and as LEDs when lit,
   which is the whole joke. */
.pixels {
  display: flex; gap: 4px; align-items: center;
  padding: 5px 7px;
  background: var(--bg-sunken);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  cursor: crosshair;
}
.pixels .led {
  position: relative; flex: none;
  width: 15px; height: 15px;
  border-radius: 2px;
  background-color: var(--led-body);
  /* Four corner solder pads, painted rather than added as elements. */
  background-image:
    linear-gradient(var(--led-pad), var(--led-pad)),
    linear-gradient(var(--led-pad), var(--led-pad)),
    linear-gradient(var(--led-pad), var(--led-pad)),
    linear-gradient(var(--led-pad), var(--led-pad));
  background-size: 5px 3.5px;
  background-position: left top, right top, left bottom, right bottom;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px var(--led-edge);
}
.pixels .led-lens {
  position: absolute;
  /* Explicit box rather than `inset`, so no stray margin from another rule can
     turn the lens into an oval — which is exactly what `.lens` in the table did. */
  top: 2.5px; left: 2.5px;
  width: 10px; height: 10px;
  margin: 0;
  border-radius: 50%;
  /* --lit is the eased brightness (see paint() in pixels.js); --glow is the
     raw one. Splitting them lets the lens colour saturate fast while the bloom
     still scales with actual output. */
  background:
    radial-gradient(circle at 38% 32%,
      color-mix(in srgb, #fff calc(var(--lit, 0) * 45%), transparent) 0%,
      transparent 55%),
    color-mix(in srgb,
      var(--c, #000) calc(var(--lit, 0) * 100%),
      var(--led-lens));
  box-shadow:
    inset 0 0 0 .5px var(--led-lens-edge),
    /* tight core */
    0 0 calc(5px * var(--glow, 0)) var(--c, transparent),
    /* wide bloom, the bit that makes it look like it is emitting */
    0 0 calc(14px * var(--glow, 0)) calc(3px * var(--glow, 0)) var(--c, transparent);
  transition: background 40ms linear;
}
@media (prefers-reduced-motion: reduce) { .pixels .led-lens { transition: none; } }
@media (max-width: 860px) { .pixels { display: none; } }
.site-nav { display: flex; align-items: center; gap: var(--s-4); }
.site-nav a { color: var(--ink-soft); font-size: var(--t-sm); }
.site-nav a:hover { color: var(--ink); }
.theme-toggle {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: var(--r-md);
  color: var(--ink-soft);
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--ink); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun,
:root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon,
:root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: none; }
}

/* ── intro ─────────────────────────────────────────────────────────── */
main { max-width: 1440px; margin: 0 auto; padding: 0 var(--s-5); }
/* Two columns: the prose reads at a comfortable measure on the left, the
   trade-name map sits beside it rather than pushing the table down. Collapses
   to one column when there isn't room for both. */
.intro {
  padding: var(--s-7) 0 var(--s-6);
  display: grid; gap: var(--s-7);
  grid-template-columns: minmax(0, 60ch) minmax(300px, 1fr);
  align-items: start;
}
.intro-copy { max-width: 60ch; }
.intro-copy .lede + .lede { margin-top: var(--s-3); }
.intro h1 { font-size: var(--t-2xl); margin-bottom: var(--s-3); }
.lede { color: var(--ink-soft); font-size: var(--t-md); line-height: 1.6; }
.lede strong { color: var(--ink); font-weight: 550; }

.trade-names {
  display: grid; gap: var(--s-2);
  margin-top: 6px; /* optically aligns with the h1's cap height */
}
.trade-names li {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
}
.tn-name { color: var(--ink-soft); }
.tn-arrow { color: var(--ink-faint); flex: none; }
.tn-part { font-weight: 600; }
.tn-note { color: var(--ink-faint); font-size: var(--t-xs); margin-left: auto; }

/* ── toolbar ───────────────────────────────────────────────────────── */
.toolbar {
  position: sticky; top: 53px; z-index: 30;
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.search-wrap { position: relative; flex: 1 1 260px; max-width: 420px; }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); pointer-events: none;
}
.search {
  width: 100%; padding: 7px 10px 7px 30px;
  background: var(--bg-raised); color: var(--ink);
  border: 1px solid var(--hairline-firm); border-radius: var(--r-md);
  font: var(--t-base) var(--sans);
}
.search::placeholder { color: var(--ink-faint); }
.search:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.toolbar-right { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; }

.seg { display: inline-flex; background: var(--bg-sunken); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 2px; }
.seg button {
  padding: 4px 10px; font-size: var(--t-sm); color: var(--ink-soft);
  border-radius: 3px; white-space: nowrap;
}
.seg button.is-on { background: var(--bg-raised); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

.btn {
  padding: 6px 11px; font-size: var(--t-sm); color: var(--ink-soft);
  background: var(--bg-raised);
  border: 1px solid var(--hairline-firm); border-radius: var(--r-md);
}
.btn:hover { color: var(--ink); background: var(--bg-hover); }
.btn[aria-pressed="true"] { color: var(--ink); border-color: var(--hairline-firm); }
.btn-quiet { color: var(--accent); font-size: var(--t-sm); text-decoration: underline; text-underline-offset: 2px; }
.filters-open { display: none; }
.filter-count {
  display: inline-grid; place-items: center; min-width: 17px; height: 17px;
  margin-left: 4px; padding: 0 4px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: var(--r-full); font-size: 10px; font-weight: 600;
}

/* ── layout ────────────────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: var(--s-6); padding: var(--s-5) 0 var(--s-8); }

/* ── facets ────────────────────────────────────────────────────────── */
.facets { position: sticky; top: 108px; align-self: start; max-height: calc(100vh - 130px); overflow-y: auto; padding-right: var(--s-2); }
.facets-head { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); }
.facets-head h2 { font-size: var(--t-sm); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); }
.facets-head .btn-quiet { margin-left: auto; }
.facets-close { display: none; }

.facet { border-bottom: 1px solid var(--hairline); }
.facet summary {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) 0; cursor: pointer;
  font-size: var(--t-sm); font-weight: 550; color: var(--ink-soft);
  list-style: none;
}
.facet summary::-webkit-details-marker { display: none; }
.facet summary::before {
  content: ""; width: 5px; height: 5px; flex: none;
  border-right: 1.4px solid currentColor; border-bottom: 1.4px solid currentColor;
  transform: rotate(-45deg); transition: transform .12s ease;
  opacity: .6;
}
.facet[open] summary::before { transform: rotate(45deg); }
.facet summary:hover { color: var(--ink); }
.facet-active {
  margin-left: auto; padding: 1px 6px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: var(--r-full); font-size: 10px; font-weight: 600;
}
.facet ul { padding-bottom: var(--s-3); display: grid; gap: 1px; }
.facet label {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 3px 4px; border-radius: var(--r-sm);
  font-size: var(--t-sm); color: var(--ink-soft); cursor: pointer;
}
.facet label:hover { background: var(--bg-hover); color: var(--ink); }
.facet label.is-empty { opacity: .38; cursor: default; }
.facet input { accent-color: var(--accent); margin: 0; }
.opt-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt-count { margin-left: auto; font-size: var(--t-xs); color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* ── chips ─────────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-3); }
.chip-active {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 9px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--r-full); font-size: var(--t-xs);
}
.chip-active button { display: grid; place-items: center; width: 14px; height: 14px; border-radius: var(--r-full); opacity: .7; }
.chip-active button:hover { opacity: 1; background: color-mix(in srgb, var(--accent) 20%, transparent); }

.result-count { font-size: var(--t-sm); color: var(--ink-faint); margin-bottom: var(--s-3); }
.empty { padding: var(--s-7) var(--s-4); text-align: center; color: var(--ink-soft); font-size: var(--t-md); }
.downloads { margin-top: var(--s-5); font-size: var(--t-sm); color: var(--ink-faint); }
/* WCAG 1.4.1: a link inside a block of text must not be distinguished by
   colour alone. Accent-on-muted tops out around 1.2:1, so underline it. */
.downloads a, .site-footer li a, .site-footer p a, .caveat a,
.prose a, .block-note a, .term p a, .lib-note a { text-decoration: underline; text-underline-offset: 2px; }

/* ── the table ─────────────────────────────────────────────────────── */
/* `overflow` makes this the nearest scrollport, so a sticky thead inside it
   anchors to THIS box, not the viewport. Giving it a viewport-tied max-height
   makes it the vertical scroller too, which is what makes `top: 0` on the
   header actually stick while the rows scroll under it. */
.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 190px);
  overscroll-behavior: contain;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--bg-raised);
}
/* Detail tables are short and shouldn't get their own scrollport. */
.detail .table-scroll { max-height: none; overflow: visible; overflow-x: auto; }
table.cat { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t-sm); }

table.cat thead th {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-raised);
  padding: var(--s-2) var(--s-3);
  text-align: left; font-size: var(--t-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint);
  white-space: nowrap;
  border-bottom: 1px solid var(--hairline-firm);
}
table.cat thead th button { display: inline-flex; align-items: center; gap: 4px; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; }
table.cat thead th button:hover { color: var(--ink); }
.sort-ind { width: 8px; height: 8px; opacity: 0; transition: opacity .12s; }
th[aria-sort="ascending"] .sort-ind,
th[aria-sort="descending"] .sort-ind { opacity: 1; }
th[aria-sort] .sort-ind::after { content: ""; display: block; width: 0; height: 0; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; }
th[aria-sort="ascending"] .sort-ind::after { border-bottom: 5px solid currentColor; }
th[aria-sort="descending"] .sort-ind::after { border-top: 5px solid currentColor; }
th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--ink); }

table.cat td { padding: var(--row-pad-y) var(--s-3); border-bottom: 1px solid var(--hairline); vertical-align: middle; }
table.cat tbody tr.row:hover td { background: var(--bg-hover); }
table.cat tbody tr.row:last-child td { border-bottom: 0; }
table.cat tbody tr:target td { background: var(--accent-soft); }

/* Density */
[data-density="comfortable"] table.cat td { padding-top: 9px; padding-bottom: 9px; }

/* Column visibility. Every column is in the DOM; this is the only thing that
   changes when the reader switches column sets. */
table.cat .adv { display: none; }
table.cat.show-adv .adv { display: table-cell; }

.c-part { min-width: 190px; }
.glyph-wrap { display: inline-flex; vertical-align: middle; color: var(--ink-faint); margin-right: var(--s-2); }
.part-names { display: inline-flex; flex-direction: column; vertical-align: middle; line-height: 1.3; }
.order-code { font-weight: 600; }
.part-number { color: var(--ink-faint); font-size: var(--t-xs); }
.new-marker {
  margin-left: var(--s-2); padding: 1px 5px;
  background: color-mix(in srgb, var(--led-g) 18%, transparent);
  color: var(--ok); border-radius: var(--r-full);
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.c-aliases {
  max-width: 190px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.alias { display: inline-block; margin-right: 5px; color: var(--ink-soft); font-size: var(--t-xs); }
/* The separator is a real character in the markup (see cells.njk), not
   generated content — CSS ::after is not reliably exposed to screen readers or
   to text extraction, and the aliases ran together. */
.alias-sep { color: var(--ink-faint); }
.fam { display: block; color: var(--ink-faint); font-size: var(--t-xs); }

/* chips & badges */
.chip { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.swatch-rgb { display: inline-flex; gap: 1.5px; }
.swatch-rgb i { width: 4px; height: 11px; border-radius: 1px; }
.swatch-rgb i:nth-child(1) { background: var(--led-r); }
.swatch-rgb i:nth-child(2) { background: var(--led-g); }
.swatch-rgb i:nth-child(3) { background: var(--led-b); }
.swatch-w { width: 4px; height: 11px; border-radius: 1px; background: var(--w-neutral); }
.chip-ch[data-white="warm"] .swatch-w { background: var(--w-warm); }
.chip-ch[data-white="cool"] .swatch-w { background: var(--w-cool); }
.chip-k { color: var(--ink-faint); font-family: var(--mono); font-size: var(--t-xs); }

/* Library support. The first version rendered all three names with the level
   only in a data attribute and no CSS at all, so every row read as if FastLED,
   WLED and Adafruit all supported it. The level has to be visible. */
.c-libraries { white-space: nowrap; }
.lib-chip {
  display: inline-flex; align-items: center; gap: 3px;
  margin-right: 6px; font-size: var(--t-xs);
}
.lib-dot {
  width: 6px; height: 6px; border-radius: var(--r-full);
  border: 1px solid currentColor; flex: none;
}
.lib-chip[data-level="native"]    { color: var(--ok); }
.lib-chip[data-level="native"] .lib-dot { background: currentColor; }
.lib-chip[data-level="via-alias"] { color: var(--warn); }
.lib-chip[data-level="via-alias"] .lib-dot { background: color-mix(in srgb, currentColor 45%, transparent); }
.lib-chip[data-level="generic"]   { color: var(--ink-soft); }
/* Not supported: struck through and faded, so it cannot be mistaken for a yes. */
.lib-chip[data-level="none"]      { color: var(--ink-faint); opacity: .55; }
.lib-chip[data-level="none"] .lib-name { text-decoration: line-through; }
.lib-chip[data-level="none"] .lib-dot  { border-style: dashed; }
.lib-chip[data-level="unknown"]   { color: var(--ink-faint); opacity: .7; }
.lib-chip[data-level="unknown"] .lib-dot { border-style: dotted; }

.badge-wires {
  display: inline-block; padding: 1px 6px; border-radius: var(--r-sm);
  font-size: var(--t-xs); font-weight: 550;
  border: 1px solid var(--hairline-firm); color: var(--ink-soft);
}
.badge-wires[data-wires="spi"] { border-color: color-mix(in srgb, var(--led-b) 45%, transparent); color: var(--led-b); }

.face-swatch {
  display: inline-block; width: 11px; height: 11px; border-radius: 2px;
  vertical-align: -1px; border: 1px solid var(--hairline-firm);
}
.face-swatch[data-face="white"] { background: #f7f7f5; }
.face-swatch[data-face="black"] { background: #1b1b1e; }
.face-swatch[data-face="other"] { background: linear-gradient(135deg, #d8d8d4 50%, #9a9a95 50%); }
.lens { color: var(--ink-soft); font-size: var(--t-xs); margin-left: 4px; }

.pill {
  display: inline-block; padding: 1px 7px; border-radius: var(--r-full);
  font-size: var(--t-xs); font-weight: 550; background: var(--muted-fill); color: var(--ink-soft);
}
.pill[data-status="active"] { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill[data-status="nrnd"], .pill[data-status="obsolete"] { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }

/* Confidence dot next to a date: the catalogue never shows a date without
   showing how much to trust it. */
.ic-date { color: var(--ink-faint); white-space: nowrap; }
.ic-tag {
  padding: 0 4px; margin-right: 3px;
  background: var(--muted-fill); border-radius: var(--r-sm);
  font-size: 9px; text-transform: uppercase; letter-spacing: .04em;
}
.conf { display: inline-block; width: 5px; height: 5px; border-radius: var(--r-full); margin-left: 5px; vertical-align: 1px; }
.conf[data-conf="high"]   { background: var(--ok); }
.conf[data-conf="medium"] { background: var(--warn); opacity: .8; }
.conf[data-conf="low"]    { background: var(--ink-faint); opacity: .55; }
.ext { font-size: 9px; opacity: .6; }

/* Group rows */
tr.group th {
  position: sticky; left: 0; z-index: 6;
  padding: 0; background: var(--bg-sunken);
  border-bottom: 1px solid var(--hairline);
  border-top: 1px solid var(--hairline);
}
.group-inner {
  display: flex; align-items: center; gap: var(--s-2);
  width: 100%; padding: 3px var(--s-3);
  font-size: var(--t-xs); color: var(--ink-soft);
}
.group-inner:hover { background: var(--bg-hover); }
/* 26px square: below Lighthouse's 24px minimum a caret is a coin-flip to hit. */
.group-toggle {
  display: grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: var(--r-sm);
  color: var(--ink-soft);
}
.group-toggle:hover { background: var(--muted-fill); color: var(--ink); }
.caret { transition: transform .12s ease; opacity: .55; flex: none; }
.group-toggle[aria-expanded="true"] .caret { transform: rotate(90deg); }
.group-name { font-weight: 600; color: var(--ink); padding: 5px 2px; }
.group-meta { color: var(--ink-faint); }
.group-count {
  margin-left: auto; padding: 0 6px;
  background: var(--muted-fill); border-radius: var(--r-full);
  font-size: 10px; font-variant-numeric: tabular-nums;
}
tr.row[hidden], tr.group[hidden] { display: none; }

/* ── glossary ──────────────────────────────────────────────────────── */
.glossary { padding: var(--s-8) 0; border-top: 1px solid var(--hairline); }
.glossary h2 { font-size: var(--t-xl); margin-bottom: var(--s-5); }
.glossary-grid { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); }
.term h3 { font-size: var(--t-base); margin-bottom: var(--s-1); }
.term p { color: var(--ink-soft); font-size: var(--t-sm); line-height: 1.55; }
.term-link { display: inline-block; margin-top: var(--s-2); font-size: var(--t-xs); }

/* ── detail pages ──────────────────────────────────────────────────── */
.detail { max-width: 960px; margin: 0 auto; padding: var(--s-5) 0 var(--s-8); }
.crumbs { font-size: var(--t-sm); color: var(--ink-faint); margin-bottom: var(--s-5); display: flex; gap: var(--s-2); }
.hero { display: flex; align-items: center; gap: var(--s-5); margin-bottom: var(--s-5); }
.hero-glyph { flex: none; color: var(--ink-faint); padding: var(--s-3); background: var(--bg-raised); border: 1px solid var(--hairline); border-radius: var(--r-lg); }
.hero h1 { font-size: var(--t-2xl); }
.hero-sub { color: var(--ink-soft); font-size: var(--t-sm); margin-top: var(--s-1); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hero-aliases { margin-top: var(--s-2); font-size: var(--t-xs); color: var(--ink-faint); }

.stats {
  display: grid; gap: 1px; margin: var(--s-5) 0;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  background: var(--hairline); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); overflow: hidden;
}
.stats > div { background: var(--bg-raised); padding: var(--s-3); }
.stats dt { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.stats dd { margin: 3px 0 0; font-size: var(--t-md); font-variant-numeric: tabular-nums; }

.prose { color: var(--ink-soft); line-height: 1.65; max-width: 68ch; }
.prose p + p { margin-top: var(--s-3); }
.block { margin-top: var(--s-7); }
.block h2 { font-size: var(--t-lg); margin-bottom: var(--s-2); }
.block h3 { font-size: var(--t-base); margin: var(--s-5) 0 var(--s-2); }
.block-note { color: var(--ink-soft); font-size: var(--t-sm); margin-bottom: var(--s-3); max-width: 70ch; line-height: 1.55; }

.callout {
  margin-top: var(--s-5); padding: var(--s-3) var(--s-4);
  background: var(--bg-raised);
  border: 1px solid var(--hairline); border-left: 3px solid var(--warn);
  border-radius: var(--r-md);
}
.callout h3 { margin: 0 0 var(--s-1); font-size: var(--t-sm); }
.callout p { color: var(--ink-soft); font-size: var(--t-sm); }

table.detail-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t-sm); }
table.detail-table th {
  padding: var(--s-2) var(--s-3); text-align: left;
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); border-bottom: 1px solid var(--hairline-firm); white-space: nowrap;
}
table.detail-table td { padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--hairline); }
table.detail-table tr:target td { background: var(--accent-soft); }
tr.variant-note td, tr.timing-note td { padding-top: 0; color: var(--ink-faint); font-size: var(--t-xs); border-bottom: 1px solid var(--hairline); }
tr.is-preferred td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.src-tag { padding: 1px 6px; border-radius: var(--r-sm); font-size: var(--t-xs); font-weight: 550; background: var(--muted-fill); }
.src-tag[data-src="datasheet"] { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.src-tag[data-src="fastled"] { background: color-mix(in srgb, var(--led-b) 16%, transparent); color: var(--led-b); }

/* Cap the column: a single pinout stretched to the full 960px article width
   scales a 260-unit viewBox by ~3.7x, leaving the package marooned in dead
   space. Two side by side is also exactly the comparison you want when a part
   has more than one pinout. */
/* ── contribute form ── */
.form { margin-top: var(--s-5); display: grid; gap: var(--s-4); max-width: 620px; }
.hidden-field { position: absolute; left: -9999px; }
.field { display: grid; gap: 5px; }
.field label { font-size: var(--t-sm); font-weight: 550; }
.field .opt { font-weight: 400; color: var(--ink-faint); }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px;
  background: var(--bg-raised); color: var(--ink);
  border: 1px solid var(--hairline-firm); border-radius: var(--r-md);
  font: var(--t-base) var(--sans);
}
.field textarea { resize: vertical; min-height: 96px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .hint { font-size: var(--t-xs); color: var(--ink-faint); line-height: 1.5; }
.form-actions { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.btn-primary {
  padding: 9px 20px; border-radius: var(--r-md);
  background: var(--accent); color: var(--accent-ink);
  font-size: var(--t-base); font-weight: 550;
}
.btn-primary:hover { filter: brightness(1.08); }
.form-actions .hint { font-size: var(--t-sm); color: var(--ink-faint); margin: 0; }

.gallery { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.shot { margin: 0; background: var(--bg-raised); border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden; }
.shot img { display: block; width: 100%; height: auto; background: var(--bg-sunken); }
.shot figcaption { padding: var(--s-2) var(--s-3); font-size: var(--t-xs); color: var(--ink-faint); display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: baseline; }
.shot-kind { padding: 1px 6px; background: var(--muted-fill); border-radius: var(--r-sm); color: var(--ink-soft); }
/* Credit is required by the schema, so it always has somewhere to sit. */
.shot-credit { margin-left: auto; }

.pinout-grid { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(280px, 420px)); }
.pinout { margin: 0; padding: var(--s-4); background: var(--bg-raised); border: 1px solid var(--hairline); border-radius: var(--r-lg); }
.pinout figcaption { margin-bottom: var(--s-3); font-size: var(--t-xs); color: var(--ink-faint); display: flex; gap: 6px; flex-wrap: wrap; }
/* Several order codes share one pinout; separate them so they don't read as
   one long part number. */
.pinout figcaption span:not(:last-child)::after { content: ","; }
.sheet-links { display: inline-flex; gap: var(--s-2); }
.pinout-svg { color: var(--ink); display: block; max-width: 340px; margin: 0 auto; }
.pinout-svg text { font-family: var(--mono); font-size: 9px; fill: currentColor; }
.pinout-svg .pinout-caption { font-family: var(--sans); font-size: 8px; }
.pin-list { margin-top: var(--s-3); display: grid; gap: 2px; font-size: var(--t-xs); max-width: 340px; margin-inline: auto; }
.pin-list li { display: flex; gap: var(--s-2); color: var(--ink-soft); }
.pin-n { color: var(--ink-faint); width: 1.2em; }
.pin-name { color: var(--ink); }
.pin-fn { color: var(--ink-faint); margin-left: auto; }

.waveform { margin: 0 0 var(--s-4); padding: var(--s-4); background: var(--bg-raised); border: 1px solid var(--hairline); border-radius: var(--r-lg); color: var(--ink); }
.waveform text { font-family: var(--mono); fill: currentColor; }
.wave-axis, .wave-tick { font-size: 8px; }
.wave-span { font-size: 8px; opacity: .75; }
.wave-bit { font-size: 9px; opacity: .6; font-family: var(--sans); }
.wave-line { color: var(--led-g); }
.waveform figcaption { margin-top: var(--s-2); font-family: var(--mono); font-size: var(--t-xs); color: var(--ink-faint); }
.waveform .src { color: var(--ink-faint); opacity: .8; }

.compat { display: grid; gap: var(--s-3); }
.compat-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 4px 10px; border-radius: var(--r-full);
  border: 1px solid var(--hairline-firm); color: var(--ink); font-size: var(--t-sm);
}
.compat-chip:hover { text-decoration: none; background: var(--bg-hover); }
.compat-chip .rel { font-size: var(--t-xs); color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; }
.compat-chip[data-rel="drop-in"] { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.compat-chip[data-rel="drop-in"] .rel { color: var(--ok); }
.compat-chip[data-rel="near-clone"] { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.compat-chip[data-rel="near-clone"] .rel { color: var(--warn); }
.compat-chip.is-inbound { border-style: dashed; }
.caveat { margin-top: var(--s-2); padding-left: var(--s-3); border-left: 2px solid var(--hairline-firm); color: var(--ink-soft); font-size: var(--t-sm); line-height: 1.55; max-width: 70ch; }

.evidence { display: grid; gap: var(--s-2); }
.evidence li { display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; font-size: var(--t-sm); }
.ev-date { color: var(--ink); font-variant-numeric: tabular-nums; }
.ev-kind { padding: 1px 6px; border-radius: var(--r-sm); background: var(--muted-fill); color: var(--ink-soft); font-size: var(--t-xs); }
.ev-kind[data-kind="datasheet_revision"] { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.ev-source { color: var(--ink-soft); }
.ev-prec { margin-left: auto; color: var(--ink-faint); font-size: var(--t-xs); }

.libs { display: grid; gap: var(--s-2); }
.libs > div { display: flex; gap: var(--s-3); font-size: var(--t-sm); }
.libs dt { min-width: 150px; color: var(--ink-faint); }
.libs dd { margin: 0; }
.libs code { padding: 1px 5px; background: var(--bg-sunken); border: 1px solid var(--hairline); border-radius: var(--r-sm); }
.lib-note { margin-top: var(--s-3); color: var(--ink-soft); font-size: var(--t-sm); max-width: 70ch; }

.part-links { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.part-links a { padding: 4px 10px; background: var(--bg-raised); border: 1px solid var(--hairline); border-radius: var(--r-md); font-size: var(--t-sm); }
.part-links a:hover { text-decoration: none; background: var(--bg-hover); }

.suppliers { display: grid; gap: var(--s-2); font-size: var(--t-sm); }
.suppliers li { display: flex; gap: var(--s-3); align-items: baseline; }
.sup-name { min-width: 90px; color: var(--ink-soft); }
.sup-checked { margin-left: auto; color: var(--ink-faint); font-size: var(--t-xs); }

/* ── footer ────────────────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--hairline); margin-top: var(--s-8); padding: var(--s-7) var(--s-5) var(--s-8); background: var(--bg-sunken); }
.footer-cols { max-width: 1440px; margin: 0 auto; display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.site-footer h2 { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); margin-bottom: var(--s-2); }
.site-footer p, .site-footer li { color: var(--ink-soft); font-size: var(--t-sm); line-height: 1.55; }
/* Footer links sat 15px tall and 3px apart — under the 24px tap-target
   minimum. Padding the links and spacing the rows fixes both at once. */
.site-footer li + li { margin-top: var(--s-2); }
.site-footer li a, .site-footer p a { display: inline-block; padding: 4px 0; }
.colophon { max-width: 1440px; margin: var(--s-5) auto 0; padding-top: var(--s-4); border-top: 1px solid var(--hairline); color: var(--ink-faint); font-size: var(--t-xs); }

/* ── responsive ────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .intro { grid-template-columns: 1fr; gap: var(--s-5); }
  .layout { grid-template-columns: 1fr; }
  .filters-open { display: inline-block; }
  .facets {
    position: fixed; inset: auto 0 0 0; z-index: 60; max-height: 78vh;
    padding: var(--s-4) var(--s-5) var(--s-7);
    background: var(--bg-raised);
    border-top: 1px solid var(--hairline-firm);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: var(--shadow);
    transform: translateY(101%); transition: transform .18s ease;
  }
  .facets.is-open { transform: none; }
  .facets-close { display: grid; place-items: center; width: 26px; height: 26px; border-radius: var(--r-md); color: var(--ink-soft); }
  .facets-head h2 { font-size: var(--t-md); text-transform: none; letter-spacing: 0; color: var(--ink); }
}

@media (max-width: 720px) {
  main { padding: 0 var(--s-4); }
  .intro { padding: var(--s-5) 0 var(--s-4); }
  .intro h1 { font-size: var(--t-xl); }
  .toolbar { top: 53px; }
  .table-scroll { max-height: calc(100vh - 150px); }
  /* Sticky first column so the part number stays visible while scrolling
     the wide spec columns sideways. */
  table.cat td.c-part, table.cat thead th[data-col="part"] {
    position: sticky; left: 0; z-index: 5;
    background: var(--bg-raised);
    box-shadow: 1px 0 0 var(--hairline);
  }
  table.cat tbody tr.row:hover td.c-part { background: var(--bg-hover); }
  .hero { flex-direction: column; align-items: flex-start; gap: var(--s-3); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
