/* Режим реплик: кнопка в одном ряду с фильтрами голосов.
   Каталог и редактор озвучки не меняются — только скрываются в этом режиме. */

.voices-row {
    display: flex;
    align-items: flex-start;
    gap: 8px 10px;
    margin-bottom: 24px;
    min-width: 0;
}

.voices-row .tabs {
    flex: 1 1 auto;
    min-width: 0;
    margin-bottom: 0;
}

.replicas-toolbar-note {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 0.76rem;
    color: var(--muted);
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(168, 85, 247, 0.12), rgba(56, 189, 248, 0.06));
    border: 1px solid rgba(168, 85, 247, 0.28);
    align-self: center;
}

.replicas-toolbar-note[hidden] {
    display: none !important;
}

.replicas-toolbar-note strong {
    color: #e9d5ff;
    font-weight: 600;
}

.replicas-mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 0 0 auto;
    padding: 8px 14px;
    min-height: 38px;
    border-radius: 999px;
    border: 1px solid rgba(168, 85, 247, 0.45);
    background: rgba(168, 85, 247, 0.12);
    color: #e9d5ff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
}

.replicas-mode-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.replicas-mode-btn:hover {
    border-color: var(--border-active);
    background: rgba(168, 85, 247, 0.22);
    box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.18);
}

.replicas-mode-btn:focus-visible {
    outline: 2px solid rgba(168, 85, 247, 0.55);
    outline-offset: 2px;
}

.replicas-mode-btn.is-on,
body.replicas-mode .replicas-mode-btn {
    background: linear-gradient(135deg, #9333ea, #a855f7);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 18px var(--accent-glow);
}

body.replicas-mode .voices-row {
    align-items: center;
}

body.replicas-mode #voiceTabs,
body.replicas-mode #voiceCostHint,
body.replicas-mode #voiceGrid,
body.replicas-mode #voiceTopNote,
body.replicas-mode .voice-showcase__nav,
body.replicas-mode #editorSection {
    display: none !important;
}

body.replicas-mode .voice-showcase {
    display: block !important;
    grid-template-columns: unset;
}

body.replicas-mode .voice-showcase__viewport {
    overflow: visible;
    grid-column: auto;
}

body.replicas-mode #replicasWorkspace {
    display: flex;
}

.replicas-workspace {
    display: none;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    padding: 2px 2px 4px;
}

.replicas-workspace[hidden] {
    display: none !important;
}

.replicas-workspace__lead {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--muted);
}

.replicas-workspace__lines {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.replica-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    min-width: 0;
}

.replica-card__head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.replica-card__num {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 800;
    background: rgba(168, 85, 247, 0.16);
    color: #e9d5ff;
}

.replica-card__num.is-female {
    background: rgba(236, 72, 153, 0.18);
    color: #f9a8d4;
}

.replica-card__num.is-male {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
}

.replica-card__voice {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0c0e14;
    color: inherit;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.replica-card__voice:hover {
    border-color: rgba(168, 85, 247, 0.4);
    background: var(--surface-hover);
}

.replica-card__voice-text {
    flex: 1 1 auto;
    min-width: 0;
}

.replica-card__voice-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.replica-card .gender-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    background: var(--muted);
}

.replica-card__head:has(.replica-card__num.is-female) .gender-dot {
    background: var(--female);
}

.replica-card__head:has(.replica-card__num.is-male) .gender-dot {
    background: var(--male);
}

.replica-card__voice-tag {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.replica-card__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.replica-card__demo {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.replicas-play-icon {
    width: 14px;
    height: 14px;
    display: block;
}

.replicas-picker .demo-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.replica-card__demo:hover,
.replica-card__demo.playing {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: #e9d5ff;
}

.replica-card__demo.playing {
    background: var(--accent);
    color: #fff;
}

.replica-card__chev {
    display: none;
}

.replica-card__ops {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    padding: 2px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0c0e14;
}

.replica-card__op {
    width: 34px;
    height: 34px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.replica-card__icon {
    width: 16px;
    height: 16px;
    display: block;
}

.replica-card__op:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.replica-card__op:disabled {
    opacity: 0.25;
    cursor: default;
}

.replica-card__op--danger:hover:not(:disabled) {
    color: #fca5a5;
}

.replica-card__main {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.replica-card__textcol {
    min-width: 0;
    width: 100%;
}

.replica-card__style {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 8px;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #0c0e14;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.replica-card__style:focus {
    outline: 2px solid rgba(168, 85, 247, 0.55);
    outline-offset: 1px;
}

.replica-card textarea {
    display: block;
    width: 100%;
    min-height: 92px;
    max-height: 220px;
    padding: 12px 12px 28px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #0c0e14;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}

.replica-card textarea:focus {
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.replica-card textarea::placeholder {
    color: #6b7280;
}

.replica-card__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    min-height: 28px;
}

.replica-card__count {
    font-size: 0.75rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.replica-card__count.is-warn { color: #fbbf24; }
.replica-card__count.is-over { color: #ef4444; }

.replica-card__stress {
    margin-left: auto;
    border: none;
    background: transparent;
    color: #c4b5fd;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
}

.replica-card__stress:hover {
    background: var(--accent-soft);
}

.replica-pause {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 12px 18px;
    min-width: 0;
}

.replica-pause__rail {
    width: 2px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 2px;
    background: linear-gradient(#a855f7, rgba(168, 85, 247, 0.15));
}

.replica-pause__label {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--muted);
}

.replica-pause__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.replica-pause__chip {
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
}

.replica-pause__chip.is-on {
    background: var(--accent-soft);
    border-color: var(--border-active);
    color: #e9d5ff;
}

.replicas-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px dashed rgba(168, 85, 247, 0.4);
    background: rgba(168, 85, 247, 0.06);
    color: #e9d5ff;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.replicas-add:hover:not(:disabled) {
    background: rgba(168, 85, 247, 0.12);
    border-style: solid;
}

.replicas-add:disabled {
    opacity: 0.45;
    cursor: default;
}

.replicas-workspace__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.replicas-cost {
    font-size: 0.8rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    margin-right: auto;
}

.replicas-fmt {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.replicas-fmt__btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

.replicas-fmt__btn.is-on {
    background: var(--accent);
    color: #fff;
}

.replicas-build {
    flex: 1 1 220px;
    min-width: 180px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #9333ea, #7c3aed);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 24px var(--accent-glow);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.replicas-build svg {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
}

.replicas-build:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 32px var(--accent-glow);
}

.replicas-build:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.replicas-status {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--muted);
    text-align: center;
}

.replicas-status.is-error {
    color: #fca5a5;
}

.replicas-picker-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1480;
    background: rgba(0, 0, 0, 0.65);
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: auto;
}

.replicas-picker-overlay.is-open {
    display: flex;
}

.replicas-picker {
    width: min(920px, calc(100vw - 24px));
    max-height: min(86vh, 760px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.replicas-picker__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.replicas-picker__head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.replicas-picker__sub {
    margin: 4px 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.replicas-picker__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 16px 8px;
    flex-shrink: 0;
}

.replicas-picker__filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

.replicas-picker__filter.is-on {
    background: var(--accent-soft);
    border-color: var(--border-active);
    color: #e9d5ff;
}

.replicas-picker__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 10px;
    padding: 8px 16px 18px;
    overflow: auto;
    min-height: 0;
}

.replicas-picker__grid .voice-card {
    margin: 0;
}

@media (max-width: 720px) {
    .replicas-mode-btn {
        padding: 8px 12px;
        min-height: 38px;
        font-size: 0.8rem;
    }

    .replicas-toolbar-note,
    .replicas-workspace__lead {
        font-size: 0.75rem;
    }

    .replica-card__voice-tag {
        display: none;
    }
}

@media (max-width: 640px) {
    .replica-card {
        padding: 10px;
    }

    .replica-card__head {
        display: grid;
        grid-template-columns: 34px minmax(0, 1fr);
        grid-template-areas:
            "num voice"
            "actions actions";
        gap: 8px;
        align-items: center;
    }

    .replica-card__num { grid-area: num; }
    .replica-card__voice { grid-area: voice; }
    .replica-card__actions {
        grid-area: actions;
        justify-content: flex-end;
        width: 100%;
    }

    .replica-card textarea {
        min-height: 84px;
        padding: 12px;
        font-size: 0.92rem;
    }

    .replica-pause {
        padding: 6px 4px 10px 8px;
        overflow-x: auto;
    }
}

@media (max-width: 420px) {
    .replica-card__demo,
    .replica-card__op {
        width: 36px;
        height: 36px;
    }

    .replica-card__head {
        grid-template-columns: 34px minmax(0, 1fr);
    }
}

/* Узкий экран: «Реплики» — такая же таблетка, как фильтры, в общем переносе */
@media (max-width: 560px) {
    .voices-row {
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }

    body:not(.replicas-mode) .voices-row .tabs {
        display: contents;
    }

    .replicas-mode-btn {
        padding: 8px 18px;
        min-height: 0;
        font-size: 0.85rem;
        gap: 0;
    }

    body:not(.replicas-mode) .replicas-mode-btn svg {
        display: none;
    }
}

@media (max-width: 640px) {
    .replicas-workspace__bar {
        flex-direction: column;
        align-items: stretch;
    }

    .replicas-cost {
        margin-right: 0;
        text-align: center;
    }

    .replicas-fmt {
        justify-content: center;
        width: 100%;
    }

    .replicas-fmt__btn {
        flex: 1;
    }

    .replicas-build {
        width: 100%;
        flex: 1 1 auto;
    }

    .replicas-picker-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .replicas-picker {
        width: 100%;
        max-height: 88vh;
        border-radius: 16px 16px 0 0;
    }

    .replicas-picker__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 8px 12px 20px;
    }

    .replica-pause {
        padding-left: 10px;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .replica-pause__chips {
        flex-wrap: nowrap;
    }
}

@media (max-width: 420px) {
    .replicas-picker__grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .replica-card {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .replica-card__voice-tag,
    .replica-card__count,
    .replica-pause__label,
    .replica-pause__chip,
    .replicas-toolbar-note,
    .replicas-workspace__lead,
    .replicas-picker__sub {
        font-size: 0.75rem;
    }
}
