*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f3f4f6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: #111827;
}

/* ===== ЛЕЙАУТ ===== */

#page-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ----- ЛЕВЫЙ САЙДБАР (чаты) ----- */

#sidebar {
  width: 260px;
  background: #111827;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-logo {
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

#new-chat-btn {
  width: 100%;
  padding: 8px 10px;
  border-radius: 999px;
  border: none;
  background: #10b981;
  color: white;
  font-size: 14px;
  cursor: pointer;
}

#new-chat-btn:hover {
  background: #059669;
}

.sidebar-search {
  padding: 0 2px;
}

#chat-search {
  width: 100%;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid #374151;
  background: #111827;
  color: #e5e7eb;
  font-size: 13px;
}

#chat-search::placeholder {
  color: #6b7280;
}

.sidebar-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  padding: 4px 2px;
}

#chat-list {
  flex: 1;
  overflow-y: auto;
}

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

.chat-list-item {
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 4px;
  transition: background 0.1s ease;
}

.chat-list-item:hover {
  background: #1f2937;
}

.chat-list-item.active {
  background: #374151;
}

.chat-list-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-list-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list-empty {
  font-size: 13px;
  color: #9ca3af;
  padding: 8px 4px;
}

/* редактирование заголовка чата */

.chat-title-input {
  flex: 1;
  background: #111827;
  border: 1px solid #4b5563;
  color: #e5e7eb;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 13px;
}

.chat-icon-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-icon-button {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  padding: 0;
}

.chat-icon-button:hover {
  background: #1f2937;
  color: #e5e7eb;
}

.chat-icon-button.edit {
  color: #a5b4fc;
}

.chat-icon-button.edit:hover {
  background: #312e81;
  color: #e5e7eb;
}

.chat-icon-button.delete {
  color: #fecaca;
}

.chat-icon-button.delete:hover {
  background: #7f1d1d;
  color: #fee2e2;
}

.chat-icon-button.save {
  color: #bbf7d0;
}

.chat-icon-button.save:hover {
  background: #166534;
  color: #dcfce7;
}

.chat-icon-button.cancel {
  color: #fecaca;
}

.chat-icon-button.cancel:hover {
  background: #7f1d1d;
  color: #fee2e2;
}

/* ===== СТРОКА МОДУЛЯ ПАМЯТИ ПОД ЧАТОМ ===== */

.chat-memory-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
  padding: 0 2px 2px 2px;
  font-size: 11px;
  color: #9ca3af;
}

.chat-memory-label {
  opacity: 0.9;
}

.chat-memory-edit {
  border: none;
  background: transparent;
  color: #a5b4fc;
  cursor: pointer;
  font-size: 11px;
  padding: 0 4px;
}

.chat-memory-edit:hover {
  color: #c4b5fd;
}

/* ----- ЦЕНТР: модули + чат + лог ----- */

#center-wrap {
  flex: 1;
  display: flex;
  padding: 10px;
  gap: 10px;
  box-sizing: border-box;
}

/* ===== ПАНЕЛЬ МОДУЛЕЙ (слева от чата) ===== */

#modules-panel {
  width: 230px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.06);
  padding: 10px;
  display: flex;
  flex-direction: column;
}

/* заголовок модулей + кнопка нового модуля */

#modules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modules-title {
  font-size: 13px;
  font-weight: 600;
}

#new-module-btn {
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  background: #e5e7eb;
  color: #111827;
}

#new-module-btn:hover {
  background: #d1d5db;
}

#modules-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow-y: auto;
}

/* карточка модуля */

.module-card {
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.module-title {
  font-weight: 500;
  word-break: break-word;
}

/* компоновка элементов внутри карточки модуля */
.module-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.module-card-bottom {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.module-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.module-icon-button {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  padding: 0;
}

.module-icon-button:hover {
  background: #e5e7eb;
  color: #111827;
}

.module-icon-button.edit {
  color: #4f46e5;
}

.module-icon-button.edit:hover {
  background: #e0e7ff;
  color: #1e1b4b;
}

.module-icon-button.delete {
  color: #b91c1c;
}

.module-icon-button.delete:hover {
  background: #fee2e2;
  color: #7f1d1d;
}

/* переключатель (тумблер) */

.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #d1d5db;
  transition: 0.2s;
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.2s;
  border-radius: 999px;
}

.switch input:checked + .slider {
  background-color: #10b981;
}

.switch input:checked + .slider:before {
  transform: translateX(16px);
}

.modules-empty {
  font-size: 13px;
  color: #6b7280;
}

/* ===== ЧАТ (центр) ===== */

#chat-panel {
  flex: 1;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#chat-section {
  flex: 1;
  min-height: 0;
}

#chat-window {
  height: 100%;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.08);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.message {
  max-width: 75%;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}

.message.user {
  align-self: flex-end;
  background: #dcfce7;
}

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

.message-images {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.message-images img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 6px;
}

/* плейсхолдер */

.chat-placeholder {
  margin: auto;
  text-align: center;
  font-size: 14px;
  color: #6b7280;
}

/* ===== ПОЛЕ ВВОДА + ВЛОЖЕНИЯ ===== */

#input-section {
  padding-top: 2px;
}

#attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.attachment-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attachment-item img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.attachment-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-size: 12px;
  line-height: 18px;
  cursor: pointer;
}

/* общий ряд ввода: поддерживаем и старый id, и новый */

#input-area,
#input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#attach-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: #e5e7eb;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#attach-btn:hover {
  background: #d1d5db;
}

#chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 150px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  resize: none;
  outline: none;
}

#chat-input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.3);
}

#send-btn {
  padding: 8px 16px;
  border-radius: 10px;
  border: none;
  background: #10b981;
  color: white;
  font-size: 14px;
  cursor: pointer;
}

#send-btn:hover {
  background: #059669;
}

/* ===== ПРАВЫЙ ЛОГ (консоль) ===== */

#log-panel {
  width: 260px;
  background: #020617;
  color: #22c55e;
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

#log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

#log-header span {
  flex-shrink: 0;
}

#show-knowledge-btn {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #22c55e;
  background: transparent;
  color: #166534;
  cursor: pointer;
  white-space: nowrap;
}

#show-knowledge-btn:hover {
  background: rgba(34, 197, 94, 0.12);
}

#log-body {
  flex: 1;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.4;
}

/* строки лога */

.log-line {
  white-space: pre-wrap;
}

.log-info {
  color: #22c55e; /* зелёный */
}

.log-warn {
  color: #facc15; /* жёлтый */
}

.log-error {
  color: #f97373; /* красный */
}

/* ===== МОДАЛКА ПОДТВЕРЖДЕНИЯ УДАЛЕНИЯ ===== */

#confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#confirm-modal-dialog {
  background: #111827;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
  min-width: 260px;
  max-width: 320px;
}

#confirm-modal-text {
  font-size: 14px;
  margin-bottom: 12px;
}

#confirm-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#confirm-yes,
#confirm-no {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  cursor: pointer;
}

#confirm-yes {
  background: #dc2626;
  color: #fef2f2;
}

#confirm-yes:hover {
  background: #b91c1c;
}

#confirm-no {
  background: #374151;
  color: #e5e7eb;
}

#confirm-no:hover {
  background: #4b5563;
}

/* ===== МОДАЛКА РЕДАКТОРА ПАМЯТИ (для чата) ===== */

#memory-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}

#memory-modal-dialog {
  background: #0f172a;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 16px 18px;
  width: min(700px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

#memory-modal-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

#memory-modal-subtitle {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 10px;
}

#memory-editor-body {
  flex: 1;
  min-height: 0;
}

#memory-textarea {
  width: 100%;
  min-height: 260px;
  max-height: 60vh;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}

#memory-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

#memory-save,
#memory-cancel {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  cursor: pointer;
}

#memory-save {
  background: #10b981;
  color: #ecfdf5;
}

#memory-save:hover {
  background: #059669;
}

#memory-cancel {
  background: #374151;
  color: #e5e7eb;
}

#memory-cancel:hover {
  background: #4b5563;
}


/* ===== МОДАЛКА НОВОГО МОДУЛЯ ===== */

#module-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}

#module-modal-dialog {
  background: #f9fafb;
  color: #111827;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  min-width: 480px;
  max-width: 640px;
}

#module-modal-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

#module-modal-subtitle {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 10px;
}

#module-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.module-field > span {
  display: block;
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 4px;
}

#module-name {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 13px;
}

#module-rules {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 13px;
  padding: 6px 8px;
}

#module-files {
  font-size: 12px;
}

#module-modal-buttons {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#module-create,
#module-cancel {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  cursor: pointer;
}

#module-create {
  background: #10b981;
  color: #ecfdf5;
}

#module-create:hover {
  background: #059669;
}

#module-cancel {
  background: #e5e7eb;
  color: #111827;
}

#module-cancel:hover {
  background: #d1d5db;
}

/* ===== СКРОЛЛБАРЫ ===== */

#chat-window::-webkit-scrollbar,
#chat-list::-webkit-scrollbar,
#modules-grid::-webkit-scrollbar,
#log-body::-webkit-scrollbar {
  width: 6px;
}

#chat-window::-webkit-scrollbar-thumb,
#chat-list::-webkit-scrollbar-thumb,
#modules-grid::-webkit-scrollbar-thumb,
#log-body::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 999px;
}

#chat-window::-webkit-scrollbar-track,
#chat-list::-webkit-scrollbar-track,
#modules-grid::-webkit-scrollbar-track,
#log-body::-webkit-scrollbar-track {
  background: transparent;
}

/* ===== Редактор существующего модуля знаний ===== */

#module-edit-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

#module-edit-dialog {
  background: #020617;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 16px 18px;
  width: 480px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.9);
}

#module-edit-header {
  font-size: 14px;
  font-weight: 600;
}

#module-edit-body {
  min-height: 150px;
}

#module-edit-text {
  width: 100%;
  min-height: 180px;
  max-height: 320px;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #020617;
  color: #e5e7eb;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}

#module-edit-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

#module-edit-save,
#module-edit-cancel {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
}

#module-edit-save {
  background: #16a34a;
  color: #ecfdf5;
}

#module-edit-save:hover {
  background: #22c55e;
}

#module-edit-cancel {
  background: #111827;
  color: #e5e7eb;
}

#module-edit-cancel:hover {
  background: #020617;
}

/* ===== АДАПТИВ ===== */

/* до 1200 — просто убираем лог */
@media (max-width: 1200px) {
  #log-panel {
    display: none;
  }

  #center-wrap {
    gap: 8px;
  }
}

/* до 900 — мобильная компоновка в 5 строк */
@media (max-width: 900px) {
  #page-layout {
    flex-direction: column;
    height: 100vh;
  }

  #center-wrap {
    flex: 1;
    flex-direction: column;
    padding: 6px;
    gap: 6px;
  }

  /* 1-й ряд: чаты (горизонтальная полоса) */
  #sidebar {
    width: 100%;
    flex-direction: column;
    padding: 6px;
    gap: 4px;
  }

  .sidebar-top {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .sidebar-logo {
    font-size: 14px;
  }

  #new-chat-btn {
    font-size: 12px;
    padding: 6px 10px;
  }

  .sidebar-search,
  .sidebar-section-title {
    display: none; /* экономим место на мобильном */
  }

  #chat-list {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .chat-list-item {
    flex: 0 0 auto;
    margin-bottom: 0;
    min-width: 80px;
    max-width: 140px;
    font-size: 12px;
    padding: 6px;
  }

  .chat-memory-row {
    display: none; /* слишком мелко для мобилки */
  }

  /* 2-й ряд: модули (горизонтальная полоса с тумблерами) */
  #modules-panel {
    width: 100%;
    padding: 6px;
  }

  #modules-header {
    margin-bottom: 4px;
  }

  #modules-grid {
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .module-card {
    flex: 0 0 auto;
    min-width: 100px;
    max-width: 140px;
  }

  /* порядок внутри center-wrap:
     2-й ряд — модули, 3-й — кнопка, 4-й — чат */
  #modules-panel {
    order: 1;
  }

  #show-knowledge-btn {
    order: 2;
    align-self: stretch;
    width: 100%;
    text-align: center;
  }

  #chat-panel {
    order: 3;
    max-width: 100%;
  }

  /* 4-й ряд: окно чата */
  #chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  #chat-section {
    flex: 1;
    min-height: 0;
  }

  #chat-window {
    min-height: 200px;
    padding: 10px;
  }

  .message {
    max-width: 100%;
    font-size: 13px;
  }

  /* 5-й ряд: поле ввода + кнопки */
  #input-section {
    padding-bottom: 6px;
  }

  #input-row {
    gap: 6px;
  }

  #chat-input {
    font-size: 13px;
    min-height: 38px;
  }

  #attach-btn {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }

  #send-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
}

/* очень узкие экраны */
@media (max-width: 600px) {
  #chat-window {
    padding: 8px;
  }

  .attachment-item {
    width: 70px;
    height: 70px;
  }
}

/* ===== Мобильная фиксация окна чата ===== */
@media (max-width: 900px) {
  /* центр занимает всё оставшееся место под строкой чатов */
  #center-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;      /* важно: позволяет сжиматься */
    overflow: hidden;   /* скролл только внутри окна чата */
  }

  /* чат-панель растягивается между кнопкой и низом экрана */
  #chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  /* секция окна чата занимает всё пространство над полем ввода */
  #chat-section {
    flex: 1;
    min-height: 0;
    display: flex;
  }

  /* скролл только внутри окна чата */
  #chat-window {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  /* поле ввода всегда приклеено к низу */
  #input-section {
    flex-shrink: 0;
    background: #f3f4f6;
    padding-top: 6px;
  }

  /* кнопка "Отобразить знания" фиксированной высоты, не растягивается */
  #show-knowledge-btn {
    flex-shrink: 0;
  }
}

/* ===== Мобильная версия кнопки + Новый чат ===== */
@media (max-width: 900px) {
  #new-chat-btn {
    padding: 4px 8px !important;
    font-size: 12px !important;
    border-radius: 8px !important;
    background: #1f2937 !important; /* тёмно-серый */
    color: #e5e7eb !important;
    border: 1px solid #374151 !important;
  }

  #new-chat-btn:hover {
    background: #374151 !important;
  }
}






/* === PATCH: Expanded module editor with stacked fields and styled chunks textarea === */
#module-edit-dialog {
  width: 80vw;
  max-width: 80vw;
  height: 80vh;
  max-height: 80vh;
}

#module-edit-body {
  min-height: auto;
  height: calc(80vh - 120px);
  overflow-y: auto;
}

/* контейнер для двух областей: правила и чанки */
.module-edit-fields {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 12px;
}

/* каждая колонка-область */
.module-edit-column {
  width: 100%;
}

/* общий стиль для полей правил и чанков */
#module-edit-text,
#module-edit-chunks {
  width: 100%;
  min-height: 260px;
  max-height: 500px;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #020617;
  color: #e5e7eb;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  white-space: pre-wrap;
  box-sizing: border-box;
}

/* подписи */
.module-edit-column label,
.module-rules-label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #9ca3af;
}


/* ===== ПРОМТЫ (System / Memory / Vision) ===== */

#prompt-list {
  margin: 8px 0 12px 0;
}

.prompt-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.prompt-item:hover {
  background: #1f2937;
}

.prompt-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt-edit-btn {
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
}

.prompt-edit-btn:hover {
  color: #f9fafb;
}

/* Модалка редактирования промта */

#prompt-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

#prompt-modal-dialog {
  background: #0f172a;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 16px 18px;
  width: min(700px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

#prompt-modal-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

#prompt-textarea {
  width: 100%;
  min-height: 260px;
  max-height: 60vh;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  margin-bottom: 10px;
}

#prompt-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#prompt-save,
#prompt-cancel {
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  font-size: 13px;
  cursor: pointer;
}

#prompt-save {
  background: #10b981;
  color: #ecfdf5;
}

#prompt-save:hover {
  background: #059669;
}

#prompt-cancel {
  background: transparent;
  color: #e5e7eb;
}

#prompt-cancel:hover {
  background: #111827;
}


/* ===== ПАНЕЛЬ КНОПОК: ЗНАНИЯ / ПРОМПТЫ ===== */

#assistant-tools-bar {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

#assistant-tools-bar button {
  flex: 1;
  width: auto;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #22c55e;
  background: transparent;
  color: #166534;
  cursor: pointer;
  white-space: nowrap;
}

#assistant-tools-bar button:hover {
  background: rgba(34, 197, 94, 0.12);
}

/* сохраняем старые стили на случай, если где-то остался id */
#show-knowledge-btn {
  width: auto;
}
