.declarant-chat {
  --dc-height: 520px;
  --dc-accent: #2563eb;
  --dc-bg: #ffffff;
  --dc-user: #2563eb;
  --dc-bot: #f1f5f9;
  --dc-text: #0f172a;
  --dc-border: #e2e8f0;
  display: flex;
  flex-direction: column;
  height: var(--dc-height);
  max-width: 760px;
  margin: 0 auto;
  border: 1px solid var(--dc-border);
  border-radius: 16px;
  background: var(--dc-bg);
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.declarant-chat__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--dc-border);
  background: #fff;
}

.declarant-chat__modes {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.declarant-chat__modes::-webkit-scrollbar {
  display: none;
}

.declarant-chat__clear {
  flex: 0 0 auto;
  margin-left: auto;
  border: 1px solid var(--dc-border);
  background: #fff;
  color: #64748b;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.declarant-chat__clear:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.declarant-chat__mode {
  flex: 0 0 auto;
  border: 1px solid var(--dc-border);
  background: #f8fafc;
  color: #475569;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.declarant-chat__mode:hover {
  border-color: var(--dc-accent);
  color: var(--dc-accent);
}

.declarant-chat__mode.is-active {
  background: var(--dc-accent);
  border-color: var(--dc-accent);
  color: #fff;
}

.declarant-chat__log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(180deg, #fafbff 0%, #ffffff 100%);
}

.declarant-chat__msg {
  display: flex;
}

.declarant-chat__msg--user {
  justify-content: flex-end;
}

.declarant-chat__msg--bot,
.declarant-chat__msg--error {
  justify-content: flex-start;
}

/* Подпись режима (в «Авто»): маленький «чип» над ответом. */
.declarant-chat__msg--tag {
  margin-bottom: -6px;
}

.declarant-chat__mode-tag {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid var(--dc-border);
  padding: 3px 10px;
  border-radius: 999px;
}

.declarant-chat__bubble {
  max-width: 80%;
  padding: 11px 15px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 15px;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--dc-text);
}

/* Листинг ТН ВЭД (mode_effective=tnved_lookup): моноширинно, чтобы сохранялись
   отступы/выравнивание структуры позиции. Перенос строк наследуется (pre-wrap). */
.declarant-chat__bubble--mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
  max-width: 92%;
}

.declarant-chat__msg--user .declarant-chat__bubble {
  background: var(--dc-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.declarant-chat__msg--bot .declarant-chat__bubble {
  background: var(--dc-bot);
  border-bottom-left-radius: 4px;
}

.declarant-chat__msg--error .declarant-chat__bubble {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-bottom-left-radius: 4px;
}

.declarant-chat__form {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--dc-border);
  background: #fff;
  align-items: flex-end;
}

.declarant-chat__input {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid var(--dc-border);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
  line-height: 1.4;
  font-family: inherit;
  outline: none;
  max-height: 160px;
  transition: border-color 0.15s ease;
}

.declarant-chat__input:focus {
  border-color: var(--dc-accent);
}

.declarant-chat__send {
  flex: 0 0 auto;
  border: none;
  background: var(--dc-accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.declarant-chat__send:hover {
  background: #1d4ed8;
}

.declarant-chat__send:disabled,
.declarant-chat__input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.declarant-chat__hint {
  margin: 0;
  padding: 0 14px 12px;
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
}

.declarant-chat__dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 2px;
  border-radius: 50%;
  background: #94a3b8;
  animation: declarant-bounce 1.2s infinite ease-in-out;
}

.declarant-chat__dot:nth-child(2) {
  animation-delay: 0.15s;
}

.declarant-chat__dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes declarant-bounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

@media (max-width: 600px) {
  .declarant-chat {
    --dc-height: 70vh;
    border-radius: 12px;
  }
  .declarant-chat__bubble {
    max-width: 88%;
    font-size: 14px;
  }
  .declarant-chat__mode,
  .declarant-chat__clear {
    font-size: 12px;
    padding: 6px 11px;
  }
}
