/* ========================================================
   TRANSCRIPTION.CSS — Вкладка транскрипции
   ======================================================== */

/* ========== GRID ========== */
.top-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 0;
    padding-bottom: 0;
}
@media (max-width: 768px) {
    .top-grid { grid-template-columns: 1fr; }
}

/* ========== DROP ZONE ========== */
.drop-zone {
    border: 2px dashed rgba(167, 139, 250, 0.35);
    border-radius: 16px;
    padding: 40px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 12px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.06) 0%, rgba(56, 139, 253, 0.04) 50%, rgba(139, 92, 246, 0.06) 100%);
    position: relative;
    overflow: hidden;
}
.drop-zone::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at center, rgba(139, 92, 246, 0.04) 0%, transparent 70%);
    pointer-events: none;
}
.drop-zone:hover {
    border-color: rgba(167, 139, 250, 0.55);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(56, 139, 253, 0.06) 50%, rgba(139, 92, 246, 0.1) 100%);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.08), inset 0 0 30px rgba(139, 92, 246, 0.03);
}
.drop-zone.dragover {
    border-color: rgba(63, 185, 80, 0.6);
    background: linear-gradient(135deg, rgba(63, 185, 80, 0.08) 0%, rgba(63, 185, 80, 0.04) 100%);
    box-shadow: 0 0 40px rgba(63, 185, 80, 0.1);
}
.drop-zone p { margin: 4px 0; }
.drop-zone .main-text {
    font-size: 15px; font-weight: 500; color: #e6edf3;
}
.drop-zone .sub-text,
#dropZoneFormats {
    color: rgba(167, 139, 250, 0.6) !important;
    font-size: 11px !important;
}
.drop-zone > div[style*="border-left"] {
    border-left-color: rgba(139, 92, 246, 0.15) !important;
}

/* ========== НАСТРОЙКИ ========== */
.settings-list { display: flex; flex-direction: column; gap: 10px; }
.setting-item {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: #e6edf3;
    position: relative;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}
.setting-item:hover {
    background: rgba(139, 92, 246, 0.05);
}
.setting-item input[type="checkbox"] {
    width: 16px; height: 16px;
}
.setting-hint { font-size: 11px; color: #8b949e; margin-left: 24px; margin-top: -4px; }
.param-hint { font-size: 11px; color: #8b949e; margin-top: 2px; }
.param-hint code {
    background: transparent; padding: 0; border-radius: 0;
    font-size: 11px; color: #a78bfa; border: none;
    font-family: inherit; font-weight: 600;
}

/* ========== РАСШИРЕННЫЕ НАСТРОЙКИ ========== */
.advanced-section {
    margin: 0 !important;
    padding-top: 4px !important;
    padding-bottom: 0 !important;
    border-top: 1px solid rgba(139, 92, 246, 0.08) !important;
}
.advanced-header {
    display: flex; align-items: center; gap: 6px;
    cursor: pointer; font-size: 12px;
    color: rgba(167, 139, 250, 0.6);
    padding: 2px 0 !important; margin: 0 !important;
    user-select: none;
}
.advanced-header:hover { color: #a78bfa; }
.advanced-toggle { display: inline-block; transition: transform 0.2s; font-size: 10px; }
.advanced-toggle.open { transform: rotate(90deg); }
.advanced-content { overflow: hidden; }
.advanced-content.collapsed { display: none; }
.advanced-content .setting-item {
    color: #f0f6fc !important;
}

.param-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.param-group { flex: 1; min-width: 180px; }
.param-group label {
    display: block; font-weight: 600 !important; font-size: 12px;
    margin-bottom: 3px; color: #f0f6fc !important;
}
.param-group input[type="range"] {
    width: calc(100% - 8px);
    accent-color: #8b5cf6;
    margin: 0 4px;
    height: 4px;
}
.param-value { font-size: 11px; color: #a78bfa; font-weight: 600; }

/* Кастомный range slider */
.param-group input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(139, 92, 246, 0.15);
    border-radius: 4px;
}
.param-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    border: 2px solid rgba(255, 255, 255, 0.15);
    margin-top: -5px;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(139, 92, 246, 0.3);
    transition: box-shadow 0.2s;
}
.param-group input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.5);
}
.param-group input[type="range"]::-moz-range-track {
    height: 4px;
    background: rgba(139, 92, 246, 0.15);
    border-radius: 4px;
    border: none;
}
.param-group input[type="range"]::-moz-range-thumb {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(139, 92, 246, 0.3);
}

/* Профиль аудио */
#audioProfile {
    padding: 5px 8px;
    line-height: 1.4;
}
#audioProfile:focus {
    border-color: rgba(139, 92, 246, 0.4);
    outline: none;
    box-shadow: none;
}

/* ========== ШАБЛОНЫ ПРАВИЛ ========== */
.templates-block {
    background: rgba(139, 92, 246, 0.04);
    border: 1px solid rgba(139, 92, 246, 0.1);
    border-radius: 14px;
    padding: 10px 12px;
    position: relative;
    overflow: hidden;
}
.templates-block::before {
    content: '';
    position: absolute;
    top: -50%; right: -50%;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse, rgba(139, 92, 246, 0.04) 0%, transparent 60%);
    pointer-events: none;
}
.templates-block button[title="Добавить шаблон"] {
    background: rgba(139, 92, 246, 0.06) !important;
    border: 1px solid rgba(139, 92, 246, 0.2) !important;
    border-radius: 6px !important;
    color: #a78bfa !important;
    transition: all 0.2s !important;
}
.templates-block button[title="Добавить шаблон"]:hover {
    background: rgba(139, 92, 246, 0.12) !important;
    border-color: rgba(139, 92, 246, 0.4) !important;
    color: #c4b5fd !important;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.1) !important;
}

.active-templates-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ═══ Чипы шаблонов ═══ */
.template-chip {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 10px; border: 1px solid; border-radius: 12px;
    font-size: 12px; color: #e6edf3; cursor: pointer;
    transition: all 0.25s ease; flex: 0 0 calc(50% - 3px); min-width: 0;
    backdrop-filter: blur(8px);
    outline: none;
    box-shadow: none;
}
.template-chip:hover {
    transform: translateY(-1px);
    filter: brightness(1.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.template-chip:focus,
.template-chip:focus-visible {
    outline: none;
}

/* Цвета чипов */
.template-chip-color-0 { background: rgba(139, 92, 246, 0.08); border-color: rgba(139, 92, 246, 0.2); }
.template-chip-color-1 { background: rgba(63, 185, 80, 0.08); border-color: rgba(63, 185, 80, 0.2); }
.template-chip-color-2 { background: rgba(210, 153, 34, 0.08); border-color: rgba(210, 153, 34, 0.2); }
.template-chip-color-3 { background: rgba(248, 81, 73, 0.08); border-color: rgba(248, 81, 73, 0.2); }
.template-chip-color-4 { background: rgba(56, 139, 253, 0.08); border-color: rgba(56, 139, 253, 0.2); }
.template-chip-color-5 { background: rgba(219, 171, 255, 0.08); border-color: rgba(219, 171, 255, 0.2); }

/* Бейджи в чипах — по цветам */
.template-chip-color-0 .template-chip-count { background: rgba(139, 92, 246, 0.25); color: #a78bfa; border-color: rgba(139, 92, 246, 0.4); }
.template-chip-color-1 .template-chip-count { background: rgba(63, 185, 80, 0.25); color: #3fb950; border-color: rgba(63, 185, 80, 0.4); }
.template-chip-color-2 .template-chip-count { background: rgba(210, 153, 34, 0.25); color: #d29922; border-color: rgba(210, 153, 34, 0.4); }
.template-chip-color-3 .template-chip-count { background: rgba(248, 81, 73, 0.25); color: #f85149; border-color: rgba(248, 81, 73, 0.4); }
.template-chip-color-4 .template-chip-count { background: rgba(56, 139, 253, 0.25); color: #58a6ff; border-color: rgba(56, 139, 253, 0.4); }
.template-chip-color-5 .template-chip-count { background: rgba(219, 171, 255, 0.25); color: #dbabff; border-color: rgba(219, 171, 255, 0.4); }

/* Внутренние элементы */
.template-chip-left { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; overflow: hidden; }
.template-chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.template-chip-count {
    font-size: 10px; padding: 0 6px;
    border: 1px solid; border-radius: 8px; font-weight: 600;
    line-height: 16px; flex-shrink: 0;
}
.template-chip-remove {
    background: none; border: none; color: #8b949e;
    cursor: pointer; font-size: 11px;
    padding: 4px; border-radius: 6px; flex-shrink: 0; margin-left: auto;
    transition: 0.15s; line-height: 1;
    outline: none;
}
.template-chip-remove:hover { background: rgba(248, 81, 73, 0.1); color: #f85149; }
.template-empty { text-align: center; padding: 8px; font-size: 11px; color: #484f58; }

#applyAllTemplatesBtn {
    background: rgba(139, 92, 246, 0.08) !important;
    border: 1px solid rgba(139, 92, 246, 0.25) !important;
    color: #a78bfa !important;
    box-shadow: none !important;
}
#applyAllTemplatesBtn:hover {
    background: rgba(139, 92, 246, 0.15) !important;
    border-color: rgba(139, 92, 246, 0.4) !important;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.1) !important;
    transform: translateY(-1px) !important;
}

/* ========== МОДАЛКА ДОБАВЛЕНИЯ ШАБЛОНА ========== */
#addTemplateModal {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(5, 8, 18, 0.75);
    backdrop-filter: blur(4px);
    z-index: 2500;
}
#addTemplateModal .atm-content {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(22, 27, 44, 0.9);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-radius: 16px; padding: 20px 24px;
    max-width: 440px; width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(139, 92, 246, 0.08);
}
.atm-template-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; margin: 12px 0; }
.atm-template-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px; cursor: pointer; transition: 0.2s;
}
.atm-template-item:hover {
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.06);
}
.atm-template-item.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.atm-template-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: #8b5cf6; flex-shrink: 0; }
.atm-template-info { flex: 1; min-width: 0; }
.atm-template-name { font-size: 13px; font-weight: 500; color: #f0f6fc; }
.atm-template-meta { font-size: 11px; color: #8b949e; margin-top: 1px; }
.atm-divider { border: none; border-top: 1px solid rgba(255, 255, 255, 0.05); margin: 8px 0; }
.atm-create-btn {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 12px; background: none;
    border: 1px dashed rgba(139, 92, 246, 0.25);
    border-radius: 10px; color: #8b949e; font-size: 12px;
    cursor: pointer; transition: 0.2s;
}
.atm-create-btn:hover { border-color: #8b5cf6; color: #a78bfa; }

/* ========== TRIGGER ПРАВИЛ ========== */
.corrections-trigger {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; margin-top: 8px;
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 10px; cursor: pointer; transition: 0.2s; font-size: 13px;
}
.corrections-trigger:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.08);
}
.trigger-left { display: flex; align-items: center; gap: 6px; font-weight: 500; color: #e6edf3; }
.trigger-right { display: flex; align-items: center; gap: 6px; }
.rule-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

/* Общий бейдж (сумма) — фиолетовый */
#ruleBadgeTotal {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* ========== БОКОВАЯ ПАНЕЛЬ ПРАВИЛ ========== */
#correctionsSidebar {
    position: fixed; top: 0; right: -100%;
    width: 400px; min-width: 320px; max-width: 700px;
    height: 100vh;
    background: rgba(13, 17, 30, 0.85);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
    z-index: 1500; transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; flex-direction: column;
}
#correctionsSidebar.open { right: 0; }
#correctionsSidebar.resizing { transition: none; }
#correctionsOverlay {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(5, 8, 18, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1400;
}
#correctionsOverlay.open { display: block; }

.sidebar-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.08);
    background: rgba(139, 92, 246, 0.03);
    flex-shrink: 0;
    position: relative;
}
.sidebar-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.2), transparent);
}
.sidebar-header h3 { margin: 0; font-size: 14px; font-weight: 600; color: #e6edf3; }
.sidebar-close {
    background: none; border: none; font-size: 18px;
    cursor: pointer; color: #8b949e; padding: 4px 8px; border-radius: 8px;
    transition: 0.15s;
}
.sidebar-close:hover { background: rgba(248, 81, 73, 0.1); color: #f85149; }
.sidebar-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.sidebar-footer {
    padding: 10px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}
.sidebar-footer .corrections-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sidebar-footer .btn-sm { padding: 5px 14px; font-size: 13px; font-weight: 500; }
.sidebar-resize-handle {
    position: absolute; top: 0; left: 0;
    width: 5px; height: 100%; cursor: col-resize;
    background: transparent; z-index: 10;
}
.sidebar-resize-handle:hover, .sidebar-resize-handle.active {
    background: linear-gradient(180deg, #8b5cf6, #a78bfa);
}

/* Таблица правил */
.corrections-table { width: 100%; border-collapse: collapse; }
.corrections-table th {
    text-align: left; padding: 6px 6px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: 600; font-size: 11px; color: #8b949e;
    text-transform: uppercase; letter-spacing: 0.5px;
    white-space: nowrap; vertical-align: middle;
}
.corrections-table td { padding: 3px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.03); }
.corrections-table input[type="text"] {
    width: 100%; padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px; font-size: 13px;
    background: rgba(255, 255, 255, 0.04);
    color: #e6edf3;
}
.corrections-table input[type="text"]:focus {
    outline: none; border-color: #8b5cf6;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}
.corrections-table input[type="text"]::placeholder { color: #484f58; }
.corrections-table .btn-remove {
    background: none; color: #8b949e; border: none;
    padding: 3px 6px; border-radius: 6px; cursor: pointer; font-size: 12px;
    transition: 0.15s;
}
.corrections-table .btn-remove:hover { background: rgba(248, 81, 73, 0.1); color: #f85149; }
.validation-error { color: #f85149; font-size: 12px; margin-top: 8px; display: none; }
.validation-error.show { display: block; }
.char-limit { font-size: 9px; color: #484f58; display: block; margin-top: 1px; }
.char-limit.over { color: #f85149; font-weight: 600; }
.rule-count { font-size: 12px; color: #8b949e; }

.corrections-table.readonly input[type="text"] {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.04);
    color: #e6edf3; cursor: default;
}
.corrections-table.readonly input[type="text"]:focus { border-color: transparent; box-shadow: none; }
.corrections-table.readonly .btn-remove { visibility: hidden; }
.corrections-table.readonly input[type="checkbox"] { visibility: hidden; }

.field-error-msg { font-size: 10px; color: #f85149; margin-top: 2px; display: block; }
.corrections-table input[type="text"].field-error {
    border-color: #f85149 !important;
    background: rgba(248, 81, 73, 0.06) !important;
    box-shadow: 0 0 0 1px rgba(248, 81, 73, 0.15) !important;
}

.row-num {
    font-size: 10px; color: #656d76;
    min-width: 14px; display: block;
    text-align: center; user-select: none; line-height: 1;
}
.col-num { width: 20px; text-align: center; }
.col-check { width: 26px; text-align: center; }

.corrections-table thead th.col-num,
.corrections-table thead th.col-check {
    padding: 6px 2px !important;
    vertical-align: middle;
    text-align: center;
}

#correctionsBody td.col-num {
    padding: 10px 2px 0 !important;
    vertical-align: top;
    text-align: center;
}
#correctionsBody td.col-check {
    padding: 3px 2px 0 !important;
    vertical-align: top;
    text-align: center;
}
#correctionsBody td:last-child {
    vertical-align: top;
    text-align: center;
    padding: 2px 2px 0 2px !important;
}
#correctionsBody td:last-child .btn-remove {
    margin-top: 3px;
	padding: 1px 4px 2px 4px;
}

.corrections-table.readonly .col-check { display: none; }
.corrections-table.readonly thead .col-check { display: none; }

.corrections-table thead .col-check {
    vertical-align: middle;
    text-align: center;
    padding: 6px 2px !important;
}
/* Все чекбоксы в таблице правил — единый размер и выравнивание */
.corrections-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Кнопки сайдбара */
.corrections-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.corrections-actions .btn-sm {
    border-radius: 10px !important;
    font-weight: 500 !important;
    padding: 6px 14px !important;
    font-size: 12px !important;
    transition: all 0.25s ease !important;
    letter-spacing: 0.01em;
}
.corrections-actions .btn-primary {
    background: rgba(46, 160, 67, 0.08) !important;
    border: 1px solid rgba(63, 185, 80, 0.25) !important;
    color: #3fb950 !important;
}
.corrections-actions .btn-primary:hover {
    background: rgba(46, 160, 67, 0.15) !important;
    border-color: rgba(63, 185, 80, 0.4) !important;
}
.corrections-actions .btn-edit {
    background: rgba(56, 139, 253, 0.08) !important;
    border: 1px solid rgba(56, 139, 253, 0.25) !important;
    color: #58a6ff !important;
}
.corrections-actions .btn-edit:hover {
    background: rgba(56, 139, 253, 0.15) !important;
    border-color: rgba(56, 139, 253, 0.4) !important;
}
.corrections-actions .btn-danger {
    background: rgba(248, 81, 73, 0.04) !important;
    border: 1px solid rgba(248, 81, 73, 0.2) !important;
    color: #f85149 !important;
}
.corrections-actions .btn-danger:hover {
    background: rgba(248, 81, 73, 0.1) !important;
    border-color: rgba(248, 81, 73, 0.4) !important;
    box-shadow: 0 0 12px rgba(248, 81, 73, 0.1) !important;
    transform: translateY(-1px) !important;
}
.corrections-actions .btn-sm:not(.btn-primary):not(.btn-edit):not(.btn-danger) {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #c9d1d9 !important;
}
.corrections-actions .btn-sm:not(.btn-primary):not(.btn-edit):not(.btn-danger):hover {
    background: rgba(139, 92, 246, 0.06) !important;
    border-color: rgba(139, 92, 246, 0.2) !important;
    color: #e6edf3 !important;
    transform: translateY(-1px) !important;
}

/* ========== QUICK RULE POPUP ========== */
#quickRulePopup {
    display: none; position: fixed; z-index: 3000;
    background:
        radial-gradient(ellipse 80% 60% at 10% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 60%),
        rgba(16, 20, 35, 0.88);
    backdrop-filter: blur(28px) saturate(1.5);
    -webkit-backdrop-filter: blur(28px) saturate(1.5);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: 16px; padding: 12px 14px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    min-width: 260px; max-width: 320px;
    animation: modalSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
#quickRulePopup .qr-title { font-size: 12px; color: #8b949e; margin-bottom: 8px; }
#quickRulePopup .qr-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
#quickRulePopup .qr-label { font-size: 11px; color: #8b949e; min-width: 60px; }
#quickRulePopup input[type="text"] {
    flex: 1; padding: 4px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #e6edf3; font-size: 13px;
}
#quickRulePopup input[type="text"]:focus {
    outline: none; border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}
#quickRulePopup .qr-suggestions { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
#quickRulePopup .qr-suggest-btn {
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 6px; padding: 2px 8px; font-size: 11px;
    color: #a78bfa; cursor: pointer; transition: 0.15s;
}
#quickRulePopup .qr-suggest-btn:hover { background: rgba(139, 92, 246, 0.15); }
#quickRulePopup .qr-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ========== ТОЧЕЧНАЯ ЗАМЕНА ========== */
#spotReplacePopup {
    display: none; position: fixed; z-index: 3000;
    background:
        radial-gradient(ellipse 80% 60% at 10% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 60%),
        rgba(16, 20, 35, 0.88);
    backdrop-filter: blur(28px) saturate(1.5);
    -webkit-backdrop-filter: blur(28px) saturate(1.5);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: 16px; padding: 12px 14px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    min-width: 260px; max-width: 320px;
    animation: modalSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
#spotReplacePopup .qr-title { font-size: 12px; color: #8b949e; margin-bottom: 8px; }
#spotReplacePopup .qr-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
#spotReplacePopup .qr-label { font-size: 11px; color: #8b949e; min-width: 60px; }
#spotReplacePopup input[type="text"] {
    flex: 1; padding: 4px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #e6edf3; font-size: 13px;
}
#spotReplacePopup input[type="text"]:focus {
    outline: none; border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}
#spotReplacePopup .qr-actions { display: flex; gap: 6px; justify-content: flex-end; }

#spotReplaceModeBtn.active-spot-mode {
    background: rgba(56, 139, 253, 0.08) !important;
    border: 1px solid rgba(56, 139, 253, 0.25) !important;
    color: #58a6ff !important;
    box-shadow: none !important;
}
#spotReplaceModeBtn.active-spot-mode:hover {
    background: rgba(56, 139, 253, 0.18) !important;
    border-color: rgba(56, 139, 253, 0.5) !important;
    color: #79c0ff !important;
    box-shadow: 0 0 14px rgba(56, 139, 253, 0.15) !important;
    transform: translateY(-1px) !important;
}

.spot-replace-mode { cursor: crosshair !important; }
.spot-replace-mode * { cursor: crosshair !important; }

/* Кнопка отмены режима добавления правил — золотая */
#addRuleModeBtn.active-rule-mode {
    background: rgba(210, 153, 34, 0.08) !important;
    border: 1px solid rgba(210, 153, 34, 0.25) !important;
    color: #d2a122 !important;
    box-shadow: none !important;
}
#addRuleModeBtn.active-rule-mode:hover {
    background: rgba(210, 153, 34, 0.18) !important;
    border-color: rgba(210, 153, 34, 0.5) !important;
    color: #e8b931 !important;
    box-shadow: 0 0 14px rgba(210, 153, 34, 0.15) !important;
    transform: translateY(-1px) !important;
}

/* Кнопки режимов — выравнивание */
#addRuleModeBtn,
#spotReplaceModeBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding-left: 8px;
    padding-right: 10px;
}
#addRuleModeBtn.active-rule-mode,
#spotReplaceModeBtn.active-spot-mode {
    padding-left: 6px;
    padding-right: 10px;
}

#resetOriginalBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding-left: 8px;
    padding-right: 10px;
}

#resetOriginalBtn svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    min-width: 14px;
    margin: 0;
}

#resetOriginalBtn span {
    white-space: nowrap;
}

#topAiAnalysisBtn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 14px !important;
}

#topAiAnalysisBtn svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    min-width: 16px;
}

#topAiAnalysisBtn span {
    flex-shrink: 0;
    white-space: nowrap;
}

/* ========== ПРОГРЕСС ========== */
.loader { display: none; margin: 0; }
.progress-wrap {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    height: 8px;
    overflow: hidden;
    margin: 2px 0 0 0;
}
.progress-bar {
    background: linear-gradient(90deg, #6d28d9, #8b5cf6, #a78bfa, #8b5cf6);
    background-size: 200% 100%;
    animation: progressShimmer 2s linear infinite;
    height: 100%;
    width: 0%;
    transition: width 0.4s ease;
    border-radius: 8px;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}
@keyframes progressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #8b949e;
}

/* ========== СТАТИСТИКА ========== */
#stats {
    display: none;
    padding: 6px 16px;
    background: rgba(139, 92, 246, 0.04);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: 10px;
    margin: 0;
    font-size: 12px;
    color: #a78bfa;
    backdrop-filter: blur(8px);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.04);
}
#stats span { margin-right: 16px !important; }

/* ========== ТУЛБАР ПОСТ-ОБРАБОТКИ ========== */
#postProcessPanel {
    display: none;
    background: rgba(22, 27, 44, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    margin-bottom: 0 !important;
    overflow: hidden;
}
.toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    flex-wrap: wrap;
}
.toolbar-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0 4px;
}
.toolbar .btn-sm {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: #c4b5fd;
    font-weight: 500;
    transition: all 0.2s;
}
.toolbar .btn-sm:hover {
    background: rgba(139, 92, 246, 0.08);
    border-color: rgba(139, 92, 246, 0.25);
    color: #e6edf3;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.06);
}
#postProcessMessage {
    padding: 0 12px; font-size: 12px; color: #8b949e;
    min-height: 24px; line-height: 24px; overflow: hidden;
}
#postProcessMessage:empty { visibility: hidden !important; }

/* ========== РЕЗУЛЬТАТ ========== */

#resultWrap {
    display: none;
    gap: 6px;
    align-items: flex-start;
}
#resultWrap.visible {
    display: flex;
}

#result {
    white-space: pre-wrap;
    background: rgba(13, 17, 30, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 24px;
    max-height: 65vh;
    overflow-y: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 14px;
    line-height: 1.7;
    color: #f5f5f5;
}
#result::-webkit-scrollbar { width: 8px; }
#result::-webkit-scrollbar-track { background: transparent; border-radius: 4px; }
#result::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.2); border-radius: 4px; }
#result::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.35); }

.tc-speaker { color: #7ee8c7; font-weight: 600; }
.tc-time { color: #f0a882; font-weight: 500; opacity: 0.8; font-size: 0.9em; }
.action-bar { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

/* ========== ОРФОГРАФИЯ ========== */
.spell-error {
    background: rgba(248, 81, 73, 0.1);
    border-bottom: 2px solid rgba(248, 81, 73, 0.6);
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.15s;
}
.spell-error:hover { background: rgba(248, 81, 73, 0.2); }
.stats-line { color: #8b949e; pointer-events: none; user-select: none; }
.add-rule-mode { cursor: crosshair !important; }
.add-rule-mode .spell-error { cursor: crosshair !important; }

#spellPanel {
    display: none;
    flex-shrink: 0;
    width: 200px;
    background: rgba(22, 27, 44, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 10px;
    max-height: 65vh;
    overflow-y: auto;
}
#spellPanel::-webkit-scrollbar { width: 4px; }
#spellPanel::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.3); border-radius: 4px; }
.spell-panel-title {
    font-size: 11px; font-weight: 600; color: #8b949e;
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.spell-panel-word {
    display: block; width: 100%;
    background: none; border: none;
    text-align: left; padding: 3px 6px;
    border-radius: 6px; cursor: pointer;
    font-size: 13px; color: #f85149;
    border-bottom: 1px solid rgba(248, 81, 73, 0.1);
    margin-bottom: 2px;
    transition: background 0.15s;
}
.spell-panel-word:hover { background: rgba(248, 81, 73, 0.08); }

/* ========== МОДАЛКА СПИКЕРОВ ========== */
#speakerModal {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(5, 8, 18, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2000; align-items: center; justify-content: center; padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}
#speakerModal::-webkit-scrollbar { width: 6px; }
#speakerModal::-webkit-scrollbar-track { background: transparent; }
#speakerModal::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.25); border-radius: 3px; }
#speakerModal::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.45); }


#speakerModal .modal-content {
    background:
        radial-gradient(ellipse 80% 60% at 10% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 90% 80%, rgba(56, 139, 253, 0.07) 0%, transparent 50%),
        rgba(16, 20, 35, 0.65);
    backdrop-filter: blur(28px) saturate(1.5);
    -webkit-backdrop-filter: blur(28px) saturate(1.5);
    border-radius: 18px; padding: 24px;
    max-width: 460px; width: 100%; max-height: 85vh; overflow-y: auto;
    border: 1px solid rgba(139, 92, 246, 0.1);
    box-shadow:
        0 16px 56px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}

#speakerModal .modal-content::-webkit-scrollbar { width: 6px; }
#speakerModal .modal-content::-webkit-scrollbar-track { background: transparent; border-radius: 3px; margin: 28px 0; }
#speakerModal .modal-content::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.25); border-radius: 3px; }
#speakerModal .modal-content::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.45); }
#speakerModal .modal-content::-webkit-scrollbar-button { display: none; height: 0; }

#speakerModal .modal-content h3 {
    color: #f0f6fc;
    background: linear-gradient(135deg, #e6edf3, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
#speakerModal .modal-content p { color: #8b949e; }


#speakerList > div {
    margin-bottom: 16px; padding: 12px;
    background: rgba(139, 92, 246, 0.03);
    border: 1px solid rgba(139, 92, 246, 0.08);
    border-left: 3px solid rgba(139, 92, 246, 0.4);
    border-radius: 12px;
    backdrop-filter: blur(8px);
}
#speakerList > div:hover {
    background: rgba(139, 92, 246, 0.06);
    border-color: rgba(139, 92, 246, 0.15);
}
#speakerList span { color: #8b949e; }
#speakerList input {
    flex: 1; padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: #f0f6fc;
    transition: all 0.2s;
}
#speakerList input:focus {
    outline: none;
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1), 0 0 16px rgba(139, 92, 246, 0.06);
    background: rgba(255, 255, 255, 0.06);
}
#speakerList button:not(.input-clear-btn) { padding: 5px 12px; font-size: 12px; }
#speakerList .input-clearable {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}
#speakerList .input-clearable .input-clear-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
}
#speakerList .input-clear-btn {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    max-width: 18px !important;
    min-height: 18px !important;
    max-height: 18px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    aspect-ratio: 1 / 1 !important;
    box-sizing: border-box !important;
}

/* ========== ИИ МОДАЛКА ========== */
#aiModal .modal-content { max-width: 950px; height: 85vh; padding: 20px; }
.ai-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px; margin-bottom: 16px;
}
.ai-templates { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

/* ═══ Кнопки шаблонов ИИ ═══ */
.ai-template-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e6edf3;
    padding: 5px 12px 6px; border-radius: 20px; font-size: 12px;
    cursor: pointer; transition: all 0.25s; display: inline-flex; align-items: center; gap: 5px;
    line-height: 1;
    vertical-align: middle;
}
.ai-template-btn:nth-child(1)  { border-color: rgba(63, 185, 80, 0.4);  color: #3fb950; }
.ai-template-btn:nth-child(2)  { border-color: rgba(210, 153, 34, 0.4); color: #d29922; }
.ai-template-btn:nth-child(3)  { border-color: rgba(248, 81, 73, 0.4);  color: #f85149; }
.ai-template-btn:nth-child(4)  { border-color: rgba(139, 92, 246, 0.4); color: #a78bfa; }
.ai-template-btn:nth-child(5)  { border-color: rgba(56, 139, 253, 0.4); color: #58a6ff; }
.ai-template-btn:nth-child(6)  { border-color: rgba(238, 186, 50, 0.4); color: #eeba32; }
.ai-template-btn:nth-child(7)  { border-color: rgba(63, 185, 80, 0.4);  color: #3fb950; }
.ai-template-btn:nth-child(8)  { border-color: rgba(56, 139, 253, 0.4); color: #58a6ff; }
.ai-template-btn:nth-child(9)  { border-color: rgba(248, 81, 73, 0.4);  color: #f85149; }
.ai-template-btn:nth-child(10) { border-color: rgba(210, 153, 34, 0.4); color: #d29922; }
.ai-template-btn:nth-child(11) { border-color: rgba(139, 92, 246, 0.4); color: #a78bfa; }
.ai-template-btn:nth-child(12) { border-color: rgba(63, 185, 80, 0.4);  color: #3fb950; }
.ai-template-btn:nth-child(13) { border-color: rgba(136, 136, 136, 0.4); color: #8b949e; }
.ai-template-btn:nth-child(1):hover  { background: rgba(63, 185, 80, 0.08); }
.ai-template-btn:nth-child(2):hover  { background: rgba(210, 153, 34, 0.08); }
.ai-template-btn:nth-child(3):hover  { background: rgba(248, 81, 73, 0.08); }
.ai-template-btn:nth-child(4):hover  { background: rgba(139, 92, 246, 0.08); }
.ai-template-btn:nth-child(5):hover  { background: rgba(56, 139, 253, 0.08); }
.ai-template-btn:nth-child(6):hover  { background: rgba(238, 186, 50, 0.08); }
.ai-template-btn:nth-child(7):hover  { background: rgba(63, 185, 80, 0.08); }
.ai-template-btn:nth-child(8):hover  { background: rgba(56, 139, 253, 0.08); }
.ai-template-btn:nth-child(9):hover  { background: rgba(248, 81, 73, 0.08); }
.ai-template-btn:nth-child(10):hover { background: rgba(210, 153, 34, 0.08); }
.ai-template-btn:nth-child(11):hover { background: rgba(139, 92, 246, 0.08); }
.ai-template-btn:nth-child(12):hover { background: rgba(63, 185, 80, 0.08); }
.ai-template-btn:nth-child(13):hover { background: rgba(136, 136, 136, 0.08); }
.ai-template-btn:nth-child(1).active  { background: rgba(63, 185, 80, 0.2);  border-color: rgba(63, 185, 80, 0.6);  color: #fff; box-shadow: 0 0 16px rgba(63, 185, 80, 0.2); }
.ai-template-btn:nth-child(2).active  { background: rgba(210, 153, 34, 0.2); border-color: rgba(210, 153, 34, 0.6); color: #fff; box-shadow: 0 0 16px rgba(210, 153, 34, 0.2); }
.ai-template-btn:nth-child(3).active  { background: rgba(248, 81, 73, 0.2);  border-color: rgba(248, 81, 73, 0.6);  color: #fff; box-shadow: 0 0 16px rgba(248, 81, 73, 0.2); }
.ai-template-btn:nth-child(4).active  { background: rgba(139, 92, 246, 0.2); border-color: rgba(139, 92, 246, 0.6); color: #fff; box-shadow: 0 0 16px rgba(139, 92, 246, 0.2); }
.ai-template-btn:nth-child(5).active  { background: rgba(56, 139, 253, 0.2); border-color: rgba(56, 139, 253, 0.6); color: #fff; box-shadow: 0 0 16px rgba(56, 139, 253, 0.2); }
.ai-template-btn:nth-child(6).active  { background: rgba(238, 186, 50, 0.2); border-color: rgba(238, 186, 50, 0.6); color: #fff; box-shadow: 0 0 16px rgba(238, 186, 50, 0.2); }
.ai-template-btn:nth-child(7).active  { background: rgba(63, 185, 80, 0.2);  border-color: rgba(63, 185, 80, 0.6);  color: #fff; box-shadow: 0 0 16px rgba(63, 185, 80, 0.2); }
.ai-template-btn:nth-child(8).active  { background: rgba(56, 139, 253, 0.2); border-color: rgba(56, 139, 253, 0.6); color: #fff; box-shadow: 0 0 16px rgba(56, 139, 253, 0.2); }
.ai-template-btn:nth-child(9).active  { background: rgba(248, 81, 73, 0.2);  border-color: rgba(248, 81, 73, 0.6);  color: #fff; box-shadow: 0 0 16px rgba(248, 81, 73, 0.2); }
.ai-template-btn:nth-child(10).active { background: rgba(210, 153, 34, 0.2); border-color: rgba(210, 153, 34, 0.6); color: #fff; box-shadow: 0 0 16px rgba(210, 153, 34, 0.2); }
.ai-template-btn:nth-child(11).active { background: rgba(139, 92, 246, 0.2); border-color: rgba(139, 92, 246, 0.6); color: #fff; box-shadow: 0 0 16px rgba(139, 92, 246, 0.2); }
.ai-template-btn:nth-child(12).active { background: rgba(63, 185, 80, 0.2);  border-color: rgba(63, 185, 80, 0.6);  color: #fff; box-shadow: 0 0 16px rgba(63, 185, 80, 0.2); }
.ai-template-btn:nth-child(13).active { background: rgba(136, 136, 136, 0.2); border-color: rgba(136, 136, 136, 0.6); color: #fff; box-shadow: 0 0 16px rgba(136, 136, 136, 0.2); }


/* ═══ Промпт ═══ */
.ai-prompt-wrap {
    position: relative;
    margin-bottom: 12px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
#aiPrompt {
    width: 100%;
    flex: 1;
    min-height: 80px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #e6edf3;
    padding: 14px;
    font-size: 14px;
    line-height: 1.5;
    font-family: inherit;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}
#aiPrompt::-webkit-scrollbar { width: 4px; }
#aiPrompt::-webkit-scrollbar-track { background: transparent; }
#aiPrompt::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.35); border-radius: 4px; }
#aiPrompt::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.55); }
#aiPrompt::-webkit-scrollbar-button { display: none; height: 0; }
#aiPrompt:focus { outline: none; border-color: #8b5cf6; box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15); }
#aiPrompt:empty::before {
    content: attr(data-placeholder);
    color: #484f58;
    pointer-events: none;
}
/* ═══ Контейнер ответа ═══ */
.ai-response-container {
    flex: 1; display: flex; flex-direction: column; min-height: 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px; overflow: hidden;
    background: rgba(13, 17, 30, 0.5); position: relative;
}
#aiResponse {
    flex: 1; overflow-y: auto; padding: 20px;
    white-space: pre-wrap; font-size: 14px; line-height: 1.6; color: #f0f6fc;
    scrollbar-width: thin; scrollbar-color: rgba(139, 92, 246, 0.25) transparent;
}
#aiResponse::-webkit-scrollbar { width: 6px; }
#aiResponse::-webkit-scrollbar-track { background: transparent; }
#aiResponse::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.25); border-radius: 3px; }
#aiResponse::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.45); }

/* ═══ Крестик закрытия ═══ */
.ai-header [onclick*="closeAiModal"] {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 18px;
    cursor: pointer;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
    padding: 0px 0 2px 0;
    align-self: flex-start;
    margin-top: 2px;
}
.ai-header [onclick*="closeAiModal"]:hover {
    background: rgba(248, 81, 73, 0.12);
    color: #f85149;
}

/* ═══ Кнопка Анализ ИИ (верхняя) ═══ */
#topAiAnalysisBtn {
    gap: 3px;
    padding: 4px 10px !important;
    justify-content: center;
}
#topAiAnalysisBtn svg {
    width: 14px; height: 14px;
    flex-shrink: 0;
    margin-left: -2px;
}

/* ========== Иконки восстановления ========== */
.restore-option svg {
    width: 20px; height: 20px;
    vertical-align: -4px;
    margin-right: 4px;
    color: #58a6ff;
}

/* ========== Модалка добавления шаблона ========== */
#atmTemplateList .btn-remove {
    flex-shrink: 0; background: none; border: none;
    color: #8b949e; cursor: pointer; font-size: 12px;
    padding: 2px 4px; border-radius: 6px; transition: 0.15s;
    display: inline-flex; align-items: center; justify-content: center;
}
#atmTemplateList .btn-remove:hover {
    background: rgba(248, 81, 73, 0.1); color: #f85149; box-shadow: none;
}
#addTemplateModal .atm-content h3 {
    display: flex; align-items: center; gap: 6px;
}
#atmTemplateList {
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
    overflow-y: auto;
}
#atmTemplateList::-webkit-scrollbar { width: 6px; }
#atmTemplateList::-webkit-scrollbar-track { background: transparent; margin: 4px 0; }
#atmTemplateList::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.3); border-radius: 3px; }
#atmTemplateList::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.6); }

/* ========== Состояния элементов ========== */
.processing-locked { opacity: 0.5; pointer-events: none; }
.disabled-control { opacity: 0.4; pointer-events: none; }
.btn-disabled { opacity: 0.4; cursor: not-allowed !important; }
#cancelBtn { border-color: #f85149; color: #f85149; transition: all 0.2s; }
#cancelBtn.cancelling { border-color: #8b949e; color: #8b949e; }

/* ========== Сайдбар ========== */
.sidebar-footer .edit-mode-indicator svg,
.sidebar-footer .edit-mode-indicator .icon { position: relative; top: 2px; }
.sidebar-body::-webkit-scrollbar { width: 6px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.2); border-radius: 3px; }
.sidebar-body::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.35); }
.sidebar-body { scrollbar-width: thin; scrollbar-color: rgba(139, 92, 246, 0.2) transparent; }
.sidebar-close { padding: 4px 8px 6px 8px; }
.sidebar-body .input-clear-btn,
.search-wrap .input-clear-btn { padding: 3px 6px 2px 6px; }
#editModeLabel svg { vertical-align: -4px !important; }
.templates-block > div:first-child > div:first-child svg { vertical-align: -2px; }
#quickRulePopup .qr-title svg { vertical-align: -3px; }
#restoreModal h3 svg { vertical-align: -2px; }
#restoreModal .btn svg { vertical-align: -5px; }

#correctionsSidebar input:focus,
#correctionsSidebar input:focus-visible {
    outline: none !important;
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.15);
}

/* ========== СМЕНА СПИКЕРА ========== */
.speaker-change-mode { cursor: crosshair !important; }
.speaker-change-mode * { cursor: crosshair !important; }
#speakerChangeModeBtn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 5px; padding-left: 8px; padding-right: 10px;
}
#speakerChangeModeBtn.active-speaker-mode {
    background: rgba(126, 232, 199, 0.08) !important;
    border: 1px solid rgba(126, 232, 199, 0.25) !important;
    color: #7ee8c7 !important;
    box-shadow: none !important;
    padding-left: 6px; padding-right: 10px;
}
#speakerChangeModeBtn.active-speaker-mode:hover {
    background: rgba(126, 232, 199, 0.18) !important;
    border-color: rgba(126, 232, 199, 0.5) !important;
    color: #a5f0d8 !important;
    box-shadow: 0 0 14px rgba(126, 232, 199, 0.15) !important;
    transform: translateY(-1px) !important;
}
#speakerChangePopup {
    display: none; position: fixed; z-index: 3000;
    background: radial-gradient(ellipse 80% 60% at 10% 20%, rgba(126, 232, 199, 0.06) 0%, transparent 60%), rgba(16, 20, 35, 0.88);
    backdrop-filter: blur(28px) saturate(1.5);
    -webkit-backdrop-filter: blur(28px) saturate(1.5);
    border: 1px solid rgba(126, 232, 199, 0.12);
    border-radius: 16px; padding: 12px 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03), inset 0 1px 0 rgba(255,255,255,0.04);
    min-width: 280px; max-width: 360px;
    animation: modalSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
#speakerChangePopup .qr-title { font-size: 12px; color: #7ee8c7; margin-bottom: 8px; font-weight: 600; }
#speakerChangePopup .qr-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
#speakerChangePopup .qr-label { font-size: 11px; color: #8b949e; min-width: 55px; flex-shrink: 0; }
.sc-selected-text {
    color: #e6edf3; font-size: 12px; max-width: 240px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    background: rgba(255,255,255,0.04); padding: 2px 8px;
    border-radius: 6px; border: 1px solid rgba(255,255,255,0.06);
}
.sc-select {
    flex: 1; padding: 4px 8px;
    background: rgba(13, 17, 30, 0.95);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px; color: #e6edf3; font-size: 13px;
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center;
    padding-right: 24px; cursor: pointer;
}
.sc-select:focus { outline: none; border-color: rgba(126,232,199,0.4); box-shadow: 0 0 0 2px rgba(126,232,199,0.1); }
.sc-select option { background: #161b2c; color: #e6edf3; padding: 6px 8px; }
.sc-select option:disabled { color: #484f58; }
.sc-select option:checked, .sc-select option:hover { background: rgba(126,232,199,0.15); }
#speakerChangePopup input[type="text"] {
    flex: 1; padding: 4px 8px;
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px; color: #e6edf3; font-size: 13px;
}
#speakerChangePopup input[type="text"]:focus {
    outline: none; border-color: rgba(126,232,199,0.4);
    box-shadow: 0 0 0 2px rgba(126,232,199,0.1);
}
.sc-whole-phrase-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: #8b949e; margin-bottom: 8px; cursor: pointer; padding: 2px 0;
}
.sc-whole-phrase-label:hover { color: #c9d1d9; }
.sc-whole-phrase-label input[type="checkbox"] {
    accent-color: #7ee8c7; width: 16px; height: 16px; margin: 0; flex-shrink: 0;
}
.sc-preview {
    font-size: 11px; color: #8b949e;
    background: rgba(126,232,199,0.04); border: 1px solid rgba(126,232,199,0.08);
    border-radius: 8px; padding: 6px 8px; margin-bottom: 8px;
    display: none; max-height: 60px; overflow-y: auto; line-height: 1.5;
    scrollbar-width: thin; scrollbar-color: rgba(126,232,199,0.25) transparent;
}
.sc-preview .sc-old { color: #f85149; text-decoration: line-through; }
.sc-preview .sc-new { color: #7ee8c7; font-weight: 500; }
.sc-preview::-webkit-scrollbar { width: 4px; }
.sc-preview::-webkit-scrollbar-track { background: transparent; }
.sc-preview::-webkit-scrollbar-thumb { background: rgba(126,232,199,0.25); border-radius: 2px; }
.sc-preview::-webkit-scrollbar-thumb:hover { background: rgba(126,232,199,0.45); }
#speakerChangePopup .qr-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ═══ Скроллбар pickTemplateList ═══ */
#pickTemplateList { scrollbar-width: thin; scrollbar-color: rgba(139,92,246,0.3) transparent; }
#pickTemplateList::-webkit-scrollbar { width: 6px; }
#pickTemplateList::-webkit-scrollbar-track { background: transparent; }
#pickTemplateList::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.3); border-radius: 3px; }
#pickTemplateList::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,0.5); }

#speakerModal .modal-content {
    overflow: hidden !important;
}

#speakerList {
    max-height: calc(85vh - 180px);
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}

#speakerList::-webkit-scrollbar { width: 6px; }
#speakerList::-webkit-scrollbar-track { background: transparent; }
#speakerList::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.25); border-radius: 3px; }
#speakerList::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.45); }
/* Фиксируем высоту контейнера кнопок */
.box-header {
    min-height: 44px; /* подбери под свою высоту */
    align-items: center;
}

/* Контейнер кнопок - фиксированная высота */
.box-header > div:last-child {
    min-height: 26px; /* высота кнопки */
}
/* ========== МОДАЛКА ФОРМАТА СКАЧИВАНИЯ - ИСПРАВЛЕНИЕ ========== */
#downloadFormatButtons button.btn {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 12px 16px !important;
}

#downloadFormatButtons button.btn > span {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

#downloadFormatButtons button.btn > div {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    line-height: 1.3 !important;
}
#downloadFormatButtons button.btn > div {
    position: relative;
    top: -2px; /* подбери значение: -2px, -3px, -4px */
}

/* ========== МОДАЛКА ВЫБОРА ШАБЛОНА ========== */
#pickTemplateModal h3 {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

#pickTemplateModal h3 svg {
    flex-shrink: 0;
    margin-top: 4px; /* опускаем иконку */
}

#pickTemplateList button,
#pickTemplateList .template-item {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
}

#pickTemplateList svg {
    flex-shrink: 0;
    margin-top: 2px; /* опускаем иконку */
}
/* Сдвиг иконки и текста в кнопках прослушивания спикеров */
#speakerList button.btn-sm {
    padding-left: 10px; /* было ~12px, уменьшаем */
}

/* Или если нужно сдвинуть иконку внутри кнопки */
#speakerList button.btn-sm svg {
    margin-left: -2px;
}
/* Выравнивание иконок в кнопках шаблонов ИИ */
.ai-template-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-align: left;
}

/* ═══ Сообщение о применении правил — центрирование иконки ═══ */
#sidebarApplyMessage {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #3fb950;
    min-height: 20px;
    margin-bottom: 6px;
}

#sidebarApplyMessage:empty {
    display: none;
}

#sidebarApplyMessage svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}
/* ═══ Кнопка просмотра шаблона в модалке ═══ */
.btn-preview-template {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #8b949e;
    cursor: pointer;
    padding: 3px 4px 3px 4px;   /* 🔥 Как у корзины */
    border-radius: 6px;
    transition: 0.15s;  /* 🔥 Как у корзины */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;  /* 🔥 Как у корзины */
}

.btn-preview-template:hover {
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
}

.btn-preview-template.active {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.btn-preview-template svg {
    width: 14px;
    height: 14px;
}

/* ═══ Режим просмотра — overlay не блокирует модалку ═══ */
#correctionsOverlay.preview-mode {
    z-index: 2000;
}

#correctionsSidebar.preview-mode {
    z-index: 2600;
}

/* Модалка остаётся поверх overlay */
#addTemplateModal {
    z-index: 2500;
}
/* ═══ Корзина — сдвиг вверх ═══ */
#atmTemplateList .btn-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #8b949e;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 6px;
    transition: 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    top: -1px;  /* 🔥 Сдвиг вверх */
}