:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --wash: rgba(42, 120, 214, 0.10);
  --series-price: #2a78d6;
  --series-list: #eb6834;
  --series-units: #1baf7a;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 8px 24px rgba(11, 11, 11, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --raised: #222221;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --wash: rgba(57, 135, 229, 0.14);
    --series-price: #3987e5;
    --series-list: #d95926;
    --series-units: #199e70;
    --good-ink: #0ca30c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --raised: #222221;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --hairline: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --wash: rgba(57, 135, 229, 0.14);
  --series-price: #3987e5;
  --series-list: #d95926;
  --series-units: #199e70;
  --good-ink: #0ca30c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.2rem); letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.visually-hidden, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 50; background: var(--raised); padding: 8px 12px; border-radius: 8px; }
.num { font-variant-numeric: tabular-nums; }

/* ---- frame */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 700; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand svg { fill: var(--accent); stroke: var(--accent); }
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a { color: var(--ink-2); padding: 6px 11px; border-radius: 8px; font-weight: 550; }
.nav a:hover { background: var(--wash); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); background: var(--wash); }
.top-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
select {
  background: var(--raised); border: 1px solid var(--hairline); border-radius: 8px; padding: 6px 10px; max-width: 46vw;
}
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--hairline); background: var(--raised); cursor: pointer; }
.icon-button svg { fill: var(--ink-2); }
main { max-width: 1240px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 40px) 56px; min-height: 70vh; outline: none; }
.foot { border-top: 1px solid var(--hairline); padding: 20px clamp(16px, 4vw, 40px) 40px; color: var(--ink-2); font-size: 0.9rem; display: grid; gap: 6px; max-width: 1240px; margin: 0 auto; }
.loading, .notice, .empty { color: var(--ink-2); padding: 32px 0; }
@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 8px 12px; }
  .nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
}

/* ---- pulse */
.pulse { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); animation: beat 2.4s infinite; }
.dot.stale { background: var(--warning); animation: none; }
@keyframes beat { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } * { scroll-behavior: auto !important; transition: none !important; } }

/* ---- hero and tiles */
.hero { display: grid; gap: 10px; margin-bottom: 22px; }
.hero p { color: var(--ink-2); max-width: 68ch; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 18px 0 26px; }
.tile { background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px; padding: 14px 16px; }
.tile .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.tile .label { color: var(--ink-2); font-size: 0.88rem; }

/* ---- sections and cards */
.section { margin: 30px 0 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head p { color: var(--ink-2); font-size: 0.92rem; }
.columns { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 26px; align-items: start; }
@media (max-width: 960px) { .columns { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px; }
.card.pad { padding: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.product { display: flex; flex-direction: column; min-width: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px; overflow: hidden; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.product:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.product .shot { position: relative; flex: none; aspect-ratio: 4 / 3; background: #fff; border-bottom: 1px solid var(--hairline); }
.product .shot img, .product .shot .blank { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.product .body { flex: 1; min-width: 0; padding: 11px 13px 13px; display: grid; gap: 7px; align-content: start; }
.product .name { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product .price { font-size: 1.05rem; font-weight: 700; }
.badge { position: absolute; top: 9px; left: 9px; background: var(--critical); color: #fff; font-weight: 700; font-size: 0.8rem; padding: 2px 8px; border-radius: 999px; }
.badge.new { background: var(--accent); left: auto; right: 9px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--ink-2); font-size: 0.86rem; }

/* ---- status chips: an icon and a word, never color alone */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; border: 1px solid var(--ring); background: var(--raised); color: var(--ink); white-space: nowrap; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.in::before { background: var(--good); }
.chip.back::before { background: var(--warning); border-radius: 2px; }
.chip.soon::before { background: var(--muted); border-radius: 0; transform: rotate(45deg); }
.chip.out::before { background: var(--critical); border-radius: 0; height: 3px; width: 9px; }
.chip.low::before { background: var(--serious); clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }

/* ---- filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0 18px; }
.filters input[type="search"] { flex: 1 1 260px; background: var(--raised); border: 1px solid var(--hairline); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.seg { display: inline-flex; background: var(--raised); border: 1px solid var(--hairline); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-weight: 550; }
.seg button[aria-pressed="true"] { background: var(--wash); color: var(--ink); }
.count { color: var(--ink-2); font-size: 0.9rem; }

/* ---- live feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--hairline); }
.feed li:last-child { border-bottom: 0; }
.feed li.fresh { animation: arrive 1.6s ease-out; }
@keyframes arrive { from { background: var(--wash); } to { background: transparent; } }
.feed img, .thumb { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--hairline); }
.feed .what { min-width: 0; }
.feed .what a { color: var(--ink); font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .what span { color: var(--ink-2); font-size: 0.88rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .when { text-align: right; font-size: 0.86rem; color: var(--ink-2); display: grid; gap: 3px; justify-items: end; }
.delta { font-weight: 700; }
.delta.down { color: var(--good-ink); }
.delta.up { color: var(--critical); }

/* ---- product page */
.crumbs { color: var(--ink-2); font-size: 0.9rem; margin-bottom: 12px; }
.product-head { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; margin-bottom: 20px; }
.product-head .shot { position: relative; background: #fff; border: 1px solid var(--hairline); border-radius: 14px; aspect-ratio: 1; overflow: hidden; }
.product-head .shot img, .product-head .shot .blank { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.product-head .facts { display: grid; gap: 10px; }
.big-price { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; }
.strike { color: var(--muted); text-decoration: line-through; font-weight: 500; font-size: 1.05rem; margin-left: 8px; }
.button { display: inline-flex; align-items: center; gap: 8px; background: var(--accent); color: #fff; padding: 9px 15px; border-radius: 10px; font-weight: 650; border: 0; cursor: pointer; }
.button:hover { text-decoration: none; filter: brightness(1.06); }
.button.quiet { background: var(--raised); color: var(--ink); border: 1px solid var(--hairline); }
@media (max-width: 720px) { .product-head { grid-template-columns: 1fr; } .product-head .shot { max-width: 260px; } }
.variants { width: 100%; border-collapse: collapse; }
.variants th { text-align: left; color: var(--ink-2); font-weight: 600; font-size: 0.85rem; padding: 8px 12px; border-bottom: 1px solid var(--hairline); position: sticky; top: 0; background: var(--surface); }
.variants td { padding: 8px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.variants tr:last-child td { border-bottom: 0; }
.variants tr[aria-selected="true"] td { background: var(--wash); }
.variants tbody tr { cursor: pointer; }
.variants .swatch { flex: none; width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--ring); object-fit: cover; }
.variant-name { display: flex; align-items: center; gap: 9px; }
.variant-name small { display: block; color: var(--ink-2); font-size: 0.84rem; }
.scroll { max-height: 420px; overflow: auto; border-radius: 14px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 6px; }
.swatches button { aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--ring); padding: 0; cursor: pointer; overflow: hidden; position: relative; background: var(--raised); }
.swatches button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.swatches button[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatches button.gone::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top right, transparent calc(50% - 1px), var(--critical) calc(50% - 1px), var(--critical) calc(50% + 1px), transparent calc(50% + 1px)), color-mix(in srgb, var(--surface) 55%, transparent); }

/* ---- charts */
.chart-card { padding: 16px 16px 10px; }
.chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--ink-2); font-size: 0.86rem; margin: 4px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 16px; height: 0; border-top: 2px solid var(--series-price); display: inline-block; }
.legend i.list { border-top: 2px dashed var(--series-list); }
.legend i.units { border-top-color: var(--series-units); }
.legend i.band { height: 8px; border: 0; border-radius: 2px; background: var(--good); }
.legend i.band.back { background: var(--warning); }
.legend i.band.soon { background: var(--muted); }
.legend i.band.out { background: var(--critical); }
.plot { position: relative; }
.plot + .plot { margin-top: 6px; }
.plot-title { color: var(--ink-2); font-size: 0.82rem; font-weight: 600; margin: 8px 0 2px; }
.tip { position: absolute; top: 8px; white-space: nowrap; pointer-events: none; z-index: 5; background: var(--raised); border: 1px solid var(--hairline); border-radius: 10px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 0.85rem; min-width: 150px; display: none; }
.tip .t { color: var(--ink-2); margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .row b { font-variant-numeric: tabular-nums; }
.tip .key { width: 12px; border-top: 2px solid var(--series-price); display: inline-block; margin-right: 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 12px; }
.stat { border: 1px solid var(--hairline); border-radius: 12px; padding: 10px 12px; background: var(--raised); }
.stat .value { font-weight: 700; font-size: 1.1rem; }
.stat .label { color: var(--ink-2); font-size: 0.82rem; }
.u-legend { display: none; }
.uplot { font-family: inherit; }
details.table-view { margin-top: 10px; color: var(--ink-2); }
details.table-view summary { cursor: pointer; font-size: 0.88rem; }
details.table-view table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.88rem; }
details.table-view th, details.table-view td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--hairline); }

/* ---- tables and prose */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--ink-2); font-weight: 600; font-size: 0.85rem; padding: 8px 12px; border-bottom: 1px solid var(--hairline); }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--hairline); }
.table tr:last-child td { border-bottom: 0; }
.prose { max-width: 72ch; display: grid; gap: 14px; }
.prose h2 { margin-top: 12px; }
.prose ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.row-link { color: var(--ink); font-weight: 600; }

/* ---- small shared pieces */
[hidden] { display: none !important; }
.pad { padding: 16px; }
.empty.pad, .loading.pad { padding: 20px 16px; }
.blank { background: var(--hairline); }
.thumb.blank { display: block; }
.scroll-x { overflow-x: auto; }
.thumb-cell { width: 60px; }
.delta.off { margin-left: 8px; }
.table .strike, .variants .strike { font-size: 0.9rem; }
.chip.new-chip::before { background: var(--accent); }
.feed li.placeholder { grid-template-columns: 0 minmax(0, 1fr) 0; }
.feed li.placeholder .what span { white-space: normal; }
.columns.section { margin-top: 30px; }

/* ---- a row of cards that scrolls sideways */
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 220px); gap: 14px; overflow-x: auto; padding: 4px 2px 12px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.strip > * { scroll-snap-align: start; }

/* ---- the alert box on a product page */
.watch { display: grid; gap: 10px; }
.watch p { color: var(--ink-2); max-width: 72ch; }
.watch .id { background: var(--raised); border: 1px solid var(--hairline); border-radius: 8px; padding: 7px 10px; font: 0.95rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; user-select: all; }

/* ---- charts, continued */
.chart-root { min-height: 120px; transition: opacity 0.15s ease; }
.chart-root.busy { opacity: 0.5; }
.tip .key.band { border: 0; width: 10px; height: 8px; border-radius: 2px; background: var(--good); }
.tip .key.band.back { background: var(--warning); }
.tip .key.band.soon { background: var(--muted); }
.tip .key.band.out { background: var(--critical); }
.tip .key.units { border-top-color: var(--series-units); }
.swatches button .blank { width: 100%; height: 100%; }

/* ---- the filament wall: status is a shape on the swatch and words in its label, never color alone */
.lines { display: grid; gap: 14px; }
.line { display: grid; gap: 8px; }
.line-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 14px; }
.line-head h2 a { color: var(--ink); }
.line .hover { min-height: 1.5em; }
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 7px; }
.sw { position: relative; display: block; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--ring); overflow: hidden; background: var(--raised); }
.sw img, .sw .blank { width: 100%; height: 100%; object-fit: cover; display: block; }
.sw:hover, .sw:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw.out::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top right, transparent calc(50% - 1.5px), var(--critical) calc(50% - 1.5px), var(--critical) calc(50% + 1.5px), transparent calc(50% + 1.5px)), color-mix(in srgb, var(--surface) 62%, transparent); }
.sw.back::after { content: ""; position: absolute; right: 0; top: 0; width: 12px; height: 12px; background: var(--warning); border-left: 2px solid var(--surface); border-bottom: 2px solid var(--surface); }
.sw.low::before { content: ""; position: absolute; right: 0; top: 0; z-index: 1; width: 18px; height: 18px; background: var(--surface); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.sw.low::after { content: ""; position: absolute; right: 0; top: 0; z-index: 2; width: 14px; height: 14px; background: var(--serious); clip-path: polygon(0 0, 100% 0, 100% 100%); }

/* ---- second pass */
.grid > *, .strip > * { min-width: 0; }
.more { margin-top: 12px; }
.hero .pulse.live { color: var(--ink-2); font-size: 0.9rem; font-weight: 550; }
.key-row { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--ink-2); font-size: 0.9rem; }
.key-row span { display: inline-flex; align-items: center; gap: 7px; }
.key-row .sw { width: 22px; height: 22px; border-radius: 6px; background: var(--axis); }
.key-row .sw.low::before { width: 13px; height: 13px; }
.key-row .sw.low::after { width: 10px; height: 10px; }
.key-row .sw.back::after { width: 9px; height: 9px; }
