:root {
  --bg: #f6f6f4; --surface: #fff; --text: #1d1d1b; --muted: #6b6b66;
  --border: #e2e2dd; --row-hover: #f1f0ec; --accent: #8b1e2d; --accent-text: #fff;
  --warn: #8a5a00; --warn-bg: #fdf3dc;
  --ebay: #1f5fa8; --tcgmarket: #1f6f43; --gamepod: #7a3fa0; --drivethrucards: #a1561b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --surface: #1f1f1d; --text: #ececea; --muted: #9a9a94;
    --border: #33332f; --row-hover: #272724; --accent: #d05a6c; --accent-text: #fff;
    --warn: #f0c46a; --warn-bg: #3a2e12;
    --ebay: #7fb0ec; --tcgmarket: #7fd1a1; --gamepod: #c9a0e6; --drivethrucards: #eab07f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.site-header { display: flex; align-items: baseline; flex-wrap: wrap; gap: .25rem 1rem; padding: .75rem 1rem;
               background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; letter-spacing: .02em; }
main { max-width: 1440px; margin: 0 auto; padding: 1rem; }
.site-footer { max-width: 1440px; margin: 0 auto; padding: 1rem; font-size: .8rem; }

input, select, button { font: inherit; color: var(--text); }
input[type=search], input[type=number], select {
  padding: .45rem .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.button { display: inline-block; border: 1px solid var(--accent); border-radius: 6px; padding: .25rem .7rem;
          background: var(--accent); color: var(--accent-text); text-decoration: none; font-size: .85rem; }

/* Layout: filters on the left, toolbar and results on the right. */
.browser { display: grid; grid-template-columns: 260px minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "filters toolbar" "filters results";
           gap: 1rem; align-items: start; }
.toolbar { grid-area: toolbar; display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.toolbar label { display: flex; align-items: center; gap: .4rem; }
.toolbar .search { flex: 1 1 280px; }
.toolbar .search input { width: 100%; font-size: 1rem; }
.filters { grid-area: filters; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto;
           background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .75rem; }
.results { grid-area: results; display: block; min-width: 0; }
.results[aria-busy=true] { opacity: .6; transition: opacity .15s; }

@media (max-width: 800px) {
  .browser { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "toolbar" "filters" "results"; }
  .filters { position: static; max-height: none; }
}

/* Filters */
.filters-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .25rem; }
.filters details { border-top: 1px solid var(--border); padding: .5rem 0; }
.filters summary { cursor: pointer; font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.options { list-style: none; margin: .4rem 0 0; padding: 0; }
.options li { margin: .1rem 0; }
.options label { display: flex; align-items: center; gap: .4rem; cursor: pointer; }
.options .count { margin-left: auto; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.options.scroll { max-height: 14rem; overflow-y: auto; padding-right: .25rem; }
.options.nested { margin: 0 0 .25rem 1.4rem; }
.market-row { display: flex; align-items: center; gap: .25rem; }
.market-row label { flex: 1; }
.expand { background: none; border: 0; cursor: pointer; padding: 0 .3rem; color: var(--muted); }
.price-range { display: flex; align-items: center; gap: .4rem; margin-top: .4rem; }
.price-range input { width: 100%; }
.min-quantity { display: flex; align-items: center; gap: .4rem; margin-top: .4rem; }
.min-quantity input { width: 5rem; }
.filters details > p { margin: .3rem 0 0; }

/* Results */
.results-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin-bottom: .5rem; }
.warning { color: var(--warn); background: var(--warn-bg); padding: .2rem .5rem; border-radius: 6px; font-size: .85rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
table.offers { width: 100%; border-collapse: collapse; }
.offers th, .offers td { text-align: left; padding: .35rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.offers tbody tr:last-child td { border-bottom: 0; }
.offers tbody tr:hover { background: var(--row-hover); }
.offers th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.offers .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.offers td.card { display: flex; align-items: center; gap: .6rem; min-width: 14rem; }
.thumb { width: 40px; height: 56px; object-fit: cover; border-radius: 3px; background: var(--border); flex: none; }
.card-name { font-weight: 600; }
.market { display: inline-block; font-size: .75rem; font-weight: 600; padding: 0 .4rem; border-radius: 4px;
          border: 1px solid currentColor; margin-right: .3rem; white-space: nowrap; }
.market-ebay { color: var(--ebay); }
.market-tcgmarket { color: var(--tcgmarket); }
.market-gamepod { color: var(--gamepod); }
.market-drivethrucards { color: var(--drivethrucards); }
.seller { word-break: break-word; }
.seller-cell .seller { display: inline-block; max-width: 100%; }
.flag { display: inline-block; width: 20px; height: 15px; margin-right: .4rem; vertical-align: -2px;
        border-radius: 2px; box-shadow: 0 0 0 1px var(--border); object-fit: cover; }
.flag-none { box-shadow: none; }
.preview { position: fixed; z-index: 10; height: 350px; width: auto; border-radius: 12px; pointer-events: none;
           box-shadow: 0 8px 30px rgb(0 0 0 / .35); }

.pager { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: center; margin: 1rem 0; }
.pager a, .pager span { min-width: 2.2rem; padding: .3rem .6rem; text-align: center; border-radius: 6px; }
.pager a { border: 1px solid var(--border); background: var(--surface); text-decoration: none; }
.pager .current { background: var(--accent); color: var(--accent-text); font-weight: 600; }
