/* ============================================================
   Добрый запас чая — Mini App
   Design system (ui-ux-pro-max): minimalist single-column,
   natural green + warm tea accent, Lora / Raleway, soft glass.
   ============================================================ */

:root {
  /* Brand palette — natural green + warm tea */
  --green-900: #14532d;
  --green-700: #1f6b3b;
  --green-600: #15803d;
  --green-500: #22c55e;
  --green-50:  #ecf6ef;

  --tea-700: #9a5b20;
  --tea-600: #b5651d; /* warm clay accent (CTA highlight) */
  --tea-100: #f4e7d6;

  --ink:        #1b2620;
  --ink-soft:   #51605a;
  --ink-faint:  #8a978f;

  --bg:       #f7f4ee; /* warm off-white */
  --surface:  #ffffff;
  --surface-2:#fbf9f5;
  --border:   #e6e1d6;
  --border-strong: #d8d2c4;

  --ozon: #005bff;
  --wb:   #cb11ab;
  --danger: #dc2626;

  --radius-sm: 10px;
  --radius:    16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(20, 40, 30, .06);
  --shadow:    0 6px 24px rgba(20, 50, 35, .10);
  --shadow-lg: 0 14px 50px rgba(20, 50, 35, .18);

  --space: 16px;
  --maxw: 640px;

  --ease: cubic-bezier(.22, .61, .36, 1);

  --font-head: "Lora", Georgia, serif;
  --font-body: "Raleway", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; margin: 0; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top) + 12px) var(--space) 12px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .leaf {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(150deg, var(--green-600), var(--green-900));
  color: #fff; box-shadow: var(--shadow-sm);
}
.brand .leaf svg { width: 22px; height: 22px; }
.brand-text h1 { font-size: 18px; letter-spacing: .2px; }
.brand-text p { margin: 1px 0 0; font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Search ---------- */
.search {
  margin-top: 14px;
  display: flex; align-items: center; gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 15px;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.search:focus-within { border-color: var(--green-500); box-shadow: 0 0 0 3px var(--green-50); }
.search svg { width: 19px; height: 19px; color: var(--ink-faint); flex: none; }
.search input {
  border: none; outline: none; background: none; width: 100%;
  font-size: 15px; color: var(--ink); font-family: inherit;
}
.search input::placeholder { color: var(--ink-faint); }

/* ---------- Category chips ---------- */
.chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 14px var(--space) 4px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: start;
  padding: 8px 15px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--ink-soft); font-size: 14px; font-weight: 600;
  white-space: nowrap;
  transition: all .18s var(--ease);
}
.chip:active { transform: scale(.96); }
.chip.active {
  background: var(--green-700); border-color: var(--green-700);
  color: #fff; box-shadow: var(--shadow-sm);
}

/* ---------- Product grid ---------- */
.grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 13px; padding: 14px var(--space) var(--space);
}
@media (max-width: 360px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), box-shadow .25s var(--ease);
  animation: rise .45s var(--ease) both;
}
.card:active { transform: scale(.97); }
@media (hover: hover) { .card:hover { box-shadow: var(--shadow); transform: translateY(-2px); } }

.card-img {
  position: relative; aspect-ratio: 1 / 1; background: var(--surface-2);
  overflow: hidden;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-img .ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--green-50), var(--tea-100));
  color: var(--green-600); opacity: .55;
}
.card-img .ph svg { width: 46px; height: 46px; }

.fav-btn {
  position: absolute; top: 9px; right: 9px;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.82); backdrop-filter: blur(6px);
  color: var(--ink-soft); box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease);
}
.fav-btn:active { transform: scale(.85); }
.fav-btn svg { width: 18px; height: 18px; }
.fav-btn.on { color: var(--tea-600); }
.fav-btn.on svg { fill: currentColor; }

.badge-out {
  position: absolute; left: 9px; top: 9px;
  background: rgba(27,38,32,.78); color: #fff;
  font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px;
}

.card-body { padding: 11px 12px 13px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.card-cat { font-size: 11.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--green-600); }
.card-name { font-family: var(--font-head); font-size: 15.5px; font-weight: 600; line-height: 1.25; color: var(--ink); }
.card-foot { margin-top: auto; display: flex; align-items: baseline; justify-content: space-between; gap: 6px; padding-top: 4px; }
.card-price { font-weight: 700; font-size: 15.5px; font-variant-numeric: tabular-nums; }
.card-weight { font-size: 12px; color: var(--ink-faint); }

/* ---------- Section title ---------- */
.section-title { padding: 6px var(--space) 0; display: flex; align-items: center; justify-content: space-between; }
.section-title h2 { font-size: 19px; }
.section-title .count { font-size: 13px; color: var(--ink-soft); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 60px 30px; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty svg { width: 52px; height: 52px; color: var(--ink-faint); opacity: .6; }
.empty p { margin: 0; font-size: 15px; }

/* ---------- Product detail sheet ---------- */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 35, 26, .5);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .28s var(--ease);
}
.sheet-scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; left: 50%; bottom: 0; z-index: 61;
  width: 100%; max-width: var(--maxw);
  transform: translate(-50%, 100%);
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  max-height: 92dvh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transition: transform .34s var(--ease);
  -webkit-overflow-scrolling: touch;
}
.sheet.open { transform: translate(-50%, 0); }
.sheet-handle { position: sticky; top: 0; display: grid; place-items: center; padding: 10px 0 4px; background: var(--surface); z-index: 2; }
.sheet-handle span { width: 38px; height: 4px; border-radius: 99px; background: var(--border-strong); }
.sheet-hero { aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.sheet-hero img { width: 100%; height: 100%; object-fit: cover; }
.sheet-hero .ph { width: 100%; height: 100%; display: grid; place-items: center; background: linear-gradient(150deg, var(--green-50), var(--tea-100)); color: var(--green-600); }
.sheet-hero .ph svg { width: 72px; height: 72px; opacity: .5; }
.sheet-body { padding: 18px var(--space) 24px; }
.sheet-cat { font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--green-600); }
.sheet-body h2 { font-size: 25px; margin: 6px 0 10px; }
.sheet-meta { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.sheet-price { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sheet-weight { font-size: 14px; color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--border); padding: 5px 11px; border-radius: 999px; }
.sheet-desc { font-size: 15.5px; line-height: 1.65; color: var(--ink-soft); white-space: pre-line; }

.buy-block { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.buy-label { font-size: 13px; color: var(--ink-faint); text-align: center; margin-bottom: 2px; }
.buy-row { display: flex; gap: 10px; }
.buy-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 15px 14px; border-radius: var(--radius);
  font-weight: 700; font-size: 15.5px; color: #fff;
  transition: transform .14s var(--ease), filter .2s var(--ease);
  min-height: 52px;
}
.buy-btn:active { transform: scale(.97); filter: brightness(1.05); }
.buy-btn.ozon { background: var(--ozon); }
.buy-btn.wb { background: var(--wb); }
.buy-btn svg { width: 19px; height: 19px; }
.buy-btn.disabled { background: var(--border-strong); color: var(--ink-faint); pointer-events: none; }

/* ---------- Chat ---------- */
.chat-wrap { display: flex; flex-direction: column; min-height: calc(100dvh - 78px - env(safe-area-inset-bottom)); }
.chat-head { padding: calc(env(safe-area-inset-top) + 14px) var(--space) 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.chat-head h2 { font-size: 19px; }
.chat-head p { margin: 3px 0 0; font-size: 13px; color: var(--ink-soft); }
.chat-log { flex: 1; padding: 16px var(--space); display: flex; flex-direction: column; gap: 9px; }
.bubble {
  max-width: 80%; padding: 10px 14px; border-radius: 16px;
  font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word;
  animation: rise .3s var(--ease) both;
}
.bubble time { display: block; font-size: 10.5px; opacity: .6; margin-top: 3px; }
.bubble.user { align-self: flex-end; background: var(--green-700); color: #fff; border-bottom-right-radius: 5px; }
.bubble.admin { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.chat-intro { align-self: center; text-align: center; color: var(--ink-soft); font-size: 14px; padding: 26px 24px; max-width: 320px; }
.chat-intro svg { width: 42px; height: 42px; color: var(--green-600); opacity: .7; margin-bottom: 8px; }

.chat-input {
  position: sticky; bottom: calc(78px + env(safe-area-inset-bottom));
  display: flex; gap: 9px; padding: 11px var(--space);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px); border-top: 1px solid var(--border);
}
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid var(--border); background: var(--surface);
  border-radius: 20px; padding: 11px 15px; font: inherit; font-size: 15px; max-height: 120px;
  outline: none; transition: border-color .2s var(--ease);
}
.chat-input textarea:focus { border-color: var(--green-500); }
.chat-send {
  width: 46px; height: 46px; flex: none; border-radius: 50%;
  background: var(--green-700); color: #fff; display: grid; place-items: center;
  transition: transform .14s var(--ease), opacity .2s;
}
.chat-send:active { transform: scale(.9); }
.chat-send:disabled { opacity: .45; }
.chat-send svg { width: 20px; height: 20px; }

/* ---------- Bottom navigation ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--maxw); z-index: 40;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 0 9px; font-size: 11px; font-weight: 600; color: var(--ink-faint);
  position: relative; transition: color .2s var(--ease);
}
.tab svg { width: 23px; height: 23px; transition: transform .2s var(--ease); }
.tab.active { color: var(--green-700); }
.tab.active svg { transform: translateY(-1px); }
.tab .dot {
  position: absolute; top: 7px; right: calc(50% - 19px);
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--tea-600); color: #fff; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center;
}

/* ---------- Misc ---------- */
.view { display: none; }
.view.active { display: block; animation: fade .3s var(--ease); }
.skeleton { background: linear-gradient(100deg, var(--surface-2) 30%, #efece5 50%, var(--surface-2) 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.toast {
  position: fixed; left: 50%; bottom: calc(94px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: all .3s var(--ease); z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
