:root {
    --mol-purple:    #6C63FF;
    --mol-purple-dk: #5247d4;
    --mol-purple-lt: #eeedf8;
    --mol-ink:       #1e1b3a;
    --mol-ink-soft:  #6b6890;
    --mol-surface:   #ffffff;
    --mol-border:    #e8e7f3;
    --mol-error:     #e84057;
    --mol-radius:    18px;
    --mol-radius-sm: 10px;
    --mol-shadow:    0 12px 48px rgba(108,99,255,.14);
    --mol-font:      'Vazirmatn', 'Tahoma', sans-serif;
    --mol-t:         .28s cubic-bezier(.4,0,.2,1);
}

.mol-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px 40px;
    font-family: var(--mol-font);
    direction: rtl;
}

/* ── Mascot ── */
.mol-mascot {
    position: relative;
    width: 130px;
    height: 140px;
    margin-bottom: -8px;
    z-index: 2;
    filter: drop-shadow(0 8px 20px rgba(108,99,255,.22));
}

.mol-mascot-svg {
    width: 130px;
    height: 140px;
    display: block;
    /* overflow hidden clips hand elements below viewBox bottom */
    overflow: hidden;
}

/* SVG mouth transitions — done via opacity attribute in JS, CSS fallback */
#mouth-smile, #mouth-ooh {
    transition: opacity .25s ease;
}

/* Mascot body animations (CSS-only, safe) */
.mol-mascot--looking .mol-mascot-svg {
    transform: translateY(-3px) rotate(-3deg);
    transition: transform var(--mol-t);
}
.mol-mascot--thinking .mol-mascot-svg {
    animation: mol-wobble 1.1s infinite ease-in-out;
}
.mol-mascot--happy .mol-mascot-svg {
    animation: mol-bounce .55s ease;
}

/* Thinking dots */
.mol-thinking {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity .3s;
    height: 12px;
}
.mol-mascot--thinking .mol-thinking { opacity: 1; }
.mol-thinking span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--mol-purple);
    animation: mol-dot 1.2s infinite ease-in-out;
}
.mol-thinking span:nth-child(2) { animation-delay: .2s; }
.mol-thinking span:nth-child(3) { animation-delay: .4s; }

/* ── Card ── */
.mol-card {
    background: var(--mol-surface);
    border-radius: var(--mol-radius);
    box-shadow: var(--mol-shadow);
    padding: 36px 32px 32px;
    width: 100%;
    max-width: 400px;
    position: relative;
    overflow: hidden;
}
.mol-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--mol-purple), #a78bfa);
    border-radius: var(--mol-radius) var(--mol-radius) 0 0;
}

/* ── Steps ── */
.mol-step { animation: mol-fade-in .3s ease; }
.mol-step-hidden { display: none; }

/* ── Typography ── */
.mol-title {
    font-size: 1.35rem; font-weight: 700;
    color: var(--mol-ink); margin: 0 0 6px; text-align: center;
}
.mol-subtitle {
    font-size: .9rem; color: var(--mol-ink-soft);
    text-align: center; margin: 0 0 24px;
}

/* ── Input ── */
.mol-field-wrap { position: relative; margin-bottom: 10px; }
.mol-input {
    width: 100%; padding: 14px 48px 14px 18px;
    font-size: 1.1rem; font-family: var(--mol-font);
    border: 2px solid var(--mol-border); border-radius: var(--mol-radius-sm);
    color: var(--mol-ink); background: #fafafa; outline: none;
    transition: border-color var(--mol-t), box-shadow var(--mol-t);
    direction: ltr; text-align: center; letter-spacing: 2px; box-sizing: border-box;
}
.mol-input:focus {
    border-color: var(--mol-purple); background: #fff;
    box-shadow: 0 0 0 4px rgba(108,99,255,.12);
}
.mol-input::placeholder { color: #bbb; letter-spacing: 1px; }
.mol-input-icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--mol-ink-soft); width: 18px; height: 18px; display: flex; align-items: center;
}
.mol-input-icon svg { width: 18px; height: 18px; }

/* ── OTP boxes ── */
.mol-otp-boxes { display: flex; gap: 10px; justify-content: center; margin-bottom: 12px; direction: ltr; }
.mol-otp-digit {
    width: 52px; height: 60px; text-align: center;
    font-size: 1.5rem; font-weight: 700; font-family: var(--mol-font);
    border: 2px solid var(--mol-border); border-radius: 12px;
    background: #fafafa; color: var(--mol-ink); outline: none; caret-color: transparent;
    transition: border-color var(--mol-t), box-shadow var(--mol-t), transform var(--mol-t);
}
.mol-otp-digit:focus {
    border-color: var(--mol-purple); background: #fff;
    box-shadow: 0 0 0 4px rgba(108,99,255,.12); transform: translateY(-3px) scale(1.05);
}
.mol-otp-digit.mol-digit-filled {
    border-color: var(--mol-purple); color: var(--mol-purple-dk); background: var(--mol-purple-lt);
}

/* ── Error ── */
.mol-error { font-size: .82rem; color: var(--mol-error); text-align: center; min-height: 20px; margin-bottom: 10px; }

/* ── Buttons ── */
.mol-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 14px 20px; border: none; border-radius: var(--mol-radius-sm);
    font-family: var(--mol-font); font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: background var(--mol-t), transform var(--mol-t), box-shadow var(--mol-t);
}
.mol-btn-primary {
    background: var(--mol-purple); color: #fff; box-shadow: 0 4px 16px rgba(108,99,255,.35);
}
.mol-btn-primary:hover  { background: var(--mol-purple-dk); transform: translateY(-2px); box-shadow: 0 6px 22px rgba(108,99,255,.45); }
.mol-btn-primary:active { transform: translateY(0); }
.mol-btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.mol-btn-secondary { background: var(--mol-purple-lt); color: var(--mol-purple); margin-top: 12px; }
.mol-btn-secondary:hover { background: #ddd9f9; }
.mol-btn-spinner { display: flex; align-items: center; }
.mol-spin { width: 20px; height: 20px; animation: mol-rotate .8s linear infinite; }

/* ── Timer ── */
.mol-timer-wrap {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; margin-bottom: 20px; font-size: .85rem; color: var(--mol-ink-soft);
}
.mol-timer { font-weight: 700; color: var(--mol-ink); font-variant-numeric: tabular-nums; direction: ltr; }
.mol-resend-btn {
    background: none; border: none; color: var(--mol-purple);
    cursor: pointer; font-family: var(--mol-font); font-size: .85rem; font-weight: 600; padding: 0; display: none;
}
.mol-resend-btn.mol-resend-visible { display: inline; }
.mol-resend-btn:disabled { opacity: .4; cursor: default; }

/* ── Back button ── */
.mol-back-btn {
    position: absolute; top: 18px; left: 18px;
    background: var(--mol-purple-lt); border: none; border-radius: 8px;
    width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--mol-purple); transition: background var(--mol-t);
}
.mol-back-btn:hover { background: #ddd9f9; }
.mol-back-btn svg { width: 18px; height: 18px; }

/* ── Success ── */
.mol-success-icon { display: flex; justify-content: center; margin-bottom: 20px; }
.mol-success-icon svg { width: 72px; height: 72px; }
.mol-check-circle { stroke-dasharray: 157; stroke-dashoffset: 157; animation: mol-draw-circle .6s ease forwards; }
.mol-check-tick   { stroke-dasharray: 50;  stroke-dashoffset: 50;  animation: mol-draw-tick .4s ease .5s forwards; }

/* ── Shake ── */
@keyframes mol-shake {
    0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)} 40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)}
}
.mol-shake { animation: mol-shake .4s ease; }

/* ── Keyframes ── */
@keyframes mol-fade-in    { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
@keyframes mol-bounce     { 0%{transform:scale(1)} 30%{transform:scale(1.06) translateY(-14px)} 55%{transform:scale(1.04) translateY(-6px)} 75%{transform:scale(1.05) translateY(-10px)} 100%{transform:scale(1) translateY(0)} }
@keyframes mol-wobble     { 0%,100%{transform:rotate(0)} 25%{transform:rotate(-5deg)} 75%{transform:rotate(5deg)} }
@keyframes mol-dot        { 0%,80%,100%{transform:scale(.7);opacity:.5} 40%{transform:scale(1.2);opacity:1} }
@keyframes mol-rotate     { to{transform:rotate(360deg)} }
@keyframes mol-draw-circle{ to{stroke-dashoffset:0} }
@keyframes mol-draw-tick  { to{stroke-dashoffset:0} }

/* ── Responsive ── */
@media (max-width: 480px) {
    .mol-card { padding: 32px 20px 28px; }
    .mol-otp-digit { width: 44px; height: 54px; font-size: 1.3rem; }
    .mol-mascot { width: 110px; height: 120px; }
    .mol-mascot-svg { width: 110px; height: 120px; }
}
@media (prefers-reduced-motion: reduce) {
    *,*::before,*::after { animation-duration:.01ms!important; transition-duration:.01ms!important; }
}
