:root {
  --bg: var(--tg-theme-bg-color, #f5f4ef);
  --bg-soft: var(--tg-theme-secondary-bg-color, #ebeae3);
  --text: var(--tg-theme-text-color, #1a1a1a);
  --hint: var(--tg-theme-hint-color, #8a8a8a);
  --accent: var(--tg-theme-button-color, #ff6a33);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-bg-color, #ffffff);
  --border: rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  padding-bottom: calc(100px + var(--safe-bottom));
  min-height: 100vh;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: 14px 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.topbar-sub   { margin-top: 4px; font-size: 13px; color: var(--hint); }

.categories {
  position: sticky;
  top: 66px;
  z-index: 9;
  display: flex; gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.categories::-webkit-scrollbar { display: none; }
.category-btn {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 100px;
  background: var(--bg-soft);
  border: 0;
  color: var(--text);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.category-btn.active { background: var(--accent); color: var(--accent-text); }

.menu { padding: 10px 12px 24px; display: flex; flex-direction: column; gap: 22px; }
.section { scroll-margin-top: 130px; }
.section h2 {
  font-size: 20px; font-weight: 700; margin: 4px 4px 10px;
  letter-spacing: -0.02em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.card {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: transform .1s;
}
.card:active { transform: scale(.98); }
.card-img {
  width: 100%; aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #ece9dc, #dcd7c6);
  background-size: cover; background-position: center;
  position: relative;
}
.card-img.no-img::after {
  content: "🍲";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 36px; opacity: .6;
}
.card-body {
  padding: 10px 12px 12px;
  display: flex; flex-direction: column;
  gap: 4px;
  flex: 1;
}
.card-price-row { display: flex; justify-content: space-between; align-items: baseline; }
.card-price { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.card-weight { font-size: 12px; color: var(--hint); }
.card-name { font-size: 14px; line-height: 1.25; margin-top: 2px; }
.card-variants-hint {
  margin-top: 4px;
  font-size: 11px; color: var(--hint);
  display: inline-flex; align-items: center; gap: 4px;
}

.qty-badge {
  position: absolute; top: 8px; right: 8px;
  min-width: 26px; height: 26px; padding: 0 8px;
  border-radius: 13px;
  background: var(--accent); color: var(--accent-text);
  font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.cart-bar {
  position: fixed; left: 0; right: 0;
  bottom: calc(8px + var(--safe-bottom));
  margin: 0 12px;
  padding: 12px 16px;
  background: var(--accent); color: var(--accent-text);
  border-radius: 16px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  z-index: 20;
}
.cart-bar[hidden] { display: none !important; }
.notice[hidden]   { display: none !important; }
.qty-badge[hidden] { display: none !important; }
.cart-summary { font-size: 14px; font-weight: 600; display: flex; gap: 10px; align-items: baseline; }
.cart-total   { font-size: 17px; }
.cart-open {
  background: rgba(255,255,255,.2); color: var(--accent-text);
  border: 0; border-radius: 100px;
  padding: 8px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer;
}

/* Sheets */
.sheet { position: fixed; inset: 0; z-index: 30; display: block; }
.sheet[hidden] { display: none; }
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.35);
  animation: fade .15s ease;
}
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 6px 16px calc(20px + var(--safe-bottom));
  max-height: 85vh; overflow-y: auto;
  animation: slideUp .22s ease;
}
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--hint); opacity: .3;
  border-radius: 2px;
  margin: 6px auto 12px;
}
.sheet-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.sheet-list { display: flex; flex-direction: column; gap: 10px; }

.variant-row, .cart-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--card); border-radius: 14px;
  box-shadow: var(--shadow);
}
.variant-info, .cart-info { flex: 1; min-width: 0; }
.variant-name, .cart-name { font-size: 14px; font-weight: 500; }
.variant-price, .cart-price-row-s {
  margin-top: 2px; font-size: 13px; color: var(--hint);
}
.qty-ctrl {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-soft); border-radius: 100px;
  padding: 4px;
}
.qty-ctrl button {
  width: 28px; height: 28px; border: 0;
  background: var(--card); color: var(--text);
  border-radius: 50%; font-size: 18px; line-height: 1;
  cursor: pointer; font-weight: 600;
}
.qty-ctrl .qty-val { min-width: 22px; text-align: center; font-weight: 600; }

.sheet-submit {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: var(--accent); color: var(--accent-text);
  border: 0; border-radius: 14px;
  font-size: 16px; font-weight: 700;
  cursor: pointer;
}
.sheet-submit:disabled { opacity: .5; }
.sheet-close {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  background: transparent; color: var(--hint);
  border: 0; border-radius: 14px;
  font-size: 14px;
  cursor: pointer;
}

.cart-meta {
  margin-top: 14px; padding: 12px 14px;
  background: var(--bg-soft); border-radius: 12px;
  font-size: 13px;
}
.cart-meta strong { font-weight: 700; }
.cart-meta .progress {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
  margin-top: 8px;
}
.cart-meta .progress > span {
  display: block; height: 100%; background: var(--accent);
  transition: width .3s;
}

.notice {
  position: fixed; left: 12px; right: 12px; top: 12px;
  padding: 12px 14px;
  background: #fff4ce; color: #5a4100;
  border-radius: 12px;
  font-size: 13px;
  z-index: 50;
  box-shadow: var(--shadow);
}

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(100%) } to { transform: translateY(0) } }
@keyframes spin { to { transform: rotate(360deg) } }

.loader {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  z-index: 100;
  color: var(--hint); font-size: 14px;
}
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--bg-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.card-img.lazy-img {
  background: linear-gradient(135deg, #ece9dc, #dcd7c6);
}

@media (max-width: 370px) {
  .grid { grid-template-columns: 1fr 1fr; }
}
