/* ═══════════════════════════════════════════════════════════════════
   WaifuGen — Dark theme anime character chat UI
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #16161e;
    --bg-card: #1a1a24;
    --bg-hover: #22222e;
    --bg-input: #1e1e2a;
    --bg-modal: #1a1a24;

    --border: #2a2a3a;
    --border-focus: #6c5ce7;

    --text-primary: #e8e6f0;
    --text-secondary: #8888a0;
    --text-muted: #55556a;

    --accent: #6c5ce7;
    --accent-hover: #7c6df7;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --accent-gradient: linear-gradient(135deg, #7C5CFF, #A855F7);

    --pink: #e84393;
    --pink-soft: rgba(232, 67, 147, 0.15);
    --green: #00b894;
    --red: #ff6b6b;
    --orange: #fdcb6e;
    --blue: #74b9ff;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s ease;
}

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
    background-color: #0d0b14;
}
body {
    font-family: var(--font);
    /* Solid bg-primary base so the topmost part (behind the iOS status
     * bar when viewport-fit=cover) matches theme-color exactly — no
     * color seam at the safe-area boundary. The radial "glow" starts
     * BELOW the safe area (at 18%) so the visual accent stays inside
     * the content area, not bleeding into system chrome. */
    background-color: var(--bg-primary);
    background-image: radial-gradient(ellipse at 50% 18%, #1a1528 0%, var(--bg-primary) 55%, #0a0a10 100%);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Particle Background ─────────────────────────────────────────── */
.particle-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.4;
}

img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }


/* ── Top Navigation ──────────────────────────────────────────────── */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 56px;
    background: rgba(15, 15, 20, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}

.brand-name {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #c084fc, #a855f7, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-link-pricing {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
    padding: 6px 12px;
    border-radius: 6px;
}
.nav-link-pricing:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.char-status {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

.nav-status {
    display: none;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
}
.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--red); }
.status-dot.reconnecting {
    background: var(--warning, #f39c12);
    animation: pulse-dot 1s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}


/* ── Container ───────────────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 80px 24px 40px;
    position: relative;
    z-index: 1;
}


/* ── Page Header ─────────────────────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}


/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-danger {
    background: rgba(255, 107, 107, 0.15);
    color: var(--red);
    border: 1px solid rgba(255, 107, 107, 0.3);
}
.btn-danger:hover {
    background: rgba(255, 107, 107, 0.25);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon { font-size: 1.2rem; line-height: 1; }

.btn:active { transform: scale(0.97); }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }


/* ── Character Grid ──────────────────────────────────────────────── */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.char-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.char-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(108, 92, 231, 0.15);
}

.char-card-image {
    width: 100%;
    height: 280px;
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.char-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.char-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--text-muted);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
}

.char-card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-new {
    background: var(--accent);
    color: white;
}
.badge-approved {
    background: var(--green);
    color: white;
}

.char-card-body {
    padding: 16px;
}

.char-card-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.char-card-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: flex;
    gap: 8px;
    align-items: center;
}

.char-card-meta .sep {
    color: var(--text-muted);
}

.char-card-rel {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.char-card-rel-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.char-card-rel-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--pink));
    border-radius: 2px;
    transition: width 0.3s ease;
}

.char-card-rel-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.char-card-actions {
    padding: 0 16px 16px;
    display: flex;
    gap: 8px;
}

.char-card-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 8px;
    font-size: 0.8rem;
}


/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}


/* ── Modal ───────────────────────────────────────────────────────── */
/* body.modal-open handled by JS for iOS compatibility */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overscroll-behavior: contain;
}

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: min(100%, 560px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalEnter 0.25s ease;
}

@keyframes modalEnter {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-wide { max-width: min(100%, 900px); }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 1.2rem; }

.modal-header {
    position: relative;
}

.modal-header-stepper {
    display: none;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    background: var(--bg-hover);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
}

.modal-header-stepper.visible {
    display: inline-block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    padding: 0 4px;
    transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.modal-body-split {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    min-height: 400px;
    flex: 1;
}

/* ── Live Preview Panel ──────────────────────────────────────── */
.live-preview-panel {
    width: 220px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--bg-secondary), var(--bg-primary));
    border-left: 1px solid var(--border);
    padding: 20px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.live-preview-header {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
    align-self: flex-start;
}

.live-preview-avatar {
    width: 140px;
    height: 140px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
    background: var(--bg-card);
    transition: all 0.3s ease;
}

.live-preview-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.live-preview-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    min-height: 1.5em;
}

.live-preview-disclaimer {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
    opacity: 0.7;
    font-style: italic;
}

.live-preview-details {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lp-row {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    animation: fadeIn 0.2s ease;
}

.lp-row-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}

.lp-row-value {
    color: var(--text-primary);
    font-weight: 500;
}

.lp-tag {
    display: inline-block;
    padding: 1px 6px;
    margin: 1px;
    background: var(--accent-glow);
    border-radius: var(--radius-pill);
    font-size: 0.65rem;
    color: var(--accent);
}

/* ── Auto Image ── */
.auto-image-container {
    max-width: 300px;
    margin: 12px 0;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}
.auto-image {
    width: 100%;
    border-radius: 12px;
    cursor: pointer;
    display: block;
}

/* ── Regenerate button (auto-image + narrator overlay + inline) ──
 * Semi-transparent — floats over the image without hiding it. Readable
 * via backdrop-filter blur + subtle border + text-shadow.
 */
.auto-image-regen-btn,
.narrator-regen-btn,
.inline-image-regen-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(30, 20, 50, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 5;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.auto-image-regen-btn:hover,
.narrator-regen-btn:hover,
.inline-image-regen-btn:hover {
    background: rgba(124, 92, 255, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}
.auto-image-regen-btn:active,
.narrator-regen-btn:active,
.inline-image-regen-btn:active {
    transform: translateY(0) scale(0.98);
}
.regen-icon {
    font-size: 1.2rem;
    display: inline-block;
    font-weight: 700;
}
.auto-image-regen-btn:hover .regen-icon,
.narrator-regen-btn:hover .regen-icon,
.inline-image-regen-btn:hover .regen-icon {
    animation: regen-spin 0.6s ease;
}
@keyframes regen-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.regen-label {
    font-size: 0.88rem;
    letter-spacing: 0.2px;
}
.regen-cost {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    font-size: 0.78rem;
    color: #fff;
    font-weight: 800;
    margin-left: 2px;
}
.regen-cost::before {
    content: "\26A1";
    margin-right: 3px;
    font-size: 0.78rem;
    filter: drop-shadow(0 0 2px rgba(251, 191, 36, 0.8));
}

/* Pro+ unlimited tier: replace the numeric cost on every image button
   with a green "FREE" pill. Applied via `html.tier-unlimited` set by
   _applyCreditsUIState when data.is_unlimited is true. No need to
   update 9 separate JS call sites — one CSS flip covers all of them.
   Also hides the ⚡ icon since there's no cost to advertise. */
html.tier-unlimited .regen-cost {
    color: transparent;
    background: rgba(57, 217, 123, 0.18);
    position: relative;
    min-width: 36px;
    justify-content: center;
}
html.tier-unlimited .regen-cost::before {
    content: "";
    display: none;
}
html.tier-unlimited .regen-cost::after {
    content: "FREE";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #39d97b;
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
}

/* Credits badge in header: subtle golden accent when ∞ is shown. */
.credits-unlimited #creditsCount,
.credits-unlimited .credits-count {
    color: #fbbf24;
    font-weight: 800;
}

/* Onboarding: hide regenerate buttons on every image variant. Mirrors
   the credits-hidden-during-onboarding pattern — new users shouldn't
   see "regenerate (15⚡)" friction until they've felt the product's
   value. Flag is toggled on <html> from _applyCreditsUIState(), so one
   class flip covers auto_image, inline, narrator, scene-shot buttons
   without touching each render site. */
html.onboarding .inline-image-regen-btn,
html.onboarding .auto-image-regen-btn,
html.onboarding .narrator-regen-btn {
    display: none !important;
}

/* Narrator variant — compact (icon + cost only, no label) */
.narrator-regen-btn {
    padding: 7px 10px;
    gap: 5px;
}
.narrator-regen-btn .regen-icon {
    font-size: 1.05rem;
}

/* Mobile — icon-only button (cost shown in confirmation dialog) */
@media (max-width: 768px) {
    .auto-image-regen-btn,
    .inline-image-regen-btn,
    .narrator-regen-btn {
        padding: 8px;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        top: 8px;
        right: 8px;
        gap: 0;
        justify-content: center;
    }
    .auto-image-regen-btn .regen-label,
    .inline-image-regen-btn .regen-label,
    .narrator-regen-btn .regen-label,
    .auto-image-regen-btn .regen-cost,
    .inline-image-regen-btn .regen-cost,
    .narrator-regen-btn .regen-cost {
        display: none;
    }
    .auto-image-regen-btn .regen-icon,
    .inline-image-regen-btn .regen-icon,
    .narrator-regen-btn .regen-icon {
        font-size: 1.15rem;
    }
}

/* Inline image needs position context */
.msg-inline-image {
    position: relative;
}

/* ── Feedback button + modal ──
 * Feedback-button needs to be obviously a button, not decoration. We went
 * from zero clicks to something only after making it a saturated solid
 * pill (not translucent) and showing the label on mobile too.
 */
.chat-feedback-btn,
.chat-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(124, 92, 255, 0.12);
    border: 1px solid rgba(124, 92, 255, 0.2);
    border-radius: 50%;
    color: #a78bfa;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    text-decoration: none;
}
.chat-feedback-btn:hover,
.chat-help-btn:hover {
    background: rgba(124, 92, 255, 0.25);
    transform: translateY(-1px);
    color: #c4b5fd;
}
/* Help button — slightly different vibe so it's not confused with feedback */
.chat-help-btn {
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1;
}
.chat-feedback-btn:active { transform: translateY(0); }
@media (max-width: 400px) {
    .chat-feedback-btn,
    .chat-help-btn {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }
    .chat-help-btn { font-size: 0.92rem; }
}

.feedback-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 3, 12, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.feedback-modal-card {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: #1e1b2d;
    border: 1px solid rgba(124, 92, 255, 0.2);
    border-radius: 20px;
    padding: 36px 32px 28px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.feedback-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: #6b7280;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}
.feedback-modal-close:hover { color: #e2e0f0; }
.feedback-modal-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}
.feedback-modal-title {
    font-size: 1.4rem;
    color: #c4b5fd;
    margin: 0 0 6px;
    font-weight: 700;
}
.feedback-modal-subtitle {
    color: #9ca3af;
    font-size: 0.88rem;
    margin: 0 0 14px;
}
.feedback-reward-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.12), rgba(250, 204, 21, 0.08));
    border: 1px solid rgba(167, 139, 250, 0.35);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #d4c5f0;
    text-align: left;
    margin-bottom: 14px;
}
.feedback-reward-hint strong {
    color: #fcd34d;
    font-weight: 700;
}
.feedback-reward-icon {
    font-size: 1rem;
    line-height: 1.3;
    flex-shrink: 0;
}
.feedback-counter {
    text-align: right;
    font-size: 0.72rem;
    color: #6b7280;
    margin-top: 6px;
    padding: 0 4px;
}
.feedback-counter.valid {
    color: #86efac;
}
.feedback-btn-submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.feedback-btn-submit:disabled:hover {
    transform: none;
    filter: none;
}

/* ── Feedback reward notification modal ─────────────────────────── */
.feedback-reward-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 3, 12, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: rewardFadeIn 0.3s ease;
}
@keyframes rewardFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.feedback-reward-modal-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    background: linear-gradient(160deg, #2a1f4a 0%, #1e1b2d 100%);
    border: 1px solid rgba(167, 139, 250, 0.45);
    border-radius: 22px;
    padding: 40px 32px 28px;
    text-align: center;
    box-shadow: 0 24px 64px rgba(124, 92, 255, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.04);
    animation: rewardPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Subtle custom scrollbar so the "scrollable" feeling is obvious
       when the admin reply is long enough to overflow. */
    scrollbar-width: thin;
    scrollbar-color: rgba(167, 139, 250, 0.5) transparent;
}
.feedback-reward-modal-card::-webkit-scrollbar {
    width: 6px;
}
.feedback-reward-modal-card::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.5);
    border-radius: 3px;
}
@keyframes rewardPop {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.feedback-reward-modal-burst {
    font-size: 3rem;
    margin-bottom: 12px;
    animation: rewardSparkle 2s ease-in-out infinite;
}
@keyframes rewardSparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.12) rotate(8deg); }
}
.feedback-reward-modal-title {
    font-size: 1.7rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fcd34d, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 6px;
}
.feedback-reward-modal-subtitle {
    color: #d4c5f0;
    font-size: 0.92rem;
    margin: 0 0 20px;
}
.feedback-reward-modal-amount {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 22px;
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.15), rgba(167, 139, 250, 0.2));
    border: 1px solid rgba(250, 204, 21, 0.45);
    border-radius: 14px;
    color: #fff;
    font-size: 1.1rem;
    margin-bottom: 18px;
    box-shadow: 0 0 24px rgba(250, 204, 21, 0.25) inset;
}
.feedback-reward-modal-amount strong {
    color: #fcd34d;
    font-weight: 800;
    font-size: 1.35rem;
}
.reward-amount-icon {
    font-size: 1.35rem;
    filter: drop-shadow(0 0 4px rgba(250, 204, 21, 0.8));
}
.feedback-reward-modal-preview {
    font-size: 0.78rem;
    color: #9b8cc0;
    font-style: italic;
    margin: 0 0 22px;
    padding: 10px 14px;
    background: rgba(15, 13, 25, 0.4);
    border-left: 2px solid rgba(167, 139, 250, 0.5);
    border-radius: 4px;
    text-align: left;
    max-height: 80px;
    overflow: hidden;
}
.feedback-reward-modal-preview:empty { display: none; }
.feedback-reward-modal-note {
    margin: 14px 0 4px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.12), rgba(167, 139, 250, 0.08));
    border: 1px solid rgba(124, 92, 255, 0.3);
    border-radius: 12px;
    text-align: left;
}
.feedback-reward-modal-note-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #a78bfa;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.feedback-reward-modal-note-label::before {
    content: "\01F4AC";
    font-size: 0.85rem;
}
.feedback-reward-modal-note-body {
    font-size: 0.88rem;
    line-height: 1.5;
    color: #d5cff0;
    white-space: pre-wrap;
    word-wrap: break-word;
    /* Cap very long admin replies so the modal still fits on phones.
       Card itself has max-height: 90vh as outer safety net; this keeps
       the button visible even when the note alone would dominate. */
    max-height: 40vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(167, 139, 250, 0.4) transparent;
}
.feedback-reward-modal-note-body::-webkit-scrollbar {
    width: 5px;
}
.feedback-reward-modal-note-body::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.4);
    border-radius: 3px;
}
.feedback-reward-modal-btn {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #7c5cff, #a78bfa);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 6px 20px rgba(124, 92, 255, 0.45);
}
.feedback-reward-modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(167, 139, 250, 0.6);
}
.feedback-reward-modal-btn:active {
    transform: translateY(0);
}
.feedback-textarea {
    width: 100%;
    background: rgba(15, 13, 25, 0.8);
    border: 1px solid rgba(124, 92, 255, 0.2);
    border-radius: 12px;
    padding: 14px 16px;
    color: #e2e0f0;
    font-size: 0.92rem;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    outline: none;
    transition: border-color 0.2s;
}
.feedback-textarea:focus {
    border-color: rgba(124, 92, 255, 0.5);
}
.feedback-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
.feedback-btn-cancel,
.feedback-btn-submit {
    flex: 1;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.feedback-btn-cancel {
    background: rgba(255, 255, 255, 0.06);
    color: #9ca3af;
}
.feedback-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #d1d5db;
}
.feedback-btn-submit {
    background: linear-gradient(135deg, #7c5cff, #a78bfa);
    color: white;
}
.feedback-btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(124, 92, 255, 0.4);
}
.auto-image-blur-overlay {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    border-radius: 12px;
    overflow: hidden;
}
.auto-image-blur-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(124,92,255,0.3), rgba(167,139,250,0.2));
    backdrop-filter: blur(20px);
}
.auto-image-blur-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 1;
}
.auto-image-lock-icon {
    font-size: 2rem;
    opacity: 0.8;
}
.auto-image-blur-text {
    color: #d1d5db;
    font-size: 0.9rem;
}
.auto-image-unlock-btn {
    background: linear-gradient(135deg, #7c5cff, #a78bfa);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.auto-image-unlock-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(124,92,255,0.4);
}
.auto-image-loading {
    width: 100%;
    aspect-ratio: 2/3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(30, 27, 45, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(124,92,255,0.15);
}
.auto-image-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(167,139,250,0.2);
    border-top-color: #a78bfa;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.auto-image-loading-text {
    color: #9ca3af;
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .live-preview-panel { display: none; }
    .modal-body-split { display: block; }
}


/* ── Forms ───────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238888a0' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-textarea {
    resize: vertical;
    min-height: 70px;
}

.char-counter { text-align: right; font-size: 0.75rem; color: #6b7280; margin-top: 4px; }
.char-counter.near-limit { color: #f59e0b; }
.char-counter.at-limit { color: #ef4444; }

.form-hint {
    margin-top: 8px;
    font-size: 0.78rem;
    color: #6b7280;
    line-height: 1.5;
}

.form-hint-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.hint-example {
    padding: 3px 10px;
    background: rgba(124, 92, 255, 0.08);
    border: 1px solid rgba(124, 92, 255, 0.15);
    border-radius: 6px;
    font-size: 0.73rem;
    color: #a78bfa;
    font-style: italic;
}

.form-hint-warning {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: 8px;
    font-size: 0.75rem;
    color: #d4b484;
    line-height: 1.45;
}

/* Character-name row: input + 🎲 random button side by side */
.name-input-wrap {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.name-input-wrap .form-input {
    flex: 1;
    min-width: 0;
}
.btn-name-random {
    padding: 0 16px;
    min-width: 48px;
    background: rgba(124, 92, 255, 0.12);
    border: 1px solid rgba(124, 92, 255, 0.3);
    border-radius: 10px;
    font-size: 1.3rem;
    cursor: pointer;
    color: #c4b5fd;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.btn-name-random:hover {
    background: rgba(124, 92, 255, 0.22);
    border-color: rgba(124, 92, 255, 0.5);
    transform: translateY(-1px);
}
.btn-name-random:active {
    transform: translateY(0);
}
/* Playful spin on click — class added/removed via JS */
.btn-name-random.btn-name-spin {
    animation: btnNameSpin 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes btnNameSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.form-hint-warning strong {
    color: #f4c870;
}

.form-row {
    display: flex;
    gap: 12px;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0 16px;
}

.wizard-info-box {
    background: rgba(124, 92, 255, 0.06);
    border: 1px solid rgba(124, 92, 255, 0.15);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.82rem;
    color: #9ca3af;
    line-height: 1.5;
}
.wizard-info-box strong { color: #c4b5fd; display: block; margin-bottom: 4px; font-size: 0.85rem; }
.wizard-info-box p { margin: 0; }

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 16px;
}

.section-optional {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 4px;
    padding: 2px 8px;
    margin-left: 8px;
    vertical-align: middle;
}

/* ── Trait Chips ──────────────────────────────────────────────────── */
/* Personality section: chips on left, preview panel on right */
.personality-layout {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 16px;
    align-items: start;
}

.trait-chips {
    margin-bottom: 8px;
}

.trait-category-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 12px 0 6px 2px;
}
.trait-category-label:first-child { margin-top: 0; }

.trait-category-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.trait-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

.trait-chip img { display: none; }

.trait-chip:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--bg-hover);
}

.trait-chip.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.trait-chip.trait-challenge.selected {
    background: #b45309;
    border-color: #d97706;
}

/* Challenge trait hint */
.trait-challenge-hint {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 10px;
    animation: fadeIn 0.3s ease;
}

.trait-hint-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.trait-hint-content {
    flex: 1;
}

.trait-hint-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fbbf24;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.trait-hint-text {
    font-size: 0.82rem;
    color: #d4a574;
    line-height: 1.5;
}

.trait-hint-text strong {
    color: #fbbf24;
}

/* Side preview panel */
.trait-preview-panel {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    position: sticky;
    top: 80px;
    transition: all 0.3s ease;
}

.trait-preview-panel.empty {
    opacity: 0.5;
}

.trait-preview-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    background: var(--bg-secondary);
}

.trait-preview-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.trait-preview-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

@media (max-width: 560px) {
    .personality-layout { grid-template-columns: 1fr; }
    .trait-preview-panel { display: none; }
}

.backstory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.backstory-actions {
    display: flex;
    gap: 6px;
}

.btn-generate-backstory {
    display: inline-block;
    padding: 4px 14px;
    font-size: 0.75rem;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.2s;
    vertical-align: middle;
}
.btn-generate-backstory:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-generate-backstory:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-generate-backstory.generating {
    animation: pulse-btn 1s infinite;
}
@keyframes pulse-btn {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.persona-hint {
    margin-top: 10px;
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--text-muted);
    padding: 10px 14px;
    background: rgba(108, 92, 231, 0.04);
    border-radius: var(--radius);
    border-left: 2px solid rgba(108, 92, 231, 0.2);
}
.persona-hint em {
    color: var(--text-secondary);
    font-style: italic;
}

.hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.text-muted { color: var(--text-secondary); }

.modal-create { max-width: 960px; width: min(100%, 960px); }


/* ── Wizard Stepper ──────────────────────────────────────────────── */
.wizard-stepper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px 20px;
    position: relative;
}

.wizard-stepper::before {
    content: '';
    position: absolute;
    top: 14px;
    left: 40px;
    right: 40px;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 1;
    cursor: pointer;
}

.wizard-step-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all var(--transition);
}

.wizard-step.active .wizard-step-circle {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 0 12px var(--accent-glow);
}

.wizard-step.completed .wizard-step-circle {
    background: var(--green);
    border-color: var(--green);
    color: white;
}

.wizard-step-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    white-space: nowrap;
}

.wizard-step.active .wizard-step-label {
    color: var(--accent);
    font-weight: 600;
}

.wizard-step.completed .wizard-step-label {
    color: var(--green);
}

.wizard-sub-step { display: none; }
.wizard-sub-step.active { display: block; animation: stepSlideIn 0.3s ease forwards; }

/* ── Customize More (collapsible section in Review step) ── */
.customize-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.15), rgba(167, 139, 250, 0.1));
    border: 1px solid rgba(124, 92, 255, 0.4);
    border-radius: 12px;
    color: #d1d5db;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 16px 18px;
    margin-top: 16px;
    transition: all 0.2s;
    text-align: left;
    animation: customizeBounce 2s ease-in-out 1s 3;
    box-shadow: 0 0 15px rgba(124, 92, 255, 0.15);
}
@keyframes customizeBounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
    60% { transform: translateY(-3px); }
}
.customize-toggle:hover {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.25), rgba(167, 139, 250, 0.18));
    border-color: rgba(124, 92, 255, 0.6);
    box-shadow: 0 0 25px rgba(124, 92, 255, 0.25);
    animation: none;
}
.customize-toggle-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
    filter: brightness(1.3);
}
.customize-toggle-text {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.customize-toggle-text strong {
    color: #c4b5fd;
    font-size: 0.95rem;
}
.customize-toggle-hint {
    color: #9ca3af;
    font-size: 0.78rem;
    margin-top: 2px;
}
.customize-toggle-arrow {
    display: inline-block;
    font-size: 0.7rem;
    color: #6b7280;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.customize-section {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
    padding: 0;
}
.customize-section.open {
    max-height: 4000px;
    opacity: 1;
    padding: 16px 0 0;
}

/* ── Preview Image Loader ── */
.preview-image-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 2 / 3;
    background: rgba(30, 27, 45, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(124,92,255,0.15);
}

/* ── Preset Template Cards ── */
/* ── AI Describe ── */
/* ── AI Describe Card — primary fast-path at top of wizard ── */
.ai-describe-card {
    position: relative;
    background:
        radial-gradient(ellipse 120% 80% at 50% 0%, rgba(124,92,255,0.18), transparent 70%),
        linear-gradient(145deg, rgba(26,21,40,0.9) 0%, rgba(20,16,31,0.95) 100%);
    border: 1px solid rgba(124,92,255,0.35);
    border-radius: 18px;
    padding: 22px 22px 20px;
    margin-bottom: 6px;
    box-shadow:
        0 0 0 1px rgba(124,92,255,0.15) inset,
        0 20px 50px -20px rgba(124,92,255,0.35),
        0 0 40px -10px rgba(244,114,182,0.15);
    overflow: hidden;
}
.ai-describe-card::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 60%;
    height: 120%;
    background: radial-gradient(ellipse, rgba(244,114,182,0.12), transparent 60%);
    pointer-events: none;
}

.ai-describe-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}
.ai-describe-sparkle {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #7c5cff, #f472b6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 8px 22px rgba(124,92,255,0.45);
    animation: sparkleFloat 3s ease-in-out infinite;
}
@keyframes sparkleFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-3px) rotate(4deg); }
}
.ai-describe-header-text h3 {
    font-size: 1.12rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}
.ai-describe-header-text p {
    font-size: 0.85rem;
    color: #9ca3af;
    margin: 0;
    line-height: 1.45;
}

.ai-describe-input {
    width: 100%;
    min-height: 88px;
    resize: vertical;
    font-size: 0.92rem;
    padding: 14px 16px;
    background: rgba(10,8,16,0.7);
    border: 1.5px solid rgba(124,92,255,0.25);
    border-radius: 12px;
    color: #e9e7f5;
    font-family: inherit;
    line-height: 1.5;
    transition: all 0.2s;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}
.ai-describe-input::placeholder {
    color: #6b6980;
}
.ai-describe-input:focus {
    outline: none;
    border-color: rgba(167,139,250,0.7);
    background: rgba(10,8,16,0.9);
    box-shadow: 0 0 0 4px rgba(124,92,255,0.15);
}

.ai-describe-hints {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}
.ai-describe-hints-label {
    font-size: 0.78rem;
    color: #6b6980;
    font-weight: 500;
    margin-right: 2px;
}
.ai-hint-chip {
    background: rgba(124,92,255,0.1);
    border: 1px solid rgba(124,92,255,0.25);
    color: #c7bfff;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.18s;
    white-space: nowrap;
    font-family: inherit;
}
.ai-hint-chip:hover {
    background: rgba(124,92,255,0.2);
    border-color: rgba(167,139,250,0.5);
    color: #fff;
    transform: translateY(-1px);
}

.ai-describe-btn {
    background: linear-gradient(135deg, #7c5cff 0%, #a78bfa 50%, #f472b6 100%);
    background-size: 200% 200%;
    color: #fff;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: all 0.25s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: center;
    box-shadow: 0 10px 28px -8px rgba(124,92,255,0.55);
    position: relative;
    z-index: 1;
    animation: gradientShift 4s ease infinite;
}
@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
.ai-describe-btn-wand {
    font-size: 1.1rem;
    display: inline-block;
    animation: wandWiggle 2.5s ease-in-out infinite;
}
@keyframes wandWiggle {
    0%, 100% { transform: rotate(0deg); }
    45% { transform: rotate(-12deg); }
    55% { transform: rotate(12deg); }
}
.ai-describe-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 38px -8px rgba(124,92,255,0.7);
}
.ai-describe-btn:active {
    transform: translateY(0);
}
.ai-describe-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    animation: none;
}

/* ── "or build step by step" divider — between AI card and manual form ── */
.wizard-manual-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 26px 0 22px;
}
.wizard-manual-divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
}
.wizard-manual-divider-text {
    color: #6b6980;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 600;
    white-space: nowrap;
}
.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Randomize Button ── */
.randomize-btn {
    background: linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    white-space: nowrap;
}
.randomize-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(167,139,250,0.3);
}
@keyframes stepSlideIn {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}

.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-modal);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    flex-shrink: 0;
}

.wizard-nav .btn { min-width: 140px; }

/* Back button on wizard nav — slightly more substantial than the
 * default ghost style so it reads as a real button rather than a
 * barely-visible outline next to the bold Generate Preview CTA. */
.wizard-nav .btn-ghost#btnWizBack {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    font-weight: 500;
}
.wizard-nav .btn-ghost#btnWizBack:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.wizard-nav-counter {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Final-step cost hint — rendered as a compact pill between
 * Back and Generate buttons. Only shown for paying users; free/
 * onboarding users see the counter hidden (nothing between the
 * two buttons) for a cleaner look. */
.wizard-nav-counter.wiz-cost-pill {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0;
    padding: 7px 14px;
    border-radius: 999px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.wizard-nav-counter.wiz-cost-pill strong {
    font-weight: 800;
}
.wizard-nav-counter.wiz-cost-pill-paid {
    background: rgba(124, 92, 255, 0.12);
    border: 1px solid rgba(124, 92, 255, 0.35);
    color: #c4b5fd;
}
.wizard-nav-counter.wiz-cost-pill-free {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #a7e3b5;
}

.btn-next-glow {
    background: var(--accent-gradient) !important;
    box-shadow: 0 4px 20px rgba(124, 92, 255, 0.4);
    min-height: 48px;
    min-width: 160px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.btn-next-glow:hover {
    box-shadow: 0 6px 28px rgba(124, 92, 255, 0.5);
    transform: translateY(-1px);
}


/* ── Card Selector (Atmosphere, etc.) ────────────────────────────── */
.card-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.card-option,
.atmo-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    cursor: pointer;
    text-align: center;
    transition: all var(--transition);
    background: var(--bg-input);
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.card-option:hover,
.atmo-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.card-option.selected,
.atmo-card.selected {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.12);
    box-shadow: 0 0 16px var(--accent-glow);
    transform: scale(1.03);
}
.atmo-card {
    position: relative;
}
.atmo-card.selected::after {
    content: "\2713";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 2;
}

.card-option-img,
.atmo-card img {
    width: 100%;
    aspect-ratio: 16/10;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--bg-secondary);
}

.card-option-label,
.atmo-card-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.atmo-card.selected .atmo-card-label {
    color: var(--accent);
}

.card-option-desc,
.atmo-card-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

@media (max-width: 560px) {
    .card-selector { grid-template-columns: repeat(2, 1fr); }
}


/* ── Image Chip Selector (Professions, Hair styles, etc.) ────────── */
.img-chip-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.img-chip-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.img-chip-grid.cols-5 { grid-template-columns: repeat(3, 1fr); }
.img-chip-grid.cols-6 { grid-template-columns: repeat(4, 1fr); }

.img-chip {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    cursor: pointer;
    text-align: center;
    transition: all var(--transition);
    background: var(--bg-input);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.img-chip:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.img-chip.selected {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.12);
    box-shadow: 0 0 12px var(--accent-glow);
    transform: scale(1.03);
}
.img-chip {
    position: relative;
}
.img-chip.selected::after {
    content: "\2713";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 2;
}

.img-chip-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    background: var(--bg-secondary);
    image-rendering: auto;
    -webkit-image-rendering: auto;
}

.img-chip-img.portrait { aspect-ratio: 3/4; }
.img-chip-img.landscape { aspect-ratio: 4/3; }

.img-chip-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.img-chip.selected .img-chip-label {
    color: var(--accent);
    font-weight: 600;
}

@media (max-width: 560px) {
    .img-chip-grid { grid-template-columns: repeat(2, 1fr); }
    .img-chip-grid.cols-5,
    .img-chip-grid.cols-6 { grid-template-columns: repeat(3, 1fr); }
}


/* ── Color Swatch Selector ───────────────────────────────────────── */
.swatch-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.color-swatch {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all var(--transition);
    position: relative;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow), 0 0 16px var(--accent-glow);
    transform: scale(1.1);
}

.color-swatch-label {
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--transition);
}

.color-swatch:hover .color-swatch-label,
.color-swatch.selected .color-swatch-label {
    opacity: 1;
}


/* ── Chip Group with Headers ─────────────────────────────────────── */
/* ── Profession Chips (image + text) ──────────────────────────────── */

.chip-group-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 16px 0 10px 4px;
}
.chip-group-label:first-child { margin-top: 0; }

.chip-group {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.prof-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 6px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
    font-size: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    color: var(--text-secondary);
    text-align: center;
}

.prof-chip img {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.prof-chip:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.prof-chip.selected {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.12);
    color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
    transform: scale(1.03);
}
.prof-chip {
    position: relative;
}
.prof-chip.selected::after {
    content: "\2713";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 2;
}

@media (max-width: 560px) {
    .chip-group { grid-template-columns: repeat(3, 1fr); }
}

.chip-group-section {
    margin-bottom: 16px;
}

.chip-group-header {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-left: 4px;
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip-option {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

.chip-option:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.chip-option.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}


/* ── Age Chip Selector ───────────────────────────────────────────── */
.age-chips {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.age-chip {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--transition);
    min-width: 44px;
    text-align: center;
}

.age-chip:hover { border-color: var(--accent); color: var(--text-primary); }
.age-chip.selected { background: var(--accent); border-color: var(--accent); color: white; }

.age-custom-input {
    width: 80px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-size: 0.85rem;
    text-align: center;
    display: none;
    -moz-appearance: textfield;
}
.age-custom-input::-webkit-inner-spin-button,
.age-custom-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.age-custom-input.visible { display: inline-block; }
.age-custom-input:focus { border-color: var(--accent); outline: none; }


/* ── Tag Input System ────────────────────────────────────────────── */
.tag-input-container {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    background: var(--bg-input);
    min-height: 44px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    transition: border-color var(--transition);
}

.tag-input-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
    animation: tag-pop 0.2s ease;
}

@keyframes tag-pop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.tag-pill-remove {
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.tag-pill-remove:hover { opacity: 1; }

.tag-input-field {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.8rem;
    outline: none;
    flex: 1;
    min-width: 80px;
    padding: 4px;
}

.tag-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag-suggestion {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-input);
}

.tag-suggestion:hover {
    border-color: var(--accent);
    color: var(--accent);
    border-style: solid;
}

.tag-suggestion.used {
    opacity: 0.3;
    pointer-events: none;
}


/* ── RPG Character Sheet (Review) ─────────────────────────────── */
.char-sheet {
    animation: stepSlideIn 0.4s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.char-sheet-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.char-sheet-sections .cs-section.full-width {
    grid-column: 1 / -1;
}

@media (max-width: 560px) {
    .char-sheet-sections { grid-template-columns: 1fr; }
}

.cs-hero {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    flex: 1;
    min-height: 180px;
}

.cs-hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 20%;
    display: block;
    position: absolute;
    inset: 0;
}

.cs-hero-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 60px 20px 20px;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    text-align: center;
}

.cs-hero-stars {
    font-size: 0.9rem;
    color: var(--orange);
    letter-spacing: 4px;
    margin-bottom: 4px;
}

.cs-hero-name {
    font-size: 1.6rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}

.cs-hero-meta {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
    margin-top: 2px;
}

.cs-section {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.cs-section-header {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cs-edit {
    font-size: 0.6rem;
    color: var(--accent);
    cursor: pointer;
    opacity: 0.6;
    text-transform: lowercase;
    letter-spacing: 0;
}
.cs-edit:hover { opacity: 1; }

/* Personality stat bars */
.cs-stat-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.cs-stat-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    width: 90px;
    flex-shrink: 0;
    text-align: left;
    white-space: nowrap;
}

.cs-stat-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
    min-width: 80px;
}

.cs-stat-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    animation: statGrow 0.6s ease forwards;
}

@keyframes statGrow {
    from { width: 0 !important; }
}

/* Appearance grid */
.cs-attr-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
}

.cs-attr {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cs-attr-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cs-attr-val {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Lore */
.cs-lore {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.6;
}

/* Trait tags */
.cs-traits-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cs-trait-tag {
    display: inline-block;
    padding: 3px 10px;
    background: var(--accent-glow);
    border-radius: var(--radius-pill);
    font-size: 0.7rem;
    color: var(--accent);
    border: 1px solid rgba(108, 92, 231, 0.3);
}

.cs-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Keep old review-card for backward compat */
.review-card {
    background: linear-gradient(135deg, var(--bg-input), var(--bg-secondary));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#wizStep7.active {
    display: flex;
    flex-direction: column;
    flex: 1;
}

#wizStep7 .section-title { flex-shrink: 0; }

.review-row {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 0.85rem;
}

.review-row:nth-last-child(-n+2) { border-bottom: none; }

.review-row.full-width {
    grid-column: 1 / -1;
}

.review-label {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.review-value {
    color: var(--text-primary);
    text-transform: capitalize;
    font-size: 0.9rem;
}

.review-value .review-tag {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px;
    background: var(--accent-glow);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    color: var(--accent);
}

@media (max-width: 560px) {
    .review-card { grid-template-columns: 1fr; }
}


/* ── Empty State Hero ────────────────────────────────────────────── */
.empty-hero {
    text-align: center;
    padding: 20px 20px 60px;
    max-width: 900px;
    margin: 0 auto;
    animation: fadeInUp 0.8s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.empty-hero-visual {
    width: 100%;
    max-width: 700px;
    margin: 0 auto 40px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 8px 60px rgba(108, 92, 231, 0.2), var(--shadow-lg);
    animation: float 4s ease-in-out infinite;
    position: relative;
}

.empty-hero-visual::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, var(--bg-primary));
    pointer-events: none;
}

.empty-hero-visual img {
    width: 100%;
    display: block;
}

.empty-hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent), var(--pink), var(--accent));
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 4s linear infinite;
}

.empty-hero p {
    color: var(--text-secondary);
    font-size: 1.15rem;
    margin-bottom: 36px;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.7;
}

.empty-hero .btn-primary {
    font-size: 1.15rem;
    padding: 16px 44px;
    box-shadow: 0 4px 24px var(--accent-glow);
    transition: all 0.3s ease;
}

.empty-hero .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px var(--accent-glow);
}

.hero-benefits {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.hero-benefit {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.hero-cta-group {
    display: flex;
    justify-content: center;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-hero-cta {
    font-size: 1.15rem;
    padding: 16px 44px;
    background: var(--accent-gradient) !important;
    box-shadow: 0 4px 24px var(--accent-glow);
}

.btn-hero-secondary {
    font-size: 0.9rem;
    padding: 12px 24px;
    color: var(--text-secondary) !important;
}

/* ── Review Edit Links + Header ───────────────────────────────── */
.review-edit {
    font-size: 0.6rem;
    color: var(--accent);
    cursor: pointer;
    margin-left: 6px;
    opacity: 0.6;
    transition: opacity var(--transition);
    text-transform: lowercase;
}
.review-edit:hover { opacity: 1; }

.review-header {
    grid-column: 1 / -1;
    text-align: center;
    padding: 8px 0 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 8px;
}

.review-header-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ── Landing Hero ──────────────────────────────────────────────── */

.landing-hero {
    text-align: center;
    padding: 8px 0 20px;
}

.landing-title {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 18px;
    background: linear-gradient(135deg, #e879a8 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.empty-hero .landing-subtitle {
    font-size: 0.88rem;
    line-height: 1.5;
    color: #c4b5d8;
    margin: 0 auto 20px;
    max-width: 500px;
    padding: 0 16px;
}

.landing-hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 16px 42px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #7c5cff 0%, #a855f7 50%, #ec4899 100%);
    background-size: 200% auto;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 24px rgba(124, 92, 255, 0.35), 0 0 50px rgba(168, 85, 247, 0.12);
    animation: ctaGlow 3s ease-in-out infinite;
    font-family: inherit;
}

.landing-hero-cta:hover {
    transform: translateY(-2px) scale(1.02);
    background-position: right center;
    box-shadow: 0 8px 32px rgba(124, 92, 255, 0.5), 0 0 70px rgba(168, 85, 247, 0.22);
}

.landing-hero-cta:active {
    transform: translateY(0) scale(1);
}

.landing-hero-cta-hint {
    margin-top: 12px;
    font-size: 0.78rem;
    color: #8a7fb0;
    letter-spacing: 0.01em;
}

/* Mobile: tighter hero so ALL elements (title + subtitle + button)
   fit in the initial viewport without scrolling. This was the main
   bounce reason — users landed, saw only the title, didn't find the
   CTA, and left. */
@media (max-width: 640px) {
    .empty-hero .landing-subtitle {
        font-size: 0.82rem;
        margin-bottom: 16px;
        padding: 0 20px;
        line-height: 1.5;
    }
    .landing-hero-cta {
        padding: 13px 30px;
        font-size: 0.98rem;
        border-radius: 12px;
    }
    .landing-hero-cta-hint {
        font-size: 0.7rem;
    }
    .landing-templates-title {
        font-size: 0.95rem;
    }
    .empty-hero .landing-templates-sub {
        font-size: 0.82rem;
        padding: 0 20px;
        line-height: 1.5;
    }
    .landing-or-divider {
        margin: 14px auto 12px;
        font-size: 0.68rem;
    }
}

/* ── Value Props ──────────────────────────────────────────────── */

.landing-values {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 900px;
    margin: 0 auto 56px;
}

.landing-value {
    padding: 28px 24px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.landing-value::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    opacity: 0;
    transition: opacity 0.3s;
}

.landing-value:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.landing-value:hover::before {
    opacity: 1;
}

/* Accent colors per card */
.landing-value[data-accent="purple"]::before { background: linear-gradient(90deg, #7c5cff, #a855f7); }
.landing-value[data-accent="blue"]::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.landing-value[data-accent="pink"]::before { background: linear-gradient(90deg, #ec4899, #f472b6); }
.landing-value[data-accent="amber"]::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

.landing-value[data-accent="purple"]:hover { border-color: rgba(124, 92, 255, 0.2); }
.landing-value[data-accent="blue"]:hover { border-color: rgba(59, 130, 246, 0.2); }
.landing-value[data-accent="pink"]:hover { border-color: rgba(236, 72, 153, 0.2); }
.landing-value[data-accent="amber"]:hover { border-color: rgba(245, 158, 11, 0.2); }
.landing-value[data-accent="red"]::before { background: linear-gradient(90deg, #ef4444, #f87171); }
.landing-value[data-accent="red"]:hover { border-color: rgba(239, 68, 68, 0.2); }
.landing-value[data-accent="green"]::before { background: linear-gradient(90deg, #10b981, #34d399); }
.landing-value[data-accent="green"]:hover { border-color: rgba(16, 185, 129, 0.2); }

.landing-value-icon {
    font-size: 1.6rem;
    margin-bottom: 12px;
}

.landing-value-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #e5e7eb;
    margin-bottom: 8px;
}

.landing-value-desc {
    font-size: 0.88rem;
    color: #9ca3af;
    line-height: 1.55;
}

/* ── Worlds Strip ─────────────────────────────────────────────── */

.landing-worlds {
    text-align: center;
    margin-bottom: 56px;
}

.landing-worlds-header {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #6b7280;
    margin-bottom: 20px;
}

.landing-worlds-grid {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.landing-world-chip {
    padding: 8px 20px;
    border-radius: 100px;
    border: 1px solid rgba(124, 92, 255, 0.15);
    background: rgba(124, 92, 255, 0.06);
    color: #c4b5fd;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.landing-world-chip:hover {
    background: rgba(124, 92, 255, 0.15);
    border-color: rgba(124, 92, 255, 0.35);
    transform: translateY(-2px);
}

/* ── Showcase Carousel ─────────────────────────────────────────── */

.landing-showcase {
    margin-bottom: 56px;
}

.showcase-header {
    text-align: center;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #6b7280;
    margin-bottom: 24px;
}

.showcase-track-wrap {
    overflow: hidden;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    position: relative;
    mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
}

.showcase-track {
    display: flex;
    gap: 20px;
    width: max-content;
}

.showcase-track:hover {
    animation-play-state: paused;
}

.showcase-card {
    flex-shrink: 0;
    width: 260px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
    cursor: default;
}

.showcase-card:hover {
    border-color: rgba(124, 92, 255, 0.25);
    box-shadow: 0 8px 30px rgba(124, 92, 255, 0.12);
    transform: translateY(-4px);
}

.showcase-img-wrap {
    aspect-ratio: 1;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.08), rgba(168, 85, 247, 0.05));
}

.showcase-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.showcase-card:hover .showcase-img-wrap img {
    transform: scale(1.05);
}

.showcase-meta {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.showcase-time {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #a78bfa;
    font-weight: 600;
}

.showcase-label {
    font-size: 0.9rem;
    color: #d1d5db;
    font-weight: 500;
}

.showcase-caption {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: #6b7280;
    font-style: italic;
}

@media (max-width: 480px) {
    .showcase-card { width: 200px; }
    .showcase-track { gap: 12px; }
}

/* ── Bottom CTA ───────────────────────────────────────────────── */

.landing-cta {
    text-align: center;
    margin-bottom: 56px;
}

.landing-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 18px 48px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #7c5cff 0%, #a855f7 50%, #ec4899 100%);
    background-size: 200% auto;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 30px rgba(124, 92, 255, 0.3), 0 0 60px rgba(168, 85, 247, 0.1);
    animation: ctaGlow 3s ease-in-out infinite;
}

@keyframes ctaGlow {
    0%, 100% { box-shadow: 0 6px 30px rgba(124, 92, 255, 0.3), 0 0 60px rgba(168, 85, 247, 0.1); }
    50% { box-shadow: 0 6px 40px rgba(124, 92, 255, 0.5), 0 0 80px rgba(168, 85, 247, 0.2); }
}

.landing-cta-btn:hover {
    transform: translateY(-3px) scale(1.03);
    background-position: right center;
    box-shadow: 0 8px 40px rgba(124, 92, 255, 0.5), 0 0 80px rgba(168, 85, 247, 0.25);
}

.landing-cta-btn:active {
    transform: translateY(0) scale(1);
}

.landing-cta-arrow {
    font-size: 1.4rem;
    transition: transform 0.3s;
}

.landing-cta-btn:hover .landing-cta-arrow {
    transform: translateX(4px);
}

.landing-cta-hint {
    margin-top: 12px;
    font-size: 0.8rem;
    color: #6b7280;
}

.landing-bottom-cta {
    text-align: center;
    padding: 40px 0 20px;
}

/* ── Template carousel (landing) ───────────────────────────────── */
/*
 * Mobile-first horizontal snap scroll — a row of tall, portrait-aspect
 * cards that you can swipe through. On desktop we switch to a centered
 * grid so all 5 cards are visible at once.
 *
 * Every card is: hero image, "TEMPLATE" badge (makes it obvious it's
 * a starting point, not a ready character), name, age/profession/atmosphere
 * meta line, and trait pills (angel, catgirl, etc).
 */

.landing-templates {
    margin: 28px 0 24px;
    padding: 0;
    width: 100%;
}
.landing-templates-header {
    text-align: center;
    margin: 0 auto 14px;
    padding: 0 20px;
    max-width: 640px;
}
.landing-templates-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 3px;
    letter-spacing: -0.01em;
}
.empty-hero .landing-templates-sub {
    font-size: 0.88rem;
    line-height: 1.5;
    color: #9b8cc0;
    margin: 0 auto;
    max-width: 500px;
    padding: 0 16px;
}

/* OR divider — horizontal line with "OR" label between hero CTA and
   templates. Gives a visual beat without taking much vertical space. */
.landing-or-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 280px;
    margin: 18px auto 16px;
    padding: 0 20px;
    color: #6b5d8c;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
}
.landing-or-divider::before,
.landing-or-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(155, 140, 192, 0.25), transparent);
}
.landing-or-divider span {
    padding: 0 4px;
}
.landing-templates-scroll {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 4px 16px 16px;
}
.landing-templates-scroll::-webkit-scrollbar { display: none; }

.template-card {
    width: 100%;
    background: rgba(30, 20, 50, 0.55);
    border: 1px solid rgba(255, 120, 200, 0.18);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}
.template-card:hover,
.template-card:active {
    transform: translateY(-3px);
    border-color: rgba(255, 120, 200, 0.6);
    box-shadow: 0 14px 36px rgba(255, 80, 180, 0.28);
}
.template-card-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: #1a0f2e;
}
.template-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.template-card-img-wrap::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,0.75) 100%);
    pointer-events: none;
}
.template-card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.95);
    background: rgba(124, 92, 255, 0.45);
    padding: 3px 7px;
    border-radius: 5px;
    z-index: 2;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.template-card-name {
    position: absolute;
    bottom: 8px;
    left: 10px;
    right: 10px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    text-shadow: 0 2px 6px rgba(0,0,0,0.9);
    z-index: 2;
    line-height: 1.15;
}
.template-card-body {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    flex: 1;
}
.template-card-meta {
    font-size: 0.72rem;
    color: #ffbce8;
    line-height: 1.35;
    text-transform: capitalize;
}
.template-card-traits {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: auto;
}
.template-card-trait {
    font-size: 0.66rem;
    padding: 3px 7px;
    background: rgba(179, 71, 255, 0.15);
    border: 1px solid rgba(179, 71, 255, 0.35);
    color: #e0c8ff;
    border-radius: 999px;
    white-space: nowrap;
    text-transform: capitalize;
}

/* Tablet: bigger cards */
@media (min-width: 600px) {
    .landing-templates-scroll {
        padding: 4px 24px 16px;
        gap: 14px;
    }
    .template-card { flex-basis: 200px; }
    .template-card-name { font-size: 1.15rem; }
}

/* Desktop: show all as centered grid, no horizontal scroll */
@media (min-width: 960px) {
    .landing-templates {
        max-width: 1100px;
        margin: 36px auto 28px;
    }
    .landing-templates-title { font-size: 1.6rem; }
    .landing-templates-sub { font-size: 0.95rem; }
    .landing-templates-scroll {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 16px;
        overflow: visible;
        padding: 4px 24px 8px;
    }
    .template-card {
        flex-basis: auto;
        min-width: 0;
    }
}

/* ── Template characters on landing ───────────────────────────── */

.landing-templates {
    max-width: 1100px;
    margin: 36px auto 0;
    padding: 0 16px;
}

.landing-templates-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #8b7ca8;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 24px;
}
.landing-templates-divider::before,
.landing-templates-divider::after {
    content: "";
    flex: 1;
    max-width: 140px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(180, 140, 220, 0.35), transparent);
}

.landing-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.template-card {
    position: relative;
    background: rgba(30, 20, 50, 0.55);
    border: 1px solid rgba(255, 120, 200, 0.15);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.template-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 120, 200, 0.55);
    box-shadow: 0 16px 40px rgba(255, 80, 180, 0.25);
}
.template-card-img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    display: block;
    background: #1a0f2e;
}
.template-card-body {
    padding: 14px 16px 16px;
}
.template-card-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 4px;
}
.template-card-sub {
    font-size: 0.8rem;
    color: #ffbce8;
    margin: 0 0 10px;
}
.template-card-teaser {
    font-size: 0.82rem;
    line-height: 1.45;
    color: #b8abcf;
    margin: 0 0 12px;
    min-height: 2.9em;
}
.template-card-cta {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #ff4fa8 0%, #b347ff 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    pointer-events: none; /* card handles click */
}
.template-card:hover .template-card-cta {
    filter: brightness(1.1);
}

@media (max-width: 640px) {
    .landing-templates-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .template-card-name { font-size: 1rem; }
    .template-card-teaser { font-size: 0.78rem; min-height: 2.6em; }
}

/* ── Tips Section ──────────────────────────────────────────────── */

.tips-section {
    margin: 48px 0;
}

.tips-title {
    text-align: center;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #6b7280;
    margin-bottom: 24px;
}

.tips-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 1000px;
    margin: 0 auto;
}

.tip-card {
    padding: 20px 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    transition: all 0.3s ease;
}

.tip-card:hover {
    border-color: rgba(124, 92, 255, 0.2);
    background: rgba(124, 92, 255, 0.04);
    transform: translateY(-2px);
}

.tip-icon {
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.tip-header {
    font-size: 0.9rem;
    font-weight: 700;
    color: #e5e7eb;
    margin-bottom: 8px;
}

.tip-text {
    font-size: 0.8rem;
    color: #9ca3af;
    line-height: 1.55;
}

.tip-text em {
    color: #a78bfa;
    font-style: italic;
}

@media (max-width: 768px) {
    .tips-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .tips-grid { grid-template-columns: 1fr; }
}

/* ── Disclaimer ───────────────────────────────────────────────── */

.landing-disclaimer {
    text-align: center;
    padding: 32px 0 16px;
    font-size: 0.7rem;
    color: #4b5563;
    line-height: 1.6;
}

/* ── Landing Responsive ───────────────────────────────────────── */

@media (max-width: 768px) {
    .landing-title { font-size: 2.2rem; }
    .landing-value { padding: 24px 20px; }
}

@media (max-width: 480px) {
    .landing-title { font-size: 1.8rem; }
    .landing-worlds-grid { gap: 8px; }
    .landing-world-chip { font-size: 0.75rem; padding: 6px 14px; }
}

/* ── Feature Cards ──────────────────────────────────────────────── */
.feature-section {
    margin-top: 48px;
    margin-bottom: 8px;
}

.feature-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 24px;
}

.feature-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 800px;
    margin: 0 auto;
}

.feature-card {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-align: center;
    transition: all 0.3s ease;
}

.feature-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 16px var(--accent-glow);
}

.feature-img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.feature-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    padding: 12px 12px 0;
}

.feature-desc {
    font-size: 0.73rem;
    color: var(--text-secondary);
    line-height: 1.5;
    padding: 0 12px 14px;
}

@media (max-width: 768px) {
    .feature-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .feature-cards { grid-template-columns: 1fr; max-width: 300px; }
}

.empty-examples {
    margin-top: 48px;
}

.empty-examples h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.example-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.example-card {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.example-card:hover {
    border-color: var(--accent);
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 20px var(--accent-glow);
}

.example-card-img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 16px;
    border: 3px solid var(--border);
    transition: border-color 0.3s ease;
}

.example-card:hover .example-card-img {
    border-color: var(--accent);
}

.example-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.example-card-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

@media (max-width: 560px) {
    .example-cards { grid-template-columns: 1fr; max-width: 280px; }
    .empty-hero h1 { font-size: 1.5rem; }
    .wizard-stepper { padding: 0 4px 16px; }
    .wizard-step-label { display: none; }
    .wizard-step-circle { width: 28px; height: 28px; font-size: 0.65rem; }
}


/* ── Generation Progress ─────────────────────────────────────────── */
.generate-progress {
    text-align: center;
    padding: 40px 20px;
}

.progress-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

.generate-progress h3 {
    font-size: 1.1rem;
    margin-bottom: 6px;
}

.progress-sub {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.progress-bar-wrap {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--pink));
    border-radius: 3px;
    width: 0%;
    transition: width 0.5s ease;
}

.progress-step {
    font-size: 0.92rem;
    color: #9ca3af;
    max-width: 500px;
    margin: 8px auto 0;
    text-align: center;
    line-height: 1.5;
}


/* ── Preview Section ─────────────────────────────────────────────── */
.preview-section {
    text-align: center;
}

.preview-image-wrap {
    width: 280px;
    max-height: 400px;
    margin: 0 auto 16px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
}

.preview-image-wrap img {
    width: 100%;
    object-fit: cover;
}

.preview-info h3 {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.preview-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 12px 0 20px;
}


/* ── Done Section ────────────────────────────────────────────────── */
.done-section {
    text-align: center;
    padding: 10px 0;
}

.done-images {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.done-image-card {
    width: 180px;
    text-align: center;
}

.done-image-card img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 6px;
}

.done-image-card span {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.done-section h3 {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.done-section .form-actions {
    margin-top: 20px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}


/* ═══════════════════════════════════════════════════════════════════
   CHAT PAGE
   ═══════════════════════════════════════════════════════════════════ */

body.chat-page {
    overflow: hidden;
}

.chat-layout {
    display: flex;
    height: calc(100vh - 56px);
    margin-top: 56px;
    overflow: hidden;
}


/* ── Sidebar ─────────────────────────────────────────────────────── */
.chat-sidebar {
    width: 280px;
    min-width: 280px;
    background: radial-gradient(ellipse at 50% 0%, #1e1830 0%, var(--bg-secondary) 70%);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
    overflow-y: auto;
    transition: transform var(--transition);
}

.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 12px;
    z-index: 50;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 8px 10px;
    font-size: 1.1rem;
    cursor: pointer;
}

.char-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(124, 92, 255, 0.3);
    box-shadow: 0 0 20px rgba(124, 92, 255, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.char-avatar-large:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(124, 92, 255, 0.25);
}

.char-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--text-muted);
    background: var(--bg-card);
}

.char-name-sidebar {
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
}

.char-profession-sidebar {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 20px;
}


/* ── Relationship Bar ────────────────────────────────────────────── */
.relationship-section {
    width: 100%;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    border: 1px solid var(--border);
}

.rel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rel-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--pink);
}

.rel-level {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.rel-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.rel-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--pink));
    border-radius: 3px;
    transition: width 0.5s ease;
    box-shadow: 0 0 8px rgba(108, 92, 231, 0.4);
}

.rel-points {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 4px;
}

.rel-perks {
    margin-top: 8px;
    font-size: 0.72rem;
    line-height: 1.6;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.rel-perks.visible {
    max-height: 500px;
    opacity: 1;
}

.rel-perk {
    padding: 2px 0;
}

.perk-unlocked {
    color: var(--text-muted);
    opacity: 0.6;
}

.perk-current {
    color: var(--accent, #e8a0bf);
    font-weight: 600;
}

.perk-locked {
    color: var(--text-muted);
    opacity: 0.35;
    font-size: 0.68rem;
}

.rel-gain-hints {
    margin-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 6px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.rel-gain-hints.visible {
    max-height: 500px;
    opacity: 1;
}

.rel-gain-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.rel-gain-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    padding: 1px 0;
}

.rel-gain-row .gain-text {
    flex: 1;
    color: var(--text-secondary);
}

.rel-gain-row .gain-pts {
    font-weight: 600;
    font-size: 0.65rem;
}

.gain-pos { color: #4ade80; }
.gain-neg { color: #f87171; }

.rel-info-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.rel-info-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 10px rgba(124, 92, 255, 0.3);
}

/* ── Mood display ────────────────────────────────────────────────── */
.rel-mood {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 4px 8px;
    background: var(--bg-input);
    border-radius: 8px;
    font-size: 0.75rem;
}

.mood-icon {
    font-size: 1rem;
}

.mood-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.mood-intensity {
    margin-left: auto;
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* ── Multi-stat bars ─────────────────────────────────────────────── */
.rel-stats {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rel-stat-row {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
}

.rel-stat-row .stat-icon {
    font-size: 0.75rem;
    width: 16px;
    text-align: center;
}

.rel-stat-row .stat-label {
    width: 48px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.68rem;
}

.rel-stat-row .stat-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.rel-stat-row .stat-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.rel-stat-row .stat-value {
    width: 22px;
    text-align: right;
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.rel-stat-row .stat-needed {
    font-size: 0.58rem;
    color: var(--text-muted);
    opacity: 0.6;
    margin-left: 2px;
}

.rel-stat-row.stat-met .stat-value {
    color: #4ade80;
}


/* ── Sidebar Details ─────────────────────────────────────────────── */
.sidebar-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 12px;
    width: 100%;
    margin-bottom: 16px;
}

.detail-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(42, 42, 58, 0.5);
}

.detail-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.3;
}

/* ── Location Map ──────────────────────────────────────────────── */
.location-map-section {
    width: 100%;
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.location-map-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}

.location-map-header:hover {
    opacity: 0.8;
}

.location-map-icon {
    font-size: 1rem;
}

.location-map-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.location-map-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 8px;
}

.location-map-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.location-map-arrow.collapsed {
    transform: rotate(-90deg);
}

.location-map-body {
    margin-top: 6px;
    max-height: 280px;
    overflow-y: auto;
}

.location-map-body.collapsed {
    display: none;
}

.location-current {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    margin-bottom: 6px;
}

.location-current-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.location-current-name {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.location-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.location-card:hover {
    background: var(--bg-tertiary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border-color: rgba(124, 92, 255, 0.3);
}

.location-card:active {
    transform: scale(0.98);
}

.location-card.current {
    background: var(--accent-soft, rgba(99, 102, 241, 0.1));
    border-left: 3px solid var(--accent);
    padding-left: 5px;
}

.location-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.location-card.locked:hover {
    background: transparent;
}

.location-card .loc-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.location-card .loc-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.location-card .loc-name {
    font-size: 0.78rem;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-card .loc-meta {
    font-size: 0.65rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-card .loc-badge {
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 4px;
    flex-shrink: 0;
}

.location-card .loc-badge.badge-new {
    background: var(--accent);
    color: white;
}

.location-card .loc-badge.badge-locked {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.location-card .loc-thumb {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Moving animation */
@keyframes locationPulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.location-card.moving {
    animation: locationPulse 0.6s ease-in-out;
}

/* ── Character Memories ─────────────────────────────────────────── */
.memory-section {
    width: 100%;
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.memory-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}

.memory-header:hover { opacity: 0.8; }

.memory-icon { font-size: 1rem; }

.memory-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.memory-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 8px;
}

.memory-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.memory-arrow.collapsed { transform: rotate(-90deg); }

.memory-body {
    margin-top: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.memory-body.collapsed { display: none; }

.memory-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.memory-item {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 5px 8px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    border-left: 2px solid var(--accent);
    line-height: 1.3;
    transition: background 0.2s ease;
}

.memory-item:hover {
    background: var(--bg-card);
}

.memory-item .memory-time {
    font-size: 0.6rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

.memory-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 12px;
    font-style: italic;
}

.sidebar-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
}

.sidebar-actions .btn {
    width: 100%;
    justify-content: center;
}


/* ── Chat Main Area ──────────────────────────────────────────────── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* ── Prologue (opening scene) ─────────────────────────────────────── */
.prologue {
    max-width: 100%;
    margin: 12px auto 24px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    animation: prologueIn 0.6s ease;
    flex-shrink: 0;
}

@keyframes prologueIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.prologue-image {
    width: 100%;
    display: block;
    /* No max-height — show full image at natural aspect ratio */
}

.prologue-body {
    padding: 20px 24px;
}

.prologue-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.65;
    font-style: italic;
}

.prologue-text strong {
    color: var(--text-primary);
    font-style: normal;
    font-weight: 600;
}

.prologue-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px auto 8px;
    max-width: 300px;
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.prologue-divider::before,
.prologue-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.prologue-hero {
    position: relative;
    min-height: 300px;
}
.prologue-hero .prologue-image {
    width: 100%;
    max-height: 500px;
    object-fit: cover;
    display: block;
}
.prologue-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent 20%, rgba(15,15,20,0.9) 80%);
    padding: 60px 32px 24px;
}
.prologue-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    text-shadow: 0 2px 12px rgba(0,0,0,0.8);
}
.prologue-overlay .prologue-text {
    color: rgba(255,255,255,0.85);
    font-size: 1rem;
    font-style: italic;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    line-height: 1.5;
}


/* ── Narrator Beats (visual-novel scene cards) ────────────────────── */
.narrator-beat {
    max-width: 100%;
    margin: 20px auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    animation: narratorIn 0.8s ease;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

@keyframes narratorIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    60% { opacity: 1; transform: translateY(-2px) scale(1.002); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.narrator-image-wrapper {
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.narrator-image {
    width: 100%;
    display: block;
    transition: transform 0.3s ease;
    /* No max-height — show full image at natural aspect ratio */
}

.narrator-image-wrapper:hover .narrator-image {
    transform: scale(1.02);
}

.narrator-image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--bg-card));
    pointer-events: none;
}

.narrator-body {
    padding: 16px 20px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.narrator-label {
    color: var(--accent);
    font-size: 0.8rem;
    flex-shrink: 0;
    margin-top: 2px;
    opacity: 0.7;
}

.narrator-text {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.65;
    font-style: italic;
    text-align: center;
    width: 100%;
}

/* Trigger-specific accent colors */
.narrator-location_change {
    border-color: rgba(116, 185, 255, 0.3);
}
.narrator-location_change .narrator-label {
    color: var(--blue);
}

.narrator-mood_shift {
    border-color: rgba(232, 67, 147, 0.3);
}
.narrator-mood_shift .narrator-label {
    color: var(--pink);
}

.narrator-relationship_milestone {
    border-color: rgba(253, 203, 110, 0.3);
}
.narrator-relationship_milestone .narrator-label {
    color: var(--orange);
}

.narrator-time_change {
    border-color: rgba(0, 184, 148, 0.25);
}
.narrator-time_change .narrator-label {
    color: var(--green);
}

/* No image variant — more compact */
.narrator-beat:not(:has(.narrator-image-wrapper)) {
    max-width: 420px;
}

.narrator-beat:not(:has(.narrator-image-wrapper)) .narrator-body {
    padding: 14px 18px;
}

.narrator-beat.narrator-has-image {
    padding: 0;
    overflow: hidden;
}
.narrator-beat.narrator-has-image .narrator-image-wrapper {
    position: relative;
    max-height: 400px;
    overflow: hidden;
}
.narrator-beat.narrator-has-image .narrator-body-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    padding: 40px 24px 20px;
}
.narrator-beat.narrator-has-image .narrator-body-overlay .narrator-text {
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    font-style: italic;
}
.narrator-beat.narrator-has-image .narrator-body-overlay .narrator-label {
    color: var(--accent);
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

@keyframes narratorGlow {
    0% { box-shadow: 0 0 20px rgba(124,92,255,0.3); }
    100% { box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
}
.narrator-beat.narrator-new {
    animation: narratorIn 0.8s ease, narratorGlow 2s ease-out;
}

/* ── Communication Mode Badge ───────────────────────────────────── */
.comm-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.comm-face {
    background: rgba(0, 184, 148, 0.15);
    color: var(--green);
}

.comm-remote {
    background: rgba(116, 185, 255, 0.15);
    color: var(--blue);
}

/* ── Narrator comm_mode_change variant ──────────────────────────── */
.narrator-comm_mode_change {
    border-color: rgba(162, 155, 254, 0.3);
}
.narrator-comm_mode_change .narrator-label {
    color: var(--accent);
}


.chat-welcome {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.welcome-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}


/* ── Lightbox ────────────────────────────────────────────────────── */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.lightbox-content img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
}
.lightbox-report {
    position: absolute;
    bottom: -36px;
    left: 50%;
    transform: translateX(-50%);
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    color: rgba(255,255,255,0.4);
    font-size: 0.68rem;
    padding: 4px 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
}
.lightbox-report:hover { color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.3); }
.lightbox-report.reported { color: #f87171; border-color: #f87171; pointer-events: none; }


/* ── Gallery Grid ────────────────────────────────────────────────── */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.gallery-item {
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 2/3;
    transition: all 0.25s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    opacity: 0;
    animation: galleryItemIn 0.4s ease forwards;
}
.gallery-item:nth-child(1) { animation-delay: 0.05s; }
.gallery-item:nth-child(2) { animation-delay: 0.10s; }
.gallery-item:nth-child(3) { animation-delay: 0.15s; }
.gallery-item:nth-child(4) { animation-delay: 0.20s; }
.gallery-item:nth-child(5) { animation-delay: 0.25s; }
.gallery-item:nth-child(6) { animation-delay: 0.30s; }
.gallery-item:nth-child(n+7) { animation-delay: 0.35s; }

@keyframes galleryItemIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.gallery-item:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 28px rgba(0,0,0,0.5), 0 0 12px rgba(124, 92, 255, 0.2);
}

.gallery-grid img:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    border-color: rgba(124, 92, 255, 0.3);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}


/* ── Loading Skeleton ────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--bg-hover) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* ── Toast Notifications ─────────────────────────────────────────── */
/* z-index above modals (feedback modal is 10000, login modal is ~9000).
 * Toasts are global notifications and must always be visible — otherwise
 * the user hits a rate limit inside a modal and sees nothing happen. */
.toast-container {
    position: fixed;
    top: 68px;
    right: 20px;
    z-index: 20000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast-container > * { pointer-events: auto; }

.toast {
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease;
    max-width: 340px;
}

.toast-error { border-left: 3px solid var(--red); }
.toast-success { border-left: 3px solid var(--green); }
.toast-info { border-left: 3px solid var(--blue); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}


/* ── Responsive: Tablet & below (≤768px) ─────────────────────────── */
@media (max-width: 768px) {
    /* Use dynamic viewport height for mobile address bars */
    .chat-layout { height: 100dvh; height: calc(100vh - 56px); height: calc(100dvh - 56px); }

    /* Sidebar: slide-out overlay */
    .chat-sidebar {
        position: fixed;
        left: 0;
        top: 56px;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        width: min(280px, 80vw);
        min-width: unset;
    }
    .chat-sidebar.open { transform: translateX(0); }

    .sidebar-toggle { display: block; }

    /* Sidebar backdrop — separate element controlled by JS */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 49;
        -webkit-tap-highlight-color: transparent;
    }
    .sidebar-backdrop.visible { display: block; }

    /* Messages */
    .msg { max-width: 88%; }

    /* Chat area padding */
    .chat-messages { padding: 16px 12px 8px; }

    /* Chat input: tighter on mobile */
    .chat-input-bar { padding: 8px 12px 12px; }
    .chat-input-bar .input-hints { display: none; }

    /* Narrator & prologue: full-width on mobile */
    .narrator-beat { max-width: 100%; margin: 12px 0; }
    .prologue { max-width: 100%; margin: 8px 0 16px; }
    .prologue-body { padding: 14px 16px; }

    /* Preview image in creation modal */
    .preview-image-wrap { width: min(280px, 100%); }

    /* Character grid */
    .char-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    /* Gallery grid: 2 columns on tablet */
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    /* Forms */
    .form-row { flex-direction: column; gap: 0; }

    /* Modal: full-width on mobile with safe padding */
    .modal-overlay { padding: 10px; }
    .modal {
        width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: var(--radius);
    }
    .modal-header { padding: 14px 16px; }
    .modal-body { padding: 16px; }

    /* Toast: top-center on mobile instead of top-right */
    .toast-container {
        right: 10px;
        left: 10px;
        align-items: center;
    }
    .toast { max-width: 100%; }

    /* Lightbox: full screen on mobile */
    .lightbox-content { max-width: 96vw; max-height: 96vh; }
    .lightbox-content img { max-width: 96vw; max-height: 96vh; border-radius: 0; }
    .lightbox-close { top: -32px; right: 4px; font-size: 1.5rem; }

    /* Touch-friendly: larger tap targets */
    .sidebar-toggle { padding: 10px 13px; font-size: 1.2rem; }
    .chat-send-btn { min-width: 40px; min-height: 40px; }

    /* Image in messages: full bubble width */
    .msg-image { max-width: 100%; }
}

/* ── Small mobile (≤480px) ───────────────────────────────────────── */
@media (max-width: 480px) {
    .modal-header h2 { font-size: 1rem; }
    .modal-body { padding: 12px; }
    .form-group { margin-bottom: 12px; }

    .msg { max-width: 95%; }

    .char-grid { grid-template-columns: 1fr; }

    /* Gallery: still 2 columns but tighter */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    /* Sidebar avatar smaller */
    .char-avatar-large { width: 90px; height: 90px; }

    /* Prologue & narrator text */
    .prologue-body { padding: 12px; }
    .narrator-body { padding: 12px 14px; }

    /* Font size slightly smaller */
    html { font-size: 14px; }

    /* Nav compact */
    .nav-brand { font-size: 0.95rem; }
}

/* ── Safe areas for notched devices (iPhone X+, etc.) ─────────── */
@supports (padding: env(safe-area-inset-bottom)) {
    .chat-input-bar {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    .sidebar-toggle {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }
    .modal-overlay {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   MESSENGER CHAT MODE
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Chat Container ── */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-primary);
    position: relative;
    max-width: 100%;
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
    /* No bottom safe-area padding here — the chat-input-bar handles
       that itself so its own background extends into the safe area
       (otherwise a color seam appeared between bg-secondary input
       bar and bg-primary chat-container safe-area padding). */
}

/* ── Chat Header ── */
.chat-header {
    display: flex;
    flex-direction: column;
    background: rgba(15, 15, 20, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 20;
    flex-shrink: 0;
}

.chat-header-top {
    display: flex;
    align-items: center;
    /* Vertical padding bumped twice — originally 12px, now 16px — to
     * give the avatar's presence glow ring enough breathing room so
     * it doesn't visually touch the separator line or wrap into the
     * relationship progress row below it. */
    padding: 16px 20px;
    gap: 12px;
    position: relative;
}

.chat-back {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.4rem;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}
.chat-back:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.08);
}

.chat-header-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(124, 92, 255, 0.3);
    flex-shrink: 0;
}

.chat-header-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.chat-char-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-char-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
}

.comm-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.comm-dot.comm-face {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.comm-dot.comm-remote {
    background: #6b7280;
}

.chat-header-rel-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.chat-rel-top-row {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.chat-rel-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: #c4b5fd;
    letter-spacing: 0.5px;
    text-shadow: 0 0 12px rgba(167, 139, 250, 0.3);
}

.chat-rel-progress {
    font-size: 0.7rem;
    color: #6b7280;
    white-space: nowrap;
    font-weight: 500;
    background: rgba(124, 92, 255, 0.08);
    padding: 1px 8px;
    border-radius: 10px;
}

.chat-rel-bar-wrap {
    width: 300px;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.chat-rel-bar {
    height: 100%;
    background: linear-gradient(90deg, #7c5cff, #a855f7, #c084fc);
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px rgba(124, 92, 255, 0.4);
    position: relative;
}

.chat-rel-bar::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 100%);
    border-radius: 3px 3px 0 0;
}

/* Tabs */
.chat-header-tabs {
    display: flex;
    padding: 0 20px;
    gap: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-tab {
    flex: 1;
    padding: 8px 0;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    color: #6b7280;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-tab:hover {
    color: #9ca3af;
}

.chat-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Tab panels */
.chat-tab-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
}

.tab-panel-content {
    max-width: 700px;
    margin: 0 auto;
}

.tab-panel-loading {
    text-align: center;
    padding: 40px 0;
    color: #6b7280;
    font-style: italic;
}

/* Memories tab */
.memory-section {
    margin-bottom: 28px;
}

.memory-section-title {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #c4b5fd;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(124, 92, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}
.memory-section-icon {
    font-size: 1.1rem;
}

/* ── Bond Card ── */
.memory-bond-card {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.15), rgba(244, 114, 182, 0.1));
    border: 1px solid rgba(124, 92, 255, 0.3);
    border-radius: 16px;
    padding: 18px 20px;
    margin-bottom: 24px;
}
.memory-bond-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}
.memory-bond-icon {
    font-size: 2rem;
    flex-shrink: 0;
}
.memory-bond-text {
    flex: 1;
}
.memory-bond-level {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f0e7ff;
    margin-bottom: 2px;
}
.memory-bond-sub {
    font-size: 0.82rem;
    color: #a78bfa;
}
.memory-bond-meeting {
    font-size: 0.85rem;
    color: #d1d5db;
    line-height: 1.5;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.memory-bond-label {
    color: #a78bfa;
    font-weight: 600;
    margin-right: 6px;
}

/* ── Story section (conversation summary) ── */
.memory-story-section .memory-story-text {
    font-size: 0.9rem;
    color: #e2e0f0;
    line-height: 1.7;
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid #a78bfa;
    border-radius: 8px;
    font-style: italic;
}

/* ── Profile grid ── */
.memory-profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.memory-profile-field {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 12px 14px;
}
.memory-profile-name {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.12), rgba(167, 139, 250, 0.08));
    border-color: rgba(124, 92, 255, 0.3);
}
.memory-profile-name .memory-profile-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #f0e7ff;
}
.memory-profile-full {
    grid-column: 1 / -1;
}
.memory-profile-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #a78bfa;
    font-weight: 600;
    margin-bottom: 6px;
}
.memory-profile-value {
    font-size: 0.95rem;
    color: #e2e0f0;
    font-weight: 500;
}
.memory-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.memory-chip {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(124, 92, 255, 0.12);
    border: 1px solid rgba(124, 92, 255, 0.25);
    border-radius: 14px;
    font-size: 0.78rem;
    color: #d1d5db;
}

/* ── Key Moments ── */
.memory-moments-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.memory-moment {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    font-size: 0.85rem;
    color: #d1d5db;
    line-height: 1.5;
}
.memory-moment-dot {
    color: #a78bfa;
    font-size: 0.5rem;
    margin-top: 7px;
    flex-shrink: 0;
}
.memory-moment-text {
    flex: 1;
}

.memories-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.memory-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    transition: border-color 0.2s;
}

.memory-item:hover {
    border-color: rgba(124, 92, 255, 0.15);
}

.memory-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.memory-content {
    flex: 1;
    min-width: 0;
}

.memory-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #a78bfa;
    font-weight: 600;
    margin-bottom: 3px;
}

.memory-value {
    font-size: 0.88rem;
    color: #d1d5db;
    line-height: 1.5;
}

/* Empty state for memories */
.memories-empty-state {
    text-align: center;
    padding: 60px 20px;
}

.memories-empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.memories-empty-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #e5e7eb;
    margin-bottom: 12px;
}

.memories-empty-desc {
    font-size: 0.9rem;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 24px;
}

.memories-empty-tips {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.memories-tip {
    padding: 8px 16px;
    background: rgba(124, 92, 255, 0.06);
    border: 1px solid rgba(124, 92, 255, 0.12);
    border-radius: 10px;
    font-size: 0.82rem;
    color: #9ca3af;
}

/* Gallery tab */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.gallery-thumb {
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.gallery-thumb:hover {
    transform: scale(1.03);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-empty {
    text-align: center;
    padding: 40px 0;
    color: #6b7280;
}


/* ── Chat Messages Area ── */
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 24px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
    position: relative;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(124, 92, 255, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 30%, rgba(168, 85, 247, 0.02) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(88, 28, 135, 0.03) 0%, transparent 50%);
}

/* ── Start Hint ── */
.chat-start-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    transition: opacity 0.3s ease;
    pointer-events: auto;
    z-index: 1;
}

.chat-hint-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.chat-hint-title {
    font-size: 1rem;
    color: #6b7280;
    margin-bottom: 8px;
    font-weight: 500;
}
.chat-hint-subtitle {
    font-size: 0.82rem;
    color: #9ca3af;
    margin-bottom: 20px;
    padding: 8px 14px;
    background: rgba(124, 92, 255, 0.08);
    border: 1px solid rgba(124, 92, 255, 0.2);
    border-radius: 20px;
    display: inline-block;
}

.chat-hint-suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.chat-hint-label {
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-weight: 700;
    color: #a78bfa;
    margin-bottom: 8px;
    opacity: 0.75;
}
.chat-hint-chip {
    padding: 9px 18px;
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.15), rgba(167, 139, 250, 0.08));
    border: 1px solid rgba(124, 92, 255, 0.35);
    border-radius: 20px;
    color: #c4b5fd;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: 500;
    /* Gentle pulse to catch the eye so users don't miss the hint.
     * Staggered delays below so chips bob in sequence. */
    animation: chipBob 2.4s ease-in-out infinite;
}
.chat-hint-suggestions .chat-hint-chip:nth-child(2) { animation-delay: 0.3s; }
.chat-hint-suggestions .chat-hint-chip:nth-child(3) { animation-delay: 0.6s; }
@keyframes chipBob {
    0%, 70%, 100% { transform: translateY(0); box-shadow: 0 0 0 rgba(124,92,255,0); }
    35%           { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(124,92,255,0.25); }
}

.chat-hint-chip:hover {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.28), rgba(167, 139, 250, 0.15));
    border-color: rgba(124, 92, 255, 0.55);
    transform: translateY(-2px);
    color: #e0d4ff;
    animation-play-state: paused;
}

/* ── Message Bubbles (messenger style) ── */
.msg {
    display: flex;
    gap: 10px;
    max-width: 75%;
    animation: msgIn 0.25s ease;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-character {
    align-self: flex-start;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 4px;
}

.msg-bubble {
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.55;
    word-break: break-word;
}

.msg-bubble-user {
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 6px;
}

.msg-bubble-char {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 6px;
    color: var(--text-primary);
}

.msg-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.msg-text {
    line-height: 1.6;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Inline image in character message bubble */
.msg-inline-image {
    margin-top: 10px;
    margin-bottom: 4px;
    /* Shrink wrapper to actual image size so the absolute-positioned
       regenerate button lines up with the image's top-right corner
       instead of floating in empty space next to a wide message bubble. */
    width: fit-content;
    max-width: 200px;
}
.msg-inline-image img {
    width: 100%;
    max-width: 200px;
    display: block;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    aspect-ratio: 5 / 6;
    object-fit: cover;
}
.msg-inline-image img:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
}

/* Scene Shot button on last character message */
.msg-scene-shot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    padding: 10px 24px;
    background: linear-gradient(135deg, #7c5cff, #a78bfa);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 12px rgba(124, 92, 255, 0.3);
    animation: sceneBtnPulse 2s ease-in-out 1s 3;
}
.msg-scene-shot-btn:hover {
    background: linear-gradient(135deg, #6a4de0, #9575e8);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(124, 92, 255, 0.5);
    color: #fff;
}
@keyframes sceneBtnPulse {
    0%, 100% { box-shadow: 0 2px 12px rgba(124, 92, 255, 0.3); }
    50% { box-shadow: 0 2px 20px rgba(124, 92, 255, 0.6); }
}
.msg-scene-shot-slot {
    min-height: 0;
    margin-top: 12px;
}

/* Character actions/narration — *asterisk text* rendered as styled spans */
.msg-action {
    font-style: italic;
    color: rgba(178, 160, 255, 0.9);
}

/* ── Experimental: streaming renderer ──
 * Activated via ?exp=streaming. Actions get a subtle inline pill
 * treatment (background tint + padding) to visually separate
 * "stage direction" from dialogue while keeping them in the same flow.
 */
.msg-action-pill {
    font-style: italic;
    color: rgba(195, 180, 255, 0.95);
    background: rgba(124, 92, 255, 0.10);
    padding: 1px 6px;
    border-radius: 5px;
    margin: 0 1px;
    /* Slight entrance so each newly revealed action doesn't just pop */
    animation: actionPillIn 240ms ease;
}
@keyframes actionPillIn {
    from { background-color: rgba(124, 92, 255, 0.22); }
    to   { background-color: rgba(124, 92, 255, 0.10); }
}

/* Emphasis — *one word* that was flagged as emphasis, not an action.
 * Renders as italic in the speech color (not pilled). */
.msg-emphasis {
    font-style: italic;
}

/* Blinking caret at the end of actively streaming text. Uses
 * ::after so it doesn't pollute the text content. */
.msg-text-streaming::after {
    content: "▎";
    display: inline-block;
    color: rgba(167, 139, 250, 0.7);
    font-weight: 400;
    margin-left: 1px;
    animation: streamCaret 1s steps(2) infinite;
}
@keyframes streamCaret {
    0%, 50%  { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.msg-image {
    margin-top: 8px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    max-width: 360px;
    transition: transform var(--transition);
}
.msg-image:hover { transform: scale(1.02); }
.msg-image img {
    width: 100%;
    border-radius: var(--radius-sm);
    display: block;
}

.msg-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.msg-user .msg-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.6);
}

/* ── Narrator Messages ── */
.msg.msg-narrator {
    align-self: center !important;
    max-width: 480px;
    width: 100%;
    margin-left: auto !important;
    margin-right: auto !important;
    margin-top: 24px;
    margin-bottom: 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: narratorFadeIn 0.6s ease;
}

@keyframes narratorFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-narrator .narrator-text {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    font-style: italic;
    line-height: 1.7;
    color: #e5e7eb;
    padding: 24px 32px;
    position: relative;
    background: linear-gradient(145deg, rgba(124, 92, 255, 0.08) 0%, rgba(88, 28, 135, 0.06) 100%);
    border-radius: 16px;
    border: 1px solid rgba(124, 92, 255, 0.12);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* Decorative separator lines */
.msg-narrator .narrator-text::before,
.msg-narrator .narrator-text::after {
    content: "";
    display: block;
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(124, 92, 255, 0.35), transparent);
    margin: 0 auto;
}
.msg-narrator .narrator-text::before {
    margin-bottom: 16px;
}
.msg-narrator .narrator-text::after {
    margin-top: 16px;
}

/* Narrator bubble (wraps text + generate button + image) */
.msg-narrator .narrator-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* Narrator image-card mode: image background with text overlay */
.narrator-image-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    max-width: 350px;
    margin: 0 auto;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.narrator-image-card:hover {
    transform: scale(1.01);
    box-shadow: 0 8px 30px rgba(124, 92, 255, 0.15), 0 4px 20px rgba(0, 0, 0, 0.4);
}

.narrator-card-bg {
    width: 100%;
    display: block;
    border-radius: 16px;
}

.narrator-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px 24px 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.5) 50%, transparent 100%);
    border-radius: 0 0 16px 16px;
}

.narrator-with-image .narrator-text {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    color: #f3f4f6;
    font-size: 0.88rem;
    line-height: 1.6;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.narrator-with-image .narrator-text::before,
.narrator-with-image .narrator-text::after {
    display: none;
}

/* Legacy narrator image (for backwards compat) */
.msg-narrator .narrator-image-wrapper {
    margin-bottom: 8px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}
.msg-narrator .narrator-image-wrapper:hover {
    transform: scale(1.02);
}
.msg-narrator .narrator-image {
    width: 100%;
    max-width: 220px;
    margin: 0 auto;
    display: block;
    border-radius: 12px;
}

/* Narrator generate button */
.narrator-generate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 32px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, #7c5cff, #a855f7);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 16px rgba(124, 92, 255, 0.3);
    animation: narratorBtnBounce 2.2s ease-in-out infinite;
}

@keyframes narratorBtnBounce {
    0%, 100% {
        transform: translateY(0);
        box-shadow: 0 4px 16px rgba(124, 92, 255, 0.3);
    }
    15% {
        transform: translateY(-6px);
        box-shadow: 0 10px 24px rgba(124, 92, 255, 0.5), 0 0 40px rgba(168, 85, 247, 0.25);
    }
    30% {
        transform: translateY(0);
        box-shadow: 0 4px 16px rgba(124, 92, 255, 0.4);
    }
    42% {
        transform: translateY(-3px);
        box-shadow: 0 8px 20px rgba(124, 92, 255, 0.45);
    }
    55% {
        transform: translateY(0);
        box-shadow: 0 4px 16px rgba(124, 92, 255, 0.3);
    }
}

.narrator-generate-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #8b6fff, #b56bfa);
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 24px rgba(124, 92, 255, 0.45);
    animation: none;
}
.narrator-generate-btn:active:not(:disabled) {
    transform: translateY(0) scale(1);
}
.narrator-generate-btn:disabled {
    opacity: 0.7;
    cursor: wait;
    animation: none;
}

/* Narrator image slot (image appears here after generation) */
.narrator-image-slot {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.narrator-image-slot .narrator-image {
    width: 100%;
    max-width: 340px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-top: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    aspect-ratio: 1 / 1;
    object-fit: cover;
}
.narrator-image-slot .narrator-image:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 24px rgba(124, 92, 255, 0.15), 0 4px 20px rgba(0, 0, 0, 0.35);
}

/* Narrator scene loading — immersive placeholder */
.narrator-scene-loading {
    width: 100%;
    max-width: 280px;
    height: 48px;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    background: rgba(124, 92, 255, 0.04);
    border: 1px solid rgba(124, 92, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px auto 0;
}

.scene-loading-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg,
        transparent 0%,
        transparent 40%,
        rgba(124, 92, 255, 0.08) 50%,
        transparent 60%,
        transparent 100%);
    background-size: 200% 100%;
    animation: sceneShimmer 2s ease-in-out infinite;
}

@keyframes sceneShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.scene-loading-text {
    position: relative;
    z-index: 1;
    font-size: 0.85rem;
    font-style: italic;
    color: #9ca3af;
    animation: sceneLoadingFade 2s ease-in-out infinite;
}

@keyframes sceneLoadingFade {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Legacy shimmer (backwards compat) */
.narrator-image-loading {
    width: 100%;
    max-width: 280px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(110deg,
        rgba(108, 92, 231, 0.06) 0%,
        rgba(108, 92, 231, 0.06) 40%,
        rgba(108, 92, 231, 0.15) 50%,
        rgba(108, 92, 231, 0.06) 60%,
        rgba(108, 92, 231, 0.06) 100%
    );
    background-size: 200% 100%;
    animation: narratorShimmer 1.5s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px auto 0;
}
.narrator-image-loading::after {
    content: "Capturing the moment...";
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    letter-spacing: 0.02em;
}
@keyframes narratorShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Relationship Level Up Card ── */
.msg-relationship-up {
    align-self: center;
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 16px 0;
    animation: relUpFadeIn 0.6s ease-out;
}
@keyframes relUpFadeIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.relationship-up-card {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.15) 0%, rgba(168, 85, 247, 0.12) 50%, rgba(236, 72, 153, 0.1) 100%);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 16px;
    padding: 20px 28px;
    text-align: center;
    max-width: 340px;
    width: 90%;
    box-shadow: 0 4px 24px rgba(108, 92, 231, 0.15), inset 0 1px 0 rgba(255,255,255,0.05);
}
.rel-up-icon {
    font-size: 2.2rem;
    margin-bottom: 6px;
    filter: drop-shadow(0 2px 6px rgba(168, 85, 247, 0.3));
}
.rel-up-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 6px;
}
.rel-up-level {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}
.rel-up-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}
.rel-unlocks {
    border-top: 1px solid rgba(168, 85, 247, 0.15);
    padding-top: 10px;
    text-align: left;
}
.rel-unlocks-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}
.rel-unlock-item {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding: 2px 0;
    line-height: 1.4;
}

/* ── Meeting Intro card ── */
.meeting-intro-bubble {
    background: rgba(124,92,255,0.06);
    border: 1px solid rgba(124,92,255,0.15);
    border-radius: 16px;
    padding: 18px 20px;
    text-align: center;
}
.meeting-intro-label {
    font-size: 0.7rem;
    color: #a78bfa;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}
.meeting-intro-text {
    font-style: normal !important;
    color: #d4d0e8 !important;
    font-size: 0.9rem !important;
    line-height: 1.55 !important;
}
/* Meeting intro shimmer inherits compact style */

/* ── Compact inline level-up card ── */
.relationship-up-card.compact {
    padding: 10px 16px;
    max-width: 260px;
}
.relationship-up-card.compact .rel-up-icon { font-size: 1.4rem; margin-bottom: 2px; }
.relationship-up-card.compact .rel-up-level { font-size: 0.95rem; margin-bottom: 0; }

/* ── Milestone Celebration Modal ── */
.milestone-overlay {
    position: fixed; inset: 0; z-index: 10001;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.3s;
}
.milestone-overlay.visible { opacity: 1; }
.milestone-card {
    background: linear-gradient(145deg, rgba(26,21,40,0.98), rgba(15,12,24,0.98));
    border: 1px solid rgba(168,85,247,0.4);
    border-radius: 20px; padding: 28px 24px; text-align: center;
    max-width: 340px; width: calc(100% - 32px);
    box-shadow: 0 16px 48px rgba(108,92,231,0.3), 0 0 80px rgba(168,85,247,0.1);
    transform: scale(0.9); transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.milestone-overlay.visible .milestone-card { transform: scale(1); }
.milestone-sparkle { font-size: 2.4rem; margin-bottom: 8px; }
.milestone-title {
    font-size: 1.3rem; font-weight: 800; color: #e9e7f5;
    margin-bottom: 6px; letter-spacing: 0.01em;
}
.milestone-desc {
    font-size: 0.85rem; color: #9ca3af; line-height: 1.5; margin-bottom: 16px;
}
.milestone-unlocks {
    background: rgba(124,92,255,0.08); border-radius: 12px;
    padding: 12px 16px; text-align: left; margin-bottom: 12px;
}
.milestone-unlocks-label {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em;
    color: #a78bfa; font-weight: 600; margin-bottom: 8px;
}
.milestone-unlocks .rel-unlock-item {
    font-size: 0.82rem; color: #d1d5db; padding: 2px 0; line-height: 1.5;
}
.rel-next-preview {
    border-top: 1px solid rgba(255,255,255,0.06); padding-top: 10px; margin-bottom: 12px;
}
.rel-next-label {
    font-size: 0.78rem; color: #7c5cff; font-weight: 600; margin-bottom: 2px;
}
.rel-next-teaser { font-size: 0.72rem; color: #6b7280; }
.milestone-btn {
    background: linear-gradient(135deg, #7c5cff, #a78bfa);
    color: #fff; border: none; border-radius: 12px; padding: 10px 24px;
    font-size: 0.9rem; font-weight: 600; cursor: pointer; width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}
.milestone-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(124,92,255,0.4);
}

/* ── Onboarding Tips ── */
/* ── Save Progress Banner (guest mode) ── */
.save-progress-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 12px;
    margin: 0 10px 6px;
    animation: tipFadeIn 0.3s ease-out;
}
.save-banner-text {
    flex: 1;
    font-size: 0.78rem;
    color: #86efac;
    line-height: 1.3;
}
.save-banner-btn {
    background: linear-gradient(135deg, #7c5cff, #a78bfa);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.save-banner-dismiss {
    background: none;
    border: none;
    color: rgba(255,255,255,0.3);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 4px;
}

.onboarding-tip {
    text-align: center; padding: 8px 16px; margin: 6px auto;
    font-size: 0.78rem; color: #c4b5fd; line-height: 1.4;
    background: rgba(124,92,255,0.08);
    border: 1px solid rgba(124,92,255,0.15);
    border-radius: 12px; max-width: 320px;
    cursor: pointer; transition: opacity 0.3s;
    animation: tipFadeIn 0.4s ease-out;
}
@keyframes tipFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Character Status Card ── */
.status-card-overlay {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 100px;
    opacity: 0; transition: opacity 0.2s;
}
.status-card-overlay.visible { opacity: 1; }
.status-card {
    background: rgba(26,21,40,0.97); border: 1px solid rgba(124,92,255,0.25);
    border-radius: 16px; padding: 16px 20px; min-width: 220px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transform: scale(0.95); transition: transform 0.2s;
}
.status-card-overlay.visible .status-card { transform: scale(1); }
.status-row {
    font-size: 0.88rem; color: #e9e7f5; padding: 4px 0;
    display: flex; align-items: center; gap: 6px;
}
.status-needs {
    font-size: 0.75rem; color: #6b7280; padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.06); margin-top: 6px;
}

/* ── Staggered narrator animation ── */
.msg-narrator.staggered-1 { animation-delay: 0.15s; animation-fill-mode: both; }
.msg-narrator.staggered-2 { animation-delay: 0.30s; animation-fill-mode: both; }
.msg-narrator.staggered-3 { animation-delay: 0.45s; animation-fill-mode: both; }
.msg-narrator.staggered-4 { animation-delay: 0.60s; animation-fill-mode: both; }

/* ── Image fade-in on load ── */
.msg-inline-image img,
.narrator-image,
.msg-scene-shot-slot img {
    opacity: 0;
    animation: imgFadeIn 0.5s ease forwards;
}
@keyframes imgFadeIn {
    from { opacity: 0; transform: scale(0.96); filter: blur(4px); }
    to { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* ── Relationship level-up celebration ── */
.msg-relationship-up {
    animation: relUpFadeIn 0.6s ease-out, relUpGlow 2s ease-in-out 0.6s;
}
@keyframes relUpGlow {
    0% { filter: brightness(1); }
    30% { filter: brightness(1.15); }
    60% { filter: brightness(1.05); }
    100% { filter: brightness(1); }
}
.rel-up-icon {
    animation: relUpBounce 0.8s ease 0.3s both;
}
@keyframes relUpBounce {
    0% { transform: scale(0.3) rotate(-15deg); opacity: 0; }
    50% { transform: scale(1.3) rotate(5deg); opacity: 1; }
    70% { transform: scale(0.9) rotate(-3deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ── Scene shot loading pulse ── */
.msg-scene-shot-btn.generating {
    position: relative;
    overflow: hidden;
    pointer-events: none;
}
.msg-scene-shot-btn.generating::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(168, 85, 247, 0.2), transparent);
    animation: sceneShotPulse 1.5s ease-in-out infinite;
}
@keyframes sceneShotPulse {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ── World event narrator glow ── */
.msg-narrator.world-event .narrator-text {
    border-left: 3px solid rgba(255, 193, 7, 0.6);
    padding-left: 14px;
}
.msg-narrator.world-event {
    animation: narratorFadeIn 0.5s ease, worldEventGlow 1.5s ease-out 0.5s;
}
@keyframes worldEventGlow {
    0% { filter: brightness(1); }
    30% { filter: brightness(1.1) drop-shadow(0 0 8px rgba(255, 193, 7, 0.3)); }
    100% { filter: brightness(1); }
}

/* ── Story arc narrator style ── */
.msg-narrator.story-arc .narrator-text {
    border-left: 3px solid rgba(168, 85, 247, 0.6);
    padding-left: 14px;
}

/* ── Smooth scroll for new messages ── */
.chat-messages {
    scroll-behavior: smooth;
}

/* ── Date Separator ── */
.msg-date-separator {
    align-self: center;
    text-align: center;
    padding: 8px 0;
    margin: 8px 0;
    width: 100%;
    position: relative;
}
.msg-date-separator span {
    position: relative;
    padding: 3px 14px;
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: var(--radius-pill);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ── System Messages ── */
.msg-system {
    align-self: center;
    max-width: 90%;
    text-align: center;
    padding: 6px 16px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Typing Indicator ── */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 24px 12px;
}

.chat-typing-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    letter-spacing: 0.02em;
}
.chat-typing-dots {
    display: flex;
    gap: 5px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    border-bottom-left-radius: 6px;
}
.chat-typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: chatTypingBounce 1.2s infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Chat Input Bar ──
 * Background matches --bg-primary (same as chat-container and
 * theme-color) so the bottom safe-area is seamless — previously
 * bg-secondary (#16161e) differed from the iOS chrome tint below,
 * creating a visible horizontal seam above the home indicator.
 * The inner .input-wrapper pill keeps its lighter bg-input for
 * visual separation between input field and container. */
.chat-input-bar {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
    flex-shrink: 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
}

.chat-input-bar .input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 8px 10px 8px 18px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.chat-input-bar .input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124,92,255,0.2), 0 0 20px rgba(124,92,255,0.1);
}

.chat-input-bar textarea,
.chat-input-bar #chatInput {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.4;
    padding: 6px 0;
    margin: 0;
    min-height: 20px;
}
.chat-input-bar textarea::placeholder,
.chat-input-bar #chatInput::placeholder {
    color: var(--text-muted);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--accent-gradient);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    box-shadow: 0 2px 10px rgba(124, 92, 255, 0.3);
    padding: 0;
}
.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(124, 92, 255, 0.5);
}
.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}
.chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

/* Generate Shot button */
.chat-gen-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.7);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    padding: 0;
}
.chat-gen-btn:hover:not(:disabled) {
    background: rgba(124, 92, 255, 0.2);
    border-color: rgba(124, 92, 255, 0.4);
    color: white;
}
.chat-gen-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Generated image in chat */
.msg-generated {
    display: flex;
    justify-content: center;
    padding: 8px 16px;
}
.generated-image-card {
    max-width: 400px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.2s;
}
.generated-image-card:hover {
    transform: scale(1.02);
}
.generated-image-card img {
    width: 100%;
    display: block;
}
.generated-caption {
    padding: 8px 12px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-align: center;
}

/* ── Failed Message ── */
.msg-failed .msg-bubble {
    border: 1px solid var(--red);
    opacity: 0.7;
}


/* Stats tab */
.stats-avatar {
    text-align: center;
    margin-bottom: 12px;
}
.stats-avatar img {
    width: 80px; height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(124, 92, 255, 0.3);
    box-shadow: 0 0 16px rgba(124, 92, 255, 0.15);
}
.stats-info {
    text-align: center;
    margin-bottom: 16px;
}
.stats-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}
.stats-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.stats-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.stats-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.stats-value {
    color: var(--text-primary);
    font-size: 0.95rem;
}
.stats-rel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.stats-rel-nums {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 4px;
}
.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.stat-item {
    display: grid;
    grid-template-columns: 70px 1fr 30px;
    align-items: center;
    gap: 8px;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.stat-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.stat-row {
    display: grid;
    grid-template-columns: 70px 1fr;
    align-items: center;
    gap: 8px;
}
.stat-bar {
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: visible;
    position: relative;
}
.stat-fill {
    height: 100%;
    background: linear-gradient(90deg, #7C5CFF, #A855F7);
    border-radius: 3px;
    transition: width 0.5s ease;
}
.stat-num {
    position: absolute;
    right: 0;
    top: -16px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}
.stats-label-sm {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.memory-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
}
.memory-item {
    padding: 6px 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 16px 0;
    font-size: 0.82rem;
}
.scene-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.detail-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 2px;
}
.perks-list, .tips-list {
    font-size: 0.85rem;
    line-height: 1.6;
}

/* Locations tab */
.settings-player-loc {
    padding: 8px 12px;
    background: rgba(124,92,255,0.08);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.85rem;
}
.location-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Memories tab */
.memories-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}


/* ── Chat Mobile Responsive (legacy — overrides moved to consolidated block) ── */
@media (max-width: 768px) {
    .chat-messages { padding: 12px 12px 8px; }
    .chat-input-bar { padding: 8px 12px 12px; }
}

@media (max-width: 480px) {
    .msg { max-width: 95%; }
    .chat-rel-badge { display: none; }
    .chat-header-actions { gap: 4px; }
}

/* ── Login Modal ──────────────────────────────────────────────────── */

.login-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

.login-modal-card {
    position: relative;
    background: linear-gradient(145deg, #141428 0%, #1a1a35 100%);
    border: 1px solid rgba(124, 92, 255, 0.25);
    border-radius: 20px;
    padding: 48px 40px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(124, 92, 255, 0.08);
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #666;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}
.login-modal-close:hover { color: #fff; }

.login-modal-logo {
    font-size: 2.5rem;
    margin-bottom: 8px;
    color: var(--accent);
    text-align: center;
}
.login-modal-logo .brand-logo {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    border-radius: 12px;
}

.login-modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #7c5cff, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-modal-subtitle {
    color: #9ca3af;
    font-size: 0.9rem;
    margin-bottom: 22px;
    line-height: 1.5;
}

/* Trust row: three pills reassuring users before they sign in */
.login-trust-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.login-trust-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(124, 92, 255, 0.1);
    border: 1px solid rgba(124, 92, 255, 0.22);
    color: #c7bfff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 7px 11px;
    border-radius: 100px;
    white-space: nowrap;
}
.login-trust-icon { font-size: 0.9rem; line-height: 1; }

/* Privacy promise: inline reassurance below the OAuth buttons */
.login-promise {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    padding: 12px 14px;
    margin-top: 14px;
    color: #a7d8c0;
    font-size: 0.78rem;
    line-height: 1.5;
    text-align: left;
}
.login-promise strong { color: #6ee7b7; font-weight: 700; }
.login-promise-icon {
    font-size: 1rem;
    line-height: 1.4;
    flex-shrink: 0;
}

@media (max-width: 420px) {
    .login-trust-row { gap: 6px; }
    .login-trust-pill { font-size: 0.68rem; padding: 6px 9px; }
    .login-promise { font-size: 0.74rem; padding: 10px 12px; }
}

.login-modal-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    color: #ef4444;
    font-size: 0.85rem;
    display: none;
}

.login-modal-footer {
    margin-top: 24px;
    color: #555;
    font-size: 0.75rem;
}

.oauth-btn {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    width: 100%; padding: 12px 16px; margin-bottom: 10px;
    border-radius: 10px; font-size: 0.95rem; font-weight: 500;
    text-decoration: none; transition: all 0.2s; cursor: pointer;
    border: 1px solid rgba(255,255,255,0.12);
}
.oauth-btn-google { background: #fff; color: #3c4043; }
.oauth-btn-google:hover { background: #f5f5f5; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.oauth-btn-discord { background: #5865F2; color: #fff; }
.oauth-btn-discord:hover { background: #4752c4; }
.oauth-btn-apple { background: #000; color: #fff; border: 1px solid #333; }
.oauth-btn-apple:hover { background: #1a1a1a; }
.oauth-logo { flex-shrink: 0; }

/* ── ToS Consent ─────────────────────────────────────────────────── */
.tos-consent { padding: 12px 0; }
.tos-checkbox-label {
    display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
    color: #9ca3af; font-size: 0.82rem; line-height: 1.4;
}
.tos-checkbox-label input[type="checkbox"] {
    margin-top: 2px; accent-color: #7c5cff; width: 16px; height: 16px; flex-shrink: 0;
}
.tos-checkbox-label a { color: #a78bfa; }
.tos-consent.error { animation: shake 0.3s; }
.tos-consent.error .tos-checkbox-label { color: #ef4444; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ── Chat Loading Overlay ────────────────────────────────────────── */
.chat-loading-overlay {
    position: absolute; inset: 0; z-index: 10;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--bg-primary, #0d0b14); gap: 16px;
}
.chat-loading-spinner {
    width: 40px; height: 40px; border: 3px solid rgba(124,92,255,0.2);
    border-top-color: #7c5cff; border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.chat-loading-text { color: #6b7280; font-size: 0.9rem; }

/* ── Nav Auth Actions ─────────────────────────────────────────────── */

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    margin-right: 16px;
}

.nav-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ccc;
    font-size: 0.85rem;
}

.nav-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(124, 92, 255, 0.3);
}

.nav-user-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c5cff, #a78bfa);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

.nav-login-btn {
    padding: 6px 16px;
    border: 1px solid rgba(124, 92, 255, 0.3);
    border-radius: 8px;
    background: rgba(124, 92, 255, 0.1);
    color: #a78bfa;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.nav-login-btn:hover {
    background: rgba(124, 92, 255, 0.2);
    border-color: rgba(124, 92, 255, 0.5);
}

.nav-logout-btn {
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: transparent;
    color: #888;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}
.nav-logout-btn:hover {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Consolidated overrides (≤768px tablet, ≤480px phone)
   Desktop CSS above is NOT modified. All mobile changes below.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── TABLET (≤768px) ──────────────────────────────────────────────── */
@media (max-width: 768px) {

    /* iOS zoom prevention: 16px minimum for inputs */
    #chatInput,
    textarea { font-size: 16px; }

    /* --- Landing Page --- */
    .landing-hero { padding: 40px 16px 24px; }
    .landing-title { font-size: 1.6rem; }
    .landing-values { gap: 12px; padding: 0 16px; }
    .landing-cta-section { padding: 20px 16px; }
    .landing-cta-btn {
        width: calc(100% - 32px);
        max-width: 320px;
        text-align: center !important;
        display: block !important;
        margin: 0 auto;
    }
    .showcase-section { padding: 24px 0 16px; }
    .worlds-strip { padding: 20px 16px; }
    .worlds-pills { gap: 8px; flex-wrap: wrap; justify-content: center; }
    .worlds-pill { font-size: 0.75rem; padding: 6px 14px; }
    .landing-disclaimer { padding: 16px; font-size: 0.65rem; }

    /* --- Creation Wizard --- */
    .modal-overlay { padding: 0; }
    .modal, .modal-wide {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        height: 100vh;
        height: 100dvh;
    }
    .modal-header { padding: 12px 16px; }
    .modal-header h2 { font-size: 1rem; }
    .modal-body-split {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        flex: 1;
        min-height: 0;
    }
    .modal-body {
        padding: 16px;
        overflow: visible;
        flex: none;
    }

    /* Stepper: compact circles, hide labels, scrollable */
    .wizard-stepper {
        padding: 0 8px 12px;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .wizard-stepper::-webkit-scrollbar { display: none; }
    .wizard-step-circle { width: 24px; height: 24px; font-size: 0.6rem; }
    .wizard-step-label { display: none; }
    .wizard-step { gap: 2px; }
    .wizard-stepper::before { top: 12px; left: 24px; right: 24px; }

    /* Wizard nav: fixed at bottom */
    .wizard-nav {
        padding: 10px 16px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        border-radius: 0;
        flex-shrink: 0;
    }
    .wizard-nav .btn {
        min-width: 90px;
        font-size: 0.85rem;
        padding: 10px 16px;
    }
    .btn-next-glow {
        min-width: 120px !important;
        min-height: 42px !important;
        font-size: 0.85rem !important;
    }
    .wizard-nav-counter { font-size: 0.65rem; }

    .card-selector { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .img-chip-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .img-chip-grid.cols-5 { grid-template-columns: repeat(2, 1fr); }
    .img-chip-grid.cols-6 { grid-template-columns: repeat(3, 1fr); }

    .personality-layout { grid-template-columns: 1fr; }
    .trait-preview-panel { display: none; }

    /* Backstory / Persona */
    .backstory-buttons, .persona-buttons { flex-wrap: wrap; gap: 8px; }
    .backstory-buttons .btn, .persona-buttons .btn { flex: 1; min-width: 120px; }

    /* Review */
    .review-card { grid-template-columns: 1fr; }
    .char-sheet-sections { grid-template-columns: 1fr; }

    /* Preview / Approval */
    .preview-actions { flex-direction: column; gap: 10px; }
    .preview-actions .btn { width: 100%; }

    /* Generation tips */
    .generation-tip { font-size: 0.95rem; padding: 0 20px; }

    /* --- Chat Page --- */
    .chat-container { height: 100vh; height: 100dvh; }

    /* Chat header handled by 600px breakpoint — only override small extras */
    .chat-header { padding: 0; gap: 0; }

    /* Messages */
    .chat-messages { padding: 10px 10px 6px; }
    .msg { max-width: 90%; }
    .msg-avatar { width: 24px; height: 24px; }
    .msg-char .msg-content { padding: 10px 14px; }
    .msg-user .msg-bubble { padding: 10px 14px; font-size: 0.9rem; }
    .msg-char .char-name { font-size: 0.7rem; }
    .msg-time { font-size: 0.6rem; }

    /* Narrator */
    .msg-narrator { max-width: 98%; margin: 12px auto; }
    .msg-narrator .narrator-bubble { border-radius: 12px; }
    .narrator-text { padding: 14px 16px; font-size: 0.9rem; }
    .narrator-with-image { border-radius: 12px; }
    .narrator-with-image .narrator-text-overlay { padding: 12px 14px; font-size: 0.8rem; }
    /* narrator shimmer handled by compact universal style */
    .narrator-gen-btn { font-size: 0.8rem; padding: 10px 20px; }

    /* Scene shot */
    .scene-shot-btn { font-size: 0.75rem; padding: 6px 14px; }
    .msg-scene-shot { max-width: 220px; }

    /* Input */
    .chat-input-bar { padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
    .chat-input-bar textarea { font-size: 16px; /* prevents iOS zoom on focus */ }
    .chat-send-btn {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 0 0 2px;
        line-height: 1;
    }

    /* First message hint — above textfield */
    .chat-start-hint {
        position: absolute !important;
        top: auto !important;
        bottom: 16px !important;
        left: 12px !important;
        right: 12px !important;
        transform: none !important;
        text-align: center;
    }
    .chat-hint-icon { font-size: 1.5rem; margin-bottom: 6px; }
    .chat-hint-title { font-size: 0.8rem; margin-bottom: 6px; }
    .chat-hint-subtitle { font-size: 0.7rem; padding: 6px 12px; margin-bottom: 12px; }
    .chat-hint-chip { font-size: 0.75rem; padding: 7px 14px; }

    /* Memories tab */
    .chat-tab-panel { padding: 14px; }
    .tab-panel-content { padding: 0; }

    /* Gallery tab */
    .tab-gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

    /* Settings modal */

    /* Lightbox */
    .lightbox-content { max-width: 98vw; max-height: 98vh; }
    .lightbox-content img { max-width: 98vw; max-height: 90vh; border-radius: 4px; }

    /* --- Login Modal --- */
    .login-modal-card { width: calc(100% - 32px); max-width: 100%; }
    .oauth-btn { padding: 14px 20px; font-size: 0.9rem; }

    /* --- Character Cards --- */
    .char-card { padding: 12px; }
    .char-card-avatar { width: 50px; height: 50px; }

    /* --- Tips (logged in) --- */
    .tips-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* ── PHONE (≤480px) ───────────────────────────────────────────────── */
@media (max-width: 480px) {

    /* --- Landing --- */
    .landing-title { font-size: 1.3rem; }

    /* Container: remove side padding so scroll containers go edge-to-edge */
    .container { padding-left: 12px; padding-right: 12px; padding-top: 64px; }

    /* Prevent horizontal scroll on mobile */
    html, body { overflow-x: hidden; }

    /* Empty hero: remove max-width so scroll containers can go full width */
    .empty-hero {
        max-width: 100vw !important;
        padding-left: 0;
        padding-right: 0;
        margin-left: -12px;
        margin-right: -12px;
        width: calc(100% + 24px);
        overflow-x: visible;
    }
    .landing-hero, .landing-cta { padding-left: 16px; padding-right: 16px; text-align: center; }
    .landing-cta { display: flex; flex-direction: column; align-items: center; }

    /* Value cards: horizontal scroll on phone */
    .landing-values {
        display: flex !important;
        grid-template-columns: unset !important;
        overflow-x: auto;
        scroll-snap-type: none;
        gap: 12px;
        padding: 0;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        max-width: 100% !important;
        margin: 0 0 56px 0;
    }
    .landing-values::-webkit-scrollbar { display: none; }
    .landing-values::before {
        content: '';
        min-width: 1px;
        padding-left: 15px;
        flex: 0 0 auto;
    }
    .landing-value {
        min-width: 240px;
        width: 240px;
        flex: 0 0 240px;
        padding: 18px 16px;
    }
    .landing-value-title { font-size: 0.9rem; }
    .landing-value-desc { font-size: 0.78rem; line-height: 1.4; }
    .landing-value-icon { font-size: 1.3rem; }
    .landing-value:last-child { margin-right: 16px; }
    .showcase-card { width: 180px; }
    .showcase-track { gap: 10px; }

    /* --- Wizard fullscreen --- */
    .modal-body { padding: 12px; }
    .chip-group { grid-template-columns: repeat(3, 1fr); }
    .card-selector { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .card-selector .card-item { padding: 8px; }
    .card-selector .card-item img { height: 60px; }

    /* --- Chat --- */
    .msg { max-width: 95%; }
    .chat-avatar { width: 64px; height: 64px; }
    .chat-char-name { font-size: 0.8rem; max-width: 140px; }
    .chat-char-location { font-size: 0.6rem; max-width: 140px; }
    .chat-rel-level { font-size: 0.65rem; }

    .narrator-text { font-size: 0.9rem; padding: 12px 14px; }
    .narrator-with-image .narrator-text-overlay { font-size: 0.8rem; }

    .hint-chip { font-size: 0.75rem; padding: 7px 12px; }

    /* Gallery 2 columns tighter */
    .tab-gallery-grid { gap: 6px; }

    /* --- General --- */
    html { font-size: 14px; }
    .nav-brand { font-size: 0.85rem; }
    .page-header h1 { font-size: 1.2rem; }
    .page-header .btn { font-size: 0.8rem; padding: 8px 16px; }

    /* Tips single column */
    .tips-grid { grid-template-columns: 1fr; }

    /* Character grid single column */
    .char-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════
   Credits Badge & Paywall Modal
   ═══════════════════════════════════════════════════════════════════ */

/* Cost badge — small corner badge on generation buttons */
.cost-badge {
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(40%, -30%);
    font-size: 0.6rem;
    background: rgba(124, 92, 255, 0.4);
    border: 1px solid rgba(124, 92, 255, 0.5);
    color: #c4b5fd;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1;
}
.cost-badge.free {
    background: rgba(34, 197, 94, 0.3);
    border-color: rgba(34, 197, 94, 0.5);
    color: #86efac;
}

/* Wrap buttons that have cost badges */
.load-more-wrap {
    text-align: center;
    padding: 12px 0;
}
.load-more-btn {
    background: rgba(124, 92, 255, 0.15);
    border: 1px solid rgba(124, 92, 255, 0.3);
    color: #c4b5fd;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}
.load-more-btn:hover {
    background: rgba(124, 92, 255, 0.25);
    border-color: rgba(124, 92, 255, 0.5);
}

/* ── Auto-translate toggle ── */
.translate-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 12px;
    padding: 4px 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}
.translate-toggle:hover {
    background: rgba(124, 92, 255, 0.1);
    border-color: rgba(124, 92, 255, 0.2);
}
.translate-toggle.active {
    background: rgba(124, 92, 255, 0.15);
    border-color: rgba(124, 92, 255, 0.3);
}
.toggle-text, .toggle-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: #6b7280;
    user-select: none;
    transition: color 0.2s;
    white-space: nowrap;
}
.translate-toggle.active .toggle-text,
.translate-toggle.active .toggle-label {
    color: #a78bfa;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    transition: 0.3s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: #888;
    border-radius: 50%;
    transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
    background: rgba(124, 92, 255, 0.4);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
    background: #a78bfa;
}

.gen-btn-wrap,
.scene-shot-wrap {
    position: relative;
    display: inline-block;
}

.nav-credits {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: rgba(124, 92, 255, 0.1);
    border: 1px solid rgba(124, 92, 255, 0.2);
    border-radius: 20px;
    font-size: 0.8rem;
    color: #a78bfa;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}
.nav-credits:hover {
    background: rgba(124, 92, 255, 0.15);
}
.credits-icon { font-size: 0.9rem; }

/* ── Paywall Modal (redesigned for conversion) ── */
.paywall-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    animation: fadeIn 0.2s ease;
}
.paywall-card {
    background: linear-gradient(160deg, #16152e 0%, #1c1a3a 50%, #1a1832 100%);
    border: 1px solid rgba(124, 92, 255, 0.2);
    border-radius: 20px;
    padding: 28px 24px 20px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    position: relative;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 60px rgba(124, 92, 255, 0.06);
    animation: modalSlideUp 0.3s ease;
}
.paywall-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    color: #4b4a6a;
    font-size: 1.3rem;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}
.paywall-close:hover { color: #a78bfa; }

/* Header with avatar */
.paywall-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 18px;
}
.paywall-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(124, 92, 255, 0.4);
    margin-bottom: 12px;
    box-shadow: 0 4px 16px rgba(124, 92, 255, 0.15);
}
.paywall-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f0eeff;
    margin-bottom: 4px;
    letter-spacing: -0.2px;
}
.paywall-subtitle {
    color: #7c7a94;
    font-size: 0.82rem;
    margin: 0;
}

/* Credit packs — 3 side by side */
.paywall-packs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}
.paywall-pack {
    flex: 1;
    padding: 14px 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}
.paywall-pack:hover {
    background: rgba(124, 92, 255, 0.1);
    border-color: rgba(124, 92, 255, 0.3);
    transform: translateY(-2px);
}
.paywall-pack-popular {
    border-color: rgba(124, 92, 255, 0.4);
    background: rgba(124, 92, 255, 0.08);
    box-shadow: 0 4px 20px rgba(124, 92, 255, 0.12);
}
.paywall-pack-badge {
    position: absolute;
    top: -9px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #fff;
    background: linear-gradient(135deg, #7c5cff, #a78bfa);
    padding: 2px 8px;
    border-radius: 6px;
    white-space: nowrap;
}
.paywall-pack-amount {
    font-size: 1.35rem;
    font-weight: 800;
    color: #e5e7eb;
    line-height: 1.2;
}
.paywall-pack-label {
    font-size: 0.65rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.paywall-pack-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: #a78bfa;
}

/* Subscription button */
.paywall-sub-btn {
    display: block;
    width: 100%;
    padding: 11px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #c4b5fd;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.paywall-sub-btn:hover {
    background: rgba(124, 92, 255, 0.1);
    border-color: rgba(124, 92, 255, 0.3);
    color: #e5e7eb;
}

/* Credits badge attention-pulse — used when the counter first reveals
 * after onboarding ends, so the user notices the new element. */
.nav-credits.credits-just-revealed {
    animation: creditsReveal 1.2s ease-out;
}
@keyframes creditsReveal {
    0%   { transform: scale(0.7); opacity: 0; }
    40%  { transform: scale(1.15); opacity: 1; box-shadow: 0 0 20px rgba(251,191,36,0.6); }
    100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 rgba(251,191,36,0); }
}

/* ── Credit info popup — shown when user taps credit counter ──
 * Added after feedback: user didn't know auto-image costs 8 credits.
 * Now a tap on the credit counter shows exact costs of each action. */
.credit-info-popup {
    position: fixed;
    top: 58px;
    right: 12px;
    z-index: 9999;
    min-width: 260px;
    max-width: calc(100vw - 24px);
    background: linear-gradient(160deg, #1e1b2d, #14101f);
    border: 1px solid rgba(124, 92, 255, 0.35);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    animation: cipSlideIn 220ms cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes cipSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cip-title {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #a78bfa;
    font-weight: 700;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.cip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 0.85rem;
    color: #d4cfe8;
}
.cip-row span:last-child { color: #fff; font-family: inherit; }
.cip-row strong { color: #c4b5fd; font-weight: 700; }
.cip-note {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.78rem;
    color: #a7e3b5;
    line-height: 1.5;
}
.cip-note strong { color: #e0d4ff; }
.cip-link-row { margin-top: 6px; }
.cip-link-row a {
    color: #a78bfa;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
}
.cip-link-row a:hover { color: #c4b5fd; }

/* ── Auto-image toast — shown when character auto-sends a photo
 * so the user understands why their balance just dropped ~8 credits */
.auto-image-toast {
    position: fixed;
    left: 50%;
    top: calc(env(safe-area-inset-top, 0px) + 14px);
    transform: translate(-50%, -30px);
    z-index: 9998;
    padding: 10px 18px;
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.3), rgba(244, 114, 182, 0.2));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(167, 139, 250, 0.4);
    border-radius: 999px;
    color: #fff;
    font-size: 0.85rem;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.2,0.9,0.3,1.1), opacity 0.3s;
    white-space: nowrap;
    box-shadow: 0 8px 28px rgba(124, 92, 255, 0.35);
}
.auto-image-toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}
.auto-image-toast strong { color: #e0d4ff; font-weight: 700; }

/* Free tier daily reset info */
.paywall-free-info {
    font-size: 0.78rem;
    color: #9b8cc0;
    background: rgba(124, 92, 255, 0.06);
    border: 1px solid rgba(124, 92, 255, 0.15);
    border-radius: 10px;
    padding: 10px 14px;
    margin-top: 10px;
    line-height: 1.5;
    text-align: center;
}
.paywall-free-info strong {
    color: #a78bfa;
}
.paywall-free-main {
    margin-bottom: 4px;
}

/* Near-level-up teaser shown when user is >75% to the next relationship
 * level. Subtle purple pill under the progress bar; clicking opens the
 * unlock preview popup. Only visible in a narrow progress window so it
 * feels like a reward cue, not permanent chrome. */
/* Daily-refresh welcome-back banner. Shown once per day when the
 * free-tier daily reset has just filled the user's balance. Slides in
 * from the top, holds ~3s, slides out. */
.refresh-celebration {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 18px);
    left: 50%;
    transform: translate(-50%, -30px);
    z-index: 9999;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.15), opacity 0.4s ease;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}
.refresh-celebration.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}
.refresh-celebration-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.25), rgba(124, 92, 255, 0.25));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(167, 139, 250, 0.4);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(124, 92, 255, 0.35);
}
.refresh-celebration-spark {
    font-size: 1.5rem;
    animation: refreshSpark 1.6s ease-in-out infinite;
}
@keyframes refreshSpark {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50%      { transform: scale(1.2) rotate(10deg); }
}
.refresh-celebration-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.refresh-celebration-text strong {
    color: #e8e8ff;
    font-weight: 700;
    font-size: 0.9rem;
}
.refresh-celebration-text span {
    font-size: 0.72rem;
    color: #c4b5d8;
    letter-spacing: 0.01em;
}

.chat-rel-teaser {
    font-size: 0.68rem;
    color: #c4b5fd;
    background: rgba(124, 92, 255, 0.1);
    border: 1px solid rgba(124, 92, 255, 0.25);
    border-radius: 999px;
    padding: 3px 10px;
    margin-top: 4px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    transition: background 0.15s;
    animation: relTeaserIn 420ms ease-out;
}
.chat-rel-teaser:hover {
    background: rgba(124, 92, 255, 0.18);
}
.chat-rel-teaser strong {
    color: #e0d4ff;
    font-weight: 700;
}
@keyframes relTeaserIn {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: translateY(0); }
}
.paywall-free-timer {
    font-size: 0.74rem;
    color: #c4b5fd;
    padding-top: 6px;
    border-top: 1px dashed rgba(124, 92, 255, 0.2);
    margin-top: 6px;
}
.paywall-free-timer strong {
    color: #e0d4ff;
    font-variant-numeric: tabular-nums;
}

/* Free-tier paywall alternatives — what they can still do without paying */
.paywall-alternatives {
    margin-top: 12px;
    padding: 10px 12px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
}
.paywall-alts-title {
    font-size: 0.72rem;
    color: #8b8496;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 8px;
    font-weight: 600;
}
.paywall-alts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.paywall-alt-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    color: #c4b5d8;
    font-family: inherit;
    position: relative;
}
.paywall-alt-item:hover {
    background: rgba(124, 92, 255, 0.08);
    border-color: rgba(124, 92, 255, 0.3);
    transform: translateY(-1px);
}
.paywall-alt-item .alt-icon {
    font-size: 1.2rem;
    line-height: 1;
}
.paywall-alt-item .alt-label {
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-align: center;
}
.paywall-alt-feedback {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(167, 139, 250, 0.06));
    border-color: rgba(34, 197, 94, 0.25);
}
.paywall-alt-feedback:hover {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(167, 139, 250, 0.1));
    border-color: rgba(34, 197, 94, 0.45);
}
.paywall-alt-feedback .alt-badge {
    font-size: 0.58rem;
    font-weight: 700;
    color: #a7e3b5;
    background: rgba(34, 197, 94, 0.2);
    padding: 1px 6px;
    border-radius: 999px;
    margin-top: 2px;
    letter-spacing: 0.02em;
}
@media (max-width: 480px) {
    .paywall-alt-item .alt-label { font-size: 0.63rem; }
    .paywall-alt-feedback .alt-badge { font-size: 0.54rem; }
}

/* Discreet billing note — placed ABOVE purchase buttons so users
   see it BEFORE clicking, not after. Muted green pill with lock icon. */
.paywall-billing-note {
    font-size: 0.75rem;
    color: #a8b0a4;
    background: rgba(34, 197, 94, 0.07);
    border: 1px solid rgba(34, 197, 94, 0.22);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 4px 0 14px;
    line-height: 1.45;
    text-align: center;
}
.paywall-billing-note strong {
    color: #a7e3b5;
    font-weight: 600;
    letter-spacing: 0.03em;
}

/* Pricing-page version — sits between hero and subscription grid */
.pricing-billing-note {
    max-width: 560px;
    margin: 0 auto 28px;
    padding: 11px 18px;
    background: rgba(34, 197, 94, 0.07);
    border: 1px solid rgba(34, 197, 94, 0.22);
    border-radius: 10px;
    font-size: 0.85rem;
    color: #a8b0a4;
    text-align: center;
    line-height: 1.5;
}
.pricing-billing-note strong {
    color: #a7e3b5;
    font-weight: 600;
    letter-spacing: 0.03em;
}
/* Top variant sits closer to hero, slightly larger breathing room */
.pricing-billing-note-top {
    margin-top: -8px;
    margin-bottom: 32px;
}

@media (max-width: 580px) {
    .pricing-billing-note { font-size: 0.72rem; padding: 9px 12px; margin-bottom: 20px; }
    .pricing-billing-note-top { margin-top: -4px; margin-bottom: 20px; }
}

/* Soft dismiss */
.paywall-dismiss {
    font-size: 0.75rem;
    color: #4b4a6a;
    cursor: pointer;
    padding: 10px 0 0;
    transition: color 0.2s;
}
.paywall-dismiss:hover {
    color: #7c7a94;
}

/* ── Paywall mobile ── */
@media (max-width: 480px) {
    .paywall-card {
        margin: 12px;
        padding: 22px 14px 16px;
        max-width: none;
        border-radius: 16px;
    }
    .paywall-close { top: 8px; right: 10px; }
    .paywall-avatar { width: 44px; height: 44px; }
    .paywall-title { font-size: 1rem; }
    .paywall-subtitle { font-size: 0.75rem; }
    .paywall-packs { gap: 6px; }
    .paywall-pack { padding: 10px 4px 8px; border-radius: 10px; }
    .paywall-pack-amount { font-size: 1.1rem; }
    .paywall-pack-label { font-size: 0.6rem; }
    .paywall-pack-price { font-size: 0.8rem; }
    .paywall-pack-badge { font-size: 0.52rem; top: -7px; }
}

/* ═══════════════════════════════════════════════════════════════════
   Pricing Page
   ═══════════════════════════════════════════════════════════════════ */

.pricing-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
}
.pricing-header {
    text-align: center;
    margin-bottom: 48px;
}
.pricing-header h1 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.pricing-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 48px;
}
.pricing-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: center;
    transition: border-color var(--transition), transform var(--transition);
    position: relative;
}
.pricing-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}
.pricing-card.popular {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}
.pricing-card.popular::before {
    content: "Most Popular";
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-gradient);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pricing-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.pricing-price {
    font-size: 2rem;
    font-weight: 700;
    color: #a78bfa;
    margin-bottom: 4px;
}
.pricing-price span {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
}
.pricing-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 20px;
}
.pricing-features {
    list-style: none;
    text-align: left;
    margin-bottom: 24px;
}
.pricing-features li {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.pricing-features li::before {
    content: "\2713 ";
    color: var(--green);
    font-weight: 600;
    margin-right: 6px;
}
.pricing-btn {
    width: 100%;
    padding: 12px;
    font-size: 0.9rem;
}

/* Credit packs section */
.packs-section {
    margin-top: 16px;
}
.packs-section h2 {
    text-align: center;
    color: var(--text-primary);
    font-size: 1.3rem;
    margin-bottom: 24px;
}
.packs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}
.pack-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: border-color var(--transition);
    cursor: pointer;
}
.pack-card:hover {
    border-color: var(--accent);
}
.pack-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: #a78bfa;
    margin-bottom: 4px;
}
.pack-price {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
}
.pack-btn {
    width: 100%;
    padding: 10px;
    font-size: 0.85rem;
}

/* ═══════════════════════════════════════════════════════════════════
   Gift Confirmation Modal
   ═══════════════════════════════════════════════════════════════════ */

/* ── Gift Modal (redesigned) ── */
.gift-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    animation: fadeIn 0.2s ease;
}

.gift-modal-card {
    background: linear-gradient(160deg, #16152e 0%, #1c1a3a 50%, #1a1832 100%);
    border: 1px solid rgba(124, 92, 255, 0.2);
    border-radius: 20px;
    padding: 36px 32px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 60px rgba(124, 92, 255, 0.06);
    animation: modalSlideUp 0.3s ease;
}

/* ══════════════════════════════════════════════════════════════════
   Gift modal v2 — bigger hero, reward chips, prominent CTA.
   Replaces the "just rows of text" layout. Overrides are scoped to
   .gift-modal-v2 so the legacy styles above stay intact for other
   callers of .gift-modal-card (unlock modal, etc.).
   ══════════════════════════════════════════════════════════════════ */
.gift-modal-card.gift-modal-v2 {
    max-width: 400px;
    padding: 28px 24px 24px;
    background:
        radial-gradient(circle at 50% 0%, rgba(251, 191, 36, 0.12) 0%, transparent 40%),
        linear-gradient(165deg, #1a1836 0%, #1f1d44 50%, #1a1836 100%);
    border: 1px solid rgba(124, 92, 255, 0.28);
    border-radius: 22px;
    box-shadow:
        0 28px 72px rgba(0, 0, 0, 0.7),
        0 0 80px rgba(124, 92, 255, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.gift-modal-icon-wrap {
    position: relative;
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gift-modal-v2 .gift-modal-icon {
    font-size: 2.6rem;
    margin: 0;
    filter: drop-shadow(0 6px 16px rgba(251, 191, 36, 0.45));
    position: relative;
    z-index: 2;
    animation: giftFloat 3s ease-in-out infinite;
}

.gift-modal-icon-glow {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.35) 0%, transparent 60%);
    filter: blur(16px);
    animation: giftPulse 2.6s ease-in-out infinite;
    z-index: 1;
}

@keyframes giftFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

@keyframes giftPulse {
    0%, 100% { opacity: 0.55; transform: scale(1);   }
    50%      { opacity: 0.9;  transform: scale(1.12); }
}

.gift-modal-v2 .gift-modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f0eeff;
    margin-bottom: 20px;
    letter-spacing: -0.3px;
}

/* Hero block: gift name + cost pill, stacked & centered. This is the
   visual anchor that tells the user what they're about to do. */
.gift-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    margin-bottom: 18px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
}

.gift-hero-name {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: #fde68a;
    line-height: 1.25;
    letter-spacing: 0.2px;
    text-shadow: 0 0 16px rgba(251, 191, 36, 0.15);
    max-width: 100%;
    word-break: break-word;
}

.gift-cost-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: rgba(251, 191, 36, 0.14);
    border: 1px solid rgba(251, 191, 36, 0.28);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #fde68a;
    letter-spacing: 0.3px;
}

.gift-cost-icon {
    font-size: 0.88rem;
    filter: drop-shadow(0 0 3px rgba(251, 191, 36, 0.6));
}

.gift-cost-tag.gift-cost-free {
    color: #6ee7b7;
    background: rgba(57, 217, 123, 0.14);
    border-color: rgba(57, 217, 123, 0.35);
    letter-spacing: 0.6px;
}

.gift-modal-text {
    color: #9ca3af;
    font-size: 0.88rem;
    margin-bottom: 20px;
    line-height: 1.6;
}

.gift-modal-detail {
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.gift-modal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    color: #e5e7eb;
    font-size: 0.95rem;
}

.gift-modal-row + .gift-modal-row {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.gift-modal-label {
    color: #7c7a94;
    font-size: 0.85rem;
    font-weight: 500;
}

.gift-modal-row .gift-modal-value {
    color: #e5e7eb;
    font-weight: 600;
    font-size: 0.95rem;
}

.gift-modal-effect {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.06) 0%, rgba(124, 92, 255, 0.02) 100%);
    border: 1px solid rgba(124, 92, 255, 0.12);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
}

.gift-modal-effect .gift-modal-label {
    margin-bottom: 10px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #7c7a94;
}

.gift-modal-rewards {
    display: flex;
    justify-content: center;
    gap: 16px;
    color: #c4b5fd;
    font-size: 0.9rem;
    font-weight: 600;
}

.gift-modal-rewards span {
    background: rgba(124, 92, 255, 0.1);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.gift-modal-warning {
    color: #fbbf24;
    font-size: 0.8rem;
    background: rgba(251, 191, 36, 0.06);
    border: 1px solid rgba(251, 191, 36, 0.12);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.gift-modal-actions {
    display: flex;
    gap: 12px;
}

.gift-modal-btn {
    flex: 1;
    padding: 13px 20px;
    font-size: 0.9rem;
    border-radius: 12px;
    cursor: pointer;
    border: none;
    font-weight: 600;
    transition: all 0.2s ease;
    letter-spacing: 0.2px;
}

.gift-modal-btn:hover {
    transform: translateY(-1px);
}

.gift-modal-btn:active {
    transform: scale(0.97);
}

.gift-modal-btn.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: #9ca3af;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.gift-modal-btn.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #d1d5db;
}

.gift-modal-btn.btn-primary {
    background: linear-gradient(135deg, #7c5cff, #a78bfa);
    color: #fff;
    box-shadow: 0 4px 16px rgba(124, 92, 255, 0.3);
}

.gift-modal-btn.btn-primary:hover {
    box-shadow: 0 6px 24px rgba(124, 92, 255, 0.4);
}

/* ── Gift modal v2: effect block, chips, buttons ───────────────── */

.gift-modal-v2 .gift-modal-effect {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.1) 0%, rgba(167, 139, 250, 0.04) 100%);
    border: 1px solid rgba(124, 92, 255, 0.22);
    border-radius: 16px;
    padding: 14px 16px 16px;
    margin-bottom: 16px;
}

.gift-effect-header {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #c4b5fd;
    font-weight: 700;
    margin-bottom: 10px;
    opacity: 0.85;
}

.gift-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.gift-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 11px;
    background: rgba(124, 92, 255, 0.16);
    border: 1px solid rgba(124, 92, 255, 0.32);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #e9e4ff;
    transition: transform 0.15s ease;
}

.gift-chip:hover {
    transform: translateY(-1px);
}

.gift-chip-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.gift-chip-value {
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.2px;
}

.gift-chip-label {
    color: #c4b5fd;
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: lowercase;
}

/* Per-stat accent colors so "trust" and "affection" don't look identical */
.gift-chip-affection         { background: rgba(236, 72, 153, 0.18);  border-color: rgba(236, 72, 153, 0.35); }
.gift-chip-affection .gift-chip-label { color: #fbcfe8; }
.gift-chip-trust             { background: rgba(34, 211, 238, 0.14);  border-color: rgba(34, 211, 238, 0.32); }
.gift-chip-trust .gift-chip-label     { color: #a5f3fc; }
.gift-chip-comfort           { background: rgba(251, 191, 36, 0.14);  border-color: rgba(251, 191, 36, 0.30); }
.gift-chip-comfort .gift-chip-label   { color: #fde68a; }
.gift-chip-respect           { background: rgba(167, 139, 250, 0.16); border-color: rgba(167, 139, 250, 0.32); }
.gift-chip-intimacy_comfort  { background: rgba(244, 114, 182, 0.16); border-color: rgba(244, 114, 182, 0.35); }

.gift-modal-v2 .gift-modal-warning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 12px;
    padding: 11px 14px;
    margin-bottom: 16px;
    color: #fde68a;
    font-size: 0.82rem;
    line-height: 1.45;
    text-align: left;
}

.gift-warning-icon {
    font-size: 1rem;
    line-height: 1.2;
    flex-shrink: 0;
}

/* Buttons — bigger, bolder, clear hierarchy */
.gift-modal-v2 .gift-modal-actions {
    gap: 10px;
    margin-top: 4px;
}

.gift-modal-v2 .gift-modal-btn {
    padding: 14px 18px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 14px;
    letter-spacing: 0.2px;
    border: 1px solid transparent;
}

.gift-btn-cancel {
    flex: 0 0 34%;
    background: rgba(255, 255, 255, 0.05);
    color: #9ca3af;
    border-color: rgba(255, 255, 255, 0.08);
}

.gift-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #d1d5db;
}

.gift-btn-send {
    flex: 1;
    background: linear-gradient(135deg, #7c5cff 0%, #a78bfa 100%);
    color: #fff;
    box-shadow:
        0 6px 20px rgba(124, 92, 255, 0.38),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.gift-btn-send:hover {
    box-shadow:
        0 8px 28px rgba(124, 92, 255, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.gift-btn-icon {
    font-size: 1.05rem;
}

/* ── Focus-visible styles for interactive chip/card elements ────── */
.trait-chip:focus-visible,
.age-chip:focus-visible,
.img-chip:focus-visible,
.prof-chip:focus-visible,
.atmo-card:focus-visible,
.showcase-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── Chat Onboarding ── */
.chat-onboarding-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}
.chat-onboarding-card {
    background: linear-gradient(160deg, #1a1528 0%, #1c1a3a 50%, #0d0b14 100%);
    border: 1px solid rgba(124,92,255,0.2);
    border-radius: 20px;
    padding: 32px 28px;
    max-width: 480px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
}
.onboarding-header {
    text-align: center;
    margin-bottom: 24px;
}
.onboarding-icon { font-size: 2.5rem; margin-bottom: 8px; }
.onboarding-header h2 {
    font-size: 1.2rem;
    color: #e2e0f0;
    font-weight: 600;
}
.onboarding-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 28px;
}
.onboarding-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.step-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 2px;
}
.step-content strong {
    display: block;
    color: #c4b5fd;
    font-size: 0.9rem;
    margin-bottom: 3px;
}
.step-content p {
    color: #9ca3af;
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 0;
}
.onboarding-start-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #7c5cff, #a78bfa);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.onboarding-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124,92,255,0.4);
}
@media (max-width: 480px) {
    .chat-onboarding-card { padding: 20px 16px; border-radius: 16px; }
    .onboarding-header h2 { font-size: 1rem; }
    .step-content strong { font-size: 0.82rem; }
    .step-content p { font-size: 0.75rem; }
}

/* ── Site Footer ── */
.site-footer {
    text-align: center;
    padding: 24px 16px;
    color: #6b7280;
    font-size: 0.78rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    margin-top: 40px;
}
.site-footer a { color: #a78bfa; }
.site-footer .footer-sep { margin: 0 8px; opacity: 0.4; }
.footer-content { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; }

/* ── Scroll-to-bottom button ── */
.scroll-bottom-btn {
    position: fixed; bottom: 80px; right: 20px; z-index: 30;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(124,92,255,0.9); color: white; border: none;
    font-size: 1.2rem; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: opacity 0.2s, transform 0.2s;
}
.scroll-bottom-btn:hover { transform: scale(1.1); }

/* ── Skeleton loading ── */
.char-card.skeleton { animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-img { height: 200px; background: rgba(255,255,255,0.05); border-radius: 12px; }
.skeleton-text { height: 20px; margin-top: 12px; background: rgba(255,255,255,0.05); border-radius: 6px; width: 60%; }
@keyframes skeleton-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.8; } }

/* ── Gallery tab empty state ── */
.tab-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    text-align: center;
    color: #6b7280;
}
.tab-empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.6; }
.tab-empty-title { font-size: 1.1rem; font-weight: 600; color: #9ca3af; margin-bottom: 6px; }
.tab-empty-desc { font-size: 0.85rem; margin-bottom: 16px; }

/* ── Cookie Consent Banner ── */
.cookie-banner {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: rgba(26, 21, 40, 0.95); backdrop-filter: blur(10px);
    border-top: 1px solid rgba(124,92,255,0.2);
    padding: 16px 24px; display: flex; align-items: center;
    justify-content: center; gap: 16px; flex-wrap: wrap;
}
.cookie-text { color: #9ca3af; font-size: 0.85rem; max-width: 600px; }
.cookie-accept {
    background: linear-gradient(135deg, #7c5cff, #a78bfa); color: white;
    border: none; padding: 8px 24px; border-radius: 8px; cursor: pointer;
    font-weight: 600; font-size: 0.85rem; white-space: nowrap;
}
.cookie-accept:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(124,92,255,0.4); }

/* ── Delete Account Button ── */
.nav-delete-account-btn {
    background: transparent; color: #ef4444; border: 1px solid rgba(239,68,68,0.3);
    padding: 6px 12px; border-radius: 8px; cursor: pointer;
    font-size: 0.75rem; font-weight: 500; transition: all 0.2s;
}
.nav-delete-account-btn:hover {
    background: rgba(239,68,68,0.1); border-color: #ef4444;
}

/* ── Mobile nav fixes ── */
@media (max-width: 600px) {
    .top-nav { padding: 0 12px; height: 50px; }
    .nav-right { gap: 8px; }
    .nav-user-info span { display: none; }
    .nav-user-avatar { width: 28px; height: 28px; }
    .nav-logout-btn { padding: 4px 8px; font-size: 0.7rem; }
    .nav-delete-account-btn { padding: 4px 8px; font-size: 0.65rem; }
    .brand-name { font-size: 1rem; }
    .nav-credits { padding: 4px 8px; font-size: 0.8rem; }
}

/* ── Mobile chat header fix ── */
@media (max-width: 600px) {
    /* ── Compact mobile header ──
     * No padding-bottom on the wrapping flex container: the
     * rel-center row (wrapped as last child) handles its own
     * bottom spacing via its internal padding. Previously parent
     * padding-bottom added ~10px of empty space BELOW the rel row
     * that visually belonged to the rel section — making content
     * look stuck to the top of its container. */
    .chat-header-top {
        display: flex !important;
        flex-wrap: wrap;
        padding: 10px 10px 0;
        gap: 0 8px;
        row-gap: 8px;
        align-items: center;
    }
    /* Row 1: ← avatar name+location  💬 ⚡credits */
    .chat-back { font-size: 1.2rem; padding: 2px 4px; flex-shrink: 0; }
    .chat-avatar { width: 32px; height: 32px; flex-shrink: 0; }
    .chat-header-info { flex: 1; min-width: 0; }
    .chat-header-text { min-width: 0; gap: 0; }
    .chat-char-name {
        font-size: 0.85rem;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .chat-char-status { font-size: 0.62rem; }
    .chat-feedback-btn {
        width: 28px; height: 28px;
        font-size: 0.85rem;
        flex-shrink: 0;
    }
    .nav-credits {
        font-size: 0.72rem;
        padding: 2px 8px;
        flex-shrink: 0;
    }
    /* Row 2: relationship bar — full width, compact.
     * Internal padding is symmetric (6px top = 6px bottom) so the
     * progress bar and level text sit vertically centered in the
     * row rather than hugging the separator above. Overall row height
     * stays modest; clearance from the avatar glow is handled by
     * `row-gap` on the parent, not by padding here. */
    .chat-header-rel-center {
        position: relative !important;
        transform: none !important;
        left: auto !important;
        width: 100%;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        /* Symmetric padding is enough now that the parent's
         * padding-bottom doesn't leak below this row. Content is
         * truly centered between the separator above and the next
         * section below. */
        padding: 8px 10px;
        border-top: 1px solid rgba(255,255,255,0.04);
        order: 10;
    }
    .chat-rel-name { font-size: 0.72rem; white-space: nowrap; }
    .chat-rel-progress {
        font-size: 0.58rem;
        padding: 0 6px;
        white-space: nowrap;
    }
    .chat-rel-bar-wrap {
        flex: 1; max-width: none; width: auto;
        height: 3px;
    }
    /* Tabs */
    .chat-header-tabs { padding: 0 10px; }
    .chat-tab { font-size: 0.72rem; padding: 5px 0; }
}

/* ── Preset cards & randomize mobile ── */
@media (max-width: 480px) {
    .ai-describe-btn { padding: 10px 24px; font-size: 0.85rem; }
    .randomize-btn { padding: 6px 12px; font-size: 0.8rem; }
}

/* ═══════════════════════════════════════════════════════════════════
 * Experimental: Visual FX (enabled per-device with ?exp=visualfx)
 * ═══════════════════════════════════════════════════════════════════
 * Adds cinematic motion to generated images without touching the GPU:
 *  - Ken Burns slow zoom+pan (only while image is on-screen, driven by
 *    IntersectionObserver — pauses off-screen images to avoid GPU
 *    layer thrash on mobile scroll)
 *  - Subtle "breathing" on header avatar
 *  - Lightbox mousemove parallax (driven by JS)
 *
 * Removed:
 *  - Film grain overlay (Safari mix-blend-mode bug made underlying
 *    images disappear intermittently)
 *  - `will-change: transform` hints (they created too many GPU layers
 *    and caused scroll freezes when new images entered viewport)
 *
 * Gate: html.fx-enabled (set from JS on load if flag is on).
 * Ken Burns only animates on images that also have `.fx-on` class —
 * JS adds/removes this class via IntersectionObserver.
 */

/* Ken Burns on scene/inline images.
 *
 * We animate a WRAPPER (.fx-kb-wrap) instead of the <img> directly —
 * iOS Safari has a long-standing quirk where CSS animations applied
 * to replaced elements (img/video) can cause them to become invisible
 * during layer compositing. Animating the wrapper sidesteps this.
 *
 * Gate: html.fx-enabled + .fx-on (added by JS on first visibility). */
html.fx-enabled .fx-kb-wrap.fx-on {
    animation: fxKenBurns var(--kb-duration, 24s) ease-in-out infinite alternate;
    transform-origin: center center;
    display: block;
}
html.fx-enabled .fx-kb-wrap {
    display: block;
}
@keyframes fxKenBurns {
    from { transform: scale(1) translate(0, 0); }
    to   { transform: scale(var(--kb-scale, 1.06)) translate(var(--kb-xe, 1%), var(--kb-ye, -1%)); }
}

/* Lightbox image: clean static view, no motion. */
html.fx-enabled #lightboxImg {
    animation: none !important;
}

/* Header avatar — breathing + presence/mood ring.
 * Ring and glow are smaller / tighter than the first pass because the
 * avatar sits near the top of the viewport and oversized effects were
 * clipping against the page edges. */
html.fx-enabled .chat-avatar {
    animation: fxBreathe 4.8s ease-in-out infinite;
    transform-origin: center center;
    box-shadow:
        0 0 0 2px var(--presence-ring, rgba(124, 92, 255, 0.55)),
        0 0 8px 1px var(--mood-glow, rgba(167, 139, 250, 0.3));
    transition: box-shadow 0.8s ease, filter 0.8s ease;
    position: relative;
}
@keyframes fxBreathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.018); }
}

/* Available presence pulse — reduced peak scale so it fits within
 * header without clipping at viewport edges. Previously scale 1.35;
 * now 1.18 with inset -2px instead of -4px. */
html.fx-enabled .chat-avatar.presence-available::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 2px solid var(--presence-ring, rgba(34, 197, 94, 0.9));
    opacity: 0;
    animation: fxPresencePulse 2.8s ease-out infinite;
    pointer-events: none;
}

@keyframes fxPresencePulse {
    0%   { transform: scale(1);    opacity: 0.55; }
    70%  { transform: scale(1.18); opacity: 0; }
    100% { transform: scale(1.18); opacity: 0; }
}

/* Sleeping: dim the avatar so it reads as "away". */
html.fx-enabled .chat-avatar.presence-sleeping {
    filter: brightness(0.72) saturate(0.75);
}
/* Busy: no pulse, just the ring color (already set by --presence-ring). */

/* Presence pulse pauses when user prefers reduced motion. */
@media (prefers-reduced-motion: reduce) {
    html.fx-enabled .chat-avatar.presence-available::after {
        animation: none !important;
        opacity: 0 !important;
    }
}

/* Typing indicator → bubble morph transition.
 * When hiding the typing indicator (JS adds .fx-morphing-out), scale
 * up slightly and fade out. Overlapping with the new bubble's fade-in
 * creates a "dots dissolve into bubble" visual feel. */
html.fx-enabled .chat-typing.fx-morphing-out {
    animation: fxTypingMorphOut 240ms ease-out forwards;
    transform-origin: left center;
    pointer-events: none;
}
@keyframes fxTypingMorphOut {
    0%   { opacity: 1; transform: scale(1);    filter: blur(0); }
    60%  { opacity: 0.4; transform: scale(1.06); filter: blur(1px); }
    100% { opacity: 0; transform: scale(1.12); filter: blur(3px); }
}

/* Character bubble entrance — fades + scales up from below so it
 * naturally flows from where the typing dots were.
 * Only applied to LIVE messages (.msg-fresh added by JS), not to
 * historical messages loaded from chat history. */
html.fx-enabled .msg-character.msg-fresh {
    animation: fxBubbleIn 340ms cubic-bezier(0.2, 0.9, 0.3, 1.15);
    transform-origin: bottom left;
}
@keyframes fxBubbleIn {
    0%   { opacity: 0; transform: translateY(6px) scale(0.92); }
    60%  { opacity: 1;                                         }
    100% { opacity: 1; transform: translateY(0)    scale(1);   }
}

/* Disable all of the above for users who prefer reduced motion —
 * accessibility + respects OS-level settings. */
@media (prefers-reduced-motion: reduce) {
    html.fx-enabled .msg-inline-image img,
    html.fx-enabled .msg-scene-shot-slot img,
    html.fx-enabled .auto-image-container img,
    html.fx-enabled .narrator-image-card img,
    html.fx-enabled .chat-avatar,
    html.fx-enabled .msg-character.msg-fresh,
    html.fx-enabled .chat-typing.fx-morphing-out {
        animation: none !important;
        transform: none !important;
    }
}
