* {
    box-sizing: border-box;
}

:root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
                 Tahoma, Arial, sans-serif;
    color: #20242a;
    background: #f3f5f8;
    font-size: 17px;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 85% 0,
            rgba(79,112,255,.07), transparent 27rem),
        linear-gradient(180deg,#fafbfc 0,#f2f4f7 100%);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: .46;
}

.topbar {
    min-height: 3.5rem;
    padding: .5rem 2.4%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid #e1e5ea;
    backdrop-filter: blur(12px);
}

.brand {
    display: flex;
    align-items: baseline;
    gap: .7rem;
}

.brand strong {
    font-size: 1.3rem;
    letter-spacing: -.02em;
}

.brand span {
    color: #626a73;
    font-size: .86rem;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.rasadeelm-brand-slot {
    flex: 0 0 auto;
}

.rasadeelm-brand-logo {
    display: block;
    width: auto;
    height: 4.30rem;
    max-width: 100%;
    object-fit: contain;
}

.engine-status {
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    color: #59616a;
    font-size: .84rem;
}

.engine-status i {
    width: .46rem;
    height: .46rem;
    border-radius: 50%;
    background: #25a65a;
}

.studio {
    width: min(95%, 1500px);
    margin: .65rem auto 1rem;
}

.intro {
    min-height: 3.8rem;
    margin-bottom: .6rem;
    padding: .15rem .2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.intro h1 {
    margin: 0;
    font-size: 1.16rem;
    font-weight: 750;
}

.intro p {
    margin: .22rem 0 0;
    color: #5f6770;
    font-size: .86rem;
}

.intro-note {
    padding: .38rem .65rem;
    white-space: nowrap;
    border: 1px solid #dde4eb;
    border-radius: 999px;
    background: rgba(255,255,255,.8);
    color: #59616a;
    font-size: .82rem;
}

.panel {
    background: rgba(255,255,255,.97);
    border: 1px solid #dde2e8;
    border-radius: .85rem;
    box-shadow: 0 .2rem 1rem rgba(27,35,45,.04);
}

.studio-grid {
    display: grid;
    grid-template-columns:
        minmax(0, 3fr)
        minmax(280px, .82fr);
    gap: .65rem;
    align-items: start;
}

.editor,
.production {
    padding: .75rem;
}

.panel-head,
.order-head {
    min-height: 2rem;
    margin-bottom: .48rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .65rem;
}

.panel-head > div:first-child,
.order-head > div:first-child {
    display: flex;
    align-items: baseline;
    gap: .55rem;
}

.panel-head strong,
.order-head strong {
    font-size: 1rem;
}

.panel-head span,
.order-head span {
    color: #626a73;
    font-size: .82rem;
}

.editor-tools {
    display: flex;
    align-items: center;
    gap: .42rem;
}

.editor-tools > span {
    direction: rtl;
}

.customer-text-area {
    position: relative;
}

.text-field {
    display: block;
}

textarea,
select,
input {
    width: 100%;
    outline: none;
    color: #20242a;
    background: #fff;
    border: 1px solid #d6dce2;
    border-radius: .58rem;
}

textarea:focus,
select:focus,
input:focus {
    border-color: #8996a5;
    box-shadow: 0 0 0 2px rgba(87,105,125,.07);
}

.primary-text textarea {
    height: clamp(315px, 48vh, 510px);
    min-height: 250px;
    padding: .8rem .85rem;
    resize: vertical;
    line-height: 1.9;
    font-size: .92rem;
}

.performance-edit {
    display: block;
    margin-top: .5rem;
}

.performance-edit > span {
    display: inline-block;
    margin: 0 0 .25rem .2rem;
    color: #737b84;
    font-size: .7rem;
    font-weight: 650;
}

.performance-edit textarea {
    height: 4.2rem;
    min-height: 4.2rem;
    max-height: 8rem;
    padding: .55rem .7rem;
    resize: vertical;
    line-height: 1.6;
    font-size: .8rem;
}

.voice-strip {
    margin-top: .55rem;
    display: grid;
    grid-template-columns:
        minmax(125px,.55fr)
        minmax(230px,1.35fr)
        auto;
    gap: .48rem;
    align-items: end;
}

.field {
    display: grid;
    gap: .24rem;
    min-width: 0;
}

.field > span {
    color: #555e67;
    font-size: .82rem;
    font-weight: 650;
}

select,
input {
    height: 2.25rem;
    padding: 0 .62rem;
}

.ghost,
.generate,
.play,
.compat-button {
    border: 0;
    border-radius: .52rem;
}

.ghost {
    padding: .48rem .7rem;
    background: #eef1f4;
    color: #30363d;
}

.ghost:hover:not(:disabled) {
    background: #e4e8ec;
}

.small {
    padding: .4rem .62rem;
    font-size: .82rem;
}

#saveProject {
    padding: .48rem .78rem;
    font-size: .9rem;
    font-weight: 650;
}

.sample-button {
    height: 2.25rem;
    padding-inline: .8rem;
    white-space: nowrap;
}

.production {
    position: sticky;
    top: .65rem;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(2,1fr);
    width: min(100%, 14rem);
    margin: 0 auto;
    gap: .35rem;
}

.metrics > div {
    min-width: 0;
    padding: .55rem .35rem;
    text-align: center;
    background: #f6f8fa;
    border: 1px solid #e5e9ed;
    border-radius: .52rem;
}

.metrics span {
    display: block;
    margin-bottom: .2rem;
    color: #454b53;
    font-size: .82rem;
    font-weight: 600;
}

.metrics b {
    display: inline-block;
    direction: rtl;
    font-size: .88rem;
    font-weight: 700;
}

.generate {
    display: block;
    width: min(100%, 14rem);
    height: 2.55rem;
    margin: .58rem auto 0;
    padding: 0 1.2rem;
    color: #fff;
    background: #252a31;
    font-weight: 700;
}

.generate:hover:not(:disabled) {
    background: #15191e;
}

.generation-progress {
    width: min(100%, 14rem);
    margin: .42rem auto 0;
}

.generation-progress[hidden] {
    display: none;
}

.generation-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .24rem;
    color: #626a73;
    font-size: .68rem;
    line-height: 1.45;
}

.generation-progress-state {
    flex: 0 0 auto;
    color: #747c85;
    font-size: .62rem;
}

.generation-progress-track {
    position: relative;
    width: 100%;
    height: .38rem;
    overflow: hidden;
    border-radius: 999rem;
    background: #e3e7eb;
}

.generation-progress-track i {
    position: absolute;
    inset-block: 0;
    right: 0;
    width: 24%;
    border-radius: inherit;
    background: #252a31;
    transition: width .28s ease;
}

.generation-progress.is-working
.generation-progress-track i {
    animation: none;
}

.generation-progress.is-ready
.generation-progress-track i {
    width: 100%;
    animation: none;
}

.generation-progress.is-failed
.generation-progress-track i {
    width: 100%;
    animation: none;
    opacity: .35;
}

/* RASADELM_GOOYASAZI_FORWARD_PROGRESS_V2 */

.player {
    margin-top: .58rem;
    padding: .58rem;
    background: #f8f9fb;
    border: 1px solid #e3e7eb;
    border-radius: .6rem;
}

.player-main {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.play {
    flex: 0 0 2rem;
    width: 2rem;
    height: 2rem;
    padding: 0;
    color: #fff;
    background: #272c32;
}

.player-main > div {
    min-width: 0;
}

.player-main strong,
.player-main span {
    display: block;
}

.player-main strong {
    font-size: .88rem;
}

.player-main span {
    margin-top: .1rem;
    overflow: hidden;
    color: #626a73;
    font-size: .8rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.timeline {
    height: .25rem;
    margin-top: .55rem;
    overflow: hidden;
    border-radius: 999px;
    background: #dfe4e8;
}

.timeline i {
    display: block;
    width: 0;
    height: 100%;
    background: #252a30;
}

.player-meta {
    margin-top: .27rem;
    display: flex;
    justify-content: space-between;
    direction: ltr;
    color: #69717a;
    font-size: .78rem;
}

.versions {
    margin-top: .48rem;
}

.empty,
.version-item {
    padding: .52rem .45rem;
    text-align: center;
    color: #8a9198;
    border: 1px dashed #d9dde2;
    border-radius: .5rem;
    font-size: .8rem;
}

.output-actions {
    margin-top: .48rem;
    display: flex;
    justify-content: center;
}

.download {
    min-width: 8.5rem;
}

.privacy-note {
    margin-top: .55rem;
    padding-top: .5rem;
    text-align: center;
    color: #737b84;
    border-top: 1px solid #eceef1;
    font-size: .78rem;
}

.compat-fields,
.compat-inline,
.compat-button {
    display: none !important;
}

@media (max-width: 900px) {
    .studio-grid {
        grid-template-columns: 1fr;
    }

    .production {
        position: static;
    }

    .primary-text textarea {
        height: 320px;
    }
}

@media (max-width: 620px) {
    :root {
        font-size: 16px;
    }

    .topbar {
        padding-inline: 3%;
    }

    .brand span,
    .intro-note {
        display: none;
    }

    .studio {
        width: 95%;
    }

    .intro {
        min-height: auto;
        padding-block: .25rem;
    }

    .intro p {
        line-height: 1.6;
    }

    .voice-strip {
        grid-template-columns: 1fr 1fr;
    }

    .voice-select {
        grid-column: 1 / -1;
    }

    .sample-button {
        width: auto;
    }

    .primary-text textarea {
        height: 250px;
    }
}

/* ===== Customer editor mode V2 ===== */

.intro h1 {
    font-size: 1.32rem;
    line-height: 1.45;
}

.intro p {
    font-size: .82rem;
    line-height: 1.65;
}

.intro-note {
    font-size: .76rem;
}

.panel-head span,
.field > span,
.text-field > span,
.performance-edit > span,
.performance-head > span {
    font-size: .78rem;
}

.customer-text-area {
    position: relative;
}

.primary-text,
.performance-edit {
    display: block;
}

.performance-edit {
    display: none;
}

.customer-text-area.reading-mode .primary-text {
    display: none;
}

.customer-text-area.reading-mode .performance-edit {
    display: block;
}

.performance-head {
    min-height: 1.8rem;
    margin-bottom: .3rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
}

.performance-head > span {
    color: #555d66;
    font-weight: 700;
}

.performance-edit textarea {
    width: 100%;
    height: clamp(330px, 48vh, 520px);
    min-height: 260px;
    line-height: 1.85;
}

.primary-text textarea {
    line-height: 1.85;
}

.editor-mode-button {
    white-space: nowrap;
}

.player-main span,
.empty,
.studio-footer {
    font-size: .73rem;
    line-height: 1.55;
}

@media (max-width: 680px) {
    .intro h1 {
        font-size: 1.16rem;
    }

    .intro p {
        font-size: .86rem;
    }

    .performance-edit textarea {
        height: 300px;
    }
}


/* ===== FINAL CUSTOMER POLISH 20260915 ===== */

/*
 * Customer-facing explanatory text:
 * larger and darker for normal reading distance.
 */
.intro p {
    font-size: .9rem;
    line-height: 1.7;
    color: #626a73;
}

.intro-note {
    font-size: .82rem;
    color: #626a73;
}

.panel-head span {
    font-size: .8rem;
    color: #6b737c;
}

.page-by-page-note {
    margin: 0 0 .48rem;
    color: #6b737c;
    font-size: .8rem;
    line-height: 1.65;
}

.field > span,
.text-field > span,
.performance-edit > span,
.performance-head > span {
    font-size: .8rem;
    color: #606872;
}

.player-main span,
.empty,
.studio-footer {
    font-size: .78rem;
    line-height: 1.6;
    color: #747c85;
}

/*
 * Language / narrator / sample:
 * natural widths, centered beneath editor.
 * Avoid stretching narrator selector across unused space.
 */
.voice-strip {
    width: min(100%, 700px);
    margin: .7rem auto 0;
    display: grid;
    grid-template-columns:
        minmax(150px, 190px)
        minmax(260px, 330px)
        minmax(130px, 160px);
    justify-content: center;
    gap: .65rem;
    align-items: end;
}

.voice-strip .language {
    grid-column: 1;
}

.voice-strip .voice-select {
    grid-column: 2;
}

.voice-strip .sample-button {
    grid-column: 3;
    width: 100%;
}

.voice-strip select {
    width: 100%;
}

@media (max-width: 680px) {
    .intro p {
        font-size: .9rem;
    }

    .intro-note,
    .panel-head span,
    .field > span,
    .text-field > span,
    .performance-edit > span,
    .performance-head > span,
    .page-by-page-note {
        font-size: .82rem;
    }

    .voice-strip {
        width: 100%;
        grid-template-columns: 1fr;
    }

    .voice-strip .language,
    .voice-strip .voice-select,
    .voice-strip .sample-button {
        grid-column: 1;
    }
}

/* ===== Customer footer: Persian-only / two compact controls ===== */

.voice-strip {
    grid-template-columns: minmax(250px, 430px) auto !important;
    justify-content: center !important;
    align-items: end !important;
    gap: .65rem !important;
}

.voice-select {
    width: 100%;
}

.sample-button {
    width: auto !important;
    min-width: 8rem;
    white-space: nowrap;
}

@media (max-width: 680px) {
    .voice-strip {
        grid-template-columns: minmax(0, 1fr) auto !important;
        justify-content: stretch !important;
    }

    .sample-button {
        min-width: 7.5rem;
    }
}

/* ===== Final customer voice controls alignment ===== */
.voice-strip {
    display: flex !important;
    justify-content: center !important;
    align-items: flex-end !important;
    gap: .65rem !important;
    width: 100% !important;
}

.voice-strip .voice-select {
    flex: 0 0 18rem !important;
    width: 18rem !important;
}

.voice-strip .sample-button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 8rem !important;
}

@media (max-width: 680px) {
    .voice-strip {
        flex-wrap: wrap !important;
    }

    .voice-strip .voice-select {
        flex: 0 1 18rem !important;
        width: min(18rem, 100%) !important;
    }
}

/* Pronunciation guidance below the text-entry panel */
.pronunciation-guidance{
    font-size:.8rem;
    line-height:1.65;
    color:#6b737c;
    width:100%;
    margin-top:1%;
    margin-bottom:1%;
    white-space:normal;
    overflow-wrap:anywhere;
}

/* Ketab Gooya: explicit return to RasadeElm landing */
.studio-close{
    display:flex;
    align-items:center;
    justify-content:center;
    width:2rem;
    aspect-ratio:1;
    flex:0 0 auto;
    border:1px solid currentColor;
    border-radius:50%;
    color:inherit;
    text-decoration:none;
    font-size:1.35rem;
    font-weight:400;
    line-height:1;
    opacity:.58;
    transition:opacity .18s ease, transform .18s ease;
}

.studio-close:hover,
.studio-close:focus-visible{
    opacity:1;
    transform:scale(1.05);
}



/* RASADELM_AUDIOBOOK_ENTRY_BUTTON_V1 */
.audiobook-entry-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    min-height: 2.65rem;
    padding: .55rem 1.15rem;
    white-space: nowrap;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 999px;
    background: linear-gradient(135deg, #ff4f9a 0%, #f41475 48%, #d90a61 100%);
    color: #fff;
    font-size: .9rem;
    font-weight: 800;
    text-decoration: none;
    box-shadow:
        0 7px 18px rgba(226, 18, 103, .28),
        inset 0 1px 0 rgba(255,255,255,.5);
    transition:
        transform .18s ease,
        box-shadow .18s ease,
        filter .18s ease;
}

.audiobook-entry-button:hover {
    transform: translateY(-2px);
    filter: brightness(1.06);
    box-shadow:
        0 10px 24px rgba(226, 18, 103, .38),
        inset 0 1px 0 rgba(255,255,255,.55);
}

.audiobook-entry-button:active {
    transform: translateY(0);
}

.audiobook-entry-arrow {
    font-size: 1.05rem;
    line-height: 1;
}

@media (max-width: 680px) {
    .audiobook-entry-button {
        min-height: 2.4rem;
        padding: .48rem .85rem;
        font-size: .8rem;
    }
}

/* RASADELM_AUDIOBOOK_ENTRY_BUTTON_VISUAL_FIX_V2 */
.intro .audiobook-entry-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    min-width: 170px;
    min-height: 44px;
    padding: .58rem 1.25rem;
    border: 1px solid #ff78b3;
    border-radius: 12px;
    background: linear-gradient(135deg, #ff3f91 0%, #ed176f 52%, #c90055 100%);
    color: #ffffff;
    font-size: .92rem;
    font-weight: 800;
    line-height: 1.2;
    text-decoration: none;
    text-shadow: 0 1px 1px rgba(80,0,30,.20);
    box-shadow:
        0 7px 18px rgba(210,0,82,.32),
        0 2px 5px rgba(0,0,0,.12),
        inset 0 1px 0 rgba(255,255,255,.48);
    cursor: pointer;
}

.intro .audiobook-entry-button:visited {
    color: #ffffff;
}

.intro .audiobook-entry-button:hover {
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-2px);
    background: linear-gradient(135deg, #ff58a0 0%, #f21b76 52%, #d4075d 100%);
    box-shadow:
        0 10px 23px rgba(210,0,82,.40),
        0 3px 7px rgba(0,0,0,.13),
        inset 0 1px 0 rgba(255,255,255,.55);
}

.intro .audiobook-entry-arrow {
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 900;
}

@media (max-width: 680px) {
    .intro .audiobook-entry-button {
        display: inline-flex;
        min-width: 150px;
        min-height: 40px;
        padding: .5rem .9rem;
        font-size: .82rem;
    }
}
