/* ===== NEW GENERATION LAYOUT (TEXT-TO-SPEECH) ===== */
/* Remove background from the main card wrapper since inner elements have their own cards */

html.audio-layout-locked {
    overflow: hidden;
    height: 100%;
}

body.section-audio.audio-tab-generator,
body.section-audio.audio-tab-voice-library,
body.section-audio.audio-tab-voice-changer,
body.section-audio.audio-tab-dubbing {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden !important;
}

#tab-panel-generator {
    height: calc(100vh - 180px);
    overflow: hidden;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

#tab-panel-voice-library {
    height: calc(100vh - 180px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#tab-panel-voice-changer {
    height: calc(100vh - 180px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#tab-panel-dubbing {
    height: calc(100vh - 180px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#tab-panel-voice-changer .voice-changer-section {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.voice-changer-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 32px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.voice-changer-controls-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-sizing: border-box;
}

.voice-changer-history-col #voice-changer-history-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    margin-top: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.voice-changer-history-col #voice-changer-history-list {
    flex: 1;
    min-height: 0;
}

#tab-panel-dubbing .dubbing-section {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.dubbing-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 32px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.dubbing-controls-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-sizing: border-box;
}

.dubbing-history-col .history-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    margin-top: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.dubbing-history-col #dubbing-history-list {
    flex: 1;
    min-height: 0;
}

.ui-gen-history-actions.ui-gen-history-actions-dubbing {
    width: 100%;
}

.ui-gen-history-actions .section-tour-help[data-section="dubbing"] {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    font-size: 16px;
    border-radius: 6px;
    margin-left: auto;
}

#tab-panel-voice-library .voice-library-section {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#tab-panel-voice-library .voice-library-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 8px;
    align-content: start;
    z-index: 1;
}

#tab-panel-voice-library .voice-library-card {
    min-height: 276px;
    overflow: visible;
    z-index: 1;
}

#tab-panel-voice-library .voice-library-card-meta {
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

#tab-panel-voice-library .voice-library-card-player,
#tab-panel-voice-library .voice-library-play-btn {
    position: relative;
    z-index: 2;
}

#tab-panel-voice-library .voice-library-grid::-webkit-scrollbar {
    width: 4px;
}

#tab-panel-voice-library .voice-library-grid::-webkit-scrollbar-track {
    background: transparent;
}

#tab-panel-voice-library .voice-library-grid::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}

.card.generation-section {
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
    margin: 0;
    /* Remove 24px bottom margin */
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.generation-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 24px;
    align-items: stretch;
    margin-top: 0;
    height: 100%;
    overflow: hidden;
    overflow-x: hidden;
}

@media (max-width: 1024px) {
    html.audio-layout-locked {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
    }

    body.section-audio.audio-tab-generator,
    body.section-audio.audio-tab-voice-library,
    body.section-audio.audio-tab-voice-changer,
    body.section-audio.audio-tab-dubbing {
        height: auto;
        max-height: none;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    #tab-panel-generator {
        height: auto;
        overflow-y: visible;
        overflow-x: hidden;
    }

    #tab-panel-voice-library {
        height: auto;
        overflow: visible;
    }

    #tab-panel-voice-changer {
        height: auto;
        overflow: visible;
    }

    #tab-panel-dubbing {
        height: auto;
        overflow: visible;
    }

    #tab-panel-voice-changer .voice-changer-section {
        height: auto;
        overflow: visible;
    }

    #tab-panel-dubbing .dubbing-section {
        height: auto;
        overflow: visible;
    }

    .voice-changer-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .dubbing-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .voice-changer-controls-col {
        overflow-y: visible;
        padding: 0;
    }

    .dubbing-controls-col {
        overflow-y: visible;
        padding: 0;
    }

    .voice-changer-history-col #voice-changer-history-section {
        height: auto;
    }

    .dubbing-history-col .history-section {
        height: auto;
        padding: 0;
    }

    #tab-panel-voice-library .voice-library-section {
        height: auto;
        overflow: visible;
    }

    #tab-panel-voice-library .voice-library-grid {
        overflow-y: visible;
        padding-right: 0;
    }

    .generation-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow-y: visible;
        overflow-x: hidden;
    }

    .generation-history-col {
        height: auto;
        align-self: auto;
    }
}

.generation-controls-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    padding-bottom: 20px;
    min-width: 0;
}

.generation-controls-col:has(.voice-dropdown.show),
.generation-controls-col:has(.model-dropdown.show) {
    overflow-y: hidden;
}

.generation-controls-col::-webkit-scrollbar {
    width: 6px;
}

.generation-controls-col::-webkit-scrollbar-track {
    background: transparent;
}

.generation-controls-col::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

.generation-controls-col::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.generation-history-col {
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 16px;
    height: 573px;
    max-height: 573px;
    min-height: 573px;
    align-self: flex-start;
    overflow: hidden;
    overflow-x: hidden;
    backdrop-filter: blur(20px) saturate(128%);
    -webkit-backdrop-filter: blur(20px) saturate(128%);
    box-shadow: var(--glass-shadow);
    min-width: 0;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 8px;
    margin-top: 16px;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}

/* Стили карточек внутри левой колонки (ввод текста, выбор голоса и т.д.) */
.ui-gen-card {
    background: var(--glass-bg);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px 20px;
    /* Уменьшено padding-top/bottom с 20px */
    position: relative;
    backdrop-filter: blur(18px) saturate(125%);
    -webkit-backdrop-filter: blur(18px) saturate(125%);
    box-shadow: var(--glass-shadow);
}

.ui-gen-card-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #6c7081;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Адаптируем существующие элементы внутри карточек */
.ui-gen-card textarea.textarea-input {
    background: rgba(27, 29, 44, 0.72);
    border: 1px solid rgba(151, 156, 184, 0.18);
    border-radius: 8px;
    box-shadow: none;
    padding: 16px;
    min-height: 120px;
    font-size: 15px;
    resize: none;
    width: 100%;
    color: #ffffff;
    outline: none;
    box-sizing: border-box;
}

.ui-gen-card textarea.textarea-input:focus {
    box-shadow: 0 0 0 2px rgba(168, 115, 255, 0.14);
    border: 1px solid rgba(168, 115, 255, 0.32);
}

/* Большие зеленые ползунки из референса */
.ui-gen-sliders {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ui-gen-slider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ui-gen-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #6c7081;
    letter-spacing: 0.05em;
}

.ui-gen-slider-value {
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    text-transform: none;
}

.ui-gen-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(86, 78, 129, 0.34);
    border-radius: 2px;
    outline: none;
}

.ui-gen-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 14px rgba(168, 115, 255, 0.56);
    transition: transform 0.2s, box-shadow 0.2s;
}

.ui-gen-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 14px rgba(168, 115, 255, 0.56);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ui-gen-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 18px rgba(168, 115, 255, 0.82);
}

@media (max-width: 720px) {
    .tts-controls-grid {
        grid-template-columns: 1fr !important;
    }
}

.ui-gen-prompt-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
    transform-origin: top center;
    transition: max-height 0.34s ease, opacity 0.24s ease, transform 0.34s ease, padding 0.34s ease, border-color 0.34s ease;
}

.ui-gen-prompt-card.is-collapsed {
    max-height: 0;
    opacity: 0;
    transform: translateY(-12px);
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-color: transparent;
    pointer-events: none;
}

.ui-gen-prompt-card.is-visible {
    max-height: 280px;
    opacity: 1;
    transform: translateY(0);
}

.tts-gender-chips {
    display: none;
    gap: 8px;
    margin-bottom: 10px;
}

.tts-gender-chips[data-visible="true"] {
    display: flex;
}

.tts-engine-chips {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.tts-engine-label {
    color: #9aa1b3;
    font-size: 12px;
    margin-right: 4px;
}

.tts-engine-chip {
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid rgba(151, 156, 184, 0.22);
    background: rgba(27, 29, 44, 0.55);
    color: #d3d6e0;
    font-size: 12px;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tts-engine-chip:hover {
    background: rgba(45, 48, 70, 0.7);
    border-color: rgba(168, 115, 255, 0.4);
}

.tts-engine-chip[data-active="true"] {
    background: rgba(168, 115, 255, 0.16);
    border-color: rgba(168, 115, 255, 0.7);
    color: #ffffff;
}

.generate-btn-queue-badge {
    position: absolute;
    top: 8px;
    right: 12px;
    z-index: 3;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.generate-btn-cost {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78em;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: rgba(243, 237, 255, 0.72);
}

.generate-btn-cost-sep {
    opacity: 0.5;
    margin-right: 2px;
}

.generate-btn-cost-icon {
    font-size: 16px !important;
    line-height: 1;
    color: #c4a2ff;
    font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
}

.generate-btn-cost-value {
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.92);
}

.history-item.is-pending {
    opacity: 0.78;
}

.history-item.is-failed {
    opacity: 0.78;
    border-color: rgba(255, 120, 120, 0.45) !important;
}

.history-status-badge.pending {
    color: #b89bff;
}

.history-status-badge.failed {
    color: #ffb4b4;
}

.history-pending-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
}

.history-pending-spinner {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.history-pending-eta {
    color: #b89bff;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    min-width: 36px;
}

.history-pending-spinner .generate-btn-dot {
    width: 6px;
    height: 6px;
    background: #b89bff;
    border-radius: 50%;
    animation: history-dot-bounce 1.2s infinite ease-in-out;
}

.history-pending-spinner .generate-btn-dot:nth-child(2) { animation-delay: 0.2s; }
.history-pending-spinner .generate-btn-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes history-dot-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.6; }
    40% { transform: translateY(-4px); opacity: 1; }
}

.history-failed-icon {
    font-size: 18px;
    padding: 0 12px;
}

.tts-seed-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.tts-seed-label {
    color: #9aa1b3;
    font-size: 12px;
}

.tts-seed-input {
    flex: 0 0 140px;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(27, 29, 44, 0.55);
    border: 1px solid rgba(151, 156, 184, 0.22);
    color: #d3d6e0;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    outline: none;
}

.tts-seed-input:focus {
    border-color: rgba(168, 115, 255, 0.7);
    background: rgba(45, 48, 70, 0.7);
}

.tts-seed-input::placeholder {
    color: #6f7588;
}

.tts-seed-clear {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(168, 115, 255, 0.18);
    border: 1px solid rgba(168, 115, 255, 0.4);
    color: #ffffff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.history-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.history-meta-row .history-meta {
    min-width: 0;
    flex: 0 1 auto;
}

.history-seed-chip {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(168, 115, 255, 0.12);
    border: 1px solid rgba(168, 115, 255, 0.32);
    color: #b89bff;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    font-family: inherit;
    flex: 0 0 auto;
}

.history-seed-chip:hover {
    background: rgba(168, 115, 255, 0.22);
    color: #ffffff;
}

/* Toggle reveal: smoothly slide-in / fade-out the conditional row that
   appears when "Разделить аудио" is on. Keeps layout flow continuous so
   neighbouring chips don't jump when the row toggles. */
.ui-gen-toggle-reveal {
    display: inline-flex;
    align-items: center;
    overflow: hidden;
    max-width: 360px;
    opacity: 1;
    transition: max-width 0.32s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.22s ease,
                margin 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.ui-gen-toggle-reveal[data-hidden="true"] {
    max-width: 0;
    opacity: 0;
    margin-left: -8px; /* eat the .ui-gen-toggles-row gap */
    pointer-events: none;
}

.tts-gender-chip {
    flex: 0 0 auto;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(151, 156, 184, 0.28);
    background: rgba(27, 29, 44, 0.55);
    color: #d3d6e0;
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.tts-gender-chip:hover {
    background: rgba(45, 48, 70, 0.7);
    border-color: rgba(168, 115, 255, 0.4);
}

.tts-gender-chip[data-active="true"] {
    background: rgba(168, 115, 255, 0.18);
    border-color: rgba(168, 115, 255, 0.7);
    color: #ffffff;
    box-shadow: 0 0 0 1px rgba(168, 115, 255, 0.55) inset;
}

.tts-style-prompt-input {
    width: 100%;
    min-height: 92px;
    resize: vertical;
    background: rgba(27, 29, 44, 0.72);
    border: 1px solid rgba(151, 156, 184, 0.18);
    border-radius: 10px;
    color: #ffffff;
    padding: 12px;
    font-size: 14px;
    line-height: 1.45;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tts-style-prompt-input::placeholder {
    color: #6f7588;
}

.tts-style-prompt-input:focus {
    border-color: rgba(168, 115, 255, 0.42);
    box-shadow: 0 0 0 2px rgba(168, 115, 255, 0.14);
}

.tts-style-prompt-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.tts-style-prompt-hint {
    color: #7b8195;
    font-size: 12px;
}

.tts-style-prompt-count {
    color: #9aa1b3;
    font-size: 12px;
    min-width: 52px;
    text-align: right;
}

/* Кнопка генерации - темно-серая */
.btn-generate-main {
    background: linear-gradient(180deg, rgba(84, 54, 135, 0.72) 0%, rgba(49, 35, 84, 0.82) 100%);
    color: #ffffff;
    border: 1px solid rgba(168, 115, 255, 0.42);
    border-radius: 12px;
    padding: 18px 24px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-top: 8px;
    position: relative;
    overflow: hidden;
}

.btn-generate-main:hover {
    background: linear-gradient(180deg, rgba(102, 65, 163, 0.82) 0%, rgba(57, 39, 98, 0.9) 100%);
    border-color: rgba(188, 146, 255, 0.62);
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28), 0 0 28px rgba(168, 115, 255, 0.2);
}

.btn-generate-main:active {
    transform: translateY(1px);
}

.btn-generate-main.loading {
    color: transparent;
    pointer-events: none;
}

.btn-generate-main svg {
    transition: transform 0.3s ease;
}

.btn-generate-main:hover svg {
    transform: scale(1.1) rotate(5deg);
}

/* Toggle (переключатели) в стиле Stitch */
.ui-gen-toggles-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    /* Уменьшено с 16px */
    width: 100%;
    align-items: center;
    flex-wrap: nowrap;
}

.ui-gen-toggles-row>* {
    flex: 1 1 0;
    min-width: 0;
}

.ui-gen-toggles-row>div {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.ui-gen-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #a0a5b5;
    justify-content: center;
}

.ui-gen-toggle svg {
    width: 14px;
    height: 14px;
}

.ui-gen-toggles-row .remove-pauses-toggle-switch {
    width: 42px !important;
    height: 24px !important;
    margin-top: 0 !important;
}

.ui-gen-toggles-row .remove-pauses-toggle-slider:before {
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
}

.ui-gen-toggles-row .remove-pauses-toggle-input:checked+.remove-pauses-toggle-slider:before {
    transform: translateX(18px);
}

.ui-gen-toggles-row .remove-pauses-label {
    font-size: 12px;
}

#remove-pauses-slider-wrapper {
    margin-left: 0 !important;
    min-width: 0 !important;
    gap: 6px !important;
}

#remove-pauses-slider-wrapper #max-pause-duration-slider {
    width: 90px !important;
    max-width: 90px !important;
}

#remove-pauses-slider-wrapper #max-pause-duration-value {
    font-size: 11px !important;
}

@media (max-width: 768px) {
    .ui-gen-toggles-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .ui-gen-toggles-row>.ui-gen-toggle {
        width: 100%;
        margin-top: 0 !important;
        justify-content: flex-start;
    }

    .ui-gen-toggles-row>div {
        width: 100%;
        display: flex !important;
        align-items: center;
        gap: 8px !important;
        justify-content: flex-start;
    }

    .ui-gen-toggles-row>div:last-of-type {
        flex-wrap: nowrap;
    }

    #remove-pauses-slider-wrapper {
        margin-left: 0 !important;
        width: auto;
        min-width: 0 !important;
        display: flex;
        align-items: center !important;
        gap: 8px;
        position: static !important;
        flex: 1 1 auto;
    }

    #remove-pauses-slider-wrapper>span:first-child {
        position: static !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        padding-bottom: 0 !important;
        text-align: left !important;
        white-space: nowrap;
        flex: 0 0 auto;
        width: auto !important;
    }

    #remove-pauses-slider-wrapper #max-pause-duration-slider {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        flex: 1 1 auto;
    }
}

/* Заголовок истории в правой колонке */
.ui-gen-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ui-gen-history-title {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}

.ui-gen-history-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ui-gen-history-actions.ui-gen-history-actions-generator {
    width: 100%;
}

.ui-gen-history-actions.ui-gen-history-actions-voice-changer {
    width: 100%;
    flex-wrap: nowrap;
}

.ui-gen-history-actions .section-tour-help[data-section="generator"] {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    font-size: 16px;
    border-radius: 6px;
    margin-left: auto;
}

.ui-gen-history-actions .section-tour-help[data-section="voice-changer"] {
    position: static;
    top: auto;
    right: auto;
    z-index: auto;
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    font-size: 16px;
    border-radius: 6px;
    margin-left: auto;
}

button.ui-gen-history-action-btn {
    background: rgba(25, 27, 42, 0.76) !important;
    border: 1px solid rgba(151, 156, 184, 0.22) !important;
    color: #a0a5b5 !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
}

button#history-select-all-btn.ui-gen-history-action-btn,
button#history-deselect-all-btn.ui-gen-history-action-btn,
button#voice-changer-history-select-all-btn.ui-gen-history-action-btn,
button#voice-changer-history-deselect-all-btn.ui-gen-history-action-btn {
    min-height: 30px !important;
    padding: 6px 10px !important;
    box-sizing: border-box !important;
    color: #fff !important;
    border-color: rgba(151, 156, 184, 0.3) !important;
}

button#history-select-all-btn.ui-gen-history-action-btn:hover,
button#history-deselect-all-btn.ui-gen-history-action-btn:hover,
button#voice-changer-history-select-all-btn.ui-gen-history-action-btn:hover,
button#voice-changer-history-deselect-all-btn.ui-gen-history-action-btn:hover {
    color: #fff !important;
    border-color: rgba(168, 115, 255, 0.46) !important;
    background: rgba(168, 115, 255, 0.12) !important;
}

button#dubbing-history-select-all-btn.ui-gen-history-action-btn,
button#dubbing-history-deselect-all-btn.ui-gen-history-action-btn {
    min-height: 30px !important;
    padding: 6px 10px !important;
    box-sizing: border-box !important;
    color: #fff !important;
    border-color: rgba(151, 156, 184, 0.3) !important;
}

button#dubbing-history-select-all-btn.ui-gen-history-action-btn:hover,
button#dubbing-history-deselect-all-btn.ui-gen-history-action-btn:hover {
    color: #fff !important;
    border-color: rgba(168, 115, 255, 0.46) !important;
    background: rgba(168, 115, 255, 0.12) !important;
}

button.ui-gen-history-action-btn:hover {
    background: rgba(31, 28, 52, 0.82) !important;
    color: #fff !important;
    border-color: rgba(168, 115, 255, 0.36) !important;
}

button.ui-gen-history-action-btn.icon-btn {
    padding: 6px !important;
    width: 30px !important;
    height: 30px !important;
}

button.ui-gen-history-action-btn.download-btn {
    color: var(--accent) !important;
}

button.ui-gen-history-action-btn.download-btn:hover {
    background: rgba(168, 115, 255, 0.1) !important;
    border-color: rgba(168, 115, 255, 0.32) !important;
}

button.ui-gen-history-action-btn.delete-btn {
    color: #ff4444 !important;
}

button#history-clear-btn.ui-gen-history-action-btn.delete-btn svg {
    width: 18px;
    height: 18px;
}

button.ui-gen-history-action-btn.delete-btn:hover {
    background: rgba(255, 68, 68, 0.1) !important;
    border-color: rgba(255, 68, 68, 0.5) !important;
}

/* Расположение голоса и модели — каждый на всю ширину */
.ui-gen-row-2col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Стили для элементов истории внутри правой колонки, чтобы гармонировали с новым фоном */
.generation-history-col .history-item {
    background: rgba(27, 29, 44, 0.72);
    border: 1px solid rgba(151, 156, 184, 0.18);
}

.generation-history-col .history-item:hover {
    border-color: rgba(168, 115, 255, 0.48);
}

/* === Tri-state split toggle ===
   Single switch with three positions: off · split · auto-split.
   Hidden shadow checkbox inputs keep legacy ids so tests can drive
   the same state machine programmatically. */

.split-tri-shadow-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    padding: 0;
}

.split-tri-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
    cursor: pointer;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 28px;
    transition: background-color 0.25s ease, border-color 0.25s ease;
    margin: 0;
    vertical-align: middle;
    user-select: none;
}

.split-tri-switch:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* State 1 (middle) — muted purple to signal "not final".
   State 2 (right) — full accent purple, matching the legacy on-state. */
.split-tri-switch[data-state="1"] {
    background-color: rgba(168, 115, 255, 0.42);
    border-color: rgba(168, 115, 255, 0.55);
}

.split-tri-switch[data-state="2"] {
    background-color: var(--accent);
    border-color: var(--accent);
}

.split-tri-knob {
    position: absolute;
    height: 20px;
    width: 20px;
    left: 4px;
    top: 50%;
    margin-top: -10px;
    background-color: white;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
    transform: translateX(0);
    pointer-events: none;
}

.split-tri-switch[data-state="1"] .split-tri-knob {
    transform: translateX(11px);
}

.split-tri-switch[data-state="2"] .split-tri-knob {
    transform: translateX(22px);
}

/* Match the .ui-gen-toggles-row compact sizing (42x24 + 16x16 knob) so
   the tri-state switch lines up pixel-for-pixel with the neighbouring
   "Удалить паузы" / "Создать субтитры" toggles inside that row. */
.ui-gen-toggles-row .split-tri-switch {
    width: 42px !important;
    height: 24px !important;
    border-radius: 24px;
}

.ui-gen-toggles-row .split-tri-knob {
    width: 16px;
    height: 16px;
    left: 3px;
    margin-top: -8px;
}

.ui-gen-toggles-row .split-tri-switch[data-state="1"] .split-tri-knob {
    transform: translateX(10px);
}

.ui-gen-toggles-row .split-tri-switch[data-state="2"] .split-tri-knob {
    transform: translateX(20px);
}

/* "Аудио в текст" pill — match the 28-px visual height of the toggle
   switches in this row and pick up a purple glow on hover. */
.ui-gen-toggles-row .audio-upload-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 12px;
    margin: 0;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: rgba(27, 29, 44, 0.55);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.ui-gen-toggles-row .audio-upload-pill:hover {
    background: rgba(168, 115, 255, 0.12);
    border-color: rgba(168, 115, 255, 0.55);
    box-shadow: 0 0 14px rgba(168, 115, 255, 0.22);
}

/* Square SEED button in the history row — matches the play/MP3/SRT pills
   geometrically and uses an accent purple instead of the green accent so
   it reads as "informational" rather than "action". */
.history-file-pill.history-seed-pill {
    color: #c4a2ff;
    border-color: rgba(196, 162, 255, 0.36);
}
.history-file-pill.history-seed-pill:hover {
    color: #fff;
    border-color: #a873ff;
    background: rgba(168, 115, 255, 0.14);
    box-shadow: 0 0 14px rgba(168, 115, 255, 0.22);
}

/* Engine chip that's locked out by the current seed binding — dimmed
   and shows a lock-cursor so the user knows clicking will surface the
   conflict popup. */
.tts-engine-chip[data-locked] {
    opacity: 0.45;
    cursor: not-allowed;
}
.tts-engine-chip[data-locked]:hover {
    opacity: 0.55;
}

/* Model selector + Seed input share a single row right below the toggles. */
.tts-engine-seed-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 12px 0 4px;
}
.tts-engine-seed-row .tts-engine-chips {
    flex: 1 1 auto;
    margin: 0;
}
.tts-engine-seed-row .tts-seed-row {
    flex: 0 0 auto;
    margin: 0;
}
@media (max-width: 720px) {
    .tts-engine-seed-row {
        flex-direction: column;
        align-items: stretch;
    }
    .tts-engine-seed-row .tts-seed-row {
        width: 100%;
    }
}
