:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #16181d;
  --muted: #5d6470;
  --border: #dde1e7;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --accent-soft: #e0f2ef;
  --super: #0f7a3d;
  --super-bg: #dcf5e5;
  --good: #3b7a14;
  --good-bg: #ecf6df;
  --fair: #4b5563;
  --fair-bg: #eef0f3;
  --high: #a4420b;
  --high-bg: #fdebdc;
  --warn: #8a5a00;
  --warn-bg: #fff2cc;
  --err: #b42318;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 4px 16px rgba(16, 24, 40, .10);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1f232b;
    --text: #e8eaee;
    --muted: #9aa2af;
    --border: #2b303a;
    --accent: #2dd4bf;
    --accent-text: #06201d;
    --accent-soft: #123330;
    --super: #6ee7a0;
    --super-bg: #10311f;
    --good: #a7dc76;
    --good-bg: #1d2e12;
    --fair: #b7bec9;
    --fair-bg: #242933;
    --high: #fdab78;
    --high-bg: #3a2113;
    --warn: #fcd34d;
    --warn-bg: #3a2e0b;
    --err: #f97066;
    --shadow: none;
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--accent); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; width: 100%; }
.muted { color: var(--muted); }

/* ---------- nagłówek ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top-inner { display: flex; align-items: center; gap: 20px; min-height: 60px; }
.logo { font-weight: 700; font-size: 20px; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.logo-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-text); font-size: 17px; }
.top nav { display: flex; gap: 20px; margin-left: auto; flex-shrink: 0; }
.top nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.top nav a:hover { color: var(--text); }
.is-home .search--top { display: none; }
.is-home .top { background: transparent; border-bottom-color: transparent; }
.is-home .top .logo { visibility: hidden; }

/* ---------- pole wyszukiwania ---------- */
.search { display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 10px 18px;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search button { border-radius: 999px; }
.search--top { flex: 1; max-width: 620px; }
.search--home { max-width: 680px; margin: 0 auto; }
.search--home input { font-size: 17px; padding: 14px 22px; box-shadow: var(--shadow-lg); }
.search--home button { padding: 0 26px; font-size: 16px; }

/* ---------- strona startowa ---------- */
.home { text-align: center; padding: 6vh 16px 40px; }
.home-logo { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: clamp(34px, 6vw, 52px); margin: 0 0 8px; letter-spacing: -.02em; }
.home-logo .logo-mark { width: 52px; height: 52px; font-size: 30px; border-radius: 14px; }
.home-tagline { color: var(--muted); margin: 0 auto 28px; max-width: 560px; }
.cats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 20px 0 8px; }
.cat { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.cat[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.suggest { max-width: 820px; margin: 20px auto 0; }
.suggest-title { font-size: 13px; color: var(--muted); margin: 18px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px;
  padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--accent); }
.chip--example { font-style: italic; color: var(--muted); }
.sources-note { color: var(--muted); font-size: 13px; margin-top: 32px; }

/* ---------- wybór z listy ---------- */
.picker-toggle { margin-top: 10px; font-size: 14px; }
.picker {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); text-align: left; margin: 14px auto 0; max-width: 900px;
}
.results .picker { max-width: none; margin: 10px 0 4px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.picker label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.picker input, .picker select {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-height: 38px;
}
.picker select:disabled { opacity: .55; }
.picker-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 14px; }
.criteria-row { display: flex; align-items: flex-start; gap: 12px; }
.criteria-row .chips { flex: 1; }
.filters-btn { padding: 6px 14px; flex-shrink: 0; border-radius: 999px; }
.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

/* ---------- wyniki ---------- */
.results { padding-top: 16px; }
.chips--criteria { justify-content: flex-start; }
.chips--criteria .chip { background: var(--accent-soft); border-color: transparent; cursor: default; }
.fixes { align-self: center; font-size: 13px; color: var(--muted); font-style: italic; }
.chip .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.chip .x:hover { color: var(--text); }
.status { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.src { display: inline-flex; align-items: center; gap: 5px; }
.src .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.src.loading .dot { background: var(--accent); animation: pulse 1s infinite ease-in-out; }
.src.ok .dot { background: var(--super); }
.src.fail .dot { background: var(--err); }
.src.skip .dot { background: var(--muted); }
.progress { color: var(--accent); }
.ext-search { margin-left: auto; font-size: 13px; font-weight: 600; text-decoration: none; }
.ext-search:hover { text-decoration: underline; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .src.loading .dot { animation: none; } }

.toolbar { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; margin: 8px 0 14px; }
.count { margin: 0; font-weight: 600; margin-right: auto; }
.sort { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; }
select, dialog input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-height: 36px;
}
select:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; cursor: pointer; border-radius: 8px; }
.primary { background: var(--accent); color: var(--accent-text); border: 0; padding: 9px 20px; font-weight: 600; }
.link { background: none; border: 0; color: var(--muted); padding: 4px; text-decoration: underline; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.card.fresh { animation: appear .35s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .card.fresh { animation: none; } }
.thumb { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); display: block; overflow: hidden; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.badge { position: absolute; left: 10px; top: 10px; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.src-badge { position: absolute; right: 10px; top: 10px; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; background: rgba(0,0,0,.6); color: #fff; }
.lvl-super { background: var(--super-bg); color: var(--super); }
.lvl-good { background: var(--good-bg); color: var(--good); }
.lvl-fair { background: var(--fair-bg); color: var(--fair); }
.lvl-high { background: var(--high-bg); color: var(--high); }
.lvl-suspicious { background: var(--warn-bg); color: var(--warn); }
.lvl-none { background: var(--fair-bg); color: var(--muted); font-weight: 500; }

.body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.title { margin: 0; font-size: 17px; }
.spec { margin: 0; color: var(--muted); font-size: 14px; }
.price-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.price { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.net { font-size: 12px; color: var(--muted); }
.line { font-size: 13px; color: var(--muted); margin: 0; }
.equip { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 0; }
.equip .bar { flex: 1; max-width: 120px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.equip .bar i { display: block; height: 100%; background: var(--accent); }
.note { font-size: 12px; color: var(--warn); margin: 0; }
.warn-note { font-size: 13px; color: var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 6px 8px; margin: 2px 0 0; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; }
.go { background: var(--accent); color: var(--accent-text); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.report { font-size: 12px; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.foot { border-top: 1px solid var(--border); margin-top: 40px; padding: 20px 0 32px; color: var(--muted); font-size: 13px; }
.foot p { margin: 0 0 8px; max-width: 820px; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; width: min(480px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 6px; font-size: 19px; }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
dialog .actions { display: flex; justify-content: flex-end; gap: 12px; }
.form-msg { margin: 0; min-height: 1.5em; font-size: 14px; }

/* Cloudflare Turnstile: widget musi być wyrenderowany, więc gdy niepotrzebny - stoi poza ekranem;
   gdy Cloudflare prosi o kliknięcie - okienko na środku z przyciemnionym tłem. */
.turnstile-box { position: fixed; left: -10000px; top: 0; }
.turnstile-box.is-active {
  left: 0; right: 0; bottom: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, .45);
}
.turnstile-card {
  background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 22px 22px 18px;
  max-width: 380px; text-align: center; box-shadow: var(--shadow-lg);
}
.turnstile-card h2 { margin: 0 0 6px; font-size: 19px; }
.turnstile-card p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.turnstile-card #turnstile { display: flex; justify-content: center; min-height: 65px; }

.doc { max-width: 780px; padding: 32px 16px; }
.doc h1 { font-size: 28px; margin-top: 0; }
.doc h2 { font-size: 19px; margin-top: 28px; }
.doc code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.doc li { margin-bottom: 6px; }

@media (max-width: 700px) {
  .top-inner { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .is-results .search--top { order: 3; flex-basis: 100%; max-width: none; }
  .top nav { gap: 12px; }
  .logo-text { display: none; }
  .is-home .logo-text { display: inline; }
  .search--home { flex-direction: column; }
  .search--home button { padding: 12px; }
  .toolbar .sort { width: 100%; justify-content: space-between; }
  .picker-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .picker-actions .primary { flex: 1; }
}
