/* Chat GPT — чат-интерфейс (синие акценты как у Deepseek) */

.cg-chat-layout {
  --accent: #0066ff;
  --accent-hover: #0052cc;
  display: flex;
  height: calc(100vh - 70px);
  min-height: 0;
  overflow: hidden;
}

.cg-sidebar {
  width: 260px;
  min-width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border, #e8e8e8);
  background: var(--bg, #fff);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cg-sidebar-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 12px 8px;
}
.cg-sidebar-title {
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  border-bottom: none;
  min-width: 0;
}
.cg-sidebar-header-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.cg-chat-search-toggle {
  display: flex;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--border-light, #f0f0f0);
  color: var(--text, #1a1a1a);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.cg-chat-search-toggle:hover {
  background: var(--border, #e0e0e0);
}
.cg-sidebar-close {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--border-light, #f0f0f0);
  color: var(--text, #1a1a1a);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.cg-sidebar-close:hover {
  background: var(--border, #e0e0e0);
}
.cg-chats-burger {
  display: none;
  position: fixed;
  top: 78px;
  left: 12px;
  z-index: 50;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--td-surface, var(--input-bg, #fff));
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  transition: background 0.2s, box-shadow 0.2s;
  touch-action: manipulation;
}
.cg-chats-burger:hover {
  background: var(--border-light, #f5f5f5);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.cg-chats-burger::before {
  content: '→';
  font-size: 1.35rem;
  line-height: 1;
  color: var(--text, #1a1a1a);
}
body.cg-sidebar-open .cg-chats-burger::before {
  content: '←';
}
.cg-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: 70px;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, visibility 0.2s;
}
.cg-sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.cg-new-chat {
  flex-shrink: 0;
  margin: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 12px;
  background: var(--border-light, #f5f5f5);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text, #1a1a1a);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cg-new-chat::before {
  content: '+';
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg, #fff);
  border: 1px solid var(--border, #e0e0e0);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1;
}

.cg-new-chat:hover {
  background: var(--border-light, #f5f5f5);
  border-color: var(--accent, #0066ff);
  color: var(--accent, #0066ff);
}

.cg-chat-search-panel {
  flex-shrink: 0;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border, #eee);
}
.cg-chat-search-panel.hidden {
  display: none !important;
}
.cg-chat-search-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.cg-chat-search-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--input-bg, var(--bg, #fff));
  color: var(--text, #1a1a1a);
  box-sizing: border-box;
}
.cg-chat-search-input:focus {
  outline: none;
  border-color: var(--accent, #0066ff);
  box-shadow: 0 0 0 2px rgba(0, 102, 255, 0.15);
}
.cg-chat-search-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--border-light, #f0f0f0);
  color: var(--text-muted, #666);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cg-chat-search-close:hover {
  background: var(--border, #e0e0e0);
  color: var(--text, #1a1a1a);
}
.cg-chat-search-status {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted, #888);
  min-height: 1.2em;
}
.cg-chat-search-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: min(50vh, 320px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.cg-chat-search-hit {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 10px;
  border: 1px solid var(--border, #e8e8e8);
  background: var(--border-light, #fafafa);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.cg-chat-search-hit:hover {
  border-color: var(--accent, #0066ff);
  background: rgba(0, 102, 255, 0.06);
}
.cg-chat-search-hit-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.cg-chat-search-hit-head .cg-chat-search-hit-title {
  flex: 1;
  min-width: 0;
}
.cg-chat-search-hit-model {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}
.cg-chat-search-hit-title {
  display: block;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text, #1a1a1a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cg-chat-search-hit-meta {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted, #888);
  margin-top: 2px;
}
.cg-chat-search-hit-snippet {
  font-size: 0.78rem;
  color: var(--text-secondary, #555);
  margin-top: 4px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cg-chat-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 8px 12px;
}
.cg-chat-group-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 12px 4px 6px;
  margin: 0;
}
.cg-chat-group-title:first-child {
  padding-top: 4px;
}

.cg-chat-item {
  display: flex;
  align-items: center;
  border-radius: 10px;
  margin-bottom: 4px;
  position: relative;
}

.cg-chat-item:hover .cg-chat-item-actions {
  opacity: 1;
}

.cg-chat-item.active {
  background: var(--border-light, #f0f0f0);
}

.cg-chat-item-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 10px 12px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text, #1a1a1a);
  border-radius: 10px;
  min-width: 0;
}
.cg-chat-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  width: 100%;
}
.cg-chat-item-model {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
  width: 1.25rem;
  text-align: center;
}
.cg-chat-item-top .cg-chat-item-title {
  flex: 1;
  min-width: 0;
}

.cg-chat-item-btn:hover {
  background: var(--border-light, #f5f5f5);
}

.cg-chat-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-weight: 500;
}

.cg-chat-item-date {
  font-size: 0.75rem;
  color: var(--text-muted, #888);
  margin-top: 2px;
}

.cg-chat-item-actions {
  opacity: 0;
  display: flex;
  gap: 2px;
  padding: 0 4px;
  transition: opacity 0.2s;
}

.cg-chat-rename,
.cg-chat-delete {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted, #888);
  transition: color 0.2s, background 0.2s;
}

.cg-chat-rename:hover,
.cg-chat-delete:hover {
  color: var(--text, #1a1a1a);
  background: var(--border-light, #eee);
}

.cg-chat-delete:hover {
  color: #c62828;
}

/* Мини-подтверждение удаления чата (fixed у кнопки ×) */
.text-chat-delete-confirm {
  position: fixed;
  z-index: 10050;
  min-width: 200px;
  max-width: min(280px, calc(100vw - 16px));
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg, #fff);
  border: 1px solid var(--border, #e8e8e8);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.03);
  font-size: 0.875rem;
  box-sizing: border-box;
  line-height: 1.4;
}

.text-chat-delete-confirm__title {
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  font-size: 0.9rem;
}

.text-chat-delete-confirm__hint {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  color: var(--text-muted, #666);
}

.text-chat-delete-confirm__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.text-chat-delete-confirm__btn {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border, #e0e0e0);
  background: var(--border-light, #f5f5f5);
  color: var(--text, #1a1a1a);
  transition: background 0.15s, border-color 0.15s;
}

.text-chat-delete-confirm__btn:hover {
  background: var(--border, #e8e8e8);
}

.text-chat-delete-confirm__btn--danger {
  background: #c62828;
  border-color: #b71c1c;
  color: #fff;
}

.text-chat-delete-confirm__btn--danger:hover {
  background: #b71c1c;
  border-color: #a01515;
}

/* Два блока: сообщения (скролл) + поле ввода (статично) */
.cg-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-page, #fafafa);
}

.cg-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.cg-messages::-webkit-scrollbar {
  display: none;
}

.cg-scroll-to-bottom {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  color: #0066FF;
  font-size: 1.25rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.2s, transform 0.2s;
}

.cg-scroll-to-bottom.visible {
  display: inline-flex;
  animation: cg-scroll-btn-in 0.3s ease-out;
}

.cg-scroll-to-bottom:hover {
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

@keyframes cg-scroll-btn-in {
  0% { opacity: 0; transform: translateY(-50%) scale(0.8); }
  60% { transform: translateY(-50%) scale(1.05); }
  100% { opacity: 1; transform: translateY(-50%) scale(1); }
}

.cg-input-area {
  flex: 0 0 auto;
  border-top: 1px solid var(--border, #e5e5e5);
  background: var(--bg, #fff);
  padding: 20px 24px;
  position: relative;
}

.cg-welcome {
  flex: 1;
  min-height: 40vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted, #888);
}

.cg-welcome.hidden {
  display: none;
}

.cg-welcome-icon {
  font-size: 4rem;
  opacity: 0.9;
}

.cg-welcome-text {
  font-size: 1rem;
  font-weight: 500;
}

.cg-msg {
  display: flex;
  gap: 12px;
  max-width: 100%;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  align-self: flex-start;
  /* Иначе колонка с аватаром тянется на высоту пузыря — PRO-обводка «съезжает» */
  align-items: flex-start;
}

.cg-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
  /* Не шире ленты: иначе длинная строка/URL раздувает ряд и уезжает за край */
  max-width: 100%;
}

@keyframes cgMsgHighlight {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 102, 255, 0.45);
  }
  35% {
    box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.2);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 102, 255, 0);
  }
}

.cg-msg.cg-msg--highlight {
  animation: cgMsgHighlight 1.2s ease-out 1;
  border-radius: 12px;
}

.cg-msg-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  background: var(--border-light, #eee);
  border-radius: 10px;
  overflow: hidden;
  box-sizing: border-box;
}

.cg-msg-user .cg-msg-avatar {
  border-radius: 50%;
  background: rgba(0, 102, 255, 0.12);
  font-weight: 600;
  color: var(--accent, #0066ff);
}

.cg-msg-user .cg-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.cg-msg-user .cg-msg-avatar-pro-wrap {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 2px;
  border-radius: 50%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(135deg, #ffcba4 0%, #e8a0bf 50%, #9b59b6 100%);
  box-shadow: 0 0 10px rgba(155, 89, 182, 0.35);
}

.cg-msg-user .cg-msg-avatar-pro-wrap .cg-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  box-sizing: border-box;
}

.cg-msg-user-body {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.cg-msg-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.6;
  word-break: break-word;
}

.cg-msg-user .cg-msg-content {
  background: var(--accent, #0066ff);
  color: #fff;
  border-radius: 12px;
  border-bottom-right-radius: 4px;
  max-width: 100%;
  width: fit-content;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}

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

.cg-msg-user .cg-msg-attachment-img {
  max-width: 200px;
  max-height: 180px;
  width: auto;
  height: auto;
  border-radius: 8px;
  display: block;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.cg-msg-user .cg-msg-attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  font-size: 0.8125rem;
  opacity: 0.95;
  border: 1px solid rgba(255, 255, 255, 0.35);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cg-msg-user .cg-msg-attachment-file-icon {
  flex-shrink: 0;
}

.cg-msg-user .cg-msg-attachment-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cg-msg-user .cg-msg-actions {
  justify-content: flex-end;
}

.cg-msg-user:hover .cg-msg-actions {
  opacity: 1;
}

.cg-msg-assistant {
  width: 100%;
  max-width: 100%;
}
.cg-msg-assistant .cg-msg-avatar {
  display: none;
}
.cg-msg-assistant-body {
  flex: 1;
  min-width: 0;
  max-width: 100%;
}
.cg-msg-model-badge {
  display: inline-block;
  align-self: flex-start;
  max-width: 100%;
  margin-bottom: 8px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text, #1a1a1a);
  background: linear-gradient(135deg, rgba(0, 102, 255, 0.12), rgba(124, 58, 237, 0.1));
  border: 1px solid rgba(0, 102, 255, 0.22);
  border-radius: 999px;
  line-height: 1.35;
  box-sizing: border-box;
}
.cg-msg-model-badge--pending {
  font-weight: 500;
  color: var(--text-muted, #555);
  background: var(--border-light, #eee);
  border-color: var(--border, #ddd);
  animation: cg-model-pulse 1.2s ease-in-out infinite;
}
@keyframes cg-model-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}
html[data-theme="dark"] .cg-msg-model-badge,
body.dark-theme .cg-msg-model-badge {
  color: #e8e8ec;
  background: linear-gradient(135deg, rgba(0, 102, 255, 0.2), rgba(124, 58, 237, 0.15));
  border-color: rgba(0, 102, 255, 0.35);
}
html[data-theme="dark"] .cg-msg-model-badge--pending,
body.dark-theme .cg-msg-model-badge--pending {
  color: #b0b0b8;
  background: #2a2a32;
  border-color: rgba(255, 255, 255, 0.12);
}
.cg-msg-assistant .cg-msg-content {
  background: var(--td-surface, var(--input-bg, #fff));
  border: 1px solid var(--border, #e8e8e8);
  border-radius: 12px;
  padding: 14px 18px;
  color: var(--text, #1a1a1a);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  overflow-x: hidden;
  overflow-y: visible;
}
.cg-msg-assistant .cg-msg-content::-webkit-scrollbar,
.cg-msg-assistant .cg-msg-content pre::-webkit-scrollbar {
  display: none;
}
.cg-msg-assistant .cg-msg-content pre {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cg-msg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.cg-msg-assistant:hover .cg-msg-actions {
  opacity: 1;
}
.cg-msg-action {
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary, #666);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.cg-msg-action:hover {
  background: var(--border-light, #f0f0f0);
  color: var(--text, #1a1a1a);
}
.cg-msg-action[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%) translateY(-6px);
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #fff;
  background: rgba(0, 0, 0, 0.85);
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.cg-msg-action[title]:hover::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%) translateY(2px);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.85);
  pointer-events: none;
  z-index: 21;
}
.cg-msg-action svg {
  display: block;
}

.cg-msg-content.cg-msg-content--streaming {
  min-height: 1.5em;
}
.cg-msg-content.cg-msg-content--streaming::after {
  content: '|';
  display: inline;
  margin-left: 2px;
  color: var(--accent, #0066ff);
  animation: cg-cursor-blink 1s step-end infinite;
  vertical-align: text-bottom;
}
.cg-msg-content.cg-msg-content--no-cursor::after {
  display: none;
}
@keyframes cg-cursor-blink {
  50% { opacity: 0; }
}

.cg-msg-content h1 {
  margin: 1em 0 0.35em;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}
.cg-msg-content h2 {
  margin: 0.9em 0 0.3em;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.35;
}
.cg-msg-content h3, .cg-msg-content h4, .cg-msg-content h5, .cg-msg-content h6 {
  margin: 0.75em 0 0.25em;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}
.cg-msg-content h1:first-child, .cg-msg-content h2:first-child,
.cg-msg-content h3:first-child, .cg-msg-content h4:first-child,
.cg-msg-content h5:first-child, .cg-msg-content h6:first-child { margin-top: 0; }

.cg-msg-content p {
  margin: 0 0 0.75em 0;
  line-height: 1.6;
}
.cg-msg-content p:first-child { margin-top: 0; }
.cg-msg-content p:last-child { margin-bottom: 0; }

.cg-msg-content hr {
  margin: 1.25em 0;
  border: none;
  border-top: 1px solid var(--border-light, #eee);
}

.cg-msg-content ul, .cg-msg-content ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
  line-height: 1.55;
}
.cg-msg-content li {
  margin: 0.2em 0;
}
.cg-msg-content ul { list-style-type: disc; }
.cg-msg-content ol { list-style-type: decimal; }

.cg-msg-content blockquote {
  margin: 0.75em 0;
  padding: 0.5em 0 0.5em 1em;
  border-left: 4px solid var(--border, #ddd);
  background: var(--border-light, #f8f8f8);
  color: var(--text-secondary, #555);
  border-radius: 0 6px 6px 0;
}

.cg-msg-content strong { font-weight: 700; }
.cg-msg-content em { font-style: italic; }
.cg-msg-content del,
.cg-msg-content s { text-decoration: line-through; }
.cg-msg-content mark { background: rgba(255, 193, 7, 0.35); padding: 0 0.15em; border-radius: 2px; }

.cg-msg-content a {
  color: #0066ff;
  text-decoration: none;
}
.cg-msg-content a:hover {
  text-decoration: underline;
}

.cg-msg-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75em 0;
  font-size: 0.9rem;
}
.cg-msg-content thead {
  background: var(--border-light, #f0f0f0);
}
.cg-msg-content th,
.cg-msg-content td {
  border: 1px solid var(--border, #e0e0e0);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.cg-msg-content th {
  font-weight: 600;
  color: var(--text, #1a1a1a);
}
.cg-msg-content tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}
.cg-msg-content pre {
  margin: 0.75em 0;
  padding: 12px 14px;
  background: #f6f6f6;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.5;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cg-msg-content pre::-webkit-scrollbar {
  display: none;
}

.cg-msg-content code {
  font-family: ui-monospace, 'SF Mono', Monaco, monospace;
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.cg-msg-content pre code {
  background: none;
  padding: 0;
}

.cg-msg-user .cg-msg-content pre {
  background: rgba(255,255,255,0.2);
}

.cg-typing {
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 8px 0 16px;
  background: var(--bg-page, #fafafa);
  box-sizing: border-box;
}
.cg-typing-inner {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  padding: 0 32px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cg-typing-text-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}
.cg-typing-model {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  line-height: 1.3;
  max-width: 100%;
}
html[data-theme="dark"] .cg-typing-model,
body.dark-theme .cg-typing-model {
  color: #e8e8ec;
}
.cg-typing-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: var(--border-light, #eee);
  border-radius: 10px;
  flex-shrink: 0;
}

.cg-typing-dots {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: 0;
  flex-shrink: 0;
  min-width: 0;
}

.cg-typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted, #888);
  animation: cg-typing-bounce 1.4s ease-in-out infinite both;
}

.cg-typing-dots span:nth-child(1) { animation-delay: 0s; }
.cg-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.cg-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cg-typing-bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

.cg-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 800px;
  margin: 0 auto;
  padding: 12px 16px 12px 12px;
  background: var(--bg, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.cg-input-wrap:focus-within {
  border-color: #0066ff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06), 0 0 0 2px rgba(0, 102, 255, 0.35), 0 0 16px rgba(0, 102, 255, 0.2), 0 0 32px rgba(0, 102, 255, 0.08);
}

.cg-input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light, #f0f0f0);
}

.cg-input-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.cg-option-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary, #666);
  cursor: pointer;
  user-select: none;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.cg-option-toggle:hover {
  background: var(--border-light, #f5f5f5);
  color: var(--text, #1a1a1a);
}

.cg-option-toggle.active {
  background: color-mix(in srgb, var(--accent, #0066ff) 12%, transparent);
  color: var(--accent, #0066ff);
}

.cg-option-toggle input {
  width: 14px;
  height: 14px;
  cursor: pointer;
  margin: 0;
}

.cg-thinking-select {
  border: 1px solid var(--border, #e0e0e0);
  background: var(--input-bg, #fff);
  color: var(--text, #1a1a1a);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.8125rem;
}

.cg-search-price-hint {
  font-weight: 500;
  color: var(--text-muted, #888);
}

.cg-option-toggle.active .cg-search-price-hint {
  color: inherit;
}

.cg-plus-menu-icon-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  font-size: 1rem;
  line-height: 1;
}

.cg-msg-reasoning {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #e8e8e8);
  background: var(--border-light, #f8f9fb);
  font-size: 0.8125rem;
}

.cg-msg-reasoning summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary, #555);
  list-style: none;
}

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

.cg-msg-reasoning-pre {
  margin: 8px 0 0;
  padding: 8px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--text-muted, #666);
  background: var(--bg, #fff);
  border-radius: 6px;
}

.cg-msg-reasoning-pre--placeholder {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  white-space: normal;
  font-family: inherit;
}

.cg-msg-awaiting {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--border-light, #f5f5f5);
  color: var(--text-muted, #888);
  font-size: 0.9375rem;
}

.cg-msg-awaiting-label {
  flex-shrink: 0;
}

.cg-msg-awaiting-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cg-msg-awaiting-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted, #888);
  animation: cg-typing-bounce 1.4s ease-in-out infinite both;
}

.cg-msg-awaiting-dots span:nth-child(1) { animation-delay: 0s; }
.cg-msg-awaiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.cg-msg-awaiting-dots span:nth-child(3) { animation-delay: 0.4s; }

.cg-mobile-active-badges {
  display: none;
}

.cg-mobile-active-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  opacity: 0.92;
}

.cg-input-cost {
  font-size: 0.7rem;
  color: #666;
  margin: 0;
  min-height: 1.2em;
  flex-shrink: 0;
}

.cg-mobile-plus-menu {
  display: none;
}

.cg-mobile-search-toggle {
  display: none;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text, #1a1a1a);
}

.cg-input-disclaimer {
  max-width: 800px;
  margin: 8px auto 0;
  padding: 0;
  font-size: 0.75rem;
  color: var(--text-muted, #888);
  text-align: center;
}

.cg-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

/**
 * Вне экрана: не перекрывает скрепку, .click() со скрепки в том же жесте открывает диалог
 * (display:none у file часто ломает это в Safari).
 */
.cg-file-input {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  pointer-events: none;
}

.cg-attach {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--border-light, #f0f0f0);
  color: var(--text-secondary, #666);
  font-size: 1.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.cg-attach:hover {
  background: var(--border, #e0e0e0);
  color: var(--text, #1a1a1a);
}

.cg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light, #f0f0f0);
  min-height: 0;
}

.cg-attachments:empty {
  display: none;
}

.cg-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--border-light, #f0f0f0);
  border-radius: 20px;
  font-size: 0.8125rem;
  color: var(--text, #1a1a1a);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cg-attachment-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cg-attachment-chip-remove {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted, #888);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}

.cg-attachment-chip-remove:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text, #1a1a1a);
}

.cg-input {
  flex: 1;
  min-width: 0;
  min-height: 24px;
  max-height: 200px;
  padding: 12px 16px 12px 20px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text, #1a1a1a);
  resize: none;
  outline: none;
  overflow-y: auto;
}

.cg-input:focus {
  outline: none;
}

.cg-input::placeholder {
  color: var(--text-muted, #888);
}

.cg-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #0066ff;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cg-send-icon {
  display: block;
}

.cg-send:hover:not(:disabled) {
  background: #0052cc;
  transform: scale(1.05);
}

.cg-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  html {
    height: 100%;
    overflow: hidden;
  }
  body {
    height: 100%;
    overflow: hidden;
    overflow-x: hidden;
    min-height: 0;
  }

  .cg-chat-layout {
    height: calc(100vh - 70px);
    /* JS: visualViewport − реальная высота .header; fallback — dvh минус измеренная/типовая шапка */
    height: var(--text-chat-inner-height, calc(100dvh - max(70px, var(--td-header-h, 70px))));
    overflow: hidden;
    overflow-x: hidden;
    min-height: 0;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
  }

  .cg-sidebar-overlay {
    display: block;
    top: var(--td-header-bottom, 70px);
  }

  /* absolute в .cg-main — не fixed от viewport: иначе расходится с колонкой чата (PWA, ptr, visualViewport) и наезжает на шапку/баннер */
  .cg-chats-burger {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    left: max(12px, env(safe-area-inset-left, 12px));
    z-index: 25;
  }

  body.cg-sidebar-open {
    overflow: hidden;
  }

  .cg-sidebar {
    position: fixed;
    left: 0;
    top: var(--td-header-bottom, 70px);
    bottom: 0;
    width: min(320px, 100vw - 48px);
    max-width: 100%;
    z-index: 100;
    /* Чуть дальше за край — не просвечивает «Новый чат» на некоторых WebKit */
    transform: translateX(calc(-100% - 20px));
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    padding-left: env(safe-area-inset-left, 0);
    border-radius: 0 20px 20px 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

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

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

  .cg-chat-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .cg-chat-item-actions {
    opacity: 1;
    gap: 6px;
    padding: 0 6px;
  }

  .cg-chat-rename,
  .cg-chat-delete {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1.35rem;
    border-radius: 10px;
  }

  .cg-main {
    padding-left: 0;
    min-width: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    flex-basis: 0;
    position: relative;
    /* Место под absolute .cg-input-area, чтобы #cgTyping (между лентой и инпутом) не перекрывался композером */
    padding-bottom: var(--cg-composer-reserve, max(120px, calc(96px + env(safe-area-inset-bottom, 0px))));
  }

  body.cg-smart-dispatch-page .cg-main {
    padding-bottom: var(--cg-composer-reserve, max(200px, calc(160px + env(safe-area-inset-bottom, 0px))));
  }

  .cg-messages {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Снизу: не дублировать --cg-composer-reserve — он на .cg-main (иначе двойной отступ до инпута). Лёгкий inset для жеста/домашней полосы. */
    padding: 16px 20px;
    padding-left: max(56px, env(safe-area-inset-left, 56px));
    padding-right: max(20px, env(safe-area-inset-right, 12px));
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }

  /* Нет блока cg-smart-header: бургер вверху колонки — доп. отступ сверху ленты */
  body:not(.cg-smart-dispatch-page) .cg-messages {
    padding-top: max(16px, calc(12px + 44px + 10px));
  }

  .cg-welcome {
    max-width: 100%;
    box-sizing: border-box;
  }

  .cg-msg-content img {
    max-width: 100%;
    height: auto;
  }
  .cg-msg-content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.cg-smart-dispatch-page .cg-messages {
    /* Высоту композера резервирует .cg-main; здесь только небольшой нижний inset */
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    scroll-padding-top: 10px;
  }

  .cg-msg {
    scroll-margin-top: 8px;
  }

  .cg-msg-reasoning {
    max-width: 100%;
    box-sizing: border-box;
  }
  .cg-msg-reasoning-pre {
    max-height: min(220px, 42vh);
  }

  .cg-smart-header {
    padding-left: max(56px, env(safe-area-inset-left, 56px));
    padding-right: max(20px, env(safe-area-inset-right, 12px));
    padding-top: 8px;
    padding-bottom: 8px;
  }

  /* Mishka AI: шапка чата — свой слой, без налезания на ленту; бургер absolute выше */
  body.cg-smart-dispatch-page .cg-smart-header {
    max-width: 100%;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-page, var(--bg, #fafafa));
    position: relative;
    z-index: 6;
    flex-shrink: 0;
    isolation: isolate;
    padding-top: 10px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
  }
  body.cg-smart-dispatch-page .cg-smart-header-top {
    min-height: 44px;
    align-items: center;
  }
  body.cg-smart-dispatch-page .cg-smart-model-banner {
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-break: break-word;
    margin-top: 12px;
    position: relative;
    z-index: 0;
  }
  body.cg-smart-dispatch-page .cg-smart-title {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Mishka AI: название чата справа (на месте ⚙️), настройки — в зоне под промптом */
  body.cg-smart-dispatch-page .cg-smart-header-actions {
    display: none;
  }
  body.cg-smart-dispatch-page .cg-smart-header-top {
    justify-content: flex-end;
  }
  body.cg-smart-dispatch-page .cg-smart-title {
    text-align: right;
    max-width: 100%;
    font-size: 0.95rem;
  }

  body.cg-smart-dispatch-page .cg-smart-settings-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
    border-radius: 7px;
    background: var(--border-light, #f0f0f0);
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary, #666);
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
  }
  html[data-theme="dark"] body.cg-smart-dispatch-page .cg-smart-settings-mobile,
  body.dark-theme.cg-smart-dispatch-page .cg-smart-settings-mobile {
    background: #2a2a32;
    border-color: rgba(255, 255, 255, 0.12);
    color: #c4c4ce;
  }

  .cg-smart-debate-panel {
    margin-left: 0;
    margin-right: 0;
    padding-left: max(12px, env(safe-area-inset-left, 12px));
    padding-right: max(12px, env(safe-area-inset-right, 12px));
    max-height: min(65vh, 560px);
  }

  .cg-smart-debate-pre {
    max-height: min(38vh, 300px);
  }

  .cg-typing-inner {
    padding: 0 12px 0 56px;
    padding-left: max(56px, env(safe-area-inset-left, 56px));
  }

  /* Выше .cg-smart-header (z-index:6) и бургера (25), иначе баннер «Отвечает» перекрывает промпт */
  .cg-input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    padding: 12px 12px max(12px, env(safe-area-inset-bottom, 12px));
    padding-left: max(12px, env(safe-area-inset-left, 12px));
    padding-right: max(12px, env(safe-area-inset-right, 12px));
    background: transparent;
    border-top: none;
    pointer-events: none;
  }

  .cg-input-area::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: max(80px, calc(60px + env(safe-area-inset-bottom, 0)));
    background: var(--bg-page, #fafafa);
    pointer-events: none;
    z-index: 0;
  }

  .cg-input-area .cg-input-wrap {
    pointer-events: auto;
    position: relative;
    z-index: 50;
  }

  .cg-input-disclaimer {
    display: block;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    text-align: center;
  }

  .cg-input-wrap {
    max-width: 100%;
    min-width: 0;
    overflow: visible;
    box-sizing: border-box;
    position: relative;
  }

  .cg-mobile-plus-menu {
    display: none;
    position: absolute;
    left: 0;
    bottom: calc(100% + 10px);
    flex-direction: column;
    background: var(--td-surface, var(--input-bg, #fff));
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    min-width: 220px;
    z-index: 10;
    border: 1px solid var(--border, #e8e8e8);
  }
  .cg-mobile-plus-menu.open {
    display: flex;
  }

  .cg-plus-menu-attach-block {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  /* Не используем pointer-events: none — иначе клик не доходит до JS (нет диалога и нет подсказки PRO). */
  .cg-plus-menu-item.cg-plus-menu-item--pro-locked {
    opacity: 0.5;
    cursor: not-allowed;
  }
  .cg-plus-menu-item.cg-plus-menu-item--pro-locked:hover {
    background: none;
  }
  .cg-plus-menu-pro-link {
    margin: -4px 0 6px;
    padding: 0 16px 10px 52px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent, #0066ff);
    text-decoration: none;
    align-self: flex-start;
  }
  .cg-plus-menu-pro-link:hover {
    text-decoration: underline;
  }
  .cg-plus-menu-pro-link:focus-visible {
    outline: 2px solid var(--accent, #0066ff);
    outline-offset: 2px;
    border-radius: 4px;
  }

  .cg-plus-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text, #1a1a1a);
    text-align: left;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
  }
  .cg-plus-menu-item:hover {
    background: var(--border-light, #f5f5f5);
  }
  .cg-plus-menu-icon {
    flex-shrink: 0;
    opacity: 0.9;
  }
  .cg-plus-menu-item.active {
    color: var(--accent, #0066ff);
    font-weight: 600;
    background: color-mix(in srgb, var(--accent, #0066ff) 14%, transparent);
  }
  .cg-plus-menu-item.active .cg-plus-menu-icon {
    color: var(--accent, #0066ff);
  }
  .cg-plus-menu-badge {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent, #0066ff);
    background: color-mix(in srgb, var(--accent, #0066ff) 22%, transparent);
    padding: 2px 8px;
    border-radius: 6px;
  }
  .cg-plus-menu-item:not(.active) .cg-plus-menu-badge {
    display: none;
  }

  .cg-mobile-search-toggle {
    display: inline-flex;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--border, #e0e0e0);
    background: var(--input-bg, #fff);
    color: var(--text, #333);
    font-size: 1.5rem;
    font-weight: 300;
  }
  .cg-mobile-search-toggle.active {
    background: color-mix(in srgb, var(--accent, #0066ff) 14%, transparent);
    border-color: color-mix(in srgb, var(--accent, #0066ff) 45%, transparent);
    color: var(--accent, #0066ff);
  }

  .cg-input-footer {
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    min-height: 0;
  }

  .cg-mobile-active-badges:not([hidden]) {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    line-height: 1;
    font-size: 0.7rem;
    padding: 0;
    margin: 0;
  }

  .cg-mobile-active-badges[hidden] {
    display: none !important;
  }

  .cg-input-cost {
    margin-left: auto;
    text-align: right;
    line-height: 1.15;
  }

  .cg-input-options {
    display: none;
  }

  /* Файлы на мобилке только через «+» → «Фото, PDF»; дублирующая скрепка в строке не нужна. */
  .cg-attach {
    display: none !important;
  }

  .cg-input-row {
    min-width: 0;
    overflow: visible;
    align-items: center;
    gap: 10px;
    padding-right: 4px;
    box-sizing: border-box;
  }

  .cg-input {
    max-height: 100px;
  }

  .cg-send {
    background: var(--accent, #0066ff);
    color: #fff;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }
  .cg-send .cg-send-icon {
    display: none;
  }
  .cg-send::after {
    content: '↑';
    font-size: 1.35rem;
    line-height: 1;
    color: #fff;
  }
  .cg-send:hover:not(:disabled) {
    background: var(--accent-hover, #0052cc);
  }

  .cg-msg {
    max-width: 100%;
    overflow: visible;
    align-items: flex-start;
  }

  .cg-msg-user .cg-msg-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .cg-msg-user .cg-msg-avatar-pro-wrap {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 2px;
    box-sizing: border-box;
  }

  .cg-msg-user .cg-msg-avatar-pro-wrap .cg-msg-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    box-sizing: border-box;
  }

  .cg-msg-assistant .cg-msg-content {
    padding: 12px 0;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }

  .cg-scroll-to-bottom {
    display: none !important;
  }

  html[data-theme="dark"] .cg-mobile-plus-menu {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  }
}

/* Умный чат Mishka AI (/text/mishka-ai) */
.cg-smart-header {
  flex-shrink: 0;
  padding: 12px 32px 10px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}
.cg-smart-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.cg-smart-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  min-width: 0;
}
.cg-smart-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.cg-smart-icon-btn {
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  background: var(--input-bg, #fff);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
html[data-theme="dark"] .cg-smart-icon-btn,
body.dark-theme .cg-smart-icon-btn {
  background: #1e1e24;
  border-color: rgba(255, 255, 255, 0.12);
}
.cg-smart-model-banner {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(0, 102, 255, 0.08), rgba(124, 58, 237, 0.06));
  border: 1px solid rgba(0, 102, 255, 0.18);
  line-height: 1.4;
}
.cg-smart-model-prefix {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #666);
  margin-bottom: 2px;
}
.cg-smart-model-name {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #111);
  word-break: break-word;
}
html[data-theme="dark"] .cg-smart-model-banner,
body.dark-theme .cg-smart-model-banner {
  background: linear-gradient(135deg, rgba(0, 102, 255, 0.18), rgba(124, 58, 237, 0.12));
  border-color: rgba(0, 102, 255, 0.35);
}
html[data-theme="dark"] .cg-smart-model-name,
body.dark-theme .cg-smart-model-name {
  color: #f2f2f5;
}
body.cg-smart-dispatch-page .cg-input-footer .cg-input-cost {
  margin-left: auto;
}

/* Десктоп Mishka AI: базовый отступ + при необходимости добивка, если низ ленты визуально заходит под композер (--cg-smart-overlap-pad в JS) */
@media (min-width: 769px) {
  body.cg-smart-dispatch-page .cg-messages {
    padding-bottom: calc(56px + var(--cg-smart-overlap-pad, 0px));
  }

  /* Файлы: drop только сюда (ниже .cg-input-row), не на textarea */
  .cg-desktop-drop-zone {
    border-radius: 0 0 12px 12px;
    transition: background 0.12s ease, box-shadow 0.12s ease;
  }
  .cg-desktop-drop-zone.cg-desktop-drop-zone--over {
    background: rgba(0, 102, 255, 0.07);
    box-shadow: inset 0 0 0 2px rgba(0, 102, 255, 0.35);
  }
  html[data-theme="dark"] .cg-desktop-drop-zone.cg-desktop-drop-zone--over,
  body.dark-theme .cg-desktop-drop-zone.cg-desktop-drop-zone--over {
    background: rgba(100, 160, 255, 0.1);
    box-shadow: inset 0 0 0 2px rgba(120, 170, 255, 0.45);
  }
}

/* Автоитог диалога в ленте Mishka AI (не сохраняется в истории на сервере) */
.cg-msg-dialog-recap .cg-msg-assistant-body {
  max-width: 100%;
}
.cg-msg-dialog-recap .cg-msg-content {
  border-left: 3px solid rgba(0, 102, 255, 0.4);
  padding-left: 14px;
  margin-top: 6px;
  background: rgba(0, 102, 255, 0.04);
  border-radius: 0 10px 10px 0;
}
html[data-theme="dark"] .cg-msg-dialog-recap .cg-msg-content,
body.dark-theme .cg-msg-dialog-recap .cg-msg-content {
  background: rgba(0, 102, 255, 0.1);
  border-left-color: rgba(100, 160, 255, 0.55);
}
.cg-msg-dialog-recap-badge.cg-msg-model-badge {
  background: rgba(124, 58, 237, 0.12);
  border-color: rgba(124, 58, 237, 0.25);
  color: var(--text, #1a1a1a);
}
html[data-theme="dark"] .cg-msg-dialog-recap-badge.cg-msg-model-badge,
body.dark-theme .cg-msg-dialog-recap-badge.cg-msg-model-badge {
  background: rgba(124, 58, 237, 0.22);
  color: #e8e8ec;
}
/* Только Mishka AI: дубль ⚙️ для мобилки (в футере ввода); на десктопе скрыт */
.cg-smart-settings-mobile {
  display: none;
}
body.cg-smart-dispatch-page .cg-msg-assistant .cg-msg-actions {
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
body.cg-smart-dispatch-page .cg-msg-copy + .cg-smart-msg-btn--in-actions {
  margin-left: 4px;
}
.cg-smart-msg-btn {
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  background: var(--input-bg, #f5f5f7);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8125rem;
  cursor: pointer;
  font-family: inherit;
}
.cg-smart-msg-btn.cg-smart-msg-btn--in-actions {
  font-size: 0.75rem;
  padding: 5px 9px;
  line-height: 1.25;
  white-space: nowrap;
}
html[data-theme="dark"] .cg-smart-msg-btn,
body.dark-theme .cg-smart-msg-btn {
  background: #2a2a32;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e8e8ec;
}
.cg-smart-modal-root {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10050;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.cg-smart-modal-root.open {
  display: flex;
}
.cg-smart-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.cg-smart-modal {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: min(86vh, 640px);
  overflow-y: auto;
  background: var(--bg, #fff);
  color: var(--text, #1a1a1a);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}
html[data-theme="dark"] .cg-smart-modal,
body.dark-theme .cg-smart-modal {
  background: #1e1e24;
  color: #e8e8ec;
}

/* Модалки Mishka AI: смена модели и новый чат — общий каркас */
.cg-smart-modal--switch,
.cg-smart-modal--new,
.cg-smart-modal--settings {
  width: min(420px, 100%);
  padding: 0;
  border: 1px solid rgba(0, 102, 255, 0.14);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
}
.cg-smart-modal--switch::before,
.cg-smart-modal--new::before,
.cg-smart-modal--settings::before {
  content: '';
  display: block;
  height: 4px;
  border-radius: 13px 13px 0 0;
  margin: 0;
  background: linear-gradient(90deg, rgba(0, 102, 255, 0.92), rgba(124, 58, 237, 0.75));
}
html[data-theme="dark"] .cg-smart-modal--switch,
body.dark-theme .cg-smart-modal--switch,
html[data-theme="dark"] .cg-smart-modal--new,
body.dark-theme .cg-smart-modal--new,
html[data-theme="dark"] .cg-smart-modal--settings,
body.dark-theme .cg-smart-modal--settings {
  border-color: rgba(0, 102, 255, 0.28);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.cg-smart-modal-head--switch {
  padding: 18px 22px 4px;
  background: linear-gradient(180deg, rgba(0, 102, 255, 0.06), transparent 72%);
}
html[data-theme="dark"] .cg-smart-modal-head--switch,
body.dark-theme .cg-smart-modal-head--switch {
  background: linear-gradient(180deg, rgba(0, 102, 255, 0.12), transparent 70%);
}
.cg-smart-modal-eyebrow {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #666);
  margin-bottom: 6px;
}
.cg-smart-modal-title--switch {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.cg-smart-modal-lead {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-muted, #555);
}
.cg-smart-field--stacked {
  display: block;
  margin: 0;
  padding: 14px 22px 6px;
}
.cg-smart-field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  margin-bottom: 8px;
}
html[data-theme="dark"] .cg-smart-field-label,
body.dark-theme .cg-smart-field-label {
  color: #e8e8ec;
}
.cg-smart-input--lg {
  margin-top: 0;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 0.9375rem;
  border-color: var(--border, rgba(0, 0, 0, 0.12));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
html[data-theme="dark"] .cg-smart-input--lg,
body.dark-theme .cg-smart-input--lg {
  box-shadow: none;
}
.cg-smart-fieldset--switch {
  border: none;
  margin: 0;
  padding: 8px 22px 4px;
}
.cg-smart-fieldset--switch .cg-smart-fieldset-legend {
  float: none;
  width: auto;
  padding: 0;
  margin: 0 0 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted, #666);
}
.cg-smart-switch-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cg-smart-fieldset--switch .cg-smart-switch-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  background: var(--input-bg, rgba(0, 0, 0, 0.02));
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
html[data-theme="dark"] .cg-smart-fieldset--switch .cg-smart-switch-card,
body.dark-theme .cg-smart-fieldset--switch .cg-smart-switch-card {
  background: rgba(255, 255, 255, 0.04);
}
.cg-smart-fieldset--switch .cg-smart-switch-card:hover {
  border-color: rgba(0, 102, 255, 0.35);
}
.cg-smart-fieldset--switch .cg-smart-switch-card:focus-within {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg, #fff), 0 0 0 4px rgba(0, 102, 255, 0.35);
}
html[data-theme="dark"] .cg-smart-fieldset--switch .cg-smart-switch-card:focus-within,
body.dark-theme .cg-smart-fieldset--switch .cg-smart-switch-card:focus-within {
  box-shadow: 0 0 0 2px #1e1e24, 0 0 0 4px rgba(0, 102, 255, 0.45);
}
.cg-smart-fieldset--switch .cg-smart-switch-card:has(.cg-smart-switch-input:checked) {
  border-color: var(--accent, #0066ff);
  background: rgba(0, 102, 255, 0.07);
  box-shadow: inset 0 0 0 1px rgba(0, 102, 255, 0.12);
}
html[data-theme="dark"] .cg-smart-fieldset--switch .cg-smart-switch-card:has(.cg-smart-switch-input:checked),
body.dark-theme .cg-smart-fieldset--switch .cg-smart-switch-card:has(.cg-smart-switch-input:checked) {
  background: rgba(0, 102, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(0, 102, 255, 0.25);
}
.cg-smart-switch-input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent, #0066ff);
  cursor: pointer;
}
.cg-smart-switch-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.cg-smart-switch-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text, #1a1a1a);
}
html[data-theme="dark"] .cg-smart-switch-card-title,
body.dark-theme .cg-smart-switch-card-title {
  color: #f2f2f5;
}
.cg-smart-switch-card-desc {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-muted, #666);
}

/* Статус смены модели в ленте: спиннер + лёгкая пульсация, чтобы не казалось зависанием */
.cg-msg-smart-switch--pending {
  animation: cg-smart-switch-breathe 2.2s ease-in-out infinite;
}
@keyframes cg-smart-switch-breathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.9;
  }
}
.cg-msg-smart-switch--pending .cg-msg-model-badge {
  position: relative;
  overflow: hidden;
}
.cg-msg-smart-switch--pending .cg-msg-model-badge::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  animation: cg-smart-switch-shimmer 2s ease-in-out infinite;
  pointer-events: none;
}
html[data-theme='dark'] .cg-msg-smart-switch--pending .cg-msg-model-badge::after,
body.dark-theme .cg-msg-smart-switch--pending .cg-msg-model-badge::after {
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
}
@keyframes cg-smart-switch-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}
.cg-msg-smart-switch-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.cg-smart-switch-spinner {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border: 2px solid var(--border, rgba(0, 0, 0, 0.12));
  border-top-color: var(--accent, #0066ff);
  border-radius: 50%;
  animation: cg-smart-switch-spin 0.7s linear infinite;
}
html[data-theme='dark'] .cg-smart-switch-spinner,
body.dark-theme .cg-smart-switch-spinner {
  border-color: rgba(255, 255, 255, 0.18);
  border-top-color: #5c9dff;
}
@keyframes cg-smart-switch-spin {
  to {
    transform: rotate(360deg);
  }
}
.cg-smart-switch-row-text {
  flex: 1;
  min-width: 0;
  line-height: 1.45;
}

.cg-smart-modal--switch .cg-smart-modal-actions,
.cg-smart-modal--new .cg-smart-modal-actions,
.cg-smart-modal--settings .cg-smart-modal-actions {
  padding: 18px 22px 22px;
  margin-top: 8px;
  border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  background: var(--border-light, rgba(0, 0, 0, 0.02));
}
html[data-theme="dark"] .cg-smart-modal--switch .cg-smart-modal-actions,
body.dark-theme .cg-smart-modal--switch .cg-smart-modal-actions,
html[data-theme="dark"] .cg-smart-modal--new .cg-smart-modal-actions,
body.dark-theme .cg-smart-modal--new .cg-smart-modal-actions,
html[data-theme="dark"] .cg-smart-modal--settings .cg-smart-modal-actions,
body.dark-theme .cg-smart-modal--settings .cg-smart-modal-actions {
  border-top-color: rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}
.cg-smart-modal--switch .cg-smart-btn-primary,
.cg-smart-modal--new .cg-smart-btn-primary,
.cg-smart-modal--settings .cg-smart-btn-primary {
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
}

.cg-smart-memory-toggle-wrap--settings {
  margin-top: 0;
  margin-bottom: 14px;
}
.cg-smart-settings-danger-slot {
  padding: 0 22px 6px;
}
.cg-smart-modal--settings .cg-smart-btn-danger-text {
  margin-bottom: 0;
}

/* «Новый чат»: тумблер истории */
.cg-smart-memory-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 6px 22px 4px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  background: var(--input-bg, rgba(0, 102, 255, 0.04));
}
html[data-theme="dark"] .cg-smart-memory-toggle-wrap,
body.dark-theme .cg-smart-memory-toggle-wrap {
  background: rgba(0, 102, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.1);
}
.cg-smart-memory-toggle-copy {
  flex: 1;
  min-width: 0;
}
.cg-smart-memory-toggle-copy .cg-smart-field-label {
  margin-bottom: 4px;
}
.cg-smart-memory-toggle-status {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text, #1a1a1a);
}
html[data-theme="dark"] .cg-smart-memory-toggle-status,
body.dark-theme .cg-smart-memory-toggle-status {
  color: #f2f2f5;
}
.cg-smart-memory-toggle-desc {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-muted, #666);
}
.cg-smart-toggle {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 30px;
  cursor: pointer;
  display: inline-block;
}
.cg-smart-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}
.cg-smart-toggle-track {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 15px;
  background: rgba(0, 0, 0, 0.14);
  transition: background 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  box-sizing: border-box;
}
html[data-theme="dark"] .cg-smart-toggle-track,
body.dark-theme .cg-smart-toggle-track {
  background: rgba(255, 255, 255, 0.18);
}
.cg-smart-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}
.cg-smart-toggle-input:checked + .cg-smart-toggle-track {
  background: var(--accent, #0066ff);
}
html[data-theme="dark"] .cg-smart-toggle-input:checked + .cg-smart-toggle-track,
body.dark-theme .cg-smart-toggle-input:checked + .cg-smart-toggle-track {
  background: var(--accent, #0066ff);
}
.cg-smart-toggle-input:checked + .cg-smart-toggle-track::after {
  transform: translateX(22px);
}
.cg-smart-toggle-input:focus-visible + .cg-smart-toggle-track {
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.35);
}
.cg-smart-toggle:hover .cg-smart-toggle-track {
  filter: brightness(1.03);
}
html[data-theme="dark"] .cg-smart-toggle:hover .cg-smart-toggle-track,
body.dark-theme .cg-smart-toggle:hover .cg-smart-toggle-track {
  filter: brightness(1.08);
}
@media (max-width: 420px) {
  .cg-smart-memory-toggle-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .cg-smart-toggle {
    align-self: flex-end;
  }
}

.cg-smart-modal-title {
  margin: 0 0 16px;
  font-size: 1.1rem;
}
.cg-smart-field {
  display: block;
  margin-bottom: 14px;
  font-size: 0.9rem;
}
.cg-smart-input {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.15));
  font-family: inherit;
  font-size: 0.9375rem;
  box-sizing: border-box;
  background: var(--input-bg, #fff);
  color: var(--text, inherit);
}
.cg-smart-fieldset {
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 0.875rem;
}
.cg-smart-fieldset label {
  display: block;
  margin: 6px 0;
}
.cg-smart-muted {
  font-size: 0.8125rem;
  color: var(--text-muted, #666);
  margin: 0 0 12px;
}
.cg-smart-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.875rem;
}
.cg-smart-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.cg-smart-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.15));
  background: var(--input-bg, #f0f0f2);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
}
.cg-smart-btn-primary {
  background: var(--accent, #0066ff);
  color: #fff;
  border-color: var(--accent, #0066ff);
}
.cg-smart-btn-danger-text {
  width: 100%;
  margin-bottom: 8px;
  background: transparent;
  color: #c62828;
  border-color: rgba(198, 40, 40, 0.35);
}
.cg-smart-debate-panel {
  max-width: 800px;
  margin: 12px auto 16px;
  width: 100%;
  min-width: 0;
  padding: 16px 32px 20px;
  box-sizing: border-box;
  background: var(--bg-page, #fafafa);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: 12px;
  flex-shrink: 0;
  align-self: stretch;
  max-height: min(70vh, 720px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
.cg-smart-debate-panel--loading {
  max-height: none;
  overflow: visible;
}
.cg-smart-debate-loading {
  margin: 0 0 12px;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-muted, #555);
}
.cg-smart-debate-loading-dots {
  display: flex;
  gap: 6px;
  padding: 4px 0 8px;
}
.cg-smart-debate-loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent, #0066ff);
  opacity: 0.45;
  animation: cg-typing-bounce 1.4s ease-in-out infinite both;
}
.cg-smart-debate-loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.cg-smart-debate-loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
.cg-smart-debate-head {
  font-weight: 600;
  margin-bottom: 12px;
}
.cg-smart-debate-live {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #c62828;
  vertical-align: middle;
  animation: cg-debate-live-pulse 1.2s ease-in-out infinite;
}
@keyframes cg-debate-live-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}
html[data-theme="dark"] .cg-smart-debate-live,
body.dark-theme .cg-smart-debate-live {
  color: #ff8a80;
}
.cg-smart-debate-stream-hint {
  margin: -4px 0 14px;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-muted, #666);
}
.cg-smart-debate-model-label {
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--text-muted, #666);
}
.cg-smart-debate-block--active {
  border-left: 3px solid var(--accent, #0066ff);
  padding-left: 10px;
  margin-left: -2px;
}
.cg-smart-debate-block {
  margin-bottom: 12px;
  min-width: 0;
}
.cg-smart-debate-block h4 {
  margin: 0 0 6px;
  font-size: 0.875rem;
}
.cg-smart-debate-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-size: 0.8125rem;
  line-height: 1.45;
  padding: 10px;
  background: var(--input-bg, #fff);
  border-radius: 8px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  max-height: min(42vh, 360px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
html[data-theme="dark"] .cg-smart-debate-panel,
body.dark-theme .cg-smart-debate-panel {
  background: #1a1a1f;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] .cg-smart-debate-pre,
body.dark-theme .cg-smart-debate-pre {
  background: #25252c;
  border-color: rgba(255, 255, 255, 0.1);
}
.cg-smart-debate-panel .cg-smart-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.cg-chat-item-time {
  font-size: 0.75rem;
  opacity: 0.85;
}

.cg-attach-pro-hint {
  position: fixed;
  left: 50%;
  bottom: max(88px, calc(env(safe-area-inset-bottom, 0px) + 72px));
  transform: translateX(-50%);
  z-index: 9999;
  max-width: min(420px, 92vw);
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.88);
  color: #fff;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}
