:root {
  --bg: #f6f5f0;
  --panel: #fffefb;
  --ink: #23291f;
  --muted: #6d7566;
  --line: #e2e0d6;
  --accent: #4a7c3f;
  --accent-soft: #e8f0e2;
  --warn: #b4552b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(35,41,31,.06), 0 8px 24px rgba(35,41,31,.06);
  --scroll: rgba(35,41,31,.15);
  --scroll-hover: rgba(35,41,31,.32);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16180f;
    --panel: #1e211a;
    --ink: #e8eadf;
    --muted: #9aa38f;
    --line: #2f342a;
    --accent: #8fc178;
    --accent-soft: #2a3324;
    --warn: #e08b5e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
    --scroll: rgba(232,234,223,.16);
    --scroll-hover: rgba(232,234,223,.34);
  }
}

* { box-sizing: border-box; }

/* ---------- posuvníky ----------
   Tenké a nevýrazné. Gutter je rezervovaný pořád, takže se šířka obsahu nemění,
   když posuvník přibude nebo zmizí (filtrování, otevření detailu). */

html, #sidebar, .chips.scroll, .modal-card { scrollbar-gutter: stable; }

* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
#sidebar:hover, .chips.scroll:hover, .modal-card:hover { scrollbar-color: var(--scroll-hover) transparent; }

/* fallback pro prohlížeče bez scrollbar-width */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--scroll);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-hover); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.leaf { font-size: 26px; color: var(--accent); }
.topbar h1 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.sub { margin: 0; font-size: 12px; color: var(--muted); }
.search-wrap { flex: 1; max-width: 520px; }
#q {
  width: 100%; padding: 9px 13px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: inherit; font: inherit;
}
#q:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.ghost-btn {
  display: none; padding: 8px 14px; font: inherit;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: inherit; cursor: pointer;
}

/* ---------- layout ---------- */

main { display: grid; grid-template-columns: 264px 1fr; gap: 22px; padding: 22px; align-items: start; }

#sidebar {
  position: sticky; top: 74px;
  max-height: calc(100vh - 96px); overflow-y: auto;
  padding: 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.filter-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.fgroup { padding: 14px 0; border-top: 1px solid var(--line); }
.fgroup h3 { margin: 0 0 9px; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.hint { text-transform: none; letter-spacing: 0; color: var(--accent); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.scroll { max-height: 190px; overflow-y: auto; }
.chip {
  padding: 4px 10px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: inherit; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .n { opacity: .6; font-size: 11px; margin-left: 4px; }
.chip.on .n { opacity: .8; }

.check { display: flex; align-items: center; gap: 7px; font-size: 13px; margin-top: 8px; cursor: pointer; }
.dual { display: flex; align-items: center; gap: 6px; }
.dual input { width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: inherit; font: inherit; }
.unit { font-size: 12px; color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ---------- results ---------- */

.results-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.sort select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: inherit; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 16px; }

.card {
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.thumb { aspect-ratio: 4/3; background: var(--accent-soft); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.none { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.card-body { padding: 11px 12px 13px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.card h2 { margin: 0; font-size: 14.5px; line-height: 1.3; }
.latin { font-size: 12px; color: var(--muted); font-style: italic; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 7px; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.stock { background: var(--accent); color: #fff; }
.badge.out { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.price { font-weight: 650; font-size: 14px; }
.empty { padding: 60px 0; text-align: center; color: var(--muted); }
.sentinel { padding: 26px 0; text-align: center; color: var(--muted); font-size: 13px; }
.d-loading { padding: 40px 0; text-align: center; color: var(--muted); }
.fatal { grid-column: 1 / -1; max-width: 640px; padding: 24px 26px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.fatal h2 { margin: 0 0 10px; font-size: 17px; }
.fatal p { color: var(--muted); font-size: 14px; }
.fatal a { color: var(--accent); }
.fatal pre, .fatal code { background: var(--accent-soft); color: var(--accent); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.fatal pre { padding: 10px 12px; overflow-x: auto; }

/* ---------- modal ---------- */

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20,24,16,.55); backdrop-filter: blur(2px); }
.modal-card {
  position: relative; z-index: 1;
  width: min(940px, 100%); max-height: 90vh; overflow-y: auto;
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow);
  padding: 26px 28px 30px;
}
.close { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 20px; color: var(--muted); cursor: pointer; }

.d-head { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 720px) { .d-head { grid-template-columns: 1fr; } }
.d-gallery img.main { width: 100%; border-radius: 10px; aspect-ratio: 4/3; object-fit: cover; background: var(--accent-soft); }
.d-thumbs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.d-thumbs img { width: 54px; height: 42px; object-fit: cover; border-radius: 6px; cursor: pointer; opacity: .65; border: 2px solid transparent; }
.d-thumbs img.on, .d-thumbs img:hover { opacity: 1; border-color: var(--accent); }
.d-title { margin: 0 0 2px; font-size: 22px; line-height: 1.2; }
.d-price { font-size: 20px; font-weight: 650; margin: 12px 0 4px; }
.d-facts { list-style: none; margin: 14px 0 0; padding: 0; font-size: 13.5px; }
.d-facts li { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.d-facts b { min-width: 150px; font-weight: 500; color: var(--muted); }
.d-section { margin-top: 26px; }
.d-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 10px; }
.d-desc { font-size: 14.5px; }
.d-desc p { margin: 0 0 10px; }
.d-desc a { color: var(--accent); }
table.vars { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.vars th, table.vars td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.vars th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 500; }
table.vars td.p { font-weight: 600; white-space: nowrap; }
.ok { color: var(--accent); }
.no { color: var(--muted); }
.eshop { display: inline-block; margin-top: 16px; padding: 9px 16px; border-radius: 999px; background: var(--accent); color: #fff; text-decoration: none; font-size: 14px; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .ghost-btn { display: block; }
  #sidebar { position: static; max-height: none; }
  #sidebar[hidden] { display: none; }
  .sub { display: none; }
}
