/* Аудиостудия использует собственную сетку и локальные переменные: оформление не влияет
   на остальные генераторы. На широком экране форма и история прокручиваются независимо. */
.ala-audio {
    --audio-bg: #101214;
    --audio-panel: #191c1f;
    --audio-line: #303438;
    --audio-muted: #989fa5;
    --audio-accent: #22d3ee;
    display: grid;
    grid-template-columns:minmax(340px, 430px) minmax(0, 1fr);
    grid-template-rows:auto minmax(0, 1fr);
    gap: 20px;
    color: #f3f5f6;
    padding: 24px;
    margin: auto;
    height: var(--audio-studio-height, calc(100dvh - 80px));
    min-height: 600px;
    box-sizing: border-box
}

.ala-audio * {
    box-sizing: border-box
}

.ala-audio [hidden] {
    display: none !important
}

.ala-audio button, .ala-audio input, .ala-audio textarea, .ala-audio select {
    font: inherit
}

.ala-audio button {
    cursor: pointer
}

.ala-audio button:disabled {
    cursor: not-allowed;
    opacity: .5
}

.ala-audio :focus-visible {
    outline: 2px solid var(--audio-accent);
    outline-offset: 3px
}

.audio-page-heading {
    grid-column: 1/-1;
    display: flex;
    align-items: baseline;
    gap: 24px
}

.audio-page-heading h1 {
    font-size: 25px;
    margin: 0;
    font-weight: 650;
    letter-spacing: -.6px
}

.audio-page-heading p {
    color: var(--audio-muted);
    font-size: 13px;
    margin: 0
}

.audio-composer, .audio-library {
    min-width: 0;
    min-height: 0;
    border: 1px solid var(--audio-line);
    border-radius: 20px;
    background: var(--audio-bg);
    overflow: hidden
}

.audio-composer {
    display: flex;
    flex-direction: column
}

.audio-composer-heading {
    padding: 22px 24px 16px
}

.audio-eyebrow {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--audio-accent)
}

.audio-composer-heading h2 {
    font-size: 23px;
    letter-spacing: -.5px;
    margin: 8px 0 0;
    font-weight: 600
}

#audio-form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1
}

.audio-form-scroll {
    overflow: auto;
    padding: 4px 24px 24px;
    scrollbar-width: thin;
    scrollbar-color: #42484d transparent;
    min-height: 0
}

.audio-top-controls {
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
    margin-bottom: 22px
}

.audio-field {
    margin: 0 0 20px;
    min-width: 0
}

.audio-field label, .audio-section-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 9px
}

.audio-field label span, .audio-section-label span + span {
    font-size: 10px;
    color: var(--audio-muted);
    font-weight: 400
}

.audio-field small, .audio-help {
    display: block;
    font-size: 11px;
    line-height: 1.6;
    color: var(--audio-muted);
    margin: 7px 0 0
}

.ala-audio input:not([type=checkbox]):not([type=file]):not([type=range]), .ala-audio select, .ala-audio textarea {
    display: block;
    width: 100%;
    color: #f3f5f6;
    background: var(--audio-panel);
    border: 1px solid var(--audio-line);
    border-radius: 10px;
    padding: 11px 12px;
    box-shadow: none;
    line-height: 1.5;
    transition: border-color .15s
}

.ala-audio textarea {
    resize: vertical;
    min-height: 84px
}

.ala-audio textarea::placeholder, .ala-audio input::placeholder {
    color: #70787e
}

.ala-audio input:focus, .ala-audio textarea:focus, .ala-audio select:focus {
    border-color: #06b6d4
}

.ala-audio [aria-invalid=true] {
    border-color: #ed8f8f !important
}

.audio-field-row {
    display: grid;
    grid-template-columns:1fr 1fr;
    gap: 14px
}

/* Ползунок обновляет скрытый параметр запроса, а подпись показывает выбранное значение.
   Пустой параметр означает авто; ползунком можно управлять стрелками с клавиатуры. */
.ala-audio input[type=range] {
    display: block;
    width: 100%;
    height: 22px;
    margin: 8px 0 12px;
    padding: 0;
    accent-color: var(--audio-accent);
    cursor: pointer
}

.audio-details {
    border-top: 1px solid var(--audio-line);
    border-bottom: 1px solid var(--audio-line);
    margin: 6px 0 22px;
    padding: 15px 0
}

.audio-details summary {
    font-size: 13px;
    font-weight: 600;
    cursor: pointer
}

.audio-details[open] summary {
    margin-bottom: 20px
}

.audio-details .audio-field:last-child {
    margin-bottom: 0
}

.audio-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
    margin: 0 0 22px;
    cursor: pointer
}

.audio-toggle strong {
    font-size: 13px;
    font-weight: 500
}

.audio-toggle small {
    display: block;
    color: var(--audio-muted);
    font-size: 11px;
    margin-top: 4px
}

.audio-toggle input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px
}

.audio-switch {
    width: 34px;
    height: 20px;
    border-radius: 20px;
    background: #41474c;
    position: relative;
    flex: none;
    transition: background .15s
}

.audio-switch:after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    top: 3px;
    left: 3px;
    border-radius: 50%;
    background: #fff;
    transition: transform .15s
}

.audio-toggle input:checked + .audio-switch {
    background: var(--audio-accent)
}

.audio-toggle input:checked + .audio-switch:after {
    transform: translateX(14px);
    background: #ffffff
}

.audio-toggle input:focus-visible + .audio-switch {
    outline: 2px solid var(--audio-accent);
    outline-offset: 3px
}

.audio-custom-toggle {
    margin: 0;
    padding: 9px 0
}

/* Все типы референсов размещаются внутри одного контейнера. Кнопки удаления — отдельные
   элементы, поэтому плеер и удаление не открывают диалог загрузки повторно. */
.audio-reference-section {
    margin-bottom: 24px
}

.audio-upload-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border: 1px dashed #50575d;
    border-radius: 12px;
    background: var(--audio-panel);
    min-height: 76px
}

.audio-reference-list {
    display: contents
}

.audio-upload-button {
    flex: 1;
    min-height: 52px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #c9cfd3;
    font-size: 13px !important
}

.audio-upload-button:hover {
    background: #282e32
}

.has-references .audio-upload-button {
    flex: 0 0 62px;
    font-size: 28px !important
}

.audio-reference {
    position: relative;
    width: calc(50% - 4px);
    min-width: 110px;
    overflow: hidden;
    border: 1px solid var(--audio-line);
    border-radius: 8px;
    background: #24292d;
    padding: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center
}

.audio-reference img, .audio-reference video {
    height: 85px;
    width: 100%;
    object-fit: cover;
    border-radius: 5px
}

.audio-reference audio {
    width: 100%;
    height: 34px;
    margin-top: 22px
}

.audio-reference-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
    padding-top: 5px;
    color: var(--audio-muted)
}

.audio-reference-remove {
    position: absolute;
    right: 4px;
    top: 4px;
    width: 23px;
    height: 23px;
    border: 0;
    border-radius: 50%;
    background: #111d;
    color: white;
    line-height: 1
}

.audio-lyrics-section {
    margin-bottom: 22px
}

.audio-submit-area {
    flex: none;
    padding: 16px 24px;
    background: #191d20;
    border-top: 1px solid var(--audio-line)
}

.audio-generate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    border: 0;
    border-radius: 11px;
    background: #00e7ff;
    color: #000;
    font-weight: 650 !important
}

.audio-button-price {
    margin-left: auto;
    border-left: 1px solid #ffffff40;
    padding-left: 12px
}

.audio-price-note {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--audio-muted);
    font-size: 10px;
    margin: 10px 0 0
}

.audio-login {
    display: block;
    color: var(--audio-accent);
    font-size: 12px;
    margin-bottom: 12px
}

.audio-message {
    padding: 10px 12px;
    border-radius: 8px;
    background: #102c38;
    color: #bae6fd;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-line;
    margin-bottom: 12px
}

.audio-message-error {
    background: #3a2325;
    color: #ffb7b7
}

.audio-library {
    display: flex;
    flex-direction: column;
    background: #141719
}

.audio-library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--audio-line)
}

.audio-library-tabs {
    display: flex;
    gap: 18px
}

.audio-library-tabs button {
    border: 0;
    background: none;
    color: var(--audio-muted);
    padding: 6px 0;
    font-size: 13px
}

.audio-library-tabs button.is-active {
    color: #fff
}

.audio-library-tabs button span {
    background: #303639;
    padding: 2px 6px;
    border-radius: 5px;
    margin-left: 7px;
    font-size: 10px
}

.audio-library-label {
    font-size: 10px;
    letter-spacing: 2px;
    color: #80898e
}

#audio-history-panel, .audio-guide {
    overflow: auto;
    min-height: 0;
    flex: 1;
    padding: 24px;
    scrollbar-width: thin;
    scrollbar-color: #42484d transparent
}

#audio-history-panel {
    display: flex;
    flex-direction: column
}

.audio-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px 20px;
    min-height: 300px
}

.audio-empty:before {
    content: '♫';
    display: grid;
    place-items: center;
    font-size: 58px;
    color: var(--audio-accent);
    width: 110px;
    height: 110px;
    border: 1px solid #164e63;
    border-radius: 32px;
    background: linear-gradient(135deg, #164e63, #172554);
    margin-bottom: 32px;
    transform: rotate(-6deg)
}

.audio-empty h2, .audio-guide h2 {
    font-size: 28px;
    letter-spacing: -.7px;
    margin: 14px 0;
    font-weight: 500
}

.audio-empty p {
    font-size: 13px;
    line-height: 1.8;
    color: var(--audio-muted);
    max-width: 350px;
    margin-bottom: 22px
}

.audio-empty-action, .audio-load-more {
    background: transparent;
    border: 1px solid #155e75;
    color: #a5f3fc;
    padding: 10px 16px;
    border-radius: 9px;
    font-size: 12px
}

.audio-history {
    display: grid;
    gap: 18px
}

.audio-job {
    padding: 18px;
    border: 1px solid var(--audio-line);
    border-radius: 14px;
    background: #1b1f22
}

.audio-job-header {
    display: flex;
    justify-content: space-between;
    gap: 12px
}

.audio-job-title {
    font-size: 16px;
    margin: 0 0 7px;
    overflow-wrap: anywhere
}

.audio-job-meta {
    font-size: 10px;
    color: var(--audio-muted)
}

.audio-status {
    font-size: 10px;
    color: #67e8f9;
    white-space: nowrap
}

.audio-status-processing, .audio-status-pending {
    color: #e1cc8b;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.audio-status-processing::before, .audio-status-pending::before {
    content: '';
    width: 12px;
    height: 12px;
    flex: 0 0 12px;
    box-sizing: border-box;
    border: 2px solid rgba(225, 204, 139, 0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: audio-status-spin 0.8s linear infinite;
}

@keyframes audio-status-spin {
    to { transform: rotate(360deg); }
}

.audio-status-failed {
    color: #ffb7b7
}

.audio-job-prompt {
    font-size: 12px;
    color: #aeb6bb;
    margin: 14px 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap
}

.audio-tracks {
    display: grid;
    grid-template-columns:repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px
}

.audio-track {
    min-width: 0;
    padding: 12px;
    background: #101416;
    border-radius: 10px
}

.audio-track-top {
    display: flex;
    gap: 10px;
    margin-bottom: 12px
}

.audio-cover {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 7px;
    background: #163344;
    color: var(--audio-accent);
    display: grid;
    place-items: center;
    font-size: 24px;
    flex: none
}

.audio-track-info {
    min-width: 0
}

.audio-track-info h4 {
    font-size: 12px;
    margin: 4px 0;
    overflow-wrap: anywhere
}

.audio-track-info p {
    font-size: 10px;
    color: var(--audio-muted);
    margin: 0;
    overflow-wrap: anywhere
}

.audio-track audio {
    width: 100%;
    height: 34px
}

.audio-track-footer {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--audio-muted);
    margin-top: 10px
}

.audio-track-footer a {
    color: #67e8f9
}

.audio-progress {
    padding-top: 18px;
    color: #a5f3fc;
    font-size: 12px
}

.audio-load-more {
    align-self: center;
    margin-top: 20px
}

.audio-guide ol {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 26px;
    margin-top: 32px
}

.audio-guide li {
    display: flex;
    gap: 18px
}

.audio-guide li > span {
    color: var(--audio-accent);
    font-size: 12px
}

.audio-guide h3 {
    font-size: 16px;
    margin: 0 0 8px
}

.audio-guide p {
    color: var(--audio-muted);
    font-size: 12px;
    line-height: 1.8
}

.audio-mobile-tabs {
    display: none
}

.audio-sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap
}

.audio-button-spinner {
    display: none
}

/* На планшете сохраняются обе колонки; на телефоне переключатель освобождает место
   под форму или историю, а документ прокручивается естественно без вложенных ловушек. */
@media (max-width: 1100px) {
    .ala-audio {
        grid-template-columns:minmax(300px, 370px) minmax(0, 1fr);
        padding: 16px;
        gap: 14px
    }

    .audio-page-heading p {
        display: none
    }

    .audio-form-scroll {
        padding: 4px 18px 20px
    }

    .audio-composer-heading, .audio-library-header {
        padding: 18px
    }

    .audio-submit-area {
        padding: 16px 18px
    }

    #audio-history-panel, .audio-guide {
        padding: 16px
    }
}

@media (max-width: 760px) {
    .ala-audio {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 0;
        padding: 12px;
        gap: 12px
    }

    .audio-page-heading {
        order: -2
    }

    .audio-page-heading h1 {
        font-size: 22px
    }

    .audio-mobile-tabs {
        display: flex;
        order: -1;
        background: #1c2023;
        border-radius: 10px;
        padding: 4px;
        gap: 4px
    }

    .audio-mobile-tabs button {
        flex: 1;
        border: 0;
        border-radius: 7px;
        padding: 9px;
        background: none;
        color: var(--audio-muted);
        font-size: 12px
    }

    .audio-mobile-tabs button.is-active {
        background: #153749;
        color: #a5f3fc
    }

    .ala-audio[data-mobile-panel=create] .audio-library, .ala-audio[data-mobile-panel=history] .audio-composer {
        display: none
    }

    .audio-form-scroll {
        overflow: visible
    }

    .audio-library {
        min-height: 65vh
    }

    .audio-composer, .audio-library {
        border-radius: 14px
    }

    .audio-submit-area {
        position: sticky;
        bottom: 0;
        z-index: 2
    }

    .audio-empty h2 {
        font-size: 24px
    }

    .audio-tracks {
        grid-template-columns:1fr
    }
}

@media (prefers-reduced-motion: reduce) {
    .ala-audio * {
        transition: none !important
    }
}

.audio-generate:hover:not(:disabled) {
    background: linear-gradient(to right, #41daff, #2563eb)
}

/* Абсолютные подписи и скрытые чекбоксы привязаны к прокручиваемой форме.
   Без содержащего блока они могли расширять документ за нижнюю границу студии. */
.audio-form-scroll, .audio-field, .audio-toggle, .audio-top-controls {
    position: relative
}

.audio-sr-only {
    top: 0;
    left: 0;
    margin: 0 !important
}

.audio-toggle input {
    top: 0;
    left: 0;
    margin: 0
}

.ala-audio input[type=hidden] {
    display: none !important
}

.audio-range-value {
    margin-left: auto;
    color: var(--audio-accent);
    font-size: 12px;
    font-variant-numeric: tabular-nums
}

.audio-range-reset {
    border: 0;
    padding: 0;
    background: none;
    color: var(--audio-muted);
    font-size: 11px !important;
    text-decoration: underline
}

.audio-field .audio-field-error, .audio-field-error {
    color: #ffb7b7;
    font-size: 11px;
    line-height: 1.5
}
