/* ============ токены ============ */
:root {
  --bg:        #fbf4ee;
  --bg-soft:   #f4e7db;
  --card:      #ffffff;
  --text:      #2a1a12;
  --muted:     #8b7264;
  --line:      rgba(42, 26, 18, .09);
  --accent:    #b4622d;
  --accent-2:  #e0913f;
  --accent-ink:#ffffff;
  --danger:    #c0392b;
  --shadow:    0 10px 30px rgba(90, 52, 28, .12);
  --shadow-sm: 0 2px 10px rgba(90, 52, 28, .08);
  --radius:    20px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --bg:        #15100d;
  --bg-soft:   #1e1712;
  --card:      #221a15;
  --text:      #f6ece4;
  --muted:     #a48d7e;
  --line:      rgba(255, 240, 230, .10);
  --accent:    #e8894a;
  --accent-2:  #f0b25f;
  --accent-ink:#20140c;
  --danger:    #ff7a6b;
  --shadow:    0 10px 30px rgba(0, 0, 0, .45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .35);
}

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

/* авторские display:flex перебивают браузерный [hidden] — возвращаем ему силу */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding-bottom: calc(96px + var(--safe-b));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
body.is-locked { overflow: hidden; }

h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }

/* ============ шапка ============ */
.hero {
  position: relative;
  padding: 18px 16px 0;
  background: linear-gradient(160deg, var(--bg-soft), var(--bg) 70%);
  overflow: hidden;
}
.hero__glow {
  position: absolute; inset: -60% 40% auto -20%; height: 220px;
  background: radial-gradient(circle, rgba(224, 145, 63, .35), transparent 65%);
  filter: blur(10px); pointer-events: none;
}
.hero__inner { position: relative; display: flex; align-items: center; gap: 12px; }
.hero__brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.hero__logo {
  display: grid; place-items: center; width: 46px; height: 46px; flex: none;
  font-size: 24px; border-radius: 16px; box-shadow: var(--shadow-sm);
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
}
.hero__title { font-size: 21px; font-weight: 800; letter-spacing: -.4px; }
.hero__sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.hero__orders {
  width: 42px; height: 42px; flex: none; font-size: 19px; border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.hero__orders:active { transform: scale(.92); }

/* ============ поиск ============ */
.search {
  position: relative; display: flex; align-items: center; gap: 8px;
  margin: 14px 0 4px; padding: 0 14px; height: 44px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow-sm);
}
.search__icon { font-size: 14px; opacity: .6; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 15px;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search__clear { font-size: 14px; color: var(--muted); padding: 4px; }

/* ============ категории ============ */
.chips {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 8px; padding: 12px 16px;
  overflow-x: auto; scrollbar-width: none;
  background: linear-gradient(var(--bg) 75%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 9px 15px; border-radius: 999px; font-size: 14px; font-weight: 600;
  white-space: nowrap; background: var(--card); box-shadow: var(--shadow-sm);
  transition: transform .15s, background .2s, color .2s;
}
.chip:active { transform: scale(.94); }
.chip.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
}

/* ============ сетка товаров ============ */
.grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; padding: 4px 16px 8px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  animation: rise .35s both;
  transition: transform .15s, box-shadow .2s;
}
.card:active { transform: scale(.98); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.card__photo {
  position: relative; aspect-ratio: 1 / .82; display: grid; place-items: center;
  font-size: 52px; text-shadow: 0 8px 18px rgba(0, 0, 0, .18);
}
.card__photo img { width: 100%; height: 100%; object-fit: cover; }
.card__photo::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,.28), transparent 60%);
}
.tone-0 { background: linear-gradient(145deg, #6b4229, #352013); }
.tone-1 { background: linear-gradient(145deg, #c98c4e, #8b5a2b); }
.tone-2 { background: linear-gradient(145deg, #f2a7b3, #d4677f); }
.tone-3 { background: linear-gradient(145deg, #a06cc4, #5f3d8c); }
.tone-4 { background: linear-gradient(145deg, #5f8d9c, #2f5563); }
.tone-5 { background: linear-gradient(145deg, #e8b04b, #c07a1e); }
.tone-6 { background: linear-gradient(145deg, #a9c46c, #4f6f28); }

.card__badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  padding: 4px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .3px; text-transform: uppercase;
  background: rgba(255, 255, 255, .92); color: #2a1a12;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.card__body { display: flex; flex-direction: column; gap: 4px; padding: 11px 12px 12px; flex: 1; }
.card__title { font-size: 14px; font-weight: 700; line-height: 1.25; }
.card__meta { font-size: 11.5px; color: var(--muted); }
.card__bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; }
.card__price { font-size: 15px; font-weight: 800; letter-spacing: -.2px; }

.add {
  width: 34px; height: 34px; flex: none; border-radius: 12px; font-size: 20px; line-height: 1;
  display: grid; place-items: center; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px rgba(180, 98, 45, .35);
  transition: transform .12s;
}
.add:active { transform: scale(.88); }

/* степпер */
.stepper {
  display: flex; align-items: center; gap: 2px; height: 34px; padding: 0 3px;
  border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); animation: pop .18s;
}
@keyframes pop { from { transform: scale(.85); } }
.stepper button { width: 28px; height: 34px; font-size: 18px; color: inherit; }
.stepper button:active { opacity: .6; }
.stepper span { min-width: 20px; text-align: center; font-size: 14px; font-weight: 800; }

/* скелетоны */
.skeleton { border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-sm); overflow: hidden; }
.skeleton__photo { aspect-ratio: 1 / .82; background: var(--bg-soft); }
.skeleton__line { height: 10px; margin: 10px 12px; border-radius: 6px; background: var(--bg-soft); }
.skeleton__line--short { width: 55%; }
.skeleton * { animation: shine 1.2s infinite; }
@keyframes shine { 50% { opacity: .45; } }

/* ============ пусто / подвал ============ */
.empty { padding: 50px 32px; text-align: center; }
.empty__emoji { font-size: 44px; }
.empty__title { margin-top: 10px; font-size: 17px; font-weight: 700; }
.empty__text { margin-top: 4px; font-size: 13.5px; color: var(--muted); }
.legal { padding: 22px 16px 8px; text-align: center; font-size: 12px; color: var(--muted); }

/* ============ плавающая корзина ============ */
.cartbar {
  position: fixed; left: 16px; right: 16px; bottom: calc(14px + var(--safe-b)); z-index: 40;
  display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 16px;
  border-radius: 18px; font-size: 15.5px; font-weight: 700; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 26px rgba(180, 98, 45, .42);
  animation: slideUp .28s cubic-bezier(.2, .8, .3, 1);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(70px); } }
.cartbar:active { transform: scale(.98); }
.cartbar__badge {
  display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px;
  border-radius: 999px; font-size: 13px; font-weight: 800;
  background: rgba(255, 255, 255, .25);
}
.cartbar__text { flex: 1; text-align: left; }

/* ============ шторки ============ */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet__backdrop {
  position: absolute; inset: 0; background: rgba(20, 10, 5, .5);
  backdrop-filter: blur(2px); animation: fade .25s;
}
@keyframes fade { from { opacity: 0; } }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
  padding: 8px 16px calc(24px + var(--safe-b));
  background: var(--bg); border-radius: 24px 24px 0 0; box-shadow: var(--shadow);
  animation: up .3s cubic-bezier(.2, .8, .3, 1);
}
.sheet__panel--product { padding: 8px 0 calc(24px + var(--safe-b)); }
@keyframes up { from { transform: translateY(100%); } }
.sheet.is-closing .sheet__panel { animation: down .22s forwards; }
.sheet.is-closing .sheet__backdrop { animation: fade .22s reverse forwards; }
@keyframes down { to { transform: translateY(100%); } }

.sheet__grip {
  width: 38px; height: 4px; margin: 0 auto 12px; border-radius: 4px;
  background: var(--line);
}
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet__head h2 { font-size: 19px; font-weight: 800; letter-spacing: -.3px; }
.linkbtn { font-size: 13.5px; font-weight: 600; color: var(--muted); }

/* карточка товара в шторке */
.pcard__photo {
  height: 210px; display: grid; place-items: center; font-size: 90px;
  text-shadow: 0 12px 26px rgba(0, 0, 0, .22);
}
.pcard__photo img { width: 100%; height: 100%; object-fit: cover; }
.pcard__body { padding: 16px 16px 0; }
.pcard__title { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.pcard__meta { margin-top: 4px; font-size: 13px; color: var(--muted); }
.pcard__desc { margin-top: 12px; font-size: 14.5px; line-height: 1.5; color: var(--text); opacity: .9; }
.pcard__row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px;
}
.pcard__price { font-size: 24px; font-weight: 800; letter-spacing: -.6px; }

.btn {
  height: 50px; padding: 0 22px; border-radius: 16px; font-size: 15.5px; font-weight: 700;
  color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(180, 98, 45, .35);
  transition: transform .12s;
}
.btn:active { transform: scale(.97); }
.btn--wide { width: 100%; margin-top: 14px; }
.btn--ghost {
  background: var(--card); color: var(--text); box-shadow: var(--shadow-sm);
}

/* ============ корзина ============ */
.cartlist { display: flex; flex-direction: column; gap: 10px; }
.citem {
  display: flex; align-items: center; gap: 12px; padding: 10px;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-sm);
}
.citem__photo {
  width: 52px; height: 52px; flex: none; display: grid; place-items: center;
  border-radius: 13px; font-size: 26px; overflow: hidden;
}
.citem__photo img { width: 100%; height: 100%; object-fit: cover; }
.citem__info { flex: 1; min-width: 0; }
.citem__title { font-size: 14px; font-weight: 700; line-height: 1.3; }
.citem__price { margin-top: 3px; font-size: 12.5px; color: var(--muted); }

.delivery { margin: 18px 0 6px; }
.switch {
  display: flex; gap: 4px; padding: 4px; border-radius: 15px; background: var(--bg-soft);
}
.switch__opt {
  flex: 1; height: 40px; border-radius: 12px; font-size: 14px; font-weight: 600;
  color: var(--muted); transition: background .2s, color .2s;
}
.switch__opt.is-active { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }

.progress { margin-top: 12px; }
.progress__bar { height: 6px; border-radius: 4px; background: var(--bg-soft); overflow: hidden; }
.progress__bar i {
  display: block; height: 100%; border-radius: 4px; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .4s cubic-bezier(.2, .8, .3, 1);
}
.progress__text { margin-top: 7px; font-size: 12.5px; color: var(--muted); }

.totals { margin-top: 16px; padding: 14px 16px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow-sm); }
.totals__row { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.totals__row + .totals__row { margin-top: 8px; }
.totals__row--sum {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 18px; font-weight: 800; color: var(--text);
}

/* ============ форма ============ */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); padding-left: 4px; }
.field input, .field textarea {
  width: 100%; padding: 14px 15px; border: 1.5px solid transparent; border-radius: 15px;
  background: var(--card); box-shadow: var(--shadow-sm); font-size: 15px; outline: 0;
  resize: none; transition: border-color .2s;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field.is-error input, .field.is-error textarea { border-color: var(--danger); }
.summary { margin-top: 4px; padding: 14px 16px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow-sm); font-size: 14px; }
.summary b { font-size: 17px; }
.formerror { font-size: 13px; color: var(--danger); text-align: center; }

/* ============ заказы ============ */
.orders { display: flex; flex-direction: column; gap: 12px; }
.order { padding: 14px 16px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow-sm); }
.order__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.order__id { font-size: 15px; font-weight: 800; }
.order__status { padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--bg-soft); }
.order__items { margin-top: 10px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.order__total { margin-top: 10px; font-size: 15px; font-weight: 800; }

/* ============ успех ============ */
.done {
  position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 32px;
  text-align: center; background: var(--bg); animation: fade .3s;
}
.done__mark { width: 92px; height: 92px; }
.done__mark svg { width: 100%; height: 100%; }
.done__circle {
  stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 152; stroke-dashoffset: 152;
  animation: draw .6s cubic-bezier(.2, .8, .3, 1) forwards;
}
.done__check {
  stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: draw .4s .5s cubic-bezier(.2, .8, .3, 1) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
.done__title { margin-top: 8px; font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.done__text { font-size: 14.5px; color: var(--muted); line-height: 1.5; max-width: 300px; }
.done__mark + .done__title { animation: rise .4s .7s both; }
.done__text, .done .btn { animation: rise .4s .8s both; }
.done .btn { margin-top: 14px; }
