:root {
  --bg: var(--tg-theme-bg-color, #17212b);
  --bg2: var(--tg-theme-secondary-bg-color, #232e3c);
  --bg3: rgba(255,255,255,0.04);
  --text: var(--tg-theme-text-color, #f1f1f1);
  --hint: var(--tg-theme-hint-color, #7f8b99);
  --link: var(--tg-theme-link-color, #64b5ef);
  --btn: var(--tg-theme-button-color, #5288c1);
  --btn_txt: var(--tg-theme-button-text-color, #fff);
  --danger: #e74c3c;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  min-height: 100%;
}
#app { min-height: 100vh; display: flex; flex-direction: column; }

#hdr {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
#hdr h1 {
  font-size: 17px; margin: 0; flex: 1; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  width: 36px; height: 36px;
  border: none; border-radius: 10px;
  background: var(--bg2); color: var(--text);
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  flex: 0 0 auto;
}
.icon-btn[hidden] { display: none !important; }
.icon-btn:active { opacity: .7; }
#cart_badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff;
  border-radius: 999px; min-width: 18px; height: 18px;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

#view { flex: 1; padding: 14px 12px 100px; }

/* ── HERO карточка ── */
.hero {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, #2c5c8f, #1e3d5f);
  border: none; border-radius: 20px;
  padding: 22px 20px;
  width: 100%; text-align: left;
  color: #fff; cursor: pointer;
  margin-bottom: 16px;
  transition: transform .1s;
}
.hero:active { transform: scale(0.985); }
.hero .hero-emoji { font-size: 40px; line-height: 1; }
.hero .hero-body { flex: 1; min-width: 0; }
.hero .hero-title { font-size: 20px; font-weight: 700; letter-spacing: .2px; }
.hero .hero-sub {
  font-size: 13px; color: #b8d4ef; margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero .hero-arrow { font-size: 24px; color: #b8d4ef; }

/* ── Сетка плиток ── */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tile {
  background: var(--bg2);
  border: none; border-radius: var(--radius);
  padding: 18px 12px 16px;
  text-align: center; color: var(--text);
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  min-height: 118px;
  transition: transform .08s, background .15s;
  overflow: hidden;
  font: inherit;
}
.tile:active { transform: scale(0.97); background: var(--bg3); }
.tile .tile-emoji {
  font-size: 32px; line-height: 1;
  text-align: center;
}
.tile .tile-body {
  flex: 0 1 auto; min-width: 0;
  display: flex; flex-direction: column;
  align-items: center;
  width: 100%;
}
.tile .tile-title {
  font-weight: 600; font-size: 13px; line-height: 1.3;
  color: var(--text);
  text-align: center;
  width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.tile .tile-sub {
  font-size: 11px; color: var(--hint); margin-top: 4px;
  text-align: center;
  width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Категории ── */
.cats {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 4px 0 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  user-select: none;
  touch-action: pan-x;
}
.cats::-webkit-scrollbar { display: none; }
.cats.dragging { cursor: grabbing; }
.cat {
  padding: 8px 14px;
  background: var(--bg2); color: var(--text);
  border: none; border-radius: 999px; font-size: 13px;
  cursor: pointer; white-space: nowrap;
  transition: background .15s;
  flex: 0 0 auto;
}
.cat:active { background: var(--bg3); }
.cat.on { background: var(--btn); color: var(--btn_txt); }

.prod-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.prod {
  background: var(--bg2); border-radius: var(--radius);
  padding: 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  transition: transform .1s;
  overflow: hidden;
}
.prod:active { transform: scale(0.98); }
.prod .emoji { font-size: 30px; }
.prod .pname {
  font-weight: 600; font-size: 13px; line-height: 1.25;
  max-height: 33px;
  overflow: hidden;
}
.prod .brand {
  color: var(--hint); font-size: 11px; min-height: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prod .regs {
  font-size: 12px; letter-spacing: 1px;
  min-height: 16px; opacity: .85;
}
.prod .price {
  color: var(--link); font-weight: 700; font-size: 15px; margin-top: auto;
}

.sheet {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.55);
  display: none; align-items: flex-end;
}
.sheet.show { display: flex; animation: fade .15s; }
.sheet-body {
  background: var(--bg); width: 100%;
  max-height: 88vh; overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 24px;
  animation: slide .22s cubic-bezier(.2,.9,.25,1);
}
@keyframes fade { from { opacity: 0 } }
@keyframes slide { from { transform: translateY(40px); opacity: .6 } }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--hint); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; background: var(--bg2); color: var(--text);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px; padding: 12px;
  font-size: 15px; font-family: inherit;
}
.field input:focus { outline: 1px solid var(--btn); border-color: var(--btn); }

.btn {
  width: 100%; padding: 14px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  margin-top: 8px;
}
.btn-primary { background: var(--btn); color: var(--btn_txt); }
.btn-ghost { background: var(--bg2); color: var(--text); }
.btn-danger { background: rgba(231,76,60,0.15); color: var(--danger); }
.btn:active { opacity: .85; }
.btn:disabled { opacity: .5; cursor: default; }

.row { display: flex; gap: 8px; }
.row .btn { margin-top: 0; }

.cart-item {
  display: flex; gap: 12px; align-items: center;
  padding: 12px; background: var(--bg2);
  border-radius: var(--radius); margin-bottom: 8px;
}
.cart-item .emoji { font-size: 22px; flex: 0 0 auto; }
.cart-item .info { flex: 1; min-width: 0; }
.cart-item .nm {
  font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cart-item .pr { color: var(--hint); font-size: 12px; margin-top: 2px; }
.qty { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.qty button {
  width: 30px; height: 30px; border-radius: 8px;
  border: none; background: var(--bg3); color: var(--text);
  font-size: 16px; cursor: pointer;
}
.qty .q { min-width: 20px; text-align: center; font-weight: 600; }

.empty {
  text-align: center; padding: 60px 20px; color: var(--hint);
}
.empty .big { font-size: 48px; }

.total {
  display: flex; justify-content: space-between;
  padding: 14px 0; font-size: 17px; font-weight: 700;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 12px;
}
.total .sum { color: var(--link); }

.reg-title {
  font-size: 12px; color: var(--hint); text-transform: uppercase;
  letter-spacing: .5px; margin: 14px 0 6px; font-weight: 600;
}
.reg-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.reg-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: var(--bg2);
  border-radius: 999px; font-size: 13px;
}
.reg-pill .flag { font-size: 15px; }
.reg-pill .nm { color: var(--text); }
.reg-none { color: var(--hint); font-size: 13px; }

/* ── FAQ аккордеон ── */
.faq-group-title {
  font-size: 13px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 22px 0 10px;
  font-weight: 600;
  padding-left: 2px;
}
.faq-group-title:first-child { margin-top: 4px; }

.faq-item {
  background: var(--bg2);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
}
.faq-item > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 44px 14px 14px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  position: relative;
  user-select: none;
}
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary::after {
  content: "›";
  position: absolute;
  right: 16px; top: 50%;
  transform: translateY(-50%) rotate(90deg);
  font-size: 18px;
  color: var(--hint);
  transition: transform .18s;
}
.faq-item[open] > summary::after {
  transform: translateY(-50%) rotate(-90deg);
}
.faq-item[open] > summary {
  background: var(--bg3);
}
.faq-item .faq-a {
  padding: 4px 14px 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  border-top: 1px solid rgba(255,255,255,0.06);
}
.faq-item .faq-a h3 {
  font-size: 15px;
  margin: 14px 0 8px;
  font-weight: 700;
  color: var(--text);
}
.faq-item .faq-a h3:first-child { margin-top: 8px; }
.faq-item .faq-a p { margin: 8px 0; }
.faq-item .faq-a ul,
.faq-item .faq-a ol {
  margin: 8px 0;
  padding-left: 22px;
}
.faq-item .faq-a li {
  margin: 4px 0;
  line-height: 1.5;
}
.faq-item .faq-a b { color: var(--text); }
.faq-item .faq-a em { color: var(--hint); }
.faq-soon {
  color: var(--hint);
  font-style: italic;
  font-size: 13px;
  padding: 6px 0 4px;
}