:root {
    /* ---- Design tokens: color ---- */
    --color-bg: #090B16;
    --color-bg-elevated: #10131F;
    --color-surface: rgba(255, 255, 255, 0.045);
    --color-surface-hover: rgba(255, 255, 255, 0.075);
    --color-primary: #6366F1;
    --color-primary-2: #8B5CF6;
    --color-gold: #F6C453;
    --color-primary-soft: rgba(99, 102, 241, 0.16);
    --color-primary-line: rgba(99, 102, 241, 0.5);
    --color-text: #F5F5FA;
    --color-text-dim: #9A9CB8;
    --color-text-faint: #5C5F7A;
    --color-border: rgba(255, 255, 255, 0.09);
    --color-border-strong: rgba(255, 255, 255, 0.16);

    /* ---- Design tokens: gradients ---- */
    --gradient-primary: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    --gradient-bg:
        radial-gradient(560px circle at 14% -6%, rgba(99, 102, 241, 0.22), transparent 60%),
        radial-gradient(480px circle at 92% 10%, rgba(139, 92, 246, 0.16), transparent 55%),
        radial-gradient(640px circle at 50% 108%, rgba(99, 102, 241, 0.12), transparent 60%);

    /* ---- Design tokens: radius ---- */
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --radius-full: 999px;

    /* ---- Design tokens: spacing (8pt grid) ---- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
    --space-6: 40px;

    /* ---- Design tokens: shadow / glow ---- */
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 52px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 10px 30px rgba(99, 102, 241, 0.35);
    --shadow-glow-strong: 0 0 0 1px rgba(99, 102, 241, 0.5), 0 12px 34px rgba(99, 102, 241, 0.4);

    /* ---- Design tokens: motion ---- */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --dur-fast: 180ms;
    --dur: 260ms;

    /* ---- Layout ---- */
    --header-h: 72px;
    --progress-h: 4px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* ---- Backward-compatible aliases (kept so existing rules below stay short) ---- */
    --bg: var(--color-bg);
    --bg-alt: var(--color-bg-elevated);
    --surface: var(--color-surface);
    --surface-alt: var(--color-surface-hover);
    --accent: var(--color-primary);
    --accent-soft: var(--color-primary-soft);
    --accent-line: var(--color-primary-line);
    --text: var(--color-text);
    --text-dim: var(--color-text-dim);
    --text-faint: var(--color-text-faint);
    --border: var(--color-border);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

body {
    background-image: var(--gradient-bg);
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.app {
    min-height: 100dvh;
    min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    background: transparent;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ---------- HEADER ---------- */
.app-header {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: calc(var(--header-h) + var(--safe-top));
    padding-top: var(--safe-top);
    background: rgba(9, 11, 22, 0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.logo {
    width: 58px;
    height: auto;
    display: block;
    filter: drop-shadow(0 4px 16px rgba(99, 102, 241, 0.35));
}

.icon-btn {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    color: var(--text);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.icon-btn:active { transform: scale(0.92); }
.icon-btn:hover { border-color: var(--color-border-strong); }

.back-btn {
    position: absolute;
    left: 16px;
    top: calc(50% + var(--safe-top) / 2);
    transform: translateY(-50%);
    opacity: 0;
    pointer-events: none;
}

.history-btn {
    position: absolute;
    right: 16px;
    top: calc(50% + var(--safe-top) / 2);
    transform: translateY(-50%);
}

.back-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ---------- PROGRESS BAR ---------- */
.progress-bar {
    position: fixed;
    top: calc(var(--header-h) + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--bg);
    z-index: 90;
}

.progress-seg {
    flex: 1;
    height: 5px;
    border-radius: var(--radius-full);
    background: var(--color-border-strong);
    overflow: hidden;
    position: relative;
}

.progress-seg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 400ms var(--ease);
}

.progress-seg.done::after,
.progress-seg.active::after {
    transform: scaleX(1);
}

/* ---------- STEPS ---------- */
.steps {
    flex: 1;
    position: relative;
    padding-top: calc(var(--header-h) + var(--safe-top) + 40px);
    overflow: hidden;
}

.step {
    position: absolute;
    inset: 0;
    top: calc(var(--header-h) + var(--safe-top) + 40px);
    display: flex;
    flex-direction: column;
    padding: var(--space-2) var(--space-4) calc(var(--space-4) + var(--safe-bottom));
    opacity: 0;
    transform: translateX(24px);
    pointer-events: none;
    transition: opacity 320ms var(--ease), transform 320ms var(--ease);
}

.step.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.step.leaving-back {
    transform: translateX(24px);
}

.step.prev {
    transform: translateX(-24px);
    opacity: 0;
}

.step-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
}

.step-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.step-header-text {
    flex: 1;
    min-width: 0;
}

.step-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 4px 0 8px;
}

.step-sub {
    font-size: 15.5px;
    line-height: 1.5;
    color: var(--text-dim);
    margin: 0 0 var(--space-5);
}

.step-header-text .step-sub {
    margin: 0;
}

.step-illustration {
    position: relative;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 42%, rgba(99, 102, 241, 0.35), rgba(99, 102, 241, 0.04) 72%);
    border: 1px solid var(--color-border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.step-illustration svg {
    width: 32px;
    height: 32px;
}

.step-illustration::before,
.step-illustration::after {
    content: "";
    position: absolute;
    background: var(--color-gold);
    clip-path: polygon(50% 0%, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0% 50%, 37% 37%);
    opacity: 0.85;
}

.step-illustration::before {
    top: 0;
    left: 8px;
    width: 9px;
    height: 9px;
}

.step-illustration::after {
    bottom: 6px;
    right: -2px;
    width: 6px;
    height: 6px;
    background: var(--color-primary-2);
}

/* ---------- GENDER CARDS ---------- */
.gender-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.gender-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    min-height: 84px;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    position: relative;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.gender-card:active { transform: scale(0.98); }

.gender-card.selected {
    border-color: var(--color-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(139, 92, 246, 0.08));
}

.gender-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--surface-alt);
    color: var(--text-dim);
    flex-shrink: 0;
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.gender-card.selected .gender-icon {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
}

.gender-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.gender-label {
    font-size: 17px;
    font-weight: 700;
}

.gender-subtitle {
    font-size: 13.5px;
    color: var(--text-dim);
}

.gender-check {
    margin-left: auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--color-border-strong);
    background: transparent;
    color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.gender-card.selected .gender-check {
    background: var(--gradient-primary);
    border-color: transparent;
    color: #fff;
}

.privacy-note {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-4) 0;
}

.privacy-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.privacy-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.privacy-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.privacy-sub {
    font-size: 13px;
    color: var(--text-dim);
}

.privacy-sub strong {
    color: var(--color-primary);
    font-weight: 600;
}

/* ---------- BUTTONS ---------- */
.next-btn {
    margin-top: auto;
    width: 100%;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 var(--space-4);
    border: none;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.next-btn svg { flex-shrink: 0; }

.next-btn:active { transform: scale(0.97); }

.next-btn:disabled {
    opacity: 0.35;
    box-shadow: none;
    cursor: not-allowed;
}

.next-btn-spaced {
    margin-top: var(--space-4);
}

/* ---------- TEXT FIELD ---------- */
.text-field {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 var(--space-3);
    height: 56px;
    margin-bottom: var(--space-4);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.text-field:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-soft);
}

.field-icon { color: var(--text-dim); flex-shrink: 0; }

.text-field input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 17px;
    height: 100%;
    min-width: 0;
}

.text-field input::placeholder { color: var(--text-faint); }

/* ---------- WHEEL PICKER ---------- */
.picker-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-2) var(--space-2);
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-sm);
}

.wheel-picker {
    position: relative;
    display: flex;
    height: 220px;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 28%, black 72%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 28%, black 72%, transparent 100%);
}

.wheel-highlight {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 44px;
    transform: translateY(-50%);
    background: var(--accent-soft);
    border-top: 1px solid var(--accent-line);
    border-bottom: 1px solid var(--accent-line);
    border-radius: var(--radius-sm);
    pointer-events: none;
    z-index: 1;
}

.wheel-col {
    flex: 1;
    height: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
    touch-action: pan-y;
    position: relative;
}

.wheel-col::-webkit-scrollbar { display: none; }

.wheel-col.dragging {
    cursor: grabbing;
    scroll-snap-type: none;
}

.wheel-col-inner {
    padding: 88px 0;
}

.wheel-item {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: center;
    font-size: 19px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
    user-select: none;
    -webkit-user-select: none;
    will-change: transform, opacity;
}

.wheel-item.near {
    color: var(--text-dim);
}

.wheel-item.active {
    color: var(--text);
    font-weight: 600;
    font-size: 21px;
}

.wheel-picker.disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* ---------- HELPER NOTE CARDS ---------- */
.helper-note {
    display: flex;
    gap: var(--space-2);
    align-items: flex-start;
    padding: var(--space-3);
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: var(--space-2);
}

.helper-note-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.helper-note-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 2px;
}

.helper-note-text {
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text-dim);
    margin: 0;
}

/* ---------- UNKNOWN TIME TOGGLE ---------- */
.unknown-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: var(--space-2);
    cursor: pointer;
}

.unknown-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    width: 46px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    position: relative;
    flex-shrink: 0;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.unknown-toggle input:checked + .toggle-track {
    background: var(--gradient-primary);
    border-color: var(--color-primary);
}

.unknown-toggle input:checked + .toggle-track .toggle-thumb {
    transform: translateX(18px);
    background: #fff;
}

.toggle-label {
    font-size: 14.5px;
    color: var(--text);
    font-weight: 500;
}

/* ---------- STEP FOOTER (pinned) ---------- */
.step-inner-scrollable {
    min-height: 0;
}

.step-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 132px;
}

.step-scroll-flush {
    padding-bottom: 24px;
}

.step-scroll > .next-btn {
    margin-bottom: var(--space-4);
}

.step-scroll > .chat-widget {
    margin-top: 0;
    margin-bottom: var(--space-4);
}

.step-static {
    flex: 1;
    padding-bottom: 92px;
}

.step-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    padding: var(--space-3) var(--space-4) calc(var(--space-3) + var(--safe-bottom));
    background: linear-gradient(to top, var(--bg) 62%, rgba(9, 11, 22, 0));
    z-index: 5;
}

.step-footer-inner {
    width: 100%;
    max-width: 420px;
}

.step-footer .next-btn {
    margin-top: 0;
}

/* ---------- QUESTION SUGGESTIONS (step 5) ---------- */
.suggestion-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: var(--space-3);
}

.suggestion-chip {
    padding: 12px 18px;
    border-radius: var(--radius-full);
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid var(--border);
    color: var(--text);
    font-size: 14.5px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.suggestion-chip:active { transform: scale(0.96); }

.suggestion-chip.selected {
    border-color: var(--color-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.1));
}

.textarea-field {
    width: 100%;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.textarea-field:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-soft);
}
.textarea-field::placeholder { color: var(--text-faint); }

.legal-note {
    font-size: 12.5px;
    color: var(--text-faint);
    text-align: center;
    line-height: 1.5;
    margin: var(--space-3) 0 0;
}

.legal-note a {
    color: var(--text-dim);
    text-decoration: underline;
}

.legal-note a:active,
.legal-note a:hover {
    color: var(--color-primary);
}

/* ---------- REPORT SUMMARY (LOCKED PREVIEW) ---------- */
.report-preview {
    display: flex;
    flex-direction: column;
}

.preview-visible {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.preview-locked-wrap {
    position: relative;
    margin-top: var(--space-2);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.preview-locked {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    filter: blur(3px);
    opacity: 0.92;
    user-select: none;
    pointer-events: none;
}

.preview-fade {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(9, 11, 22, 0) 0%, rgba(9, 11, 22, 0.4) 45%, rgba(9, 11, 22, 0.82) 100%);
    pointer-events: none;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 13px 16px;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.summary-label {
    font-size: 14px;
    color: var(--text-dim);
    flex-shrink: 0;
}

.summary-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    text-align: right;
}

.summary-lock {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-lock-badge {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(16, 19, 31, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--color-border-strong);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
}

.insight-heading {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 4px 0 0;
}

.insight-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.insight-line {
    padding: 13px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
    margin: 0;
}

/* ---------- BUTTON LOADING STATE ---------- */
.next-btn.loading {
    opacity: 0.85;
    cursor: wait;
    position: relative;
    color: transparent;
}

.next-btn.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ---------- CELEBRATION ---------- */
.confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 250;
}

/* ---------- PRICING MODAL ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 6, 12, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: 100%;
    max-width: 440px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-strong);
    border-radius: 24px 24px 0 0;
    padding: var(--space-4) var(--space-4) calc(var(--space-4) + var(--safe-bottom));
    box-shadow: var(--shadow-lg);
    transform: translateY(24px);
    transition: transform var(--dur) var(--ease);
}

.modal-overlay.open .modal-card {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 4px;
}

.modal-sub {
    font-size: 13.5px;
    color: var(--text-dim);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.pricing-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.pricing-option {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.pricing-option.selected {
    border-color: var(--color-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(139, 92, 246, 0.08));
}

.pricing-radio {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--color-border-strong);
    flex-shrink: 0;
    margin-top: 2px;
    position: relative;
    transition: border-color var(--dur) var(--ease);
}

.pricing-option.selected .pricing-radio {
    border-color: var(--color-primary);
}

.pricing-radio::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--gradient-primary);
    transform: scale(0);
    transition: transform var(--dur) var(--ease);
}

.pricing-option.selected .pricing-radio::after {
    transform: scale(1);
}

.pricing-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.pricing-price {
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
}

.pricing-desc {
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--text-dim);
}

.modal-card .next-btn {
    margin-top: 0;
}

.modal-error {
    font-size: 13px;
    color: #FF6B6B;
    text-align: center;
    margin: 0 0 var(--space-3);
}

.modal-upi-note {
    font-size: 12px;
    color: var(--text-faint);
    text-align: center;
    margin: var(--space-2) 0 0;
}

/* ---------- HISTORY MODAL ---------- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-height: 55vh;
    overflow-y: auto;
}

.history-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: var(--space-3);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    text-align: left;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.history-item:active { transform: scale(0.98); }

.history-item:hover {
    border-color: var(--color-primary-line);
}

.history-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.history-question {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-plan-badge {
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-primary);
    background: var(--color-primary-soft);
    padding: 3px 8px;
    border-radius: var(--radius-full);
}

.history-meta {
    font-size: 12.5px;
    color: var(--text-dim);
}

.history-empty {
    font-size: 14px;
    color: var(--text-dim);
    text-align: center;
    padding: var(--space-5) 0;
    margin: 0;
}

/* ---------- FULL REPORT (step 7) ---------- */
.glance-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    margin: 0 0 10px;
}

.glance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.glance-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: var(--space-3);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(139, 92, 246, 0.06));
    border: 1px solid var(--color-primary-line);
    border-radius: var(--radius-md);
}

.glance-title {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-dim);
}

.glance-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.full-report-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.report-body {
    display: flex;
    flex-direction: column;
}

.report-body h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    margin: var(--space-4) 0 var(--space-2);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.report-body h3:first-child {
    margin-top: 0;
}

.report-body p {
    font-size: 14.5px;
    line-height: 1.7;
    color: var(--text-dim);
    margin: 0 0 var(--space-3);
}

.report-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-6) var(--space-3);
    color: var(--text-dim);
    font-size: 14px;
    text-align: center;
}

.report-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--color-border-strong);
    border-top-color: var(--color-primary);
    animation: spin 0.8s linear infinite;
}

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

.ai-disclaimer {
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--text-faint);
    text-align: center;
    margin: var(--space-4) 0 0;
}

/* ---------- UPSELL CALLOUT ---------- */
.upsell-callout {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    margin-top: var(--space-4);
    padding: var(--space-3);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(246, 196, 83, 0.08));
    border: 1px solid var(--color-primary-line);
    border-radius: var(--radius-md);
}

.upsell-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.upsell-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    margin: 0;
}

/* ---------- CHAT WIDGET (extended plan follow-ups) ---------- */
.chat-widget {
    margin-top: var(--space-4);
    padding: var(--space-3);
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.chat-heading {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 var(--space-3);
}

.chat-log {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.chat-log:empty {
    display: none;
}

.chat-bubble {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
}

.chat-bubble p {
    margin: 0 0 6px;
}

.chat-bubble p:last-child {
    margin-bottom: 0;
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--gradient-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble.ai {
    align-self: flex-start;
    background: var(--surface-alt);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-bubble.pending {
    align-self: flex-start;
    background: var(--surface-alt);
    color: var(--text-dim);
    font-style: italic;
}

.chat-input-row {
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    height: 46px;
    padding: 0 14px;
    background: var(--surface-alt);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text);
    font-size: 14.5px;
    outline: none;
    transition: border-color var(--dur) var(--ease);
}

.chat-input:focus { border-color: var(--color-primary); }
.chat-input::placeholder { color: var(--text-faint); }
.chat-input:disabled { opacity: 0.5; }

.chat-send {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}

.chat-send:active { transform: scale(0.94); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-limit-note {
    font-size: 12px;
    color: var(--text-faint);
    text-align: center;
    margin: var(--space-2) 0 0;
}

@media (min-width: 481px) {
    .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
