/* АРТБУКЕТ — Telegram Mini App
   Палитра салона: тёплый кремовый фон, глубокий графит, приглушённая роза. */

:root {
  --bg: #faf7f4;
  --surface: #ffffff;
  --ink: #23201e;
  --ink-soft: #7a716b;
  --line: #ebe4dd;
  --accent: #b2506a;
  --accent-soft: #fceff2;
  --ok: #3f7d58;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(35, 32, 30, .05), 0 8px 24px rgba(35, 32, 30, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171514;
    --surface: #211e1d;
    --ink: #f2ede9;
    --ink-soft: #a2978f;
    --line: #322d2b;
    --accent: #e08aa2;
    --accent-soft: #35242a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }

.view { padding: 0 16px calc(96px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.view--center { display: grid; place-items: center; min-height: 100dvh; }

/* ─── Шапка ──────────────────────────────────────────────── */
.masthead {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 20px 0 14px;
}
.masthead h1 {
  margin: 0; font-size: 22px; letter-spacing: .14em; font-weight: 600;
  font-family: Georgia, "Times New Roman", serif;
}
.masthead p { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-soft); }

.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  width: 40px; height: 40px; font-size: 17px; flex: none;
}

.subhead { display: flex; align-items: center; gap: 8px; padding: 14px 0 8px; }
.subhead h2 { margin: 0; font-size: 18px; font-weight: 600; }
.back {
  border: none; background: none; font-size: 30px; line-height: 1;
  padding: 0 6px 4px 0; color: var(--ink-soft);
}

/* ─── Чипсы ──────────────────────────────────────────────── */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 9px 15px; font-size: 14px; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.chip--sm { padding: 7px 13px; font-size: 13px; }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip:disabled { opacity: .4; }

/* ─── Сетка товаров ──────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); position: relative; text-align: left;
  border: none; padding: 0; display: flex; flex-direction: column;
}
.card__img { aspect-ratio: 3 / 4; width: 100%; object-fit: cover; background: var(--line); }
.card__body { padding: 9px 11px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card__title { font-size: 13.5px; line-height: 1.3; color: var(--ink-soft); }
.card__foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; }

.price { font-weight: 600; font-size: 15px; white-space: nowrap; }
.price--lg { font-size: 20px; }

.add {
  border: none; background: var(--accent); color: #fff; border-radius: 10px;
  width: 30px; height: 30px; font-size: 19px; line-height: 1; flex: none;
  display: grid; place-items: center; padding: 0;
}
.add.is-in { background: var(--ok); }

.badge {
  position: absolute; top: 9px; left: 9px; background: var(--accent-soft);
  color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: .04em;
  padding: 4px 8px; border-radius: 999px;
}

.empty { text-align: center; color: var(--ink-soft); padding: 40px 20px; }

.fineprint {
  margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line);
  color: var(--ink-soft); font-size: 12.5px;
}
.fineprint p { margin: 0 0 5px; }

/* ─── Корзина ────────────────────────────────────────────── */
.row {
  display: flex; gap: 12px; align-items: center; padding: 12px;
  background: var(--surface); border-radius: var(--radius); margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.row img { width: 56px; height: 72px; object-fit: cover; border-radius: 10px; flex: none; }
.row__main { flex: 1; min-width: 0; }
.row__title { font-size: 14px; margin-bottom: 4px; }

.qty { display: flex; align-items: center; gap: 10px; }
.qty button {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); font-size: 16px; line-height: 1; padding: 0;
}
.qty span { min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; }

.totals {
  background: var(--surface); border-radius: var(--radius); padding: 14px;
  margin-top: 14px; box-shadow: var(--shadow);
}
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.totals .muted { color: var(--ink-soft); }
.totals .sum { font-weight: 600; font-size: 17px; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }
.totals .note { color: var(--ok); font-size: 12.5px; }

/* ─── Форма ──────────────────────────────────────────────── */
.block { border: none; padding: 0; margin: 0 0 22px; }
.block legend {
  padding: 0 0 10px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .09em; color: var(--ink-soft);
}

.segmented { display: flex; gap: 8px; margin-bottom: 12px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center; padding: 11px 8px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-size: 14px;
}
.segmented input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.field em { font-style: normal; opacity: .65; }
.field input, .field textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit; resize: vertical;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.checkbox { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; margin-bottom: 12px; }
.checkbox input { margin-top: 2px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }

.hint { font-size: 13px; color: var(--ink-soft); margin: 0 0 12px; }
.error {
  background: var(--accent-soft); color: var(--accent); padding: 11px 13px;
  border-radius: 12px; font-size: 13.5px; margin: 0 0 12px;
}

.primary {
  width: 100%; border: none; border-radius: 14px; background: var(--accent);
  color: #fff; padding: 15px; font-size: 16px; font-weight: 600;
}
.primary:disabled { opacity: .5; }

/* ─── Нижняя кнопка корзины (вне Telegram) ───────────────── */
.cartbar[hidden] { display: none; }
.cartbar {
  position: fixed; left: 16px; right: 16px; bottom: calc(14px + var(--safe-b));
  max-width: 608px; margin: 0 auto; border: none; border-radius: 14px;
  background: var(--accent); color: #fff; padding: 15px; font-size: 15px;
  font-weight: 600; box-shadow: 0 8px 24px rgba(178, 80, 106, .3); z-index: 40;
  display: flex; justify-content: space-between; gap: 12px;
}

/* ─── Карточка товара ────────────────────────────────────── */
.sheet[hidden] { display: none; }
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }
.sheet__panel {
  position: relative; width: 100%; max-width: 640px; margin: 0 auto;
  background: var(--surface); border-radius: 22px 22px 0 0; overflow: hidden;
  max-height: 92dvh; overflow-y: auto; animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }

.sheet__panel img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.sheet__close {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 34px; height: 34px;
  border-radius: 50%; border: none; background: rgba(255, 255, 255, .92); color: #23201e;
  font-size: 22px; line-height: 1; padding: 0;
}
.sheet__body { padding: 16px 16px calc(20px + var(--safe-b)); }
.sheet__body h3 { margin: 0 0 4px; font-size: 19px; }
.sheet__size { margin: 0 0 10px; font-size: 13px; color: var(--ink-soft); }
.sheet__desc { margin: 0 0 18px; color: var(--ink-soft); font-size: 14px; }
.sheet__foot { display: flex; align-items: center; gap: 14px; }
.sheet__foot .primary { width: auto; flex: 1; }

/* ─── Заказы ─────────────────────────────────────────────── */
.order {
  background: var(--surface); border-radius: var(--radius); padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow);
}
.order__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.order__status { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.order__items { font-size: 13.5px; color: var(--ink-soft); }

.done { text-align: center; padding: 20px; max-width: 360px; }
.done__mark { font-size: 54px; margin-bottom: 10px; }
.done h2 { margin: 0 0 8px; }
.done p { color: var(--ink-soft); margin: 0 0 24px; }
