/* ===== AI Собеседник - Основные стили ===== */
/* variables/base/components/layout подключаются отдельными <link> в index.html для параллельной загрузки */

/* ===== ПАНЕЛЬ ЗАПИСИ — РАСТЯГИВАЕТСЯ НА ВСЮ ВЫСОТУ ===== */
.recording-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0; /* Важно для flex-контейнера */
}

/* Компактный бейдж режима */
.mode-badge-compact {
  align-self: flex-start;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.panel-header h1,
.panel-header h2 {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #1b1f24;
  margin: 0;
}

.mode-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #eef2ff;
  color: #0000FF;
  padding: 6px 12px;
  border-radius: 40px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(0, 0, 255, 0.1);
}

.mode-icon {
  font-size: 14px;
}

/* ===== ИНТЕГРИРОВАННЫЙ АССИСТЕНТ ===== */
.ai-assistant {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: linear-gradient(145deg, #f6f8ff 0%, #FFFFFF 100%);
  border-radius: 20px;
  padding: 20px 24px;
  border: 1px solid rgba(0, 0, 255, 0.08);
  box-shadow: 
    0 8px 20px -8px rgba(0, 0, 0, 0.04),
    0 2px 6px -2px rgba(0, 0, 0, 0.02);
  transition: all 0.15s ease;
}

.ai-assistant.listening {
  border-color: rgba(0, 0, 255, 0.2);
  box-shadow: 
    0 8px 20px -8px rgba(0, 0, 255, 0.12),
    0 0 0 1px rgba(0, 0, 255, 0.1);
}

.ai-avatar {
  width: 48px;
  height: 48px;
  background: #0000FF;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 6px 12px -4px rgba(0, 0, 255, 0.24);
}

.ai-avatar.ai-sphere-wrap {
  width: 72px;
  height: 72px;
  min-width: 48px;
  min-height: 48px;
  background: transparent;
  border-radius: 50%;
  box-shadow: none;
  overflow: visible;
  position: relative;
  flex-shrink: 0;
}

.ai-sphere-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 48px;
  min-height: 48px;
}

.ai-assistant.listening .ai-sphere-wrap {
  filter: drop-shadow(0 0 12px rgba(0, 0, 255, 0.35));
}

.ai-assistant.thinking .ai-sphere-wrap {
  filter: drop-shadow(0 0 14px rgba(80, 80, 255, 0.45));
}

.ai-assistant.error .ai-sphere-wrap {
  filter: drop-shadow(0 0 10px rgba(220, 60, 60, 0.3));
}

.ai-assistant.connection-offline .ai-sphere-wrap {
  filter: none;
}

.ai-assistant.connection-lost .ai-sphere-wrap {
  filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.28));
}

.ai-assistant.connection-lost .ai-insight-trigger {
  cursor: pointer;
}

.ai-content {
  flex: 1;
}

.ai-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

/* Селектор режимов в шапке ассистента */
.mode-selector {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  background: #eef1f8;
  border-radius: 10px;
  padding: 2px;
  width: 100%;
  max-width: none;
  margin: 0;
  box-sizing: border-box;
}

.mode-selector--header {
  border: 1px solid rgba(0, 0, 255, 0.07);
}

.mode-selector-pill {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  width: 0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 255, 0.12);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transform: translateX(0);
  transition:
    transform 0.3s cubic-bezier(0.32, 0.72, 0, 1),
    width 0.3s cubic-bezier(0.32, 0.72, 0, 1),
    opacity 0.15s ease;
}

.mode-selector .mode-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1 1 0;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #646b75;
  font-weight: 500;
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
  transition: color 0.15s ease;
}

.mode-selector .mode-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.mode-selector .mode-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-selector .mode-btn.active {
  background: transparent;
  color: #0000ff;
  font-weight: 600;
  box-shadow: none;
}

.mode-selector .mode-btn:hover:not(.active) {
  color: #1b1f24;
}

@media (prefers-reduced-motion: reduce) {
  .mode-selector-pill {
    transition: none;
  }
}

.ai-name {
  font-weight: 650;
  font-size: 16px;
  color: #1b1f24;
}

.ai-badge {
  background: #c7d2fe;
  color: #0000FF;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ai-message {
  font-size: 14px;
  color: #646b75;
  line-height: 1.5;
}

.ai-question {
  display: none !important;
  margin-top: 10px;
  padding: 12px 16px;
  background: #FFFFFF;
  border-radius: 14px;
  font-size: 15px;
  color: #1b1f24;
  border: 1px solid rgba(0, 0, 255, 0.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.ai-question:empty {
  display: none;
}

/* ===== ПОДСКАЗКА (скрыта — подсказки режимов убраны из UI) ===== */
.session-hint,
#sessionHint {
  display: none !important;
}

.hidden {
  display: none !important;
}
/* ===== СТАТУС-БАР ===== */
.status-bar {
  padding: 12px 16px;
  background: #f6f7f9;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #646b75;
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 4px solid transparent;
  transition: all 0.15s ease;
}

.status-bar::before {
  content: 'ℹ️';
  font-size: 16px;
  opacity: 0.7;
}

.status-bar.recording {
  background: #fff7ed;
  border-left-color: #f59e0b;
  color: #92400e;
}

.status-bar.recording::before {
  content: '🔴';
  opacity: 1;
  animation: pulse 1.5s infinite;
}

.status-bar.success {
  background: #ecfdf5;
  border-left-color: #10b981;
  color: #047857;
}

.status-bar.success::before {
  content: '✅';
  opacity: 1;
}

.status-bar.error {
  background: #fef2f2;
  border-left-color: #ef4444;
  color: #b91c1c;
}

.status-bar.error::before {
  content: '❌';
  opacity: 1;
}

.status-bar.warning {
  background: #fffbeb;
  border-left-color: #f59e0b;
  color: #92400e;
}

.status-bar.warning::before {
  content: '⚠️';
  opacity: 1;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== КНОПКИ УПРАВЛЕНИЯ ===== */
.recording-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: auto;
  padding: 8px 0 0;
}

/* Центральный слот с основной кнопкой (Начать/Пауза) */
.record-primary-slot {
  flex: 0 1 min(100%, 400px);
  width: min(100%, 400px);
  min-width: 0;
  display: flex;
  gap: 8px;
}

.record-primary-slot .record-action-btn {
  flex: 1 1 auto;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  gap: 8px;
  flex-shrink: 1;
}

.record-action-btn .btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.record-action-btn.btn-primary {
  box-shadow: 0 4px 14px rgba(0, 0, 255, 0.2);
}

.record-action-btn.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 255, 0.24);
}

.record-action-btn.btn-secondary {
  border: 1.5px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.record-action-btn.btn-secondary:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #d7ddff;
  background: #fafbff;
}

/* Вспомогательные кнопки слева (меню) */
.record-aux-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  border: 1px solid rgba(0, 0, 255, 0.14);
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.record-aux-btn:hover {
  color: #0000ff;
  border-color: rgba(0, 0, 255, 0.35);
  background: #f6f8ff;
}

.record-aux-btn:active {
  transform: scale(0.96);
}

.record-aux-wrap {
  position: relative;
  flex: 0 0 auto;
}

/* Кнопка меню в панели записи нужна только на мобильных (на ПК меню слева сверху) */
.record-aux-btn--menu {
  display: none;
}

.record-auto-note {
  font-size: 11px;
  line-height: 1.4;
  color: #94a3b8;
  padding: 8px 8px 4px;
  margin-top: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

/* Иллюстрация-обложка внутри редактора */
.rich-editor img[data-role="cover"] {
  float: right;
  margin: 0 0 12px 16px;
  max-width: 25%;
  border-radius: 12px;
}

.record-auto-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.record-auto-item:hover {
  background: #f6f8ff;
}

.record-auto-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.record-auto-item-label {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.record-auto-item-hint {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.35;
}

/* Тумблер-переключатель */
.record-auto-switch {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 24px;
}

.record-auto-checkbox {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.record-auto-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.18s ease;
}

.record-auto-slider::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.28);
  transition: transform 0.18s ease;
}

.record-auto-checkbox:checked + .record-auto-slider {
  background: #0000ff;
}

.record-auto-checkbox:checked + .record-auto-slider::before {
  transform: translateX(16px);
}

.record-auto-checkbox:focus-visible + .record-auto-slider {
  outline: 2px solid rgba(0, 0, 255, 0.4);
  outline-offset: 2px;
}

.btn-large {
  padding: 16px 24px;
  font-size: 16px;
  flex: 1;
}

.btn-large .btn-icon {
  width: 22px;
  height: 22px;
}

.record-primary-slot .record-action-btn.btn-large {
  flex: 1 1 auto;
  min-height: 42px;
  padding: 10px 16px;
  font-size: 14px;
  border-radius: 14px;
}

.record-primary-slot .record-action-btn.btn-large .btn-icon {
  width: 18px;
  height: 18px;
}

/* ===== ПАНЕЛЬ РЕДАКТИРОВАНИЯ ===== */
.content-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0; /* Важно для flex-контейнера */
}

.content-panel.hidden {
  display: none !important;
}

/* Текстовый редактор — занимает всё доступное пространство */
.text-editor-expanded {
  flex: 1;
  min-height: 200px;
  max-height: none !important;
  resize: none;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #eef2ff;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  border-right: 1px solid #e5e7eb;
}

.toolbar-group:last-child {
  border-right: none;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: #646b75;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
}

.toolbar-btn:hover {
  background: #f6f7f9;
  color: #1b1f24;
}

.toolbar-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.toolbar-btn:disabled:hover {
  background: transparent;
  color: #646b75;
}

.toolbar-btn-danger:hover {
  background: #fef2f2;
  color: #ef4444;
}

.toolbar-spacer {
  flex: 1;
}

.export-select {
  padding: 8px 32px 8px 12px;
  background: #FFFFFF;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  color: #1b1f24;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23646b75' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* ===== AI РЕДАКТИРОВАНИЕ ===== */
.ai-edit-section {
  background: #f6f8ff;
  border-radius: 20px;
  padding: 20px;
  border: 1px solid rgba(0, 0, 255, 0.06);
}

.ai-edit-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.quick-edit-panel {
  border: none;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
}

/* Раскрывающийся список «ИИ-редактор» — единый вид на ПК и мобильных */
.quick-edit-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  background: #ffffff;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  color: #1b1f24;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.quick-edit-toggle:hover {
  background: #fafbff;
  border-color: #d7ddff;
}

.quick-edit-toggle::-webkit-details-marker {
  display: none;
}

.quick-edit-panel[open] > .quick-edit-toggle {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: #eef2ff;
  background: #fafbff;
}

.quick-edit-toggle-icon {
  flex-shrink: 0;
  color: #0000ff;
}

.quick-edit-toggle-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.quick-edit-toggle-label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.quick-edit-toggle-hint {
  font-size: 11px;
  color: #646b75;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-edit-chevron {
  flex-shrink: 0;
  color: #646b75;
  transition: transform 0.15s ease;
}

.quick-edit-panel[open] .quick-edit-chevron {
  transform: rotate(180deg);
}

.quick-edit-buttons {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  background: #ffffff;
  border: 1.5px solid #e5e7eb;
  border-top: none;
  border-radius: 0 0 12px 12px;
}

.quick-edit-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-edit-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  padding: 6px 10px 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.quick-edit-divider {
  height: 1px;
  margin: 6px 8px;
  background: rgba(148, 163, 184, 0.22);
}

.quick-edit-buttons .record-auto-item {
  margin: 0 2px;
}

.quick-edit-buttons .record-auto-note {
  margin: 2px 4px 4px;
  padding: 6px 8px 2px;
}

.quick-edit-auto-count {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #7c3aed;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(124, 58, 237, 0.35);
  pointer-events: none;
}

.quick-edit-auto-count[hidden] {
  display: none;
}

.quick-edit-panel.is-auto-recording .quick-edit-auto-count {
  animation: quickEditAutoCountPulse 1.4s ease-in-out infinite;
}

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

.quick-edit-section.is-disabled .quick-edit-section-title {
  opacity: 0.55;
}

/* «ИИ-редактор» в строке форматирования — справа, акцентная кнопка */
.rich-format-toolbar .quick-edit-panel--toolbar {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
  align-self: center;
  overflow: visible;
}

.rich-format-toolbar .quick-edit-panel--toolbar > .quick-edit-toggle {
  background: linear-gradient(135deg, #faf5ff 0%, #eef2ff 100%);
  border-color: #c4b5fd;
  box-shadow: 0 1px 4px rgba(109, 40, 217, 0.12);
  padding: 7px 12px;
  white-space: nowrap;
}

.rich-format-toolbar .quick-edit-panel--toolbar > .quick-edit-toggle:hover {
  background: linear-gradient(135deg, #f3e8ff 0%, #e0e7ff 100%);
  border-color: #8b5cf6;
}

.rich-format-toolbar .quick-edit-panel--toolbar[open] > .quick-edit-toggle {
  border-radius: 12px;
  border-color: #8b5cf6;
  background: linear-gradient(135deg, #f3e8ff 0%, #e0e7ff 100%);
}

.rich-format-toolbar .quick-edit-panel--toolbar .quick-edit-toggle-icon {
  color: #7c3aed;
}

.rich-format-toolbar .quick-edit-panel--toolbar .quick-edit-toggle-label {
  color: #5b21b6;
}

.rich-format-toolbar .quick-edit-panel--toolbar .quick-edit-chevron {
  color: #7c3aed;
  transform: rotate(180deg);
}

.rich-format-toolbar .quick-edit-panel--toolbar[open] .quick-edit-chevron {
  transform: rotate(0deg);
}

.rich-format-toolbar .quick-edit-panel--toolbar .quick-edit-buttons {
  position: absolute;
  bottom: calc(100% + 6px);
  top: auto;
  right: 0;
  left: auto;
  min-width: 260px;
  max-width: min(320px, calc(100vw - 24px));
  max-height: min(70vh, 480px);
  overflow-y: auto;
  z-index: 60;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.1), 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Заголовки и списки в нижней панели — раскрываются вверх, как «ИИ-редактор» */
.rich-format-toolbar .rf-heading-menu,
.rich-format-toolbar .rf-list-menu {
  top: auto;
  bottom: calc(100% + 6px);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.1), 0 8px 24px rgba(0, 0, 0, 0.08);
}

.btn-edit {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: #ffffff;
  border: none;
  border-radius: 8px;
  color: #1b1f24;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  text-align: left;
  line-height: 1.3;
}

.btn-edit:hover {
  background: #eef2ff;
  color: #0000ff;
}

.btn-edit span {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}

.btn-edit svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.smart-input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.smart-textarea {
  flex: 1;
  padding: 12px 16px;
  background: #FFFFFF;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.4;
  font-family: inherit;
  resize: none;
  transition: border-color 0.12s ease;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.smart-textarea::-webkit-scrollbar {
  display: none;
}

.smart-textarea:focus {
  outline: none;
  border-color: #0000FF;
}

.smart-actions {
  display: flex;
  gap: 8px;
}

.smart-action-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.smart-action-btn.mic-mode {
  background: #0000FF;
  color: white;
}

.smart-action-btn.send-mode {
  background: #10b981;
  color: white;
}

.smart-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

/* ===== РЕЗУЛЬТАТ ЭКСПОРТА ===== */
.export-result {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  margin-top: 8px;
}

.export-result.success {
  background: #ecfdf5;
  color: #047857;
  border-left: 4px solid #10b981;
}

.export-result.error {
  background: #fef2f2;
  color: #b91c1c;
  border-left: 4px solid #ef4444;
}

/* ===== ДЕСКТОПНЫЕ ЭЛЕМЕНТЫ ===== */
@media (min-width: 601px) {
  .desktop-only {
    display: flex !important;
  }
  
  .toolbar-menu-btn {
    display: none !important;
  }
  
  #appendRecordingBtn {
    background: transparent;
    color: #646b75;
  }
  
  #appendRecordingBtn:hover {
    background: #f6f7f9;
    color: #1b1f24;
  }
  
  #appendRecordingBtn span {
    display: inline !important;
  }

  #appendRecordingBtn svg {
    stroke: currentColor !important;
  }
}

/* ===== МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
@media (max-width: 600px) {
  .container {
    gap: 16px;
  }
  
  /* Запись */
  .recording-controls {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-top: 6px;
    padding-bottom: calc(4px + var(--safe-bottom, env(safe-area-inset-bottom, 0px)));
    margin-bottom: 0;
  }

  body[data-mode="thought-organizer"].thought-live-view .container,
  body[data-mode="conversation"] .container {
    padding-bottom: calc(8px + var(--safe-bottom, env(safe-area-inset-bottom, 0px)));
  }

  /* На мобильных кнопка меню переезжает вниз, слева от кнопки записи */
  .record-aux-btn--menu {
    display: flex;
  }

  .record-aux-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }

  .record-primary-slot {
    flex: 0 1 70%;
    width: 70%;
    max-width: 70%;
  }

  .record-primary-slot .record-action-btn.btn-large {
    min-height: 40px;
    padding: 9px 12px;
    font-size: 13px;
    border-radius: 13px;
  }

  .record-primary-slot .record-action-btn.btn-large .btn-icon {
    width: 17px;
    height: 17px;
  }
  
  .ai-assistant {
    padding: 14px;
    gap: 10px;
  }
  
  .ai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .ai-avatar.ai-sphere-wrap {
    width: 56px;
    height: 56px;
    border-radius: 50%;
  }
  
  .ai-name {
    font-size: 14px;
  }
  
  .ai-message {
    font-size: 13px;
  }
  
  .hint-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .hint-item {
    gap: 10px;
  }
  
  /* ===== РЕДАКТИРОВАНИЕ (МОБИЛЬНАЯ) ===== */
  .content-panel {
    gap: 12px;
  }
  
  /* Заголовок и кнопка "Назад" */
  .panel-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  
  .panel-header h2 {
    font-size: 18px;
  }
  
  .panel-header .btn {
    padding: 8px 12px;
    font-size: 13px;
    width: auto;
  }

  /* Тулбар редактора — только самое нужное */
  .editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eef2ff;
    flex-wrap: nowrap;
  }
  
  /* Группа с историей (undo/redo/reset) */
  .toolbar-group:first-child {
    display: flex;
    gap: 4px;
  }
  
  /* Продолжить запись — выделенная кнопка */
   #appendRecordingBtn {
    background: #0000ff !important;
    color: white !important;
    padding: 10px 16px !important;
    border-radius: 30px !important;
  }
  
  #appendRecordingBtn:hover {
    background: #0000d6 !important;
  }
  
  #appendRecordingBtn svg {
    stroke: white !important;
  }
  
  /* Бургер-меню для остальных действий */
  .toolbar-group:last-child {
    position: relative;
  }
  
  .toolbar-menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1.5px solid #e5e7eb;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  
  .toolbar-menu-dropdown {
    position: absolute;
    top: 48px;
    right: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.15);
    border: 1px solid #eef2ff;
    padding: 8px;
    min-width: 160px;
    display: none;
    z-index: 100;
  }
  
  .toolbar-menu-dropdown.active {
    display: block;
  }
  
  .toolbar-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    color: #1b1f24;
    text-decoration: none;
    font-size: 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
  }
  
  .toolbar-menu-item:hover {
    background: #f6f8ff;
  }
  
  .toolbar-menu-item.danger {
    color: #ef4444;
  }
  
  .toolbar-menu-item.danger:hover {
    background: #fef2f2;
  }
  
  /* Скрываем обычные кнопки тулбара на мобильных */
  .toolbar-btn span,
  .export-select,
  .editor-toolbar .btn-primary {
    display: none;
  }
  
  /* Текстовый редактор — МАКСИМУМ МЕСТА */
  .text-editor {
    min-height: 200px;
    max-height: none;
    flex: 1;
    font-size: 15px;
    padding: 16px;
    line-height: 1.6;
  }
  
  /* AI-редактирование — компактно */
  .ai-edit-section {
    padding: 10px 12px;
    border-radius: 16px;
  }

  .ai-edit-stack {
    gap: 8px;
  }

  .quick-edit-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #ffffff;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    color: #1b1f24;
    transition: background 0.12s ease, border-color 0.12s ease;
  }

  .quick-edit-panel[open] > .quick-edit-toggle {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: #eef2ff;
    background: #fafbff;
  }

  .quick-edit-toggle-icon {
    flex-shrink: 0;
    color: #0000ff;
  }

  .quick-edit-toggle-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
  }

  .quick-edit-toggle-label {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
  }

  .quick-edit-toggle-hint {
    font-size: 11px;
    color: #646b75;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .quick-edit-chevron {
    flex-shrink: 0;
    color: #646b75;
    transition: transform 0.15s ease;
  }

  .quick-edit-panel[open] .quick-edit-chevron {
    transform: rotate(180deg);
  }

  .quick-edit-panel {
    border-radius: 12px;
    overflow: hidden;
  }

  .quick-edit-buttons {
    flex-direction: column;
    gap: 0;
    padding: 4px;
    background: #ffffff;
    border: 1.5px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 12px 12px;
  }

  .btn-edit {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: unset;
    max-width: unset;
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 8px;
    border: none;
    box-shadow: none;
    text-align: left;
  }

  .btn-edit span {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
  }

  .btn-edit svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  .btn-edit:active:not(:disabled) {
    background: #eef2ff;
  }

  /* Умное поле ввода */
  .smart-input-container {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  
  .smart-textarea {
    flex: 1;
    min-height: 60px;
    max-height: 80px;
    font-size: 14px;
    padding: 10px 14px;
    border-radius: 12px;
  }
  
  .smart-actions {
    display: flex;
    gap: 6px;
  }
  
  .smart-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 30px;
  }
  
  /* Боковое меню */
  .app-sidebar {
    width: 100%;
    max-width: 280px;
  }
  
  /* Модальные окна */
  .modal-dialog {
    padding: 20px 18px;
    max-width: 90%;
  }
  
  .modal-dialog h2 {
    font-size: 18px;
  }
  
  .modal-dialog p {
    font-size: 13px;
  }
  
  .modal-buttons {
    flex-direction: column;
    gap: 8px;
  }
  
  .modal-buttons .btn {
    width: 100%;
  }
  
  /* Результат экспорта */
  .export-result {
    font-size: 13px;
    padding: 10px 12px;
  }
}

/* Десктоп: порядок блоков в общем пространстве кнопок. */
@media (min-width: 601px) {
  .rich-format-toolbar {
    order: -2;
  }
}

/* Дополнительно для очень маленьких экранов */
@media (max-width: 400px) {
  .container {
    padding: 12px 10px;
  }

  .quick-edit-toggle-hint {
    font-size: 10px;
  }

  .btn-edit {
    padding: 9px 10px;
    font-size: 12px;
  }
  
  .toolbar-btn span {
    font-size: 11px;
  }
  
  .toolbar-group {
    padding: 0 4px;
  }
  
  .editor-toolbar .btn-primary span {
    display: inline;
  }
}

.btn-edit:disabled,
#btnApplyManualEdit:disabled {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

.btn-edit:disabled:hover,
#btnApplyManualEdit:disabled:hover {
  border-color: #e5e7eb !important;
  background: #FFFFFF !important;
}

/* ===== АДАПТИВНЫЙ ТУЛБАР ===== */
@media (max-width: 600px) {
  body {
    background: #ffffff;
  }

  .container {
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  body[data-mode="thought-organizer"].thought-live-view .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .panel-header {
    justify-content: center !important;
  }
  
  .panel-header h2 {
    text-align: center;
    width: 100%;
  }

  .rich-format-toolbar .rf-row-format .rf-heading-dropdown {
    display: flex !important;
  }

  .rich-format-toolbar .quick-edit-panel--toolbar .quick-edit-toggle-hint {
    display: none;
  }
}

@media (min-width: 601px) {
  .rf-btn-continue {
    background: transparent;
    color: #646b75;
    font-weight: 500;
  }

  .rf-btn-continue:hover {
    background: #f6f7f9;
    color: #1b1f24;
  }

  .rf-btn-continue svg {
    stroke: currentColor;
  }
}

/* На мобильных — на всю высоту экрана (отступы в base.css) */
@media (max-width: 600px) {
  .recording-panel {
    padding-top: 4px;
  }
  
  .session-hint {
    padding: 16px;
  }
  
  .mode-badge-compact {
    margin-bottom: 4px;
  }
}

/* Для очень маленьких экранов */
@media (max-width: 400px) {
  .ai-assistant {
    padding: 12px;
  }
  
  .hint-grid {
    gap: 8px;
  }
}

/* Адаптивность */
@media (max-width: 600px) {
  .text-editor-expanded {
    min-height: 180px;
    font-size: 15px;
    padding: 16px;
  }
  
  .panel-header h2 {
    font-size: 18px;
  }
  
  .ai-edit-section {
    padding: 10px 12px;
    border-radius: 16px;
  }
}

@media (max-width: 400px) {
  .text-editor-expanded {
    min-height: 150px;
    padding: 14px;
  }
}

.export-result:empty {
  display: none;
}

/* ===== ПЕРЕКЛЮЧАТЕЛЬ РЕЖИМОВ ===== */


/* ===== ИСТОРИЯ ДИАЛОГА ===== */
.interview-history {
  background: #f8fafc;
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid #eef2ff;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  color: #1e293b;
  font-size: 14px;
}

.history-clear-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
  padding: 4px 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
}

.history-clear-btn svg {
  display: block;
}

.history-clear-btn:hover {
  opacity: 1;
  background: #fee2e2;
}

.history-messages {
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.history-message {
  padding: 12px 16px;
  border-radius: 16px;
  max-width: 85%;
  animation: messageSlideIn 0.2s ease;
}

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

.history-message.user {
  background: #f8fafc;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-right: 3px solid #818cf8;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.history-message.assistant {
  background: white;
  border: 1px solid #e2e8f0;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.history-message.assistant.acknowledgement {
  background: #f1f5f9;
  color: #475569;
  font-style: italic;
}

.history-message.assistant.question {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.message-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 6px;
  opacity: 0.8;
}

.history-message.user .message-header {
  color: #94a3b8;
}

.message-role {
  font-weight: 600;
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

/* Адаптивность */
@media (max-width: 600px) {
  .mode-selector .mode-btn {
    padding: 4px 4px;
    font-size: 10px;
  }

  .mode-selector .mode-btn svg {
    width: 11px;
    height: 11px;
  }
  
  .history-messages {
    max-height: 200px;
  }
}

/* ===== МОДАЛЬНЫЕ КНОПКИ (общие) ===== */
.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-buttons .btn {
  flex: initial;
  padding: 12px 20px;
}

/* Оболочка режимов «Мысли», «Диалог», «Чат с ИИ» — flat shell (карточка только у #aiAssistant на ПК) */
body[data-mode="thought-organizer"].thought-live-view,
body[data-mode="conversation"],
body[data-mode="ai-chat"] {
  padding: 0;
  justify-content: center;
  align-items: stretch;
  background: #ffffff;
}

@media (min-width: 601px) {
  body[data-mode="thought-organizer"].thought-live-view,
  body[data-mode="conversation"],
  body[data-mode="ai-chat"] {
    padding: 0;
  }
}

body[data-mode="thought-organizer"].thought-live-view .container,
body[data-mode="conversation"] .container,
body[data-mode="ai-chat"] .container {
  overflow: hidden;
  gap: 0;
  box-shadow: none;
  border-radius: 0;
  background: #ffffff;
  width: 100%;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 100dvh;
  padding: calc(44px + var(--safe-top, env(safe-area-inset-top, 0px))) 16px 0;
}

@media (max-width: 600px) {
  body[data-mode="thought-organizer"].thought-live-view .container {
    /* +4px: в «Мыслях» recordingPanel = display:contents, нет padding-top панели как в Диалог/Чат */
    padding-top: calc(8px + var(--safe-top, env(safe-area-inset-top, 0px)));
    padding-left: 12px;
    padding-right: 12px;
  }

  body[data-mode="conversation"] .container,
  body[data-mode="ai-chat"] .container {
    padding-top: calc(48px + var(--safe-top, env(safe-area-inset-top, 0px)));
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: calc(28px + var(--mobile-bottom-ui, calc(env(safe-area-inset-bottom, 0px) + 12px)));
  }

  body[data-mode="thought-organizer"].thought-live-view #aiAssistant,
  body[data-mode="conversation"] #aiAssistant,
  body[data-mode="ai-chat"] #aiAssistant {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    transition: none;
  }

  body[data-mode="thought-organizer"].thought-live-view #aiAssistant.listening,
  body[data-mode="conversation"] #aiAssistant.listening,
  body[data-mode="ai-chat"] #aiAssistant.listening {
    border: none;
    box-shadow: none;
  }
}

@media (min-width: 601px) {
  body[data-mode="thought-organizer"].thought-live-view .container,
  body[data-mode="conversation"] .container,
  body[data-mode="ai-chat"] .container {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 100dvh;
  }
}

body[data-mode="conversation"] .recording-panel,
body[data-mode="ai-chat"] .recording-panel {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
}

body[data-mode="conversation"] .interview-history {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 12px;
}

body[data-mode="thought-organizer"].thought-live-view.thought-keyboard-open #contentEditor {
  padding-bottom: var(--thought-bottom-chrome-total, 180px);
}

body[data-mode="thought-organizer"].thought-live-view.thought-keyboard-open .editor-chrome-dock,
body[data-mode="thought-organizer"].thought-live-view.thought-keyboard-open .recording-controls {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, calc(100vw - 24px));
  max-width: 900px;
  z-index: 40;
  box-sizing: border-box;
  padding-left: 12px;
  padding-right: 12px;
}

body[data-mode="thought-organizer"].thought-live-view.thought-keyboard-open .recording-controls {
  bottom: calc(var(--thought-keyboard-inset, 0px) + var(--safe-bottom, env(safe-area-inset-bottom, 0px)));
  margin-top: 0;
  padding-top: 4px;
  padding-bottom: 8px;
}

body[data-mode="thought-organizer"].thought-live-view.thought-keyboard-open .editor-chrome-dock {
  bottom: calc(
    var(--thought-keyboard-inset, 0px)
    + var(--thought-recording-chrome-height, 56px)
    + var(--safe-bottom, env(safe-area-inset-bottom, 0px))
  );
  margin-top: 0;
  padding-top: 8px;
  padding-bottom: 4px;
}

body[data-mode="thought-organizer"].thought-live-view #recordingPanel,
body[data-mode="thought-organizer"].thought-live-view #contentPanel {
  display: contents;
}

body[data-mode="thought-organizer"].thought-live-view #contentPanel.hidden {
  display: none !important;
}

body:not([data-mode="thought-organizer"]) #contentPanel {
  display: none !important;
}

body:not([data-mode="thought-organizer"]) .quick-edit-panel--toolbar,
body:not([data-mode="thought-organizer"]) .voice-edit-open-btn {
  display: none !important;
}

body:not([data-mode="thought-organizer"]) .ai-edit-section {
  display: none !important;
}

body[data-mode="thought-organizer"].thought-live-view #aiAssistant {
  order: 1;
  flex-shrink: 0;
  width: 100%;
}

body[data-mode="thought-organizer"].thought-live-view #contentEditorShell,
body[data-mode="thought-organizer"].thought-live-view .content-editor-shell {
  order: 3;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body[data-mode="thought-organizer"].thought-live-view .editor-chrome-dock {
  order: 4;
  flex-shrink: 0;
  width: 100%;
  margin-top: auto;
}

body[data-mode="thought-organizer"].thought-live-view #contentEditor {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body[data-mode="thought-organizer"].thought-live-view .ai-edit-section {
  flex-shrink: 0;
  margin-top: 0;
  padding: 8px 0 4px;
  background: #ffffff;
  border: none;
  border-radius: 0;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.04);
  z-index: 12;
}

body[data-mode="thought-organizer"].thought-live-view .ai-edit-stack {
  gap: 6px;
}

body[data-mode="thought-organizer"].thought-live-view .text-editor.rich-editor {
  min-height: 0;
  flex: 1 1 auto;
  background: #ffffff;
  border-radius: 0;
  max-height: none;
}

@media (min-width: 601px) {
  body[data-mode="thought-organizer"].thought-live-view .text-editor.text-editor-expanded.rich-editor {
    border: 1px solid #c8cdd5;
  }

  body[data-mode="thought-organizer"].thought-live-view .text-editor.text-editor-expanded.rich-editor:focus-within {
    border-color: #b4bac4;
    box-shadow: none;
  }
}

body[data-mode="thought-organizer"].thought-live-view .text-editor.rich-editor:focus-within {
  background: #ffffff;
  box-shadow: none;
}

body[data-mode="thought-organizer"].thought-live-view .rich-editor .ProseMirror {
  min-height: 0;
  flex: 1 1 auto;
  padding: 8px 4px 16px 8px;
  border-radius: 0;
  background: #ffffff;
}

body[data-mode="thought-organizer"].thought-live-view .rich-format-toolbar {
  gap: 3px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body[data-mode="thought-organizer"].thought-live-view .rf-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

body[data-mode="thought-organizer"].thought-live-view .rf-heading-toggle {
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

body[data-mode="thought-organizer"].thought-live-view .rf-btn.rf-list-main {
  width: 26px;
  height: 30px;
}

body[data-mode="thought-organizer"].thought-live-view .rf-list-chevron {
  height: 30px;
  width: 16px;
}

body[data-mode="thought-organizer"].thought-live-view .rich-format-toolbar .rf-sep {
  height: 18px;
  margin: 0 2px;
}

body[data-mode="thought-organizer"].thought-live-view .quick-edit-panel--toolbar > .quick-edit-toggle {
  padding: 5px 10px;
}

body[data-mode="thought-organizer"].thought-live-view .quick-edit-panel--toolbar .quick-edit-toggle-hint {
  display: none;
}

.editor-chrome-toggle {
  display: none;
}

/* Сворачивание: кнопка поверх dock, без отдельной строки в потоке */
.editor-toolbar-toggle {
  display: none;
}

body[data-mode="thought-organizer"].thought-live-view #editorChromeDock {
  /* absolute-потомок кнопки позиционируется от dock */
  overflow: visible;
}

body[data-mode="thought-organizer"].thought-live-view .editor-chrome-toggle {
  display: block;
  position: absolute;
  z-index: 5;
  margin: 0;
  padding: 0;
  line-height: 0;
  pointer-events: none;
}

body[data-mode="thought-organizer"].thought-live-view .editor-chrome-toggle .editor-toolbar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 12px;
  border: 1.5px solid #c4b5fd;
  border-radius: 12px;
  background: linear-gradient(135deg, #faf5ff 0%, #eef2ff 100%);
  box-shadow: 0 1px 4px rgba(109, 40, 217, 0.12);
  color: #5b21b6;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  pointer-events: auto;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

body[data-mode="thought-organizer"].thought-live-view .editor-chrome-toggle .editor-toolbar-toggle:hover,
body[data-mode="thought-organizer"].thought-live-view .editor-chrome-toggle .editor-toolbar-toggle:focus-visible {
  background: linear-gradient(135deg, #f3e8ff 0%, #e0e7ff 100%);
  border-color: #8b5cf6;
}

body[data-mode="thought-organizer"].thought-live-view .editor-chrome-toggle .editor-toolbar-toggle-icon {
  color: #7c3aed;
  flex-shrink: 0;
}

body[data-mode="thought-organizer"].thought-live-view .editor-chrome-toggle .editor-toolbar-toggle-chevron {
  color: #7c3aed;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

/* Развёрнуто: компактный шеврон в правом верхнем углу панели */
body[data-mode="thought-organizer"].thought-live-view:not(.thought-toolbar-collapsed) .editor-chrome-toggle {
  top: 4px;
  right: 8px;
}

body[data-mode="thought-organizer"].thought-live-view:not(.thought-toolbar-collapsed) .editor-chrome-toggle .editor-toolbar-toggle {
  padding: 4px 6px;
  gap: 0;
  min-height: 28px;
  min-width: 28px;
  justify-content: center;
  border-color: rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  color: #64748b;
}

body[data-mode="thought-organizer"].thought-live-view:not(.thought-toolbar-collapsed) .editor-chrome-toggle .editor-toolbar-toggle-icon,
body[data-mode="thought-organizer"].thought-live-view:not(.thought-toolbar-collapsed) .editor-chrome-toggle .editor-toolbar-toggle-label {
  display: none;
}

body[data-mode="thought-organizer"].thought-live-view:not(.thought-toolbar-collapsed) .editor-chrome-toggle .editor-toolbar-toggle-chevron {
  transform: rotate(0deg);
  color: #64748b;
}

body[data-mode="thought-organizer"].thought-live-view:not(.thought-toolbar-collapsed) .ai-edit-section {
  /* место под floating-шеврон, без отдельной строки */
  padding-right: 34px;
}

body[data-mode="thought-organizer"].thought-live-view.thought-toolbar-collapsed .ai-edit-section {
  display: none !important;
}

/* Свёрнуто: без карточки dock — только плавающая кнопка над записью */
body[data-mode="thought-organizer"].thought-live-view.thought-toolbar-collapsed #editorChromeDock {
  height: 0;
  min-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  overflow: visible;
}

body[data-mode="thought-organizer"].thought-live-view.thought-toolbar-collapsed .editor-chrome-toggle {
  right: 0;
  bottom: 8px;
}

body[data-mode="thought-organizer"].thought-live-view.thought-toolbar-collapsed .editor-chrome-toggle .editor-toolbar-toggle-chevron {
  transform: rotate(180deg);
}

@media (max-width: 600px) {
  body[data-mode="thought-organizer"].thought-live-view .rich-format-toolbar {
    gap: 3px;
  }

  body[data-mode="thought-organizer"].thought-live-view .editor-toolbar-body {
    width: 100%;
  }

  body[data-mode="thought-organizer"].thought-live-view:not(.thought-toolbar-collapsed) .editor-chrome-toggle {
    top: 2px;
    right: 4px;
  }

  body[data-mode="thought-organizer"].thought-live-view:not(.thought-toolbar-collapsed) .ai-edit-section {
    padding-right: 30px;
  }
}

/* Кнопка «ИИ-правки» — слева в строке с «ИИ-редактор» */
.voice-edit-open-btn {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1.5px solid rgba(0, 0, 255, 0.18);
  border-radius: 12px;
  background: linear-gradient(135deg, #f0f9ff 0%, #eef2ff 100%);
  box-shadow: 0 1px 4px rgba(0, 0, 255, 0.08);
  color: #1e40af;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  order: 98;
  margin-right: auto;
  transition: background 0.12s ease, border-color 0.12s ease;
}

body[data-mode="thought-organizer"] .voice-edit-open-btn {
  display: inline-flex;
}

.voice-edit-open-btn:hover,
.voice-edit-open-btn:focus-visible {
  background: linear-gradient(135deg, #e0f2fe 0%, #e0e7ff 100%);
  border-color: rgba(0, 0, 255, 0.35);
}

.voice-edit-open-icon {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  color: #0000ff;
}

.voice-edit-open-icon-part {
  display: block;
  flex-shrink: 0;
}

.voice-edit-open-icon-slash {
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  opacity: 0.45;
  transform: translateY(-0.5px);
  user-select: none;
}

.voice-edit-open-label--mobile {
  display: none;
}

@media (max-width: 600px) {
  .voice-edit-open-label--desktop {
    display: none;
  }

  .voice-edit-open-label--mobile {
    display: inline;
  }
}

body[data-mode="thought-organizer"] .rf-row-format::after {
  content: '';
  width: 100%;
  order: 97;
  height: 0;
}

body[data-mode="thought-organizer"] .rich-format-toolbar .quick-edit-panel--toolbar {
  order: 99;
}

body[data-mode="thought-organizer"].thought-live-view .voice-edit-open-btn {
  padding: 5px 10px;
}

body[data-mode="thought-organizer"].thought-live-view .smart-textarea {
  padding: 8px 12px;
  font-size: 14px;
  min-height: 40px;
}

body[data-mode="thought-organizer"].thought-live-view .smart-action-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

body[data-mode="thought-organizer"].thought-live-view .smart-input-container {
  gap: 6px;
}

body[data-mode="thought-organizer"].thought-live-view .recording-controls {
  order: 5;
  flex-shrink: 0;
  margin-top: 0;
  padding: 4px 0 calc(6px + var(--safe-bottom, env(safe-area-inset-bottom, 0px)));
  border-top: none;
  background: transparent;
  z-index: 12;
  justify-content: center;
}

body[data-mode="thought-organizer"].thought-live-view .record-primary-slot {
  flex: 0 1 min(400px, 72%);
  width: min(100%, 400px);
  max-width: 72%;
}

@media (min-width: 601px) {
  body[data-mode="thought-organizer"].thought-live-view .recording-controls {
    padding-bottom: calc(8px + var(--safe-bottom, env(safe-area-inset-bottom, 0px)));
  }

  body[data-mode="thought-organizer"].thought-live-view .record-primary-slot {
    flex: 0 1 380px;
    width: 380px;
    max-width: 380px;
  }

  body[data-mode="conversation"] .recording-controls {
    justify-content: center;
    padding-bottom: 8px;
  }

  body[data-mode="conversation"] .record-primary-slot {
    flex: 0 1 380px;
    width: 380px;
    max-width: 380px;
  }
}

/* Лишние блоки панели записи в едином виде «Мысли» */
body[data-mode="thought-organizer"].thought-live-view .session-hint,
body[data-mode="thought-organizer"].thought-live-view .interview-history,
body[data-mode="thought-organizer"].thought-live-view #aiChatPanel,
body[data-mode="thought-organizer"].thought-live-view #status {
  display: none !important;
}

/* ===== Мобильный компактный header ассистента (режим «Мысли») ===== */
.ai-insight-trigger {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  flex-shrink: 0;
  line-height: 0;
}

.ai-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.ai-header-center-group {
  display: flex;
  align-items: flex-start;
  flex: 1 1 auto;
  min-width: 0;
}

.ai-header-center-group .ai-name {
  font-size: 14px;
}

.ai-header-identity {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  width: 100%;
  min-width: 0;
}

.ai-header-identity-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ai-header-identity .mode-selector--header {
  /* Селектор живёт внутри .mode-tools-row рядом с «+» — не тянуть на 100% родителя */
  width: auto;
  max-width: none;
  min-width: 0;
  flex: 1 1 auto;
}

.ai-header-identity .mode-tools-row {
  width: 100%;
  max-width: none;
  min-width: 0;
}

.ai-header-sidebar-btn {
  display: none;
}

.ai-header-actions {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.ai-header-icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(0, 0, 255, 0.12);
  border-radius: 10px;
  background: #ffffff;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  box-sizing: border-box;
}

.ai-header-icon-btn:hover,
.ai-header-icon-btn:focus-visible {
  color: #0000ff;
  background: #f6f8ff;
  border-color: rgba(0, 0, 255, 0.2);
}

/* На ПК меню только в левом верхнем углу (#appAvatar), не в панели ассистента */
.ai-header-icon-btn.ai-header-sidebar-btn {
  display: none !important;
}

.ai-header-menu-slot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.ai-insight-popover {
  position: fixed;
  inset: 0;
  z-index: 12050;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.ai-insight-popover[hidden] {
  display: none !important;
}

.ai-insight-popover-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(2px);
}

.ai-insight-popover-sheet {
  position: relative;
  width: min(100%, 520px);
  max-height: min(72vh, 520px);
  overflow: auto;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  padding: 16px 18px calc(18px + var(--safe-bottom, env(safe-area-inset-bottom, 0px)));
  box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.14);
  animation: aiInsightSheetIn 0.22s ease;
}

@keyframes aiInsightSheetIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-insight-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.ai-insight-popover-title {
  font-size: 15px;
  font-weight: 650;
  color: #1b1f24;
}

.ai-insight-popover-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: #f3f4f6;
  color: #64748b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.ai-insight-popover-lead {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  color: #ea580c;
}

.ai-insight-popover-body {
  font-size: 14px;
  line-height: 1.65;
  color: #334155;
  white-space: pre-wrap;
}

.ai-insight-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.ai-insight-popover-actions[hidden] {
  display: none !important;
}

.ai-insight-action {
  border: 0;
  border-radius: 10px;
  padding: 9px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.ai-insight-action--secondary {
  background: #f1f5f9;
  color: #475569;
}

.ai-insight-action--primary {
  background: #4f46e5;
  color: #fff;
}

/* Модальное окно «ИИ-правки» */
.voice-edit-modal {
  position: fixed;
  inset: 0;
  z-index: 12060;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.voice-edit-modal[hidden] {
  display: none !important;
}

.voice-edit-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(2px);
}

.voice-edit-modal-sheet {
  position: relative;
  width: min(100%, 520px);
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom, env(safe-area-inset-bottom, 0px)));
  box-shadow: 0 -16px 48px rgba(15, 23, 42, 0.12);
  animation: aiInsightSheetIn 0.22s ease;
}

@media (min-width: 601px) {
  .voice-edit-modal {
    align-items: center;
    padding: 24px;
  }

  .voice-edit-modal-sheet {
    border-radius: 20px;
    padding: 20px 22px 22px;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.16);
  }
}

.voice-edit-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.voice-edit-modal-title {
  font-size: 15px;
  font-weight: 650;
  color: #1b1f24;
}

.voice-edit-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.voice-edit-modal-close:hover {
  background: #e2e8f0;
  color: #334155;
}

.voice-edit-modal-hint {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: #64748b;
}

.voice-edit-composer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 10px 10px 8px 12px;
  border: 1px solid #dbe3ef;
  border-radius: 18px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.voice-edit-composer:focus-within {
  border-color: #0000ff;
  box-shadow: 0 0 0 2px rgba(0, 0, 255, 0.08);
}

.voice-edit-input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  max-height: 140px;
  padding: 0;
  border: 0;
  resize: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: #1b1f24;
  background: transparent;
  outline: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.voice-edit-input::-webkit-scrollbar {
  display: none;
}

.voice-edit-input::placeholder {
  color: #94a3b8;
}

/* Поля приложения — онлайн-редактор документов (эвристика для браузеров) */
.app-document-editor-shell,
.app-document-editor,
.ProseMirror.app-document-editor {
  -webkit-user-select: text;
  user-select: text;
}

#historyMessages .message-text,
#aiChatMessages .ai-chat-message-text {
  -webkit-user-select: text;
  user-select: text;
}

.voice-edit-composer-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.voice-edit-composer-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.voice-edit-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  line-height: 0;
  flex: 0 0 auto;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.voice-edit-mic-btn {
  background: #0000ff;
  color: #fff;
}

.voice-edit-mic-btn:hover:not(:disabled) {
  background: #0000d6;
}

.voice-edit-send-btn {
  box-shadow: none;
}

.voice-edit-send-btn:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
}

.voice-edit-composer:not(.is-typing) .voice-edit-send-btn {
  display: none;
}

.voice-edit-composer.is-typing:not(.is-recording) .voice-edit-mic-btn {
  display: none;
}

.voice-edit-composer.is-recording .voice-edit-send-btn {
  display: none;
}

.voice-edit-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.voice-edit-action-btn.loading {
  animation: spin 0.8s linear infinite;
  background: #64748b !important;
}

.voice-edit-action-btn.loading svg {
  animation: spin 0.8s linear infinite;
}

body.voice-edit-open {
  overflow: hidden;
}

/* Модальное окно: пропало соединение */
.connection-lost-modal {
  position: fixed;
  inset: 0;
  z-index: 12070;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.connection-lost-modal[hidden] {
  display: none !important;
}

.connection-lost-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(2px);
}

.connection-lost-modal-sheet {
  position: relative;
  width: min(100%, 420px);
  padding: 22px 22px 20px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.16);
}

.connection-lost-modal-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 650;
  color: #1b1f24;
}

.connection-lost-modal-text {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.55;
  color: #475569;
}

.connection-lost-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.connection-lost-modal-actions .btn {
  flex: 1 1 140px;
}

body.connection-lost-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  body.ai-mobile-header {
    padding-top: 0;
  }

  html.mode-switching .container,
  html.mode-switching .ai-assistant,
  html.mode-switching #aiAssistant {
    transition: none !important;
  }

  body.ai-mobile-header .container {
    padding-top: calc(4px + var(--safe-top, env(safe-area-inset-top, 0px)));
    padding-left: 12px;
    padding-right: 12px;
  }

  body.ai-mobile-header[data-mode="thought-organizer"].thought-live-view .container {
    padding-top: calc(8px + var(--safe-top, env(safe-area-inset-top, 0px)));
  }

  body.ai-mobile-header #aiAssistant,
  body.ai-mobile-header[data-mode="thought-organizer"].thought-live-view #aiAssistant {
    /* position: fixed задаёт app-shell.css — не сбрасывать в relative */
    display: flex !important;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 10px;
    padding: 0;
    gap: 8px;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    transition: none;
  }

  body.ai-mobile-header[data-mode="thought-organizer"].thought-live-view #aiAssistant {
    margin-bottom: 12px;
  }

  body.ai-mobile-header .ai-header-sidebar-btn {
    display: inline-flex !important;
    flex: 0 0 auto;
    position: relative;
    z-index: 2;
    margin-top: 2px;
  }

  body.ai-mobile-header .ai-header-center-group {
    position: static;
    left: auto;
    top: auto;
    transform: none;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: none;
    pointer-events: auto;
    z-index: 1;
  }

  body.ai-mobile-header .ai-header-identity {
    width: 100%;
    padding: 5px 8px 6px 5px;
    border: 1px solid rgba(0, 0, 255, 0.12);
    border-radius: 14px;
    background: #ffffff;
    box-sizing: border-box;
    gap: 5px;
  }

  body.ai-mobile-header .ai-header-identity-main {
    gap: 8px;
    min-width: 0;
  }

  body.ai-mobile-header .ai-header-identity .mode-tools-row {
    width: 100%;
    gap: 4px;
  }

  body.ai-mobile-header .ai-header-identity .mode-selector--header {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    background: #f3f5fb;
    border-color: rgba(0, 0, 255, 0.08);
    border-radius: 9px;
    padding: 2px;
  }

  body.ai-mobile-header .ai-header-identity .tools-hub-plus-btn {
    width: 26px;
    min-width: 26px;
    height: auto;
    align-self: stretch;
    border-radius: 8px;
    background: #f3f5fb;
  }

  body.ai-mobile-header .ai-header-identity .mode-selector .mode-btn {
    padding: 4px 4px;
    font-size: 10px;
    gap: 3px;
    border-radius: 7px;
  }

  body.ai-mobile-header .ai-header-identity .mode-selector .mode-btn svg {
    width: 11px;
    height: 11px;
  }

  body.ai-mobile-header .ai-assistant.has-insight .ai-header-identity {
    border-color: rgba(234, 88, 12, 0.35);
    box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.07);
  }

  body.ai-mobile-header #aiHeaderActions {
    flex: 0 0 auto;
    margin-left: 0;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    position: relative;
    z-index: 2;
    margin-top: 2px;
  }

  body.ai-mobile-header #aiHeaderActions[hidden] {
    display: none !important;
  }

  body.ai-mobile-header .ai-content {
    display: none !important;
  }

  body.ai-mobile-header .ai-insight-trigger {
    cursor: pointer;
    flex-shrink: 0;
  }

  body.ai-mobile-header .ai-avatar.ai-sphere-wrap {
    width: 40px;
    height: 40px;
  }

  body.ai-mobile-header #aiStatusRow {
    margin-bottom: 0;
    min-width: 0;
    flex-shrink: 1;
  }

  body.ai-mobile-header .ai-name {
    font-size: 15px;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.ai-mobile-header .ai-badge {
    display: none !important;
  }

  body.ai-mobile-header .thought-menu:not(.thought-menu--inline) {
    display: none !important;
  }

  body.ai-mobile-header #thoughtMenuAnchor {
    display: none;
  }

  body.ai-mobile-header .thought-menu--inline {
    position: static;
    top: auto;
    right: auto;
    z-index: auto;
  }

  body.ai-mobile-header .thought-menu--inline .conversation-menu-btn {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(0, 0, 255, 0.12);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: none;
    backdrop-filter: none;
    box-sizing: border-box;
  }

  body.ai-mobile-header .thought-menu--inline .conversation-menu-btn:hover,
  body.ai-mobile-header .thought-menu--inline .conversation-menu-btn:focus-visible {
    background: #f6f8ff;
    color: #0000ff;
    border-color: rgba(0, 0, 255, 0.2);
  }

  body.ai-mobile-header .thought-menu--inline .conversation-menu-dropdown {
    position: fixed;
    top: calc(52px + var(--safe-top, env(safe-area-inset-top, 0px)));
    right: max(10px, env(safe-area-inset-right, 0px));
    left: auto;
    min-width: 220px;
  }

  body.ai-mobile-header .record-aux-btn--menu {
    display: none !important;
  }
}

@media (min-width: 601px) {
  body:not(.ai-mobile-header) .ai-insight-trigger {
    cursor: default;
    pointer-events: none;
  }

  body:not(.ai-mobile-header) .ai-header-top {
    display: none;
  }

  body:not(.ai-mobile-header) #aiAssistant {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    padding: 12px 16px;
    background: #f8faff;
    border: 1px solid rgba(0, 0, 255, 0.06);
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }

  body:not(.ai-mobile-header) #aiAssistant.listening {
    border-color: rgba(0, 0, 255, 0.16);
    box-shadow:
      0 2px 10px rgba(0, 0, 255, 0.08),
      0 0 0 1px rgba(0, 0, 255, 0.06);
  }

  body:not(.ai-mobile-header) .ai-header-center-group {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    padding-right: 0;
    margin-right: 0;
    border-right: none;
    box-sizing: border-box;
    justify-content: stretch;
    align-items: center;
  }

  /* ПК: одна строка — identity слева, режимы справа (на mobile → column) */
  body:not(.ai-mobile-header) .ai-header-identity {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    border: none;
    border-radius: 0;
    background: none;
    box-shadow: none;
    gap: 16px;
    width: 100%;
    max-width: none;
  }

  body:not(.ai-mobile-header) .ai-header-identity-main {
    flex: 1 1 auto;
    gap: 10px;
    min-width: 0;
    justify-content: flex-start;
    width: auto;
    align-self: center;
  }

  body:not(.ai-mobile-header) .ai-avatar.ai-sphere-wrap {
    width: 48px;
    height: 48px;
  }

  body:not(.ai-mobile-header) .ai-header-center-group .ai-name {
    font-size: 15px;
    font-weight: 650;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body:not(.ai-mobile-header) .ai-header-identity .mode-tools-row {
    flex: 0 0 auto;
    flex-shrink: 0;
    margin-top: 0;
    margin-inline: 0;
    margin-left: auto;
    width: auto;
    max-width: none;
    min-width: 0;
    align-self: center;
    gap: 6px;
  }

  body:not(.ai-mobile-header) .ai-header-identity .mode-selector--header {
    flex: 0 0 auto;
    margin-top: 0;
    margin-inline: 0;
    margin-left: 0;
    width: auto;
    max-width: none;
    min-width: max-content;
    background: rgba(0, 0, 255, 0.05);
    border-color: rgba(0, 0, 255, 0.08);
    border-radius: 10px;
    padding: 2px;
    align-self: center;
  }

  body:not(.ai-mobile-header) .ai-header-identity .tools-hub-plus-btn {
    width: 28px;
    min-width: 28px;
    height: auto;
    align-self: stretch;
    border-radius: 8px;
    background: rgba(0, 0, 255, 0.05);
    border-color: rgba(0, 0, 255, 0.08);
  }

  body:not(.ai-mobile-header) .ai-header-identity .mode-selector .mode-btn {
    flex: 0 0 auto;
    min-width: auto;
    padding: 5px 11px;
    font-size: 12px;
    gap: 5px;
    border-radius: 8px;
  }

  body:not(.ai-mobile-header) .ai-header-identity .mode-selector .mode-btn span {
    overflow: visible;
    text-overflow: clip;
  }

  body:not(.ai-mobile-header) .ai-header-identity .mode-selector .mode-btn svg {
    width: 12px;
    height: 12px;
  }

  body:not(.ai-mobile-header) .ai-header-identity .mode-selector .mode-btn.active {
    box-shadow: none;
    background: transparent;
  }

  body:not(.ai-mobile-header) .ai-content {
    display: none !important;
  }

  body:not(.ai-mobile-header)[data-mode="thought-organizer"].thought-live-view #aiAssistant,
  body:not(.ai-mobile-header)[data-mode="conversation"] #aiAssistant,
  body:not(.ai-mobile-header)[data-mode="ai-chat"] #aiAssistant {
    margin-bottom: 0;
  }

  .ai-header-actions {
    display: none !important;
  }
}

/* Узкий desktop: только иконки, если строка не помещается */
@media (min-width: 601px) and (max-width: 680px) {
  body:not(.ai-mobile-header) .ai-header-identity {
    gap: 10px;
  }

  body:not(.ai-mobile-header) .ai-header-identity .mode-selector .mode-btn {
    padding: 5px 6px;
    font-size: 11px;
  }

  body:not(.ai-mobile-header) .ai-header-identity .mode-selector .mode-btn span {
    display: none;
  }

  body:not(.ai-mobile-header) .ai-header-identity .mode-selector .mode-btn svg {
    width: 14px;
    height: 14px;
  }
}

/* Пауза: подсказка сессии скрыта, блок управления остаётся видимым */
body.thought-paused .session-hint {
  display: none !important;
}

body[data-mode="conversation"] .interview-history {
  display: block !important;
}

body[data-mode="ai-chat"] .interview-history,
body[data-mode="ai-chat"] .recording-controls {
  display: none !important;
}

body[data-mode="ai-chat"] .ai-chat-panel {
  display: block !important;
  flex: none;
  min-height: 0;
  overflow: visible;
}

.ai-chat-guest-quota {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #eef2ff;
  border: 1px solid rgba(0, 0, 255, 0.12);
  font-size: 13px;
  color: #1b1f24;
}

.ai-chat-guest-quota.exhausted {
  background: #fef2f2;
  border-color: rgba(239, 68, 68, 0.25);
  color: #991b1b;
}

.ai-chat-guest-quota-link {
  flex-shrink: 0;
  font-weight: 600;
  color: #0000ff;
  text-decoration: none;
}

.ai-chat-guest-quota-link:hover {
  text-decoration: underline;
}

.ai-chat-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.ai-chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
  margin-top: auto;
  padding-top: 10px;
  border-top: 0;
  background: transparent;
}

.ai-chat-composer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 10px 10px 8px 12px;
  border: 1px solid #dbe3ef;
  border-radius: 18px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-chat-composer:focus-within {
  border-color: #0000ff;
  box-shadow: 0 0 0 2px rgba(0, 0, 255, 0.08);
}

.ai-chat-composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.ai-chat-composer-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  margin-left: auto;
}

.ai-chat-composer.is-typing .ai-chat-attach-btn,
.ai-chat-composer.is-recording .ai-chat-attach-btn {
  display: none;
}

.ai-chat-composer:not(.is-typing) .ai-chat-send-btn,
.ai-chat-composer.is-recording .ai-chat-send-btn {
  display: none;
}

.ai-chat-composer.is-typing:not(.is-recording) .ai-chat-mic-btn {
  display: none;
}

.ai-chat-tool-btn.ai-chat-mic-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  line-height: 0;
  flex: 0 0 auto;
  background: #0000ff;
  color: #fff;
}

.ai-chat-tool-btn.ai-chat-mic-btn:hover:not(:disabled) {
  background: #0000d6;
  color: #fff;
  border-color: transparent;
}

.ai-chat-tool-btn.ai-chat-mic-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-chat-tool-btn.ai-chat-mic-btn svg {
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.ai-chat-file-input {
  display: none !important;
  visibility: hidden;
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.ai-chat-tool-btn.ai-chat-attach-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  line-height: 0;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #64748b;
}

.ai-chat-tool-btn.ai-chat-attach-btn:hover:not(:disabled) {
  color: #4338ca;
  background: #eef2ff;
}

.ai-chat-tool-btn.ai-chat-attach-btn svg {
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.ai-chat-attach-btn.has-attachments {
  border-color: #6366f1;
  color: #4338ca;
  background: #eef2ff;
}

.ai-chat-attach-btn.is-uploading {
  opacity: 0.8;
}

.ai-chat-attach-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-chat-attach-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #4338ca;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.ai-chat-attachments-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #c7d2fe;
  border-radius: 14px;
  background: #f8fafc;
}

.ai-chat-attachments-preview-title {
  font-size: 12px;
  font-weight: 700;
  color: #4338ca;
}

.ai-chat-attachments-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-chat-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #fff;
}

.ai-chat-attachment-chip.is-ready {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.ai-chat-attachment-chip.is-uploading {
  border-color: #fde68a;
  background: #fffbeb;
}

.ai-chat-attachment-chip.is-error {
  border-color: #fecaca;
  background: #fef2f2;
}

.ai-chat-attachment-chip img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 auto;
}

.ai-chat-attachment-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #fde68a;
  border-top-color: #d97706;
  border-radius: 50%;
  animation: ai-chat-attach-spin 0.8s linear infinite;
  flex: 0 0 auto;
}

@keyframes ai-chat-attach-spin {
  to { transform: rotate(360deg); }
}

.ai-chat-attachment-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ai-chat-attachment-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 auto;
}

.ai-chat-attachment-name {
  font-size: 12px;
  color: #334155;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-chat-attachment-size {
  font-size: 11px;
  color: #64748b;
}

.ai-chat-attachment-remove {
  border: 0;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  flex: 0 0 auto;
}

.ai-chat-send-btn.has-attachments {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

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

.ai-chat-message-attachment img {
  max-width: 180px;
  max-height: 120px;
  border-radius: 10px;
  border: 1px solid #dbe3ef;
}

.ai-chat-message-attachment-label {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #dbe3ef;
  font-size: 12px;
  color: #475569;
}

.ai-chat-panel.ai-chat-dragover .ai-chat-composer {
  outline: 2px dashed #6366f1;
  outline-offset: 2px;
}

.ai-chat-tool-btn,
.ai-chat-new-btn {
  border: 1px solid #dbe3ef;
  background: #fff;
  color: #475569;
  border-radius: 10px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.ai-chat-tool-btn:hover,
.ai-chat-new-btn:hover {
  border-color: #0000ff;
  color: #0000ff;
  background: #eef2ff;
}

.ai-chat-context-bar {
  display: none;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0 2px;
  color: #64748b;
  font-size: 11px;
  flex-shrink: 0;
}

.ai-chat-context-bar.visible {
  display: flex;
}

.ai-chat-context-bar.warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.ai-chat-context-bar.limit {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.ai-chat-mode-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.ai-chat-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: auto;
  height: 32px;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 999px;
  padding: 0 10px;
  cursor: pointer;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
  flex-shrink: 1;
}

.ai-chat-mode-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-mode-btn:hover {
  color: #334155;
  background: #f1f5f9;
}

.ai-chat-mode-btn.active {
  color: #4338ca;
  background: #eef2ff;
  border-color: #c7d2fe;
  box-shadow: none;
}

.ai-chat-mode-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.ai-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.ai-chat-empty {
  margin: auto;
  color: #94a3b8;
  text-align: center;
  font-size: 14px;
}

.ai-chat-message {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.45;
  font-size: 14px;
  white-space: normal;
}

.ai-chat-message.user {
  align-self: flex-end;
  background: #0000ff;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-chat-message.assistant {
  align-self: flex-start;
  max-width: 100%;
  background: transparent;
  border: none;
  color: #1b1f24;
  border-radius: 0;
  padding: 4px 2px;
}

.ai-chat-message.research-progress {
  background: transparent;
  border: none;
  color: #4338ca;
}

.ai-chat-message.image-progress {
  background: transparent;
  border: none;
  color: #5b21b6;
}

.ai-chat-message.image-result {
  background: transparent;
  border: none;
}

.ai-chat-image-progress-bar {
  margin-top: 10px;
  height: 4px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  overflow: hidden;
}

.ai-chat-image-progress-bar span {
  display: block;
  height: 100%;
  width: 35%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  animation: aiChatImageProgress 1.4s ease-in-out infinite;
}

@keyframes aiChatImageProgress {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.ai-chat-message.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.ai-chat-message.research-result {
  max-width: 96%;
  width: 96%;
  padding: 14px;
}

.ai-chat-message-text-hidden {
  display: none;
}

.ai-chat-answer-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(226, 232, 240, 0.55);
}

.ai-chat-answer-action {
  border: 1px solid #dbe3ef;
  background: #fff;
  color: #64748b;
  border-radius: 999px;
  padding: 5px 9px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.ai-chat-answer-action:hover {
  border-color: #0000ff;
  color: #0000ff;
  background: #eef2ff;
}

.ai-research-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-research-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 12px;
}

.ai-research-title {
  color: #1b1f24;
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
}

.ai-research-meta {
  color: #64748b;
  font-size: 12px;
}

.ai-research-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ai-research-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 700;
}

.ai-research-answer {
  line-height: 1.55;
}

.ai-research-answer a {
  color: #0f766e;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-research-cite {
  color: #0f766e;
  text-decoration: none;
  font-weight: 650;
  margin: 0 1px;
}

.ai-research-cite:hover {
  text-decoration: underline;
}

.ai-research-section-heading {
  margin: 1.25em 0 0.5em;
  font-size: 1.05em;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
}

.ai-research-section-heading .ai-research-section-num {
  color: #0f766e;
  margin-right: 0.15em;
}

.ai-research-hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 1.25em 0;
}

.ai-research-answer blockquote {
  margin: 0.75em 0;
  padding: 0.35em 0.85em;
  border-left: 3px solid #99f6e4;
  color: #334155;
  background: #f8fafc;
}

.ai-research-badge.confidence-high {
  background: #dcfce7;
  color: #166534;
}

.ai-research-badge.confidence-medium {
  background: #fef3c7;
  color: #92400e;
}

.ai-research-badge.confidence-low {
  background: #fee2e2;
  color: #991b1b;
}

.ai-research-section {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
  overflow: hidden;
}

.ai-research-section > summary {
  cursor: pointer;
  padding: 9px 12px;
  color: #1b1f24;
  font-weight: 700;
  font-size: 13px;
}

.ai-research-answer,
.ai-research-aspects,
.ai-research-sources,
.ai-research-no-sources {
  padding: 0 12px 10px;
  color: #1b1f24;
}

.ai-research-search-plan {
  margin: 0 12px 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 13px;
}

.ai-research-search-plan-label {
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.ai-research-search-focus {
  margin: 0 0 8px;
  color: #64748b;
  line-height: 1.4;
}

.ai-research-search-list {
  margin: 0;
  padding-left: 1.2rem;
}

.ai-research-search-item {
  margin-bottom: 6px;
  line-height: 1.45;
}

.ai-research-search-query {
  display: block;
  font-weight: 600;
  color: #0f172a;
}

.ai-research-search-intent {
  display: block;
  color: #64748b;
  font-size: 12px;
  margin-top: 2px;
}

.ai-research-search-stat {
  display: inline-block;
  margin-top: 2px;
  font-size: 11px;
  color: #6366f1;
}

.ai-research-search-retry {
  display: block;
  font-size: 11px;
  color: #b45309;
  margin-top: 2px;
}

.ai-research-search-warn {
  display: inline-block;
  font-size: 11px;
  color: #dc2626;
  margin-left: 6px;
}

.ai-research-aspect-answer {
  padding: 0 12px 12px;
}

.ai-chat-message-text p,
.ai-research-answer p,
.ai-research-aspect div p,
.ai-research-aspect-answer p {
  margin: 0 0 8px;
}

.ai-chat-message-text p:last-child,
.ai-research-answer p:last-child,
.ai-research-aspect div p:last-child {
  margin-bottom: 0;
}

.ai-research-answer h2,
.ai-research-answer h3,
.ai-research-answer h4,
.ai-research-aspect div h2,
.ai-research-aspect div h3,
.ai-research-aspect div h4,
.ai-chat-message-text h2,
.ai-chat-message-text h3,
.ai-chat-message-text h4 {
  color: #0f172a;
  line-height: 1.25;
  margin: 14px 0 6px;
}

.ai-chat-message-images {
  margin-top: 10px;
}

.ai-chat-generated-image,
.ai-chat-md-image,
.ai-research-generated-images figure {
  margin: 12px 0 0;
  max-width: 100%;
}

.ai-chat-generated-image img,
.ai-chat-md-image img,
.ai-research-generated-images img {
  display: block;
  max-width: min(100%, 420px);
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.ai-chat-generated-image figcaption,
.ai-chat-md-image figcaption,
.ai-research-generated-images figcaption {
  margin-top: 6px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

.ai-research-generated-images {
  padding-top: 8px;
}

.ai-research-answer h2:first-child,
.ai-research-answer h3:first-child,
.ai-research-answer h4:first-child,
.ai-research-aspect div h2:first-child,
.ai-research-aspect div h3:first-child,
.ai-research-aspect div h4:first-child,
.ai-chat-message-text h2:first-child,
.ai-chat-message-text h3:first-child,
.ai-chat-message-text h4:first-child {
  margin-top: 0;
}

.ai-research-answer h2,
.ai-chat-message-text h2 {
  font-size: 17px;
}

.ai-research-answer h3,
.ai-chat-message-text h3 {
  font-size: 15px;
}

.ai-research-answer h4,
.ai-research-aspect div h4,
.ai-chat-message-text h4 {
  font-size: 14px;
}

.ai-chat-message-text ul,
.ai-chat-message-text ol,
.ai-research-answer ul,
.ai-research-answer ol,
.ai-research-aspect div ul,
.ai-research-aspect div ol {
  margin: 6px 0 10px;
  padding-left: 20px;
}

.ai-chat-message-text li,
.ai-research-answer li,
.ai-research-aspect div li {
  margin: 3px 0;
}

.ai-research-aspect {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 6px;
  padding: 8px 10px;
}

.ai-research-aspect summary {
  cursor: pointer;
  font-weight: 600;
  color: #334155;
}

.ai-research-aspect summary span {
  color: #64748b;
  font-size: 11px;
  font-weight: 500;
}

.ai-research-aspect summary .ai-research-framework {
  color: #6d28d9;
  background: #ede9fe;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 4px;
}

.ai-research-aspect div {
  margin-top: 7px;
  color: #1b1f24;
}

.ai-research-sources {
  margin: 0;
  padding-left: 28px;
}

.ai-research-sources li {
  margin-bottom: 10px;
}

.ai-research-sources a {
  color: #0000ff;
  font-weight: 600;
  text-decoration: none;
}

.ai-research-sources a:hover {
  text-decoration: underline;
}

.ai-research-sources p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 12px;
}

.ai-chat-message-role {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.75;
  margin-bottom: 4px;
}

.ai-chat-input {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  padding: 0 2px 2px;
  font: inherit;
  line-height: 1.5;
  outline: none;
  background: transparent;
  box-shadow: none;
}

.ai-chat-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  margin-left: 0;
  border-radius: 50%;
  box-shadow: none;
}

.ai-chat-send-btn:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
}

.ai-chat-input:focus {
  border-color: transparent;
  box-shadow: none;
}

.ai-chat-research-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 13px;
  cursor: pointer;
}

.ai-chat-selected-mode {
  color: #64748b;
  font-size: 13px;
}

.ai-chat-composer-footer .btn:disabled,
.ai-chat-input:disabled {
  opacity: 0.65;
  cursor: wait;
}

.session-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.session-history-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.session-history-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.session-history-toolbar[hidden] {
  display: none !important;
}

.session-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.session-toolbar-btn:hover {
  background: #f1f5f9;
  color: #334155;
}

.session-toolbar-btn.is-active {
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
}

.session-toolbar-btn.has-filter::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6366f1;
}

.session-toolbar-btn {
  position: relative;
}

.session-history-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-bottom: 8px;
}

.session-history-search {
  flex: 1 1 auto;
  min-width: 0;
}

.session-history-search-close {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}

.session-history-search-close:hover {
  background: #f1f5f9;
  color: #64748b;
}

.sidebar-section--history.is-guest .session-toolbar-btn:not(#sidebarNewSessionBtn),
.sidebar-section--history.is-guest .session-history-search-wrap,
.sidebar-section--history.is-guest .session-history-list,
.sidebar-section--history.is-guest .session-history-count {
  display: none !important;
}

.sidebar-section--history.is-guest .session-history-header {
  margin-bottom: 0;
}

.session-history-search-wrap[hidden] {
  display: none !important;
}

.session-history-search {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: #1b1f24;
  background: #fff;
  outline: none;
}

.session-history-search:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

.session-history-search::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.session-history-count {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  margin-left: 4px;
}

.session-history-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.session-history-load-more {
  border: 0;
  background: transparent;
  color: #0000ff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.session-history-load-more:hover {
  background: rgba(0, 0, 255, 0.06);
}

.session-history-empty,
.session-history-loading {
  color: #94a3b8;
  font-size: 12px;
  padding: 8px 10px;
}

.session-history-empty--cta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px 12px;
}

.session-history-empty-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #1b1f24;
}

.session-history-empty-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: #64748b;
}

.session-history-empty-btn {
  margin-top: 4px;
  border: 0;
  border-radius: 10px;
  background: #0000ff;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
}

.session-history-empty-btn:hover {
  background: #0000cc;
}

.notes-undo-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  z-index: 12000;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(440px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  background: #1b1f24;
  color: #f8fafc;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.notes-undo-toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.notes-undo-toast[hidden] {
  display: none !important;
}

.notes-undo-toast-msg {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-undo-toast-btn {
  border: 0;
  background: transparent;
  color: #93c5fd;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  flex: 0 0 auto;
}

.notes-undo-toast-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.notes-undo-toast-btn--ghost {
  color: #cbd5e1;
  font-weight: 600;
}

.session-history-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  min-height: 44px;
  border-radius: 8px;
  position: relative;
  content-visibility: auto;
  contain-intrinsic-size: 52px;
  padding: 2px 0;
}

.session-history-row.is-current::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: #0000ff;
}

.session-history-row.is-current {
  background: rgba(0, 0, 255, 0.07);
}

.session-history-row.is-loading {
  background: rgba(15, 23, 42, 0.04);
}

.session-history-row.is-loading .session-history-item {
  cursor: progress;
}

.session-history-pin {
  flex: 0 0 18px;
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  margin-left: 4px;
  margin-top: 10px;
}

.session-history-item {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 6px 8px 6px 10px;
  cursor: pointer;
  text-align: left;
  color: #475569;
}

.session-history-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.session-history-row.is-current .session-history-item,
.session-history-item.is-current {
  color: #0000cc;
  font-weight: 600;
}

.session-history-row:hover .session-history-item {
  background: rgba(15, 23, 42, 0.04);
}

.session-history-row.is-current .session-history-item {
  background: transparent;
}

.session-history-menu-btn {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  margin-right: 2px;
  margin-top: 6px;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.session-history-row:hover .session-history-menu-btn,
.session-history-row:focus-within .session-history-menu-btn,
.session-history-menu-btn:focus-visible {
  opacity: 1;
}

.session-history-menu-btn:hover {
  background: rgba(15, 23, 42, 0.06);
  color: #475569;
}

.session-history-item-title {
  display: block;
  font-size: 13px;
  font-weight: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
}

.session-history-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  font-size: 11px;
  line-height: 1.3;
  color: #94a3b8;
}

.session-history-item-date,
.session-history-item-size {
  flex-shrink: 0;
}

.session-history-item-size {
  color: #a1a1aa;
}

.session-history-mode-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  color: #64748b;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.session-history-item-meta .session-offline-badge {
  font-size: 10px;
  font-weight: 600;
  color: #b45309;
}

.session-history-rename-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #a5b4fc;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 600;
  color: #1b1f24;
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

.session-notes-menu {
  position: fixed;
  z-index: 10050;
  min-width: 168px;
  padding: 4px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.session-notes-menu[hidden] {
  display: none !important;
}

.session-notes-menu-item {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: #1b1f24;
  cursor: pointer;
}

.session-notes-menu-item:hover {
  background: #f1f5f9;
}

.session-notes-menu-item--danger {
  color: #b91c1c;
}

.session-notes-menu-item--danger:hover {
  background: #fef2f2;
}

.session-notes-menu-item[hidden] {
  display: none !important;
}

@media (hover: none) {
  .session-history-menu-btn {
    opacity: 1;
  }
}

.session-folder-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 2px 0;
  padding-left: calc(10px + var(--note-depth, 0) * 14px);
  border-radius: 8px;
}

.session-folder-toggle {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.session-folder-toggle:hover {
  background: rgba(15, 23, 42, 0.06);
  color: #64748b;
}

.session-folder-icon {
  flex: 0 0 18px;
  color: #64748b;
  display: inline-flex;
}

.session-folder-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-folder-menu-btn {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  margin-right: 2px;
}

.session-folder-row:hover .session-folder-menu-btn,
.session-folder-row:focus-within .session-folder-menu-btn {
  opacity: 1;
}

.session-folder-children {
  display: block;
}

.session-history-row {
  padding-left: calc(10px + var(--note-depth, 0) * 14px);
}

.session-history-row.is-dragging,
.session-folder-row.is-dragging {
  opacity: 0.45;
}

.session-folder-row.is-drop-target {
  background: rgba(99, 102, 241, 0.1);
  outline: 1px dashed rgba(99, 102, 241, 0.45);
  border-radius: 8px;
}

#sessionHistoryList.is-root-drop-target {
  outline: 1px dashed rgba(99, 102, 241, 0.35);
  outline-offset: 2px;
  border-radius: 8px;
}

.session-notes-root-drop {
  margin: 6px 10px 4px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: #64748b;
  text-align: center;
  border: 1px dashed #cbd5e1;
}

.session-notes-root-drop[hidden] {
  display: none !important;
}

#sessionHistoryList.is-root-drop-target .session-notes-root-drop {
  color: #4f46e5;
  border-color: rgba(99, 102, 241, 0.55);
  background: rgba(99, 102, 241, 0.06);
}

.session-folder-picker {
  position: fixed;
  z-index: 10050;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 16px));
  max-height: min(360px, calc(100vh - 16px));
  overflow-y: auto;
  padding: 4px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.session-folder-picker[hidden] {
  display: none !important;
}

.session-folder-picker-item {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px 8px calc(10px + var(--note-depth, 0) * 14px);
  border-radius: 7px;
  font-size: 13px;
  color: #1b1f24;
  cursor: pointer;
}

.session-folder-picker-item:hover {
  background: #f1f5f9;
}

@media (hover: none) {
  .session-folder-menu-btn {
    opacity: 1;
  }
}

@media (max-width: 600px) {
  .ai-chat-mode-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 10px;
    flex-shrink: 0;
  }

  .ai-chat-mode-label {
    display: none;
  }

  .ai-chat-message {
    max-width: 94%;
  }

  .ai-chat-message.research-result {
    width: 100%;
    max-width: 100%;
  }

  .ai-research-card-header {
    flex-direction: column;
  }
}

.history-message.assistant.greeting {
  background: #f8fafc;
  border-color: #e2e8f0;
}

/* Стартовое приветствие в «Чат с ИИ» — как обычное сообщение ассистента */
.ai-chat-message.assistant.greeting.ai-chat-greeting-placeholder {
  align-self: flex-start;
  max-width: 100%;
  width: auto;
  margin: 0;
  padding: 4px 2px;
  background: transparent;
  border: none;
  border-radius: 0;
  color: #1b1f24;
}

.ai-chat-greeting-placeholder .ai-chat-message-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: inherit;
  white-space: normal;
}

.history-message.user.optimistic {
  animation: none;
  background: #eef2ff;
  border-color: #c7d2fe;
  border-right-color: #818cf8;
  opacity: 0.94;
  box-shadow: none;
  transition: background-color 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}

.history-message.user.optimistic .message-text {
  color: #334155;
}

.history-message.user.optimistic .message-text:empty::before {
  content: 'Слушаю…';
  color: #94a3b8;
  font-style: italic;
}

.history-message.user.optimistic .message-text:not(:empty)::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: #818cf8;
  opacity: 0.55;
  animation: transcriptCaret 1.2s ease-in-out infinite;
}

.history-message.user.finalized {
  animation: none;
  opacity: 1;
  background: #f8fafc;
  border-color: #e2e8f0;
  border-right-color: #818cf8;
  transition: background-color 0.25s ease, opacity 0.25s ease;
}

@keyframes transcriptCaret {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.85; }
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}


/* ===== ВЫПАДАЮЩЕЕ МЕНЮ ЭКСПОРТА ===== */
.export-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.15), 0 4px 12px -4px rgba(0, 0, 0, 0.08);
  border: 1px solid #eef2ff;
  padding: 8px;
  min-width: 220px;
  z-index: 100;
  animation: dropdownSlideIn 0.15s ease;
}

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

.export-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #1b1f24;
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: inherit;
  text-align: left;
}

.export-dropdown-item:hover {
  background: #f6f8ff;
  color: #0000ff;
}

.export-dropdown-item svg {
  flex-shrink: 0;
  opacity: 0.6;
}

.export-dropdown-item:hover svg {
  opacity: 1;
}

.export-dropdown-section {
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b0;
}

.export-dropdown-divider {
  height: 1px;
  background: #eef2ff;
  margin: 6px 4px;
}

.export-variant-item.active {
  background: #f0f4ff;
  color: #0000ff;
  font-weight: 600;
}

.export-variant-item.active::after {
  content: '✓';
  margin-left: auto;
  font-size: 12px;
}

#exportDropdownBtn {
  position: relative;
}

.toolbar-btn-primary {
  background: #0000ff !important;
  color: white !important;
  border-radius: 10px !important;
}

.toolbar-btn-primary:hover {
  background: #0000d6 !important;
}


/* ===== МОДАЛЬНОЕ ОКНО ТАРИФОВ ===== */
#tariffsModal {
  padding: 16px;
  overflow-y: auto;
  z-index: 10020;
}

.tariffs-modal-dialog {
  width: min(920px, calc(100vw - 32px));
  max-width: 920px;
  max-height: calc(100vh - 32px);
  padding: 28px;
  border-radius: 28px;
  overflow: hidden;
}

.tariffs-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.tariffs-modal-header h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.tariffs-modal-title-icon {
  flex-shrink: 0;
  color: #0000ff;
}

.tariffs-modal-close {
  width: 38px;
  height: 38px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
  color: #646b75;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tariffs-modal-close:hover {
  background: #f6f8ff;
  border-color: #0000ff;
  color: #0000ff;
}

.tariffs-modal-lead {
  max-width: 620px;
  margin: 10px 0 22px;
  color: #646b75;
  font-size: 15px;
  line-height: 1.5;
}

.tariffs-modal-content {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.tariff-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100%;
  padding: 20px;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 8px 24px -18px rgba(15, 23, 42, 0.35);
}

.tariff-card--popular {
  border: 2px solid #0000ff;
  box-shadow: 0 18px 36px -24px rgba(0, 0, 255, 0.5);
}

.tariff-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  margin-bottom: 14px;
}

.tariff-badge,
.tariff-discount {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.tariff-badge {
  background: #0000ff;
  color: #ffffff;
}

.tariff-badge--ghost {
  background: #eef2ff;
  color: #0000ff;
}

.tariff-discount {
  background: #ecfdf5;
  color: #047857;
}

.tariff-title {
  min-height: 46px;
  margin: 0 0 14px;
  color: #1b1f24;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.tariff-minutes {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
  color: #0000ff;
}

.tariff-minutes span {
  font-size: 34px;
  font-weight: 750;
  line-height: 1;
}

.tariff-minutes small {
  color: #646b75;
  font-size: 14px;
  font-weight: 600;
}

.tariff-price {
  margin-top: 6px;
  color: #1b1f24;
  font-size: 28px;
  font-weight: 750;
  line-height: 1.1;
}

.tariff-note {
  margin-top: 6px;
  color: #9ca3b0;
  font-size: 13px;
}

.tariff-description {
  flex: 1;
  margin: 14px 0 20px;
  color: #646b75;
  font-size: 14px;
  line-height: 1.45;
}

.tariff-buy-btn {
  width: 100%;
  flex: 0 0 auto;
  padding: 12px 16px;
}

.tariffs-modal-state {
  grid-column: 1 / -1;
  padding: 24px;
  border-radius: 18px;
  background: #f8fafc;
  color: #646b75;
  text-align: center;
}

.tariffs-modal-state--error {
  background: #fef2f2;
  color: #b91c1c;
}

@media (max-width: 760px) {
  #tariffsModal {
    align-items: flex-start;
    padding: 10px;
  }

  .tariffs-modal-dialog {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 20px);
    padding: 18px;
    border-radius: 22px;
    overflow-y: auto;
  }

  .tariffs-modal-header h2 {
    font-size: 21px;
  }

  .tariffs-modal-lead {
    margin: 8px 0 16px;
    font-size: 14px;
  }

  .tariffs-modal-content {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .tariff-card {
    padding: 16px;
    border-radius: 20px;
  }

  .tariff-title {
    min-height: 0;
    margin-bottom: 12px;
    font-size: 17px;
  }

  .tariff-minutes span {
    font-size: 30px;
  }

  .tariff-price {
    font-size: 25px;
  }

  .tariff-description {
    margin: 12px 0 16px;
  }
}

@media (max-width: 420px) {
  #tariffsModal {
    padding: 0;
  }

  .tariffs-modal-dialog {
    min-height: 100dvh;
    max-height: none;
    border-radius: 0;
    padding: 16px 14px 18px;
  }

  .tariffs-modal-close {
    width: 34px;
    height: 34px;
    border-radius: 12px;
  }

  .tariff-card-top {
    flex-wrap: wrap;
  }
}

/* ===== АНИМАЦИЯ PTT (Push-To-Talk) ===== */
.voice-edit-mic-btn.recording,
#voiceEditBtn.recording,
.ai-chat-mic-btn.recording {
  animation: pttPulse 1.5s infinite;
  position: relative;
  background: #ef4444 !important;
}

.voice-edit-mic-btn.recording::before,
#voiceEditBtn.recording::before,
.ai-chat-mic-btn.recording::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #ef4444;
  animation: pttRing 1.5s infinite;
}

@keyframes pttPulse {
  0%, 100% { 
    background-color: #ef4444; 
    transform: scale(1); 
  }
  50% { 
    background-color: #dc2626; 
    transform: scale(1.05); 
  }
}

@keyframes pttRing {
  0% {
    inset: -4px;
    opacity: 1;
  }
  100% {
    inset: -16px;
    opacity: 0;
  }
}

/* ===== СПИННЕР ДЛЯ ОТПРАВКИ ===== */
.smart-action-btn.loading {
  animation: spin 0.8s linear infinite;
  background: #64748b !important;
}

.smart-action-btn.loading svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===== Tools hub («+») ===== */
.mode-tools-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
  box-sizing: border-box;
}

.mode-tools-row .mode-selector--header {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

.tools-hub-plus-btn {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 28px;
  min-width: 28px;
  padding: 0;
  border: 1px solid rgba(0, 0, 255, 0.1);
  border-radius: 8px;
  background: #eef1f8;
  color: #646b75;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.tools-hub-plus-btn:hover {
  color: #0000ff;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 255, 0.12);
}

.tools-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1200;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 23, 42, 0.42);
  padding: 16px;
  box-sizing: border-box;
}

.tools-overlay.active {
  display: flex;
}

.tools-panel {
  width: min(440px, 100%);
  max-height: min(86vh, 640px);
  overflow: auto;
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid rgba(0, 0, 255, 0.08);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  padding: 18px 18px 20px;
  box-sizing: border-box;
}

.tools-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.tools-panel-header h2 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  color: #1b1f24;
}

.tools-panel-close,
.tools-panel-back {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.tools-panel-lead {
  margin: 0 0 14px;
  font-size: 13px;
  color: #64748b;
}

.tools-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tools-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 255, 0.1);
  background: #f8fafc;
  color: #1b1f24;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tools-card:hover:not(.is-disabled):not(:disabled) {
  background: #eef2ff;
  border-color: rgba(0, 0, 255, 0.22);
}

.tools-card.is-disabled,
.tools-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.tools-card-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #ffffff;
  color: #0000ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 255, 0.08);
}

.tools-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tools-card-title {
  font-size: 15px;
  font-weight: 650;
}

.tools-card-desc {
  font-size: 13px;
  color: #64748b;
  line-height: 1.4;
}

.audio-dropzone {
  border: 1.5px dashed rgba(0, 0, 255, 0.28);
  border-radius: 14px;
  background: #f8fafc;
  padding: 28px 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.audio-dropzone.is-dragover,
.audio-dropzone:hover {
  background: #eef2ff;
  border-color: rgba(0, 0, 255, 0.45);
}

.audio-dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #64748b;
  font-size: 13px;
  text-align: center;
}

.audio-dropzone-inner strong {
  color: #1b1f24;
  font-size: 15px;
  font-weight: 650;
}

.audio-progress {
  margin-top: 4px;
}

.audio-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: #64748b;
}

.audio-progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.audio-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: #0000ff;
  transition: width 0.25s ease;
}

.audio-transcribe-error {
  margin: 12px 0 0;
  color: #dc2626;
  font-size: 13px;
  line-height: 1.4;
}

@media (min-width: 900px) {
  .tools-overlay {
    align-items: center;
  }
}

body.ai-mobile-header .tools-hub-plus-btn {
  width: 26px;
  min-width: 26px;
}