/* ============ AIuzbek — тёмная тема One Dark, фиолетовый акцент ============ */

:root {
  --bg: #1d2127;
  --bg-elev: #262b33;
  --bg-elev2: #2d323c;
  --bg-input: #2b303a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #d7dae0;
  --text-dim: #abb2bf;
  --text-faint: #7f8591;
  --accent: #8b5cf6;
  --accent-strong: #7c3aed;
  --accent-hover: #a78bfa;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --accent-border: rgba(139, 92, 246, 0.35);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.55);
  --font: 'Onest', -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Атрибут hidden всегда сильнее любого display (иначе экран входа
   и другие элементы с display:flex не скрывались) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 75% -10%, rgba(139, 92, 246, 0.07), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(139, 92, 246, 0.04), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

textarea, input { font-family: inherit; }

svg { display: block; }

::selection { background: rgba(139, 92, 246, 0.35); }

/* Скроллбары */
* { scrollbar-width: thin; scrollbar-color: rgba(139, 92, 246, 0.4) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.35); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.5); }

/* ============ Каркас ============ */

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

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 55;
}

/* ============ Иконочные кнопки ============ */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn svg { width: 19px; height: 19px; }

.icon-btn:hover {
  background: var(--bg-elev2);
  color: var(--text);
}

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

.icon-btn:disabled:hover { background: none; color: var(--text-dim); }

/* ============ Сайдбар ============ */

.sidebar {
  width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  gap: 12px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.2px;
}

.logo__icon {
  width: 24px;
  height: 24px;
  color: var(--accent);
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.55));
}

.sidebar-close { display: none; }

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.35);
  transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.new-chat-btn svg { width: 17px; height: 17px; }

.new-chat-btn:hover {
  filter: brightness(1.12);
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.5);
}

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

/* Список чатов */

.chat-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 8px;
}

.chat-group {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  padding: 14px 8px 6px;
}

.chat-group:first-child { padding-top: 4px; }

.chat-group--pinned {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-hover);
}

.chat-group--pinned svg { width: 13px; height: 13px; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-sm);
  padding: 0 4px 0 0;
  transition: background 0.12s ease;
}

.chat-item:hover, .chat-item:focus-within { background: var(--bg-elev2); }

.chat-item.active {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

.chat-item__btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  text-align: left;
  padding: 10px 8px 10px 12px;
  font-size: 16px;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.chat-item.active .chat-item__btn { color: var(--text); }

.chat-item__btn > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item__actions {
  display: none;
  align-items: center;
  gap: 2px;
  padding-right: 4px;
}

.chat-item:hover .chat-item__actions,
.chat-item:focus-within .chat-item__actions,
.chat-item.confirm .chat-item__actions { display: flex; }

.chat-item__actions .icon-btn { width: 26px; height: 26px; }
.chat-item__actions .icon-btn svg { width: 14px; height: 14px; }

/* Скелетон генерации названия темы */
.chat-title-skeleton {
  display: inline-block;
  vertical-align: middle;
  width: 75%;
  max-width: 160px;
  height: 13px;
  border-radius: 7px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 25%,
    rgba(139, 92, 246, 0.25) 50%,
    rgba(255, 255, 255, 0.06) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.chat-item__pin.active { color: var(--accent); }
.chat-item__pin.active:hover { color: var(--accent-hover); }

.chat-item__wand.busy { animation: think 1s ease infinite; opacity: 0.65; }

@media (hover: none) {
  .chat-item__actions { display: flex; }
}

.chat-item__rename {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13.5px;
  padding: 7px 10px;
  margin: 2px 4px 2px 8px;
  outline: none;
}

.chat-item__confirm {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.chat-item.confirm .chat-item__btn,
.chat-item.confirm .chat-item__actions { display: none; }
.chat-item.confirm .chat-item__confirm { display: flex; }

.chat-item__confirm button {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
}

.chat-item__confirm-yes { background: var(--danger-soft); color: var(--danger); }
.chat-item__confirm-yes:hover { background: rgba(248, 113, 113, 0.22); }
.chat-item__confirm-no:hover { background: var(--bg-elev2); }

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 4px 0;
  border-top: 1px solid var(--border);
}

.sidebar-foot__user {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 8px 10px;
  margin: 0 -10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-foot__user:hover { background: var(--bg-elev2); color: var(--text); }

.sidebar-foot__user svg {
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  flex-shrink: 0;
  transition: transform 0.4s ease;
}

.sidebar-foot__user:hover svg { color: var(--accent); transform: rotate(90deg); }

.sidebar-foot__user span {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-faint);
  transition: background 0.15s ease, color 0.15s ease;
}

.logout-btn:hover { background: var(--bg-elev2); color: var(--danger); }
.logout-btn svg { width: 16px; height: 16px; }

/* ============ Основная область ============ */

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

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(29, 33, 39, 0.55);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  min-height: 58px;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar { background: rgba(29, 33, 39, 0.92); }
}

.menu-btn { display: none; }

.topbar-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 300px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.model-btn:hover {
  border-color: var(--accent-border);
  background: var(--bg-elev2);
}

.model-btn__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.model-btn svg { width: 15px; height: 15px; color: var(--text-faint); }

/* ============ Лента сообщений ============ */

.messages-wrap {
  flex: 1;
  position: relative;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.messages {
  max-width: 800px;
  margin: 0 auto;
  padding: 78px 20px 170px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.msg {
  display: flex;
  gap: 14px;
  animation: msg-in 0.22s ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg--user {
  flex-direction: column;
  align-items: flex-end;
}

.msg--user .msg-bubble {
  max-width: 78%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 16px 16px 4px 16px;
  padding: 11px 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg--assistant { flex-direction: column; gap: 6px; }

.msg-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.4);
  margin-bottom: 2px;
}

.msg-avatar svg { width: 18px; height: 18px; color: #fff; }

.assistant-row {
  display: flex;
  gap: 14px;
}

.assistant-body {
  flex: 1;
  min-width: 0;
}

.msg-content { word-break: break-word; font-size: 18px; line-height: 1.65; }

.msg--error .msg-content {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
}

.msg-meta {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.msg:hover .msg-meta, .msg-meta:focus-within { opacity: 1; }

@media (hover: none) {
  .msg-meta { opacity: 1; }
}

.msg-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-faint);
  padding: 5px 8px;
  border-radius: 8px;
}

.msg-copy:hover { background: var(--bg-elev2); color: var(--text-dim); }
.msg-copy svg { width: 14px; height: 14px; }

/* Курсор печати */

.cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--accent);
  border-radius: 2px;
  animation: blink 0.9s steps(2) infinite;
}

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

/* Вложения в сообщении */

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.att-thumb {
  max-width: 200px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  display: block;
}

.att-audio {
  width: 280px;
  max-width: 100%;
  height: 40px;
}

.att-video {
  max-width: 320px;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  display: block;
}

.att-file {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 16px;
  text-decoration: none;
  max-width: 100%;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.att-file:hover { border-color: var(--accent-border); color: var(--text); }
.att-file svg { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }
.att-file span {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ Markdown ============ */

.msg-content > *:first-child { margin-top: 0; }
.msg-content > *:last-child { margin-bottom: 0; }

.msg-content p { margin: 0 0 14px; }

.msg-content h1, .msg-content h2, .msg-content h3,
.msg-content h4, .msg-content h5, .msg-content h6 {
  margin: 20px 0 10px;
  line-height: 1.3;
}

.msg-content h1 { font-size: 1.35em; }
.msg-content h2 { font-size: 1.2em; }
.msg-content h3 { font-size: 1.08em; }

.msg-content ul, .msg-content ol {
  margin: 0 0 12px;
  padding-left: 24px;
}

.msg-content li { margin: 4px 0; }

.msg-content a {
  color: var(--accent-hover);
  text-decoration: none;
  border-bottom: 1px solid rgba(167, 139, 250, 0.4);
}

.msg-content a:hover { border-bottom-color: var(--accent-hover); }

.msg-content blockquote {
  margin: 0 0 12px;
  padding: 4px 14px;
  border-left: 3px solid var(--accent);
  background: rgba(139, 92, 246, 0.06);
  border-radius: 0 8px 8px 0;
  color: var(--text-dim);
}

.msg-content code:not(pre code) {
  font-family: var(--mono);
  font-size: 0.88em;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.18);
  padding: 1.5px 6px;
  border-radius: 6px;
}

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

.msg-content th, .msg-content td {
  border: 1px solid var(--border-strong);
  padding: 7px 12px;
  text-align: left;
}

.msg-content th { background: var(--bg-elev2); font-weight: 600; }

.msg-content hr {
  border: none;
  border-top: 1px solid var(--border-strong);
  margin: 18px 0;
}

.msg-content img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}

/* Блоки кода */

.code-wrap {
  position: relative;
  margin: 0 0 14px;
}

.code-wrap pre {
  margin: 0;
  padding: 14px 16px;
  padding-top: 40px;
  background: #1b1e24;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.code-wrap code {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  background: none !important;
  padding: 0 !important;
}

.code-wrap__bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  pointer-events: none;
}

.code-wrap__lang {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: lowercase;
}

.code-copy {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 4px 8px;
  border-radius: 7px;
}

.code-copy:hover { background: var(--bg-elev2); color: var(--text-dim); }
.code-copy svg { width: 13px; height: 13px; }

/* ============ Пустое состояние ============ */

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 12px;
  animation: msg-in 0.3s ease;
}

.empty-state__orb {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 8px 40px rgba(124, 58, 237, 0.45);
  margin-bottom: 8px;
}

.empty-state__orb svg { width: 36px; height: 36px; color: #fff; }

.empty-state h1 {
  margin: 0;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  text-align: center;
  background: linear-gradient(90deg, #e6e9ef 30%, var(--accent-hover));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.empty-state p {
  margin: 0 0 14px;
  color: var(--text-faint);
  font-size: 17px;
  text-align: center;
}

/* ============ Композер ============ */

.composer-zone {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: 10px 20px calc(16px + env(safe-area-inset-bottom));
  background: transparent;
  pointer-events: none;
}

.composer-zone .chips,
.composer-zone .composer,
.composer-zone .composer-hint {
  pointer-events: auto;
}

.composer-max {
  max-width: 800px;
  margin: 0 auto;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  font-size: 13px;
  color: var(--text-dim);
  animation: msg-in 0.18s ease;
}

.chip--warn { border-color: rgba(248, 113, 113, 0.5); background: var(--danger-soft); }

.chip__thumb {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 7px;
  flex-shrink: 0;
}

.chip__icon { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }

.chip__name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.chip__size { color: var(--text-faint); flex-shrink: 0; }

.chip__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.chip__remove:hover { background: var(--bg-elev2); color: var(--danger); }
.chip__remove svg { width: 13px; height: 13px; }

.chip--uploading { opacity: 0.55; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 9px 9px 9px 6px;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: rgba(43, 48, 58, 0.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .composer { background: rgba(43, 48, 58, 0.94); }
}

.composer:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12), 0 4px 24px rgba(0, 0, 0, 0.3);
}

.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  line-height: 1.5;
  padding: 8px 4px;
  max-height: 172px;
}

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

.send-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 3px 14px rgba(124, 58, 237, 0.4);
  transition: filter 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.send-btn svg { width: 18px; height: 18px; }

.send-btn:hover:not(:disabled) { filter: brightness(1.15); }

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

.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.send-btn--stop {
  background: var(--bg-elev2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: none;
}

.composer-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
  padding: 8px 0 0;
}

/* Кнопка «вниз» */

.scroll-down {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elev2);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  box-shadow: var(--shadow-pop);
  z-index: 25;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.scroll-down:hover { color: var(--accent-hover); border-color: var(--accent-border); }
.scroll-down svg { width: 18px; height: 18px; }

/* ============ Дровер выбора модели ============ */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  visibility: hidden;
}

.drawer.open {
  pointer-events: auto;
  visibility: visible;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.drawer.open .drawer-backdrop { opacity: 1; }

.drawer-panel {
  position: absolute;
  top: 66px;
  right: 16px;
  width: 400px;
  max-width: calc(100vw - 32px);
  max-height: min(70vh, 620px);
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
  transform: scale(0.96) translateY(-6px);
  transform-origin: top right;
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
  overflow: hidden;
}

.drawer.open .drawer-panel {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.drawer-handle { display: none; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 10px 10px 18px;
  flex-shrink: 0;
}

.drawer-title { font-size: 15px; font-weight: 700; }

.drawer-count {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 13px;
}

.drawer-search {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 14px 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  flex-shrink: 0;
  transition: border-color 0.15s ease;
}

.drawer-search:focus-within { border-color: var(--accent-border); }

.drawer-search svg { width: 16px; height: 16px; color: var(--text-faint); flex-shrink: 0; }

.drawer-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14.5px;
}

.drawer-search input::placeholder { color: var(--text-faint); }

.drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.model-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.model-item:hover { background: var(--bg-elev2); }

.model-item.selected {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.model-item--off { opacity: 0.45; cursor: not-allowed; }

.model-item__body {
  flex: 1;
  min-width: 0;
}

.model-item__name {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-item__id {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-item__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.22);
  color: var(--accent-hover);
}

.badge--off {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

.model-item__check {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0;
}

.model-item.selected .model-item__check { opacity: 1; }

.drawer-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
}

/* ============ Тосты ============ */

.toasts {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100vw - 24px));
}

.toast {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev2);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-pop);
  font-size: 16px;
  color: var(--text);
  animation: toast-in 0.22s ease;
}

.toast--error { border-color: rgba(248, 113, 113, 0.45); background: #2f2327; color: #fca5a5; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast.hide { opacity: 0; transition: opacity 0.3s ease; }

/* ============ Мобильная версия ============ */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(360px, 88vw);
    z-index: 60;
    transform: translateX(-105%);
    transition: transform 0.24s ease;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-pop);
  }

  .sidebar-close { display: inline-flex; }

  .menu-btn { display: inline-flex; }

  .topbar { padding: 8px 10px; min-height: 54px; }

  .topbar-title { font-size: 17px; }

  .model-btn {
    max-width: 42vw;
    padding: 8px 10px;
    font-size: 12.5px;
  }

  .messages { padding: 70px 12px 150px; gap: 18px; }

  .msg--user .msg-bubble { max-width: 88%; }

  .assistant-row { gap: 10px; }

  .msg-avatar { width: 28px; height: 28px; }

  .empty-state h1 { font-size: 22px; }

  .composer-zone { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }

  .composer-hint { display: none; }

  /* Дровер моделей: bottom-sheet на 70% экрана, не меньше */
  .drawer-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: 70vh;
    min-height: 70vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(105%);
    transform-origin: bottom center;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .drawer.open .drawer-panel { transform: translateY(0); }

  .drawer-handle {
    display: block;
    width: 42px;
    height: 4px;
    border-radius: 4px;
    background: var(--border-strong);
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  .drawer-head { padding-top: 10px; }

  .scroll-down { bottom: 100px; }
}

/* ============ Режим размышления ============ */

.reason-btn { color: var(--text-faint); }

.reason-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.reason-btn.active:hover { background: var(--accent-soft); color: var(--accent-hover); }

.reason-btn.active svg {
  filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.6));
}

.reasoning {
  border: 1px solid var(--border);
  background: rgba(139, 92, 246, 0.05);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}

.reasoning summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-faint);
  user-select: none;
  list-style: none;
}

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

.reasoning summary .r-ic { width: 15px; height: 15px; color: var(--accent); flex-shrink: 0; }

.reasoning summary .chev {
  margin-left: auto;
  width: 14px;
  height: 14px;
  color: var(--text-faint);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.reasoning[open] summary .chev { transform: rotate(180deg); }

.reasoning--live .r-label { animation: think 1.2s ease infinite; color: var(--accent-hover); }

@keyframes think { 50% { opacity: 0.45; } }

.reasoning__body {
  padding: 10px 14px 12px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

/* ============ Страницы входа/регистрации ============ */

body.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
  background:
    radial-gradient(700px 420px at 70% -10%, rgba(139, 92, 246, 0.12), transparent 60%),
    var(--bg);
}

.auth-card {
  width: min(400px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 28px 26px 26px;
  box-shadow: var(--shadow-pop);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
  margin-bottom: 14px;
}

.auth-orb {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 6px 26px rgba(124, 58, 237, 0.45);
}

.auth-orb svg { width: 22px; height: 22px; color: #fff; }

.auth-title {
  margin: 0 0 18px;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.auth-field { margin-bottom: 14px; }

.auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--text);
  font-size: 17px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field input:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.auth-field input::placeholder { color: var(--text-faint); }

.auth-error {
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13.5px;
  color: #fca5a5;
  margin-bottom: 14px;
}

.auth-submit {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.35);
  transition: filter 0.15s ease, transform 0.1s ease;
}

.auth-submit:hover { filter: brightness(1.12); }
.auth-submit:active { transform: scale(0.99); }

.auth-switch {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-faint);
  text-decoration: none;
  transition: color 0.15s ease;
}

.auth-switch:hover { color: var(--accent-hover); }

/* ============ Страница настроек ============ */

.settings-body {
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.settings-app {
  display: flex;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* Сайдбар / меню разделов (как в чате) */

.settings-nav {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  gap: 12px;
  z-index: 60;
  transition: transform 0.24s ease;
}

.settings-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
  min-height: 36px;
}

.settings-nav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.2px;
}

.settings-nav__close {
  display: none;
}

.settings-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}

.settings-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.settings-menu__item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-faint);
  transition: color 0.12s ease;
}

.settings-menu__item:hover {
  background: var(--bg-elev2);
  color: var(--text);
}

.settings-menu__item:hover svg {
  color: var(--text-dim);
}

.settings-menu__item.is-active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.settings-menu__item.is-active svg {
  color: var(--accent);
}

.settings-nav__foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 4px 0;
  border-top: 1px solid var(--border);
}

.settings-nav__foot-link,
.settings-nav__foot-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.settings-nav__foot-link svg,
.settings-nav__foot-user svg {
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.settings-nav__foot-link:hover,
.settings-nav__foot-user:hover {
  background: var(--bg-elev2);
  color: var(--text);
}

.settings-nav__foot-link:hover svg,
.settings-nav__foot-user:hover svg {
  color: var(--accent);
}

/* Основная колонка */

.settings-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100dvh;
  background: var(--bg);
}

/* Топбар */

.settings-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
  background: rgba(29, 33, 39, 0.65);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  z-index: 20;
  flex-shrink: 0;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .settings-topbar { background: rgba(29, 33, 39, 0.94); }
}

.settings-topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.settings-menu-btn {
  display: none;
}

.settings-topbar__title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.settings-topbar__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.settings-topbar__back svg {
  width: 15px;
  height: 15px;
}

.settings-topbar__back:hover {
  background: var(--bg-elev2);
  border-color: var(--accent-border);
  color: var(--text);
}

/* Скролл и центрированный контент */

.settings-scroll {
  flex: 1;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.settings-content {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  display: flex;
  flex-direction: column;
}

.settings-lead {
  margin: 0 0 28px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-dim);
}

.settings-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 20px;
}

.settings-info {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.settings-info__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.settings-info__row:last-child {
  border-bottom: none;
}

.settings-info__row dt {
  font-size: 14px;
  color: var(--text-dim);
}

.settings-info__row dd {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  overflow-wrap: anywhere;
}

.settings-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.settings-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.settings-cards--fonts {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

.settings-label {
  display: block;
  padding: 0;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
}

.settings-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  min-height: 74px;
  padding: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.settings-option:hover:not(.settings-option--disabled) {
  border-color: var(--accent);
  background: var(--bg-elev2);
}

.settings-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.settings-option input[type='radio'] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  flex-shrink: 0;
}

.settings-option--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.settings-option__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.settings-option__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.settings-option__name:has(+ .settings-option__desc) {
  line-height: 1.35;
}

.settings-option__desc {
  font-size: 12.5px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.settings-preview {
  margin-top: 24px;
  padding: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.settings-preview__label {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
}

.settings-preview__bubble {
  line-height: 1.65;
  font-size: 18px;
  transition: font-size 0.15s ease;
}

.settings-form textarea {
  width: 100%;
  max-width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--mono);
  line-height: 1.55;
  outline: none;
  resize: vertical;
  min-height: 240px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.settings-form textarea:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.settings-form textarea::placeholder {
  color: var(--text-faint);
}

.settings-form .auth-field {
  margin-bottom: 20px;
}

.settings-form .auth-field:last-child {
  margin-bottom: 0;
}

.settings-form .auth-field input {
  min-width: 0;
  min-height: 48px;
}

.settings-field-hint {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

/* Липкая нижняя панель действий (как composer-zone) */

.settings-actions-zone {
  flex-shrink: 0;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(29, 33, 39, 0.65);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  z-index: 10;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .settings-actions-zone { background: rgba(29, 33, 39, 0.94); }
}

.settings-actions-max {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-actions__hint {
  font-size: 13px;
  color: var(--text-dim);
}

.settings-actions__submit {
  width: auto;
  min-width: 170px;
  min-height: 46px;
  padding: 12px 24px;
  box-shadow: none;
}

.settings-body :is(a, button, input, textarea, [tabindex]):focus-visible,
.settings-option:has(input:focus-visible) {
  outline: 2px solid var(--accent-hover);
  outline-offset: 3px;
}

/* Размер текста сообщений (настройка «Внешний вид») */

body[data-font='compact'] .msg-content { font-size: 16px; }
body[data-font='large'] .msg-content { font-size: 20px; }

.profile-banner {
  margin-bottom: 24px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  border: 1px solid;
}

.profile-banner--success {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.35);
  color: #6ee7a0;
}

.profile-banner--error,
.profile-banner--warning {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

/* ============ Адаптивность настроек ============ */

@media (max-width: 768px) {
  .settings-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 86vw);
    transform: translateX(-105%);
    box-shadow: none;
  }

  .settings-nav.open {
    transform: translateX(0);
    box-shadow: var(--shadow-pop);
  }

  .settings-nav__close {
    display: inline-flex;
  }

  .settings-menu-btn {
    display: inline-flex;
  }

  .settings-topbar {
    padding: 8px 12px;
    min-height: 54px;
  }

  .settings-topbar__title {
    font-size: 17px;
  }

  .settings-topbar__back span {
    display: none;
  }

  .settings-topbar__back {
    padding: 7px 9px;
  }

  .settings-content {
    padding: 20px 14px 32px;
  }

  .settings-lead {
    margin-bottom: 20px;
    font-size: 14px;
  }

  .settings-cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-cards--fonts {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-info__row {
    padding: 14px 0;
  }

  .settings-actions-zone {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }

  .settings-actions-max {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 8px;
  }

  .settings-actions__hint {
    text-align: center;
    font-size: 12px;
    display: none;
  }

  .settings-actions__submit {
    width: 100%;
    min-width: 0;
    min-height: 48px;
  }
}


/* ---------- Источники веб-поиска ---------- */

.msg-sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.msg-sources__label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.msg-sources__label svg { width: 14px; height: 14px; color: var(--accent); }

.msg-sources__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13.5px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.source-chip:hover {
  border-color: var(--accent-border);
  color: var(--text);
}

.source-chip__domain {
  font-weight: 700;
  color: var(--accent-hover);
  flex-shrink: 0;
}

.source-chip__title {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-chip svg { width: 13px; height: 13px; color: var(--text-faint); flex-shrink: 0; }
.source-chip:hover svg { color: var(--accent-hover); }

.search-btn { color: var(--text-faint); }

.search-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.search-btn.active:hover { background: var(--accent-soft); color: var(--accent-hover); }

.search-btn.active svg {
  filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.6));
}

.ignore-btn { color: var(--text-faint); }

.ignore-btn.active {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.16);
}

.ignore-btn.active:hover {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
}

.ignore-btn.active svg {
  filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.6));
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .messages-wrap { scroll-behavior: auto; }
}
