/* Палитра задана токенами целиком: тёмная тема переопределяет только их.
   Светлая живёт на голом :root, поэтому у каждого цвета есть значение даже
   когда ни один media-запрос и ни один data-theme не сработал. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #16181d;
  --ink-soft: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #1f5fd6;
  --brand-dark: #1a4fb3;
  --brand-ink: #ffffff;
  --accent: #fef3c7;
  --accent-ink: #92400e;
  --danger: #b42318;
  --online: #4ade80;
  --dots: #c3c8d1;
  --thumb-a: #eef1f5;
  --thumb-b: #e7ebf1;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .25);
  --shadow-brand: 0 8px 24px rgba(31, 95, 214, .35);
}

/* Системная тема — пока пользователь не выбрал своё (тогда стоит data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #12151b;
    --ink: #e8eaee;
    --ink-soft: #b9bfc9;
    --muted: #8b93a1;
    --line: #2a2f39;
    --brand: #6c9bff;
    --brand-dark: #8ab0ff;
    --brand-ink: #0f1115;
    --accent: #3b2f12;
    --accent-ink: #f6d488;
    --danger: #ff8b7d;
    --online: #4ade80;
    --dots: #4b525f;
    --thumb-a: #1b1f27;
    --thumb-b: #222732;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
    --shadow-brand: 0 8px 24px rgba(108, 155, 255, .28);
  }
}

/* Явный выбор пользователя — перекрывает системный. */
:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #12151b;
  --ink: #e8eaee;
  --ink-soft: #b9bfc9;
  --muted: #8b93a1;
  --line: #2a2f39;
  --brand: #6c9bff;
  --brand-dark: #8ab0ff;
  --brand-ink: #0f1115;
  --accent: #3b2f12;
  --accent-ink: #f6d488;
  --danger: #ff8b7d;
  --online: #4ade80;
  --dots: #4b525f;
  --thumb-a: #1b1f27;
  --thumb-b: #222732;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
  --shadow-brand: 0 8px 24px rgba(108, 155, 255, .28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ── Плашка «это демо» ───────────────────────────────────────────── */

.demo-ribbon {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 20px;
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
}

/* ── Шапка ───────────────────────────────────────────────────────── */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 64px;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--brand);
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 22px;
  color: var(--muted);
  font-size: 15px;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Переключатели языка и темы ──────────────────────────────────── */

/* Сегментный переключатель: варианты видны сразу, лишнего клика по меню нет. */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 8px 10px;
  min-width: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--ink); }

.seg button[aria-pressed="true"] {
  background: var(--brand);
  color: var(--brand-ink);
}

.icon-btn {
  color: var(--muted);
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
}

/* ── Герой ───────────────────────────────────────────────────────── */

.hero { padding: 48px 0 8px; }

.hero-inner {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
  align-items: start;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
}

.hero h1 {
  margin: 0 0 12px;
  font-size: 38px;
  line-height: 1.15;
  letter-spacing: -.02em;
}

.lead { margin: 0 0 20px; font-size: 17px; color: var(--ink-soft); max-width: 56ch; }

.cta {
  font: inherit;
  font-weight: 600;
  padding: 13px 24px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: var(--brand-ink);
  cursor: pointer;
}

.cta:hover { background: var(--brand-dark); }

.hint { margin: 10px 0 0; font-size: 14px; color: var(--muted); }

.hero-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.hero-card-title { font-weight: 600; margin-bottom: 12px; }

.feature-list { margin: 0; padding-left: 18px; color: var(--ink-soft); }
.feature-list li { margin-bottom: 8px; }

/* ── Секции ──────────────────────────────────────────────────────── */

.section-title { margin: 44px 0 4px; font-size: 22px; letter-spacing: -.01em; }
.section-note { margin: 0 0 18px; color: var(--muted); font-size: 15px; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.category {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  font-weight: 500;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.product {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Фида без картинок — вместо фото нейтральная заглушка, а не битый <img>. */
.thumb {
  height: 150px;
  background:
    repeating-linear-gradient(45deg, var(--thumb-a) 0 12px, var(--thumb-b) 12px 24px);
}

.product-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-vendor { font-size: 13px; color: var(--muted); }
.product-name { font-weight: 500; line-height: 1.35; }
.product-price { font-size: 18px; font-weight: 600; margin-top: auto; padding-top: 6px; }

.ghost {
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  margin-top: 8px;
}

.ghost:hover { border-color: var(--brand); }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 44px 0;
}

.info {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.info h3 { margin: 0 0 8px; font-size: 17px; }
.info p { margin: 0; color: var(--ink-soft); }

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 24px 0;
  color: var(--muted);
  font-size: 14px;
}

.site-footer p { margin: 0; }

/* ── Виджет чата ─────────────────────────────────────────────────── */

.chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  font: inherit;
  font-weight: 600;
  padding: 14px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-ink);
  cursor: pointer;
  box-shadow: var(--shadow-brand);
}

.chat-launcher:hover { background: var(--brand-dark); }

.chat-launcher-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
}

.chat {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat[hidden] { display: none; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--brand);
  color: var(--brand-ink);
}

.chat-title { font-weight: 600; }
.chat-subtitle { font-size: 13px; opacity: .85; }

.chat-close {
  margin-left: auto;
  font-size: 26px;
  line-height: 1;
  background: transparent;
  border: 0;
  color: var(--brand-ink);
  cursor: pointer;
  padding: 0 4px;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-2);
}

.chat-intro {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink-soft);
  font-size: 15px;
}

.msg {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* Сообщение клиента — сырой текст, переносы держит CSS. Ответ бота приходит
   размеченным, там переносы уже <br>. */
.msg.user { white-space: pre-wrap; }

.msg a { color: inherit; text-decoration: underline; }
.msg.bot a { color: var(--brand); }

.msg p { margin: 0 0 10px; }
.msg > :last-child { margin-bottom: 0; }

.msg ul,
.msg ol { margin: 6px 0; padding-left: 22px; }

.msg li { margin: 2px 0; }

.msg strong { font-weight: 600; }

.msg.user {
  align-self: flex-end;
  background: var(--brand);
  color: var(--brand-ink);
  border-bottom-right-radius: 4px;
}

.msg.bot {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; }

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dots);
  animation: blink 1.2s infinite;
}

.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

@keyframes blink {
  0%, 60%, 100% { opacity: .35; }
  30% { opacity: 1; }
}

.chat-suggests {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
}

.chat-suggests button {
  font: inherit;
  font-size: 13px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand);
  cursor: pointer;
}

.chat-suggests[hidden] { display: none; }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.chat-form input {
  flex: 1;
  font: inherit;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

.chat-form input:focus { border-color: var(--brand); }

.chat-form button {
  font: inherit;
  font-size: 18px;
  width: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: var(--brand-ink);
  cursor: pointer;
}

.chat-form button:disabled { opacity: .5; cursor: default; }

.chat-error {
  padding: 0 14px 12px;
  color: var(--danger);
  font-size: 14px;
}

.chat-error[hidden] { display: none; }

@media (max-width: 860px) {
  .hero-inner { grid-template-columns: 1fr; }
  .nav { display: none; }
  .hero h1 { font-size: 30px; }
  /* Кнопка-заглушка «Корзина» уступает место рабочим переключателям. */
  .icon-btn { display: none; }
}

@media (max-width: 480px) {
  .chat { right: 8px; bottom: 8px; height: calc(100vh - 16px); }
  .chat-launcher { right: 12px; bottom: 12px; }
}
