:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f3efeb);
  --text: var(--tg-theme-text-color, #1f1a17);
  --hint: var(--tg-theme-hint-color, #8a817a);
  --link: var(--tg-theme-link-color, #8a4b22);
  --accent: #8a4b22;
  --accent-text: #ffffff;
  --sale: #c62828;
  --ok: #2e7d32;
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--tg-theme-bg-color, #1b1917);
    --bg2: var(--tg-theme-secondary-bg-color, #262220);
    --text: var(--tg-theme-text-color, #f2ede8);
    --hint: var(--tg-theme-hint-color, #a39a92);
    --link: var(--tg-theme-link-color, #e0a070);
    --accent: #b86a36;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
a { color: var(--link); text-decoration: none; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }

.top { position: sticky; top: 0; z-index: 20; display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.top__back { border: 0; background: var(--bg2); width: 38px; height: 38px; border-radius: 50%; font-size: 26px; line-height: 1; padding-bottom: 4px; flex: none; }
.search { flex: 1; }
.search input { width: 100%; height: 38px; border-radius: 19px; border: 0; padding: 0 16px; background: var(--bg2); color: var(--text); font-size: 15px; outline: none; }
.view { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); min-height: 70vh; }
body.has-main .view { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
.loading, .empty { color: var(--hint); text-align: center; padding: 48px 12px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 0 6px; font-size: 11px; color: var(--hint); }
.tabs a.on { color: var(--accent); }
.tabs .ico { font-size: 20px; line-height: 22px; }
.badge { position: absolute; top: 2px; left: 52%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--sale); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

.mainbar { position: fixed; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom)); z-index: 25; padding: 8px 12px; background: var(--bg); border-top: 1px solid var(--line); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 11px 16px; background: var(--bg2); color: var(--text); font-weight: 600; cursor: pointer; }
.btn--main { width: 100%; background: var(--accent); color: var(--accent-text); font-size: 16px; padding: 14px; }
.btn--acc { background: var(--accent); color: var(--accent-text); }
.btn--line { background: transparent; border: 1px solid var(--line); }
.btn[disabled] { opacity: .45; }
.btn--sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 20px 0 10px; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; }
.row-head a { font-size: 14px; }
.hint { color: var(--hint); font-size: 13px; }

.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cat { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 10px 6px; border-radius: var(--radius); background: var(--bg2); color: var(--text); font-size: 13px; line-height: 1.2; }
.cat img { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; background: #fff; }
.cat .n { color: var(--hint); font-size: 11px; }
.list { display: flex; flex-direction: column; }
.list a { display: flex; justify-content: space-between; gap: 10px; padding: 13px 4px; border-bottom: 1px solid var(--line); color: var(--text); }
.list a span:last-child { color: var(--hint); white-space: nowrap; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; border-radius: 16px; padding: 7px 13px; background: var(--bg2); color: var(--text); font-size: 13px; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-text); }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar .count { margin-left: auto; color: var(--hint); font-size: 13px; }
select.btn { appearance: none; -webkit-appearance: none; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cats { grid-template-columns: repeat(4, 1fr); } }
.card { position: relative; display: flex; flex-direction: column; border-radius: var(--radius); background: var(--bg2); overflow: hidden; color: var(--text); }
.card__img { display: block; aspect-ratio: 1; background: #fff; }
.card__img img { width: 100%; height: 100%; object-fit: contain; }
.card.out .card__img img { filter: grayscale(1); opacity: .6; }
.card__b { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px 10px; flex: 1; }
.card__n { font-size: 13px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 3.75em; color: var(--text); }
.price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; font-weight: 700; }
.price s { color: var(--hint); font-weight: 400; font-size: 12px; }
.price.sale b { color: var(--sale); }
.st { font-size: 12px; color: var(--ok); }
.st.no { color: var(--hint); }
.card__buy { margin-top: auto; }
.card__buy .btn { width: 100%; padding: 8px; font-size: 13px; }
.disc { position: absolute; top: 8px; left: 8px; background: var(--sale); color: #fff; font-size: 12px; font-weight: 700; border-radius: 8px; padding: 2px 6px; }
.fav { position: absolute; top: 4px; right: 4px; border: 0; background: rgba(255,255,255,.85); color: #333; width: 32px; height: 32px; border-radius: 50%; font-size: 17px; }
.fav.on { color: var(--sale); }
.more { text-align: center; padding: 16px; color: var(--hint); }
.hscroll { display: grid; grid-auto-flow: column; grid-auto-columns: 44%; gap: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.hscroll::-webkit-scrollbar { display: none; }
@media (min-width: 560px) { .hscroll { grid-auto-columns: 30%; } }

.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 -12px; background: #fff; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: none; width: 100%; aspect-ratio: 1; object-fit: contain; scroll-snap-align: center; }
.dots { display: flex; justify-content: center; gap: 5px; margin: 8px 0; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }
.p-title { font-size: 18px; line-height: 1.3; margin: 8px 0 6px; }
.p-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--hint); font-size: 13px; }
.p-price { display: flex; align-items: baseline; gap: 10px; margin: 12px 0 4px; font-size: 24px; font-weight: 800; }
.p-price s { font-size: 15px; color: var(--hint); font-weight: 400; }
.p-price.sale b { color: var(--sale); }
.p-actions { display: flex; gap: 8px; margin: 12px 0; }
.p-actions .grow { flex: 1; }
.stepper { display: inline-flex; align-items: center; background: var(--bg2); border-radius: 12px; overflow: hidden; }
.stepper button { border: 0; background: transparent; width: 40px; height: 40px; font-size: 20px; }
.stepper span { min-width: 30px; text-align: center; font-weight: 700; }
.p-actions .stepper { flex: 1; justify-content: space-between; }
.box { background: var(--bg2); border-radius: var(--radius); padding: 12px; margin: 12px 0; }
.feat { width: 100%; border-collapse: collapse; font-size: 14px; }
.feat td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.feat td:first-child { color: var(--hint); width: 45%; padding-right: 10px; }
.feat tr:last-child td { border-bottom: 0; }
.desc { font-size: 14px; overflow-wrap: anywhere; }
.desc.cut { max-height: 260px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.desc h2 { font-size: 16px; margin: 14px 0 6px; }
.desc h3 { font-size: 15px; margin: 12px 0 6px; }
.desc table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.desc td, .desc th { border: 1px solid var(--line); padding: 4px 6px; }
.desc img { height: auto; border-radius: 8px; }
.variants { display: flex; flex-direction: column; gap: 6px; }
.variants a { display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 10px; background: var(--bg); color: var(--text); font-size: 13px; }
.variants a.on { outline: 2px solid var(--accent); }

.citem { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.citem img { width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: 10px; flex: none; }
.citem .b { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.citem .n { font-size: 13px; line-height: 1.25; color: var(--text); }
.citem .r { display: flex; justify-content: space-between; align-items: center; }
.citem .del { border: 0; background: none; color: var(--hint); font-size: 13px; padding: 4px; }
.sum { display: flex; justify-content: space-between; padding: 6px 0; }
.sum.total { font-size: 18px; font-weight: 800; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 6px 0 2px; }
.progress i { display: block; height: 100%; background: var(--ok); }

.form label { display: block; font-size: 13px; color: var(--hint); margin: 10px 0 4px; }
.form input, .form textarea, .form select { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 15px; }
.form textarea { min-height: 70px; resize: vertical; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); margin: 6px 0; background: var(--bg); }
.opt input { margin-top: 3px; accent-color: var(--accent); }
.opt.off { opacity: .45; }
.opt small { display: block; color: var(--hint); }
.err { color: var(--sale); font-size: 13px; margin-top: 4px; }

.cmp { overflow-x: auto; margin: 0 -12px; padding: 0 12px; }
.cmp table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.cmp td, .cmp th { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; min-width: 130px; text-align: left; }
.cmp th { position: sticky; left: 0; background: var(--bg); color: var(--hint); font-weight: 400; min-width: 110px; max-width: 120px; }
.cmp tr.diff td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.cmp .hd img { width: 90px; height: 90px; object-fit: contain; background: #fff; border-radius: 8px; display: block; }

.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet__bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.sheet__body { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow-y: auto; background: var(--bg); border-radius: 18px 18px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); }
.sheet__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet__head h2 { margin: 0; }
.fgroup { border-bottom: 1px solid var(--line); padding: 10px 0; }
.fgroup h3 { font-size: 14px; margin: 0 0 8px; }
.fvals { display: flex; flex-wrap: wrap; gap: 6px; }
.fvals .chip small { color: inherit; opacity: .6; margin-left: 4px; }
.frow { display: flex; gap: 8px; }
.frow input { flex: 1; min-width: 0; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.sheet__foot { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 12px 0 4px; background: var(--bg); }
.sheet__foot .btn { flex: 1; }
.switch { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: calc(130px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: rgba(30,26,23,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; text-align: center; }
.note { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); border-radius: 12px; padding: 10px 12px; font-size: 13px; margin: 10px 0; }
.stars { color: #f2a900; letter-spacing: 1px; }
.form label.opt { display: flex; color: var(--text); font-size: 15px; margin: 6px 0; }
.form label.opt input { width: auto; flex: none; padding: 0; }
.banners { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; gap: 10px; }
.banners::-webkit-scrollbar { display: none; }
.banner { flex: none; width: 100%; scroll-snap-align: center; border-radius: var(--radius); overflow: hidden; background: var(--bg2); }
.banner img { display: block; width: 100%; aspect-ratio: 960 / 432; object-fit: cover; }
.banners-small { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.banners-small .banner img { aspect-ratio: 480 / 216; }
.repeat { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.repeat .btn { flex: none; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.pill--blue { background: color-mix(in srgb, #1e6fd9 15%, transparent); color: #1e6fd9; }
.pill--orange { background: color-mix(in srgb, #e08a00 18%, transparent); color: #b86e00; }
.pill--green { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill--gray { background: var(--line); color: var(--hint); }
.me-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.ava { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; flex: none; }
.bonus-card { display: flex; justify-content: space-between; align-items: center; color: var(--text); }
.bonus-card > span { font-size: 22px; color: var(--hint); }
.bonus-sum { font-size: 26px; font-weight: 800; margin: 2px 0; }
.ocard { display: flex; flex-direction: column; gap: 8px; color: var(--text); }
.othumbs { display: flex; gap: 6px; align-items: center; }
.othumbs img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 8px; }
.steps { display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; align-items: center; gap: 10px; color: var(--hint); font-size: 14px; }
.step i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.step.on { color: var(--text); }
.step.on i { background: var(--ok); border-color: var(--ok); }
