:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --text: #16181d;
  --muted: #5d6470;
  --line: #dde0e6;
  --accent: #e8591a;         /* molten orange */
  --accent-ink: #ffffff;
  --new: #e8591a;
  --update: #1f7ae0;
  --reprint: #6b46c1;
  --bootleg: #8a8f98;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1114; --surface: #181b20; --surface-2: #22262d; --text: #eceef2; --muted: #9aa1ad;
    --line: #2b3038; --accent: #ff7a3d; --update: #4c9bff; --reprint: #a384ff; --bootleg: #7d838d;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1114; --surface: #181b20; --surface-2: #22262d; --text: #eceef2; --muted: #9aa1ad;
  --line: #2b3038; --accent: #ff7a3d; --update: #4c9bff; --reprint: #a384ff; --bootleg: #7d838d;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .04em; font-size: 15px; white-space: nowrap; }
.brand span { color: var(--accent); margin-left: 2px; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:active { background: var(--surface-2); }
.search { flex: 1; display: flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 999px; padding: 0 12px; min-width: 0; }
.search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search input { border: 0; background: none; outline: none; padding: 8px 0; width: 100%; min-width: 0; }

/* category chips */
.chiprow { position: sticky; top: calc(53px + env(safe-area-inset-top)); z-index: 15; display: flex; align-items: center;
  background: var(--bg); padding-left: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px 10px 8px; scrollbar-width: none; flex: 1; }
.filter-chip { display: flex; align-items: center; gap: 4px; flex: none; }
.filter-chip svg { width: 15px; height: 15px; }
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.filter-chip.active .n { color: inherit; opacity: .9; }
.filter-summary { display: flex; align-items: center; gap: 8px; margin: 2px 2px 8px; padding: 6px 6px 6px 12px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 999px; font-size: 13px; width: fit-content; max-width: 100%; }
.filter-summary .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-summary .x { border: 0; background: var(--surface-2); border-radius: 50%; width: 24px; height: 24px; cursor: pointer; flex: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px;
  font-size: 13px; cursor: pointer; }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { color: var(--muted); margin-left: 4px; font-size: 12px; }
.chip.active .n { color: inherit; opacity: .7; }

main { padding: 0 12px calc(24px + env(safe-area-inset-bottom)); max-width: 1200px; margin: 0 auto; }
.resultbar { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; padding: 2px 2px 8px; }

/* product grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; } }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; cursor: pointer; border: 1px solid transparent; }
.card:active { border-color: var(--line); }
.thumb { position: relative; aspect-ratio: 1; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noimg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: var(--muted); font-size: 12px; text-align: center; padding: 12px;
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, transparent 10px 20px); }
.noimg svg { width: 40px; height: 40px; stroke-width: 1.6; opacity: .7; }
.noimg strong { font-weight: 600; letter-spacing: .02em; }
.noimg.big { position: relative; inset: auto; aspect-ratio: 16 / 10; font-size: 14px; }
.noimg.big svg { width: 56px; height: 56px; }
.noimg.big span { max-width: 260px; font-size: 12px; line-height: 1.4; }
/* scale separators when a manufacturer is filtered */
.scale-sep { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin: 14px 2px 2px; font-size: 13px;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text); }
.scale-sep:first-child { margin-top: 2px; }
.scale-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.scale-sep small { order: 2; color: var(--muted); font-weight: 500; letter-spacing: 0; }
/* filter bottom sheet */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 86vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px 16px 0 0; transform: translateY(100%); transition: transform .22s ease;
  max-width: 760px; margin: 0 auto; }
.sheet.open { transform: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 4px 16px; font-size: 16px; }
.sheet-body { overflow-y: auto; padding: 0 16px 12px; }
.sheet-body h4 { margin: 14px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sheet-body input[type=search] { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 11px; font-size: 13px; cursor: pointer; }
.opt .n { color: var(--muted); margin-left: 5px; font-size: 11px; }
.opt.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.opt.on .n { color: inherit; opacity: .7; }
.hint { width: 100%; margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.sheet-foot { display: flex; gap: 10px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet-foot .text-btn { flex: 0 0 auto; padding: 10px 16px; }
.primary-btn { flex: 1; border: 0; border-radius: 10px; padding: 11px; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }
.badge { position: absolute; top: 6px; left: 6px; font-size: 10px; font-weight: 800; letter-spacing: .06em;
  padding: 3px 6px; border-radius: 4px; color: #fff; }
.badge.new { background: var(--new); }
.badge.update { background: var(--update); }
.tags { position: absolute; bottom: 6px; left: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 10px; font-weight: 700; padding: 2px 5px; border-radius: 4px; background: rgba(0,0,0,.62); color: #fff; }
.tag.reprint { background: var(--reprint); }
.tag.bootleg { background: var(--bootleg); }
.card-body { padding: 8px 9px 10px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.producer { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name { font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price { margin-top: auto; padding-top: 4px; font-weight: 800; font-size: 16px; }
.price small { font-weight: 500; font-size: 11px; color: var(--muted); margin-left: 4px; }
.meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); background: var(--surface); z-index: 50;
  transform: translateX(-100%); transition: transform .22s ease; display: flex; flex-direction: column;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.setting { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.setting.row { flex-direction: row; justify-content: space-between; align-items: center; }
.setting label { font-size: 13px; color: var(--muted); }
.setting select { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 0; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.toggle { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle:checked { background: var(--accent); }
.toggle:checked::after { left: 21px; }
.drawer-foot { margin-top: auto; padding-top: 16px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.drawer-foot .legal { margin: 4px 0 0; }
.drawer-foot .legal a { color: var(--muted); }
.drawer-foot .disclaimer { margin: 0; font-size: 11px; line-height: 1.45; opacity: .85; }
.text-btn { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 8px; cursor: pointer; }

/* detail */
.detail { position: fixed; inset: 0; background: var(--bg); z-index: 30; overflow-y: auto; }
.detail-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; background: var(--surface);
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px; border-bottom: 1px solid var(--line); }
.detail-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-body { max-width: 760px; margin: 0 auto; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; background: var(--surface-2); scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: none; width: 100%; aspect-ratio: 1; object-fit: contain; scroll-snap-align: center; background: var(--surface); }
.gallery-count { text-align: center; font-size: 12px; color: var(--muted); padding: 6px; }
.gallery-wrap { position: relative; }
.gallery-wrap .gallery img { cursor: pointer; }
.gal-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 999px; cursor: pointer;
  background: rgba(15, 17, 20, .55); color: #fff; }
.gal-nav svg { width: 20px; height: 20px; }
.gal-nav.prev { left: 8px; }
.gal-nav.next { right: 8px; }
.gal-nav:disabled { opacity: .22; cursor: default; }
@media (hover: hover) { .gal-nav:not(:disabled):hover { background: rgba(15, 17, 20, .78); } }
.panel { background: var(--surface); margin: 8px 0; padding: 14px 16px; }
.panel h2 { font-size: 18px; margin: 4px 0 6px; line-height: 1.3; }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.big-price { font-size: 24px; font-weight: 800; }
.big-price small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.panel ul { margin: 0; padding-left: 18px; }
.panel li { margin: 3px 0; }
.note { border-left: 3px solid var(--update); padding: 8px 12px; background: var(--surface-2); border-radius: 0 8px 8px 0; font-size: 13px; }
.offer { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.offer:last-child { border-bottom: 0; }
a { color: var(--accent); }
.badges-inline { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.badges-inline .badge, .badges-inline .tag { position: static; }

.filter-summary[hidden], .scrim[hidden], #gradeSection[hidden], .setting[hidden] { display: none; }

/* manufacturer list: all brands A–Z in their own scroll area */
#sheetMakers { max-height: 210px; overflow-y: auto; padding: 2px 2px 6px; border-bottom: 1px solid var(--line);
  overscroll-behavior: contain; }

/* grid image box is locked to a square: no image can stretch its card or the row (HM-043) */
.thumb { overflow: hidden; }
.thumb > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.noimg .n { font-size: 11px; opacity: .8; }
.tag.edition { background: #2b6cb0; }

/* tentative names (HM-045) */
.tentative { display: inline-block; align-self: flex-start; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: #b7791f; border: 1px dashed #b7791f; border-radius: 4px; padding: 1px 5px; margin-top: 2px; }
.detail .tentative { font-size: 11px; text-transform: none; letter-spacing: 0; margin: 2px 0 6px; }
.unoff { color: var(--muted); margin-left: 2px; }
.unoff-long { text-transform: none; letter-spacing: 0; font-size: 11px; }
