* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #07070e;
    --s1: #0e0e1c;
    --s2: #14142a;
    --border: #1e1e38;
    --gold: #f2c94c;
    --gold2: #e0a800;
    --text: #eeeef8;
    --dim: #5a5a78;
    --red: #ff4b4b;
    --green: #2dce89;
    --r: 14px;
}

html,
body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* ── HEADER ── */
.header {
    width: 100%;
    max-width: 460px;
    padding: 20px 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -.5px;
}

.logo em {
    color: var(--gold);
    font-style: normal;
}

.steps {
    display: flex;
    gap: 6px;
    align-items: center;
}

.step-dot {
    height: 7px;
    border-radius: 4px;
    background: var(--border);
    transition: all .35s cubic-bezier(.4, 0, .2, 1);
    width: 7px;
}

.step-dot.done {
    background: var(--gold2);
    width: 7px;
}

.step-dot.active {
    background: var(--gold);
    width: 22px;
}

/* ── MAIN ── */
main {
    width: 100%;
    max-width: 460px;
    padding: 20px 20px 0;
    flex: 1;
}

.page {
    display: none;
    animation: fadeUp .3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── STEP 1: RECORD ── */
.record-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    padding: 16px 0;
}

.record-ring {
    position: relative;
    width: 110px;
    height: 110px;
    cursor: pointer;
}

.ring-outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2.5px solid var(--gold);
    transition: all .3s;
}

.ring-pulse {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 1.5px solid var(--gold);
    opacity: 0;
}

.ring-btn {
    position: absolute;
    inset: 8px;
    background: var(--s2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    transition: all .3s;
    border: none;
    cursor: pointer;
    color: white;
}

.record-ring.recording .ring-outer {
    border-color: var(--red);
    box-shadow: 0 0 28px rgba(255, 75, 75, .4);
}

.record-ring.recording .ring-pulse {
    animation: pulse 1.2s ease-out infinite;
    border-color: var(--red);
}

.record-ring.recording .ring-btn {
    background: rgba(255, 75, 75, .12);
}

@keyframes pulse {
    0% {
        opacity: .7;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.6);
    }
}

.record-label {
    font-size: 13px;
    color: var(--dim);
    letter-spacing: .1em;
    text-transform: uppercase;
    font-weight: 600;
}

.waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 44px;
    width: 100%;
    opacity: 0;
    transition: opacity .4s;
}

.waveform.on {
    opacity: 1;
}

.wb {
    width: 4px;
    background: linear-gradient(to top, var(--gold2), var(--gold));
    border-radius: 3px;
    height: 6px;
    animation: wb .7s ease-in-out infinite;
}

@keyframes wb {

    0%,
    100% {
        height: 6px;
    }

    50% {
        height: 36px;
    }
}

.transcript-card {
    width: 100%;
    min-height: 110px;
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 16px 18px;
    position: relative;
    direction: rtl;
    font-family: 'Noto Nastaliq Urdu', serif;
    font-size: 20px;
    line-height: 2;
    text-align: right;
    transition: border-color .3s;
}

.transcript-card.has-text {
    border-color: rgba(242, 201, 76, .25);
}

.t-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--dim);
    font-size: 15px;
    white-space: nowrap;
    pointer-events: none;
    font-family: 'Noto Nastaliq Urdu', serif;
}

.t-final {
    color: var(--text);
}

.t-interim {
    color: var(--dim);
}

.stop-btn {
    display: none;
    padding: 11px 28px;
    border-radius: 50px;
    border: 2px solid var(--red);
    background: transparent;
    color: var(--red);
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}

.stop-btn:hover {
    background: rgba(255, 75, 75, .1);
}

.stop-btn.show {
    display: block;
}

.tip-text {
    font-size: 12px;
    color: var(--dim);
    text-align: center;
    line-height: 1.7;
}

/* ── TIMELINE ── */
.timeline-word {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gold);
    color: #000;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Noto Nastaliq Urdu', serif;
    cursor: grab;
    user-select: none;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.timeline-word:active {
    cursor: grabbing;
    box-shadow: 0 0 12px rgba(242, 201, 76, 0.8);
    transform: translateY(-50%) scale(1.05);
    z-index: 3;
}

.playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--red);
    z-index: 10;
    box-shadow: 0 0 8px var(--red);
    pointer-events: none;
    display: none;
}

.playhead.active {
    display: block;
}

/* ── STEP 2: STYLE ── */
.style-wrap {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.s-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--dim);
    margin-bottom: 10px;
}

.bg-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.bg-pill {
    flex: 1;
    min-width: 64px;
    height: 100px;
    border-radius: 10px;
    cursor: pointer;
    border: 2.5px solid transparent;
    transition: all .2s;
    position: relative;
    overflow: hidden;
}

.bg-pill.sel {
    border-color: var(--gold);
    box-shadow: 0 0 14px rgba(242, 201, 76, .35);
}

.bg-pill.upload-pill {
    background: var(--s2);
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-direction: column;
    gap: 4px;
    color: var(--dim);
    font-size: 13px;
}

.bg-pill.upload-pill span {
    font-size: 24px;
}

.style-btns,
.anim-btns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.style-btn,
.music-btn {
    padding: 10px 6px;
    border-radius: 9px;
    border: 2px solid var(--border);
    background: var(--s1);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all .2s;
}

.style-btn.sel,
.music-btn.sel {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(242, 201, 76, .05);
}

.music-row {
    display: flex;
    gap: 8px;
}

.music-btn {
    flex: 1;
    padding: 11px 8px;
}

.music-tag {
    display: none;
    margin-top: 8px;
    padding: 8px 14px;
    background: var(--s1);
    border-radius: 8px;
    font-size: 12px;
    color: var(--gold);
    border: 1px solid rgba(242, 201, 76, .2);
}

.music-tag.show {
    display: block;
}

.thumb-wrap {
    display: flex;
    justify-content: center;
}

#thumbCanvas {
    border-radius: 12px;
    border: 1px solid var(--border);
    width: 120px;
    height: 214px;
}

/* ── STEP 3: PREVIEW ── */
.preview-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

#previewCanvas {
    border-radius: 18px;
    width: 252px;
    height: 448px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .85), 0 0 0 1px var(--border);
}

.preview-btns {
    display: flex;
    gap: 10px;
}

.btn-play,
.nav-back {
    padding: 11px 22px;
    border-radius: 50px;
    border: 2px solid var(--border);
    background: var(--s2);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}

.btn-export,
.nav-next {
    padding: 11px 24px;
    border-radius: 50px;
    border: none;
    background: var(--gold);
    color: #000;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}

.btn-export:disabled,
.nav-next:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.exp-status {
    font-size: 13px;
    color: var(--dim);
    text-align: center;
    min-height: 20px;
}

.dl-btn {
    display: none;
    padding: 13px 36px;
    border-radius: 50px;
    background: linear-gradient(135deg, #1a8a4a, #0f5a30);
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
    box-shadow: 0 6px 24px rgba(29, 185, 84, .3);
}

.dl-btn.show {
    display: block;
}

/* ── NAV & MISC ── */
.nav {
    width: 100%;
    max-width: 460px;
    padding: 16px 20px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-back {
    padding: 11px 24px;
    background: transparent;
    color: var(--dim);
}

.nav-back:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--dim);
}

.nav-back:disabled {
    opacity: .3;
    cursor: not-allowed;
}

.nav-next {
    padding: 11px 28px;
}

.nav-next:hover:not(:disabled) {
    background: #ffd55e;
    transform: translateY(-1px);
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--s2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 500;
    z-index: 999;
    transition: transform .3s;
    white-space: nowrap;
    max-width: 90vw;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    background: rgba(242, 201, 76, .1);
    color: var(--gold);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    border: 1px solid rgba(242, 201, 76, .2);
    margin-bottom: 12px;
}

.page-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 4px;
}

.page-sub {
    font-size: 14px;
    color: var(--dim);
    margin-bottom: 20px;
    line-height: 1.5;
}