:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f4f2ee);
  --text: var(--tg-theme-text-color, #1d1c1a);
  --hint: var(--tg-theme-hint-color, #85817a);
  --accent: #3f6b4f;
  --accent-text: #ffffff;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.brand { display: flex; align-items: center; gap: 8px; padding: 10px 12px 0; }
.home { flex: none; }
.logo { display: block; width: auto; height: 30px; }
:root[data-theme=dark] .logo { filter: invert(1); }
.hours { font-size: 12px; color: var(--hint); }
.contacts { display: flex; gap: 6px; margin-left: auto; }
.contact {
  padding: 6px 11px; border-radius: 999px; font-size: 13px; line-height: 1.3; text-decoration: none;
  background: var(--bg2); color: var(--text);
}
.contact.main { background: var(--accent); color: var(--accent-text); }

.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: 10px 12px 8px;
}
#search {
  width: 100%; height: 38px; padding: 0 12px; border: 0; border-radius: 10px; outline: 0;
  font-size: 16px; background: var(--bg2); color: var(--text);
}
#search::placeholder { color: var(--hint); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-top: 8px; margin: 0 -12px; padding-inline: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--bg2); font-size: 14px; white-space: nowrap; }
.chip.active { background: var(--accent); color: var(--accent-text); }
.chips.sub { padding-top: 6px; }
.chips.sub .chip { padding: 4px 10px; font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; padding: 4px 12px 96px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card { display: block; text-align: left; min-width: 0; }
.card .photo { position: relative; aspect-ratio: 4 / 5; border-radius: var(--radius); overflow: hidden; background: var(--bg2); }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .price { margin-top: 6px; font-weight: 600; }
.card .name { font-size: 14px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ribbon { position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 8px; font-size: 12px; background: var(--accent); color: var(--accent-text); }
.old { margin-left: 6px; font-weight: 400; color: var(--hint); text-decoration: line-through; }

.status { padding: 24px 16px 96px; margin: 0; text-align: center; color: var(--hint); }
.status:empty { display: none; }

#product-view { padding-bottom: 170px; }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; background: var(--bg2); }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: none; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; scroll-snap-align: center; }
.info { padding: 14px 16px; }
.info h1 { font-size: 20px; line-height: 1.25; margin: 0 0 4px; }
.info .subtitle { margin: 0 0 8px; color: var(--hint); }
.info .price { font-size: 20px; font-weight: 600; margin: 8px 0 12px; }
.info .desc p { margin: 0 0 8px; }
.link-back { display: block; padding: 12px 16px; color: var(--accent); }

.option { margin: 14px 0; }
.option .title { font-weight: 600; margin-bottom: 6px; }
.option .required { color: var(--hint); font-weight: 400; }
.choice { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.choice .extra { margin-left: auto; color: var(--hint); white-space: nowrap; }
.option input[type=text], .option textarea {
  width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; font: inherit; font-size: 16px;
  background: var(--bg2); color: var(--text); outline: 0;
}

.buy {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--bg);
  box-shadow: 0 -1px 0 color-mix(in srgb, var(--hint) 25%, transparent);
}
.qty { display: flex; align-items: center; border-radius: 12px; background: var(--bg2); }
.qty button { width: 40px; height: 46px; font-size: 20px; }
.qty span { min-width: 22px; text-align: center; }
.primary { flex: 1; min-height: 46px; padding: 0 14px; border-radius: 12px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.primary:disabled { opacity: .6; }

#cart-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
#cart-open {
  display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 48px; padding: 0 16px;
  border-radius: 12px; background: var(--accent); color: var(--accent-text); font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
}
body.on-product #cart-bar { bottom: calc(66px + env(safe-area-inset-bottom)); }

/* Ecwid рисует светлую витрину, в тёмной теме Telegram ей нужен свой фон */
#store-view { background: #fff; color: #1d1c1a; min-height: 100vh; }
#store-view.offscreen { position: absolute; left: 0; top: 0; width: 100vw; height: 1px; min-height: 0; overflow: hidden; visibility: hidden; }
/* уведомления Ecwid (баннер куки) сами включают visibility, показываем их на шаге оформления */
#store-view.offscreen .ec-notices { display: none !important; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20; padding: 10px 14px;
  border-radius: 12px; background: rgba(30, 30, 30, .92); color: #fff; text-align: center; pointer-events: none;
}
body.on-product #toast { bottom: calc(142px + env(safe-area-inset-bottom)); }
