:root {
  color-scheme: light;
  --bg: #f3f3f1;
  --card: #ffffff;
  --line: #e6e6e2;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #ff5a00;
  --blue: #257de0;
  --down: #0a7a2a;
  --down-bg: #e6f4ea;
  --up: #b3261e;
  --up-bg: #fbeaea;
  --star: #f2a600;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 18px rgba(0,0,0,.06);
  --shadow-hover: 0 2px 4px rgba(0,0,0,.06), 0 14px 32px rgba(0,0,0,.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f0f10;
    --card: #1a1a1c;
    --line: #2b2b2e;
    --text: #efefef;
    --muted: #9c9c9c;
    --blue: #4a9bf0;
    --down: #6fd38a;
    --down-bg: #15301e;
    --up: #f08a84;
    --up-bg: #3a1a19;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-hover: 0 10px 30px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.45 system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.top {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 9px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--down); }
.dot.pulse { animation: pulse .8s ease-out; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--accent); background: var(--accent); } 100% { box-shadow: 0 0 0 9px transparent; } }
nav { display: flex; gap: 4px; }
nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 500; }
nav a:hover { color: var(--text); }
nav a.on { color: var(--text); background: var(--bg); }

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
input, select {
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.search { position: relative; flex: 1 1 260px; max-width: 420px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { width: 100%; padding-left: 36px; }
.range { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.range input { width: 86px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
  user-select: none;
}
.chip input { display: none; }
.chip:has(input:checked) { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  padding: 22px 28px 10px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.card.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { box-shadow: 0 0 0 3px var(--accent); } }

.photo {
  position: relative;
  aspect-ratio: 1;
  background: #fff;
  display: grid;
  place-items: center;
  padding: 14px;
}
.photo img { width: 100%; height: 100%; object-fit: contain; transition: transform .25s ease; }
.card:hover .photo img { transform: scale(1.04); }
.photo .none { color: #bbb; font-size: 12px; }
.badges { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.66);
  color: #fff;
}
.badge.ad { background: var(--accent); }
.delta {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.delta.down { color: var(--down); background: var(--down-bg); }
.delta.up { color: var(--up); background: var(--up-bg); }

.body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 14px; flex: 1; border-top: 1px solid var(--line); }
.title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.9em;
}
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.stars { color: var(--star); letter-spacing: -1px; }
.price { margin-top: auto; padding-top: 4px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price b { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.price b small { font-size: 13px; font-weight: 600; }
.price s { color: var(--muted); font-size: 12px; }
.ship { font-size: 12px; color: var(--muted); }
.foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 4px; }
.foot .seller { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smart { color: var(--blue); font-weight: 700; font-size: 11px; }
.super { color: var(--accent); font-size: 11px; font-weight: 600; }

#sentinel { height: 40px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; font-size: 15px; }

@media (max-width: 640px) {
  .top, .bar { padding-left: 14px; padding-right: 14px; }
  .grid { padding: 14px; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .price b { font-size: 18px; }
}

/* --- podgląd oferty --- */
dialog#preview {
  width: min(1040px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  overflow: auto;
}
dialog#preview[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
dialog#preview::backdrop { background: rgba(10,10,12,.55); backdrop-filter: blur(3px); }
.pv {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  grid-template-areas: "photo info" "hist hist";
}
#preview .x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  z-index: 2;
}
#preview .x:hover { color: var(--text); border-color: var(--muted); }
.pv-photo { grid-area: photo; background: #fff; display: grid; place-items: center; padding: 28px; aspect-ratio: 1; border-right: 1px solid var(--line); }
.pv-photo img { width: 100%; height: 100%; object-fit: contain; }
.pv-info { grid-area: info; padding: 28px 30px 24px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pv-cat { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding-right: 40px; }
.pv-info h2 { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 600; padding-right: 30px; }
.pv-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pv-tags .badge { position: static; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; }
.tag.smart { color: var(--blue); }
.tag.super { color: var(--accent); }
.pv-price { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.pv-price b { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pv-price .delta { position: static; }
.pv-price s { color: var(--muted); }
.pv-ship { color: var(--muted); font-size: 13px; }
.go {
  align-self: flex-start;
  margin: 6px 0 4px;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}
.go:hover { filter: brightness(1.08); }
.pv dl { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 6px 0 0; font-size: 13px; }
.pv dt { color: var(--muted); }
.pv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pv code { font: 12px ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); }
.pv-hist { grid-area: hist; padding: 20px 30px 26px; border-top: 1px solid var(--line); }
.pv-hist h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pv-hist svg { display: block; overflow: visible; }
.pv-hist svg text { fill: var(--muted); font-size: 11px; }
.pv-hist .grid { stroke: var(--line); }
.pv-hist .series { fill: none; stroke: var(--blue); stroke-width: 2; }
.pv-hist .mark { fill: var(--blue); stroke: var(--card); stroke-width: 2; }
.pv-hist .cross { stroke: var(--muted); stroke-dasharray: 3 3; }
.pv-hist table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 13px; }
.pv-hist th, .pv-hist td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.pv-hist th { color: var(--muted); font-weight: 500; }
.pv-hist .num { text-align: right; font-variant-numeric: tabular-nums; }
#tip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
@media (max-width: 760px) {
  .pv { grid-template-columns: 1fr; grid-template-areas: "photo" "info" "hist"; }
  .pv-photo { border-right: 0; border-bottom: 1px solid var(--line); max-height: 320px; aspect-ratio: auto; }
}

/* --- szukanie po linku --- */
.find { display: flex; align-items: center; gap: 6px; flex: 1; max-width: 560px; margin-left: auto; position: relative; }
.find input { flex: 1; min-width: 0; }
.find button {
  font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 10px; border: 0;
  background: var(--accent); color: #fff; cursor: pointer;
}
.find button:hover { filter: brightness(1.08); }
.find-msg { position: absolute; top: 100%; left: 2px; margin-top: 4px; font-size: 12px; color: var(--up); white-space: nowrap; }
.pv-missing { position: relative; padding: 34px 36px 30px; display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
.pv-missing h2 { margin: 0; font-size: 20px; padding-right: 30px; }
.pv-missing p { margin: 0; }
dialog#preview:has(.pv-missing) { width: min(560px, calc(100vw - 40px)); }
.find button:disabled { opacity: .7; cursor: progress; }
.pv-note { font-size: 12.5px; padding: 7px 10px; border-radius: 8px; margin-bottom: 10px; background: var(--bg); color: var(--muted); }
.pv-note.ok { background: color-mix(in srgb, var(--down) 12%, var(--card)); color: var(--down); }
.pv-note.warn { background: color-mix(in srgb, #e8a400 16%, var(--card)); color: var(--text); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin-top: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
