/* ===== AI-чат «Спросить» (Фаза 6.4) ===== */

.chat-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.chat-head {
  text-align: center;
  margin-bottom: 22px;
}
.chat-head h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  margin: 0 0 6px;
  letter-spacing: 0.4px;
}
.chat-head p {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
}

/* --- Ввод --- */
.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 10px 10px 10px 16px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.chat-input-row:focus-within {
  border-color: rgba(212, 169, 78, 0.55);
  box-shadow: 0 0 0 3px rgba(212, 169, 78, 0.08);
}
#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  min-height: 24px;
  max-height: 120px;
  padding: 2px 0;
}
#chat-input::placeholder { color: var(--muted); }

#chat-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #14100a;
  background: linear-gradient(135deg, #e8c97a, #d4a94e);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  box-shadow: 0 4px 16px rgba(212, 169, 78, 0.28);
}
#chat-send:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(212, 169, 78, 0.4); }
#chat-send:active { transform: translateY(0) scale(0.97); }
#chat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* --- История (подсказки) --- */
.chat-history {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.chat-hist-chip {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-hist-chip:hover { color: var(--text); border-color: rgba(212,169,78,0.45); }
.chat-hist-label {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.7;
  align-self: center;
}

/* --- Результат --- */
.chat-result { margin-top: 24px; }
.chat-answer {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-left: 3px solid rgba(212, 169, 78, 0.75);
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-answer .qa { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }

.chat-evidence {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.chat-ev-card {
  border: 1px solid color-mix(in srgb, var(--sc, #888) 40%, transparent);
  border-radius: 14px;
  background: rgba(255,255,255,0.025);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.chat-ev-card:hover {
  border-color: color-mix(in srgb, var(--sc, #888) 70%, transparent);
  transform: translateY(-2px);
}
.chat-ev-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-ev-src {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--sc, #888);
}
.chat-ev-book {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
.chat-ev-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
  overflow-wrap: anywhere;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 9px;
}
.chat-ev-text.open { -webkit-line-clamp: unset; }
.chat-ev-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-conf {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.chat-conf-track {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.chat-conf-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--sc, #888) 45%, transparent), var(--sc, #888));
  box-shadow: 0 0 6px color-mix(in srgb, var(--sc, #888) 55%, transparent);
}
.chat-conf-val {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: right;
}
.chat-ev-actions { display: flex; gap: 6px; }
.chat-ev-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.chat-ev-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.25); }
.chat-ev-btn.active { color: #ff8b7a; border-color: rgba(255,107,92,0.5); background: rgba(255,107,92,0.08); }
.chat-ev-btn.cmp-active { color: #7c9cff; border-color: rgba(124,156,255,0.5); background: rgba(124,156,255,0.08); }

/* --- Пусто / загрузка --- */
.chat-empty {
  text-align: center;
  padding: 46px 16px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}
.chat-empty svg { opacity: 0.5; margin-bottom: 12px; }
.chat-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 0;
  color: var(--muted);
  font-size: 13.5px;
}
.chat-spinner .spin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(212,169,78,0.2);
  border-top-color: #d4a94e;
  animation: chat-rot 0.8s linear infinite;
}
@keyframes chat-rot { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .chat-wrap { padding: 20px 12px 48px; }
  .chat-head h2 { font-size: 22px; }
  .chat-evidence { grid-template-columns: 1fr; }
}

/* --- Chat-send: золотая грань + неон --- */
#chat-send {
  box-shadow:
    0 3px 0 #8a6420,
    0 6px 0 rgba(0, 0, 0, 0.3),
    0 8px 18px rgba(212, 169, 78, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    inset 0 -3px 5px rgba(122, 86, 20, 0.35);
  transition: transform 0.16s var(--ease-out), box-shadow 0.22s var(--ease-out), opacity 0.18s;
}
#chat-send:hover {
  transform: translateY(-2px);
  box-shadow:
    0 5px 0 #8a6420,
    0 9px 0 rgba(0, 0, 0, 0.3),
    0 14px 26px rgba(212, 169, 78, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 5px rgba(122, 86, 20, 0.35),
    0 0 18px rgba(212, 169, 78, 0.35);
}
#chat-send:active {
  transform: translateY(2px) scale(0.97);
  box-shadow:
    0 1px 0 #8a6420,
    0 2px 4px rgba(0, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.4),
    inset 0 -3px 5px rgba(122, 86, 20, 0.35);
}

