:root {
  color-scheme: light dark;
  --bg: light-dark(#f6f6f3, #141517);
  --surface: light-dark(#ffffff, #1e2023);
  --text: light-dark(#1b1c1e, #e9e9ea);
  --muted: light-dark(#62656b, #a0a4ab);
  --border: light-dark(#e2e2dd, #2f3237);
  --brand: light-dark(#1f5fd6, #7aa7ff);
  --brand-text: light-dark(#fff, #0d1a33);
  --blocket: #e2182b;
  --tradera: #f5b400;
  --error-bg: light-dark(#fdecec, #3a1d1f);
  --error-text: light-dark(#8d1a1a, #ffb4b4);
  --off-bg: light-dark(#eceef1, #2a2d31);
  --radius: 12px;
  accent-color: var(--brand);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.4; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px max(16px, calc((100% - 1200px) / 2));
  position: sticky; top: 0; z-index: 5;
}
h1 { font-size: 1.25rem; margin: 0 0 12px; }
h1 .sub { font-weight: 400; color: var(--muted); font-size: .9rem; margin-left: 6px; }

.search .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search .row + .row { margin-top: 10px; }
#q {
  flex: 1 1 260px; font-size: 1rem; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
button { font: inherit; cursor: pointer; }
button.primary {
  background: var(--brand); color: var(--brand-text); border: 0;
  padding: 10px 20px; border-radius: 8px; font-weight: 600;
}
button:disabled { opacity: .5; cursor: default; }
.filters { gap: 16px !important; font-size: .9rem; }
.filters select {
  margin-left: 4px; padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
.platforms { border: 0; padding: 0; margin: 0; display: flex; gap: 14px; }
.hint { margin: 8px 0 0; font-size: .8rem; color: var(--muted); }

.pill { font-size: .7rem; padding: 1px 6px; border-radius: 99px; vertical-align: middle; }
.pill.off { background: var(--off-bg); color: var(--muted); }

main { padding: 16px max(16px, calc((100% - 1200px) / 2)) 48px; }

.status { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; font-size: .88rem; }
.status:empty { display: none; }
.chip {
  display: inline-flex; gap: 6px; align-items: center;
  padding: 6px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.blocket .dot { background: var(--blocket); }
.chip.tradera .dot { background: var(--tradera); }
.chip.error { background: var(--error-bg); color: var(--error-text); border-color: transparent; }
.chip.disabled { background: var(--off-bg); color: var(--muted); }
.chip.loading { color: var(--muted); }

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
}
.empty { color: var(--muted); grid-column: 1 / -1; text-align: center; padding: 40px 0; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.thumb { position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; background: var(--off-bg); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb img:not([src]) { visibility: hidden; }
.badge {
  position: absolute; top: 8px; left: 8px; font-size: .72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .03em;
}
.badge.blocket { background: var(--blocket); color: #fff; }
.badge.tradera { background: var(--tradera); color: #1b1300; }
.info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.title { font-size: .95rem; margin: 0; font-weight: 600; }
.title a { color: inherit; text-decoration: none; }
.title a:hover { text-decoration: underline; }
.price { margin: 0; font-weight: 700; font-size: 1.05rem; }
.auction, .meta { margin: 0; font-size: .8rem; color: var(--muted); }
.auction:empty { display: none; }
.more {
  margin-top: auto; align-self: flex-start; background: none; border: 0; padding: 4px 0;
  color: var(--brand); font-size: .85rem;
}

/* Skeleton */
.card.skeleton .thumb, .card.skeleton .line {
  background: linear-gradient(90deg, var(--off-bg), var(--border), var(--off-bg));
  background-size: 200% 100%; animation: shimmer 1.2s infinite linear;
}
.card.skeleton .line { height: 12px; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .card.skeleton .thumb, .card.skeleton .line { animation: none; }
}

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 24px; }
.pager button {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}

/* Dialog */
dialog {
  width: min(720px, calc(100% - 32px)); max-height: calc(100dvh - 48px);
  border: 0; border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text);
}
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop {
  background: rgb(0 0 0 / .5);
  overflow: hidden; overscroll-behavior: contain;
}
.dialog-head {
  display: flex; justify-content: space-between; align-items: start; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
.dialog-head h2 { margin: 0; font-size: 1.1rem; }
.dialog-head form { margin: 0; }
.close { background: none; border: 0; font-size: 1.1rem; color: var(--muted); padding: 2px 6px; }
#details-body { padding: 16px; }
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin-bottom: 12px; }
.gallery img { height: 240px; border-radius: 8px; scroll-snap-align: start; flex: none; }
.desc { white-space: pre-wrap; font-size: .92rem; }
.details-error { color: var(--error-text); }
