:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e2e4e9;
  --text: #1a1b1e;
  --text-muted: #6b7280;
  --accent: #6d5bff;
  --accent-text: #ffffff;
  --user-bubble: #6d5bff;
  --user-bubble-text: #ffffff;
  --ai-bubble: #ffffff;
  --ai-bubble-text: #1a1b1e;
  --sidebar-bg: #17181c;
  --sidebar-text: #e6e6e9;
  --sidebar-muted: #9a9aa2;
  --sidebar-active: #2a2b31;
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101114;
    --surface: #1b1c20;
    --surface-2: #212226;
    --border: #2d2e33;
    --text: #eceef0;
    --text-muted: #9a9aa2;
    --ai-bubble: #212226;
    --ai-bubble-text: #eceef0;
    --sidebar-bg: #0c0d0f;
    --sidebar-active: #1e1f24;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
}

.new-chat-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.new-chat-btn:hover {
  opacity: 0.9;
}

/* :not([hidden]) по той же причине, что и у .attachment-chip ниже —
   безусловный display перебивает скрытие через атрибут hidden. */
.manufacturers-file-link:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--sidebar-active);
  color: var(--sidebar-text);
  text-decoration: none;
  transition: opacity 0.15s;
}

.manufacturers-file-link:hover {
  opacity: 0.85;
}

.manufacturers-file-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.manufacturers-file-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.manufacturers-file-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.manufacturers-file-meta {
  font-size: 11px;
  color: var(--sidebar-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-form {
  margin: 0;
}

.logout-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--sidebar-active);
  color: var(--sidebar-text);
  border-radius: 10px;
  width: 32px;
  height: 32px;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.logout-btn:hover {
  opacity: 0.8;
}

/* Login page */

.login-body {
  margin: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 340px;
  margin: 16px;
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
}

.login-logo {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  color: var(--text);
}

.login-error {
  background: rgba(229, 72, 77, 0.12);
  color: #e5484d;
  border: 1px solid rgba(229, 72, 77, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 10px;
}

.login-form input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
}

.login-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.login-form button {
  margin-top: 20px;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.login-form button:hover {
  opacity: 0.9;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--sidebar-muted);
  transition: background 0.12s, color 0.12s;
}

.thread-item:hover {
  background: var(--sidebar-active);
  color: var(--sidebar-text);
}

.thread-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text);
  font-weight: 600;
}

.thread-item-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item-delete {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--sidebar-muted);
  font-size: 16px;
  line-height: 1;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}

.thread-item:hover .thread-item-delete {
  opacity: 1;
}

.thread-item-delete:hover {
  background: rgba(229, 72, 77, 0.2);
  color: #e5484d;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
}

/* Main */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-title {
  font-size: 16px;
  font-weight: 700;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-mode-launch-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.voice-mode-launch-btn:hover {
  opacity: 0.85;
}

.voice-mode-launch-btn:active {
  transform: scale(0.94);
}

.voice-reply-toggle {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

.voice-reply-toggle:hover {
  opacity: 0.8;
}

.voice-reply-toggle.active {
  background: var(--accent);
  color: var(--accent-text);
}

/* Кнопка "новый чат" в хедере — видна только в мобильной раскладке
   (см. медиазапрос ниже); на десктопе эта функция уже есть в сайдбаре. */
.new-chat-mobile-btn {
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.new-chat-mobile-btn:hover {
  opacity: 0.85;
}

.new-chat-mobile-btn:active {
  transform: scale(0.94);
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Пустой экран нового чата — короткая приветственная заглушка,
   как в мобильном приложении Claude: иконка + фраза по центру. */
.chat:empty {
  align-items: center;
  justify-content: center;
}

.chat:empty::before {
  content: "👾";
  font-size: 46px;
  line-height: 1;
}

.chat:empty::after {
  content: "Кого найдём сегодня?";
  font-size: 17px;
  color: var(--text-muted);
  text-align: center;
}

.message-row {
  display: flex;
  gap: 10px;
  max-width: 720px;
}

.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.assistant {
  align-self: flex-start;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: var(--surface-2);
}

.bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.55;
  word-wrap: break-word;
}

.message-row.user .bubble {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 4px;
}

.message-row.assistant .bubble {
  background: var(--ai-bubble);
  color: var(--ai-bubble-text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.bubble p {
  margin: 0 0 8px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble pre {
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
}

.bubble code {
  background: var(--surface-2);
  padding: 2px 5px;
  border-radius: 5px;
  font-size: 13px;
}

.bubble pre code {
  background: none;
  padding: 0;
}

.bubble ul, .bubble ol {
  margin: 4px 0;
  padding-left: 20px;
}

.bubble a {
  color: inherit;
  text-decoration: underline;
}

.cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--text-muted);
  margin-left: 2px;
  animation: blink 1s step-start infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  50% { opacity: 0; }
}

.status-line {
  padding: 6px 24px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* Composer — панель ввода в стиле Claude: одна скруглённая карточка,
   текст сверху, панель иконок снизу внутри неё же. */

.composer-wrap {
  padding: 0 24px 20px;
  background: var(--surface);
  display: flex;
  justify-content: center;
}

.composer-box {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px 10px;
  border-radius: 26px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 2px 18px rgba(109, 91, 255, 0.18);
}

.composer-box textarea {
  resize: none;
  max-height: 200px;
  padding: 6px 4px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
}

.composer-box textarea::placeholder {
  color: var(--text-muted);
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.composer-toolbar-left,
.composer-toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.composer-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.composer-icon-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.composer-icon-btn.listening {
  background: #e5484d;
  color: #ffffff;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.composer-icon-btn.unsupported {
  opacity: 0.35;
  cursor: not-allowed;
}

.composer-icon-btn.unsupported:hover {
  background: transparent;
  color: var(--text-muted);
}

.composer-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, transform 0.1s;
}

.composer-send-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.composer-send-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.composer-send-btn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: default;
}

/* Белая круглая кнопка голосового режима в панели композера —
   видна только в мобильной раскладке, подменяет кнопку отправки,
   когда поле ввода пустое (как в мобильном приложении Claude).
   display: none здесь — базовое (десктопное) состояние; медиазапрос
   ниже включает её, а [hidden] (JS) снова выключает через :not() —
   та же схема, что у .attachment-chip / .voice-mode-overlay, чтобы
   не повторить баг с безусловным display. */
.composer-voice-btn {
  display: none;
}

/* Список вложений (до 10 чипов) живёт внутри карточки композера, над полем ввода */

/* :not([hidden]) — важно: иначе это правило задаёт display:flex
   безусловно и перебивает собственный display:none браузера для
   атрибута hidden — из-за этого JS-переключение .hidden = true/false
   переставало реально скрывать блок после первого показа. */
.attachment-list:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
  max-height: 112px;
  overflow-y: auto;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  max-width: 100%;
}

.attachment-chip.is-uploading {
  opacity: 0.6;
}

.attachment-chip.is-error {
  border-color: #d9534f;
  color: #d9534f;
}

.attachment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.attachment-chip button {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.attachment-chip button:hover {
  color: var(--text);
}

/* Mobile */

@media (max-width: 768px) {
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 15;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .chat-header {
    padding-left: 60px;
  }

  /* На тач-устройствах нет hover — крестик удаления держим видимым всегда */
  .thread-item-delete {
    opacity: 1;
  }

  .message-row {
    max-width: 88%;
  }

  /* Мобильный хедер — как в приложении Claude: только бургер (слева,
     абсолютно позиционирован) и кнопка нового чата справа. Голосовой
     режим и озвучивание ответов переезжают в панель композера. */
  .voice-mode-launch-btn,
  .voice-reply-toggle {
    display: none;
  }

  .new-chat-mobile-btn {
    display: flex;
  }

  .composer-voice-btn:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #ffffff;
    color: #111111;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.1s;
  }

  .composer-voice-btn:not([hidden]):active {
    transform: scale(0.94);
  }

  .composer-voice-btn.unsupported {
    opacity: 0.35;
    cursor: not-allowed;
  }

  /* Кнопка отправки на мобильном видна только когда есть что отправлять —
     при пустом поле её место занимает белый круг голосового режима выше.
     [hidden] здесь работает через !important, т.к. базовое правило
     .composer-send-btn задаёт display: flex безусловно (десктопу это не
     мешает — там hidden на эту кнопку никогда не ставится). */
  .composer-send-btn[hidden] {
    display: none !important;
  }
}

/* ===========================================================
   Голосовой режим — полноэкранный "звонок" с автоматической
   сменой реплик (как телефонный разговор), без кликов между
   репликами. Движок голоса остаётся тем же бесплатным (STT/TTS
   браузера) — меняется только сценарий общения.
   =========================================================== */

/* :not([hidden]) — та же причина, что и у .attachment-chip /
   .manufacturers-file-link выше: безусловный display: flex здесь
   перебивал бы встроенный [hidden] { display: none } браузера (при
   равной специфичности побеждает правило автора), и оверлей звонка
   показывался бы ВСЕГДА, игнорируя атрибут hidden — ровно это и
   происходило: окно звонка открывалось само при загрузке страницы и
   не закрывалось по кнопке, потому что JS честно выставлял
   hidden = true/false, а CSS это попросту не учитывал. */
.voice-mode-overlay:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: radial-gradient(circle at 50% 35%, var(--surface-2), var(--bg) 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 32px 24px;
}

.voice-mode-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.voice-mode-close:hover {
  opacity: 0.8;
}

.voice-orb {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent), #3c2fb8 75%);
  box-shadow: 0 0 0 0 rgba(109, 91, 255, 0.5);
  transition: background 0.3s ease;
}

/* Подключаюсь — коротко, пока ещё не подтверждён реальный старт
   распознавания (см. watchdog в app.js) */
.voice-orb.connecting {
  opacity: 0.6;
}

/* Слушаю — мягкая пульсация, как дыхание */
.voice-orb.listening {
  animation: voice-orb-listening 2.4s ease-in-out infinite;
}

@keyframes voice-orb-listening {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(109, 91, 255, 0.35); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 20px rgba(109, 91, 255, 0); }
}

/* Думаю — быстрое вращение градиента, без изменения размера */
.voice-orb.thinking {
  background: conic-gradient(from 0deg, var(--accent), #3c2fb8, var(--accent));
  animation: voice-orb-thinking 1.1s linear infinite;
}

@keyframes voice-orb-thinking {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Говорю — более частая, "живая" пульсация в ритме речи */
.voice-orb.speaking {
  animation: voice-orb-speaking 0.55s ease-in-out infinite alternate;
}

@keyframes voice-orb-speaking {
  from { transform: scale(1); }
  to { transform: scale(1.14); }
}

.voice-mode-status {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  min-height: 20px;
}

.voice-mode-transcript {
  max-width: 560px;
  min-height: 48px;
  text-align: center;
  font-size: 18px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}

.voice-mode-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.voice-mode-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.voice-mode-btn:hover {
  opacity: 0.85;
}

.voice-mode-end-btn {
  background: #e5484d;
  color: #fff;
  border-color: #e5484d;
}

@media (max-width: 720px) {
  .voice-orb {
    width: 110px;
    height: 110px;
  }

  .voice-mode-transcript {
    font-size: 16px;
  }
}


/* ===========================================================
   Оформление в духе Claude.ai: тёплая светлая палитра, светлый
   сайдбар, ответы ассистента без «пузырей» в центральной колонке,
   сообщения пользователя — мягкая плашка справа, большая карточка
   ввода. Правила ниже идут последними и переопределяют базовые.
   =========================================================== */

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --border: #e4e1d8;
  --text: #2b2822;
  --text-muted: #7b776c;
  --ai-bubble: transparent;
  --ai-bubble-text: #2b2822;
  --user-bubble: #efece5;
  --user-bubble-text: #2b2822;
  --sidebar-bg: #f3f1eb;
  --sidebar-text: #2b2822;
  --sidebar-muted: #7b776c;
  --sidebar-active: #e7e4db;
  --column: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1e1b;
    --surface: #2a2926;
    --surface-2: #32312d;
    --border: #3e3c37;
    --text: #ece9e1;
    --text-muted: #a09b8f;
    --ai-bubble: transparent;
    --ai-bubble-text: #ece9e1;
    --user-bubble: #32312d;
    --user-bubble-text: #ece9e1;
    --sidebar-bg: #191816;
    --sidebar-text: #ece9e1;
    --sidebar-muted: #a09b8f;
    --sidebar-active: #2a2926;
  }
}

/* Сайдбар */

.sidebar {
  width: 272px;
  border-right: 1px solid var(--border);
}

.new-chat-btn {
  background: transparent;
  color: var(--sidebar-text);
  border: 1px solid var(--border);
  text-align: left;
  font-weight: 500;
}

.new-chat-btn:hover {
  background: var(--sidebar-active);
  opacity: 1;
}

.sidebar-user {
  border-top: 1px solid var(--border);
}

.logout-btn {
  border-color: var(--border);
}

/* Шапка и область чата */

.chat-header {
  background: var(--bg);
  border-bottom: none;
  padding: 12px 24px;
}

.chat-title {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 14px;
}

.chat {
  background: var(--bg);
  padding: 8px 24px 24px;
  gap: 22px;
}

.status-line {
  background: var(--bg);
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: 6px 24px;
}

/* Приветствие нового чата — засечки, как у Claude */

.chat:empty::before {
  content: "👾";
  font-size: 34px;
  margin-bottom: 14px;
}

.chat:empty::after {
  content: "Кого найдём сегодня?";
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  font-size: 32px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Сообщения */

.message-row {
  width: 100%;
  max-width: var(--column);
  align-self: center;
}

.message-row .avatar {
  display: none;
}

.message-row.user {
  flex-direction: row;
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.message-row.user .bubble {
  max-width: 82%;
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border-radius: 18px;
  border-bottom-right-radius: 18px;
  padding: 10px 16px;
  white-space: pre-wrap;
}

.message-row.assistant .bubble {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 2px 0;
  width: 100%;
  font-size: 16px;
  line-height: 1.7;
}

.bubble p {
  margin: 0 0 12px;
}

.bubble table {
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  max-width: 100%;
  margin: 8px 0 14px;
  font-size: 14px;
}

.bubble th,
.bubble td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.bubble th {
  background: var(--surface-2);
}

.bubble a {
  color: var(--accent);
}

/* Карточка ввода */

.composer-wrap {
  background: var(--bg);
  padding: 0 24px 22px;
}

.composer-box {
  max-width: var(--column);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 2px 12px rgba(40, 34, 20, 0.07);
  padding: 14px 16px 10px;
}

.composer-box:focus-within {
  border-color: var(--text-muted);
  box-shadow: 0 2px 16px rgba(40, 34, 20, 0.12);
}

.composer-icon-btn:hover {
  background: var(--surface-2);
}

.composer-send-btn {
  background: var(--accent);
}

.attachment-chip {
  background: var(--surface-2);
  border-radius: 12px;
}

.voice-mode-launch-btn {
  background: var(--surface-2);
  color: var(--text);
}

/* Перетаскивание файлов: затемнение всего окна с рамкой по краю */

.drop-overlay:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 28, 22, 0.38);
  backdrop-filter: blur(2px);
  /* События мыши проходят сквозь слой — dragleave считается по окну. */
  pointer-events: none;
}

.drop-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 36px 48px;
  border: 2px dashed var(--text-muted);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.drop-overlay-title {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 22px;
}

.drop-overlay-sub {
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .chat,
  .composer-wrap {
    padding-left: 14px;
    padding-right: 14px;
  }

  .message-row {
    max-width: 100%;
  }

  .chat:empty::after {
    font-size: 26px;
  }

  .chat-header {
    padding-left: 60px;
    padding-right: 14px;
  }

  .sidebar {
    box-shadow: none;
  }

  .sidebar.open {
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  }
}

@media (prefers-reduced-motion: reduce) {
  .drop-overlay-card { transition: none; }
}


/* Плашка сработавших напоминаний над чатом */

.task-banner:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 24px;
}

.task-banner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
  font-size: 14px;
}

.task-banner-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-banner-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.task-banner-actions button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.task-banner-actions button:hover {
  background: var(--border);
}

@media (max-width: 768px) {
  .task-banner:not([hidden]) {
    padding: 0 14px;
  }

  .task-banner-row {
    flex-direction: column;
    align-items: stretch;
  }

  .task-banner-actions {
    flex-wrap: wrap;
  }
}


/* Этапы работы агента: карточка внутри ответа, как у Claude */

.steps-card {
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  font-size: 14px;
}

.steps-card[hidden] { display: none; }

.steps-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
}

.steps-summary::-webkit-details-marker { display: none; }

.steps-summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 4px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform .15s;
  order: 5;
}

.steps-card[open] .steps-summary::after { transform: rotate(-135deg); }

.steps-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps-timer { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.steps-spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent, #c96442);
  animation: steps-spin .8s linear infinite;
}

.steps-card.finished .steps-spinner {
  animation: none;
  border: 0;
  width: 16px;
  height: 16px;
  position: relative;
}

.steps-card.finished .steps-spinner::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 5px;
  height: 10px;
  border-right: 2px solid #3a9d5d;
  border-bottom: 2px solid #3a9d5d;
  transform: rotate(45deg);
}

.steps-bar {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent, #c96442), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: steps-slide 1.4s ease-in-out infinite;
}

.steps-card.finished .steps-bar { display: none; }

.steps-list {
  list-style: none;
  margin: 0;
  padding: 4px 14px 12px;
  border-top: 1px solid var(--border);
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  color: var(--text);
}

.step.running { color: var(--text); font-weight: 500; }
.step.done { color: var(--text-muted); }
.step.error { color: #c0392b; }

.step-text { flex: 1; min-width: 0; }
.step-time { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.step-icon {
  width: 14px;
  height: 14px;
  flex: none;
  position: relative;
}

.step.running .step-icon {
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent, #c96442);
  animation: steps-spin .8s linear infinite;
}

.step.done .step-icon::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 4px;
  height: 9px;
  border-right: 2px solid #3a9d5d;
  border-bottom: 2px solid #3a9d5d;
  transform: rotate(45deg);
}

.step.error .step-icon::before,
.step.error .step-icon::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  width: 2px;
  height: 14px;
  background: #c0392b;
  transform: rotate(45deg);
}

.step.error .step-icon::after { transform: rotate(-45deg); }

.answer:empty { display: none; }

@keyframes steps-spin { to { transform: rotate(360deg); } }
@keyframes steps-slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }

@media (prefers-reduced-motion: reduce) {
  .steps-spinner, .steps-bar, .step.running .step-icon { animation: none; }
}

/* ---- Палитра Claude: убираем фиолетовый, акцент — тёплый терракотовый ---- */

:root {
  --accent: #c96442;
  --accent-text: #ffffff;
  --sidebar-w: 272px;
}

@media (prefers-color-scheme: dark) {
  :root { --accent: #d97757; }
}

.composer-box:focus-within {
  border-color: var(--text-muted);
  box-shadow: 0 2px 16px rgba(40, 34, 20, 0.12);
}

.voice-orb {
  background: radial-gradient(circle at 35% 30%, var(--accent), #8f4328 75%);
  box-shadow: 0 0 0 0 rgba(201, 100, 66, 0.5);
}

.voice-orb.thinking {
  background: conic-gradient(from 0deg, var(--accent), #8f4328, var(--accent));
}

@keyframes voice-orb-listening {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(201, 100, 66, 0.35); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 20px rgba(201, 100, 66, 0); }
}

/* ---- Бургер: скрыть/показать список диалогов (десктоп и мобильная версия) ---- */

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  top: 10px;
  left: 12px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--text-muted);
}

.sidebar-toggle:hover {
  background: var(--sidebar-active);
  color: var(--text);
}

.sidebar-toggle svg { display: block; }

@media (min-width: 769px) {
  .sidebar {
    width: var(--sidebar-w);
    padding-top: 60px;           /* место под бургер */
    transition: margin-left 0.2s ease;
  }

  .app.sidebar-collapsed .sidebar {
    margin-left: calc(-1 * var(--sidebar-w));
  }

  .chat-header {
    transition: padding-left 0.2s ease;
  }

  .app.sidebar-collapsed .chat-header {
    padding-left: 64px;          /* заголовок не заезжает под бургер */
  }

  .app.sidebar-collapsed .sidebar-toggle {
    background: var(--surface);
    border: 1px solid var(--border);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .chat-header { transition: none; }
}

/* Значок вместо фиолетового смайлика — лучик в цвет акцента */

.chat:empty::before {
  content: "✻";
  color: var(--accent);
  font-size: 40px;
  margin-bottom: 14px;
}

.chat-title::before,
.login-logo::before {
  content: "✻";
  color: var(--accent);
  margin-right: 8px;
}
