:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #0f0f0f);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --card: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --accent: var(--tg-theme-button-color, #d1442f);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  padding-bottom: 90px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Категории */
#tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
}
#tabs::-webkit-scrollbar { display: none; }

#tabs button {
  flex: 0 0 auto;
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}
#tabs button.active { background: var(--accent); color: var(--accent-text); }

/* Меню */
#menu { padding: 0 12px; }

h3.group {
  margin: 22px 0 10px;
  font-size: 19px;
  font-weight: 600;
}

.item {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--card);
}

.item .photo {
  width: 84px;
  height: 84px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--card);
}

.item .photo.empty {
  display: grid;
  place-items: center;
  color: var(--hint);
  font-size: 26px;
}

.item .name { font-weight: 500; }
.item .desc {
  margin-top: 3px;
  color: var(--hint);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item .price { margin-top: 5px; font-weight: 600; }
.item .tag {
  display: inline-block;
  margin-bottom: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
}

.add {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 20px;
  line-height: 1;
}

.qty { display: flex; align-items: center; gap: 10px; }
.qty button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}
.qty b { min-width: 16px; text-align: center; }

/* Кнопка корзины */
#cart-button {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  padding: 15px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 16px;
  font-weight: 600;
}

/* Шторки */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  max-height: 88vh;
  overflow-y: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: var(--bg);
  animation: up .22s ease;
}
@keyframes up { from { transform: translateY(100%); } }

.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0 0 6px; font-size: 19px; }
.close { border: 0; background: none; color: var(--hint); font-size: 20px; }

#overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, .4);
}

.line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--card);
}
.line .n { flex: 1; }
.line .sum { font-weight: 600; }

.total {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  font-size: 17px;
}

label { display: block; margin-top: 12px; }
label span { display: block; margin-bottom: 5px; color: var(--hint); font-size: 13px; }

input, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--card);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  resize: none;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); }

.primary {
  width: 100%;
  margin-top: 16px;
  padding: 15px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 16px;
  font-weight: 600;
}
.primary:disabled { opacity: .5; }

.note { margin: 12px 0 0; color: var(--hint); font-size: 13px; }
.error { margin: 10px 0 0; color: #e0483c; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
}

#crash {
  margin: 12px;
  padding: 12px;
  border-radius: 10px;
  background: #2b1210;
  color: #ff9d92;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
