:root {
    --color-accent: #7F96FF;
    --color-accent-hover: #6b82eb;
    --color-bg-primary: #0F0F0F;
    --color-bg-secondary: #1a1a1a;
    --color-bg-tertiary: #252525;
    --color-bg-input: #1f1f1f;
    --color-border: #333;
    --color-border-light: #444;
    --color-text-primary: #e0e0e0;
    --color-text-secondary: #888;
    --color-text-muted: #666;
    --color-error: #ff5555;
    --color-success: #50fa7b;
}

/* Убираем стрелки у всех скроллбаров */
::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

/* Light Theme */
body.light-theme {
    --color-bg-primary: #f5f5f5;
    --color-bg-secondary: #ffffff;
    --color-bg-tertiary: #f0f0f0;
    --color-bg-input: #fafafa;
    --color-border: #ddd;
    --color-border-light: #e0e0e0;
    --color-text-primary: #1a1a1a;
    --color-text-secondary: #666;
    --color-text-muted: #999;
    --color-error: #d32f2f;
    --color-success: #388e3c;
}

/* Light Theme Overrides */
body.light-theme {
    background: #f5f5f5;
    color: #1a1a1a;
}

body.light-theme .panel {
    background: #ffffff;
    border-color: #ddd;
}

body.light-theme .panel-header {
    background: #ffffff;
    border-color: #eee;
}

body.light-theme .chat-messages {
    background: #ffffff !important; /* Делаем полностью белым */
    border: none !important;
    box-shadow: none !important;
}

body.light-theme .chat-panel {
    background: #ffffff !important;
    border: none !important;
}

body.light-theme .message.user {
    background: none !important;
    background-color: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    color: #1a1a1a !important;
}

body.light-theme .message.assistant {
    background: #f7f7f7 !important; /* Чуть темнее фона чата */
    border: 1px solid #f7f7f7 !important; /* Обводка цвета заливки */
    color: #1a1a1a !important;
}

body.light-theme .message.loading {
    background: #f5f5f5 !important; /* Светло-серый фон для индикатора загрузки */
    border: 1px solid #eee;
}

body.light-theme .typing-dot {
    background: #999 !important; /* Серые точки вместо тёмных */
}

body.light-theme .chat-input-container {
    background: #ffffff;
    border: none !important; /* Убрана обводка */
    box-shadow: none !important;
}

body.light-theme .input-wrapper {
    border: none !important;
    box-shadow: none !important;
}

/* Кнопки в блоке ввода - светлая тема */
body.light-theme .btn-input-action {
    color: #bbb; /* Светло-серые по умолчанию */
    transition: color 0.2s ease;
}

body.light-theme .btn-input-action:hover {
    color: #666 !important; /* Темнее при наведении */
}

body.light-theme #userInput {
    background: #f5f5f5 !important;
    border: none !important; /* Без рамки */
    color: #1a1a1a !important;
}

body.light-theme .btn-icon,
body.light-theme .btn-export {
    color: #666;
    border-color: #ddd;
}

body.light-theme .btn-attestation {
    background: #f5f5f5;
    border-color: #ddd;
    color: #666;
}

body.light-theme .btn-scope-toggle {
    background: #f5f5f5;
    border-color: #ddd;
    color: #666;
}

body.light-theme .btn-icon:hover,
body.light-theme .btn-export:hover {
    background: transparent !important;
    color: #333 !important; /* Тёмный при наведении в светлой теме */
}

body.light-theme .btn-attestation:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

body.light-theme .btn-scope-toggle:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

body.light-theme .instruction-tabs {
    background: #f5f5f5;
    border: none !important;
}

body.light-theme .instruction-tab {
    color: #666;
}

body.light-theme .instruction-tab.active {
    background: #ffffff;
    color: var(--color-accent);
}

body.light-theme .instruction-content {
    background: #ffffff;
}

body.light-theme .prompt-input,
body.light-theme .prompt-preview {
    background: #ffffff !important; /* Абсолютно белый */
    border-color: #ddd;
    color: #1a1a1a;
}

body.light-theme .prompt-editor.drag-over,
body.light-theme .prompt-preview.drag-over {
    background: #f0f8ff !important;
    border: 2px dashed var(--color-accent) !important;
}

body.light-theme .prompt-variation-chip {
    background: #f0f0f0;
    color: #666;
}

body.light-theme .prompt-variation-chip.active {
    background: var(--color-accent);
    color: #fff;
}

body.light-theme .markdown-toolbar {
    background: #ffffff; /* Белый фон */
    border: none;
}

body.light-theme .toolbar-btn {
    color: #888;
}

body.light-theme .toolbar-btn:hover {
    background: #f0f0f0;
    color: #333;
}

body.light-theme .toolbar-divider {
    background: #ddd;
}

body.light-theme .modal-content {
    background: #ffffff;
    border: none; /* Убрана обводка */
}

body.light-theme .modal-content h3 {
    color: #1a1a1a;
}

body.light-theme #nameModal {
    background: rgba(245, 245, 245, 0.98);
}

body.light-theme #nameModal .auth-modal-content input {
    background: #f5f5f5 !important;
    border: 1px solid #dddddd;
    color: #1a1a1a;
}

body.light-theme #nameModal .auth-modal-content input:-webkit-autofill,
body.light-theme #nameModal .auth-modal-content input:-webkit-autofill:hover,
body.light-theme #nameModal .auth-modal-content input:-webkit-autofill:focus,
body.light-theme #nameModal .auth-modal-content input:-webkit-autofill:active {
    -webkit-text-fill-color: #1a1a1a !important;
    -webkit-box-shadow: 0 0 0 1000px #f5f5f5 inset !important;
    box-shadow: 0 0 0 1000px #f5f5f5 inset !important;
    border: 1px solid #dddddd !important;
    caret-color: #1a1a1a;
}

body.light-theme .auth-password-toggle {
    color: #777;
}

body.light-theme .auth-password-toggle:hover {
    color: #222;
    background: rgba(0, 0, 0, 0.08);
}

body.light-theme #modalLoginInput,
body.light-theme #modalLoginInput:-webkit-autofill,
body.light-theme #modalLoginInput:-webkit-autofill:hover,
body.light-theme #modalLoginInput:-webkit-autofill:focus,
body.light-theme #modalLoginInput:-webkit-autofill:active {
    background-color: #f5f5f5 !important;
}

/* Old settings styles removed */

body.light-theme .dropdown-menu {
    background: #ffffff;
    border-color: #ddd;
}

body.light-theme .dropdown-item {
    color: #1a1a1a;
}

body.light-theme .start-conversation {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

body.light-theme .btn-start {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

body.light-theme .btn-start:hover {
    background: #e0e0e0;
}

body.light-theme .resizer {
    background: #ddd; /* Цвет разделителя */
}

body.light-theme .resizer:hover,
body.light-theme .resizer.resizing {
    background: var(--color-accent);
}

/* Исправление текста в редакторе промптов */
body.light-theme .prompt-preview h1,
body.light-theme .prompt-preview h2,
body.light-theme .prompt-preview h3,
body.light-theme .prompt-preview h4,
body.light-theme .prompt-preview h5,
body.light-theme .prompt-preview h6,
body.light-theme .prompt-preview strong,
body.light-theme .prompt-preview b {
    color: #1a1a1a !important;
}

body.light-theme .prompt-preview code {
    background: transparent;
    color: inherit;
}

body.light-theme .prompt-preview pre {
    background: transparent;
    border: none;
}

body.light-theme .prompt-preview em,
body.light-theme .prompt-preview i {
    color: #444 !important;
}

body.light-theme .prompt-preview ul,
body.light-theme .prompt-preview ol {
    color: #1a1a1a !important;
}

body.light-theme .prompt-preview h1,
body.light-theme .prompt-preview h2 {
    border-bottom-color: #ddd !important;
}

/* Дополнительные исправления для светлой темы */

/* Кнопки в модалках и настройках */
body.light-theme .btn-modal-cancel:hover {
    background: #e0e0e0 !important;
    color: #1a1a1a !important;
}

/* Поля ввода при фокусе */
body.light-theme input:focus,
body.light-theme textarea:focus,
body.light-theme .prompt-editor:focus,
body.light-theme #userInput:focus {
    background: #f5f5f5 !important; /* Тот же фон, что и без фокуса */
    border: none !important;
    outline: none !important;
    color: #1a1a1a !important;
    box-shadow: none !important;
}

/* Выпадающие меню */
body.light-theme .dropdown-menu {
    background: #ffffff !important;
    border: 1px solid #ddd !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
}

body.light-theme .dropdown-item {
    color: #333 !important;
}

body.light-theme .dropdown-item:hover {
    background: #f0f0f0 !important;
    color: #000 !important;
}

/* Кнопка закрытия модалки */
body.light-theme .modal-close {
    color: #666 !important;
}

body.light-theme .modal-close:hover {
    background: #f0f0f0 !important;
    color: #d32f2f !important;
}

/* Кнопка добавления вариации промпта */
body.light-theme .add-variation-btn {
    color: #666 !important;
}

body.light-theme .add-variation-btn:hover {
    background: #e0e0e0 !important;
    color: #1a1a1a !important;
}

/* Кнопка улучшения отзыва */
body.light-theme .btn-improve-from-rating {
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    color: #333 !important;
}

body.light-theme .btn-improve-from-rating:hover {
    background: #e0e0e0 !important;
}

/* Иконки действий в чате (копировать и т.д.) */
body.light-theme .message-actions .btn-icon {
    color: #888 !important;
}

body.light-theme .message-actions .btn-icon:hover {
    background: #e0e0e0 !important;
    color: #333 !important;
}

/* Мобильные табы */
body.light-theme .mobile-tabs {
    background: #f5f5f5;
    border-bottom: none;
    padding: 10px 50px;
}

body.light-theme .mobile-tab {
    background: #e0e0e0;
    color: #333; /* Был #666, стал темнее */
    border: none !important; /* Убираем обводку */
}

body.light-theme .mobile-tab.active {
    background: var(--color-accent);
    color: #fff;
    border: none !important;
}

body.light-theme ::-webkit-scrollbar-thumb {
    background-color: #ccc !important;
    border-color: #f5f5f5 !important;
}

body.light-theme ::-webkit-scrollbar-thumb:hover {
    background-color: #aaa !important;
}

/* Кнопка старта */
body.light-theme #startBtn {
    background: #f5f5f5 !important;
    color: #333 !important;
    border: none !important; /* Убрал рамку */
    box-shadow: none !important;
}

body.light-theme #startBtn:hover {
    background: #e0e0e0 !important;
}

/* Полоска-разделитель в светлой теме */
body.light-theme .resize-handle {
    background: #ffffff !important; /* Белый - цвет фона */
    border: none !important;
    width: 6px !important;
    transition: background 0.2s ease !important;
}

body.light-theme .resize-handle:hover {
    background: #d0d0d0 !important; /* Серый при наведении */
}

body.light-theme .resize-handle:active {
    background: #bbb !important; /* Чуть темнее при перетаскивании */
}

/* Убираем рамки в чате */
body.light-theme .chat-panel,
body.light-theme .chat-messages {
    border: none !important;
    box-shadow: none !important;
}

body.light-theme .panel {
    border: none !important;
}

/* Дополнительно проверим разделители */
body.light-theme .panel-header {
    border-bottom: none !important; /* Убрал полоску */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    height: 100dvh;
    overflow: hidden;
}

/* Custom tooltips */
.custom-tooltip-target {
    position: relative;
}

.custom-tooltip-layer {
    position: fixed !important;
    inset: auto !important;
    margin: 0;
    left: -9999px;
    top: -9999px;
    z-index: 2147483647;
    pointer-events: none;
    padding: 12px 24px;
    width: max-content;
    max-width: min(420px, calc(100vw - 24px));
    border-radius: 8px;
    border: 1px solid #444;
    background: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
    opacity: 0;
    visibility: hidden;
    transition: none;
}

.custom-tooltip-layer:popover-open {
    position: fixed !important;
    inset: auto !important;
    margin: 0;
}

.custom-tooltip-layer::before {
    content: none;
}

.custom-tooltip-layer.visible {
    visibility: visible;
    opacity: 1;
}

.custom-tooltip-layer.placement-bottom {
    transform: none;
}

.custom-tooltip-layer.placement-bottom::before {
    content: none;
}

body.light-theme .custom-tooltip-layer {
    border-color: #444;
    background: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    color: #fff;
}

body.light-theme .custom-tooltip-layer::before {
    content: none;
}

body.light-theme .custom-tooltip-layer.placement-bottom::before {
    content: none;
}

@media (hover: none) {
    .custom-tooltip-layer {
        display: none !important;
    }
}

.container {
    display: flex;
    height: 100dvh;
    gap: 0;
    background: #0F0F0F;
    position: relative;
    flex-direction: column;
}

.mobile-tabs {
    display: none;
    background: #0F0F0F;
    padding: 10px 50px; /* Боковые отступы для плавающих кнопок */
    gap: 8px;
    border-bottom: none;
    flex-shrink: 0;
}

.mobile-tab {
    flex: 1;
    padding: 10px 16px;
    background: #252525;
    border: none;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.mobile-tab:hover {
    background: #333333;
}

.mobile-tab.active {
    background: var(--color-accent);
    border: none;
    color: #fff;
}

/* Cloud save button */
/* Old cloud save styles removed */

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

.panels-container {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 0;
}

/* На широких экранах все панели видимы */
@media (min-width: 1025px) {
    .panel {
        display: flex !important;
    }
}

.resize-handle {
    width: 8px;
    background: #0F0F0F;
    cursor: col-resize;
    position: relative;
    transition: background 0.2s;
    z-index: 10;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Невидимая зона захвата для удобного перетаскивания */
.resize-handle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -12px;
    right: -12px;
    bottom: 0;
    cursor: col-resize;
}

/* Визуальный индикатор (три точки) - скрыт */
.resize-handle::after {
    content: '';
}

.resize-handle:hover {
    background: #1a1a1a;
}

.resize-handle:active {
    background: #252525;
}

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0F0F0F;
    min-width: 250px;
}

.prompt-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0F0F0F;
    min-width: 320px;
    min-height: 0;
    overflow: hidden;
}

body.attestation-mode #instructionsPanel {
    display: none !important;
}

body.attestation-mode .resize-handle {
    display: none !important;
}

body.attestation-mode .chat-panel {
    flex: 1 0 100% !important;
}

.panel-header {
    padding: 16px 60px 16px 20px; /* Увеличил отступ справа для кнопки настроек */
    background: #0F0F0F;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
    height: 60px;
    flex-shrink: 0;
}

#instructionsPanel .panel-header {
    padding-left: 0;
}

#instructionsPanel.compact-tabs .panel-header {
    padding-left: 16px;
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 500;
    color: #f0f0f0;
    margin: 0;
    line-height: 1;
}

.header-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
    height: 100%;
    margin-left: auto;
    flex-shrink: 0;
    padding-left: 12px;
}

.btn-attestation {
    background: #222;
    border: 1px solid #333;
    color: #bbb;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-attestation:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.btn-scope-toggle {
    background: #222;
    border: 1px solid #333;
    color: #bbb;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-scope-toggle:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.btn-scope-toggle.is-local {
    color: #7cc89b;
    border-color: #2f5f46;
}

.btn-scope-toggle.is-local:hover {
    color: #9ee0b7;
    border-color: #4f8d6b;
}

.btn-attestation-exit {
    display: none;
}

body.attestation-mode .btn-attestation {
    display: none;
}

body.attestation-mode .btn-attestation-exit {
    display: inline-flex;
}

/* Export buttons always visible */
.btn-export {
    opacity: 1;
}

.char-count {
    font-size: 12px;
    color: #888;
    padding: 0 8px;
}


.btn-icon {
    padding: 8px;
    background: transparent;
    border: none !important; /* Убираем border */
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    height: 32px;
    width: 32px;
}

.btn-icon:hover {
    background: #252525;
    border-color: #444;
}

.btn-icon.btn-export {
    color: #888; /* Серо-светлый по умолчанию */
}

.btn-icon.btn-export:hover {
    background: transparent;
    border-color: transparent;
    color: #fff; /* Белый при наведении */
    transform: none; /* Убрана анимация увеличения */
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

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

.start-conversation {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    min-height: 200px;
    flex-direction: column;
}

.btn-start {
    width: 320px;
    max-width: 90%;
    padding: 54px 72px;
    background: #252525;
    border: none;
    color: #777777;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.btn-start:hover {
    background: #2a2a2a;
    color: #999999;
}

.btn-start:active {
    background: #1f1f1f;
}

.btn-start-attestation {
    margin-top: 8px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 8px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    animation: slideIn 0.3s ease-out;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.message-content {
    margin-bottom: 4px;
}

.message-content p {
    margin: 0 0 8px 0;
}

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

.message-content pre {
    margin: 8px 0;
    padding: 12px;
    background: #0a0a0a;
    border-radius: 6px;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid #2a2a2a;
}

.message-content code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.message-content pre code {
    display: block;
    padding: 0;
    background: none;
}

.message-content :not(pre) > code {
    background: #0a0a0a;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #2a2a2a;
}

.message-content strong {
    font-weight: 700;
}

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

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 {
    font-size: 1.5em;
}

.message-content h2 {
    font-size: 1.3em;
}

.message-content h3 {
    font-size: 1.15em;
}

.message-content h4 {
    font-size: 1em;
}

.message-content hr {
    border: none;
    border-top: 1px solid #444;
    margin: 16px 0;
}

.message-content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 13px;
    line-height: 1.4;
}

.message-content th,
.message-content td {
    padding: 8px 12px;
    border: 1px solid #444;
    text-align: left;
    min-width: 120px; /* Ensure columns have enough width */
}

.message-content th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    white-space: nowrap;
}

.message-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

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

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

.message-content br {
    display: block;
    content: "";
    margin-top: 8px;
}

.message-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 6px;
    font-size: 11px;
    color: #cccccc;
}

.message-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 1;
}

.btn-copy {
    background: none;
    border: none;
    color: #cccccc;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.message.user {
    align-self: flex-end;
    background: none !important;
    background-color: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    color: #e0e0e0 !important;
}

.message.user .message-content :not(pre) > code {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
}

body.light-theme .message.user .message-content :not(pre) > code {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.16);
}

.message.user a,
body.light-theme .message.user a {
    color: inherit;
}

.message.assistant {
    align-self: flex-start;
    background: #252525;
    color: #e0e0e0;
}

.message.error {
    align-self: center;
    background: #5a2a2a;
    color: #ff9999;
    max-width: 90%;
}

.message.rating {
    align-self: center;
    background: #2a2a2a;
    color: #e0e0e0;
    max-width: 95%;
    padding: 16px 24px;
}

.message.rating .message-content :not(pre) > code {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(0, 0, 0, 0.3);
}

/* Improve from rating button */
.improve-from-rating-container {
    display: flex;
    justify-content: center;
    padding: 16px 0;
    margin-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.btn-improve-from-rating {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--color-accent);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.btn-improve-from-rating:hover {
    transform: scale(1.02);
}

.btn-improve-from-rating:disabled {
    opacity: 0.8;
    cursor: wait;
}

.btn-improve-from-rating .spinner {
    animation: spin 1s linear infinite;
}

.message.rerate-confirm {
    align-self: center;
    background: transparent;
    box-shadow: none;
    border: 0;
    padding: 0;
    max-width: 95%;
}

.rerate-confirm-box {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 10px;
    background: #1f1f1f;
    border: 1px solid #2d2d2d;
}

.rerate-confirm-text {
    color: #cfcfcf;
    font-size: 13px;
    line-height: 1.35;
}

.btn-rerate-confirm {
    border: 0;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    background: var(--color-accent);
    transition: filter 0.2s ease;
}

.btn-rerate-confirm:hover {
    filter: brightness(1.08);
}

.message.loading {
    align-self: flex-start;
    background: #252525;
    color: #999;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

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

.chat-input-container {
    padding: 0 20px 16px;
    background: #0F0F0F;
    display: flex;
    gap: 12px;
    flex-shrink: 0;
    align-items: flex-end;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    min-height: 44px;
}

.input-actions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: flex;
    gap: 4px;
    z-index: 10;
    align-items: flex-end;
}

#userInput {
    flex: 1;
    padding: 12px 100px 12px 12px;
    background: #1f1f1f;
    border: none;
    border-radius: 16px;
    color: #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s, height 0.1s ease;
    height: 44px;
    min-height: 44px;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.4;
    box-sizing: border-box;
    width: 100%;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#userInput::-webkit-scrollbar {
    display: none;
}

#userInput:focus {
    border-color: #333333;
    box-shadow: none;
}

#userInput::placeholder {
    color: #777;
}

#userInput.locked-dialog {
    min-height: 62px;
    height: 62px;
    padding-top: 10px;
    padding-right: 12px;
    padding-bottom: 10px;
    line-height: 1.35;
}

.input-wrapper.is-locked .input-actions {
    display: none;
}

.btn-input-action {
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    border: none;
    outline: none;
    color: #888888;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-input-action:hover {
    color: #cccccc;
}

.btn-input-action.recording {
    color: #ff4444;
    animation: pulse 1.5s ease-in-out infinite;
}

.btn-input-action.loading {
    color: var(--color-accent);
    animation: spin 1s linear infinite;
}

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

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

.btn-send {
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--color-accent);
    border: none;
    color: #fff;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-sizing: border-box;
}

.btn-send svg {
    transform: rotate(0deg);
    transition: transform 0.2s;
}

.btn-send:hover svg {
    transform: rotate(15deg);
}

.btn-send.voice-mode:hover svg {
    transform: none;
}

.btn-send.voice-mode svg {
    transform: none;
}

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

.btn-send:disabled {
    background: #252525;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Instruction tabs */
.instruction-tabs {
    display: flex;
    gap: 0;
    padding: 0;
    background: transparent;
    border-bottom: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

/* Кастомный выпадающий список для узких экранов */
.custom-instruction-dropdown {
    display: none;
    position: relative;
    min-width: 140px;
    z-index: 100;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background-color: #1a1a1a;
    border: none;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.dropdown-trigger:hover {
    background-color: #252525;
}

.dropdown-arrow {
    margin-left: 10px;
    color: #888;
    transition: transform 0.2s ease;
}

.custom-instruction-dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-options {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background-color: #1a1a1a;
    border: none;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: fadeInScale 0.15s ease;
}

.custom-instruction-dropdown.active .dropdown-options {
    display: block;
}

.dropdown-option {
    padding: 10px 14px;
    color: #888;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropdown-option:hover {
    background-color: #252525;
    color: #fff;
}

.dropdown-option.active {
    background-color: var(--color-accent);
    color: #fff;
}

/* Light theme for dropdown */
body.light-theme .dropdown-trigger {
    background-color: #f8f9fa;
    border: none;
    color: #1a1a1a;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

body.light-theme .dropdown-trigger:hover {
    background-color: #ffffff;
}

body.light-theme .dropdown-options {
    background-color: #ffffff;
    border: none;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

body.light-theme .dropdown-option {
    color: #666;
}

body.light-theme .dropdown-option:hover {
    background-color: #f0f0f0;
    color: #1a1a1a;
}

body.light-theme .dropdown-option.active {
    background-color: var(--color-accent);
    color: #fff;
}

/* При узкой панели - скрываем табы, показываем кастомный dropdown */
.prompt-panel.compact-tabs .instruction-tabs {
    display: none;
}

.prompt-panel.compact-tabs .custom-instruction-dropdown {
    display: block;
}

.instruction-tab {
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.instruction-tab:hover {
    color: #ccc;
}

.instruction-tab.active {
    color: var(--color-accent);
}

/* Prompt variations */
.prompt-variations-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    flex-shrink: 0;
    align-items: center;
    min-height: 34px;
}

.prompt-variation-chip {
    padding: 4px 12px;
    background: #1a1a1a;
    border: none;
    border-radius: 14px;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}

.prompt-variation-chip .chip-name {
    position: relative;
    top: -1px;
}

.prompt-variation-chip:hover {
    background: #252525;
    color: #e0e0e0;
}

.prompt-variation-chip.active {
    background: var(--color-accent);
    color: #fff;
}

.prompt-variation-chip .delete-variation {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.25);
    color: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    align-self: center;
    position: static;
    margin-left: 4px;
    margin-right: -3px;
    opacity: 0.7;
    transform: none;
}

.prompt-variation-chip .delete-variation:hover {
    opacity: 1;
    background: rgba(0,0,0,0.4);
}

.add-variation-btn {
    width: 22px;
    min-width: 22px; /* Не сжимается */
    height: 22px;
    border-radius: 50%;
    border: 1px dashed #444;
    background: transparent;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    font-size: 14px;
    line-height: 1;
}

.add-variation-btn:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

/* Instruction content container */
.instruction-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

body.user-mode .markdown-toolbar,
body.user-mode .prompt-length-info,
body.user-mode .prompt-wrapper,
body.user-mode .prompt-editor,
body.user-mode .prompt-preview {
    display: none !important;
}

/* Markdown Toolbar */
.markdown-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 6px 10px;
    background: #0F0F0F;
    flex-shrink: 0;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

.markdown-toolbar::-webkit-scrollbar {
    display: none;
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: #888;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 28px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.toolbar-btn:hover {
    background: #333;
    color: #fff;
}

.toolbar-btn:active {
    background: #444;
}

.toolbar-btn strong {
    font-weight: 700;
}

.toolbar-btn em {
    font-style: italic;
}

.toolbar-btn s {
    text-decoration: line-through;
}

.toolbar-btn-eye.state-hidden {
    color: #ff8a8a;
}

.toolbar-btn-eye svg {
    width: 16px;
    height: 16px;
    display: block;
}

.toolbar-btn-ai {
    font-size: 18px;
    line-height: 1;
}

.toolbar-btn-history {
    line-height: 1;
}

.toolbar-btn-history svg {
    width: 16px;
    height: 16px;
    display: block;
}

.toolbar-divider {
    width: 1px;
    height: 16px;
    background: #333;
    margin: 0 6px;
    flex: 0 0 auto;
}

.prompt-length-info {
    color: #7a7a7a;
    font-size: 12px;
    line-height: 1.35;
    padding: 0 12px 8px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-length-info.is-over {
    color: #ff6f6f;
}

body.light-theme .toolbar-btn-eye.state-hidden {
    color: #d32f2f;
}

body.light-theme .prompt-length-info {
    color: #777;
}

body.light-theme .prompt-length-info.is-over {
    color: #d32f2f;
}

.prompt-panel.compact-toolbar .markdown-toolbar {
    flex-wrap: wrap;
    overflow-x: hidden;
    overflow-y: auto;
    align-items: flex-start;
    row-gap: 4px;
}

.prompt-panel.compact-toolbar .toolbar-divider {
    display: none;
}

.prompt-panel.compact-toolbar .toolbar-btn {
    min-width: 24px;
    height: 24px;
    padding: 3px 6px;
    font-size: 11px;
}

.prompt-panel.compact-toolbar .toolbar-btn-ai {
    font-size: 15px;
}

.prompt-panel.compact-toolbar .toolbar-btn-history {
    font-size: inherit;
}

.prompt-panel.compact-toolbar .toolbar-btn-history svg {
    width: 14px;
    height: 14px;
}

.prompt-panel.compact-toolbar .prompt-length-info {
    padding: 0 10px 6px;
    font-size: 11px;
}

.instruction-editor {
    display: none;
}

.instruction-editor.active {
    display: flex;
    flex: 1;
}

.prompt-wrapper.instruction-editor.active {
    display: flex;
}

.prompt-editor {
    flex: 1;
    padding: 16px 20px;
    background: #0F0F0F;
    border: none;
    color: #e0e0e0;
    font-size: 14px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    resize: none;
    outline: none;
    line-height: 1.6;
    max-width: 100%;
    box-sizing: border-box;
    transition: background 0.2s;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #444 #0F0F0F;
    min-height: 0;
}

.prompt-editor:focus {
    background: #0F0F0F;
}

.prompt-editor::placeholder {
    color: #666;
}

/* Scrollbars for Prompt Editor and Preview */
.prompt-editor, .prompt-preview {
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
}

.prompt-editor::-webkit-scrollbar,
.prompt-preview::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.prompt-editor::-webkit-scrollbar-track,
.prompt-preview::-webkit-scrollbar-track {
    background: transparent;
}

.prompt-editor::-webkit-scrollbar-thumb,
.prompt-preview::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 3px;
}

.prompt-editor::-webkit-scrollbar-thumb:hover,
.prompt-preview::-webkit-scrollbar-thumb:hover {
    background-color: #555;
}

/* Light Theme Scrollbars */
body.light-theme .prompt-editor,
body.light-theme .prompt-preview {
    scrollbar-color: #ccc transparent;
}

body.light-theme .prompt-editor::-webkit-scrollbar-thumb,
body.light-theme .prompt-preview::-webkit-scrollbar-thumb {
    background-color: #ccc;
}

body.light-theme .prompt-editor::-webkit-scrollbar-thumb:hover,
body.light-theme .prompt-preview::-webkit-scrollbar-thumb:hover {
    background-color: #aaa;
}

.prompt-editor.drag-over,
.prompt-preview.drag-over {
    border: 2px dashed var(--color-accent) !important;
    background: #1a1a2e !important;
}

/* Prompt wrapper for edit/preview modes */
.prompt-wrapper {
    flex-direction: row;
    min-height: 0;
    position: relative;
    gap: 0;
    overflow: hidden;
}

/* ВАЖНО: скрываем неактивные вкладки */
.prompt-wrapper.instruction-editor {
    display: none;
}

.prompt-wrapper.instruction-editor.active {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Edit mode: только редактор (textarea) */
.prompt-wrapper .prompt-editor {
    display: block;
    flex: 1;
    width: 100%;
}

.prompt-wrapper .prompt-preview {
    display: none;
}

/* Preview/WYSIWYG mode: только preview (editable) */
.prompt-wrapper.preview-mode .prompt-editor {
    display: none;
}

.prompt-wrapper.preview-mode .prompt-preview {
    display: block;
    flex: 1;
    width: 100%;
    cursor: text;
}

/* Markdown Preview Styles (WYSIWYG editable) */
.prompt-preview {
    flex: 1;
    padding: 16px 20px;
    background: #0F0F0F;
    color: #e0e0e0;
    font-size: 14px;
    line-height: 1.7;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #444 #0F0F0F;
    outline: none;
    max-width: 100%;
    box-sizing: border-box;
    min-height: 0;
    cursor: text;
}


/* Selection styling in preview */
.prompt-preview::selection,
.prompt-preview *::selection {
    background: rgba(127, 150, 255, 0.3); /* Keep rgba for opacity */
}

/* Old preview scrollbar styles removed */

.prompt-preview h1 {
    font-size: 2.1em;
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #333;
}

.prompt-preview h2 {
    font-size: 1.65em;
    font-weight: 700;
    line-height: 1.25;
    color: #f0f0f0;
    margin: 24px 0 12px 0;
}

.prompt-preview h3 {
    font-size: 1.35em;
    font-weight: 700;
    line-height: 1.3;
    color: #e8e8e8;
    margin: 20px 0 10px 0;
}

.prompt-preview h4 {
    font-size: 1.05em;
    font-weight: 600;
    color: #ddd;
    margin: 16px 0 8px 0;
}

.prompt-preview p {
    margin: 0 0 12px 0;
}

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

.prompt-preview li {
    margin: 6px 0;
}

.prompt-preview li::marker {
    color: var(--color-accent);
}

.prompt-preview strong {
    font-weight: 700;
    color: #fff;
}

.prompt-preview em {
    font-style: italic;
    color: #ccc;
}

.prompt-preview code {
    font-family: inherit;
    font-size: inherit;
    background: transparent;
    padding: 0;
    border-radius: 0;
    border: none;
    color: inherit;
    white-space: pre-wrap;
    word-break: break-word;
}

.prompt-preview pre {
    margin: 12px 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
}

.prompt-preview pre code {
    display: block;
    padding: 0;
    background: none;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
}

/* Убираем подсветку синтаксиса в промпте */
.prompt-preview pre code,
.prompt-preview pre code *,
.prompt-preview code,
.prompt-preview code * {
    color: inherit !important;
    background: transparent !important;
}

.prompt-preview blockquote {
    margin: 16px 0;
    padding: 12px 16px;
    background: var(--color-bg-secondary);
    border-left: 3px solid var(--color-accent);
    color: #bbb;
    font-style: italic;
}

.prompt-preview hr {
    border: none;
    border-top: 1px solid #333;
    margin: 24px 0;
}

.prompt-preview a {
    color: var(--color-accent);
    text-decoration: none;
}

.prompt-preview a:hover {
    text-decoration: underline;
}

.prompt-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.prompt-preview th,
.prompt-preview td {
    border: 1px solid #333;
    padding: 10px 12px;
    text-align: left;
}

.prompt-preview th {
    background: #1a1a1a;
    color: #fff;
    font-weight: 600;
}

.prompt-preview tr:nth-child(even) {
    background: #141414;
}

/* Preview button - hidden by default, shown on header hover */
/* Responsive design */
@media (max-width: 1024px) {
    .message {
        max-width: 90%;
    }
    
    .panel-header h2 {
        font-size: 16px;
    }
}

/* Узкие экраны - одна колонка с табами */
@media (max-width: 1024px) {
    .mobile-tabs {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 10px;
    }

    .mobile-tab {
        flex: 0 1 calc(50% - 12px);
        max-width: 128px;
    }
    
    .panels-container {
        position: relative;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }
    
    .panel {
        display: none;
        width: 100%;
        height: 100%;
        flex: none !important;
        min-height: 0;
    }
    
    .panel.active {
        display: flex !important;
        flex-direction: column;
    }
    
    .resize-handle {
        display: none;
    }
    
    .chat-panel, .prompt-panel {
        min-width: 0;
        max-height: 100%;
    }
    
    .chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding-bottom: 80px;
    }
    
    .chat-input-container {
        flex-shrink: 0;
        padding: 0 16px 12px;
        position: sticky;
        bottom: 0;
        background: #0F0F0F;
        z-index: 100;
    }
}

@media (max-width: 768px) {
    .mobile-tabs {
        padding: 8px 72px;
        gap: 10px;
        align-items: center;
    }

    .panel-header {
        padding: 14px 16px;
        flex-shrink: 0;
        min-height: 64px;
        height: 64px;
    }

    #instructionsPanel .panel-header {
        padding-left: 0;
    }

    #instructionsPanel.compact-tabs .panel-header {
        padding-left: 12px;
    }
    
    .panel-header h2 {
        font-size: 16px;
    }
    
    .btn-rate {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .mobile-tab {
        font-size: 13px;
        padding: 0 10px;
        min-height: 44px;
        height: 44px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        max-width: 112px;
    }
    
    .chat-input-container {
        padding: 0 12px 10px;
        position: sticky;
        bottom: 8px;
        background: #0F0F0F;
    }
    
    .chat-messages {
        padding-bottom: 20px;
    }
    
    .input-wrapper {
        min-width: 0;
    }

    .input-actions {
        bottom: 8px;
        right: 8px;
    }
    
    #userInput {
        min-height: 24px;
        font-size: 14px;
    }
    
    .btn-send, .btn-voice-inline {
        flex-shrink: 0;
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    .btn-icon {
        width: 28px;
        height: 28px;
    }
    
    .mobile-tab {
        font-size: 12px;
        padding: 0 8px;
        min-height: 44px;
        height: 44px;
        border-radius: 10px;
        max-width: 108px;
    }
}

/* Manager name input in header */
.manager-name-container {
    display: flex;
    align-items: center;
    flex: 1;
}

.manager-name-container input {
    background: #1a1a1a;
    border: none;
    border-radius: 6px;
    color: #e0e0e0;
    padding: 6px 10px;
    font-size: 13px;
    width: 140px;
    transition: border-color 0.2s, background 0.2s;
}

.manager-name-container input:focus {
    outline: none;
    border-color: var(--color-accent);
    background: #222;
}

.manager-name-container input::placeholder {
    color: #555;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    padding: 20px; /* Добавил отступы */
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

#settingsModal {
    align-items: flex-start;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

#settingsModal .settings-panel {
    margin: 0 auto;
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-content {
    background: #1a1a1a;
    border: none; /* Убрана обводка */
    border-radius: 12px;
    padding: 32px 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-content h3 {
    color: #fff;
    margin: 0 0 12px 0;
    font-size: 22px;
    font-weight: 600;
}

.modal-content p {
    color: #888;
    margin: 0 0 20px 0;
    font-size: 14px;
}

.modal-content input {
    width: 100%;
    background: #1a1a1a;
    border: none;
    border-radius: 8px;
    color: #e0e0e0;
    padding: 12px 16px;
    font-size: 16px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.modal-content input:focus {
    outline: none;
}

.modal-content input::placeholder {
    color: #555;
}

#nameModal {
    position: fixed;
    inset: 0;
    width: 100dvw;
    height: 100dvh;
    padding: 0;
    background: rgba(8, 8, 10, 0.96);
    align-items: stretch;
    justify-content: stretch;
}

#nameModal .auth-modal-content {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    border-radius: 0 !important;
    margin: 0;
    padding: clamp(20px, 4vw, 44px);
    transform: none;
    transition: none;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#nameModalStep1 {
    width: min(720px, 100%);
    margin: 0 auto;
    padding: min(6vh, 48px) 0 20px;
}

.auth-mail-help {
    margin: 12px 0 0;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    background: #151515;
    overflow: hidden;
}

.auth-mail-help summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 14px;
    color: #c9c9c9;
    font-size: 14px;
    font-weight: 600;
    user-select: none;
}

.auth-mail-help summary::-webkit-details-marker {
    display: none;
}

.auth-mail-help summary::after {
    content: '▾';
    float: right;
    color: #8f8f8f;
    transition: transform 0.2s ease;
}

.auth-mail-help:not([open]) summary::after {
    transform: rotate(-90deg);
}

.auth-mail-help img {
    width: 100%;
    height: auto;
    display: block;
    border-top: 1px solid #242424;
    border-bottom: 1px solid #242424;
}

.auth-mail-help-caption {
    margin: 10px 12px 12px !important;
    color: #9b9b9b !important;
    font-size: 12px !important;
    line-height: 1.4;
    text-align: left;
}

#nameModal .auth-modal-content input {
    background: #1a1a1a !important;
    border: 1px solid #2a2a2a;
    color: #e0e0e0;
}

#nameModal .auth-modal-content input:focus {
    border-color: #3a3a3a;
}

#nameModal .auth-modal-content input::placeholder {
    color: #666;
}

#nameModal .auth-modal-content input:-webkit-autofill,
#nameModal .auth-modal-content input:-webkit-autofill:hover,
#nameModal .auth-modal-content input:-webkit-autofill:focus,
#nameModal .auth-modal-content input:-webkit-autofill:active {
    -webkit-text-fill-color: #e0e0e0 !important;
    -webkit-box-shadow: 0 0 0 1000px #1a1a1a inset !important;
    box-shadow: 0 0 0 1000px #1a1a1a inset !important;
    border: 1px solid #2a2a2a !important;
    caret-color: #e0e0e0;
    transition: background-color 99999s ease-in-out 0s !important;
}

#modalLoginInput,
#modalLoginInput:-webkit-autofill,
#modalLoginInput:-webkit-autofill:hover,
#modalLoginInput:-webkit-autofill:focus,
#modalLoginInput:-webkit-autofill:active {
    background-color: #1a1a1a !important;
}

.auth-password-wrap {
    position: relative;
    margin-bottom: 20px;
}

.auth-password-wrap input {
    margin-bottom: 0;
    padding-right: 46px;
}

#modalPasswordInput::-ms-reveal,
#modalPasswordInput::-ms-clear {
    display: none;
}

#modalPasswordInput::-webkit-credentials-auto-fill-button,
#modalPasswordInput::-webkit-contacts-auto-fill-button,
#modalPasswordInput::-webkit-caps-lock-indicator {
    visibility: hidden;
    display: none !important;
    pointer-events: none;
}

.auth-password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #8d8d8d;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 3;
    -webkit-tap-highlight-color: transparent;
}

.auth-password-toggle svg {
    width: 19px;
    height: 19px;
}

.auth-password-toggle .icon-eye,
.auth-password-toggle .icon-eye-off {
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-password-toggle:hover {
    color: #f0f0f0;
    background: rgba(255, 255, 255, 0.06);
}

.auth-password-toggle:focus-visible {
    outline: 1px solid #4a4a4a;
    outline-offset: 1px;
}

.auth-password-toggle .icon-eye-off {
    display: none;
}

.auth-password-toggle.is-visible .icon-eye {
    display: none;
}

.auth-password-toggle.is-visible .icon-eye-off {
    display: block;
}

.btn-modal-submit {
    width: 100%;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.btn-modal-submit:hover {
    background: var(--color-accent-hover);
}

.btn-modal-submit:active {
    transform: scale(0.98);
}

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

.btn-role {
    background: #1a1a1a;
    color: #888;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-role:hover {
    background: #252525;
    color: #ccc;
}

.btn-role.selected {
    background: var(--color-accent);
    color: #fff;
}

/* Floating Settings Button */
/* Плавающая кнопка очистки чата (слева) */
.btn-clear-floating {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 2000;
    background: transparent;
    border: none !important;
    color: #888;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-clear-floating:hover {
    color: #fff;
    background: transparent !important;
}

body.light-theme .btn-clear-floating {
    color: #999;
}

body.light-theme .btn-clear-floating:hover {
    color: #333;
}

/* Плавающая кнопка настроек (справа) */
.btn-settings-floating {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 2000;
    background: transparent;
    border: none !important;
    color: #888;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-settings-floating:hover {
    color: #fff;
    background: transparent !important;
}

body.light-theme .btn-settings-floating {
    color: #666;
}

body.light-theme .btn-settings-floating:hover {
    color: #333;
}

#nameModal.active ~ .btn-clear-floating,
#nameModal.active ~ .btn-settings-floating {
    display: none !important;
    pointer-events: none !important;
}

#settingsModal.active ~ .btn-clear-floating {
    display: none !important;
    pointer-events: none !important;
}

/* Мобильная версия - кнопки в одной линии с табами */
@media (max-width: 768px) {
    .btn-clear-floating {
        top: 8px;
        left: 8px;
        width: 56px;
        height: 56px;
        padding: 0;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .btn-settings-floating {
        top: 8px;
        right: 8px;
        width: 56px;
        height: 56px;
        padding: 0;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .btn-clear-floating svg,
    .btn-settings-floating svg {
        width: 26px;
        height: 26px;
    }
}

/* Убираем обводку у всех иконок-кнопок */
.btn-icon {
    border: none !important;
    background: transparent;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.light-theme .btn-icon:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-icon-small {
    background: transparent;
    border: 1px solid #444;
    color: #888;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon-small:hover {
    background: #2a2a2a;
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* ========== NEW SETTINGS PANEL ========== */
.settings-panel {
    background: #1a1a1a;
    border-radius: 12px;
    padding: 20px 24px;
    width: min(940px, calc(100vw - 32px));
    min-width: 320px;
    max-width: 940px;
}

.settings-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
    line-height: 1.25;
}

.account-row {
    align-items: flex-start;
}

.account-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.account-line {
    color: #8f8f8f;
    font-size: 13px;
    line-height: 1.3;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: baseline;
}

#accountLoginValue {
    color: #d9d9d9;
    font-weight: 600;
    letter-spacing: 0.01em;
    display: inline-block;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.settings-row:last-child {
    margin-bottom: 0;
}

.settings-section {
    margin-top: 12px;
}

.changes-section {
    margin-top: 16px;
}

.changes-header {
    font-size: 13px;
    color: #888;
    margin-bottom: 10px;
}

.changes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
}

.change-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #222;
    border-radius: 8px;
    padding: 8px 10px;
    color: #ccc;
    font-size: 12px;
}

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

.change-title {
    font-weight: 600;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.change-time {
    color: #777;
    font-size: 11px;
}

.btn-restore {
    background: transparent;
    border: 1px solid #444;
    color: #aaa;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.btn-restore:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.changes-empty {
    color: #666;
    font-size: 12px;
    padding: 6px 2px;
}

.settings-label {
    color: #888;
    font-size: 14px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    flex: 0 0 88px;
    width: 88px;
    margin-top: 2px;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 22px;
    display: flex;
    align-items: center;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: 0.3s;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px; /* Чуть увеличил отступ */
}

.slider-icon {
    color: #888; /* Цвет неактивных иконок */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: color 0.3s;
    width: 18px; /* Совпадает с размером круга */
    height: 18px;
}

.slider-icon svg {
    width: 12px;
    height: 12px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    top: 2px;
    background-color: #fff;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    z-index: 2;
}

input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Активная иконка (под белым кругом) */
input:not(:checked) + .toggle-slider .moon,
input:checked + .toggle-slider .sun {
    color: #1a1a1a;
}

/* Неактивная иконка */
input:checked + .toggle-slider .moon,
input:not(:checked) + .toggle-slider .sun {
    color: #666;
}

/* Стили для светлой темы */
body.light-theme .toggle-slider .moon,
body.light-theme .toggle-slider .sun {
    color: #999;
}

body.light-theme input:not(:checked) + .toggle-slider .moon,
body.light-theme input:checked + .toggle-slider .sun {
    color: #1a1a1a;
}

/* Роль */
.role-row {
    align-items: center;
}

.role-row .btn-change {
    margin-left: 0;
}

.voice-config-row {
    align-items: flex-start;
}

.voice-config-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.voice-config-note {
    color: #777;
    font-size: 12px;
    line-height: 1.35;
}

.voice-config-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.voice-config-actions .btn-change,
.voice-config-actions .btn-cancel {
    height: 30px;
    padding: 0 12px;
    border-radius: 6px;
}

.voice-config-actions .btn-cancel {
    flex: 0 0 auto;
    border: none;
}

.role-text {
    color: #ccc;
    font-size: 14px;
    display: flex;
    align-items: center;
    height: 24px; /* Тот же рост что и у кнопки */
}

.btn-change {
    background: transparent;
    border: none;
    color: #666;
    font-size: 13px;
    cursor: pointer;
    padding: 0 8px;
    border-radius: 4px;
    transition: all 0.2s;
    height: 24px;
    display: flex;
    align-items: center;
    margin-left: 4px; /* Небольшой отступ от текста роли */
}

.btn-change:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.btn-danger-subtle {
    color: #ff7d7d;
}

.btn-danger-subtle:hover {
    color: #ffd0d0;
    background: rgba(255, 64, 64, 0.12);
}

.btn-danger-subtle:disabled {
    opacity: 0.55;
    cursor: default;
}

body.light-theme .btn-change:hover {
    color: #333;
}

body.light-theme .voice-config-actions .btn-cancel {
    background: #e6e6e6;
    color: #555;
}

body.light-theme .voice-config-actions .btn-cancel:hover {
    background: #d7d7d7;
}

body.light-theme .btn-danger-subtle {
    color: #c53030;
}

body.light-theme .btn-danger-subtle:hover {
    color: #fff;
    background: rgba(197, 48, 48, 0.9);
}

/* Theme & Color Section */
.theme-color-section {
    margin-bottom: 20px;
}

.theme-color-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.color-presets {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: 0;
}

.color-preset {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.color-preset.active {
    box-shadow: 0 0 0 2px #1a1a1a, 0 0 0 3px #fff;
}

body.light-theme .color-preset.active {
    box-shadow: 0 0 0 2px #fff, 0 0 0 3px #888;
}

/* More Colors Button and Popup */
.more-colors-container {
    position: relative;
}

.more-colors-btn {
    width: 20px;
    height: 20px;
    border: 1px dashed #555;
    border-radius: 50%;
    background: transparent;
    color: #888;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.more-colors-btn:hover {
    border-color: #888;
    color: #ccc;
}

body.light-theme .more-colors-btn {
    border-color: #ccc;
    color: #888;
}

body.light-theme .more-colors-btn:hover {
    border-color: #999;
    color: #666;
}

.more-colors-popup {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #1a1a1a;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 1000;
    width: 200px;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    display: none;
}

.more-colors-popup.active {
    display: grid;
}

body.light-theme .more-colors-popup {
    background: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.color-option {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    transition: transform 0.1s;
}

.color-option:hover {
    transform: scale(1.2);
}

/* Name Input */
.name-input {
    background: #2a2a2a;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    color: #fff;
    font-size: 14px;
    outline: none;
    width: auto;
    min-width: 100px;
    transition: background 0.2s;
}

.account-block .name-input {
    width: 100%;
    min-width: 0;
}

.name-input:focus {
    background: #333;
}

.name-input::placeholder {
    color: #666;
}

/* Password Section */
.password-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #333;
}

.password-input {
    width: 100%;
    background: #2a2a2a;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    color: #fff;
    font-size: 14px;
    outline: none;
    margin-bottom: 8px;
}

.error-text {
    color: #ff5555;
    font-size: 12px;
    margin: 4px 0;
}

.password-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.btn-cancel, .btn-confirm {
    flex: 1;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.btn-cancel {
    background: #333;
    color: #aaa;
}

.btn-cancel:hover {
    background: #444;
}

.btn-confirm {
    background: var(--color-accent);
    color: #fff;
}

.btn-confirm:hover {
    background: var(--color-accent-hover);
}

/* Export Row */
.export-row {
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px; /* Дополнительный отступ сверху */
}

.admin-accordion {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #333;
}

.admin-accordion-trigger {
    list-style: none;
    cursor: pointer;
    color: #bdbdbd;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    line-height: 1.2;
    padding: 0;
}

.admin-accordion-trigger::-webkit-details-marker {
    display: none;
}

.admin-accordion-trigger::after {
    content: '▾';
    color: #888;
    transition: transform 0.2s ease;
}

.admin-accordion:not([open]) .admin-accordion-trigger::after {
    transform: rotate(-90deg);
}

.admin-panel {
    margin-top: 12px;
    padding-top: 0;
    border-top: none;
}

.admin-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.admin-panel-title {
    color: #bdbdbd;
    font-size: 13px;
    letter-spacing: 0.01em;
}

.admin-table-wrap {
    max-height: 220px;
    overflow: auto;
    border-radius: 8px;
    background: #222;
}

.admin-users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.admin-users-table th,
.admin-users-table td {
    padding: 8px 10px;
    text-align: left;
    color: #c8c8c8;
    border-bottom: 1px solid #2f2f2f;
    vertical-align: middle;
}

.admin-users-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #252525;
    color: #8f8f8f;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.admin-users-table tr:last-child td {
    border-bottom: none;
}

.admin-empty {
    color: #666 !important;
    text-align: center !important;
}

.admin-role-select {
    width: 100%;
    min-width: 82px;
    background: #2c2c2c;
    border: none;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 12px;
    padding: 6px 8px;
    outline: none;
    cursor: pointer;
}

.admin-time {
    white-space: nowrap;
    color: #b3b3b3;
}

.admin-access-source {
    color: #a7a7a7;
    white-space: nowrap;
}

.admin-invite-form {
    display: grid;
    grid-template-columns: 1fr 112px auto;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}

.admin-invite-input,
.admin-invite-days {
    width: 100%;
    background: #2c2c2c;
    border: none;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 12px;
    padding: 8px 10px;
    outline: none;
    box-sizing: border-box;
}

.admin-invite-days-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    background: #2c2c2c;
    border-radius: 6px;
    padding: 0 10px;
    box-sizing: border-box;
}

.admin-invite-days {
    width: 48px;
    min-width: 0;
    padding: 8px 0;
    border-radius: 0;
    background: transparent;
    text-align: center;
}

.admin-invite-days-unit {
    color: #8f8f8f;
    font-size: 12px;
    white-space: nowrap;
}

.admin-invite-btn {
    height: 32px;
    border-radius: 6px;
}

.admin-access-status {
    font-weight: 600;
    white-space: nowrap;
}

.admin-access-status.is-active {
    color: #8fcb8f;
}

.admin-access-status.is-blocked {
    color: #e19393;
}

.admin-muted {
    color: #7d7d7d !important;
}

.admin-users-table td:last-child {
    white-space: nowrap;
}

@media (max-width: 820px) {
    .admin-invite-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    #settingsModal {
        align-items: center;
        justify-content: center;
        padding: max(10px, env(safe-area-inset-top, 0px) + 6px) 10px max(10px, env(safe-area-inset-bottom, 0px) + 6px);
    }

    .settings-panel {
        width: calc(100vw - 20px);
        min-width: 0;
        max-width: none;
        padding: 16px;
    }

    #settingsModal .settings-panel {
        margin: 0;
        max-height: min(92dvh, calc(100dvh - 20px));
    }

    .settings-row {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 16px;
    }

    .settings-label {
        flex: 0 0 auto;
        width: auto;
        margin-top: 0;
    }

    .account-block {
        width: 100%;
    }
}

.export-dropdown {
    position: relative;
}

.btn-export {
    background: #2a2a2a;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-export:hover {
    color: #fff;
}

/* Light Theme */
body.light-theme .settings-panel {
    background: #fff;
}

body.light-theme .settings-label {
    color: #666;
}

body.light-theme .theme-icon-svg {
    color: #999;
}

body.light-theme .toggle-slider {
    background-color: #e0e0e0;
}

body.light-theme .toggle-slider:before {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body.light-theme .slider-icon {
    color: #999;
}

body.light-theme input:checked + .toggle-slider {
    background-color: #e0e0e0;
}

body.light-theme input:not(:checked) + .toggle-slider .moon {
    color: #1a1a1a;
}

body.light-theme input:checked + .toggle-slider .sun {
    color: #1a1a1a;
}

body.light-theme .name-input {
    background: #f5f5f5;
    color: #1a1a1a;
}

body.light-theme .auth-mail-help {
    background: #fafafa;
    border-color: #dddddd;
}

body.light-theme .auth-mail-help summary {
    color: #303030;
}

body.light-theme .auth-mail-help summary::after {
    color: #7a7a7a;
}

body.light-theme .auth-mail-help img {
    border-top-color: #e8e8e8;
    border-bottom-color: #e8e8e8;
}

body.light-theme .auth-mail-help-caption {
    color: #5d5d5d !important;
}

body.light-theme .name-input::placeholder {
    color: #999;
}

body.light-theme .account-line {
    color: #747474;
}

body.light-theme #accountLoginValue {
    color: #262626;
}

body.light-theme .role-text {
    color: #1a1a1a;
}

body.light-theme .btn-change {
    color: #888;
}

body.light-theme .btn-change:hover {
    color: #000;
    background: rgba(0, 0, 0, 0.05);
}

body.light-theme .password-section {
    border-color: #eee;
}

body.light-theme .password-input {
    background: #f5f5f5;
    color: #1a1a1a;
}

body.light-theme .btn-cancel {
    background: #eee;
    color: #666;
}

body.light-theme .btn-export {
    background: #f5f5f5;
    color: #666;
}

body.light-theme .btn-export:hover {
    color: #333;
}

body.light-theme .admin-accordion {
    border-color: #ececec;
}

body.light-theme .admin-accordion-trigger {
    color: #666;
}

body.light-theme .admin-accordion-trigger::after {
    color: #777;
}

body.light-theme .admin-panel {
    border-color: transparent;
}

body.light-theme .admin-panel-title {
    color: #666;
}

body.light-theme .admin-table-wrap {
    background: #f7f7f7;
}

body.light-theme .admin-users-table th {
    background: #efefef;
    color: #777;
}

body.light-theme .admin-users-table th,
body.light-theme .admin-users-table td {
    color: #333;
    border-bottom-color: #e5e5e5;
}

body.light-theme .admin-role-select {
    background: #ffffff;
    color: #222;
    border: 1px solid #ddd;
}

body.light-theme .admin-invite-input,
body.light-theme .admin-invite-days {
    background: #ffffff;
    color: #222;
    border: 1px solid #ddd;
}

body.light-theme .admin-invite-days-wrap {
    background: #ffffff;
    border: 1px solid #ddd;
}

body.light-theme .admin-invite-days {
    border: none;
}

body.light-theme .admin-invite-days-unit {
    color: #666;
}

body.light-theme .admin-time {
    color: #666;
}

body.light-theme .admin-access-source {
    color: #666;
}

body.light-theme .admin-access-status.is-active {
    color: #2f7a38;
}

body.light-theme .admin-access-status.is-blocked {
    color: #b23b3b;
}

body.light-theme .admin-muted {
    color: #8f8f8f !important;
}

body.light-theme .change-item {
    background: #f5f5f5;
    color: #333;
}

body.light-theme .change-title {
    color: #1a1a1a;
}

body.light-theme .change-time {
    color: #888;
}

body.light-theme .btn-restore {
    border-color: #ddd;
    color: #666;
}

body.light-theme .btn-restore:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* Hide old export buttons - moved to settings */
#exportChat,
#exportCurrentPrompt {
    display: none !important;
}

/* Old btn-export-settings removed */

/* AI Improve Button */
.btn-ai-improve {
    background: transparent !important;
    color: var(--color-accent) !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    transition: none !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
}

.btn-ai-improve span {
    position: relative;
    top: -4px;
}

.btn-ai-improve:hover,
.btn-ai-improve:active,
.btn-ai-improve:focus,
body.light-theme .btn-ai-improve,
body.light-theme .btn-ai-improve:hover,
body.light-theme .btn-ai-improve:active,
body.light-theme .btn-ai-improve:focus {
    background: transparent !important;
    color: var(--color-accent) !important;
    border: none !important;
    transform: none !important;
    outline: none !important;
    box-shadow: none !important;
}

elevenlabs-convai#elevenlabsConvaiWidget {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    display: block !important;
}

elevenlabs-convai[data-voice-hidden="true"] {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

elevenlabs-convai[data-voice-hidden="false"] {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    position: fixed !important;
    z-index: 1000001 !important;
}

.voice-mode-screen {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    background: var(--color-bg-primary);
}

.voice-mode-actions {
    position: fixed;
    top: max(14px, env(safe-area-inset-top, 0px) + 8px);
    left: max(14px, env(safe-area-inset-left, 0px) + 8px);
    z-index: 1000002;
    max-width: min(92vw, 720px);
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
}

.voice-mode-actions[hidden] {
    display: none !important;
}

.voice-mode-actions-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.voice-mode-exit-btn,
.voice-mode-rate-btn {
    z-index: 1000002;
    border: 1px solid var(--color-border-light);
    background: rgba(18, 18, 18, 0.9);
    color: var(--color-text-primary);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}

.voice-mode-exit-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.voice-mode-rate-btn {
    background: color-mix(in srgb, var(--color-accent) 28%, #121212);
    border-color: color-mix(in srgb, var(--color-accent) 52%, var(--color-border-light));
}

.voice-mode-rate-btn:hover {
    border-color: var(--color-accent);
    background: color-mix(in srgb, var(--color-accent) 36%, #121212);
}

body.light-theme .voice-mode-exit-btn,
body.light-theme .voice-mode-rate-btn {
    background: rgba(255, 255, 255, 0.95);
}

.voice-mode-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: min(86vw, 640px);
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--color-border-light);
    background: rgba(18, 18, 18, 0.9);
    color: var(--color-text-secondary);
    font-size: 13px;
    line-height: 1.35;
}

.voice-mode-status[data-state="ready"] {
    color: var(--color-accent);
    border-color: color-mix(in srgb, var(--color-accent) 58%, var(--color-border-light));
}

.voice-mode-status[data-state="waiting"] {
    color: #ffd27b;
    border-color: rgba(255, 180, 60, 0.6);
}

.voice-mode-status[data-state="listening"] {
    color: var(--color-text-primary);
    border-color: rgba(255, 255, 255, 0.42);
}

.voice-mode-status[data-state="error"] {
    color: #ff8a8a;
    border-color: rgba(255, 70, 70, 0.65);
}

body.light-theme .voice-mode-status {
    background: rgba(255, 255, 255, 0.96);
}

body.light-theme .voice-mode-status[data-state="listening"] {
    border-color: rgba(0, 0, 0, 0.35);
}

body.voice-mode-active {
    overflow: hidden;
}

body.voice-mode-active > :not(#voiceModeScreen):not(#voiceModeActions):not(#elevenlabsConvaiWidget) {
    visibility: hidden !important;
    pointer-events: none !important;
}

/* AI Improve Modal */
.ai-improve-modal {
    max-width: 500px;
    width: min(90vw, 500px);
    position: relative;
    border: none;
}

.ai-improve-modal h3 {
    font-size: 20px;
}

.prompt-history-modal {
    max-width: 560px;
    width: min(92vw, 560px);
    position: relative;
    border: none;
    text-align: left;
}

.prompt-history-modal h3 {
    font-size: 19px;
    margin-bottom: 14px;
    padding-right: 24px;
}

.prompt-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: min(60vh, 420px);
    overflow-y: auto;
    padding-right: 4px;
}


.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
}

.modal-close:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.ai-improve-modal textarea {
    width: 100%;
    background: #0f0f0f;
    border: none;
    border-radius: 8px;
    color: #e0e0e0;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 20px;
    box-sizing: border-box;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.2s;
}

.ai-improve-modal textarea:focus {
    outline: none;
}

.ai-improve-modal textarea::placeholder {
    color: #555;
}

/* AI Modal - светлая тема */
body.light-theme .ai-improve-modal textarea {
    background: #f5f5f5 !important;
    color: #1a1a1a !important;
    border: none !important;
}

body.light-theme .ai-improve-modal textarea::placeholder {
    color: #999 !important;
}

body.light-theme .ai-improve-modal .btn-modal-cancel {
    background: #e0e0e0 !important;
    color: #333 !important;
}

body.light-theme .ai-improve-modal .btn-modal-cancel:hover {
    background: #d0d0d0 !important;
}

body.light-theme .ai-improve-actions .btn-ai-apply-current {
    background: #e8e8e8;
    color: #333;
}

body.light-theme .ai-improve-actions .btn-ai-apply-current:hover {
    background: #dcdcdc;
}

body.light-theme .prompt-history-modal {
    background: #fff;
}

.ai-improve-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.ai-improve-actions .btn-modal-submit {
    width: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-accent);
    flex: 1 1 160px;
    max-width: 100%;
}

.ai-improve-actions .btn-ai-apply-current {
    background: #2f2f2f;
    color: #d7d7d7;
}

.ai-improve-actions .btn-modal-cancel {
    flex: 1 1 160px;
    max-width: 100%;
}

.ai-improve-actions .btn-modal-submit:hover {
    background: var(--color-accent-hover);
}

.ai-improve-actions .btn-ai-apply-current:hover {
    background: #3a3a3a;
}

.ai-improve-actions .btn-modal-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-modal-cancel {
    background: #333;
    color: #ccc;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-modal-cancel:hover {
    background: #444;
}

/* Diff View */
.diff-view {
    background: #0f0f0f;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Non-monospace */
    white-space: normal; /* Allow wrapping */
    text-align: left;
    font-size: 14px;
    line-height: 1.6;
    color: #e0e0e0;
    border: 1px solid #333;
}

div.diff-added, div.diff-removed {
    display: block;
    padding: 12px 16px 12px 35px; /* Увеличил отступ слева, чтобы цифры списков не наезжали на границу */
    margin: 16px 0;
    border-left: 4px solid;
    position: relative;
}

.diff-view ol, .diff-view ul {
    padding-left: 0; /* Убираем лишний отступ у списков, так как он есть у родителя */
    margin: 8px 0;
}

.diff-view li {
    margin-bottom: 8px;
    list-style-position: inside; /* Цифры теперь внутри блока текста */
}

div.diff-added {
    border-left-color: #8ce65e;
}

div.diff-removed {
    border-left-color: #ff6b6b;
}

.diff-added {
    background-color: rgba(40, 167, 69, 0.25);
    color: #8ce65e;
    text-decoration: none;
    padding: 2px 4px;
    border-radius: 4px;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

.diff-removed {
    background-color: rgba(220, 53, 69, 0.25);
    color: #ff6b6b;
    text-decoration: line-through;
    opacity: 0.8;
    padding: 2px 4px;
    border-radius: 4px;
    margin-right: 4px;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

.btn-loader .spinner {
    animation: spin 1s linear infinite;
}

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

@media (max-width: 768px) {
    .manager-name-container {
        display: none;
    }
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 4px;
    display: none;
    flex-direction: column;
    z-index: 1000;
    min-width: 80px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-item {
    background: transparent;
    border: none;
    color: #e0e0e0;
    padding: 8px 12px;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    width: 100%;
}

.dropdown-item:hover {
    background: #333;
    color: #fff;
}

.dropdown-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
}

.dropdown-item-icon svg {
    opacity: 0.8;
}

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

.dropdown-divider {
    height: 1px;
    background: #444;
    margin: 4px 0;
}

/* Copy notification toast */
.copy-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
}

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