:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #1b1a17;
  --mute: #6b675f;
  --line: #e2ded6;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --save: #116149;
  --save-bg: #e3f3ec;
  --hot-bg: #fdebe1;
  --warn: #92400e;
  --shadow: 0 1px 2px rgba(27, 26, 23, .06), 0 6px 20px rgba(27, 26, 23, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --surface: #1e1c19;
    --ink: #f1eee8;
    --mute: #a39e93;
    --line: #322f2a;
    --accent: #fb8a4c;
    --accent-ink: #1b1a17;
    --save: #6fd3ab;
    --save-bg: #16312a;
    --hot-bg: #3a2216;
    --warn: #f3b46b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* header */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 17px; }
.search { flex: 1; max-width: 420px; margin-left: auto; }
.search input {
  width: 100%; height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit;
}
.search input:focus-visible, select:focus-visible, button:focus-visible, .card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* hero */
.hero { padding: 28px 0 18px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
h1 { margin: 0; font-size: clamp(28px, 5vw, 42px); line-height: 1.08; letter-spacing: -.03em; }
.status { margin: 8px 0 0; color: var(--mute); }

/* tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tab small { font-weight: 500; color: var(--mute); margin-left: 4px; }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tab[aria-selected="true"] small { color: inherit; opacity: .7; }

/* controls */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 16px 0; font-size: 13px; color: var(--mute); }
.controls label { display: flex; align-items: center; gap: 6px; }
.controls select {
  height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit;
}
.controls .check { cursor: pointer; color: var(--ink); }
.controls .check input { width: 16px; height: 16px; accent-color: var(--accent); }
.count { margin-left: auto; font-variant-numeric: tabular-nums; }

/* grid + cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; } }
.card {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; text-align: left; color: inherit; font: inherit;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card.out { opacity: .6; }
.thumb { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 9px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; min-height: 21px; }
.tag { padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; background: var(--line); color: var(--ink); }
.tag.hot { background: var(--hot-bg); color: var(--accent); }
.tag.save { background: var(--save-bg); color: var(--save); }
.tag.warn { background: transparent; border: 1px solid var(--line); color: var(--warn); }
.name { flex: 1; margin: 0; font-size: 13.5px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.price { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.price b { font-size: 21px; letter-spacing: -.02em; }
.price s { color: var(--mute); font-size: 13px; }
.promo { margin: 0; font-size: 12px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.star {
  position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--mute);
  font-size: 16px; line-height: 1; cursor: pointer;
}
.star[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.empty { padding: 56px 16px; text-align: center; color: var(--mute); border: 1px dashed var(--line); border-radius: 14px; }
.empty strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 17px; }
.pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; padding: 28px 0; }
.pg {
  min-width: 40px; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.pg:hover:not(:disabled) { border-color: var(--ink); }
.pg[aria-current] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pg:disabled { opacity: .4; cursor: default; }
.pager .gap { color: var(--mute); padding: 0 2px; }
.pg-note { flex-basis: 100%; text-align: center; color: var(--mute); font-size: 14px; margin-top: 6px; }
.btn {
  display: inline-block; padding: 10px 20px; border-radius: 999px; border: 1px solid var(--ink);
  background: transparent; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.foot { padding: 24px 16px 48px; border-top: 1px solid var(--line); margin-top: 24px; color: var(--mute); font-size: 12.5px; }
.foot p { max-width: 720px; margin: 0; }

/* detail dialog */
dialog {
  width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 20px; cursor: pointer;
}
.d-body { display: grid; grid-template-columns: 280px 1fr; gap: 24px; padding: 24px; }
@media (max-width: 640px) { .d-body { grid-template-columns: 1fr; padding: 16px; } .d-body .thumb { max-width: 220px; margin: 0 auto; } }
.d-body > * { min-width: 0; }
.facts span:last-child { overflow-wrap: anywhere; }
.d-body h2 { margin: 8px 40px 10px 0; font-size: 19px; line-height: 1.25; letter-spacing: -.01em; }
.d-body .price b { font-size: 30px; }
.facts { margin: 16px 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.facts li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.facts span:first-child { color: var(--mute); }
.facts span:last-child { font-variant-numeric: tabular-nums; text-align: right; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; }
