/* ====== Квиз «Банкротство» — стили 1:1 с Tilda-референсом ====== */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: Manrope, sans-serif;
  background: #fcf3e9;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  margin: 0;
  overflow-x: hidden;
  color: #1e293b;
}

/* ---- Карточка ---- */
.quiz-wrapper {
  width: 480px;
  max-width: 100%;
  height: 560px;
  background: #fff;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

/* ---- Шапка ---- */
.quiz-header {
  background: linear-gradient(135deg, #01aa60 0%, #018a4e 100%);
  padding: 16px 18px 14px;
  color: #fff;
  flex-shrink: 0;
}
.header-top { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}
.avatar-icon { display: flex; line-height: 1; }
.avatar-letter { line-height: 1; }
.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #4ade80;
  border-radius: 50%;
  border: 2px solid #01aa60;
  animation: pulse-dot 2s ease infinite;
}
/* когда статус рисует Lottie — прячем CSS-точку */
.avatar.lottie-online .online-dot { display: none; }
.lottie-online-holder {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  pointer-events: none;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  50% { box-shadow: 0 0 0 4px rgba(74, 222, 128, 0); }
}
.header-info { min-width: 0; }
.header-name { font-size: 16px; font-weight: 700; }
.header-status { font-size: 13px; opacity: 0.9; }

.progress-bar {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 99px;
  height: 4px;
  margin-top: 12px;
  overflow: hidden;
}
.progress-fill {
  background: #fff;
  height: 100%;
  border-radius: 99px;
  width: 20%;
  transition: width 0.4s;
}
.progress-label { font-size: 11px; opacity: 0.65; margin-top: 6px; }

/* ---- Чат ---- */
.chat-area {
  flex: 1 1 0%;
  min-height: 56px;
  overflow-y: auto;
  padding: 18px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background-color: #f7faf8;
}

.bot-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-start;
  max-width: 88%;
  animation: fadeUp 0.3s ease both;
}
.mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #01aa60;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.mini-avatar svg { width: 15px; height: 15px; }

.bubble {
  max-width: 82%;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  animation: fadeUp 0.3s ease both;
  word-break: break-word;
}
.bubble.bot {
  background: #fff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}
.bot-row .bubble.bot { align-self: unset; max-width: 100%; animation: none; }
.bubble.user {
  background: #01aa60;
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  font-weight: 500;
}

/* индикатор «печатает» */
.bubble.typing { background: #fff; align-self: flex-start; padding: 10px 14px; }
.bot-row.typing-row .bubble.typing { align-self: unset; animation: none; }
.lottie-typing { width: 46px; height: 20px; }
/* CSS-fallback точки, если Lottie не загрузился */
.dots { display: flex; gap: 5px; align-items: center; }
.dots span {
  width: 7px; height: 7px;
  background: #7ab89a;
  border-radius: 50%;
  animation: blink 1.2s ease infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ---- Зона вариантов ---- */
.input-zone { flex-shrink: 0; }
/* режим «панель» (вопрос с вариантами): рамка жёсткая, список скроллится внутри,
   кнопка/подсказка/подвал не сдвигаются */
.input-zone.panel {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.input-zone.panel .choices-area {
  flex: 1 1 auto;
  min-height: 0;
}
.choices-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}
.choices-area {
  padding: 8px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.choice-btn {
  background: #fff;
  border: 1.5px solid #b8e8d4;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 14px;
  font-family: Manrope, sans-serif;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.choice-btn:hover { background: #e8f8f1; border-color: #01aa60; }
@media (hover: hover) { .choice-btn:hover { transform: translateX(2px); } }
.choice-btn:active { transform: scale(0.97); background: #e8f8f1; border-color: #01aa60; }
.choice-badge {
  background: #01aa60;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* подсказка над вариантами */
.choices-hint {
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  padding: 0 2px 2px;
}

/* множественный выбор */
.choice-btn.multi { padding-right: 12px; }
.choice-btn .check-box {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: 1.5px solid #cfe9dd;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.choice-btn .check-box svg {
  width: 14px;
  height: 14px;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.choice-btn.multi.selected {
  background: #e8f8f1;
  border-color: #01aa60;
}
.choice-btn.multi.selected .check-box {
  background: #01aa60;
  border-color: #01aa60;
}
.choice-btn.multi.selected .check-box svg { opacity: 1; transform: scale(1); }
.choice-btn.multi:active { transform: scale(0.985); }
.submit-btn.multi-cta { margin-top: 4px; }

/* текстовое поле (имя) */
.text-row {
  display: flex;
  border: 1.5px solid #b8e8d4;
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
  width: 100%;
}
.text-row:focus-within { border-color: #01aa60; }
.text-input {
  flex: 1 1 0%;
  border: none;
  outline: none;
  padding: 13px;
  font-size: 15px;
  font-family: Manrope, sans-serif;
  font-weight: 500;
  color: #1e293b;
  background: transparent;
  min-width: 0;
}
.text-input::placeholder { color: #94a3b8; font-weight: 400; }
@media (max-width: 520px) { .text-input { font-size: 16px; } }

/* ---- Телефон ---- */
.phone-area {
  padding: 8px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  width: 100%;
}
.phone-row {
  display: flex;
  border: 1.5px solid #b8e8d4;
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
  width: 100%;
}
.phone-row:focus-within { border-color: #01aa60; }
.phone-prefix {
  background: #f4fbf7;
  border-right: 1.5px solid #b8e8d4;
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.phone-input {
  flex: 1 1 0%;
  border: none;
  outline: none;
  padding: 13px;
  font-size: 15px;
  font-family: Manrope, sans-serif;
  font-weight: 500;
  color: #1e293b;
  background: transparent;
  min-width: 0;
}
.phone-input::placeholder { color: #94a3b8; font-weight: 400; }

.consent-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.consent-check { width: 19px; height: 19px; flex-shrink: 0; margin-top: 1px; cursor: pointer; accent-color: #01aa60; }
.consent-label { font-size: 12.5px; color: #64748b; line-height: 1.5; }
.consent-label a { color: #01aa60; text-decoration: none; font-weight: 500; }
.consent-label a:hover { text-decoration: underline; }

.submit-btn {
  background: #01aa60;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 15px 20px;
  font-size: 15px;
  font-family: Manrope, sans-serif;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.submit-btn:hover { background: #019954; }
.submit-btn:active { transform: scale(0.98); background: #019954; }
.submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Экран благодарности / тупик ---- */
.thank-you {
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 24px;
  text-align: center;
  animation: fadeUp 0.4s ease both;
}
.ty-icon { width: 96px; height: 96px; }
.ty-title { font-size: 20px; font-weight: 700; color: #1e293b; }
.ty-text { font-size: 14px; color: #64748b; line-height: 1.55; max-width: 320px; }
.ty-phone { font-size: 22px; font-weight: 700; color: #01aa60; letter-spacing: 0.01em; }
.ty-restart {
  margin-top: 6px;
  background: transparent;
  border: 1.5px solid #b8e8d4;
  color: #01aa60;
  border-radius: 12px;
  padding: 11px 18px;
  font-family: Manrope, sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ty-restart:hover { background: #e8f8f1; border-color: #01aa60; }

.thank-you.dead-end .ty-icon { color: #ef4444; }

/* ---- Футер ---- */
.legal-links {
  flex-shrink: 0;
  text-align: center;
  padding: 9px 14px 12px;
  background: #fff;
  font-size: 10px;
  color: #64748b;
  border-top: 1px solid #eef3ef;
  letter-spacing: 0.2px;
  line-height: 1.5;
}
.legal-links a { text-decoration: none; color: inherit; transition: color 0.2s; }
.legal-links a:hover { color: #01aa60; text-decoration: underline; }
.legal-links span.sep { color: #cbd5e0; margin: 0 3px; }
.legal-company { color: #334155; font-weight: 500; }
.legal-phone { margin-top: 1px; }
.legal-phone a { color: #01aa60; font-weight: 700; }
.legal-docs { margin-top: 4px; }
.legal-docs a { color: #94a3b8; white-space: nowrap; }
@media (max-width: 520px) {
  .legal-links { padding: 8px 12px 10px; font-size: 9.5px; }
}

/* ---- Cookie ---- */
.cookie-banner {
  position: fixed;
  bottom: 16px;
  right: 16px;
  max-width: 340px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  z-index: 50;
}
.cookie-banner.hidden { display: none; }
.cookie-text { font-size: 13px; color: #334155; line-height: 1.5; }
.cookie-text a { color: #94a3b8; text-decoration: none; }
.cookie-accept {
  background: #0f0f0f;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-family: Manrope, sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
}
.cookie-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
}

/* ---- Мобильная адаптация (как в референсе) ---- */
@media (max-width: 520px) {
  body { display: block; padding: 0; margin: 0; min-height: 100dvh; }
  .quiz-wrapper {
    max-width: 100%;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    overflow-x: hidden;
  }
  .quiz-header { padding: max(14px, env(safe-area-inset-top)) 12px 12px; }
  .chat-area { padding: 14px 12px 8px; gap: 9px; }
  .bubble { font-size: 13.5px; padding: 10px 13px; max-width: 88%; }
  .choices-area { padding: 8px 12px max(16px, env(safe-area-inset-bottom)); gap: 7px; }
  .choice-btn { padding: 14px 16px; }
  .phone-area { padding: 8px 12px max(16px, env(safe-area-inset-bottom)); }
  .phone-input { font-size: 16px; }
  .consent-check { width: 20px; height: 20px; }
  .submit-btn { padding: 16px 20px; }
  .legal-links { padding: 8px 12px 12px; }

  /* карточка ужимается на высоту cookie-панели, чтобы та не перекрывала кнопки */
  body.cookie-open .quiz-wrapper { height: calc(100dvh - var(--cookie-h, 0px)); }

  /* cookie как нижняя панель во всю ширину */
  .cookie-banner {
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    border-radius: 16px 16px 0 0;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.1);
  }
  .cookie-text { flex: 1 1 180px; font-size: 12.5px; }
  .cookie-accept { flex: 0 0 auto; padding: 11px 22px; }
  .cookie-close { top: 8px; right: 10px; }
}
