/**
 * DIVIALET - Версия с настройками модели и канвасами
 * Стили для одноокного интерфейса с диалогами в узлах
 * + Система настроек модели
 * + Кнопка удаления в виде крестика в правом верхнем углу
 * + Левая панель навигации по канвасам
 */

/* Импорт шрифтов */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --node-default-width: 450px;
    --node-default-height: 650px;
}

/* Сброс стилей */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Основные стили */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #2d3748;
    height: 100vh;
    overflow: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Контейнер приложения */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #ffffff;
}

/* ==================== ПАНЕЛЬ ИНСТРУМЕНТОВ ==================== */

.toolbar {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.app-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #3182ce;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.node-navigator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #718096;
}

.node-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 0.85rem;
    background: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 160px;
    max-width: 200px;
}

.node-select:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.2);
}

.node-select:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.toolbar-right {
    display: flex;
    gap: 0.75rem;
}

.btn {
    padding: 0.6rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: white;
    color: #4a5568;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: #3182ce;
    color: white;
    border-color: #3182ce;
}

.btn-primary:hover {
    background: #2c5282;
    border-color: #2c5282;
}

.btn-secondary {
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.btn:disabled {
    background: #f7fafc;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

/* ==================== ГЛАВНАЯ ОБЛАСТЬ КОНТЕНТА ==================== */

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ==================== ЛЕВАЯ ПАНЕЛЬ НАВИГАЦИИ ==================== */

.canvas-sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    z-index: 50;
    min-width: 280px;
    max-width: 400px;
    resize: horizontal;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.export-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.1rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    opacity: 0.6;
}

.export-btn:hover {
    background-color: #f7fafc;
    opacity: 1;
    transform: scale(1.1);
}

.export-btn:active {
    transform: scale(0.95);
}

.sidebar-header h3 {
    margin: 0;
    flex: 1;
}

.sidebar-header h3::before {
    content: '💬';
    font-size: 1.2rem;
}

.canvas-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.canvas-list::-webkit-scrollbar {
    width: 6px;
}

.canvas-list::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.canvas-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.canvas-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0.5rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    position: relative;
    gap: 0.75rem;
}

.canvas-item:hover {
    background: #f7fafc;
    border-color: #e2e8f0;
}

.canvas-item.active {
    background: #ebf8ff;
    border-color: #3182ce;
    color: #3182ce;
}

.canvas-item-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid currentColor;
    opacity: 0.7;
}

.canvas-item-content {
    flex: 1;
    min-width: 0;
}

.canvas-item-title {
    font-weight: 500;
    font-size: 0.9rem;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.canvas-item.active .canvas-item-title {
    color: #3182ce;
    font-weight: 600;
}

.canvas-item-meta {
    font-size: 0.75rem;
    color: #718096;
    margin-top: 0.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.canvas-item-nodes {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.canvas-item-time {
    color: #a0aec0;
}

.canvas-item-rename {
    position: absolute;
    top: 8px;
    right: 28px;
    width: 20px;
    height: 20px;
    background: rgba(49, 130, 206, 0.1);
    border: none;
    border-radius: 50%;
    color: #3182ce;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.2s ease;
}

.canvas-item:hover .canvas-item-rename {
    display: flex;
}

.canvas-item-rename:hover {
    background: rgba(49, 130, 206, 0.2);
    color: #2c5282;
    transform: scale(1.1);
}

.canvas-item-rename:active {
    transform: scale(0.9);
}

.canvas-item-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    border-radius: 50%;
    color: #dc2626;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.canvas-item:hover .canvas-item-delete {
    display: flex;
}

.canvas-item-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #b91c1c;
    transform: scale(1.1);
}

.canvas-item-delete:active {
    transform: scale(0.9);
}

/* Drag & Drop стили для канвасов */
.canvas-item[draggable="true"] {
    cursor: move;
}

.canvas-item:hover[draggable="true"] {
    cursor: move;
}

.canvas-item[draggable="true"]:active {
    cursor: grabbing;
}

.empty-canvas-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: #718096;
    font-size: 0.9rem;
    line-height: 1.5;
    height: 200px;
}

.empty-canvas-list-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ==================== ОБЛАСТЬ ДЕРЕВА ==================== */

.tree-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f7fafc;
}

.tree-canvas {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: auto;
    background: 
        radial-gradient(circle at 20px 20px, #e2e8f0 1px, transparent 1px),
        radial-gradient(circle at 60px 60px, #e2e8f0 1px, transparent 1px);
    background-size: 40px 40px;
    cursor: grab;
    scroll-behavior: smooth;
    user-select: none;
    will-change: transform;
}

.tree-canvas:active {
    cursor: grabbing;
}

.nodes-container {
    position: relative;
    padding: 2rem;
    transform-origin: 0 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}


/* ==================== ЦВЕТОВЫЕ СХЕМЫ УЗЛОВ ==================== */

.dialog-node {
    position: absolute;
    width: 450px;
    min-height: 650px;
    background: white;
    border: 2px solid var(--node-border-color, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    overflow: hidden;
    cursor: move;
    transition: all 0.2s ease;
    z-index: 100;
    will-change: transform, left, top;
}

.dialog-node:hover {
    border-color: var(--node-primary-color, #3182ce);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
    cursor: pointer;
}

.dialog-node.active {
    border-color: var(--node-primary-color, #3182ce);
    box-shadow: 0 8px 20px rgba(49, 130, 206, 0.2);
    transform: translateY(-2px);
}

.dialog-node.processing {
    border-color: #ed8936;
    box-shadow: 0 8px 20px rgba(237, 137, 54, 0.2);
}

/* Цветовые классы для узлов */
.node-color-blue {
    --node-primary-color: #3182ce;
    --node-border-color: #2c5282;
    --node-bg-color: #ebf8ff;
}

.node-color-green {
    --node-primary-color: #48bb78;
    --node-border-color: #38a169;
    --node-bg-color: #f0fff4;
}

.node-color-purple {
    --node-primary-color: #805ad5;
    --node-border-color: #6b46c1;
    --node-bg-color: #faf5ff;
}

.node-color-red {
    --node-primary-color: #e53e3e;
    --node-border-color: #c53030;
    --node-bg-color: #fed7d7;
}

.node-color-orange {
    --node-primary-color: #ed8936;
    --node-border-color: #dd6b20;
    --node-bg-color: #fef5e7;
}

.node-color-pink {
    --node-primary-color: #d53f8c;
    --node-border-color: #b83280;
    --node-bg-color: #fed7e2;
}

.node-color-teal {
    --node-primary-color: #38b2ac;
    --node-border-color: #319795;
    --node-bg-color: #e6fffa;
}

.node-color-yellow {
    --node-primary-color: #d69e2e;
    --node-border-color: #b7791f;
    --node-bg-color: #fffff0;
}

.dialog-node.new {
    animation: nodeSlideIn 0.3s ease-out;
}

/* Ручка для изменения размера */
.dialog-node::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(-45deg, transparent 30%, #cbd5e0 30%, #cbd5e0 35%, transparent 35%, transparent 65%, #cbd5e0 65%, #cbd5e0 70%, transparent 70%);
    cursor: nw-resize;
    z-index: 200;
    border-bottom-right-radius: 10px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.dialog-node:hover::after {
    opacity: 1;
}

.dialog-node.resizing::after {
    opacity: 1;
    background: linear-gradient(-45deg, transparent 30%, #3182ce 30%, #3182ce 35%, transparent 35%, transparent 65%, #3182ce 65%, #3182ce 70%, transparent 70%);
}

.dialog-node.resizing {
    user-select: none;
}

/* Стили для перетаскивания */
.dialog-node.dragging {
    cursor: grabbing;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    transform: scale(1.02) translateY(-4px);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.dialog-node.dragging * {
    pointer-events: none;
}

.dialog-node.dragging .node-header {
    cursor: grabbing;
}

.dialog-node:not(.dragging) {
    transition: left 0.3s ease, top 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

@keyframes nodeSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==================== ЗАГОЛОВОК УЗЛА ==================== */

.node-header {
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--node-bg-color, #f7fafc) 0%, #f7fafc 100%);
    border-bottom: 1px solid var(--node-border-color, #e2e8f0);
    cursor: move;
    user-select: none;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    grid-row: 1;
}

.node-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.node-title {
    flex: 1;
    min-width: 0; /* Позволяет тексту сжиматься */
    font-weight: 600;
    font-size: 1rem;
    color: #2d3748;
    background: none;
    border: none;
    outline: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.node-title:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

.node-title:focus {
    background-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.2);
}

.node-header-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0; /* Кнопки не сжимаются */
}

.node-config-btn,
.node-height-expand-btn,
.node-fullscreen-btn,
.node-delete-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.node-config-btn:hover,
.node-height-expand-btn:hover,
.node-fullscreen-btn:hover {
    background: rgba(255, 255, 255, 1);
    color: #333;
    transform: scale(1.05);
}

.node-delete-btn:hover {
    background: #e53e3e;
    color: white;
    border-color: #c53030;
    transform: scale(1.05);
}

.node-height-expand-btn.active {
    background: #3182ce;
    color: white;
    border-color: #2c5282;
}

/* Обновляем стили для .node-controls */
.node-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0; /* Убираем отступы сверху, так как теперь есть отступ в .node-title-row */
}

.node-header:hover {
    background: linear-gradient(135deg, var(--node-bg-color, #edf2f7) 0%, #edf2f7 100%);
}

.node-header:active {
    background: linear-gradient(135deg, var(--node-border-color, #e2e8f0) 0%, #cbd5e0 100%);
}

/* Кнопка удаления в правом верхнем углу */
.node-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    border-radius: 50%;
    color: #dc2626;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s ease;
    opacity: 0;
    z-index: 10;
}

.dialog-node:hover .node-delete-btn {
    opacity: 1;
}

.node-delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #b91c1c;
    transform: scale(1.1);
}

.node-delete-btn:active {
    transform: scale(0.95);
}

/* Кнопка настроек модели для корневых узлов */
.node-config-btn {
    position: absolute;
    top: 8px;
    right: 36px;
    width: 24px;
    height: 24px;
    background: rgba(49, 130, 206, 0.1);
    border: none;
    border-radius: 50%;
    color: #3182ce;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
    opacity: 0;
    z-index: 10;
}

.dialog-node:hover .node-config-btn {
    opacity: 1;
}

.node-config-btn:hover {
    background: rgba(49, 130, 206, 0.2);
    color: #2c5282;
    transform: scale(1.1);
}

.node-config-btn:active {
    transform: scale(0.95);
}

/* Индикатор перетаскивания */
.node-header::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background: repeating-linear-gradient(
        to bottom,
        #cbd5e0 0px,
        #cbd5e0 2px,
        transparent 2px,
        transparent 4px
    );
    border-radius: 2px;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.node-header:hover::before {
    opacity: 0.8;
}

.dialog-node.dragging .node-header::before {
    opacity: 1;
    background: repeating-linear-gradient(
        to bottom,
        #3182ce 0px,
        #3182ce 2px,
        transparent 2px,
        transparent 4px
    );
}

.node-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #2d3748;
    outline: none;
    border: none;
    background: transparent;
    border-radius: 4px;
    padding: 2px 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    margin-left: 16px;
    margin-right: 70px; /* отступ от кнопок справа */
}

.node-title:focus {
    background: white;
    box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.5);
    white-space: normal;
    overflow: visible;
}

/* Левая часть шапки с заголовком и счетчиком */
.node-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    margin-left: 16px;
    margin-right: 70px; /* отступ от кнопок справа */
}

.node-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-left: 16px;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-left: auto;
    justify-content: flex-end;
}

/* ==================== СЧЕТЧИК ТОКЕНОВ ==================== */

/* ==================== СЧЕТЧИК ТОКЕНОВ ==================== */

.token-counter {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: rgba(113, 128, 150, 0.1);
    border: 1px solid rgba(113, 128, 150, 0.2);
    color: #4a5568;
    transition: all 0.2s ease;
}

.token-counter.token-warning {
    background: rgba(237, 137, 54, 0.1);
    border-color: rgba(237, 137, 54, 0.3);
    color: #dd6b20;
}

.token-counter.token-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

.token-count {
    font-weight: 600;
}

.token-separator {
    opacity: 0.6;
}

.token-max {
    opacity: 0.8;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .token-counter {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

.context-toggle {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s ease;
    color: #718096;
}

.context-toggle.shared {
    color: #48bb78;
}

.context-toggle:hover {
    background: rgba(113, 128, 150, 0.1);
}

.context-toggle.shared:hover {
    background: rgba(72, 187, 120, 0.1);
}

.model-select {
    padding: 0.4rem 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8rem;
    background: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 100px;
}

.model-select:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.2);
}

.model-select:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.color-select {
    padding: 0.4rem 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8rem;
    background: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 100px;
}

.color-select:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.2);
}

.color-select:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.node-menu {
    position: relative;
}

/* Удаляем старую кнопку меню */
.node-menu-btn {
    display: none;
}

/* ==================== СООБЩЕНИЯ ==================== */

.node-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 200px;
    grid-row: 2;
    width: 100%;
    box-sizing: border-box;
}

.node-messages::-webkit-scrollbar {
    width: 8px;
}

.node-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.node-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.node-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.message {
    display: flex;
    gap: 0.75rem;
    width: 100%;
    margin-bottom: 0.5rem;
    animation: messageSlideIn 0.3s ease-out;
}

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

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

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: auto;
    width: auto;
    height: 24px;
    padding: 4px 8px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #4a5568;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
    margin-right: 0.75rem;
    margin-top: 0.25rem;
    line-height: 1;
}

.message.user .message-avatar {
    background: #48bb78;
}

.message-content {
    background: #f7fafc;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    cursor: text;
    user-select: text;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    transition: all 0.2s ease;
    position: relative;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.message.user .message-content {
    background: #3182ce;
    color: white;
}

.message-content:hover {
    background: #edf2f7;
    transform: translateY(-1px);
}

.message.user .message-content:hover {
    background: #2c5282;
}

/* Кнопка копирования текста */
.copy-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(49, 130, 206, 0.2);
    border-radius: 6px;
    color: #4a5568;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    z-index: 10;
}

.message:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(49, 130, 206, 0.1);
    border-color: #3182ce;
    color: #3182ce;
    transform: scale(1.05);
}

.copy-btn:active {
    transform: scale(0.95);
}

.copy-btn.copied {
    background: rgba(72, 187, 120, 0.1);
    border-color: #48bb78;
    color: #48bb78;
}

.copy-btn.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.copy-btn svg {
    transition: transform 0.2s ease;
}

.copy-btn:hover svg {
    transform: scale(1.1);
}

/* Кнопка редактирования сообщения */
.edit-btn {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 1px;
    height: 1px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(237, 137, 54, 0.2);
    border-radius: 6px;
    color: #4a5568;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    z-index: 10;
}

.message.user:hover .edit-btn {
    opacity: 1;
}

.edit-btn:hover {
    background: rgba(237, 137, 54, 0.1);
    border-color: #ed8936;
    color: #ed8936;
    transform: scale(1.05);
}

.edit-btn:active {
    transform: scale(0.95);
}

.edit-btn svg {
    transition: transform 0.2s ease;
}

.edit-btn:hover svg {
    transform: scale(1.1);
}

/* Стили для режима редактирования */
.message-edit-input {
    width: 100% !important;
    min-height: 80px !important;
    padding: 0.75rem !important;
    border: 2px solid #3182ce !important;
    border-radius: 5px !important;
    font-family: inherit !important;
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
    resize: vertical !important;
    background: white !important;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1) !important;
    outline: none !important;
    color: #2d3748 !important;
    box-sizing: border-box !important;
}

.message-edit-input:focus {
    border-color: #2c5282 !important;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.2) !important;
}

.edit-controls {
    display: flex !important;
    flex-direction: row !important;
    gap: 0.5rem !important;
    margin-top: 0.5rem !important;
    justify-content: flex-start !important;
}

.edit-cancel-btn {
    width: 15px;
    height: 15px;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    background: white;
    color: #dc2626;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    padding: 0;
}

.edit-cancel-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #dc2626;
    transform: scale(1.1);
}

.edit-cancel-btn:active {
    transform: scale(0.95);
}

.edit-save-btn {
    width: 15px;
    height: 15px;
    border: 1px solid #48bb78;
    border-radius: 50%;
    background: #48bb78;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    padding: 0;
}

.edit-save-btn:hover {
    background: #38a169;
    border-color: #38a169;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
}

.edit-save-btn:active {
    transform: scale(0.95);
}

.edit-save-btn::before {
    content: '✓';
}

/* Улучшенное отображение сообщения пользователя для редактирования */
.message.user .message-content {
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.message.user .message-content:hover {
    background: #2c5282;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(49, 130, 206, 0.2);
}

.message.user .message-content::before {
    content: 'Нажмите для редактирования';
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(45, 55, 72, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 100000;
}

.message.user .message-content:hover::before {
    opacity: 1;
}

.message.user .message-content::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 8px 8px;
}

.message.user .message-content:hover::after {
    opacity: 1;
}

/* Скрываем подсказку на мобильных устройствах */
@media (max-width: 768px) {
    .message.user .message-content::before {
        display: none;
    }
}

.message:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(49, 130, 206, 0.1);
    border-color: #3182ce;
    color: #3182ce;
    transform: scale(1.05);
}

.copy-btn:active {
    transform: scale(0.95);
}

.copy-btn.copied {
    background: rgba(72, 187, 120, 0.1);
    border-color: #48bb78;
    color: #48bb78;
}

.copy-btn.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.copy-btn svg {
    transition: transform 0.2s ease;
}

.copy-btn:hover svg {
    transform: scale(1.1);
}

/* Уведомление о копировании */
.copy-notification {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: #2d3748;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1001;
    max-width: 300px;
    word-wrap: break-word;
}

.copy-notification.success {
    background: #48bb78;
    border: 1px solid #38a169;
}

.copy-notification.error {
    background: #e53e3e;
    border: 1px solid #c53030;
}

.copy-notification.show {
    transform: translateX(0);
    opacity: 1;
}

/* УЛУЧШЕННАЯ ПОДСВЕТКА ИСХОДНОГО ТЕКСТА */
.message-content.highlighted {
    background: #fef5e7 !important;
    border: 2px solid #ed8936 !important;
    box-shadow: 0 0 0 4px rgba(237, 137, 54, 0.2), 0 0 20px rgba(237, 137, 54, 0.1);
    transform: translateY(-2px);
    z-index: 100;
    position: relative;
}

.message.user .message-content.highlighted {
    background: #744210 !important;
    color: #fef5e7 !important;
    border-color: #ed8936 !important;
}

.message-content.pulse {
    animation: highlightPulse 1s ease-in-out 2;
}

@keyframes highlightPulse {
    0%, 100% { 
        background: #fef5e7;
        transform: translateY(-2px);
    }
    50% { 
        background: #fed7aa;
        transform: translateY(-4px);
    }
}

/* ==================== ИНДИКАТОР ПЕЧАТИ ==================== */

.typing-indicator {
    display: none;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 1rem;
    padding: 0.5rem;
    font-size: 0.9rem;
    color: #718096;
    background: #f7fafc;
    border-radius: 5px;
    grid-row: 3;
    height: 40px;
}

.typing-indicator.show {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #718096;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

@keyframes typing {
    0%, 60%, 100% { 
        transform: translateY(0); 
        opacity: 0.4; 
    }
    30% { 
        transform: translateY(-8px); 
        opacity: 1; 
    }
}

/* ==================== ПОЛЕ ВВОДА ==================== */

.node-input {
    padding: 1rem;
    border-top: 1px solid #e2e8f0;
    background: white;
    position: relative;
    z-index: 10;
    box-sizing: border-box;
    grid-row: 4;
    /* Убираем min-height и transition, которые вызывали проблему */
}

.input-container {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    position: relative;
    z-index: 10;
}

.message-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    resize: none;
    font-size: 0.95rem;
    line-height: 1.4;
    min-height: 44px; /* Минимальная высота (примерно 3 строки) */
    max-height: 140px; /* Максимальная высота (примерно 10 строк) */
    height: 44px; /* Начальная высота */
    font-family: inherit;
    transition: all 0.2s ease;
    background: #f7fafc;
    position: relative;
    z-index: 10;
    pointer-events: auto;
    overflow-y: auto; /* Добавляем скролл если текст не помещается */
}

.message-input:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
    background: white;
}

.message-input::placeholder {
    color: #a0aec0;
}

.send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 5px;
    background: var(--node-primary-color, #3182ce);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--node-border-color, #2c5282);
    transform: translateY(-1px);
}

.send-btn:active {
    transform: translateY(0);
}

.send-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
}

/* ==================== СВЯЗИ МЕЖДУ УЗЛАМИ ==================== */

.connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-width: 18000px;
    min-height: 18000px;
    pointer-events: none;
    z-index: 0; /* Изменено с 1 на 0 - теперь линии будут под узлами */
    transform-origin: 0 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    shape-rendering: geometricPrecision;
    will-change: transform;
}

.connection-line {
    stroke: var(--connection-color, #3182ce);
    stroke-width: 2;
    fill: none;
    opacity: 0.6;
    transition: all 0.15s ease;
    stroke-linecap: round;
    stroke-linejoin: round;
    shape-rendering: geometricPrecision;
}

.connection-line:hover {
    stroke-width: 3;
    opacity: 1;
}

.connection-line.highlighted {
    stroke: #ed8936;
    stroke-width: 3;
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(237, 137, 54, 0.3));
    animation: connectionPulse 2s ease-in-out infinite;
}

@keyframes connectionPulse {
    0%, 100% { 
        stroke-width: 3;
        opacity: 1;
    }
    50% { 
        stroke-width: 4;
        opacity: 0.8;
    }
}

.connection-line.shared {
    stroke: var(--connection-color, #48bb78);
    stroke-dasharray: none;
}

.connection-line.isolated {
    stroke: var(--connection-color, #718096);
    stroke-dasharray: 8,4;
    stroke-width: 2;
}

.connection-line.new {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawConnection 0.8s ease-out forwards;
}

@keyframes drawConnection {
    0% {
        stroke-dashoffset: 1000;
        opacity: 0;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 0.6;
    }
}

/* ==================== TOOLTIP ДЛЯ ВЫДЕЛЕНИЯ ==================== */

.selection-tooltip {
    position: fixed;
    background: #2d3748;
    color: white;
    padding: 1rem;
    border-radius: 5px;
    font-size: 0.9rem;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    max-width: 300px;
    display: none;
    pointer-events: none;
    animation: tooltipSlideIn 0.2s ease-out;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes tooltipSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.selection-tooltip.show {
    display: block;
    pointer-events: auto;
}

.tooltip-preview {
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: #cbd5e0;
    font-style: italic;
    border-left: 3px solid #3182ce;
    padding-left: 0.5rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.tooltip-actions {
    display: flex;
    gap: 0.5rem;
}

.tooltip-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    flex: 1;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.tooltip-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.tooltip-btn:hover::before {
    left: 100%;
}

.fork-btn {
    background: #ed8936;
    color: white;
    border: 1px solid #dd6b20;
}

.fork-btn:hover {
    background: #dd6b20;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(237, 137, 54, 0.3);
}

.fork-btn:active {
    transform: translateY(0);
    background: #c05621;
}

/* ==================== МОДАЛЬНЫЕ ОКНА ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    animation: modalSlideIn 0.3s ease-out;
}

.modal-large {
    max-width: 800px;
    width: 95%;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #718096;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #f7fafc;
    color: #2d3748;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: white;
    color: #2d3748;
}

.form-input:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.form-input::placeholder {
    color: #a0aec0;
}

.form-help {
    font-size: 0.8rem;
    color: #718096;
    margin-top: 0.5rem;
    line-height: 1.4;
}

.form-help a {
    color: #3182ce;
    text-decoration: none;
}

.form-help a:hover {
    text-decoration: underline;
}

/* ==================== НАСТРОЙКИ МОДЕЛИ ==================== */

.config-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.config-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: #3182ce;
    border-radius: 2px;
}

.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: white;
    color: #2d3748;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
}

.form-textarea:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.form-range {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.form-range::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: #3182ce;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(49, 130, 206, 0.3);
    transition: all 0.2s ease;
}

.form-range::-webkit-slider-thumb:hover {
    background: #2c5282;
    transform: scale(1.1);
}

.form-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #3182ce;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(49, 130, 206, 0.3);
}

/* ==================== ЗАГРУЗКА ФАЙЛОВ ==================== */

.file-upload-area {
    border: 2px dashed #cbd5e0;
    border-radius: 5px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f7fafc;
}

.file-upload-area:hover {
    border-color: #3182ce;
    background: #ebf8ff;
}

.file-upload-area.dragover {
    border-color: #3182ce;
    background: #ebf8ff;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.upload-text {
    color: #4a5568;
    line-height: 1.6;
}

.upload-text strong {
    color: #2d3748;
    font-weight: 600;
}

.upload-text small {
    color: #718096;
    font-size: 0.85rem;
}

.uploaded-files {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.file-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 0.8rem;
    color: #718096;
}

.file-remove {
    background: #fed7d7;
    color: #e53e3e;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.file-remove:hover {
    background: #feb2b2;
    color: #c53030;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

/* ==================== СИСТЕМА МАСШТАБИРОВАНИЯ ==================== */

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: #718096;
    border-left: 1px solid #e2e8f0;
    padding-left: 1rem;
    margin-left: 1rem;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: white;
    color: #4a5568;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.zoom-btn:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.zoom-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.zoom-btn:disabled {
    background: #f7fafc;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.zoom-level {
    font-weight: 600;
    color: #3182ce;
    min-width: 48px;
    text-align: center;
    font-size: 0.85rem;
    background: rgba(49, 130, 206, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid rgba(49, 130, 206, 0.2);
}

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

.zoom-level.updating {
    animation: zoomPulse 0.3s ease-in-out;
}

.tree-canvas::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.tree-canvas::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 6px;
}

.tree-canvas::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 6px;
    border: 2px solid #f1f5f9;
}

.tree-canvas::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.tree-canvas::-webkit-scrollbar-corner {
    background: #f1f5f9;
}

/* ==================== ФОРМАТИРОВАНИЕ ОТВЕТОВ ИИ ==================== */

.message-content p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.message-content p:first-child {
    margin-top: 0;
}

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

.message-content strong {
    font-weight: 600;
    color: inherit;
}

.message-content em {
    font-style: italic;
    color: inherit;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', Consolas, Monaco, monospace;
    font-size: 0.9em;
    color: inherit;
}

.message.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

.message-content pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    border-radius: 6px;
    margin: 0.5rem 0;
    overflow-x: auto;
    border-left: 3px solid rgba(49, 130, 206, 0.5);
}

.message.user .message-content pre {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.message-content pre code {
    background: none;
    padding: 0;
    font-family: 'Courier New', Consolas, Monaco, monospace;
    font-size: 0.85em;
    line-height: 1.4;
    color: inherit;
}

.message-content br + strong {
    display: inline-block;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
    font-size: 1.05em;
}

.message-content {
    line-height: 1.6;
    word-spacing: 0.05em;
}

.message-content p,
.message-content pre,
.message-content strong {
    animation: fadeInText 0.3s ease-out;
}

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

/* ==================== ДОПОЛНИТЕЛЬНЫЕ СТИЛИ ==================== */

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #3182ce;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.btn:focus,
.context-toggle:focus,
.model-select:focus,
.color-select:focus,
.node-delete-btn:focus,
.node-config-btn:focus,
.message-input:focus,
.send-btn:focus,
.form-input:focus,
.form-textarea:focus,
.tooltip-btn:focus {
    outline: 2px solid #3182ce;
    outline-offset: 2px;
}

::selection {
    background: rgba(49, 130, 206, 0.2);
}

::-moz-selection {
    background: rgba(49, 130, 206, 0.2);
}

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: #718096;
}

.text-error {
    color: #e53e3e;
}

.text-success {
    color: #38a169;
}

.no-select {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.save-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #48bb78;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.save-indicator.show {
    opacity: 1;
}

/* ==================== АДАПТИВНОСТЬ ==================== */

@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .toolbar-left {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .toolbar-right {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .canvas-sidebar {
        width: 240px;
        min-width: 240px;
    }

    .sidebar-header {
        padding: 0.75rem 1rem;
    }

    .canvas-item {
        padding: 0.5rem 0.75rem;
        margin: 0.125rem 0.25rem;
    }

    .canvas-item-title {
        font-size: 0.85rem;
    }

    .canvas-item-meta {
        font-size: 0.7rem;
    }

    .dialog-node {
        width: 320px;
        min-height: 250px;
        max-height: 1300px;
    }

    .modal {
        width: 95%;
        padding: 1.5rem;
    }

    .zoom-controls {
        gap: 0.5rem;
        padding-left: 0.75rem;
        margin-left: 0.75rem;
    }
    
    .zoom-btn {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    
    .zoom-level {
        font-size: 0.8rem;
        min-width: 42px;
        padding: 0.2rem 0.4rem;
    }

    /* Кнопка копирования на мобильных */
    .copy-btn {
        opacity: 1; /* Всегда видна на мобильных */
        width: 32px;
        height: 32px;
    }

    .copy-notification {
        bottom: 60px;
        right: 10px;
        left: 10px;
        max-width: none;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .main-content {
        flex-direction: column;
    }

    .canvas-sidebar {
        width: 100%;
        min-width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        resize: vertical;
    }

    .sidebar-header h3 {
        font-size: 0.9rem;
    }

    .canvas-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0.5rem;
        gap: 0.5rem;
        display: flex;
    }

    .canvas-item {
        min-width: 180px;
        margin: 0;
        flex-shrink: 0;
    }

    .toolbar {
        padding: 0.75rem;
    }

    .dialog-node {
        width: 290px;
        min-height: 220px;
        max-height: 1300px;
    }

    .modal {
        padding: 1rem;
    }

    .zoom-controls {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
        margin-top: 0.5rem;
        border-top: 1px solid #e2e8f0;
        padding-top: 0.5rem;
    }
    
    .zoom-btn {
        width: 26px;
        height: 26px;
        font-size: 0.65rem;
    }
    
    .zoom-level {
        font-size: 0.75rem;
        min-width: 38px;
    }

    /* Улучшенная кнопка копирования для маленьких экранов */
    .copy-btn {
        width: 36px;
        height: 36px;
        bottom: 6px;
        right: 6px;
    }

    .copy-notification {
        bottom: 40px;
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }
}

/* ==================== ТЕМНАЯ ТЕМА ==================== */

@media (prefers-color-scheme: dark) {
    body {
        background: #1a202c;
        color: #e2e8f0;
    }

    .app-container {
        background: #2d3748;
    }

    .toolbar {
        background: #2d3748;
        border-color: #4a5568;
    }

    .canvas-sidebar {
        background: #2d3748;
        border-color: #4a5568;
    }

    .sidebar-header {
        background: #4a5568;
        border-color: #718096;
    }

    .sidebar-header h3 {
        color: #e2e8f0;
    }

    .canvas-item {
        color: #e2e8f0;
        border-color: #4a5568;
    }

    .canvas-item:hover {
        background: #4a5568;
        border-color: #718096;
    }

    .canvas-item.active {
        background: #2c5282;
        border-color: #3182ce;
        color: #e2e8f0;
    }

    .canvas-item-title {
        color: #e2e8f0;
    }

    .canvas-item.active .canvas-item-title {
        color: #e2e8f0;
    }

    .canvas-item-meta {
        color: #a0aec0;
    }

    .canvas-item-time {
        color: #718096;
    }

    .empty-canvas-list {
        color: #a0aec0;
    }

    .tree-canvas {
        background: #1a202c;
    }

    .dialog-node {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .node-header {
        background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    }

    .message-content {
        background: #4a5568;
        color: #e2e8f0;
    }

    .message.user .message-content {
        background: #3182ce;
    }

    .message-input {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }

    .btn {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }

    .modal {
        background: #2d3748;
        color: #e2e8f0;
    }

    .form-input,
    .form-textarea {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }

    /* Кнопка копирования в темной теме */
    .copy-btn {
        background: rgba(45, 55, 72, 0.9);
        border-color: rgba(113, 128, 150, 0.3);
        color: #cbd5e0;
    }

    .copy-btn:hover {
        background: rgba(49, 130, 206, 0.2);
        border-color: #3182ce;
        color: #3182ce;
    }

    .copy-notification {
        background: #4a5568;
        color: #e2e8f0;
        border: 1px solid #718096;
    }

    .copy-notification.success {
        background: #38a169;
        border-color: #48bb78;
    }

    .copy-notification.error {
        background: #c53030;
        border-color: #e53e3e;
    }
}

@media (prefers-contrast: high) {
    .dialog-node {
        border-width: 3px;
    }

    .connection-line {
        stroke-width: 3;
    }

    .btn {
        border-width: 2px;
    }

    .message-content {
        border: 1px solid #e2e8f0;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .dialog-node {
        transform: none !important;
    }

    .message {
        transform: none !important;
    }

    .tree-canvas {
        scroll-behavior: auto;
    }
}

@media print {
    .toolbar,
    .canvas-sidebar,
    .selection-tooltip,
    .modal-overlay,
    .save-indicator {
        display: none !important;
    }

    .main-content {
        flex-direction: column;
    }

    .tree-canvas {
        overflow: visible !important;
        background: none !important;
    }

    .dialog-node {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }

    .connection-line {
        stroke: #000 !important;
    }
}
/* ==================== СТИЛИ ДЛЯ ИНФОРМАЦИИ О ХРАНИЛИЩЕ ==================== */

.storage-info {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.storage-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.storage-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.storage-label {
    font-weight: 500;
    color: #4a5568;
}

.storage-value {
    font-weight: 600;
    color: #2d3748;
    font-family: 'Courier New', monospace;
}

/* Цветовая индикация для размера хранилища */
.storage-value[style*="color: #e53e3e"] {
    background: rgba(239, 68, 68, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.storage-value[style*="color: #ed8936"] {
    background: rgba(237, 137, 54, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(237, 137, 54, 0.2);
}

.storage-value[style*="color: #48bb78"] {
    background: rgba(72, 187, 120, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(72, 187, 120, 0.2);
}

/* Расширенные стили для конфигурационных секций */
.config-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.config-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Иконки для разных секций */
.section-title:has-text("🔑")::before {
    content: '';
    width: 4px;
    height: 20px;
    background: #3182ce;
    border-radius: 2px;
}

.section-title:has-text("💾")::before {
    content: '';
    width: 4px;
    height: 20px;
    background: #48bb78;
    border-radius: 2px;
}

.section-title:has-text("💽")::before {
    content: '';
    width: 4px;
    height: 20px;
    background: #ed8936;
    border-radius: 2px;
}

/* Улучшенные кнопки в настройках */
.btn-danger {
    background: #fed7d7;
    color: #e53e3e;
    border: 1px solid #feb2b2;
}

.btn-danger:hover {
    background: #feb2b2;
    border-color: #fc8181;
    color: #c53030;
}

.btn-warning {
    background: #fef5e7;
    color: #ed8936;
    border: 1px solid #fbd38d;
}

.btn-warning:hover {
    background: #fbd38d;
    border-color: #f6ad55;
    color: #dd6b20;
}

/* Адаптивность для модальных окон с большим количеством контента */
@media (max-width: 768px) {
    .storage-info {
        padding: 0.75rem;
    }
    
    .storage-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .storage-value {
        font-size: 0.9rem;
    }
    
    .section-title {
        font-size: 1rem;
    }
    
    .config-section {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }
}

/* Темная тема для новых элементов */
@media (prefers-color-scheme: dark) {
    .storage-info {
        background: #4a5568;
        border-color: #718096;
    }
    
    .storage-item {
        border-color: #718096;
    }
    
    .storage-label {
        color: #e2e8f0;
    }
    
    .storage-value {
        color: #f7fafc;
    }
    
    .section-title {
        color: #f7fafc;
    }
    
    .config-section {
        border-color: #4a5568;
    }
    
    .btn-danger {
        background: #742a2a;
        color: #feb2b2;
        border-color: #9c4221;
    }
    
    .btn-danger:hover {
        background: #9c4221;
        border-color: #c53030;
        color: #fed7d7;
    }
    
    .btn-warning {
        background: #744210;
        color: #fbd38d;
        border-color: #9c4221;
    }
    
    .btn-warning:hover {
        background: #9c4221;
        border-color: #dd6b20;
        color: #fef5e7;
    }
}
/* ==================== CSS ДЛЯ ПОЛНОЭКРАННОГО РЕЖИМА ==================== */

/* Стиль для узла в полноэкранном режиме */
.node-fullscreen-active {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    border: 2px solid var(--node-primary-color, #3182ce) !important;
    border-radius: 12px !important;
    background: white !important;
    position: absolute !important;
    z-index: 1001 !important;
}

/* Плавные переходы для входа/выхода из полноэкранного режима */
.dialog-node {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Убираем переходы во время изменения размера */
.dialog-node.resizing {
    transition: none !important;
}

/* Дополнительные стили для улучшения внешнего вида в полноэкранном режиме */
.node-fullscreen-active .node-header {
    background: linear-gradient(135deg, var(--node-bg-color, #ebf8ff), white);
    border-bottom: 1px solid var(--node-border-color, #2c5282);
    border-radius: 10px 10px 0 0;
}

.node-fullscreen-active .node-messages {
    border-radius: 0;
}

.node-fullscreen-active .node-input {
    border-radius: 0 0 10px 10px;
    border-top: 1px solid #e2e8f0;
}


/* Кнопка полноэкранного режима */
.node-fullscreen-btn {
    position: absolute;
    top: 8px;
    right: 64px; /* Размещаем левее кнопки настроек */
    width: 24px;
    height: 24px;
    background: rgba(49, 130, 206, 0.1);
    border: none;
    border-radius: 50%;
    color: #3182ce;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s ease;
    opacity: 0;
    z-index: 10;
}

.dialog-node:hover .node-fullscreen-btn {
    opacity: 1;
}

.node-fullscreen-btn:hover {
    background: rgba(49, 130, 206, 0.2);
    color: #2c5282;
    transform: scale(1.1);
}

.node-fullscreen-btn:active {
    transform: scale(0.95);
}

/* Стили для узла в полноэкранном режиме */
.node-fullscreen {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    border: 2px solid var(--node-primary-color, #3182ce) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border-radius: 6px !important;
}

.node-fullscreen .node-header {
    background: linear-gradient(135deg, var(--node-bg-color, #f7fafc) 0%, #ffffff 100%) !important;
    border-bottom: 2px solid var(--node-border-color, #e2e8f0) !important;
    padding: 1rem 1.5rem !important;
}

.node-fullscreen .node-title {
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    margin-right: 100px !important; /* Больше отступ от кнопок в полноэкранном режиме */
}

.node-fullscreen .node-messages {
    padding: 1.5rem !important;
    gap: 1.25rem !important;
}

.node-fullscreen .message {
    margin-bottom: 0.75rem !important;
}

.node-fullscreen .message-content {
    font-size: 1rem !important;
    line-height: 1.6 !important;
    padding: 1rem 1.25rem !important;
    border-radius: 16px !important;
}

.node-fullscreen .message-avatar {
    width: 36px !important;
    height: 36px !important;
    font-size: 0.8rem !important;
}

.node-fullscreen .node-input {
    padding: 1.25rem 1.5rem !important;
    border-top: 2px solid #e2e8f0 !important;
}

.node-fullscreen .message-input {
    padding: 1rem 1.25rem !important;
    font-size: 1rem !important;
    min-height: 50px !important;
    max-height: 120px !important;
    border-radius: 12px !important;
    border: 2px solid #e2e8f0 !important;
}

.node-fullscreen .message-input:focus {
    border-color: var(--node-primary-color, #3182ce) !important;
    box-shadow: 0 0 0 4px rgba(49, 130, 206, 0.1) !important;
}

.node-fullscreen .send-btn {
    width: 50px !important;
    height: 50px !important;
    border-radius: 12px !important;
}

.node-fullscreen .typing-indicator {
    margin: 0.75rem 1.5rem !important;
    padding: 0.75rem !important;
    font-size: 1rem !important;
    border-radius: 12px !important;
    height: 50px !important;
}

/* Кнопка полноэкранного режима в полноэкранном состоянии */
.node-fullscreen .node-fullscreen-btn {
    opacity: 1 !important;
    background: rgba(49, 130, 206, 0.15) !important;
    color: #2c5282 !important;
    font-size: 16px !important;
    width: 28px !important;
    height: 28px !important;
    right: 68px !important; /* Корректируем позицию */
}

.node-fullscreen .node-fullscreen-btn:hover {
    background: rgba(49, 130, 206, 0.25) !important;
    transform: scale(1.05) !important;
}

/* Корректировка позиций других кнопок в полноэкранном режиме */
.node-fullscreen .node-config-btn {
    right: 100px !important; /* Сдвигаем левее */
    width: 28px !important;
    height: 28px !important;
    font-size: 14px !important;
}

.node-fullscreen .node-delete-btn {
    right: 8px !important;
    width: 28px !important;
    height: 28px !important;
    font-size: 16px !important;
}

/* Плавные переходы для входа/выхода из полноэкранного режима */
.dialog-node {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Убираем transitions во время перетаскивания */
.dialog-node.dragging {
    transition: none !important;
}

/* Убираем transitions во время изменения размера */
.dialog-node.resizing {
    transition: none !important;
}

/* Особые стили для полноэкранного режима на мобильных устройствах */
@media (max-width: 768px) {
    .node-fullscreen {
        border-radius: 5px !important;
    }
    
    .node-fullscreen .node-header {
        padding: 0.75rem 1rem !important;
    }
    
    .node-fullscreen .node-title {
        font-size: 1rem !important;
        margin-right: 80px !important;
    }
    
    .node-fullscreen .node-messages {
        padding: 1rem !important;
        gap: 1rem !important;
    }
    
    .node-fullscreen .message-content {
        font-size: 0.95rem !important;
        padding: 0.75rem 1rem !important;
        border-radius: 12px !important;
    }
    
    .node-fullscreen .node-input {
        padding: 1rem !important;
    }
    
    .node-fullscreen .message-input {
        font-size: 0.95rem !important;
        padding: 0.75rem 1rem !important;
        min-height: 44px !important;
        max-height: 100px !important;
    }
    
    .node-fullscreen .send-btn {
        width: 44px !important;
        height: 44px !important;
    }
    
    .node-fullscreen .node-fullscreen-btn {
        width: 24px !important;
        height: 24px !important;
        font-size: 14px !important;
        right: 60px !important;
    }
    
    .node-fullscreen .node-config-btn {
        width: 24px !important;
        height: 24px !important;
        right: 88px !important;
    }
    
    .node-fullscreen .node-delete-btn {
        width: 24px !important;
        height: 24px !important;
    }
}

/* Анимация для кнопки полноэкранного режима */
@keyframes fullscreenPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.node-fullscreen-btn:hover {
    animation: fullscreenPulse 0.6s ease-in-out;
}

/* Темная тема для полноэкранного режима */
@media (prefers-color-scheme: dark) {
    .node-fullscreen {
        background: #2d3748 !important;
        border-color: #4a5568 !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5) !important;
    }
    
    .node-fullscreen .node-header {
        background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%) !important;
        border-color: #718096 !important;
    }
    
    .node-fullscreen .node-title {
        color: #f7fafc !important;
    }
    
    .node-fullscreen .message-content {
        background: #4a5568 !important;
        color: #f7fafc !important;
    }
    
    .node-fullscreen .message.user .message-content {
        background: #3182ce !important;
    }
    
    .node-fullscreen .message-input {
        background: #4a5568 !important;
        border-color: #718096 !important;
        color: #f7fafc !important;
    }
    
    .node-fullscreen .message-input:focus {
        border-color: #3182ce !important;
        box-shadow: 0 0 0 4px rgba(49, 130, 206, 0.2) !important;
    }
    
    .node-fullscreen .typing-indicator {
        background: #4a5568 !important;
        color: #cbd5e0 !important;
    }
    
    .node-fullscreen .node-input {
        background: #2d3748 !important;
        border-color: #4a5568 !important;
    }
}
/* Исправленный CSS-подход для полноэкранного режима */

/* Полноэкранный режим через CSS */
.node-fullscreen-css {
    position: fixed !important;
    top: 20px !important; /* высота toolbar + небольшой отступ */
    left: 50px !important; /* ширина sidebar + минимальный отступ */
    right: 50px !important; /* небольшой отступ справа */
    bottom: 20px !important; /* небольшой отступ снизу */
    width: auto !important;
    
    z-index: 1500 !important;
    transform: none !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    border: 2px solid var(--node-primary-color, #3182ce) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Убираем класс node-fullscreen если он был добавлен */
.node-fullscreen-css.node-fullscreen {
    /* Переопределяем стили из node-fullscreen */
    border-radius: 12px !important;
}

/* Адаптивность для CSS-подхода */
@media (max-width: 768px) {
    .node-fullscreen-css {
        left: 250px !important; /* для меньших экранов */
        top: 80px !important;
    }
}

@media (max-width: 480px) {
    .node-fullscreen-css {
        top: 280px !important; /* учитываем горизонтальную панель на мобильных */
        left: 5px !important;
        right: 5px !important;
        bottom: 5px !important;
    }
}

/* ==================== СТИЛИ ДЛЯ УЛУЧШЕННОЙ ОБРАБОТКИ ФАЙЛОВ ==================== */

/* Метаинформация файла */
.file-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.file-size {
    font-size: 0.8rem;
    color: #718096;
    background: #f7fafc;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

/* Индикатор количества токенов */
.file-tokens {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid;
    white-space: nowrap;
}

.token-count-normal {
    color: #48bb78;
    background: rgba(72, 187, 120, 0.1);
    border-color: rgba(72, 187, 120, 0.3);
}

.token-count-medium {
    color: #ed8936;
    background: rgba(237, 137, 54, 0.1);
    border-color: rgba(237, 137, 54, 0.3);
}

.token-count-high {
    color: #e53e3e;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

/* Превью содержимого файла */
.file-preview {
    font-size: 0.75rem;
    color: #a0aec0;
    font-style: italic;
    margin-top: 0.25rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
    cursor: help;
}

/* Улучшенный элемент файла */
.file-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1rem;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.file-item:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.file-info {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.file-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin-bottom: 0.25rem;
}

.file-remove {
    background: #fed7d7;
    color: #e53e3e;
    border: 1px solid #feb2b2;
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.file-remove:hover {
    background: #feb2b2;
    color: #c53030;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.file-remove:active {
    transform: translateY(0);
}

/* Предупреждение о большом размере файла */
.file-warning {
    background: #fef5e7;
    border: 1px solid #f6ad55;
    border-radius: 6px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #744210;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-warning::before {
    content: '⚠️';
    font-size: 1rem;
}

/* Информация о лимитах файлов */
.file-limits-info {
    background: #ebf8ff;
    border: 1px solid #bee3f8;
    border-radius: 6px;
    padding: 0.75rem;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #2b6cb0;
    line-height: 1.4;
}

.file-limits-info h4 {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c5282;
}

.file-limits-info ul {
    margin: 0;
    padding-left: 1rem;
}

.file-limits-info li {
    margin-bottom: 0.25rem;
}

/* Статистика обработки файлов */
.file-processing-stats {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    border-radius: 6px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #22543d;
}

.processing-stat {
    display: inline-block;
    margin-right: 1rem;
    margin-bottom: 0.25rem;
}

.processing-stat strong {
    color: #1a365d;
}

/* Прогресс-бар для обработки файлов */
.file-processing-progress {
    background: #edf2f7;
    border-radius: 4px;
    height: 4px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.file-processing-progress-bar {
    background: linear-gradient(90deg, #48bb78, #38a169);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

/* Улучшенная область загрузки файлов */
.file-upload-area {
    border: 2px dashed #cbd5e0;
    border-radius: 5px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f7fafc;
    position: relative;
}

.file-upload-area:hover {
    border-color: #3182ce;
    background: #ebf8ff;
    transform: translateY(-1px);
}

.file-upload-area.dragover {
    border-color: #3182ce;
    background: #ebf8ff;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(49, 130, 206, 0.2);
}

.file-upload-area.processing {
    pointer-events: none;
    opacity: 0.7;
}

.file-upload-area.processing::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #3182ce;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .file-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .file-info {
        align-items: flex-start;
    }
    
    .file-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .file-preview {
        max-width: none;
        white-space: normal;
        overflow: visible;
        text-overflow: initial;
    }
    
    .file-remove {
        align-self: flex-end;
        margin-top: 0.25rem;
    }
    
    .file-upload-area {
        padding: 1.5rem;
    }
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    .file-item {
        background: #4a5568;
        border-color: #718096;
    }
    
    .file-item:hover {
        background: #2d3748;
        border-color: #a0aec0;
    }
    
    .file-name {
        color: #f7fafc;
    }
    
    .file-size {
        background: #2d3748;
        border-color: #4a5568;
        color: #cbd5e0;
    }
    
    .file-preview {
        color: #718096;
    }
    
    .file-upload-area {
        background: #4a5568;
        border-color: #718096;
    }
    
    .file-upload-area:hover,
    .file-upload-area.dragover {
        background: #2c5282;
        border-color: #3182ce;
    }
    
    .file-warning {
        background: #744210;
        border-color: #b7791f;
        color: #fef5e7;
    }
    
    .file-limits-info {
        background: #2c5282;
        border-color: #3182ce;
        color: #bee3f8;
    }
    
    .file-limits-info h4 {
        color: #90cdf4;
    }
    
    .file-processing-stats {
        background: #22543d;
        border-color: #38a169;
        color: #c6f6d5;
    }
    
    .processing-stat strong {
        color: #f0fff4;
    }
}

/* ==================== УЛУЧШЕННЫЕ СТИЛИ ДЛЯ ТАБЛИЦ С АДАПТИВНОЙ ШИРИНОЙ ==================== */

.ai-table-container {
    margin: 1rem 0;
    overflow-x: auto;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: white;
    border: 1px solid #e2e8f0;
    /* Убираем фиксированную ширину для адаптивности */
    width: 100%;
    max-width: 100%;
}

.ai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    line-height: 1.4;
    background: white;
    margin: 0;
    /* Автоматическое распределение ширины колонок */
    table-layout: auto;
}

.ai-table thead {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-bottom: 2px solid #e2e8f0;
}

.ai-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #2d3748;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    background: inherit;
    /* УБИРАЕМ white-space: nowrap для переноса текста */
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    /* Убираем фиксированную ширину */
    min-width: 80px; /* Минимальная ширина для читаемости */
    /* Адаптивная ширина */
    width: auto;
}

.ai-table th:last-child {
    border-right: none;
}

.ai-table td {
    padding: 0.75rem 1rem;
    border-right: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
    color: #4a5568;
    vertical-align: top;
    /* ВКЛЮЧАЕМ перенос текста */
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    /* УБИРАЕМ max-width для адаптивности */
    min-width: 80px; /* Минимальная ширина для читаемости */
    width: auto;
    /* Умное распределение пространства */
    max-width: none;
}

.ai-table td:last-child {
    border-right: none;
}

/* Автоматическое выравнивание для разных типов данных */
.ai-table td {
    text-align: left;
}

/* Выравнивание по центру для коротких данных */
.ai-table td:only-child {
    text-align: center;
}

/* Выравнивание вправо для числовых данных (определяется по содержимому) */
.ai-table td:matches(^\s*[\d.,]+\s*$) {
    text-align: right;
}

.ai-table tbody tr {
    transition: background-color 0.2s ease;
}

.ai-table tbody tr:hover {
    background: #f7fafc;
}

.ai-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.ai-table tbody tr:nth-child(even):hover {
    background: #f1f5f9;
}

/* Специальные стили для колонок с разным содержимым */
.ai-table th:first-child,
.ai-table td:first-child {
    /* Первая колонка часто содержит названия - делаем её немного шире */
    min-width: 120px;
}

.ai-table th:last-child,
.ai-table td:last-child {
    /* Последняя колонка часто содержит описания - позволяем ей расширяться */
    width: auto;
}

/* Адаптивность таблиц */
@media (max-width: 768px) {
    .ai-table-container {
        margin: 0.75rem 0;
        border-radius: 6px;
        /* На мобильных разрешаем горизонтальную прокрутку */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .ai-table {
        font-size: 0.85rem;
        /* На мобильных используем минимальную ширину для компактности */
        min-width: 500px;
    }
    
    .ai-table th,
    .ai-table td {
        padding: 0.5rem 0.75rem;
        /* Уменьшаем минимальную ширину на мобильных */
        min-width: 60px;
        font-size: 0.85rem;
        line-height: 1.3;
    }
    
    .ai-table th {
        font-size: 0.8rem;
        font-weight: 700;
        /* Обеспечиваем перенос на мобильных */
        white-space: normal;
        word-break: break-word;
    }
    
    .ai-table th:first-child,
    .ai-table td:first-child {
        min-width: 80px;
    }
}

@media (max-width: 480px) {
    .ai-table-container {
        margin: 0.5rem -0.5rem; /* Расширяем на всю ширину сообщения */
        border-radius: 4px;
    }
    
    .ai-table {
        font-size: 0.8rem;
        min-width: 400px; /* Минимальная ширина для очень маленьких экранов */
    }
    
    .ai-table th,
    .ai-table td {
        padding: 0.4rem 0.5rem;
        min-width: 50px;
        font-size: 0.8rem;
        line-height: 1.2;
    }
    
    .ai-table th:first-child,
    .ai-table td:first-child {
        min-width: 70px;
    }
}

/* Улучшенная обработка длинного текста */
.ai-table th,
.ai-table td {
    /* Умный перенос слов */
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    
    /* Разрешаем разрыв в любом месте для очень длинных слов */
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Специальная обработка для URL и длинных строк без пробелов */
.ai-table td {
    word-break: break-all; /* Для URL и длинных строк */
}

.ai-table th {
    word-break: break-word; /* Для заголовков более консервативный подход */
}

/* Таблицы в сообщениях пользователя (светлые на темном фоне) */
.message.user .ai-table-container {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.3);
}

.message.user .ai-table {
    background: rgba(255, 255, 255, 0.95);
}

.message.user .ai-table thead {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.8) 100%);
}

.message.user .ai-table th {
    color: #2d3748;
    border-color: rgba(255, 255, 255, 0.4);
}

.message.user .ai-table td {
    color: #2d3748;
    border-color: rgba(255, 255, 255, 0.3);
}

.message.user .ai-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.8);
}

.message.user .ai-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.85);
}

/* Темная тема для таблиц */
@media (prefers-color-scheme: dark) {
    .ai-table-container {
        background: #2d3748;
        border-color: #4a5568;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .ai-table {
        background: #2d3748;
    }
    
    .ai-table thead {
        background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
        border-color: #718096;
    }
    
    .ai-table th {
        color: #f7fafc;
        border-color: #4a5568;
    }
    
    .ai-table td {
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .ai-table tbody tr:hover {
        background: #4a5568;
    }
    
    .ai-table tbody tr:nth-child(even) {
        background: #374151;
    }
    
    .ai-table tbody tr:nth-child(even):hover {
        background: #4a5568;
    }
    
    /* Таблицы в сообщениях пользователя в темной теме */
    .message.user .ai-table-container {
        background: rgba(45, 55, 72, 0.95);
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    .message.user .ai-table {
        background: rgba(45, 55, 72, 0.95);
    }
    
    .message.user .ai-table thead {
        background: linear-gradient(135deg, rgba(74, 85, 104, 0.9) 0%, rgba(45, 55, 72, 0.8) 100%);
    }
    
    .message.user .ai-table th {
        color: #f7fafc;
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    .message.user .ai-table td {
        color: #e2e8f0;
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* Анимация появления таблиц */
.ai-table-container {
    animation: tableSlideIn 0.4s ease-out;
}

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

/* Улучшенный скроллбар для таблиц */
.ai-table-container::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.ai-table-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.ai-table-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.ai-table-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Индикатор прокрутки для мобильных */
@media (max-width: 768px) {
    .ai-table-container::after {
        content: "← Прокрутите для просмотра →";
        display: block;
        text-align: center;
        font-size: 0.7rem;
        color: #a0aec0;
        padding: 0.25rem;
        background: #f7fafc;
        border-top: 1px solid #e2e8f0;
        font-style: italic;
    }
    
    .ai-table-container:not(:hover)::after {
        opacity: 0.6;
    }
}

/* Скрываем индикатор прокрутки в темной теме */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .ai-table-container::after {
        background: #4a5568;
        border-color: #718096;
        color: #cbd5e0;
    }
}

.text-highlight {
  background-color: rgba(255, 234, 0, 0.7); /* Яркий желтый фон */
  box-shadow: 0 0 5px rgba(255, 234, 0, 0.5);
  border-radius: 3px;
  padding: 1px 3px;
  transition: all 0.3s ease;
}

.node-height-expand-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.node-height-expand-btn:hover {
    background: rgba(255, 255, 255, 1);
    color: #333;
    transform: scale(1.05);
}

.node-height-expand-btn:active {
    transform: scale(0.95);
}

.node-height-expand-btn.active {
    background: #3182ce;
    color: white;
    border-color: #2c5282;
}

/* Стили для узла с увеличенной высотой */
.node-height-expanded {
    border: 2px solid #3182ce !important;
    box-shadow: 0 4px 20px rgba(49, 130, 206, 0.3) !important;
}

/* Фокус для доступности */
.node-height-expand-btn:focus {
    outline: 2px solid #3182ce;
    outline-offset: 2px;
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    .node-height-expand-btn {
        background: rgba(74, 85, 104, 0.9);
        border-color: rgba(113, 128, 150, 0.3);
        color: #cbd5e0;
    }
    
    .node-height-expand-btn:hover {
        background: rgba(74, 85, 104, 1);
        color: #f7fafc;
    }
    
    .node-height-expanded {
        border-color: #4a5568 !important;
        box-shadow: 0 4px 20px rgba(74, 85, 104, 0.3) !important;
    }
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .node-height-expand-btn {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

/* Стили для заголовка tooltip с кнопкой закрытия */
.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}



.tooltip-close-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

.tooltip-preview {
    flex: 1;
    margin-bottom: 0;
}

/* ==================== СТИЛИ ДЛЯ ПРИКРЕПЛЕНИЯ ФАЙЛОВ ==================== */

.input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}

.attach-btn-inside {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.attach-btn-inside:hover {
    background: #f1f5f9;
    color: #3182ce;
    transform: translateY(-50%) scale(1.1);
}

.message-input-with-attach {
    flex: 1;
    min-height: 44px;
    max-height: 140px;
    padding: 12px 16px 12px 48px; /* Отступ слева для булавки */
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    background: white;
}

.message-input-with-attach:focus {
    border-color: #3182ce;
    box-shadow: 0 0 0 1px #3182ce;
}

.attached-files-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 0;
}

.file-icon-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-icon-circle:hover {
    background: #ebf8ff;
    border-color: #3182ce;
    transform: scale(1.05);
}

.remove-file-icon {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e53e3e;
    color: white;
    border: none;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.remove-file-icon:hover {
    background: #c53030;
    transform: scale(1.1);
}

/* Стили для системных сообщений с файлами */

.message.system .message-avatar {
    background: #64748b;
    color: white;
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    .attach-btn-inside {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .message-input-with-attach {
        padding-left: 40px;
    }
    
    .file-icon-circle {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* Анимация появления файлов */
.attached-files-icons {
    animation: slideDown 0.2s ease;
}

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

/* ==================== СТИЛИ ДЛЯ СТАТУСА API ==================== */

/* Индикатор статуса API в интерфейсе */
.api-status {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-block;
    margin: 5px 0;
    transition: all 0.3s ease;
}

.api-status-user {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
}

.api-status-default {
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(49, 130, 206, 0.3);
}

.api-status-none {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(229, 62, 62, 0.3);
}

/* Информация о конфигурации API в настройках */
.api-config-info {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.api-info-section h3 {
    margin: 0 0 12px 0;
    color: #2d3748;
    font-size: 1rem;
    font-weight: 600;
}

.api-info-item {
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-weight: 500;
}

.api-info-item.success {
    background: #f0fff4;
    color: #38a169;
    border-left: 4px solid #48bb78;
}

.api-info-item.info {
    background: #ebf8ff;
    color: #3182ce;
    border-left: 4px solid #3182ce;
}

.api-info-item.error {
    background: #fed7d7;
    color: #e53e3e;
    border-left: 4px solid #e53e3e;
}

.api-info-detail {
    padding: 4px 0 4px 20px;
    color: #4a5568;
    font-size: 0.9rem;
}

.api-info-hint {
    padding: 8px 12px;
    background: #fffbeb;
    border: 1px solid #f6e05e;
    border-radius: 4px;
    color: #d69e2e;
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Улучшенные стили для полей API ключей */
.api-key-group {
    margin-bottom: 20px;
    position: relative;
}

.api-key-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2d3748;
}

.api-key-input {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.api-key-input:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.api-key-input.has-value {
    border-color: #48bb78;
    background: #f0fff4;
}

.api-key-status {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
}

.api-key-status.configured {
    color: #48bb78;
}

.api-key-status.empty {
    color: #cbd5e0;
}

/* Информационное сообщение о базовом API */
.default-api-notice {
    background: linear-gradient(135deg, #ebf8ff 0%, #e6fffa 100%);
    border: 1px solid #3182ce;
    border-radius: 8px;
    padding: 16px;
    margin: 20px 0;
    position: relative;
}

.default-api-notice::before {
    content: '🌐';
    position: absolute;
    top: 16px;
    left: 16px;
    font-size: 1.5rem;
}

.default-api-notice-content {
    margin-left: 40px;
}

.default-api-notice h4 {
    margin: 0 0 8px 0;
    color: #2c5282;
    font-size: 1rem;
    font-weight: 600;
}

.default-api-notice p {
    margin: 0;
    color: #2d3748;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Анимация для обновления статуса */
.api-status.updating {
    animation: statusPulse 0.5s ease-in-out;
}

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

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .api-config-info {
        padding: 12px;
        margin-bottom: 16px;
    }
    
    .api-info-item {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
    
    .api-info-detail {
        padding-left: 16px;
        font-size: 0.8rem;
    }
    
    .api-status {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
}

/* Исправление отображения <br> в таблицах ИИ */
.ai-table td br,
.ai-table th br {
    display: block;
    content: "";
    margin: 0;
    line-height: 1.2;
}

.ai-table td,
.ai-table th {
    white-space: pre-line; /* Позволяет переносы строк */
    vertical-align: top;
}

/* Стили для отображения баланса API */
.api-balance {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    margin-right: 10px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e6f7ff 100%);
    border: 1px solid #90cdf4;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #2b6cb0;
    cursor: default;
    transition: all 0.2s ease;
}

.api-balance:hover {
    background: linear-gradient(135deg, #e6f7ff 0%, #d6eeff 100%);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.balance-icon {
    margin-right: 6px;
    font-size: 1rem;
}

.balance-text {
    font-weight: 500;
}

.api-balance.updating {
    animation: balancePulse 1s infinite;
}

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

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .api-balance {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
    
    .balance-icon {
        font-size: 0.9rem;
    }
}

/* Стили для отображения прикрепленных файлов в сообщениях */
.file-attachment-content {
    padding: 12px 16px !important;
    background: #f8fafc !important;
    border-radius: 12px !important;
    border-left: 3px solid #3182ce !important;
}

.files-header {
    margin-bottom: 10px;
    font-weight: 600;
    color: #3182ce;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.files-header::before {
    content: '📎';
    margin-right: 6px;
    font-size: 1.1rem;
}

.attached-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attached-file-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.attached-file-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e0;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.file-icon {
    font-size: 1.5rem;
    margin-right: 12px;
    color: #3182ce;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 3px;
}

.file-meta {
    display: flex;
    gap: 8px;
    font-size: 0.8rem;
    color: #718096;
}

.file-type {
    padding: 2px 6px;
    background: #ebf8ff;
    border-radius: 4px;
    color: #3182ce;
    font-weight: 500;
}

.file-size {
    color: #718096;
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    .file-attachment-content {
        background: #2d3748 !important;
        border-left-color: #4299e1 !important;
    }
    
    .files-header {
        color: #4299e1;
    }
    
    .attached-file-item {
        background: #1a202c;
        border-color: #4a5568;
    }
    
    .attached-file-item:hover {
        background: #2d3748;
        border-color: #718096;
    }
    
    .file-name {
        color: #e2e8f0;
    }
    
    .file-type {
        background: #2c5282;
        color: #90cdf4;
    }
    
    .file-size {
        color: #a0aec0;
    }
}
/* Стили для модального окна просмотра содержимого файла */
.file-content-modal-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    height: 80vh;
    max-width: 900px;
    min-height: 300px;
    overflow: hidden;
    position: relative;
    width: 90%;
}

.file-content-modal-header {
    align-items: center;
    background-color: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
}

.file-content-modal-title {
    align-items: center;
    display: flex;
    font-size: 1rem;
    font-weight: 600;
}

.file-content-icon {
    font-size: 1.25rem;
    margin-right: 10px;
}

.file-content-name {
    max-width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-content-modal-close {
    background: none;
    border: none;
    color: #718096;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 4px;
}

.file-content-modal-close:hover {
    color: #4a5568;
}

.file-content-modal-body {
    flex: 1;
    overflow: auto;
    padding: 16px;
}

.file-content-text {
    font-family: 'Roboto Mono', monospace, 'Courier New', Courier;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Индикатор загрузки для файла */
.file-content-loading {
    align-items: center;
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: center;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 5;
    background-color: rgba(255, 255, 255, 0.9);
}

.file-content-loading::after {
    content: 'Загрузка содержимого...';
    margin-top: 12px;
    font-size: 0.9rem;
    color: #4a5568;
}

.file-content-loading::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #3182ce;
    border-radius: 50%;
    animation: file-spinner 1s linear infinite;
}

@keyframes file-spinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Стили для интерактивных элементов файла */
.file-attachment-content .simple-file-item {
    cursor: pointer;
    transition: background-color 0.2s;
    padding: 3px 6px;
    border-radius: 4px;
}

.file-attachment-content .simple-file-item:hover {
    background-color: rgba(49, 130, 206, 0.1);
}

.file-attachment-content .file-pin-icon {
    cursor: pointer;
}

.file-attachment-content .simple-file-name {
    cursor: pointer;
    border-bottom: 1px dashed transparent;
}

.file-attachment-content .simple-file-item:hover .simple-file-name {
    border-bottom-color: #3182ce;
}

/* Стили для модального окна подтверждения сброса */
.reset-confirm-modal {
    max-width: 500px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
}

.reset-warning {
    background-color: #fff5f5;
    border-left: 4px solid #e53e3e;
    padding: 12px;
    margin-bottom: 16px;
    border-radius: 4px;
}

.reset-warning p {
    margin: 8px 0;
    color: #2d3748;
}

.reset-warning ul {
    margin: 8px 0;
    padding-left: 24px;
}

.reset-warning li {
    margin: 4px 0;
    color: #2d3748;
}

.reset-confirm-input {
    margin-top: 16px;
}

.reset-confirm-input label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.reset-confirm-input input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e53e3e;
    border-radius: 4px;
    font-size: 16px;
    background-color: #fff5f5;
}

.danger-btn {
    background-color: #e53e3e;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

.danger-btn:hover {
    background-color: #c53030;
}

/* Стили для секции опасной зоны в настройках */
.danger-section {
    border-top: 1px solid #e2e8f0;
    margin-top: 20px;
    padding-top: 20px;
    background-color: #fff5f5;
    border-radius: 8px;
    padding: 16px;
}

.danger-section h3 {
    color: #e53e3e;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
}

.danger-section h3::before {
    content: "⚠️";
    margin-right: 8px;
}

.settings-row .danger-btn {
    padding: 8px 16px;
    font-size: 14px;
    background-color: #e53e3e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(229, 62, 62, 0.3);
}

.settings-row .danger-btn:hover {
    background-color: #c53030;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(229, 62, 62, 0.4);
}

.settings-row .danger-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(229, 62, 62, 0.3);
}

.settings-description {
    margin-top: 8px;
    font-size: 13px;
    color: #718096;
}

/* Дополнительные стили для модального окна сброса */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 16px;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #2d3748;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #a0aec0;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #4a5568;
}

/* Улучшенные стили для кнопок в модальном окне */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.modal-footer .cancel-btn {
    background-color: #e2e8f0;
    color: #4a5568;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.modal-footer .cancel-btn:hover {
    background-color: #cbd5e0;
}

.modal-footer .danger-btn {
    background-color: #e53e3e;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(229, 62, 62, 0.3);
}

.modal-footer .danger-btn:hover {
    background-color: #c53030;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(229, 62, 62, 0.4);
}

.modal-footer .danger-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(229, 62, 62, 0.3);
}

/* Специфичные стили для модального окна сброса */
.reset-confirm-modal .modal-header {
    background-color: #fff5f5;
    border-radius: 8px 8px 0 0;
    padding: 12px 16px;
}

.reset-confirm-modal .modal-header h3 {
    color: #e53e3e;
    display: flex;
    align-items: center;
}

.reset-confirm-modal .modal-body {
    padding: 16px;
}

.reset-confirm-modal .modal-footer {
    padding: 12px 16px;
    background-color: #f7fafc;
    border-radius: 0 0 8px 8px;
}

/* Стили для панели навигатора узлов */
.node-navigator-panel {
  position: fixed;
  top: 100px;
  right: 20px;
  width: 280px;
  max-height: calc(100vh - 100px);
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 900;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid #e2e8f0;
  transition: transform 0.3s ease, opacity 0.3s ease, width 0.3s ease;
}

.node-navigator-panel.collapsed {
  transform: translateX(calc(100% - 35px));
  width: 300px;
}

.node-navigator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  user-select: none;
}

.node-navigator-title {
  font-size: 14px;
  font-weight: 600;
  color: #4a5568;
}

.node-navigator-toggle {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  color: #718096;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.node-navigator-panel.collapsed .node-navigator-toggle .chevron-icon {
  transform: rotate(180deg);
}

.node-navigator-content {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.node-navigator-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.node-navigator-group {
  margin-bottom: 8px;
}

.node-navigator-group-header {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: #f1f5f9;
  font-weight: 600;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
}

.node-navigator-group-header:hover {
  background: #e2e8f0;
}

.node-navigator-group-icon {
  margin-right: 8px;
  font-size: 14px;
  color: var(--node-primary-color, #3182ce);
}

.node-navigator-group-items {
  display: flex;
  flex-direction: column;
  padding-left: 12px;
  margin-top: 4px;
}

.node-navigator-item {
  display: flex;
  align-items: center;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  color: #4a5568;
  transition: background 0.2s;
  position: relative;
}

.node-navigator-item:hover {
  background: #f1f5f9;
}

.node-navigator-item.active {
  background: #ebf8ff;
  color: #2b6cb0;
  font-weight: 500;
}

.node-navigator-item-icon {
  margin-right: 8px;
  font-size: 12px;
  opacity: 0.7;
}

.node-navigator-item-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-navigator-level-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  border-radius: 50%;
  font-size: 8px;
  line-height: 12px;
  text-align: center;
  color: white;
  background: var(--node-primary-color, #3182ce);
}

.node-navigator-empty {
  padding: 12px;
  color: #718096;
  font-style: italic;
  font-size: 12px;
  text-align: center;
}

/* Индикатор активного узла */
.node-navigator-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: transparent;
  transition: background 0.2s;
}

.node-navigator-item.active::before {
  background: var(--node-primary-color, #3182ce);
}

/* Адаптивность для маленьких экранов */
@media (max-height: 700px) {
  .node-navigator-panel {
    top: 60px;
    max-height: calc(100vh - 80px);
  }
}

@media (max-width: 768px) {
  .node-navigator-panel {
    width: 240px;
    right: 10px;
  }
}

/* Стили для кнопок действий в навигаторе */
.node-navigator-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.node-navigator-action-btn {
    background: none;
    border: none;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.2s ease;
}

.node-navigator-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.1);
}

.node-navigator-action-btn:active {
    transform: scale(0.95);
}

.node-navigator-group-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--node-primary-color, #3182ce);
    color: white;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.node-navigator-group-header:hover {
    background: var(--node-border-color, #2c5282);
}

.node-navigator-group-icon {
    margin-right: 8px;
}
/* Стили для панели поиска в файле */
.file-content-search-panel {
    background-color: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-direction: row;
    padding: 8px 12px;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-input-container {
    display: flex;
    flex: 1;
    position: relative;
    min-width: 200px;
}

.file-content-search-input {
    background-color: white;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 0.9rem;
    padding: 6px 30px 6px 10px;
    width: 100%;
}

.file-content-search-input:focus {
    border-color: #3182ce;
    outline: none;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.file-content-search-clear {
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    font-size: 1.1rem;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    visibility: hidden;
    padding: 0;
    line-height: 1;
}

.file-content-search-clear.visible {
    visibility: visible;
}

.file-content-search-clear:hover {
    color: #4a5568;
}

.search-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-count {
    color: #4a5568;
    font-size: 0.8rem;
    white-space: nowrap;
}

.search-nav-btn {
    background-color: white;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    color: #4a5568;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    transition: all 0.2s ease;
}

.search-nav-btn:hover:not(:disabled) {
    background-color: #edf2f7;
    border-color: #a0aec0;
}

.search-nav-btn:disabled {
    background-color: #f7fafc;
    border-color: #e2e8f0;
    color: #cbd5e0;
    cursor: not-allowed;
}

.search-case-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

.search-case-checkbox {
    cursor: pointer;
    margin: 0;
}

.search-case-label {
    color: #4a5568;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Стили для выделения результатов поиска */
.search-highlight {
    background-color: rgba(250, 240, 137, 0.5);
    border-radius: 2px;
    padding: 0 2px;
    margin: 0 -2px;
    box-shadow: 0 0 0 1px rgba(250, 240, 137, 0.5);
}

.search-highlight.active {
    background-color: rgba(246, 173, 85, 0.7);
    box-shadow: 0 0 0 1px rgba(246, 173, 85, 0.7);
}

/* Стили для темной темы */
@media (prefers-color-scheme: dark) {
    .file-content-search-panel {
        background-color: #2d3748;
        border-color: #4a5568;
    }
    
    .file-content-search-input {
        background-color: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .file-content-search-input:focus {
        border-color: #4299e1;
        box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
    }
    
    .file-content-search-clear {
        color: #718096;
    }
    
    .file-content-search-clear:hover {
        color: #e2e8f0;
    }
    
    .search-count {
        color: #a0aec0;
    }
    
    .search-nav-btn {
        background-color: #2d3748;
        border-color: #4a5568;
        color: #a0aec0;
    }
    
    .search-nav-btn:hover:not(:disabled) {
        background-color: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .search-nav-btn:disabled {
        background-color: #1a202c;
        border-color: #2d3748;
        color: #4a5568;
    }
    
    .search-case-label {
        color: #a0aec0;
    }
    
    .search-highlight {
        background-color: rgba(180, 160, 20, 0.4);
        box-shadow: 0 0 0 1px rgba(180, 160, 20, 0.4);
    }
    
    .search-highlight.active {
        background-color: rgba(180, 100, 20, 0.5);
        box-shadow: 0 0 0 1px rgba(180, 100, 20, 0.5);
    }
}

/* Стили для LaTeX формул */
.latex-display {
    display: block;
    margin: 1rem 0;
    padding: 0.5rem;
    overflow-x: auto;
    background-color: rgba(240, 240, 240, 0.5);
    border-left: 3px solid #ccc;
    text-align: center;
}

/* Настройка для встроенного рендеринга формул с использованием MathJax */
.MathJax {
    outline: none;
}

/* Обычные инлайн-формулы $ и \( \) */
.message-content .MathJax_Display {
    margin: 1em 0;
}

/* Стили для отображения самих формул до рендеринга */
.dialog-node .message-content {
    /* Улучшаем читаемость LaTeX */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Формула в процессе загрузки/рендеринга */
.latex-display, [class*="math-tex"] {
    position: relative;
    opacity: 0.9;
}

/* Улучшаем отображение формул в темах */
.node-color-blue .latex-display {
    background-color: rgba(235, 248, 255, 0.6);
    border-left-color: #3182ce;
}

.node-color-green .latex-display {
    background-color: rgba(240, 255, 244, 0.6);
    border-left-color: #48bb78;
}

.node-color-purple .latex-display {
    background-color: rgba(250, 245, 255, 0.6);
    border-left-color: #805ad5;
}

.node-color-red .latex-display {
    background-color: rgba(254, 215, 215, 0.6);
    border-left-color: #e53e3e;
}

.node-color-orange .latex-display {
    background-color: rgba(254, 245, 231, 0.6);
    border-left-color: #ed8936;
}

.node-color-pink .latex-display {
    background-color: rgba(254, 215, 226, 0.6);
    border-left-color: #d53f8c;
}

.node-color-teal .latex-display {
    background-color: rgba(230, 255, 250, 0.6);
    border-left-color: #38b2ac;
}

.node-color-yellow .latex-display {
    background-color: rgba(255, 255, 240, 0.6);
    border-left-color: #d69e2e;
}

/* Стили для математических формул */
.math-display {
    display: block;
    margin: 1em 0;
    overflow-x: auto;
    text-align: center;
}

.MathJax {
    overflow-x: auto;
    max-width: 100%;
}

/* Стили для inline формул */
.message-content .MathJax[display="true"] {
    margin: 1em 0;
}

/* Улучшаем отображение формул на мобильных устройствах */
@media (max-width: 768px) {
    .math-display {
        font-size: 0.9em;
    }
}
/* Стили для настроек веб-поиска */
.model-extra-options {
    display: flex;
    margin-top: 5px;
    margin-bottom: 5px;
    padding: 5px;
    border-radius: 5px;
    background-color: rgba(0, 0, 0, 0.03);
}

.web-search-options {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.web-search-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.web-search-toggle input {
    margin: 0;
}

.web-search-context-size {
    padding: 3px 5px;
    font-size: 0.85rem;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.web-search-context-size:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.prompt-templates {
  margin-top: 10px;
  font-size: 0.9rem;
}

.prompt-templates-title {
  margin-bottom: 5px;
  color: #4a5568;
  font-weight: 500;
}

.prompt-templates-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-template-item {
  padding: 4px 10px;
  background-color: #edf2f7;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.prompt-template-item:hover {
  background-color: #e2e8f0;
}

/* Добавьте эти стили в ваш CSS файл */
.highlighted-text-fragment {
    background-color: rgba(255, 215, 0, 0.5);
    border-radius: 3px;
    padding: 2px 0;
    animation: pulse-highlight 2s infinite;
}

@keyframes pulse-highlight {
    0% { background-color: rgba(255, 215, 0, 0.3); }
    50% { background-color: rgba(255, 215, 0, 0.7); }
    100% { background-color: rgba(255, 215, 0, 0.3); }
}

.api-balance {
    display: inline-flex; /* Меняем на inline-flex для лучшего соответствия с соседними инлайн-элементами */
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 2px 10px; /* Минимальный padding */
    min-height: 28px; /* Минимальная высота - подстройте под соседние элементы */
    box-sizing: border-box;
    border-radius: 4px;
    background-color: #f0f5ff;
    cursor: pointer;
    margin-bottom: 0; /* Убираем нижний отступ */
    margin-right: 6px; /* Добавляем небольшой отступ справа */
    transition: background-color 0.2s;
    white-space: nowrap;
    line-height: normal; /* Нормализуем высоту строки */
    vertical-align: middle; /* Важно для inline-flex элементов */
}

.api-balance:hover {
    background-color: #e0eaff;
}

.api-balance.updating {
    animation: pulse 1.5s infinite;
}

.api-balance .balance-icon {
    margin-right: 4px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    font-size: inherit; /* Наследуем размер шрифта */
}

.api-balance .balance-text {
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    font-size: inherit; /* Наследуем размер шрифта */
}

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

/* ==================== СТИЛИ ДЛЯ СИСТЕМЫ ЗАМЕТОК ==================== */

/* Панель заметок */
.notes-panel {
    position: fixed;
    right: 20px;
    top: 410px;
    width: 400px;
    max-width: 90vw;
    height: 600px;
    max-height: 80vh;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
}

.notes-panel.collapsed {
    transform: translateX(360px);
}

/* Заголовок панели заметок */
.notes-header {
    display: flex;
    align-items: center;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
    cursor: move;
    user-select: none;
}

/* Запрет перетаскивания для свернутой панели */
.notes-panel.collapsed .notes-header {
    cursor: default;
}

.notes-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 12px;
}

.notes-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.notes-toggle .chevron-icon {
    transition: transform 0.3s ease;
}

.notes-panel.collapsed .notes-toggle .chevron-icon {
    transform: rotate(-180deg);
}

.notes-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
}

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

.notes-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.notes-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Контент заметок */
.notes-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.notes-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Пустое состояние */
.notes-empty {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
}

.notes-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.notes-empty-text {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
}

.notes-empty-hint {
    font-size: 14px;
    line-height: 1.5;
}

/* Элемент заметки */
.note-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
}

.note-item:hover {
    background: #f1f5f9;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.note-item.collapsed .note-header {
    cursor: pointer;
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    user-select: none;
}

.note-header:hover .note-collapse-icon {
    color: #3b82f6;
}

.note-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #64748b;
}

.note-collapse-icon {
    color: #94a3b8;
    font-size: 10px;
    transition: all 0.2s ease;
}

.note-date {
    color: #94a3b8;
}

.note-source {
    color: #3b82f6;
    cursor: pointer;
    transition: color 0.2s ease;
}

.note-source:hover {
    color: #2563eb;
    text-decoration: underline;
}

.note-edited {
    color: #f59e0b;
}

.note-actions {
    display: flex;
    gap: 4px;
}

.note-action-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.note-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #475569;
}

/* Превью заметки (показывается когда свернута) */
.note-preview {
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
    margin-top: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-preview.hidden {
    display: none;
}

/* Полный текст заметки */
.note-text {
    font-size: 14px;
    line-height: 1.6;
    color: #334155;
    word-wrap: break-word;
    margin-top: 8px;
}

.note-text.hidden {
    display: none;
}

/* Сохраняем форматирование из оригинального сообщения */
.note-text pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    margin: 8px 0;
}

.note-text code {
    background: #f1f5f9;
    color: #e11d48;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.note-text ul, .note-text ol {
    margin: 8px 0;
    padding-left: 24px;
}

.note-text li {
    margin: 4px 0;
}

.note-text strong {
    font-weight: 600;
    color: #1e293b;
}

.note-text em {
    font-style: italic;
    color: #475569;
}

.note-text h1, .note-text h2, .note-text h3, 
.note-text h4, .note-text h5, .note-text h6 {
    font-weight: 600;
    margin: 12px 0 8px 0;
    color: #1e293b;
}

.note-text h1 { font-size: 20px; }
.note-text h2 { font-size: 18px; }
.note-text h3 { font-size: 16px; }
.note-text h4 { font-size: 15px; }
.note-text h5 { font-size: 14px; }
.note-text h6 { font-size: 13px; }

.note-text blockquote {
    border-left: 3px solid #3b82f6;
    margin: 8px 0;
    padding-left: 12px;
    color: #475569;
    font-style: italic;
}

.note-text p {
    margin: 8px 0;
}

/* Таблица в заметке */
.note-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.note-table td, .note-table th {
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    background: white;
}

.note-table th {
    background: #f8fafc;
    font-weight: 600;
}

.note-table tr:nth-child(even) td {
    background: #f8fafc;
}

/* Textarea для редактирования заметки */
.note-edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.6;
    font-family: inherit;
    resize: vertical;
    background: white;
    outline: none;
}

/* Модальное окно для ручного добавления заметки */
.modal-compact {
    background: white;
    border-radius: 12px;
    width: 500px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 24px;  /* Добавлен общий отступ */
}

.form-textarea {
    width: 100%;
    padding: 12px 14px;  /* Увеличены отступы внутри поля */
    border: 1px solid #e2e8f0;
    border-radius: 8px;  /* Увеличен радиус скругления */
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    min-height: 150px;  /* Увеличена минимальная высота */
    font-family: inherit;
    box-sizing: border-box;  /* Добавлено для корректного расчета ширины */
}

.form-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal-actions {
    margin-top: 20px;  /* Отступ сверху от текстового поля */
    display: flex;
    gap: 10px;  /* Расстояние между кнопками */
    justify-content: flex-end;  /* Выравнивание кнопок справа */
}

/* Кнопка "В заметки" в сообщениях */
.add-note-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.add-note-btn:hover {
    background: rgba(103, 126, 234, 0.1);
    color: #667eea;
}

/* Кнопка "В заметки" в tooltip */
.tooltip-btn.add-note-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tooltip-btn.add-note-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Уведомления */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

.notification-success {
    background: #10b981;
    color: white;
}

.notification-info {
    background: #3b82f6;
    color: white;
}

.notification-warning {
    background: #f59e0b;
    color: white;
}

.notification-error {
    background: #ef4444;
    color: white;
}

/* Подсветка сообщения при переходе к источнику */
.highlight-flash {
    animation: highlightFlash 2s ease;
}

@keyframes highlightFlash {
    0% { background-color: transparent; }
    20% { background-color: rgba(102, 126, 234, 0.2); }
    80% { background-color: rgba(102, 126, 234, 0.2); }
    100% { background-color: transparent; }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .notes-panel {
        width: 320px;
        height: 500px;
        right: 10px;
        top: 390px;
    }
    
    .notes-panel.collapsed {
        transform: translateX(290px);
    }
    
    .note-text {
        font-size: 13px;
    }
}

/* ==================== СТИЛИ ДЛЯ OPENAI ASSISTANTS ==================== */

/* Форма добавления ассистента */
.assistant-add-form {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.assistant-id-input {
    flex: 1.5;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
}

.assistant-name-input {
    flex: 1;
}

/* Список ассистентов */
.assistants-list {
    margin-top: 20px;
}

.no-assistants {
    text-align: center;
    color: #718096;
    padding: 20px;
    background: #f7fafc;
    border-radius: 8px;
    font-style: italic;
}

.assistant-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.assistant-item:hover {
    border-color: #cbd5e0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.assistant-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.assistant-name {
    font-weight: 600;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 6px;
}

.assistant-name::before {
    content: '🤖';
    font-size: 1.1em;
}

.assistant-id {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    color: #718096;
}

/* Иконка режима ассистента в узле */
.assistant-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 20px;
    opacity: 0.8;
    animation: assistantPulse 2s infinite;
}

@keyframes assistantPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Режим ассистента для узла */
.dialog-node.assistant-mode {
    border-color: #805ad5;
    box-shadow: 0 0 0 2px rgba(128, 90, 213, 0.1);
}

.dialog-node.assistant-mode .node-header {
    background: linear-gradient(135deg, #805ad5 0%, #6b46c1 100%);
}

.dialog-node.assistant-mode .model-select {
    background: rgba(255, 255, 255, 0.95);
    border-color: #805ad5;
}

/* Кнопки управления ассистентами */
.btn-danger.btn-sm {
    padding: 4px 12px;
    font-size: 0.85rem;
}

/* Группа опций в селекторе */
optgroup[label="OpenAI Assistants"] {
    font-weight: 600;
    color: #805ad5;
}

optgroup[label="OpenAI Assistants"] option {
    padding-left: 20px;
    font-weight: normal;
}

/* Индикатор thread в сообщениях */
.message.assistant-thread-info {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-left: 3px solid #805ad5;
    padding: 8px 12px;
    margin: 10px 0;
    font-size: 0.85rem;
    color: #4a5568;
    font-style: italic;
}

/* Адаптивность */
@media (max-width: 768px) {
    .assistant-add-form {
        flex-direction: column;
    }
    
    .assistant-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .assistant-info {
        text-align: center;
    }
}

// ==================== СТИЛИ ДЛЯ КОНТЕЙНЕРОВ КОДА ====================
    /* Контейнер для блока кода */
    .code-block-container {
        margin: 20px 0;
        border-radius: 8px;
        overflow: hidden;
        background: #282c34;
        border: 1px solid #3a3f4b;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        max-width: 100%; /* Ограничиваем ширину */
        box-sizing: border-box; /* Включаем padding и border в ширину */
    }
    
    /* Заголовок блока кода */
    .code-block-header {
        padding: 8px 14px;
        background: #21252b;
        border-bottom: 1px solid #3a3f4b;
        font-size: 13px;
    }
    
    /* Язык программирования */
    .code-language {
        color: #abb2bf;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        font-size: 12px;
    }
    
    /* Обертка для кода с кнопкой */
    .code-block-wrapper {
        position: relative;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden; /* Скрываем выходящий контент */
    }
    
    /* Кнопка копирования - плавающая в углу */
    .code-copy-btn {
        position: absolute;
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(33, 37, 43, 0.9);
        border: 1px solid #4b5263;
        border-radius: 6px;
        color: #abb2bf;
        cursor: pointer;
        transition: all 0.2s ease;
        z-index: 10;
        opacity: 0.8;
    }
    
    .code-copy-btn:hover {
        opacity: 1;
        background: rgba(58, 63, 75, 0.95);
        border-color: #5c6370;
        color: #ffffff;
        transform: scale(1.05);
    }
    
    .code-copy-btn:active {
        transform: scale(0.95);
    }
    
    .code-copy-btn.copied {
        background: rgba(152, 195, 121, 0.2);
        border-color: #98c379;
        color: #98c379;
        opacity: 1;
    }
    
    .code-copy-btn svg {
        width: 18px;
        height: 18px;
        pointer-events: none;
    }
    
    /* Блок кода - С ОГРАНИЧЕННОЙ ШИРИНОЙ И ГОРИЗОНТАЛЬНОЙ ПРОКРУТКОЙ */
    .code-block {
        margin: 0;
        padding: 20px;
        padding-right: 65px; /* Отступ справа для кнопки */
        overflow-x: auto; /* Горизонтальная прокрутка только для кода */
        overflow-y: hidden; /* Скрываем вертикальную прокрутку */
        background: #282c34;
        color: #abb2bf;
        font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'SF Mono', Consolas, Monaco, 'Courier New', monospace;
        font-size: 15px;
        line-height: 1.7;
        tab-size: 4;
        white-space: pre;
        font-weight: 400;
        letter-spacing: 0.3px;
        max-width: 100%; /* Ограничиваем ширину */
        box-sizing: border-box;
    }
    
    /* Фикс для предотвращения растягивания контейнера */
    .message-content .code-block-container {
        max-width: calc(100% - 10px); /* Немного меньше чем контейнер сообщения */
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Ограничение ширины pre элемента */
    .code-block pre {
        margin: 0;
        max-width: 100%;
        overflow-x: auto;
    }
    
    .code-block code {
        background: transparent;
        padding: 0;
        border: none;
        color: #e6e6e6;
        font-family: inherit;
        font-size: inherit;
        font-weight: inherit;
        display: inline-block; /* Позволяет коду расширяться по горизонтали */
        min-width: 100%; /* Минимальная ширина для коротких строк */
    }
    
    /* Улучшенный скроллбар для блока кода */
    .code-block::-webkit-scrollbar {
        height: 10px;
        width: 10px;
    }
    
    .code-block::-webkit-scrollbar-track {
        background: #21252b;
        border-radius: 5px;
    }
    
    .code-block::-webkit-scrollbar-thumb {
        background: #4b5263;
        border-radius: 5px;
    }
    
    .code-block::-webkit-scrollbar-thumb:hover {
        background: #5c6370;
    }
    
    /* Скроллбар всегда видимый для блоков с длинными строками */
    .code-block:hover::-webkit-scrollbar {
        display: block;
    }
    
    /* Инлайн код */
    .inline-code {
        background: #3a3f4b;
        padding: 3px 8px;
        border-radius: 4px;
        font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'SF Mono', Consolas, Monaco, 'Courier New', monospace;
        font-size: 14px;
        color: #e06c75;
        border: 1px solid #4b5263;
        white-space: nowrap;
        font-weight: 500;
        max-width: 100%;
        overflow-x: auto;
        display: inline-block;
    }
    
    /* Улучшенная подсветка синтаксиса с более яркими цветами */
    .code-block .keyword {
        color: #c678dd;
        font-weight: 500;
    }
    
    .code-block .string {
        color: #98c379;
    }
    
    .code-block .number {
        color: #d19a66;
    }
    
    .code-block .comment {
        color: #7f848e;
        font-style: italic;
        opacity: 0.8;
    }
    
    .code-block .function {
        color: #61afef;
        font-weight: 500;
    }
    
    .code-block .class {
        color: #e5c07b;
        font-weight: 500;
    }
    
    .code-block .operator {
        color: #56b6c2;
    }
    
    .code-block .punctuation {
        color: #abb2bf;
    }
    
    /* Светлая тема для кода */
    .dialog-node.light-theme .code-block-container {
        background: #fafafa;
        border-color: #d1d5da;
    }
    
    .dialog-node.light-theme .code-block-header {
        background: #f6f8fa;
        border-bottom-color: #d1d5da;
    }
    
    .dialog-node.light-theme .code-block {
        background: #fafafa;
        color: #24292e;
    }
    
    .dialog-node.light-theme .code-block code {
        color: #24292e;
    }
    
    .dialog-node.light-theme .code-language {
        color: #586069;
    }
    
    .dialog-node.light-theme .code-copy-btn {
        background: rgba(246, 248, 250, 0.95);
        color: #586069;
        border-color: #d1d5da;
    }
    
    .dialog-node.light-theme .code-copy-btn:hover {
        background: rgba(255, 255, 255, 0.95);
        border-color: #959da5;
        color: #24292e;
    }
    
    .dialog-node.light-theme .inline-code {
        background: #f6f8fa;
        color: #d73a49;
        border-color: #d1d5da;
    }
    
    /* Светлая тема - подсветка синтаксиса */
    .dialog-node.light-theme .code-block .keyword {
        color: #d73a49;
        font-weight: 500;
    }
    
    .dialog-node.light-theme .code-block .string {
        color: #032f62;
    }
    
    .dialog-node.light-theme .code-block .number {
        color: #005cc5;
    }
    
    .dialog-node.light-theme .code-block .comment {
        color: #6a737d;
        font-style: italic;
    }
    
    .dialog-node.light-theme .code-block .function {
        color: #6f42c1;
        font-weight: 500;
    }
    
    .dialog-node.light-theme .code-block .class {
        color: #e36209;
        font-weight: 500;
    }
    
    /* Анимация для уведомления о копировании */
    @keyframes copySuccess {
        0% {
            transform: scale(1);
        }
        50% {
            transform: scale(1.1) rotate(5deg);
        }
        100% {
            transform: scale(1);
        }
    }
    
    .code-copy-btn.copied {
        animation: copySuccess 0.3s ease;
    }
    
    /* Адаптивность для маленьких экранов */
    @media (max-width: 480px) {
        .code-copy-btn {
            width: 32px;
            height: 32px;
            top: 8px;
            right: 8px;
        }
        
        .code-copy-btn svg {
            width: 16px;
            height: 16px;
        }
        
        .code-block {
            font-size: 14px;
            padding: 16px;
            padding-right: 50px;
            line-height: 1.6;
        }
        
        .inline-code {
            font-size: 13px;
        }
    }
    
    /* Для средних экранов */
    @media (min-width: 481px) and (max-width: 768px) {
        .code-block {
            font-size: 14px;
            line-height: 1.65;
        }
    }
    
    /* Для больших экранов */
    @media (min-width: 1400px) {
        .code-block {
            font-size: 16px;
            line-height: 1.75;
        }
        
        .inline-code {
            font-size: 15px;
        }
    }
    
    /* Предотвращение переноса строк в блоке кода */
    .code-block {
        word-break: normal;
        word-wrap: normal;
        overflow-wrap: normal;
        white-space: pre; /* Сохраняем форматирование и пробелы */
    }
    
    /* При наведении на контейнер кода показываем кнопку ярче */
    .code-block-container:hover .code-copy-btn {
        opacity: 1;
    }
    
    /* Дополнительные улучшения для читаемости */
    .code-block {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
    
    /* Выделение текущей строки при наведении */
    .code-block:hover {
        background: #2c313a;
    }
    
    /* Фикс для узлов диалога - предотвращаем расширение */
    .dialog-node .message-content {
        overflow-x: hidden; /* Скрываем горизонтальную прокрутку в сообщениях */
        max-width: 100%;
    }
    
    /* Убеждаемся что код не выходит за пределы сообщения */
    .message.assistant .message-content .code-block-container,
    .message.user .message-content .code-block-container {
        max-width: 100%;
        overflow: hidden;
    }
    
    /* Индикатор наличия горизонтальной прокрутки */
    .code-block-container.has-scroll .code-block::after {
        content: '→';
        position: absolute;
        right: 10px;
        bottom: 10px;
        color: #5c6370;
        font-size: 18px;
        font-weight: bold;
        pointer-events: none;
        opacity: 0.5;
    }


/* ==================== СТИЛИ ДЛЯ ТАБЛИЦ В СООБЩЕНИЯХ ==================== */
.message-table-container {
    overflow-x: auto;
    margin: 10px 0;
    border-radius: 8px;
    background: #f8f9fa;
    padding: 10px;
    position: relative;
}

.message-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.message-table th:last-child {
    border-right: none;
}

.message-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    font-size: 14px;
}

.message-table td:last-child {
    border-right: none;
}

.message-table tbody tr:last-child td {
    border-bottom: none;
}

.message-table tbody tr:hover {
    background: #f7fafc;
}

.message-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.message-table tbody tr:nth-child(even):hover {
    background: #edf2f7;
}

.table-copy-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    color: #4a5568;
    transition: all 0.2s;
    opacity: 0;
}

.table-copy-btn:hover {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-table-container:hover .table-copy-btn {
    opacity: 1;
}

    /* Стили для обычных текстовых блоков в тройных кавычках */
    .text-block {
        margin: 16px 0;
        padding: 16px;
        background: #f6f8fa;
        border: 1px solid #d1d5da;
        border-radius: 6px;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    }
    
    .text-block pre {
        margin: 0;
        white-space: pre-wrap;
        word-wrap: break-word;
        font-family: inherit;
        font-size: 14px;
        line-height: 1.6;
        color: #24292e;
        background: transparent;
    }
    
    /* Темная тема для текстовых блоков */
    .dialog-node.dark-theme .text-block {
        background: #2d333b;
        border-color: #444c56;
    }
    
    .dialog-node.dark-theme .text-block pre {
        color: #adbac7;
    }
    
    /* Убедимся, что таблицы отображаются правильно */
    .message-content table {
        margin: 16px 0;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        display: block;
    }
    
    /* Предотвращаем применение стилей кода к таблицам */
    .message-content table:not(.code-table) {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
    }
    
/* Сохранение форматирования при подсветке */
.highlighted-text-fragment {
    background-color: rgba(255, 235, 59, 0.5);
    padding: 0 2px;
    border-radius: 2px;
    animation: highlight-pulse 1s ease-in-out;
    /* Сохраняем исходное форматирование */
    display: inline;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-content[data-original-html] {
    /* Индикатор что есть сохраненный оригинал */
    position: relative;
}

/* Анимация мигания для подсвеченного текста */
@keyframes highlight-blink {
    0%, 100% {
        background-color: rgba(255, 235, 59, 0.5);
        box-shadow: 0 0 8px rgba(255, 235, 59, 0.6);
    }
    50% {
        background-color: rgba(255, 235, 59, 0.8);
        box-shadow: 0 0 12px rgba(255, 235, 59, 0.9);
    }
}

/* Улучшенная подсветка фрагмента */
.highlighted-text-fragment {
    background-color: rgba(255, 235, 59, 0.5);
    padding: 2px 4px;
    border-radius: 3px;
    display: inline;
    white-space: pre-wrap;
    word-wrap: break-word;
    transition: all 0.3s ease;
}

/* Контейнер сообщений должен иметь правильные стили для прокрутки */
.node-messages {
    scroll-behavior: smooth;
    position: relative;
}

/* При наведении на подсвеченный фрагмент */
.highlighted-text-fragment:hover {
    background-color: rgba(255, 235, 59, 0.7);
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.8);
}

/* Обертка для файла с кнопкой удаления */
.simple-file-item-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    padding: 2px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.simple-file-item-wrapper:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

/* Кнопка удаления файла из системного сообщения */
.remove-file-btn {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
    visibility: hidden;
    flex-shrink: 0;
}

.simple-file-item-wrapper:hover .remove-file-btn {
    opacity: 1;
    visibility: visible;
}

.remove-file-btn:hover {
    background: #fee2e2;
    color: #dc2626;
    transform: scale(1.1);
}

.remove-file-btn:active {
    transform: scale(0.95);
}

/* Обновляем стиль simple-file-item для flex */
.simple-file-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    .simple-file-item-wrapper:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }
    
    .remove-file-btn {
        color: #64748b;
    }
    
    .remove-file-btn:hover {
        background: rgba(239, 68, 68, 0.2);
        color: #ef4444;
    }
}

