/* Чат «Разборщик» — Timeweb/DeepSeek агент */

.dialog--ai-chat {
  width: min(440px, calc(100vw - 24px));
  max-height: min(720px, calc(100vh - 24px));
  padding: 0;
  border: none;
  border-radius: 20px;
  background: var(--bg-elevated, var(--bg-lower));
  color: var(--text-primary);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.dialog--ai-chat::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.ai-chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: min(680px, calc(100vh - 48px));
  min-height: 420px;
}

.ai-chat__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent);
}

.ai-chat__title {
  margin: 0;
  font: 600 18px/1.25 var(--font);
}

.ai-chat__sub {
  margin: 4px 0 0;
  font: 400 13px/1.35 var(--font);
  color: color-mix(in srgb, var(--text-primary) 60%, transparent);
}

.ai-chat__close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
  color: var(--text-primary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.ai-chat__messages {
  overflow: auto;
  padding: 16px 18px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.ai-chat__msg {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font: 400 14px/1.45 var(--font);
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-chat__msg--user {
  justify-self: end;
  background: color-mix(in srgb, var(--accent, #7b61ff) 22%, transparent);
}

.ai-chat__msg--assistant {
  justify-self: start;
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.ai-chat__msg--error {
  justify-self: stretch;
  background: color-mix(in srgb, #ff6b6b 16%, transparent);
  color: #ffb0b0;
  font-size: 13px;
}

.ai-chat__msg--system {
  justify-self: stretch;
  background: transparent;
  color: color-mix(in srgb, var(--text-primary) 55%, transparent);
  font-size: 13px;
  padding: 4px 0;
}

.ai-chat__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent);
}

.ai-chat__input {
  min-height: 44px;
  max-height: 120px;
  resize: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--text-primary) 14%, transparent);
  background: color-mix(in srgb, var(--text-primary) 5%, transparent);
  color: var(--text-primary);
  font: 400 14px/1.4 var(--font);
}

.ai-chat__input:focus {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #7b61ff) 28%, transparent);
}

.ai-chat__send {
  min-width: 96px;
  min-height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--accent, #7b61ff);
  color: #fff;
  font: 600 14px/1 var(--font);
  cursor: pointer;
}

.ai-chat__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-chat__status {
  grid-column: 1 / -1;
  margin: 0;
  font: 400 12px/1.3 var(--font);
  color: color-mix(in srgb, var(--text-primary) 50%, transparent);
}
