:root {
    --w-primary: #5b2dd6;
    --w-primary-strong: #4a1fbe;
    --w-soft: #efe9fc;
    --w-page-bg: #f4f5fa;
    --w-surface: #ffffff;
    --w-border: #dde1ee;
    --w-text: #232742;
    --w-muted: #6b7189;
    --w-ok: #1a9e63;
    --w-bad: #d63d3d;
}

body.wizard-page {
    background:
        radial-gradient(circle at 16% 14%, rgba(155, 110, 247, 0.16), transparent 45%),
        radial-gradient(circle at 86% 18%, rgba(255, 122, 178, 0.12), transparent 42%),
        radial-gradient(circle at 12% 88%, rgba(255, 217, 77, 0.08), transparent 40%),
        radial-gradient(circle at 50% 96%, rgba(91, 45, 214, 0.12), transparent 55%),
        linear-gradient(180deg, #fbf8ff 0%, #f1eafb 100%);
    background-attachment: fixed;
    color: var(--w-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    margin: 0;
}

.w-progress-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--w-border);
    padding: 10px 16px;
}

.w-progress-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.w-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--w-text);
    text-decoration: none;
    white-space: nowrap;
}

.w-brand-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--w-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.w-brand-dot svg { width: 68%; height: 68%; }

.w-progressbar {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 40px;
}

.w-bar-fill {
    position: absolute;
    left: 5%;
    top: 26px;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--w-primary), #9b6ef7);
    transition: width 0.35s ease;
    box-shadow: 0 1px 4px rgba(91, 45, 214, 0.35);
    min-width: 6px;
}

.w-progressbar::before {
    content: "";
    position: absolute;
    left: 5%;
    right: 5%;
    top: 27.5px;
    height: 3px;
    background: #e6e8f2;
    border-radius: 999px;
}

.w-pmark {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 2px;
    border-radius: 999px;
    font-size: 0.78rem;
    color: var(--w-muted);
    white-space: nowrap;
    cursor: pointer;
    background: #fff;
    padding-left: 6px;
    padding-right: 6px;
}

.w-pmark .w-pdot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e6e8f2;
    color: var(--w-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
}

.w-pmark.active { color: var(--w-primary); font-weight: 600; }
.w-pmark.active .w-pdot { background: var(--w-primary); color: #fff; }
.w-pmark.done { color: var(--w-ok); }
.w-pmark.done .w-pdot { background: var(--w-ok); color: #fff; }
.w-pmark.done .w-pdot::after { content: "✓"; }

.w-pct {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--w-primary);
    min-width: 40px;
    text-align: right;
}

.w-stage {
    max-width: 1100px;
    margin: 0 auto;
    padding: 84px 16px 32px;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: center;
}

.w-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.w-card {
    background: var(--w-surface);
    border: 1px solid var(--w-border);
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(20, 24, 60, 0.08);
    padding: 28px;
}

.w-q-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--w-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.w-q-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 8px 0 18px;
}

.w-q-hint {
    font-size: 0.85rem;
    color: var(--w-muted);
    margin-top: 6px;
}

.w-field {
    width: 100%;
    border: 1.5px solid var(--w-border);
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 1rem;
    background: #fff;
    color: var(--w-text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.w-field:focus {
    border-color: var(--w-primary);
    box-shadow: 0 0 0 3px rgba(91, 45, 214, 0.15);
}

.w-field.invalid {
    border-color: var(--w-bad);
    box-shadow: 0 0 0 3px rgba(214, 61, 61, 0.12);
}

.w-err {
    color: var(--w-bad);
    font-size: 0.8rem;
    margin-top: 6px;
    min-height: 1em;
}

.w-city-wrap {
    position: relative;
}

.w-city-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 30;
    background: #fff;
    border: 1.5px solid var(--w-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(30, 27, 75, 0.16);
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
}

.w-city-opt {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.92rem;
    color: var(--w-text);
    cursor: pointer;
    transition: background 0.12s ease;
}

.w-city-opt:hover,
.w-city-opt.on {
    background: rgba(91, 45, 214, 0.08);
    color: var(--w-primary-strong);
}

.w-city-empty {
    padding: 9px 12px;
    font-size: 0.85rem;
    color: var(--w-muted);
}

.w-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.w-chip {
    border: 1.5px solid var(--w-border);
    background: #fff;
    color: var(--w-text);
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.w-chip:hover { border-color: var(--w-primary); }

.w-chip.on {
    background: var(--w-soft);
    border-color: var(--w-primary);
    color: var(--w-primary-strong);
    font-weight: 600;
}

.w-occ-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.w-occ-card {
    border: 1.5px solid var(--w-border);
    border-radius: 14px;
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    background: #fff;
    transition: all 0.15s ease;
    font-size: 0.9rem;
    font-weight: 600;
}

.w-occ-card:hover { border-color: var(--w-primary); }

.w-occ-card.on {
    background: var(--w-soft);
    border-color: var(--w-primary);
    color: var(--w-primary-strong);
}

.w-scale {
    display: flex;
    gap: 8px;
    align-items: center;
}

.w-scale-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1.5px solid var(--w-border);
    background: #fff;
    font-weight: 700;
    font-size: 1rem;
    color: var(--w-text);
    cursor: pointer;
    transition: all 0.15s ease;
}

.w-scale-btn.on {
    background: var(--w-primary);
    border-color: var(--w-primary);
    color: #fff;
}

.w-nav {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    align-items: center;
}

.w-btn {
    border: none;
    border-radius: 12px;
    padding: 11px 22px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.w-btn-next {
    background: var(--w-primary);
    color: #fff;
}

.w-btn-next:hover { background: var(--w-primary-strong); }

.w-btn-next:disabled {
    background: #c9cbe0;
    cursor: not-allowed;
}

.w-btn-back {
    background: transparent;
    color: var(--w-muted);
    border: 1px solid var(--w-border);
}

.w-btn-back:hover { color: var(--w-text); }

.w-save-note {
    font-size: 0.75rem;
    color: var(--w-muted);
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.w-save-note .spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--w-border);
    border-top-color: var(--w-primary);
    border-radius: 50%;
    animation: w-spin 0.8s linear infinite;
    display: inline-block;
}

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

.w-toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    background: #2b2e42;
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.85rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    max-width: 90vw;
}

.w-toast.bad { background: var(--w-bad); }

.w-toast.ok { background: var(--w-ok); }

/* ---- Avatar column ---- */
.w-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.w-avatar-stage {
    width: 45vw;
    max-width: 520px;
    height: 80vh;
    max-height: 640px;
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.w-avatar-stage:not(.w-casting-stage) {
    background:
        radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0) 62%),
        radial-gradient(circle at 18% 82%, rgba(155, 110, 247, 0.24), transparent 55%),
        radial-gradient(circle at 84% 16%, rgba(255, 122, 178, 0.18), transparent 50%),
        linear-gradient(180deg, #fbf8ff 0%, #f1eafb 100%);
    border-radius: 34px;
    border: 1px solid rgba(91, 45, 214, 0.10);
    box-shadow: 0 20px 55px rgba(91, 45, 214, 0.18);
}

.w-avatar-svg {
    width: 100%;
    height: 100%;
    transform-origin: 50% 60%;
    filter: drop-shadow(0 16px 20px rgba(64, 34, 150, 0.30));
    animation: w-idle-breathe 3.4s ease-in-out infinite;
}

.w-avatar-svg .head { transform-box: fill-box; transform-origin: 50% 85%; transition: transform 0.3s ease; }
.w-avatar-svg .eyes { transform-box: fill-box; transform-origin: 50% 50%; transition: transform 0.2s ease; }
.w-avatar-svg .arm-l { transform-box: fill-box; transform-origin: 50% 3%; transition: transform 0.25s ease; }
.w-avatar-svg .arm-r { transform-box: fill-box; transform-origin: 50% 3%; transition: transform 0.25s ease; }
.w-avatar-svg .mouth { transition: transform 0.2s ease, opacity 0.2s ease; }
.w-avatar-svg .mouth-happy, .w-avatar-svg .mouth-o, .w-avatar-svg .mouth-confused { opacity: 0; }
.av-happy .mouth-happy, .av-magic .mouth-happy { opacity: 1; }
.av-typing .mouth-o { opacity: 1; }
.av-confused .mouth-confused { opacity: 1; }

@keyframes w-idle-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.015); }
}

.w-avatar-svg .eye-lid { opacity: 0; transform-origin: 50% 50%; transform-box: fill-box; }

@keyframes w-blink {
    0%, 92%, 100% { opacity: 0; }
    95% { opacity: 1; }
}

.w-avatar-svg .eyes.blink .eye-lid { animation: w-blink 4s infinite; }

.av-typing .w-avatar-svg { animation: w-type-bob 0.6s ease-in-out infinite; }

@keyframes w-type-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.av-typing .head { transform: rotate(3deg); }

.av-typing .arm-r { transform: rotate(-22deg); animation: w-scribble 0.5s ease-in-out infinite; }

@keyframes w-scribble {
    0%, 100% { transform: rotate(-22deg); }
    50% { transform: rotate(-13deg); }
}

.av-thinking .head { transform: rotate(7deg); }

.av-thinking .eyes { transform: translateY(-5px); }

.av-thinking .arm-l { transform: rotate(16deg); }

.av-thinking .w-avatar-svg { animation: w-think-tap 1.6s ease-in-out infinite; }

@keyframes w-think-tap {
    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.012); }
}

.av-happy .head { transform: rotate(-2.5deg); }

.av-happy .arm-l { transform: rotate(-30deg); }

.av-happy .arm-r { transform: rotate(30deg); }

.av-happy .w-avatar-svg { animation: w-happy-jump 0.7s ease-in-out 2; }

@keyframes w-happy-jump {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-6px) scale(1.02); }
}

.av-confused .head { transform: rotate(-8deg) translateX(2px); }

.av-confused .eyes { transform: translateY(2px); }

.av-magic .w-avatar-svg { animation: w-magic-glow 1.8s ease-in-out infinite; }

@keyframes w-magic-glow {
    0%, 100% { filter: drop-shadow(0 0 0 rgba(155, 110, 247, 0)); transform: scale(1); }
    50% { filter: drop-shadow(0 0 22px rgba(155, 110, 247, 0.55)); transform: scale(1.025); }
}

.mote { opacity: 0; transform-box: fill-box; transform-origin: center; transition: opacity 0.3s ease; }

.av-magic .mote { opacity: 0.8; animation: w-mote 2.6s ease-in-out infinite; }

.av-magic .mote.m2 { animation-delay: 0.4s; }

.av-magic .mote.m3 { animation-delay: 0.8s; }

.av-magic .mote.m4 { animation-delay: 1.2s; }

.av-magic .mote.m5 { animation-delay: 1.6s; }

.av-magic .mote.m6 { animation-delay: 2s; }

@keyframes w-mote {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.2; }
    50% { transform: translate(0, -20px) scale(1.4); opacity: 0.9; }
}

.w-avatar3d-el {
    position: absolute;
    inset: 0;
    display: none;
}

.w-avatar3d-el canvas {
    width: 100% !important;
    height: 100% !important;
}

.w-avatar3d-el.on { display: block; }

.w-avatar-svg.off { display: none; }

/* ---- Success ---- */
.w-success {
    text-align: center;
    max-width: 560px;
}

.w-success h2 { font-weight: 700; }

.w-success .occasion-id,
.w-success .lead-number {
    font-family: ui-monospace, monospace;
    background: var(--w-soft);
    color: var(--w-primary-strong);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.w-plan {
    text-align: left;
    background: #fff;
    border: 1px solid var(--w-border);
    border-radius: 12px;
    padding: 14px 16px;
}

.w-plan-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--w-border);
    margin-bottom: 8px;
}

.w-plan-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--w-border);
    font-size: 0.9rem;
}

.w-plan-item:last-of-type { border-bottom: 0; }

.w-plan-slot {
    flex: 0 0 92px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--w-primary-strong);
    background: var(--w-soft);
    border-radius: 999px;
    padding: 2px 10px;
    text-align: center;
}

.w-plan-title { flex: 1 1 auto; }

.w-plan-cost { color: var(--w-muted); font-variant-numeric: tabular-nums; }

/* ---- Mobile ---- */
@media (max-width: 900px) {
    .w-stage {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 74px 12px 96px;
    }

    .w-right { order: -1; }

    .w-avatar-stage {
        width: min(62vw, 320px);
        height: 180px;
        max-height: 180px;
        min-height: 0;
        margin-bottom: -34px;
        z-index: 2;
    }

    .w-card {
        z-index: 1;
        position: relative;
        padding: 22px 18px;
    }

    .w-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(6px);
        border-top: 1px solid var(--w-border);
        margin: 0;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        box-shadow: 0 -6px 20px rgba(20, 24, 60, 0.1);
    }

    .w-btn-next, .w-btn-back { flex: 1; justify-content: center; padding: 13px; }

    .w-pmark span:not(.w-pdot) { display: none; }

    .w-pmark { padding: 4px; }
    .w-q-title { font-size: 1.15rem; }
}

/* ---- Casting overlay (full-screen performance) ---- */
.w-avatar-stage.w-casting-stage {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-height: none;
    min-height: 0;
    margin: 0;
    z-index: 1500;
    background: #efe9fc;
}

.w-casting-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 40%, #ffffff 0%, #efe9fc 40%, #ded5f7 72%, #c9bcf0 100%);
    animation: w-cast-pulse 2.2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes w-cast-pulse {
    0%, 100% { opacity: 0.92; }
    50% { opacity: 1; }
}

.w-casting-stage::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 43%;
    width: min(66vw, 620px);
    height: min(66vw, 620px);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(155, 110, 247, 0.28) 45%, rgba(155, 110, 247, 0) 70%);
    animation: w-cast-halo 2.4s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes w-cast-halo {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.85; }
    50% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
}

.w-casting-stage .w-avatar-svg {
    width: min(58vw, 480px);
    height: min(76vh, 640px);
    position: relative;
    z-index: 2;
}

.w-casting-stage.av-magic .w-avatar-svg {
    animation: w-cast-enter 0.5s ease-out both, w-magic-glow 1.8s ease-in-out 0.5s infinite;
}

@keyframes w-cast-enter {
    0% { opacity: 0.25; transform: scale(0.72) translateY(4vh); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.w-casting-msg {
    position: absolute;
    bottom: 12%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    font-weight: 600;
    color: #4a2d9e;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d9cdf5;
    border-radius: 999px;
    padding: 10px 24px;
    font-size: 0.95rem;
    box-shadow: 0 10px 30px rgba(74, 45, 158, 0.18);
    white-space: nowrap;
    max-width: 88vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Casting state hides the wizard chrome ---- */
.w-casting-on .w-left,
.w-casting-on .w-progress-header {
    opacity: 0;
    visibility: hidden;
}

.w-casting-on .w-toast { display: none; }

.w-left,
.w-progress-header {
    transition: opacity 0.25s ease;
}

/* ---- Confetti + fireworks ---- */
.w-confetti {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 2100;
}

.w-conf-piece {
    position: absolute;
    top: -4vh;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    animation: w-fall linear forwards;
}

.w-firework {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 14px 5px currentColor;
    transform: translate(-50%, -50%);
    animation: w-burst 0.85s ease-out forwards;
}

.w-fire-ring {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 3px solid currentColor;
    box-shadow: 0 0 10px 2px currentColor;
    transform: translate(-50%, -50%);
    animation: w-ring 0.85s ease-out forwards;
}

@keyframes w-fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(108vh) rotate(720deg); opacity: 0.4; }
}

@keyframes w-burst {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    70% { transform: translate(-50%, -50%) scale(4); opacity: 0.85; }
    100% { transform: translate(-50%, -50%) scale(5.5); opacity: 0; }
}

@keyframes w-ring {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
    60% { transform: translate(-50%, -50%) scale(2.6); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(3.4); opacity: 0; }
}

/* ---- Queued (plan not ready yet) ---- */
.w-queued {
    text-align: left;
    background: #fdf6e3;
    border: 1px solid #f0dcae;
    border-radius: 12px;
    padding: 14px 16px;
}

.w-queued-title {
    font-weight: 700;
    color: #8a6116;
    margin-bottom: 4px;
}
