:root {
  --ink: #1d1b1a;
  --muted: #7a7472;
  --line: #e8e3df;
  --bg: #faf7f4;
  --card: #ffffff;
  --accent: #a34b5e;
  --accent-soft: #f6ecee;
  --ok: #2f6b45;
  --radius: 14px;
  --chat-w: 396px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; }

.demo-banner {
  background: #241f1d; color: #f3e9e6; font-size: 11.5px; text-align: center;
  padding: 6px 12px; letter-spacing: 0.01em;
}

/* ---------- topbar ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.brand-name { font-weight: 650; font-size: 15px; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; }
.ghost {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  font-size: 13px; color: var(--ink);
}
.ghost:hover { border-color: #cfc6c1; }
.cart-count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 6px;
  background: var(--ink); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 4px;
}

/* ---------- catalog ---------- */
.layout { padding-top: 22px; padding-bottom: 80px; }
.catalog-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
#catalog-title { font-size: 22px; letter-spacing: -0.01em; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px;
  font-size: 12.5px; color: #4a4442;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.result-line { color: var(--muted); font-size: 13px; min-height: 18px; }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: box-shadow 0.15s, transform 0.15s;
}
.card:hover { box-shadow: 0 8px 24px rgba(29, 27, 26, 0.07); transform: translateY(-1px); }
.card.picked { outline: 2px solid var(--accent); outline-offset: -1px; }
.card-pic { position: relative; background: #f2efec; aspect-ratio: 3 / 4; overflow: hidden; cursor: pointer; }
.card-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-badge {
  position: absolute; top: 8px; left: 8px; background: rgba(29,27,26,0.82); color: #fff;
  font-size: 10.5px; padding: 3px 7px; border-radius: 6px;
}
.card-badge.sale { background: var(--accent); }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.card-name { font-size: 13.5px; line-height: 1.35; cursor: pointer; }
.card-name:hover { color: var(--accent); }
.card-meta { font-size: 11.5px; color: var(--muted); }
.card-price { font-weight: 700; font-size: 14px; margin-top: auto; }
.card-price .old { font-weight: 400; color: var(--muted); text-decoration: line-through; font-size: 11.5px; margin-left: 6px; }
.card-actions { display: flex; gap: 6px; margin-top: 6px; }
.card-actions button { flex: 1; }
.btn-cart {
  border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 8px; font-size: 12.5px;
}
.btn-cart:hover { border-color: var(--ink); }
.btn-cart.in { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- chat ---------- */
.chat {
  position: fixed; right: 24px; bottom: 24px; width: var(--chat-w); height: min(72vh, 640px);
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 18px 48px rgba(29, 27, 26, 0.14);
  display: flex; flex-direction: column; z-index: 40; overflow: hidden;
}
.chat[hidden] { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-title { display: flex; gap: 10px; align-items: center; }
.chat-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.chat-status { font-size: 11.5px; color: var(--muted); }
.chat-close { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); }

.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; font-size: 13.5px; line-height: 1.45; }
.msg.user { align-self: flex-end; background: var(--ink); color: #fff; padding: 9px 12px; border-radius: 14px 14px 4px 14px; }
.msg.bot { align-self: flex-start; }
.msg.bot .bubble { background: #f7f4f2; border-radius: 14px 14px 14px 4px; padding: 10px 12px; }
.msg.typing .bubble { display: inline-flex; gap: 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #b9b1ad; animation: blink 1.1s infinite; }
.dot:nth-child(2) { animation-delay: 0.15s; } .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.thumbs { display: flex; gap: 8px; margin-top: 8px; }
.thumb { flex: 1; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; cursor: pointer; }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.thumb div { font-size: 10.5px; padding: 5px 6px; line-height: 1.25; color: #4a4442; }
.routine { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; }
.routine h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.routine-step { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; font-size: 12.5px; border-bottom: 1px dashed #eee9e5; }
.routine-step:last-of-type { border-bottom: 0; }
.routine-step .n { width: 16px; color: var(--muted); font-size: 11px; }
.routine-step .t { flex: 1; }
.routine-step .p { color: var(--muted); font-size: 11.5px; }
.routine-total { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12.5px; font-weight: 600; }
.routine-add { width: 100%; margin-top: 8px; background: var(--ink); color: #fff; border: 0; border-radius: 9px; padding: 8px; font-size: 12.5px; }

.msg-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.msg-actions button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 10px; font-size: 11.5px; }
.msg-meta { margin-top: 6px; font-size: 11px; color: var(--muted); }

.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-input input {
  flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 13.5px;
}
.chat-input input:focus { outline: none; border-color: var(--accent); }
.chat-input button { width: 38px; border: 0; border-radius: 10px; background: var(--ink); color: #fff; font-size: 16px; }

.chat-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 35; background: var(--ink); color: #fff;
  border: 0; border-radius: 999px; padding: 12px 18px; font-size: 13.5px; box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}
.chat:not([hidden]) ~ .chat-fab { display: none; }

/* ---------- overlay / product ---------- */
.overlay { position: fixed; inset: 0; background: rgba(24, 20, 19, 0.45); z-index: 60; display: grid; place-items: center; padding: 20px; }
.overlay[hidden] { display: none; }
.sheet {
  background: #fff; border-radius: 18px; max-width: 880px; width: 100%; max-height: 90vh; overflow: auto;
  display: grid; grid-template-columns: 340px 1fr;
}
.sheet-pic { background: #f2efec; }
.sheet-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet-body { padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.sheet-brand { font-size: 12px; color: var(--muted); }
.sheet-name { font-size: 19px; line-height: 1.3; }
.sheet-price { font-size: 20px; font-weight: 700; }
.sheet-price .old { font-size: 13px; font-weight: 400; color: var(--muted); text-decoration: line-through; margin-left: 8px; }
.sheet-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { font-size: 11.5px; background: #f5f1ee; border-radius: 999px; padding: 4px 9px; color: #4a4442; }
.pill.on { background: #eaf3ec; color: var(--ok); }
.pill.warn { background: #fdf0e6; color: #9a5a1e; }
.sheet-desc { font-size: 13px; color: #4a4442; }
.sheet-sub { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-top: 6px; }
.inci { font-size: 12px; color: #4a4442; background: #faf8f6; border: 1px solid var(--line); border-radius: 10px; padding: 9px; max-height: 130px; overflow: auto; }
.sheet-actions { display: flex; gap: 8px; margin-top: auto; }
.primary { background: var(--ink); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; font-size: 13.5px; }
.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; font-size: 13.5px; }

/* ---------- drawer ---------- */
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 360px; background: #fff; z-index: 70;
  border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: -12px 0 32px rgba(0,0,0,0.08);
}
.drawer[hidden] { display: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.cart-item { display: flex; gap: 10px; align-items: center; }
.cart-item img { width: 52px; height: 66px; object-fit: cover; border-radius: 8px; background: #f2efec; }
.cart-item .t { flex: 1; font-size: 12.5px; line-height: 1.3; }
.cart-item .p { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.cart-item button { border: 0; background: none; color: var(--muted); font-size: 16px; }
.drawer-foot { border-top: 1px solid var(--line); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.drawer-total { font-size: 18px; font-weight: 700; }
.cart-empty { color: var(--muted); font-size: 13px; padding: 20px 0; text-align: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 90;
}
.toast[hidden] { display: none; }

/* ---------- место под докированный чат ---------- */
@media (min-width: 1280px) {
  .layout { padding-right: calc(var(--chat-w) + 56px); }
}
@media (max-width: 1279px) {
  .chat:not(.open) { display: none; }
  .chat.open { display: flex; }
  .chat:not([hidden]) ~ .chat-fab { display: inline-flex; }
  .chat.open ~ .chat-fab { display: none; }
}

/* ---------- mobile ---------- */
@media (max-width: 1180px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .wrap { padding: 0 16px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  #catalog-title { font-size: 19px; }
  .chat {
    right: 0; left: 0; bottom: 0; width: 100%; height: 78vh; border-radius: 18px 18px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
  }
  .chat-fab { right: 16px; left: 16px; bottom: 16px; padding: 14px; text-align: center; }
  .sheet { grid-template-columns: 1fr; max-height: 92vh; }
  .sheet-pic img { aspect-ratio: 4 / 3; }
  .drawer { width: 100%; }
  .topbar-in { height: 58px; }
}

@media (max-width: 520px) {
  .brand-sub { display: none; }
  .brand-name { font-size: 13.5px; }
  .topbar-actions .ghost { padding: 7px 9px; font-size: 12px; }
  .demo-banner { font-size: 10.5px; padding: 5px 10px; }
  .chat-title b { font-size: 13.5px; }
  .sheet-body { padding: 16px; }
  .sheet-name { font-size: 17px; }
}

/* кнопки-ответы на уточняющий вопрос */
.msg-actions.ask button {
  background: #fff; border: 1px solid var(--accent); color: var(--accent); font-weight: 500;
}
.msg-actions.ask button:hover { background: var(--accent-soft); }
