:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #ebe7dd;
  --ink: #1d1b17;
  --muted: #6b665b;
  --line: #d9d3c4;
  --accent: #d9780a;
  --accent-ink: #ffffff;
  --accent-soft: #fbead2;
  --good: #2d7a3e;
  --shadow: 0 1px 2px rgba(29, 27, 23, .08), 0 6px 20px rgba(29, 27, 23, .06);
  --img-bg: #ffffff;
  --radius: 4px;
  --display: "Oswald", "Bahnschrift", "Arial Narrow", "Segoe UI", system-ui, sans-serif;
  --body: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14130f;
    --surface: #1e1c17;
    --surface-2: #28251e;
    --ink: #efebe1;
    --muted: #a39d8f;
    --line: #38342a;
    --accent: #f0a032;
    --accent-ink: #1a1306;
    --accent-soft: #3a2a10;
    --good: #6cc07c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
    --img-bg: #f2efe8;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14130f;
  --surface: #1e1c17;
  --surface-2: #28251e;
  --ink: #efebe1;
  --muted: #a39d8f;
  --line: #38342a;
  --accent: #f0a032;
  --accent-ink: #1a1306;
  --accent-soft: #3a2a10;
  --good: #6cc07c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  --img-bg: #f2efe8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: 0 16px 48px; }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: .01em; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px; min-height: 56px;
  background: var(--surface); border-bottom: 3px solid var(--accent);
}
.brand { display: flex; min-height: 44px; align-items: center; gap: 10px; text-decoration: none; font: 700 22px var(--display); text-transform: uppercase; letter-spacing: .06em; }
.brand img { border-radius: 4px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
  text-decoration: none; color: var(--muted); font: 600 14px var(--display); text-transform: uppercase; letter-spacing: .08em; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -3px;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }
.count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--accent); color: var(--accent-ink); border-radius: 10px; font: 700 12px var(--body);
}
.count:empty, .count[data-zero="1"] { background: var(--surface-2); color: var(--muted); }
.theme-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font: 600 13px var(--body);
}
.theme-btn:hover { border-color: var(--ink); }

/* ---- masthead ---- */
.masthead { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding: 32px 0 24px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 6px; font: 600 12px var(--display); letter-spacing: .2em; text-transform: uppercase; color: var(--accent); }
.masthead h1 { font-size: clamp(28px, 5vw, 48px); line-height: 1.05; text-transform: uppercase; }
.lede { margin: 0; color: var(--muted); max-width: 36ch; }
.actions { display: flex; gap: 8px; }

/* ---- buttons / fields ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--ink); border-radius: var(--radius);
  font: 600 14px var(--body); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); color: var(--accent-ink); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: 600 14px var(--body); padding: 8px; min-height: 40px; }
.field { display: block; margin: 0 0 16px; }
.field > span { display: flex; justify-content: space-between; font: 600 12px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field output { color: var(--ink); font-family: var(--mono); letter-spacing: 0; text-transform: none; }
input[type="search"], select {
  width: 100%; min-height: 40px; padding: 0 10px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); font: 15px var(--body);
}
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 32px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: 260px 1fr; gap: 32px; align-items: start; }
.filters { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; padding-right: 6px; }
.filters-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.filters-head h2 { font-size: 20px; text-transform: uppercase; }
.filters-toggle { display: none; }
.group { border-top: 1px solid var(--line); padding: 12px 0; }
.group > h3 { font: 600 12px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check .n { margin-left: auto; color: var(--muted); font: 12px var(--mono); }

.results-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.results-bar p { margin: 0; font: 600 14px var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.sort { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.sort select { width: auto; }

/* ---- product cards ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.card {
  position: relative; display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-top: 4px solid var(--ink); box-shadow: var(--shadow);
  transition: transform .15s ease, border-top-color .15s ease;
}
.card:hover { transform: translateY(-3px); border-top-color: var(--accent); }
.card .pic { display: block; width: 100%; aspect-ratio: 1 / 1; background: var(--img-bg); border: 0; padding: 14px; cursor: pointer; }
.card .pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card .body { padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.brand-tag { font: 700 12px var(--display); letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }
.card h3 { font-size: 17px; line-height: 1.25; text-transform: none; font-weight: 500; }
.card h3 button { all: unset; display: block; box-sizing: border-box; min-height: 40px; cursor: pointer; }
.card h3 button:hover { text-decoration: underline; }
.specs { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); margin-top: auto; }
.spec { padding: 8px 4px 0; text-align: center; border-left: 1px solid var(--line); }
.spec:first-child { border-left: 0; }
.spec b { display: block; font: 600 17px var(--display); }
.spec small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.card-actions { display: flex; gap: 6px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.chip {
  flex: 1; min-height: 40px; padding: 0 8px; background: transparent; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); font: 600 13px var(--body); cursor: pointer;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.empty { grid-column: 1 / -1; padding: 48px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); }
.more { display: flex; justify-content: center; margin-top: 28px; }
.section-title { display: flex; align-items: center; gap: 10px; font-size: 22px; text-transform: uppercase; margin: 24px 0 14px; }

/* ---- detail dialog ---- */
dialog { width: min(920px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 0; border-top: 4px solid var(--accent); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
dialog::backdrop { background: rgba(10, 9, 6, .6); }
.detail { display: grid; grid-template-columns: 1fr 1fr; }
.detail .pic { background: var(--img-bg); padding: 24px; display: grid; place-items: center; min-height: 280px; }
.detail .pic img { width: 100%; max-height: 420px; object-fit: contain; }
.detail .info { padding: 24px; position: relative; }
.detail h2 { font-size: 26px; line-height: 1.15; margin: 4px 0 16px; }
.close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 50%; font-size: 22px; cursor: pointer; z-index: 2; }
.spec-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 14px; }
.spec-table th, .spec-table td { padding: 7px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.spec-table th { color: var(--muted); font-weight: 500; padding-right: 12px; }
.spec-table td { font-family: var(--mono); font-size: 13px; text-align: right; }
.detail .card-actions { padding: 0; border: 0; flex-wrap: wrap; }
.detail .card-actions .btn { flex: 1; }

/* ---- logs ---- */
.log-filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.log-filters .field { min-width: 140px; margin-bottom: 0; }
.log-filters .grow { flex: 1; min-width: 200px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
.log-table { width: 100%; border-collapse: collapse; font: 12px/1.45 var(--mono); }
.log-table td { padding: 5px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log-table .t { white-space: nowrap; color: var(--muted); }
.log-table .msg { word-break: break-word; }
.lvl { font-weight: 700; }
.lvl.Warning { color: var(--accent); }
.lvl.Error, .lvl.Fatal { color: #d6372e; }
.files { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.files li { display: flex; gap: 12px; align-items: center; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line); flex-wrap: wrap; }
.files .grow { flex: 1; font-family: var(--mono); }
.tail { margin: 12px 0 0; padding: 12px; background: var(--surface); border: 1px solid var(--line); font: 12px/1.45 var(--mono); max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; }

.footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* ---- phones and small tablets ---- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 12px; }
  .filters-toggle {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px;
    background: var(--surface); color: var(--ink); border: 1px solid var(--ink); border-radius: var(--radius); font: 600 14px var(--body);
  }
  .filters { display: none; position: static; max-height: none; padding: 12px; background: var(--surface); border: 1px solid var(--line); }
  .filters.open { display: block; }
  .detail { grid-template-columns: 1fr; }
  .detail .pic { min-height: 0; padding: 16px; }
  .detail .pic img { max-height: 260px; }
}
@media (max-width: 520px) {
  .log-table { min-width: 560px; }
  .topbar { gap: 8px; flex-wrap: wrap; padding: 6px 12px; }
  .brand span { font-size: 19px; }
  .tabs { order: 3; flex: 1 0 100%; }
  .topbar-right { margin-left: auto; }
  #theme-label { display: none; }
  .theme-btn { width: 44px; justify-content: center; padding: 0; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card .pic { padding: 8px; }
  .card .body { padding: 10px 10px 8px; }
  .card h3 { font-size: 14px; }
  .spec b { font-size: 14px; }
  .spec small { font-size: 10px; letter-spacing: .02em; }
  .spec { padding-left: 2px; padding-right: 2px; }
  .card-actions { padding: 8px; gap: 4px; }
  .chip { font-size: 12px; padding: 0 4px; }
  main { padding: 0 12px 40px; }
  .masthead { padding: 20px 0 16px; }
}
@media (prefers-reduced-motion: reduce) { .card { transition: none; } }

/* ---- compare ------------------------------------------------------------------------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.check.inline { display: inline-flex; margin-right: 6px; }
.masthead .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }

.tray {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: var(--surface); border-top: 2px solid var(--accent); box-shadow: 0 -6px 20px rgba(0, 0, 0, .12);
}
.tray-items { display: flex; gap: 8px; }
.tray-item { position: relative; width: 44px; height: 44px; background: var(--img-bg); border: 1px solid var(--line); flex: none; }
.tray-item img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tray-item button {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; padding: 0; line-height: 1;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 14px;
}
.tray-item button::after { content: ""; position: absolute; inset: -9px; }
.tray-text { margin: 0 auto 0 0; color: var(--muted); font: 600 13px var(--display); letter-spacing: .06em; text-transform: uppercase; }
.tray .btn[aria-disabled="true"] { opacity: .5; }
body.has-tray { padding-bottom: 72px; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 40; max-width: min(92vw, 520px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 14px;
}

.compare-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
.compare-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 100%; }
.compare-table th, .compare-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
.compare-table thead th { border-bottom: 2px solid var(--ink); vertical-align: top; }
.compare-table th[scope="row"] {
  position: sticky; left: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-weight: 600;
  min-width: 104px; max-width: 132px; border-right: 1px solid var(--line);
}
.compare-table .corner { position: sticky; left: 0; z-index: 2; background: var(--surface-2); min-width: 104px; border-right: 1px solid var(--line); }
.compare-table .pcol { min-width: 168px; width: 25%; }
.compare-table td { font-family: var(--mono); font-size: 13px; }
.compare-table td[data-empty="1"] { color: var(--muted); }
.compare-table td.best { background: var(--accent-soft); font-weight: 700; box-shadow: inset 3px 0 0 var(--good); }
.compare-table tr.same td, .compare-table tr.same th[scope="row"] { opacity: .75; }
.compare-table td.none { text-align: center; color: var(--muted); font-family: var(--body); padding: 32px 12px; }
.pc { position: relative; display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.pc-pic { background: var(--img-bg); border: 1px solid var(--line); height: 120px; padding: 6px; cursor: pointer; }
.pc-pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pc-name { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; font: 600 15px/1.25 var(--display); color: var(--ink); }
.pc-name:hover { color: var(--accent); }
.pc-remove {
  position: absolute; top: 0; right: 0; z-index: 1; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 18px; line-height: 1;
}
.pc .link { padding: 6px 0; text-align: left; text-decoration: none; }

@media (max-width: 520px) {
  .tray { padding: 8px 12px; gap: 8px; }
  .tray-text { display: none; }
  .tray-items { margin-right: auto; }
  .compare-table .pcol { min-width: 148px; }
  .compare-table th[scope="row"], .compare-table .corner { min-width: 84px; max-width: 96px; font-size: 12px; padding: 8px; }
  .compare-table th, .compare-table td { padding: 8px; }
  .chip { font-size: 11px; }
}

/* Short descriptions (ADR 0014): two lines on a card, in full in the dialog */
.summary { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.summary.full { display: block; font-size: 15px; margin: 0 0 12px; color: var(--ink); }

/* Approximate prices (ADR 0012) */
.price { margin: 8px 0 0; font-family: var(--mono); font-size: 14px; }
.price b { font-weight: 700; }
.price small { color: var(--muted); font-size: 12px; }
.price-note { margin: 2px 0 12px; color: var(--muted); font-size: 12px; }
.compare-table td { white-space: pre-line; }

/* ---- category tiles, breadcrumbs, tree (ADR 0013) ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 0 0 24px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; min-height: 120px; padding: 18px 18px 16px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--ink); box-shadow: var(--shadow);
  transition: transform .15s ease, border-top-color .15s ease;
}
.tile:hover { transform: translateY(-3px); border-top-color: var(--accent); }
.tile b { font: 600 22px var(--display); text-transform: uppercase; letter-spacing: .02em; line-height: 1.15; }
.tile-count { font: 600 13px var(--mono); color: var(--accent); }
.tile small { color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: auto; }
.tiles.sub .tile { min-height: 84px; padding: 12px 14px; }
.tiles.sub .tile b { font-size: 17px; }
.landing-search { display: flex; gap: 8px; max-width: 560px; margin: 0 0 24px; }
.landing-search input { flex: 1; min-width: 0; }
.browse-all { margin: 0 0 32px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; padding: 20px 0 6px; font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; min-height: 40px; }
.crumbs a:hover { text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.cat-title { font-size: clamp(26px, 4.5vw, 40px); text-transform: uppercase; margin: 0 0 16px; }
.cat-nav { border-top: 0; padding-top: 0; }
.cat-nav ul { list-style: none; margin: 0; padding: 0; }
.cat-nav ul ul { margin-left: 14px; border-left: 1px solid var(--line); padding-left: 8px; }
.cat-nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 40px; padding: 0 6px; color: var(--ink); text-decoration: none; border-radius: var(--radius); }
.cat-nav a:hover { background: var(--surface-2); }
.cat-nav a.on { background: var(--accent-soft); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.cat-nav .n { color: var(--muted); font: 12px var(--mono); }
@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr; gap: 12px; }
  .tile { min-height: 0; }
  .tiles.sub { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .landing-search { flex-wrap: nowrap; }
}
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } }
