:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f2f4);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #7d8085);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --line: rgba(127, 127, 127, .25);
  --danger: #d6453d;
  --r: 14px;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg2); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
.top { padding: 18px 16px 6px; max-width: 720px; margin: 0 auto; }
.top h1 { margin: 0 0 4px; font-size: 24px; }
.hint { margin: 0; color: var(--hint); font-size: 14px; }

main { max-width: 720px; margin: 0 auto; padding: 8px 12px 0; display: grid; gap: 12px; }

.card { background: var(--bg); border-radius: var(--r); overflow: hidden; }
.card-head { display: flex; gap: 10px; align-items: flex-start; padding: 14px 14px 8px; }
.num {
  flex: none; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 14px;
  background: var(--bg2); color: var(--hint); font-size: 13px; font-weight: 600;
  display: grid; place-items: center;
}
.card-title { margin: 0; font-size: 17px; font-weight: 600; flex: 1; overflow-wrap: anywhere; }
.card.has-sel .num { background: var(--accent); color: var(--accent-text); }

.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 14px 8px; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img {
  flex: none; height: 170px; max-width: 80vw; border-radius: 10px; object-fit: cover;
  scroll-snap-align: start; background: var(--bg2); cursor: zoom-in;
}
.gallery img:only-child { width: 100%; max-width: none; }

.desc { padding: 2px 14px 8px; color: var(--hint); font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; }

.variants { padding: 4px 8px 10px; display: grid; gap: 4px; }
.variant {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 8px; border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.variant:active { background: var(--bg2); }
.box {
  flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line);
  display: grid; place-items: center; color: transparent; transition: .12s;
}
.variant.on .box { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.variant.on { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.v-name { flex: 1; overflow-wrap: anywhere; }
.v-price { flex: none; font-weight: 600; white-space: nowrap; }
.v-price.none { color: var(--hint); font-weight: 400; font-size: 14px; }

.admin-row { display: flex; gap: 6px; padding: 8px 12px 12px; border-top: 1px solid var(--line); }
.admin-row .btn { padding: 8px 12px; font-size: 14px; }
.admin-row .grow { flex: 1; }

.adminbar { max-width: 720px; margin: 12px auto 0; padding: 0 12px; display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 0; border-radius: 10px; padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--bg); color: var(--text);
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }

.total {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: none;
}
.total-label { color: var(--hint); font-size: 13px; }
.total-sum { font-size: 24px; font-weight: 700; }

.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.overlay[hidden], .lightbox[hidden] { display: none; }
.panel {
  background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.panel h2 { margin: 0 0 12px; font-size: 19px; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.sum-row small { display: block; color: var(--hint); }
.sum-row b { white-space: nowrap; }
.empty { color: var(--hint); padding: 12px 0; }

/* редактор */
.panel label { display: block; font-size: 13px; color: var(--hint); margin: 14px 0 6px; }
.panel input, .panel textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid transparent; border-radius: 10px; outline: none;
}
.panel input:focus, .panel textarea:focus { border-color: var(--accent); }
.panel textarea { min-height: 90px; resize: vertical; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg2); }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph button {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border: 0; border-radius: 13px;
  background: rgba(0, 0, 0, .65); color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
}
.ph .mv { top: auto; bottom: 4px; right: auto; left: 4px; width: 26px; }
.ph.add { position: relative; display: grid; place-items: center; border: 2px dashed var(--line); color: var(--hint); cursor: pointer; font-size: 13px; text-align: center; padding: 4px; }
.ph.add input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; padding: 0; border: 0; cursor: pointer; font-size: 0; }
.vrow { display: grid; grid-template-columns: 1fr 120px 36px; gap: 6px; margin-bottom: 6px; }
.vrow button { border: 0; border-radius: 10px; background: var(--bg2); color: var(--danger); font-size: 18px; cursor: pointer; }
.panel .actions { display: flex; gap: 8px; margin-top: 18px; }
.panel .actions .btn { flex: 1; background: var(--bg2); }
.panel .actions .btn.primary { background: var(--accent); }

.lightbox { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .nav, .lightbox .close {
  position: absolute; border: 0; background: rgba(255, 255, 255, .18); color: #fff; width: 44px; height: 44px;
  border-radius: 22px; font-size: 22px; cursor: pointer;
}
.lightbox .close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.lightbox .prev { left: 10px; } .lightbox .next { right: 10px; }
.lightbox .cnt { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); color: #fff; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 40;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
}
