/* Colors come from the user's Telegram theme (light or dark) — the shop always looks native.
   The fallbacks below are used when the page is opened in a normal browser. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #111418);
  --hint: var(--tg-theme-hint-color, #8a9099);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --line: color-mix(in srgb, var(--text) 10%, transparent);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #17212b; --bg2: #0e1621; --text: #f5f5f5; --hint: #708499;
    --link: #6ab3f3; --btn: #5288c1; --btn-text: #ffffff;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text); }
body { font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding-bottom: 90px; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: var(--text); }
h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--hint); margin: 20px 4px 8px; font-weight: 600; }
.hint { color: var(--hint); }
[hidden] { display: none !important; }

/* top tabs */
.top { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; padding: 8px 12px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 10px; color: var(--hint); font-weight: 600; }
.tabs button.active { background: var(--bg2); color: var(--text); }

main { padding: 12px; max-width: 720px; margin: 0 auto; }
.state { text-align: center; color: var(--hint); padding: 40px 12px; }

/* search & categories */
.search input { width: 100%; border: 0; background: var(--bg); padding: 11px 14px; border-radius: 12px; outline: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 0; background: var(--bg); padding: 7px 14px; border-radius: 999px; white-space: nowrap; color: var(--text); }
.chip.active { background: var(--btn); color: var(--btn-text); }

/* product grid */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--bg); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card.out { opacity: .55; }
.tile { aspect-ratio: 1 / .85; display: grid; place-items: center; font-size: 52px; border: 0; width: 100%; }
.card-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-name { font-size: 14px; line-height: 1.25; min-height: 2.5em; }
.card-row { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.price { font-weight: 700; }
.add { border: 0; background: var(--btn); color: var(--btn-text); width: 34px; height: 34px; border-radius: 10px; font-size: 20px; line-height: 1; }
.out-label { font-size: 12px; color: var(--hint); }

/* quantity stepper */
.stepper { display: inline-flex; align-items: center; background: var(--bg2); border-radius: 10px; }
.stepper button { border: 0; background: transparent; width: 32px; height: 32px; font-size: 18px; color: var(--link); }
.stepper span { min-width: 22px; text-align: center; font-weight: 600; }

/* sheet */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet-card { position: relative; width: 100%; max-width: 560px; background: var(--bg); border-radius: 18px 18px 0 0; padding: 0 0 20px; animation: up .2s ease-out; max-height: 90vh; overflow: auto; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-card .tile { aspect-ratio: 16 / 9; font-size: 84px; border-radius: 18px 18px 0 0; }
.sheet-body { padding: 14px 16px 0; }
.sheet-body p { color: var(--hint); margin: 6px 0 14px; }
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* cart */
.line { display: flex; align-items: center; gap: 10px; background: var(--bg); padding: 10px; border-radius: 12px; margin-bottom: 8px; }
.line .mini { width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center; font-size: 24px; flex: none; }
.line .info { flex: 1; min-width: 0; }
.line .info div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.options { display: grid; gap: 8px; }
.option { display: flex; gap: 10px; align-items: center; background: var(--bg); padding: 12px; border-radius: 12px; border: 2px solid transparent; text-align: left; width: 100%; }
.option.active { border-color: var(--btn); }
.option .grow { flex: 1; }
.option small { display: block; color: var(--hint); }
.form { display: grid; gap: 8px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--hint); }
.form input { background: var(--bg); border: 1px solid transparent; border-radius: 12px; padding: 11px 12px; outline: none; }
.form input:focus { border-color: var(--btn); }
.form input.invalid { border-color: var(--danger); }
.totals { background: var(--bg); border-radius: 12px; padding: 12px; margin-top: 16px; display: grid; gap: 4px; }
.totals div { display: flex; justify-content: space-between; }
.totals .sum { font-weight: 700; font-size: 17px; padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; }
.free { color: #2e9d4f; font-weight: 600; }
.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); padding: 10px 12px; border-radius: 12px; }
.note { background: var(--bg); padding: 10px 12px; border-radius: 12px; color: var(--hint); font-size: 13px; }

/* orders */
.order { background: var(--bg); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.order-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.status { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--bg2); }
.status.paid, .status.shipped { color: var(--link); }
.status.done { color: #2e9d4f; }
.status.cancelled { color: var(--danger); }
.order small { color: var(--hint); }

/* admin */
.arow { display: flex; align-items: center; gap: 8px; background: var(--bg); padding: 8px 10px; border-radius: 12px; margin-bottom: 6px; }
.arow .mini { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-size: 18px; flex: none; }
.arow .name { flex: 1; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arow input[type=number] { width: 78px; border: 1px solid var(--line); background: var(--bg2); border-radius: 8px; padding: 6px; }
.arow label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--hint); }
.arow .save { border: 0; background: var(--btn); color: var(--btn-text); border-radius: 8px; padding: 6px 10px; font-size: 13px; }

/* misc */
.center { text-align: center; padding-top: 40px; }
.big { font-size: 64px; }
.btn { border: 0; background: var(--btn); color: var(--btn-text); padding: 12px 20px; border-radius: 12px; font-weight: 600; margin-top: 16px; }
.fab { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20; border: 0; background: var(--btn); color: var(--btn-text); padding: 15px; border-radius: 14px; font-weight: 700; max-width: 696px; margin: 0 auto; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.fab:disabled { opacity: .6; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: rgba(20,20,20,.88); color: #fff; padding: 9px 16px; border-radius: 999px; z-index: 40; font-size: 14px; max-width: 90%; text-align: center; }
