/* ── Reset & Base ──────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Global themed scrollbar ── */
* { scrollbar-width: thin; scrollbar-color: rgba(168, 85, 247, 0.3) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(168, 85, 247, 0.3); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(168, 85, 247, 0.5); }

:root {
    /* ── Tier 1: Primary — main CTAs only ── */
    --primary: #A855F7;
    --primary-dark: #7C3AED;
    --primary-rgb: 168, 85, 247;

    /* ── Tier 2: Accent — secondary actions ── */
    --accent: #E879A8;
    --accent-rgb: 232, 121, 168;
    --accent-soft: rgba(232, 121, 168, 0.12);

    /* ── Tier 3: Muted — tertiary, labels, metadata ── */
    --muted: #6E6888;
    --muted-soft: rgba(110, 104, 136, 0.15);

    /* ── Tier 4: Surface — containers, backgrounds ── */
    --bg: #0D0A1A;
    --surface: rgba(22, 17, 40, 0.65);
    --surface-solid: #16112A;
    --surface2: #1E1838;

    /* ── Text ── */
    --text: #E8E6F0;
    --text-dim: #8B85A8;

    /* ── Semantic ── */
    --danger: #FF6B6B;
    --success: #4ECB71;

    /* ── Shared ── */
    --radius: 16px;
    --radius-lg: 24px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --gradient-primary: linear-gradient(135deg, var(--primary), var(--accent));
    --gradient-accent: linear-gradient(135deg, var(--accent), var(--primary));
    --border-subtle: 1px solid rgba(255,255,255,0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ── Utility ────────────────────────────────────────────────── */
.text-gradient {
    background: linear-gradient(135deg, #E879A8, #A855F7, #E879A8);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 4s ease infinite;
}
.glass {
    background: rgba(22, 17, 40, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: var(--border-subtle);
}
.hidden { display: none !important; }

@keyframes shimmer {
    0%, 100% { background-position: 0% center; }
    50%      { background-position: 200% center; }
}

/* ── Floating Orbs ──────────────────────────────────────────── */
.orbs {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0;
    will-change: transform, opacity;
    animation-fill-mode: both;
}
.orb-1 {
    width: 320px; height: 320px;
    background: radial-gradient(circle, #7C3AED 0%, rgba(124,58,237,0.3) 40%, transparent 70%);
    top: -100px; right: -60px;
    animation: orbFloat1 16s ease-in-out infinite, orbFadeIn 2s 0.3s ease both;
}
.orb-2 {
    width: 260px; height: 260px;
    background: radial-gradient(circle, #E879A8 0%, rgba(232,121,168,0.25) 40%, transparent 70%);
    bottom: 15%; left: -80px;
    animation: orbFloat2 20s ease-in-out infinite, orbFadeIn 2s 0.6s ease both;
}
.orb-3 {
    width: 200px; height: 200px;
    background: radial-gradient(circle, #A855F7 0%, rgba(168,85,247,0.2) 40%, transparent 70%);
    top: 45%; right: 5%;
    animation: orbFloat3 24s ease-in-out infinite, orbFadeIn 2s 0.9s ease both;
}
@keyframes orbFadeIn {
    from { opacity: 0; }
    to   { opacity: 0.2; }
}
@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(-25px, 35px) scale(1.05); }
    66%      { transform: translate(15px, -20px) scale(0.97); }
}
@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(35px, -20px) scale(0.95); }
    66%      { transform: translate(-15px, 30px) scale(1.03); }
}
@keyframes orbFloat3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(-20px, -30px) scale(1.06); }
    66%      { transform: translate(25px, 15px) scale(0.96); }
}

/* ── Floating Sparkles ─────────────────────────────────────── */
.sparkles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.sparkle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    will-change: transform, opacity;
}
/* Clean crisp dots — no blur, smooth sine-wave drift */
.sparkle.s1 { width: 4px; height: 4px; background: #c4a0f7; left: 8%;  animation: sparkleRise1 10s ease-in-out infinite; }
.sparkle.s2 { width: 6px; height: 6px; background: #e8a0c0; left: 28%; animation: sparkleRise2 13s 1.5s ease-in-out infinite; }
.sparkle.s3 { width: 4px; height: 4px; background: rgba(255,255,255,0.5); left: 48%; animation: sparkleRise1 9s 3s ease-in-out infinite; }
.sparkle.s4 { width: 6px; height: 6px; background: #c4a0f7; left: 68%; animation: sparkleRise2 11s 0.5s ease-in-out infinite; }
.sparkle.s5 { width: 4px; height: 4px; background: #e8a0c0; left: 18%; animation: sparkleRise1 14s 2s ease-in-out infinite; }
.sparkle.s6 { width: 4px; height: 4px; background: rgba(255,255,255,0.4); left: 85%; animation: sparkleRise2 12s 4s ease-in-out infinite; }

@keyframes sparkleRise1 {
    0%   { transform: translateY(90vh) translateX(0); opacity: 0; }
    8%   { opacity: 0.6; }
    50%  { transform: translateY(40vh) translateX(12px); opacity: 0.25; }
    92%  { opacity: 0.5; }
    100% { transform: translateY(-5vh) translateX(-4px); opacity: 0; }
}
@keyframes sparkleRise2 {
    0%   { transform: translateY(90vh) translateX(0); opacity: 0; }
    8%   { opacity: 0.5; }
    50%  { transform: translateY(40vh) translateX(-10px); opacity: 0.2; }
    92%  { opacity: 0.45; }
    100% { transform: translateY(-5vh) translateX(6px); opacity: 0; }
}

/* ── Aurora sweep (login + home) ──────────────────────────── */
.aurora {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.aurora::before {
    content: '';
    position: absolute;
    width: 150%;
    height: 100%;
    top: 0;
    left: -25%;
    background: radial-gradient(
        ellipse 80% 50% at 30% 50%,
        rgba(168,85,247,0.06) 0%,
        transparent 50%
    ),
    radial-gradient(
        ellipse 70% 40% at 70% 60%,
        rgba(232,121,168,0.05) 0%,
        transparent 50%
    );
    animation: auroraSweep 25s ease-in-out infinite;
    transform-origin: center;
}
@keyframes auroraSweep {
    0%   { transform: translateX(-10%) scale(1); opacity: 0.6; }
    33%  { transform: translateX(5%) scale(1.05); opacity: 1; }
    66%  { transform: translateX(10%) scale(0.98); opacity: 0.7; }
    100% { transform: translateX(-10%) scale(1); opacity: 0.6; }
}

/* ── Entrance Animations ───────────────────────────────────── */
.anim-fade-up {
    animation: animFadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.anim-d2 { animation-delay: 0.15s; }
.anim-d3 { animation-delay: 0.3s; }
.anim-d4 { animation-delay: 0.45s; }
@keyframes animFadeUp {
    from { opacity: 0; transform: translateY(28px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ───────────────────────────────────────────────── */
.app-header {
    background: rgba(13, 10, 26, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header.hidden { display: none; }
.app-header h1 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    cursor: pointer;
}
.header-back {
    position: absolute;
    left: 12px;
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.header-back:hover {
    background: rgba(232, 121, 168, 0.1);
}

/* ── User Menu (header avatar) ────────────────────────────── */
.user-menu {
    position: absolute;
    right: 12px;
    display: flex;
    align-items: center;
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(168, 85, 247, 0.4);
    transition: border-color 0.2s, box-shadow 0.2s;
    object-fit: cover;
}
.user-avatar:hover {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
}

/* ── Account Dropdown ─────────────────────────────────────── */
.account-dropdown {
    position: fixed;
    width: 240px;
    background: var(--surface-solid);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 200;
    padding: 16px;
    animation: dropdownSlide 0.2s ease;
}
@keyframes dropdownSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.account-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}
.account-avatar-lg {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(168, 85, 247, 0.3);
    object-fit: cover;
    margin-bottom: 4px;
}
.account-info strong {
    font-size: 0.95rem;
    color: var(--text);
}
.account-info small {
    font-size: 0.75rem;
    color: var(--text-dim);
}
.account-dropdown hr {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin: 12px 0;
}
.account-action {
    width: 100%;
    background: none;
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}
.account-action:hover {
    background: rgba(255,255,255,0.05);
}
.account-action + .account-action {
    margin-top: 6px;
}
.account-upgrade {
    background: var(--accent-soft);
    border-color: rgba(232, 121, 168, 0.2);
    color: var(--accent);
    font-weight: 600;
}
.account-upgrade:hover {
    background: rgba(232, 121, 168, 0.2);
}

/* ── Login Screen ─────────────────────────────────────────── */
#screen-login {
    position: relative;
    overflow: hidden;
    max-width: 100%;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
}
.login-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px 24px;
    text-align: center;
    gap: 28px;
    position: relative;
    z-index: 1;
}
.app-icon {
    margin-bottom: 16px;
    animation: loginFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.app-icon svg {
    filter: drop-shadow(0 0 16px rgba(168, 85, 247, 0.35));
    animation: iconBreath 4s ease-in-out infinite;
}
@keyframes iconBreath {
    0%, 100% { filter: drop-shadow(0 0 12px rgba(168,85,247,0.25)); transform: scale(1); }
    50%      { filter: drop-shadow(0 0 24px rgba(168,85,247,0.5)); transform: scale(1.04); }
}
.login-title {
    font-size: 3.2rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1;
    animation: loginTitleIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes loginTitleIn {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.login-tagline {
    color: var(--text-dim);
    font-size: 1.1rem;
    font-weight: 400;
    margin-top: -12px;
    animation: loginFadeIn 0.8s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.login-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 4px;
    animation: loginFadeIn 0.8s 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.login-pill {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: var(--muted-soft);
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.06);
}
@keyframes loginFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.btn-google {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    color: #3c4043;
    border: none;
    border-radius: 24px;
    padding: 14px 32px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    transition: box-shadow 0.25s, transform 0.2s;
    animation: loginBtnIn 0.8s 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes loginBtnIn {
    from { opacity: 0; transform: translateY(16px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.btn-google:hover {
    box-shadow: 0 6px 24px rgba(168, 85, 247, 0.2), 0 2px 8px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}
.btn-google:active {
    transform: translateY(0) scale(0.97);
    transition-duration: 0.08s;
}
.btn-google svg {
    flex-shrink: 0;
}

/* ── Screens ──────────────────────────────────────────────── */
.screen { display: none; padding: 20px; max-width: 600px; margin: 0 auto; position: relative; }
.screen.active { display: block; animation: animFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
#screen-view, #screen-building { padding-bottom: 110px; }
.screen-header { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.screen-header h2 { font-size: 1.2rem; flex: 1; font-weight: 700; letter-spacing: -0.01em; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    touch-action: manipulation;
}
.btn:active { transform: scale(0.95); transition-duration: 0.08s; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.3);
    position: relative;
}
.btn-primary:hover {
    box-shadow: 0 8px 28px rgba(168, 85, 247, 0.45);
    transform: translateY(-2px);
}
.btn-primary:active {
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.3);
}
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-large { width: 100%; padding: 16px; font-size: 1.1rem; }
.btn-back {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s;
    white-space: nowrap;
}
.btn-back:hover {
    background: rgba(232, 121, 168, 0.1);
}
.word-counter {
    display: block;
    font-size: 0.72rem;
    color: var(--text-dim);
    text-align: right;
    margin-top: 6px;
    min-height: 1em;
    transition: color 0.2s;
}
.word-counter.under { color: var(--primary); }
.word-counter.over  { color: var(--danger); }
.word-counter.ok    { color: var(--text-dim); }

.btn-row { display: flex; gap: 12px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

.btn-mic {
    background: var(--surface2);
    border: 2px solid var(--accent);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
}
.btn-mic:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: var(--accent);
    transform: scale(1.05);
}
.btn-mic:active {
    background: var(--primary);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.5);
    transform: scale(0.92);
    transition-duration: 0.08s;
}

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 40px 0 28px;
    position: relative;
    z-index: 1;
}

/* Animated book icon */
.hero-icon-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
}
.hero-icon {
    width: 80px;
    height: 80px;
    border-radius: 28px;
    background: linear-gradient(135deg, #C084FC, #E879A8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow:
        0 8px 32px rgba(192, 132, 252, 0.4),
        0 0 60px rgba(232, 121, 168, 0.2);
    animation: heroFloat 4s ease-in-out infinite;
}
@keyframes heroFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}
.hero-sparkle {
    position: absolute;
    font-size: 1rem;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    pointer-events: none;
}
.hero-sparkle-1 {
    top: -4px; right: -6px;
    color: #E879A8;
    animation: sparkleSpin 8s linear infinite;
}
.hero-sparkle-2 {
    bottom: -4px; left: -6px;
    color: #C084FC;
    animation: sparklePulse 2s ease-in-out infinite;
}
@keyframes sparkleSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@keyframes sparklePulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50%      { transform: scale(1.4); opacity: 1; }
}

/* Hero title entrance */
.hero .welcome-text {
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}
.hero .welcome-text .home-app-icon {
    margin-right: 10px;
}
.home-app-icon {
    flex-shrink: 0;
    color: var(--primary);
    filter: drop-shadow(0 0 8px rgba(var(--primary-rgb), 0.3));
}
.hero-sub {
    color: var(--text-dim);
    margin-bottom: 28px;
    font-size: 0.88rem;
    line-height: 1;
    white-space: nowrap;
}
.hero-buttons {
    display: flex;
    gap: 12px;
}
.hero-buttons .btn { flex: 1; }

/* Glass surprise button */
.btn-glass {
    background: rgba(22, 17, 40, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(232, 121, 168, 0.15);
    color: var(--accent);
    font-weight: 700;
    box-shadow: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-glass:hover {
    border-color: rgba(232, 121, 168, 0.4);
    box-shadow: 0 6px 24px rgba(232, 121, 168, 0.12);
    transform: translateY(-2px);
    color: #f0a0c0;
}
.btn-glass:active {
    box-shadow: none;
}

/* New Story button — solid primary with breathing glow */
.btn-new-story {
    background: rgba(var(--primary-rgb), 0.75);
    color: #fff;
    border: 1px solid rgba(var(--primary-rgb), 0.3);
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.2);
    animation: btnBreathGlow 4s ease-in-out infinite;
}
@keyframes btnBreathGlow {
    0%, 100% { box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.18); }
    50%      { box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.3); }
}
.btn-new-story:hover {
    background: rgba(var(--primary-rgb), 0.9);
    box-shadow: 0 6px 24px rgba(var(--primary-rgb), 0.35);
    transform: translateY(-2px);
    animation: none;
}
.btn-new-story:active {
    box-shadow: 0 2px 10px rgba(var(--primary-rgb), 0.2);
}

/* Section header */
.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.section-title {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}
.section-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    background: var(--muted-soft);
    padding: 2px 10px;
    border-radius: 20px;
}

.limit-badge {
    display: inline-block;
    margin-top: 14px;
    font-size: 0.82rem;
    color: var(--muted);
    background: var(--muted-soft);
    padding: 4px 14px;
    border-radius: 20px;
}

/* ── Stories List ─────────────────────────────────────────── */
.stories-list { display: flex; flex-direction: column; gap: 12px; }

.story-card {
    background: rgba(22, 17, 40, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius);
    overflow: visible;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255,255,255,0.06);
    position: relative;
    z-index: 1;
    animation: cardSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
/* Stagger card entrance */
.story-card:nth-child(1)  { animation-delay: 0.05s; }
.story-card:nth-child(2)  { animation-delay: 0.10s; }
.story-card:nth-child(3)  { animation-delay: 0.15s; }
.story-card:nth-child(4)  { animation-delay: 0.20s; }
.story-card:nth-child(5)  { animation-delay: 0.25s; }
@keyframes cardSlideIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.story-card:hover {
    border-color: rgba(168, 85, 247, 0.2);
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25), 0 0 20px rgba(168, 85, 247, 0.06);
}
.story-card:active {
    transform: translateY(-1px) scale(0.99);
    transition-duration: 0.08s;
}
.story-card.menu-open {
    z-index: 100;
}
.story-card-body {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    cursor: pointer;
}

/* Book icon thumbnail */
.card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--muted-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.4rem;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s;
}
.story-card:hover .card-icon {
    transform: scale(1.08) rotate(-3deg);
    background: var(--accent-soft);
}
.card-info {
    flex: 1;
    min-width: 0;
}
.card-info h3 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-params {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}
.card-param {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--muted-soft);
    border: 1px solid rgba(110, 104, 136, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: capitalize;
}
.story-card .meta {
    display: flex;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-dim);
    align-items: center;
}
.story-card .meta .meta-dot { opacity: 0.4; }

/* Right side: extend button + overflow */
.card-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.card-extend-btn {
    background: var(--accent-soft);
    border: 1px solid rgba(232, 121, 168, 0.2);
    color: var(--accent);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    font-family: inherit;
}
.card-extend-btn:hover {
    background: rgba(232, 121, 168, 0.2);
    border-color: var(--accent);
    box-shadow: 0 2px 10px rgba(232, 121, 168, 0.2);
}
/* Read aloud button on story cards — accent tier */
.card-read-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--accent-soft);
    border: 1px solid rgba(232, 121, 168, 0.2);
    color: var(--accent);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    font-family: inherit;
}
.card-read-btn:hover {
    background: rgba(232, 121, 168, 0.2);
    border-color: var(--accent);
    box-shadow: 0 2px 10px rgba(232, 121, 168, 0.2);
}
.card-extend-disabled {
    background: rgba(139, 133, 168, 0.08);
    border-color: rgba(139, 133, 168, 0.15);
    color: var(--text-dim);
    opacity: 0.5;
    cursor: not-allowed;
}
.card-extend-disabled:hover {
    background: rgba(139, 133, 168, 0.08);
    border-color: rgba(139, 133, 168, 0.15);
    box-shadow: none;
}

/* EPIC golden pill */
.card-epic-pill {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 50%, #f6d365 100%);
    background-size: 200% 200%;
    animation: epicShimmer 3s ease infinite;
    border: 1px solid rgba(218, 165, 32, 0.5);
    color: #5a3e00;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    white-space: nowrap;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(218, 165, 32, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

@keyframes epicShimmer {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Overflow (three-dot) button */
.card-overflow-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.card-overflow-btn:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text);
}

/* Overflow dropdown menu */
.card-overflow-menu {
    position: absolute;
    top: 100%;
    right: 12px;
    margin-top: 4px;
    background: var(--surface-solid);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 4px;
    min-width: 140px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 50;
    animation: menuSlideDown 0.15s ease;
}
.card-overflow-menu.menu-above {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
    animation: menuSlideUp 0.15s ease;
}
@keyframes menuSlideUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes menuSlideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.overflow-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
    font-family: inherit;
}
.overflow-item:hover {
    background: rgba(255,255,255,0.06);
}
.overflow-item-danger {
    color: var(--danger);
}
.overflow-item-danger:hover {
    background: rgba(255, 107, 107, 0.1);
}
.overflow-item-disabled {
    color: var(--text-dim);
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Empty state (glass dashed box) */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-dim);
    border-radius: var(--radius);
    border: 2px dashed rgba(255,255,255,0.08);
    background: rgba(22, 17, 40, 0.3);
}
.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 12px;
    animation: heroFloat 4s ease-in-out infinite;
}

/* ── Wizard ───────────────────────────────────────────────── */
.wizard-step { display: none; }
.wizard-step.active { display: block; animation: fadeIn 0.3s; }

.wizard-step label {
    display: block;
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.wizard-step .hint {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* ── Inputs ───────────────────────────────────────────────── */
.input-group {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 16px;
}
.input-group input,
.input-group textarea {
    flex: 1;
    background: rgba(22, 17, 40, 0.6);
    border: 1.5px solid rgba(255,255,255,0.08);
    border-radius: var(--radius);
    padding: 14px;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    overflow-y: hidden;
    max-height: calc(1.5em * 20 + 28px); /* 20 lines + padding */
    transition: border-color 0.25s, box-shadow 0.25s, height 0.15s ease;
}
.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.12);
}

/* ── Create Story Progress Dots ──────────────────────────── */
.create-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 24px;
    padding: 16px 0;
}
.progress-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
}
.dot-inner {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--surface2);
    border: 2px solid rgba(255,255,255,0.1);
    transition: all 0.3s cubic-bezier(.4,0,.2,1);
}
.progress-dot.active .dot-inner {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
}
.progress-dot.done .dot-inner {
    background: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 8px rgba(78, 203, 113, 0.4);
}
.dot-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    transition: color 0.3s;
}
.progress-dot.active .dot-label { color: var(--primary); }
.progress-dot.done .dot-label { color: var(--success); }
.progress-line {
    width: 40px;
    height: 2px;
    background: rgba(255,255,255,0.08);
    margin: 0 8px;
    margin-bottom: 18px;
    border-radius: 1px;
    position: relative;
    overflow: hidden;
    align-self: flex-start;
    margin-top: 5px;
}
.progress-line.filled {
    background: var(--primary);
}

/* Create section labels */
.create-label {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}
.create-hint {
    color: var(--text-dim);
    font-size: 0.88rem;
    margin-bottom: 14px;
    line-height: 1.5;
}
.create-section { margin-bottom: 8px; }
.idea-counter {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-align: right;
    margin-top: 6px;
    color: var(--muted);
    transition: color 0.2s;
}
.idea-counter.under { color: var(--accent); }
.idea-counter.over  { color: var(--danger); }

/* Glass input group */
.input-group-glass {
    background: rgba(22, 17, 40, 0.45);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--border-subtle);
    border-radius: var(--radius);
    padding: 4px;
    position: relative;
}
.input-group-glass textarea,
.input-group-glass input {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 12px !important;
}
.input-group-glass textarea:focus,
.input-group-glass input:focus {
    outline: none;
    border: none !important;
    box-shadow: none !important;
}
.input-group-glass:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.12);
}
/* ── Input Row (textarea + mic side by side) ──────────────── */
.input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.input-row .input-group { flex: 1; }
.input-row .btn-mic {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}
.btn-mic:hover svg { stroke: var(--text); }

/* Create button */
.btn-create {
    margin-top: 8px;
    border-radius: var(--radius-lg);
    font-size: 1.1rem;
    letter-spacing: 0.01em;
    animation: btnBreathGlow 3s ease-in-out infinite;
}
.btn-create:hover {
    animation: none;
}

/* Conclude button glass style */
.btn-conclude {
    color: var(--text-dim);
    font-weight: 600;
}
.btn-conclude:hover {
    color: var(--text);
}

/* ── Mode Selectors ─────────────────────────────────────── */
.mode-selectors {
    margin-bottom: 20px;
}
.mode-group {
    margin-bottom: 12px;
}
.mode-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.mode-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.mode-chip {
    background: rgba(22, 17, 40, 0.5);
    border: 1.5px solid rgba(255,255,255,0.08);
    color: var(--text-dim);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
    white-space: nowrap;
}
.mode-chip:hover {
    border-color: rgba(168, 85, 247, 0.3);
    color: var(--text);
    background: rgba(168, 85, 247, 0.08);
    transform: translateY(-1px);
}
.mode-chip:active {
    transform: scale(0.95);
    transition-duration: 0.08s;
}
.mode-chip.selected {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
    box-shadow: 0 3px 14px rgba(168, 85, 247, 0.35);
}
.mode-chip.chip-bounce {
    animation: chipPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes chipPop {
    0%   { transform: scale(0.9); }
    60%  { transform: scale(1.1); }
    100% { transform: scale(1); }
}
.btn-create.surprise-pulse {
    animation: surprisePulse 0.6s ease;
}
@keyframes surprisePulse {
    0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.5); }
    50%  { transform: scale(1.06); box-shadow: 0 0 20px 8px rgba(168, 85, 247, 0.3); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); }
}

/* ── Round Progress (Building Screen) ────────────────────── */
.round-progress {
    background: rgba(22, 17, 40, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 14px 20px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.round-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}
.round-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--surface2);
    border: 2px solid rgba(255,255,255,0.08);
    transition: all 0.3s;
}
.round-dot.done {
    background: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 6px rgba(78, 203, 113, 0.4);
}
.round-dot.current {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(232, 121, 168, 0.5);
    animation: dotPulse 1.5s ease-in-out infinite;
}
@keyframes dotPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}
.round-dot.warning { background: #FFA726; border-color: #FFA726; box-shadow: 0 0 6px rgba(255,167,38,0.4); }
.round-dot.final { background: var(--danger); border-color: var(--danger); box-shadow: 0 0 6px rgba(255,107,107,0.4); }
.round-dot-inf {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-left: 2px;
    letter-spacing: 1px;
}
.round-label {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--accent);
    white-space: nowrap;
}
.round-hint {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-left: auto;
    text-align: right;
}
.round-progress.warning .round-label { color: #FFA726; }
.round-progress.final .round-label { color: var(--danger); }


/* ── Story Content ────────────────────────────────────────── */
.story-content {
    background: rgba(22, 17, 40, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--border-subtle);
    border-radius: var(--radius);
    padding: 20px;
    line-height: 1.75;
    font-size: 1.05rem;
    margin-bottom: 24px;
    white-space: pre-wrap;
}
.story-content .part {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--surface2);
}
.story-content .part:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.story-content .part.extension { border-left: 3px solid var(--accent); padding-left: 16px; }
.story-content .new-part { animation: fadeIn 0.5s; }

/* ── Floating Audio FAB ──────────────────────────────────── */
/* ── Persistent Bottom Audio Player ───────────────────────── */
.audio-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    background: rgba(14, 10, 28, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(168, 85, 247, 0.2);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
    padding: 0 0 env(safe-area-inset-bottom, 0);
    transition: transform 0.35s cubic-bezier(.4,0,.2,1), opacity 0.35s;
}
.audio-player.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

/* Seek bar wrapper — sits at top edge of player */
.ap-seek-wrap {
    padding: 0 16px;
    position: relative;
    top: -4px;
}
.ap-seek-bar {
    position: relative;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    cursor: pointer;
}
.ap-seek-fill {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
    pointer-events: none;
}
/* Range input overlaid on seek bar */
.ap-seek-input {
    position: absolute;
    top: -6px; left: 0;
    width: 100%;
    height: 18px;
    opacity: 0;
    cursor: pointer;
    margin: 0;
    -webkit-appearance: none;
}
/* Chapter markers on seek bar */
.ap-chapter-markers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.ap-marker {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 10px;
    background: rgba(255,255,255,0.4);
    border-radius: 1px;
    transform: translateX(-1px);
}

/* Controls row */
.ap-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px 10px;
    justify-content: center;
}
.ap-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    transition: all 0.2s;
    flex-shrink: 0;
}
.ap-play {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 12px rgba(168, 85, 247, 0.35);
}
.ap-play:hover { transform: scale(1.08); box-shadow: 0 4px 18px rgba(168, 85, 247, 0.5); }
.ap-play:active { transform: scale(0.95); }
/* ap-info and ap-info-right balance the play button in center */
.ap-info-right { flex: 1; }

/* Info section */
.ap-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.ap-chapter-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ap-time {
    font-size: 0.68rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* Loading spinner for the play button */
.ap-play.is-loading svg { display: none; }
.ap-play.is-loading #ap-icon-loading { display: block !important; animation: apSpin 1s linear infinite; }
@keyframes apSpin { to { transform: rotate(360deg); } }

/* ── Building Controls ────────────────────────────────────── */
.building-controls {
    background: rgba(22, 17, 40, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--border-subtle);
    border-radius: var(--radius);
    padding: 20px 20px 24px;
    margin-top: 16px;
}
.building-controls p {
    font-weight: 600;
    margin-bottom: 12px;
}

/* ── Spin Wheel ──────────────────────────────────────────── */
.controls-title { font-weight: 600; margin-bottom: 16px; }

.spin-section { text-align: center; margin-bottom: 20px; }

.spin-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 18px;
}

.spin-wheel-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.spin-pointer {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 14px solid var(--accent);
    z-index: 5;
    filter: drop-shadow(0 2px 4px rgba(232, 121, 168, 0.5));
}

.spin-wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    border: 3px solid var(--surface2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    background: conic-gradient(
        var(--primary) 0deg 120deg,
        var(--accent) 120deg 240deg,
        #7C3AED 240deg 360deg
    );
}

/* Number labels on the wheel — positioned at center of each 120° slice */
/* Conic slices from top clockwise: 0=top-right(60°), 1=bottom(180°), 2=top-left(300°) */
.spin-num {
    position: absolute;
    font-size: 1.3rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 2;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    transform: translate(-50%, -50%);
}
/* Each number sits ~30% from center toward the middle of its 120° slice */
.spin-num[data-index="0"] { top: 34%; left: 70%; }
.spin-num[data-index="1"] { top: 72%; left: 50%; }
.spin-num[data-index="2"] { top: 34%; left: 30%; }

/* Center dot */
.spin-wheel::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    background: var(--surface);
    border: 2px solid var(--surface2);
    border-radius: 50%;
    z-index: 3;
}

.spin-btn {
    background: var(--gradient-primary);
    border: none;
    color: white;
    padding: 12px 28px;
    border-radius: 24px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.4);
}
.spin-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(168, 85, 247, 0.5); }
.spin-btn:active { transform: scale(0.97); }
.spin-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Option cards below the wheel */
.spin-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    text-align: left;
}
.spin-option {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface2);
    border: 2px solid transparent;
    border-radius: var(--radius);
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.spin-option:hover {
    border-color: var(--primary);
    background: rgba(168, 85, 247, 0.1);
}
.spin-option.selected {
    border-color: var(--accent);
    background: rgba(232, 121, 168, 0.1);
}
.spin-option-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    color: white;
    flex-shrink: 0;
}
.spin-option[data-index="0"] .spin-option-num { background: var(--primary); }
.spin-option[data-index="1"] .spin-option-num { background: var(--accent); }
.spin-option[data-index="2"] .spin-option-num { background: #7C3AED; }
.spin-option-text {
    font-size: 0.92rem;
    line-height: 1.3;
    color: var(--text);
}
.spin-option.selected .spin-option-text { font-weight: 600; }

@keyframes winPulse {
    0%, 100% { filter: brightness(1); }
    50%      { filter: brightness(1.5); }
}

.spin-hint {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* Or divider */
.or-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-dim);
    font-size: 0.82rem;
}
.or-divider::before,
.or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--surface2);
}

/* ── Suggestions Toggle (Epic Weaver+) ───────────────────── */
.suggestions-toggle {
    background: rgba(168, 85, 247, 0.1);
    border: 1px dashed rgba(168, 85, 247, 0.4);
    color: var(--primary);
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: all 0.2s;
    font-family: inherit;
    margin: 12px 0 16px;
}
.suggestions-toggle:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: var(--primary);
}

/* ── Story Content Glass ─────────────────────────────────── */
.story-content-glass {
    background: rgba(22, 17, 40, 0.45);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: var(--border-subtle);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* ── Story Params Pills ──────────────────────────────────── */
.story-params {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.story-params:empty { display: none; }
.param-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 14px;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.12);
    color: var(--text-dim);
    text-transform: capitalize;
}
.param-pill-label {
    color: rgba(255,255,255,0.3);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.6rem;
    letter-spacing: 0.04em;
    margin-right: 2px;
}

/* ── View Screen ─────────────────────────────────────────── */
.view-topbar {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    position: relative;
}
.view-menu-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}
.view-menu-btn:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text);
}
.view-overflow-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--surface-solid);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 4px;
    min-width: 170px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 100;
    animation: menuSlideDown 0.15s ease;
}
.view-overflow-menu.hidden { display: none; }

.view-hero {
    margin-bottom: 16px;
}
.view-title {
    flex: 1;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.25;
    margin: 0;
    color: var(--text);
    min-width: 0;
    word-wrap: break-word;
}
.view-hero .story-params {
    margin-bottom: 8px;
}
.view-hero .story-meta {
    margin-bottom: 0;
}

/* Chapter nav wrap */
.chapter-nav-wrap { margin-bottom: 12px; }

/* ── Story Meta ───────────────────────────────────────────── */
.story-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0;
}
.story-meta .tag {
    background: rgba(22, 17, 40, 0.55);
    backdrop-filter: blur(12px);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    color: var(--text-dim);
    border: var(--border-subtle);
}

/* ── Card-Based Story Reader ──────────────────────────────── */
.card-reader {
    position: relative;
    margin-bottom: 24px;
}
.card-track {
    position: relative;
    min-height: 200px;
}
.reader-card {
    box-sizing: border-box;
    background: rgba(22, 17, 40, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--border-subtle);
    border-radius: var(--radius);
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.75;
    font-size: 1.05rem;
    scroll-behavior: smooth;
    /* Bottom-up entrance animation */
    animation: cardSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes cardSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}
.reader-card .part-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(168, 85, 247, 0.15);
}
.reader-card .part-text {
    color: var(--text);
}
.reader-card.active-audio {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.15);
}
/* Chapter menu icon (inside card part-label) */
.chapter-menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.25);
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chapter-menu-icon:hover {
    background: rgba(168, 85, 247, 0.25);
    border-color: var(--primary);
}
/* Chapter jump dropdown (inside card-reader) */
.chapter-menu-dropdown {
    position: absolute;
    top: 48px;
    left: 12px;
    min-width: 220px;
    max-height: 280px;
    overflow-y: auto;
    background: rgba(22, 17, 40, 0.97);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius);
    padding: 6px 0;
    z-index: 100;
    box-shadow: 0 12px 32px rgba(0,0,0,0.6);
}
.chapter-menu-dropdown.hidden { display: none; }
.chapter-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}
.chapter-menu-item:hover { background: rgba(168, 85, 247, 0.12); color: var(--text); }
.chapter-menu-item.active {
    color: var(--primary);
    font-weight: 700;
    background: rgba(168, 85, 247, 0.08);
}
.chapter-menu-item-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}
.chapter-menu-item.active .chapter-menu-item-num {
    background: var(--primary);
    color: white;
}

/* Navigation bar (prev / dots / next) */
.card-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0 4px;
}
.card-nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(22, 17, 40, 0.55);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    min-width: 90px;
    justify-content: center;
}
.card-nav-btn:hover { border-color: var(--primary); background: rgba(168, 85, 247, 0.15); }
.card-nav-btn:disabled { opacity: 0.2; pointer-events: none; }
/* Dots */
.card-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}
.card-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    transition: all 0.3s;
    cursor: pointer;
}
.card-dot.active {
    background: var(--primary);
    transform: scale(1.3);
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
}
.card-counter {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-dim);
    padding-bottom: 4px;
}

/* Read Aloud button inside card reader */
.ap-read-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 8px auto 0;
    padding: 10px 24px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 14px rgba(168, 85, 247, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}
.ap-read-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.5);
}
.ap-read-btn:active { transform: scale(0.96); }

/* ── Story Complete Banner ────────────────────────────────── */
.story-complete-banner {
    position: relative;
    background: linear-gradient(135deg, #1A1A2E 0%, #2A1A3E 50%, #1A2A3E 100%);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 28px 20px;
    margin-top: 20px;
    margin-bottom: 40px;
    text-align: center;
    overflow: hidden;
    animation: bannerReveal 0.8s ease;
}
.story-complete-banner.hidden { display: none; }

@keyframes bannerReveal {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.banner-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(168, 85, 247, 0.15) 0%, transparent 60%);
    animation: bannerPulse 3s ease-in-out infinite;
    pointer-events: none;
}
@keyframes bannerPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.05); }
}

.banner-content { position: relative; z-index: 1; }

.banner-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
    animation: bannerSpin 2s ease-in-out 1;
}
@keyframes bannerSpin {
    0%   { transform: rotate(0deg) scale(0.5); opacity: 0; }
    50%  { transform: rotate(180deg) scale(1.2); opacity: 1; }
    100% { transform: rotate(360deg) scale(1); opacity: 1; }
}

.story-complete-banner h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent), var(--primary), #C084FC);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% auto;
    animation: bannerShimmer 3s linear infinite;
}
@keyframes bannerShimmer {
    0%   { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.banner-msg {
    color: var(--text-dim);
    font-size: 0.95rem;
    margin-bottom: 6px;
}
.banner-ext {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-style: italic;
    margin-bottom: 18px;
}
.banner-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.banner-btn-secondary {
    padding: 12px 24px;
    font-size: 0.95rem;
    border-radius: 30px;
}
.banner-btn {
    background: var(--gradient-primary);
    padding: 12px 24px;
    font-size: 0.95rem;
    border-radius: 30px;
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
    transition: all 0.2s;
}
.banner-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(168, 85, 247, 0.6);
}

/* ── Sequel Offer (after conclusion on building screen) ────── */
.sequel-offer {
    text-align: center;
    background: rgba(22, 17, 40, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: var(--radius);
    padding: 28px 20px;
    margin-top: 16px;
    animation: animFadeUp 0.5s ease both;
}
.sequel-offer.hidden { display: none; }
.sequel-offer-icon { font-size: 2rem; margin-bottom: 8px; }
.sequel-offer-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}
.sequel-offer-msg {
    font-size: 0.88rem;
    opacity: 0.8;
    margin-bottom: 4px;
}

/* ── Sequel Kick-start Module ─────────────────────────────── */
.sequel-kickstart {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(22, 17, 40, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 16px;
    margin-bottom: 20px;
    animation: animFadeUp 0.5s ease both;
    animation-delay: 0.3s;
}
.sequel-kickstart.hidden { display: none; }
.sequel-kickstart-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}
.sequel-kickstart-body {
    flex: 1;
    min-width: 0;
}
.sequel-kickstart-body h4 {
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--text);
}
.sequel-kickstart-body p {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.4;
    margin: 0;
}
.sequel-kickstart-btn {
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* ── View content padding for dock ────────────────────────── */
.view-content-padded { padding-bottom: 60px; }

/* ── Extend ───────────────────────────────────────────────── */
.extend-info {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}
.extend-info .count {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

/* ── Loading ──────────────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 10, 26, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    gap: 6px;
    text-align: center;
}
.loading-overlay.hidden { display: none; }

.loading-scene {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.loading-book {
    position: relative;
    color: var(--primary);
    animation: bookFloat 2.5s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}
@keyframes bookFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}
.loading-quill {
    position: absolute;
    top: 50%;
    right: 2px;
    color: var(--accent);
    animation: quillWrite 1.2s ease-in-out infinite;
    transform-origin: bottom right;
}
@keyframes quillWrite {
    0%, 100% { transform: rotate(-15deg); }
    25%      { transform: rotate(-20deg) translate(-3px, 1px); }
    50%      { transform: rotate(-12deg) translate(1px, -1px); }
    75%      { transform: rotate(-18deg) translate(-2px, 1px); }
}
.loading-sparkles {
    position: absolute;
    inset: 0;
}
.l-sparkle {
    position: absolute;
    font-size: 1rem;
    animation: sparkleFloat 2s ease-in-out infinite;
    opacity: 0;
}
.l-s1 { top: 5%; left: 10%; animation-delay: 0s; color: var(--accent); }
.l-s2 { top: 5%; right: 10%; animation-delay: 0.5s; color: var(--primary); }
.l-s3 { bottom: 10%; left: 8%; animation-delay: 1s; color: #C084FC; }
.l-s4 { bottom: 10%; right: 8%; animation-delay: 1.5s; color: var(--accent); }
@keyframes sparkleFloat {
    0%   { opacity: 0; transform: translateY(8px) scale(0.5); }
    30%  { opacity: 1; transform: translateY(-4px) scale(1); }
    70%  { opacity: 1; transform: translateY(-8px) scale(1.1); }
    100% { opacity: 0; transform: translateY(-16px) scale(0.5); }
}
.loading-text {
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--text), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: textPulse 2s ease-in-out infinite;
}
@keyframes textPulse {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 1; }
}
.loading-tip {
    font-size: 0.82rem;
    color: var(--text-dim);
    text-align: center;
    max-width: 280px;
    min-height: 2.4em;
    animation: tipFade 0.5s ease;
}
@keyframes tipFade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.loading { text-align: center; color: var(--text-dim); padding: 20px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(13, 10, 26, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 20px;
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 400px;
}
.modal-content h3 { margin-bottom: 16px; }
.modal-content input {
    width: 100%;
    background: var(--bg);
    border: 2px solid var(--surface2);
    border-radius: var(--radius);
    padding: 14px;
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 16px;
}
.modal-content input:focus { outline: none; border-color: var(--primary); }

/* Over-limit modal */
.overlimit-modal-content {
    max-width: 440px;
    padding: 28px 20px;
}
.overlimit-header {
    text-align: center;
    margin-bottom: 20px;
}
.overlimit-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
}
.overlimit-header h3 {
    margin-bottom: 6px;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.overlimit-sub {
    color: var(--text-dim);
    font-size: 0.9rem;
}
.overlimit-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 16px;
}
.overlimit-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(22, 17, 40, 0.6);
    border: var(--border-subtle);
    border-radius: 12px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
    color: var(--text);
    font-family: inherit;
}
.overlimit-item:hover {
    border-color: rgba(255, 107, 107, 0.3);
    background: rgba(255, 107, 107, 0.06);
}
.overlimit-item-info {
    flex: 1;
    min-width: 0;
}
.overlimit-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.overlimit-item-meta {
    display: flex;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 3px;
}
.overlimit-item-delete {
    color: var(--danger);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
}
.overlimit-item:hover .overlimit-item-delete {
    opacity: 1;
}
.overlimit-section-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin: 12px 0 8px;
    text-align: center;
}
.overlimit-divider {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    margin: 14px 0;
    position: relative;
}
.overlimit-divider::before,
.overlimit-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 35%;
    height: 1px;
    background: rgba(255,255,255,0.08);
}
.overlimit-divider::before { left: 0; }
.overlimit-divider::after { right: 0; }
.overlimit-actions {
    text-align: center;
}

/* ── Typing Animation ────────────────────────────────────── */
.part-text { display: inline; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }



/* ── Error Toast ─────────────────────────────────────────── */
.error-toast {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    z-index: 400;
    max-width: 90%;
    text-align: center;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 8px 32px rgba(255, 107, 107, 0.3);
}
.error-toast.show {
    bottom: 30px;
}

/* ── Chapter Navigation Strip ─────────────────────────────── */
.chapter-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 0 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.chapter-nav::-webkit-scrollbar { display: none; }

.chapter-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    padding: 6px 14px 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s;
    font-family: inherit;
}
.chapter-btn:hover {
    color: var(--text);
}
.chapter-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── Part Labels ─────────────────────────────────────────── */
.part-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed rgba(232, 121, 168, 0.2);
}
.part.extension .part-label {
    color: #C084FC;
    border-bottom-color: rgba(139, 92, 246, 0.2);
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-dim);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* ── Voice Input Overlay ─────────────────────────────────── */
.voice-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 10, 26, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 250;
    animation: fadeIn 0.2s ease;
}
.voice-overlay.hidden { display: none; }

.voice-modal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px 30px;
    max-width: 340px;
    width: 100%;
    position: relative;
}

/* Mic button container — anchor for rings */
.voice-mic-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
}

/* Pulsing rings around mic button */
.voice-rings {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 140px;
    height: 140px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.voice-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--primary);
    opacity: 0;
}
.voice-overlay.active .voice-ring {
    animation: voiceRingPulse 2.4s ease-out infinite;
}
.voice-ring-1 { animation-delay: 0s !important; }
.voice-ring-2 { animation-delay: 0.8s !important; }
.voice-ring-3 { animation-delay: 1.6s !important; }

@keyframes voiceRingPulse {
    0%   { transform: scale(0.5); opacity: 0.6; }
    100% { transform: scale(2.2); opacity: 0; }
}

.voice-mic-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    z-index: 2;
    transition: all 0.3s;
    box-shadow: 0 4px 24px rgba(168, 85, 247, 0.4);
}
.voice-mic-btn.listening {
    animation: micPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.6);
}
.voice-mic-btn.done {
    background: linear-gradient(135deg, var(--success), #2EAA50);
    box-shadow: 0 0 30px rgba(78, 203, 113, 0.5);
    animation: none;
}

@keyframes micPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}

.voice-status {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.02em;
}

.voice-transcript {
    min-height: 48px;
    padding: 12px 20px;
    background: var(--surface);
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 1rem;
    line-height: 1.5;
    text-align: center;
    width: 100%;
    max-width: 300px;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.3s;
}
.voice-transcript.has-text {
    opacity: 1;
    transform: translateY(0);
    color: var(--text);
    border: 1px solid var(--primary);
}

.voice-hint {
    font-size: 0.82rem;
    color: var(--text-dim);
}

/* ── Gamification: Level Themes ──────────────────────────── */

/* Epic Weaver theme (blue/teal cosmic) */
body[data-level="epic-weaver"] {
    --primary: #38BDF8;
    --primary-dark: #0EA5E9;
    --primary-rgb: 56, 189, 248;
    --accent: #22D3EE;
    --accent-rgb: 34, 211, 238;
    --bg: #0A1628;
    --surface: rgba(10, 30, 60, 0.65);
    --surface-solid: #0F1E38;
    --surface2: #152640;
}
body[data-level="epic-weaver"] .text-gradient {
    background: linear-gradient(135deg, #22D3EE, #38BDF8, #22D3EE);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
body[data-level="epic-weaver"] .orb-1 { background: radial-gradient(circle, rgba(56,189,248,0.18), transparent 70%); }
body[data-level="epic-weaver"] .orb-2 { background: radial-gradient(circle, rgba(34,211,238,0.12), transparent 70%); }
body[data-level="epic-weaver"] .orb-3 { background: radial-gradient(circle, rgba(56,189,248,0.10), transparent 70%); }

/* Legend theme (gold/amber) */
body[data-level="legend"] {
    --primary: #F59E0B;
    --primary-dark: #D97706;
    --primary-rgb: 245, 158, 11;
    --accent: #FBBF24;
    --accent-rgb: 251, 191, 36;
    --bg: #1A1207;
    --surface: rgba(40, 30, 12, 0.65);
    --surface-solid: #241C0E;
    --surface2: #2E2414;
}
body[data-level="legend"] .text-gradient {
    background: linear-gradient(135deg, #FBBF24, #F59E0B, #FBBF24);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
body[data-level="legend"] .orb-1 { background: radial-gradient(circle, rgba(245,158,11,0.18), transparent 70%); }
body[data-level="legend"] .orb-2 { background: radial-gradient(circle, rgba(251,191,36,0.12), transparent 70%); }
body[data-level="legend"] .orb-3 { background: radial-gradient(circle, rgba(245,158,11,0.10), transparent 70%); }

/* ── Level Badge (home screen) ───────────────────────────── */
.level-badge {
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid rgba(var(--primary-rgb), 0.3);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.level-badge:hover {
    border-color: var(--primary);
    box-shadow: 0 0 16px rgba(var(--primary-rgb), 0.3);
    transform: scale(1.05);
}
.level-badge-icon {
    font-size: 1.1rem;
}

/* ── EPIC Story Card Styling ─────────────────────────────── */
.stories-section-header .section-icon {
    font-size: 1rem;
}

/* ── Level Rules Modal ───────────────────────────────────── */
.level-rules-content {
    max-width: 380px;
    text-align: center;
}
.level-rules-title {
    font-size: 1.2rem;
    margin-bottom: 20px;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.level-rules-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 20px;
}
.level-rule {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--surface2);
    width: 100%;
    text-align: left;
    transition: all 0.3s ease;
}
.level-rule .rule-badge {
    font-size: 1.8rem;
    flex-shrink: 0;
}
.level-rule .rule-info strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 2px;
}
.level-rule .rule-info p {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.4;
    margin: 0;
}
.level-rule-arrow {
    color: var(--text-dim);
    font-size: 0.9rem;
    opacity: 0.5;
}
.epic-tag-inline {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: #1A1207;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 1px;
}
.level-rules-progress {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Highlight current level in rules */
.level-rule.current-level {
    border: 1px solid rgba(var(--primary-rgb), 0.4);
    box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.15);
}

/* ── Level-Up Celebration Overlay ────────────────────────── */
.levelup-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);
    -webkit-backdrop-filter: blur(8px);
    animation: levelupFadeIn 0.4s ease;
}
.levelup-overlay.hidden { display: none; }
.levelup-burst {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.4), transparent 70%);
    animation: levelupPulse 1.5s ease-out infinite;
}
.levelup-content {
    position: relative;
    text-align: center;
    animation: levelupBounce 0.6s ease;
}
.levelup-badge {
    font-size: 4rem;
    margin-bottom: 12px;
    animation: levelupSpin 0.8s ease;
}
.levelup-title {
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}
.levelup-name {
    font-size: 1.1rem;
    color: var(--text);
    font-weight: 600;
}

@keyframes levelupFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes levelupPulse {
    0% { transform: scale(0.8); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 0.2; }
    100% { transform: scale(0.8); opacity: 0.6; }
}
@keyframes levelupBounce {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes levelupSpin {
    0% { transform: rotate(0deg) scale(0.5); }
    50% { transform: rotate(360deg) scale(1.2); }
    100% { transform: rotate(360deg) scale(1); }
}

/* ── Premium / Paywall ──────────────────────────────────── */

.premium-modal-content {
    max-width: 420px;
    padding: 32px 24px 24px;
    text-align: center;
    background: rgba(22, 17, 40, 0.9);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(168, 85, 247, 0.25);
}
.premium-header { margin-bottom: 24px; }
.premium-crown { font-size: 2.8rem; margin-bottom: 8px; display: block; }
.premium-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.premium-subtitle { color: var(--text-dim); font-size: 0.9rem; }

.premium-benefits {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
    text-align: left;
}
.premium-benefit {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(168, 85, 247, 0.06);
    border: 1px solid rgba(168, 85, 247, 0.12);
    border-radius: 12px;
}
.premium-benefit-icon { font-size: 1.3rem; flex-shrink: 0; width: 32px; text-align: center; }
.premium-benefit-text strong { font-size: 0.88rem; display: block; margin-bottom: 1px; }
.premium-benefit-text p { font-size: 0.78rem; color: var(--text-dim); margin: 0; }
.premium-cta { width: 100%; margin-bottom: 12px; font-size: 1rem; }
.premium-dismiss { font-size: 0.72rem; color: var(--text-dim); opacity: 0.5; }

/* Edit button on story chapters */
/* Right side of part label (read + edit buttons) */
.part-label-right {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.chapter-read-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.25);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.chapter-read-btn:hover {
    background: rgba(168, 85, 247, 0.25);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.25);
}
.chapter-read-btn.is-playing {
    color: white;
    background: var(--gradient-primary);
    animation: chReadPulse 1.5s ease-in-out infinite;
}
.chapter-read-btn.is-generating {
    opacity: 0.7;
    pointer-events: none;
}
@keyframes chReadPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.3); }
    50% { box-shadow: 0 0 8px 3px rgba(168, 85, 247, 0.25); }
}

.premium-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.7rem;
    transition: color 0.2s, background 0.2s;
    vertical-align: middle;
}
.premium-edit-btn:hover { color: var(--accent); background: rgba(232, 121, 168, 0.1); }
.premium-lock-icon { opacity: 0.4; vertical-align: middle; }

/* PRO badge */
.premium-cta-badge {
    display: inline-block;
    background: var(--gradient-accent);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    letter-spacing: 0.5px;
    vertical-align: middle;
    margin-left: 4px;
}

/* Inline premium CTA (chapters/sequels) */
.premium-inline-cta {
    width: 100%;
    margin-top: 8px;
    font-size: 0.85rem;
    text-align: center;
    border: 1px solid rgba(168, 85, 247, 0.2);
}
.premium-inline-cta:hover { border-color: rgba(168, 85, 247, 0.4); }
.premium-upgrade-inline { width: 100%; }

/* ── Feedback (Thumbs Up/Down) ─────────────────────────────── */
.feedback-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    opacity: 0.4;
    transition: opacity 0.2s;
}
.part:hover .feedback-row { opacity: 1; }
.fb-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.fb-btn:hover { background: rgba(255,255,255,0.05); }
.fb-up.active { background: rgba(78, 203, 113, 0.15); border-color: var(--success); }
.fb-down.active { background: rgba(255, 107, 107, 0.15); border-color: var(--danger); }
.fb-verbatim {
    display: flex;
    gap: 6px;
    flex: 1;
}
.fb-verbatim-input {
    flex: 1;
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 4px 10px;
    color: var(--text);
    font-size: 0.8rem;
}
.fb-verbatim-input:focus { border-color: var(--primary); outline: none; }
.fb-verbatim-send {
    background: var(--primary);
    border: none;
    border-radius: 8px;
    padding: 4px 12px;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
}
.fb-verbatim-send:hover { opacity: 0.85; }

/* ── Premium Price ─────────────────────────────────────────── */
.premium-price {
    font-size: 1.8rem;
    font-weight: 800;
    text-align: center;
    margin: 8px 0 4px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.premium-price small {
    font-size: 0.75rem;
    font-weight: 500;
    -webkit-text-fill-color: var(--text-dim);
}

/* ── Home Top-Right Group (trophy + badge) ────────────────── */
.home-top-right {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
}

/* ── Trophy Button (home screen) ──────────────────────────── */
.trophy-btn {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 6px 12px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}
.trophy-btn:hover { background: var(--surface2); transform: scale(1.08); }
.trophy-btn:active { transform: scale(0.95); transition-duration: 0.08s; }

/* Home screen user avatar */
.home-avatar {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(168, 85, 247, 0.4);
    object-fit: cover;
    z-index: 10;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.home-avatar:hover {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
}

/* ── Leaderboard Screen ───────────────────────────────────── */
.leaderboard-tabs {
    display: flex;
    gap: 0;
    padding: 12px 16px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.lb-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 10px 4px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}
.lb-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.lb-tab:hover { color: var(--text); }

.leaderboard-list {
    padding: 8px 16px 24px;
}
.lb-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    transition: background 0.2s;
}
.lb-entry:hover { background: rgba(255,255,255,0.03); }
.lb-entry.lb-me {
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.2);
}
.lb-rank {
    width: 28px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dim);
}
.lb-medal {
    width: 28px;
    text-align: center;
    font-size: 1.1rem;
}
.lb-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.08);
}
.lb-avatar-placeholder {
    background: var(--surface2);
}
.lb-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lb-value {
    font-size: 0.8rem;
    color: var(--text-dim);
    white-space: nowrap;
}
