:root,
:root[data-theme="dark"] {
  --bg: #0f1011;
  --surface: #17191b;
  --surface-2: #1f2225;
  --tile: #e9ecea;
  --line: #2a2e31;
  --text: #eef0ee;
  --muted: #8b9294;
  --accent: #5dcaa5;
  --accent-ink: #04342c;
  --accent-soft: rgba(93, 202, 165, .14);
  --danger: #f09595;
  --shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
:root[data-theme="light"] {
  --bg: #f6f7f6;
  --surface: #ffffff;
  --surface-2: #eef1ef;
  --tile: #f1f3f2;
  --line: #e2e6e4;
  --text: #15191a;
  --muted: #646d70;
  --accent: #0f6e56;
  --accent-ink: #ffffff;
  --accent-soft: rgba(15, 110, 86, .1);
  --danger: #a32d2d;
  --shadow: 0 10px 40px rgba(0, 0, 0, .12);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── Header ─────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 1240px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
}
.logo { font-weight: 600; font-size: 18px; letter-spacing: -.02em; color: var(--text); text-decoration: none; white-space: nowrap; }
.logo span { color: var(--accent); }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; height: 38px;
}
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; height: 100%; }
.search:focus-within { border-color: var(--accent); }
.cur {
  height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 8px;
}
.icon-btn, .cart-btn {
  position: relative; width: 38px; height: 38px; flex: none; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center;
}
.icon-btn svg, .cart-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .moon, :root[data-theme="light"] .sun { display: none; }
.cart-btn { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.count {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--text); color: var(--bg); font-size: 11px; font-weight: 600; display: grid; place-items: center;
}

.cats {
  max-width: 1240px; margin: 0 auto; padding: 0 16px 10px;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cats button {
  flex: none; height: 32px; padding: 0 14px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 500;
}
.cats button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ── Layout ─────────────────────────────── */
.wrap { max-width: 1240px; margin: 0 auto; padding: 12px 16px 40px; }
.eu {
  display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; padding: 8px 12px;
  border-radius: 10px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  font-size: 13px;
}
.eu svg { width: 22px; height: 22px; flex: none; }
.eu b { font-weight: 600; color: var(--accent); }
.eu span { color: var(--text); }
.trust {
  display: flex; gap: 8px 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted);
  padding: 0 0 4px;
}
.trust b { color: var(--text); font-weight: 500; }
.sec { font-size: 15px; font-weight: 600; margin: 14px 0 10px; letter-spacing: -.01em; }
.grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
}
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* ── Product card ───────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  transition: border-color .15s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.thumb {
  aspect-ratio: 16 / 11; border-radius: 8px; overflow: hidden; background: var(--tile);
  border: 0; padding: 0; width: 100%; display: block;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .ph { width: 100%; height: 100%; display: grid; place-items: center; color: #8b9294; font-size: 12px; }
.c-name {
  color: var(--text); text-decoration: none;
  font-weight: 600; font-size: 14px; line-height: 1.25; letter-spacing: -.01em;
}
.c-name:hover { color: var(--accent); }

/* ── Homepage category sections ─────────── */
.group { margin-top: 6px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sec .n { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 4px; }
.see-all { background: none; border: 0; padding: 0; color: var(--accent); font-size: 13px; font-weight: 500; }
.see-all::after { content: " →"; }

/* ── Product page ───────────────────────── */
.pdp-wrap { padding-top: 14px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--accent); }
.crumb span { margin: 0 4px; }
.pdp { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.pdp-img img { width: 100%; height: auto; aspect-ratio: 160 / 110; border-radius: 14px; background: var(--tile); display: block; }
.pdp-info h1 { margin: 2px 0 8px; font-size: 30px; letter-spacing: -.025em; line-height: 1.15; }
.pdp-sum { margin: 0 0 16px; color: var(--muted); font-size: 15px; }
.pdp-label { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.pdp-doses { gap: 6px; }
.pdp .pdp-doses button { height: auto; min-height: 46px; min-width: 72px; padding: 6px 12px; font-size: 15px; font-weight: 600; display: grid; justify-items: start; line-height: 1.2; color: var(--text); }
.pdp .pdp-doses button small { font-size: 11px; font-weight: 400; color: var(--muted); }
.pdp-price {
  margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.pdp-price .price { font-size: 26px; }
.pdp-add { height: 46px; padding: 0 22px; font-size: 15px; }
.pdp-points { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.pdp-points b { color: var(--text); font-weight: 500; }
.pdp-points a { color: var(--accent); }
.pdp-points li::before { content: "✓"; color: var(--accent); margin-right: 8px; }
.pdp-body { max-width: 760px; margin-top: 26px; }
.pdp-sec { border-top: 1px solid var(--line); padding: 16px 0 6px; }
.pdp-sec h2 { margin: 0 0 8px; font-size: 17px; letter-spacing: -.01em; }
.pdp-sec p { margin: 0 0 10px; line-height: 1.6; }
.pdp-sec ul { margin: 0 0 10px; padding-left: 20px; line-height: 1.7; }
.specs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 14px; }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; }
.pdp-ruo { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.c-cat { font-size: 12px; font-weight: 500; color: var(--accent); margin-top: -4px; }
.doses { display: flex; flex-wrap: wrap; gap: 4px; }
.doses button {
  height: 26px; padding: 0 8px; border-radius: 7px; font-size: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
}
.doses button[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.doses button.out { text-decoration: line-through; }
.doses select { width: 100%; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 6px; font-size: 12px; }
.c-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-top: 2px; }
.price { font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.price small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); letter-spacing: 0; }
.add {
  height: 34px; padding: 0 12px; border-radius: 9px; border: 0; flex: none;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13px;
}
.add:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.add.done { background: var(--text); color: var(--bg); }

/* ── Sheets and drawer ──────────────────── */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); }
.sheet, .drawer {
  position: fixed; z-index: 50; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); overflow-y: auto; overscroll-behavior: contain;
}
.sheet {
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  border-radius: 16px; padding: 18px;
}
.drawer {
  top: 0; right: 0; bottom: 0; width: min(420px, 100%); overflow-x: hidden;
  padding: 16px; display: flex; flex-direction: column;
}
.x {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface-2); font-size: 20px; line-height: 1;
}
.d-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.d-head h2 { margin: 0; font-size: 17px; }
.d-head .x { position: static; }

.p-head { display: grid; grid-template-columns: 140px 1fr; gap: 14px; align-items: center; padding-right: 30px; }
.p-head img { width: 140px; height: 140px; object-fit: cover; border-radius: 10px; background: var(--tile); }
.p-cat { margin: 0; font-size: 12px; color: var(--accent); font-weight: 500; }
.p-head h2 { margin: 2px 0 6px; font-size: 20px; letter-spacing: -.02em; }
.p-coa { font-size: 13px; color: var(--accent); }
.p-vars { margin-top: 14px; display: grid; gap: 6px; }
.var {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.var b { font-weight: 600; }
.var .muted { font-size: 12px; }
.var .price { font-size: 15px; text-align: right; }
.p-note { font-size: 12px; color: var(--muted); margin: 12px 0 0; }

.lines { display: grid; gap: 8px; }
.line {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center;
  padding: 8px; border: 1px solid var(--line); border-radius: 10px;
}
.line img, .line .ph { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--tile); }
.line .nm { font-weight: 600; font-size: 14px; }
.line .sub { font-size: 12px; color: var(--muted); }
.qty { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.qty button { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); line-height: 1; }
.line .lp { font-weight: 600; text-align: right; }
#cartView { flex: 1; display: flex; flex-direction: column; }
.sum { margin-top: auto; padding-top: 14px; display: grid; gap: 6px; position: sticky; bottom: 0; background: var(--surface); }
.row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.row.total { font-size: 16px; padding: 6px 0; border-top: 1px solid var(--line); margin-top: 4px; }
.warn { margin: 4px 0; font-size: 13px; color: var(--danger); }
.primary {
  height: 46px; border: 0; border-radius: 11px; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; font-size: 15px; margin-top: 6px; width: 100%;
}
.primary:disabled { opacity: .45; cursor: not-allowed; }

.co { display: grid; gap: 10px; }
.co label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.co select { width: 100%; height: 40px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 8px; color: var(--text); }
.co select.bad { border-color: var(--danger); }
.qsum { display: grid; gap: 4px; margin-top: 4px; }
.done-msg {
  margin: 4px 0 8px; padding: 12px 16px; border-radius: 10px; font-size: 14px;
  background: var(--accent-soft); border: 1px solid var(--accent);
}
.co input:not([type="checkbox"]) {
  width: 100%; min-width: 0; height: 40px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 10px; color: var(--text);
}
.co input:focus { outline: 0; border-color: var(--accent); }
.co input.bad { border-color: var(--danger); }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chk { display: flex !important; gap: 8px; align-items: flex-start; color: var(--text) !important; }
.chk input { margin-top: 3px; accent-color: var(--accent); }
.back { justify-self: start; background: none; border: 0; padding: 0; color: var(--accent); font-size: 13px; }
.err { margin: 0; color: var(--danger); font-size: 13px; }

.foot { border-top: 1px solid var(--line); text-align: center; padding: 18px 16px 90px; font-size: 12px; color: var(--muted); }
.foot p { margin: 4px 0; }

.mbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30;
  height: 52px; border: 0; border-radius: 14px; padding: 0 16px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow);
}
.mbar-go::after { content: " →"; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── Phones ─────────────────────────────── */
@media (max-width: 640px) {
  .top-in { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .logo { order: 1; flex: 1; }
  .cur { order: 2; height: 34px; }
  .icon-btn, .cart-btn { order: 3; width: 34px; height: 34px; }
  .search { order: 4; flex-basis: 100%; height: 36px; }
  .cats { padding: 0 12px 8px; }
  .wrap { padding: 8px 12px 30px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card { padding: 6px; border-radius: 10px; }
  .c-name { font-size: 13px; }
  .price { font-size: 15px; }
  .add { height: 32px; padding: 0 10px; }
  .c-foot { flex-wrap: wrap; }
  /* Category sections become rows that scroll sideways; the next card peeks in as a hint. */
  .row-scroll {
    display: grid; grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 44%;
    overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding: 0 12px;
    margin: 0 -12px; padding: 0 12px 4px; scrollbar-width: none;
  }
  .row-scroll::-webkit-scrollbar { display: none; }
  .row-scroll > .card { scroll-snap-align: start; }
  .group { margin-top: 2px; }
  .pdp { grid-template-columns: 1fr; gap: 14px; }
  .pdp-info h1 { font-size: 24px; }
  .pdp-price .price { font-size: 22px; }
  .pdp-add { padding: 0 16px; }
  .specs { grid-template-columns: 1fr; gap: 2px; }
  .specs dd { margin-bottom: 8px; }
  .drawer { width: 100%; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .toast { bottom: 80px; }
}
@media (min-width: 641px) { .mbar { display: none !important; } .foot { padding-bottom: 18px; } }
