/* Прототип «Умного поиска» — макет «Задайте вопрос — диалог v8». Цвет акцента задаётся одной переменной. */

:root {
  --bg: #FBF3E6;
  --bg-soft: #FFF9F3;
  --ink: #2D241A;
  --ink-soft: #4A3F32;
  --muted: #5C5040;
  --accent: #8C6C33;
  --accent-light: #C19A5B;
  --dark: #2F2418;
  --line: #E6D3AE;
  --line-soft: #E6D8BE;
  --card-line: #EDE3D1;
  --tile: #F7F1E6;
  --bubble: #EFE2C9;
  --link: #7A5C28;
  --underline: #C9B48F;
  --tab-idle: #7A6A55;
  --font: 'Montserrat', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); }
a:hover { color: #4F3B18; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- шапка сайта ------------------------------------------------------------------ */

.site-header { position: sticky; top: 0; z-index: 10; width: 100%; }

.promo {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  background: var(--dark);
  color: #fff;
  font-size: 16px;
  text-align: center;
  text-decoration: none;
}
.promo:hover { color: #E6D3AE; }

.navbar {
  display: flex;
  align-items: stretch;
  min-height: 100px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}

.navbar-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 56px;
  padding: 8px 16px 8px 24px;
}

.burger { display: none; }

.logo { display: block; flex: 0 0 auto; }
.logo img { display: block; width: 104px; height: auto; }

.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 56px; }
.site-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.site-nav a:hover { color: var(--accent); }

.nav-search {
  flex: 0 1 300px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 0 36px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.nav-search input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: .04em;
  color: var(--ink);
  outline: none;
  text-transform: uppercase;
}
.nav-search input::placeholder { color: var(--ink); opacity: 1; }
.nav-search-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  padding: 0;
}

.nav-buy { flex: 0 0 auto; display: flex; align-items: center; padding: 16px 30px; }
.nav-buy a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 148px;
  height: 58px;
  background: var(--accent-light);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: .04em;
  text-align: center;
  text-transform: uppercase;
  text-decoration: none;
}
.nav-buy a:hover { filter: brightness(.94); color: #fff; }

/* --- главная ---------------------------------------------------------------------- */

.home-main { flex: 1 1 auto; }
.home-banner { display: block; width: 100%; height: auto; }

.ask-section {
  width: 100%;
  background: var(--bg);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 56px 24px 60px;
}
.ask-section-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.home-ask { width: 100%; display: flex; flex-wrap: wrap; gap: 0; }
.home-field { flex: 999 1 420px; min-width: 0; gap: 16px; height: 76px; padding: 0 24px; }
.home-field .ask-input { font-size: 20px; }
.home-submit {
  flex: 1 1 180px;
  height: 76px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.home-submit:hover { filter: brightness(.92); }
.home-hint {
  margin: 0;
  max-width: 760px;
  font-size: 16px;
  line-height: 1.55;
  text-align: center;
  color: var(--muted);
}

.choose { width: 100%; background: #9A9A80; padding: 48px 24px 0; height: 300px; overflow: hidden; }
.choose-inner { max-width: 1690px; margin: 0 auto; border: 1px solid #B9B9A3; border-bottom: 0; }
.choose-title {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #B9B9A3;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .14em;
  color: #fff;
}
.choose-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choose-grid div {
  height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .12em;
  text-align: center;
  color: #fff;
}
.choose-grid div:nth-child(n+2) {
  border-left: 1px solid #B9B9A3;
  border-bottom: 1px solid #B9B9A3;
  color: #E4E4D6;
}

/* --- поле вопроса ----------------------------------------------------------------- */

.ask-field {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--accent);
}
.ask-field:focus-within { box-shadow: 0 0 0 3px rgba(140, 108, 51, .25); }
.ask-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 17px;
  color: var(--ink);
}
.ask-input:focus { outline: none; }
.ask-input::placeholder { color: #7A6E5E; opacity: 1; }

/* --- диалог ----------------------------------------------------------------------- */

.dialog { flex: 1 1 auto; width: 100%; padding: 40px 24px 32px; }
.thread {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.msg { display: flex; flex-direction: column; animation: enter .35s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.msg-user { flex-direction: row; justify-content: flex-end; }
.bubble {
  margin: 0;
  max-width: 78%;
  padding: 14px 20px;
  background: var(--bubble);
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.user-avatar { display: none; }

.msg-bot { flex-direction: row; gap: 16px; align-items: flex-start; }
.avatar {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar img { width: 30px; height: auto; }

.bot-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 16px; padding-top: 8px; }
.bot-content { display: flex; flex-direction: column; gap: 16px; }

/* прошлые ответы сворачиваются; «Развернуть» открывает их снова */
.collapsed, .btn-collapse { display: none; }
.msg-bot:not(.is-latest) .suggest { display: none; }
.msg-bot.is-latest .collapsed,
.msg-bot.is-latest .btn-collapse { display: none; }
.msg-bot.is-collapsible:not(.is-latest):not(.is-open) .bot-content { display: none; }
.msg-bot.is-collapsible:not(.is-latest):not(.is-open) .collapsed { display: flex; }
.msg-bot.is-collapsible:not(.is-latest).is-open .btn-collapse { display: inline-flex; }

.collapsed {
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  background: #fff;
  border: 1px solid var(--card-line);
}
.collapsed-info { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-width: 0; }
.collapsed-title { font-size: 14px; font-weight: 600; }
.thumbs { display: flex; gap: 4px; }
.thumbs span, .set-thumbs span {
  width: 36px;
  height: 36px;
  background: var(--tile);
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumbs img, .set-thumbs img { width: 80%; height: 80%; object-fit: contain; }
.set-thumbs span { width: 40px; height: 40px; }

.btn-collapse {
  align-self: flex-start;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.btn-collapse:hover { color: var(--ink); }

.typing { flex-direction: row; align-items: center; }
.typing-text { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.dots { display: flex; gap: 4px; }
.dot {
  display: block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  animation: dot 1s ease-in-out infinite;
}
.dot:nth-child(2) { animation-delay: .15s; }
.dot:nth-child(3) { animation-delay: .3s; }
@keyframes dot {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* --- блоки ответа ----------------------------------------------------------------- */

.block-text p { margin: 0; font-size: 16px; line-height: 1.6; }
.block-text ul {
  margin: 0;
  padding: 0 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 15px;
  line-height: 1.55;
}
.block-text a { font-size: 15px; }

.intro { margin: 0; font-size: 17px; line-height: 1.5; font-weight: 600; }

.cards {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.card { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: #fff; border: 1px solid var(--card-line); }
.card-head { display: flex; gap: 14px; align-items: flex-start; }
.card-img {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  background: var(--tile);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-img img { width: 86%; height: 86%; object-fit: contain; }
.card-heading { display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; min-width: 0; }
.card-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--underline);
  overflow-wrap: anywhere;
}
.card-title:hover { color: var(--ink); }
.card-goal { font-size: 12px; line-height: 1.4; color: var(--muted); }
.card-desc { margin: 0; font-size: 13px; line-height: 1.55; color: var(--ink-soft); }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.btn-accent, .btn-page, .btn-wide, .ask-submit {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
.btn-accent:hover, .btn-page:hover, .btn-wide:hover, .ask-submit:hover { filter: brightness(.92); color: #fff; }
.btn-accent { height: 40px; padding: 0 14px; }
.btn-page, .btn-wide {
  align-self: flex-start;
  height: 48px;
  padding: 0 24px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.btn-page { height: 44px; padding: 0 20px; }

.btn-outline {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--underline);
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--link);
  white-space: nowrap;
}
.btn-outline:hover { border-color: var(--link); }

.card-site {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--link);
  white-space: nowrap;
}
.card-site:hover { color: var(--ink); }

.label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.articles { display: flex; flex-direction: column; gap: 10px; }
.article-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.article {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--card-line);
  text-decoration: none;
  color: var(--ink);
}
.article:hover { border-color: var(--underline); color: var(--ink); }
.article-img { flex: 0 0 72px; width: 72px; height: 54px; object-fit: cover; display: block; background: var(--tile); }
.article span { font-size: 13px; font-weight: 600; line-height: 1.35; }

.detail { background: #fff; border: 1px solid var(--line-soft); display: flex; flex-direction: column; }
.detail-head { padding: 24px; display: flex; flex-wrap: wrap; gap: 24px; }
.detail-img {
  flex: 0 0 180px;
  width: 180px;
  height: 180px;
  background: var(--tile);
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-img img { width: 80%; height: 80%; object-fit: contain; }
.detail-info { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.detail-info h3 { margin: 0; font-size: 22px; font-weight: 600; line-height: 1.25; }
.detail-info p { margin: 0; font-size: 15px; line-height: 1.6; color: var(--ink-soft); }

.tabs { display: flex; flex-wrap: wrap; border-top: 1px solid var(--card-line); padding: 0 24px; gap: 4px 24px; }
.tab {
  height: 48px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--tab-idle);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab-panel { padding: 20px 24px 24px; border-top: 1px solid var(--card-line); }

.substances { display: flex; flex-direction: column; }
.substance {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 0;
  border-bottom: 1px solid var(--card-line);
  font-size: 14px;
  line-height: 1.4;
}
.substance b { flex: 0 0 auto; font-weight: 600; }
.features {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.features li { padding: 16px; background: var(--bg); font-size: 14px; font-weight: 600; line-height: 1.35; }
.how { margin: 0; font-size: 15px; line-height: 1.6; }

.sets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.set {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: #fff;
  border: 1px solid var(--card-line);
  text-align: left;
  color: var(--ink);
}
.set:hover { border-color: var(--underline); }
.set-top { display: flex; flex-direction: column; gap: 16px; padding: 20px; }
.set-title { font-size: 17px; font-weight: 600; line-height: 1.3; }
.set-thumbs { display: flex; gap: 4px; }
.set-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--card-line);
}
.set-count { font-size: 12px; letter-spacing: .04em; color: var(--muted); }
.set-go { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); white-space: nowrap; }

.set-items {
  margin: 0;
  padding: 0 20px;
  list-style: none;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--card-line);
}
.set-item { border-bottom: 1px solid var(--card-line); }
.set-item:last-child { border-bottom: 0; }
.set-item a { display: flex; align-items: center; gap: 20px; padding: 16px 0; text-decoration: none; color: var(--ink); }
.set-item a:hover { color: var(--link); }
.set-item-img {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  background: var(--tile);
  display: flex;
  align-items: center;
  justify-content: center;
}
.set-item-img img { width: 84%; height: 84%; object-fit: contain; }
.set-item-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.set-item-title { font-size: 16px; font-weight: 600; line-height: 1.35; }
.set-item-desc { font-size: 13px; line-height: 1.55; color: var(--ink-soft); }

.block-buy p { margin: 0; font-size: 16px; line-height: 1.6; }
.block-buy { display: flex; flex-direction: column; gap: 16px; }

.disclaimer { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

/* --- кнопки-подсказки -------------------------------------------------------------- */

.suggest { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--underline);
  background: #fff;
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
  color: var(--ink);
}
.chip:hover { border-color: var(--link); background: var(--bg-soft); }
.chip-primary { border-color: var(--accent); background: var(--accent); font-weight: 600; color: #fff; }
.chip-primary:hover { filter: brightness(.92); background: var(--accent); color: #fff; }

/* --- строка ввода внизу ------------------------------------------------------------ */

.ask-bar {
  position: sticky;
  bottom: 0;
  width: 100%;
  background: var(--bg);
  border-top: 1px solid var(--line-soft);
  padding: 16px 24px 18px;
}
.ask-form { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
body[data-page="ask"] .ask-field { height: 64px; padding: 0 8px 0 20px; }
.ask-submit {
  flex: 0 0 auto;
  height: 48px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.ask-form[aria-busy="true"] .ask-submit { opacity: .6; }
.ask-hint { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); text-align: center; }
.hint-short { display: none; }

/* --- узкий экран: шапка переносится ------------------------------------------------ */

@media (max-width: 1279px) {
  .navbar { flex-wrap: wrap; }
  .navbar-main { flex: 1 1 100%; flex-wrap: wrap; justify-content: center; gap: 16px 40px; }
  .nav-search { flex: 1 1 300px; border-top: 1px solid var(--line); }
  .nav-buy { border-top: 1px solid var(--line); }
}

/* --- мобильная версия (макет «диалог v8 мобильная») --------------------------------- */

@media (max-width: 720px) {
  .promo { min-height: 36px; padding: 6px 16px; font-size: 13px; }
  .navbar { min-height: 0; height: 64px; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px 0 4px; }
  .navbar-main { flex: 1 1 auto; flex-wrap: nowrap; justify-content: space-between; gap: 0; padding: 0; }
  .burger {
    display: flex;
    width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
  }
  .logo img { width: 64px; }
  .site-nav, .nav-search input { display: none; }
  .nav-search { flex: 0 0 auto; padding: 0; border: 0; }
  .nav-search-btn { width: 44px; height: 48px; }
  .nav-buy { padding: 0; }
  .nav-buy a { width: auto; height: 40px; padding: 0 12px; font-size: 11px; letter-spacing: .04em; white-space: nowrap; }

  .home-ask { flex-direction: column; gap: 12px; }
  .home-field { flex: 1 1 100%; height: 60px; padding: 0 16px; }
  .home-field .ask-input { font-size: 16px; }
  .home-submit { flex: 1 1 100%; height: 56px; }
  .ask-section { padding: 32px 16px; }
  .home-hint { font-size: 14px; }
  .choose { height: auto; padding: 32px 16px 0; }
  .choose-grid { grid-template-columns: minmax(0, 1fr); }
  .choose-grid div { height: 72px; font-size: 15px; }
  .choose-grid div:nth-child(n+2) { border-left: 0; }
  .choose-grid div:nth-child(3) { border-bottom: 0; }

  .dialog { padding: 20px 16px 24px; }
  .thread { gap: 24px; }
  .msg-user { align-items: flex-end; gap: 8px; }
  .bubble { max-width: 80%; padding: 12px 16px; font-size: 15px; }
  .user-avatar {
    display: flex;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    background: var(--bubble);
  }
  .msg-bot { flex-direction: column; gap: 10px; }
  .avatar { flex-basis: 32px; width: 32px; height: 32px; }
  .avatar img { width: 24px; }
  .bot-body { gap: 14px; }
  .block-text p { font-size: 15px; }
  .block-text ul { padding-left: 18px; font-size: 14px; }
  .intro { font-size: 16px; line-height: 1.45; }
  .cards, .sets { grid-template-columns: minmax(0, 1fr); }
  .collapsed-info { flex-direction: column; align-items: flex-start; gap: 8px; }
  .detail-head { padding: 16px; gap: 16px; }
  .detail-img { flex-basis: 120px; width: 120px; height: 120px; }
  .detail-info h3 { font-size: 20px; }
  .tabs { padding: 0 16px; }
  .tab-panel { padding: 16px; }
  .article-grid { grid-template-columns: minmax(0, 1fr); }

  .ask-bar { padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
  body[data-page="ask"] .ask-field { height: 56px; padding: 0 6px 0 16px; }
  .ask-submit { width: 48px; height: 44px; padding: 0; justify-content: center; }
  .ask-submit-label { display: none; }
  .ask-hint .hint-long { display: none; }
  .hint-short { display: inline; }
}
