@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap');

:root {
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-serif: 'Lora', Georgia, Cambria, "Times New Roman", Times, serif;
    
    /* Light Theme Palette */
    --bg-page: #F8FAFC;
    --bg-surface: #FFFFFF;
    --bg-surface-elevated: #FFFFFF;
    --bg-surface-subtle: #F1F5F9;
    --bg-surface-active: #E2E8F0;
    --bg-overlay: rgba(15, 23, 42, 0.4);
    
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #94A3B8;
    
    --border-subtle: #E2E8F0;
    --border-strong: #CBD5E1;
    --border-accent: rgba(99, 102, 241, 0.35);
    
    --accent: #6366F1;
    --accent-hover: #4F46E5;
    --accent-subtle: rgba(99, 102, 241, 0.08);
    --accent-gradient: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    --accent-glow: 0 4px 20px -2px rgba(99, 102, 241, 0.3);
    
    --gold: #F59E0B;
    --gold-subtle: rgba(245, 158, 11, 0.12);
    --success: #10B981;
    --success-subtle: rgba(16, 185, 129, 0.12);
    --danger: #EF4444;
    --danger-subtle: rgba(239, 68, 68, 0.12);
    
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 16px 36px -4px rgba(15, 23, 42, 0.12);
    
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
}

[data-theme="dark"] {
    --bg-page: #080C14;
    --bg-surface: #0F172A;
    --bg-surface-elevated: #162035;
    --bg-surface-subtle: #141C2E;
    --bg-surface-active: #1D2840;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-tertiary: #64748B;
    
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.15);
    --border-accent: rgba(99, 102, 241, 0.4);
    
    --accent: #818CF8;
    --accent-hover: #6366F1;
    --accent-subtle: rgba(129, 140, 248, 0.12);
    --accent-gradient: linear-gradient(135deg, #6366F1 0%, #A855F7 100%);
    --accent-glow: 0 6px 24px -2px rgba(99, 102, 241, 0.4);
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 6px 20px -2px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 20px 48px -4px rgba(0, 0, 0, 0.75);
}

/* Sepia Paper Theme for Book Reader */
[data-reader-theme="sepia"] #viewReader .card {
    background-color: #FAF4E8 !important;
    color: #433422 !important;
    border-color: #E8DCC4 !important;
}
[data-reader-theme="sepia"] #viewReader .reader-prose p {
    color: #382A1B !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background-color: var(--bg-page);
    background-image: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 45%);
    background-attachment: fixed;
    color: var(--text-primary);
    direction: ltr;
    text-align: left;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Header */
.app-header {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-decoration: none;
    user-select: none;
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--accent-glow);
    transition: transform 0.2s ease;
}
.brand:hover .brand-icon {
    transform: rotate(-3deg) scale(1.05);
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Banner */
.demo-banner {
    background: linear-gradient(90deg, #1E1B4B 0%, #312E81 100%);
    color: #E0E7FF;
    border-bottom: 1px solid rgba(129, 140, 248, 0.25);
    padding: 10px 24px;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 28px 80px;
}

/* Typography & General */
h1, h2, h3, h4, h5 {
    letter-spacing: -0.02em;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1;
}

.btn svg {
    flex-shrink: 0;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #FFFFFF;
    box-shadow: var(--accent-glow);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px -2px rgba(99, 102, 241, 0.45);
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-surface-subtle);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
    background: var(--bg-surface-active);
    border-color: var(--border-strong);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--bg-surface-subtle);
    color: var(--text-primary);
}

.nav-link-btn {
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-link-btn.nav-active {
    background: var(--accent-subtle) !important;
    color: var(--accent) !important;
    border: 1px solid var(--border-accent) !important;
    font-weight: 700 !important;
    box-shadow: 0 0 14px rgba(99, 102, 241, 0.2);
}

.btn-sm {
    padding: 7px 12px;
    font-size: 0.84rem;
    border-radius: var(--radius-xs);
}

.btn-lg {
    padding: 12px 26px;
    font-size: 1.05rem;
    border-radius: var(--radius-sm);
}

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Novel Grid & Visual Novel Cards */
.novel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
}

.novel-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.novel-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-lg), 0 0 25px -5px rgba(99, 102, 241, 0.15);
}

.novel-card-cover {
    height: 160px;
    width: 100%;
    position: relative;
    overflow: hidden;
    background-color: var(--bg-surface-subtle);
}

.novel-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.novel-card:hover .novel-card-cover img {
    transform: scale(1.06);
}

.novel-card-cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(15, 23, 42, 0.85) 100%);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 14px 18px;
}

.novel-card-body {
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
}

/* Presets Grid */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.preset-card {
    position: relative;
    height: 200px;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border-subtle);
    transition: all 0.25s ease;
    box-shadow: var(--shadow-sm);
}

.preset-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: var(--shadow-md), 0 0 20px -3px rgba(99, 102, 241, 0.25);
}

.preset-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.preset-card:hover .preset-bg {
    transform: scale(1.08);
}

.preset-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15,23,42,0.3) 0%, rgba(15,23,42,0.92) 80%);
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.preset-badge {
    align-self: flex-start;
    margin-bottom: auto;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #FFFFFF;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.preset-title {
    font-weight: 800;
    font-size: 1.05rem;
    color: #FFFFFF;
    margin-bottom: 4px;
}

.preset-desc {
    font-size: 0.8rem;
    color: rgba(248, 250, 252, 0.8);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Magic Box */
.magic-box {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(168, 85, 247, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-md);
    padding: 22px;
    margin-bottom: 28px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-surface-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.94rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-top: 5px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1;
}

.badge-ready {
    background: var(--accent-subtle);
    color: var(--accent);
}
.badge-writing {
    background: var(--gold-subtle);
    color: var(--gold);
}
.badge-completed {
    background: var(--success-subtle);
    color: var(--success);
}
.badge-draft {
    background: var(--bg-surface-subtle);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

/* Tabs */
.tab-nav {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 24px;
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 11px 18px;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Stepper & Progress Bar */
.progress-bar-bg {
    background: var(--bg-surface-subtle);
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    margin: 16px 0;
}

.progress-bar-fill {
    background: var(--accent-gradient);
    height: 100%;
    transition: width 0.4s ease;
    box-shadow: 0 0 12px var(--accent);
}

.stage-stepper {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-top: 14px;
}

.stage-step {
    font-size: 0.75rem;
    text-align: center;
    padding: 10px 4px;
    border-radius: var(--radius-xs);
    background: var(--bg-surface-subtle);
    color: var(--text-tertiary);
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.stage-step svg {
    width: 16px;
    height: 16px;
}

.stage-step.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 800;
    border: 1px solid var(--border-accent);
}

.stage-step.completed {
    background: var(--success-subtle);
    color: var(--success);
}

/* Character Dossier Card */
.character-dossier-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 22px;
    transition: all 0.2s ease;
}

.character-dossier-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-md);
}

.character-dossier-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.character-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-surface-subtle);
    border: 2px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.character-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.character-dossier-traits {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 12px;
    font-size: 0.88rem;
}

.trait-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.5;
}

.trait-label {
    font-weight: 700;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    min-width: 55px;
    text-transform: uppercase;
}

/* Reader Prose */
.reader-prose {
    font-family: var(--font-serif);
    line-height: 1.95;
    letter-spacing: -0.003em;
}

.reader-prose p {
    margin-bottom: 1.6em;
    text-indent: 1.8em;
}

.reader-prose p:first-of-type {
    text-indent: 0;
}

.reader-prose p:first-of-type::first-letter {
    font-size: 3.2em;
    float: left;
    line-height: 0.85;
    margin-right: 0.15em;
    font-family: var(--font-serif);
    font-weight: 700;
    color: var(--accent);
}

/* Drawer: Behind the Scenes */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    max-width: 92vw;
    height: 100vh;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.45);
    border-left: 1px solid var(--border-subtle);
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.drawer.open {
    transform: translateX(0);
}

.scene-block {
    background: var(--bg-surface-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 20px;
}

.turn-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 12px;
}

.thought-box {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.05) 0%, rgba(245, 158, 11, 0.05) 100%);
    border-left: 3px solid var(--danger);
    padding: 10px 14px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 0.88rem;
    font-style: italic;
    color: var(--text-primary);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    padding: 32px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

/* Modern Floating Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 380px;
}

.toast.toast-success {
    border-color: rgba(16, 185, 129, 0.4);
    background: var(--bg-surface-elevated);
}
.toast.toast-error {
    border-color: rgba(239, 68, 68, 0.4);
}
.toast.toast-info {
    border-color: rgba(99, 102, 241, 0.4);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .header-container { padding: 12px 18px; }
    .main-content { padding: 20px 16px; }
    .novel-grid { grid-template-columns: 1fr; }
    .stage-stepper { grid-template-columns: repeat(3, 1fr); }
    .drawer { width: 100vw; }
    .chapter-list-item { flex-direction: column; align-items: flex-start !important; gap: 12px; }
    .chapter-thumb-container { width: 100% !important; height: 140px !important; }
}

/* ==================== CHAPTER HERO ARTWORK ==================== */
.reader-hero-wrapper {
    margin-bottom: 36px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-md);
    background: #090D16;
}

.reader-hero-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 400px;
    overflow: hidden;
    background: #0B1120;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reader-hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.reader-hero-frame:hover .reader-hero-img {
    transform: scale(1.02);
}

.reader-hero-overlay {
    position: absolute;
    inset: auto 0 0 0;
    background: linear-gradient(180deg, transparent 0%, rgba(8, 12, 20, 0.7) 40%, rgba(8, 12, 20, 0.95) 100%);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.reader-hero-caption-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reader-hero-badge {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: #818CF8;
}

.reader-hero-location {
    font-size: 0.95rem;
    font-weight: 600;
    color: #F8FAFC;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.btn-hero-regen {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-hero-regen:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
}

/* ==================== CHAPTER LIST ITEM & THUMBNAIL ==================== */
.chapter-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-surface-subtle);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    gap: 16px;
}

.chapter-list-item:hover {
    border-color: var(--accent);
    background: var(--bg-surface-elevated);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.chapter-thumb-container {
    width: 104px;
    height: 64px;
    border-radius: var(--radius-xs);
    overflow: hidden;
    flex-shrink: 0;
    background: #0B1120;
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chapter-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ==================== USER PROFILE & AUTH UI ==================== */
.user-nav-capsule {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 6px;
    background: var(--bg-surface-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
}

.user-nav-capsule:hover {
    border-color: var(--accent);
    background: var(--bg-surface-elevated);
}

.user-nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #FFFFFF;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    gap: 2px;
    animation: modalPop 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-dropdown-menu.show {
    display: flex;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background 0.15s ease;
    text-decoration: none;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg-surface-subtle);
    color: var(--accent);
}

.dropdown-item.danger:hover {
    background: var(--danger-subtle);
    color: var(--danger);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* ==================== ADMIN DASHBOARD ==================== */
.admin-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.admin-kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.admin-kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--accent-subtle);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.admin-kpi-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 4px;
}

.admin-kpi-label {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    font-weight: 600;
}

.admin-table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.admin-table th {
    background: var(--bg-surface-subtle);
    padding: 14px 18px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}

.admin-table td {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: var(--bg-surface-subtle);
}

.table-action-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.table-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.table-action-btn.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-subtle);
}

/* User Status Badges */
.badge-user-active {
    background: rgba(16, 185, 129, 0.14);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-user-suspended {
    background: rgba(239, 68, 68, 0.14);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-role-admin {
    background: rgba(139, 92, 246, 0.14);
    color: #8B5CF6;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

.badge-role-author {
    background: rgba(99, 102, 241, 0.14);
    color: #6366F1;
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.auth-tabs {
    display: flex;
    background: var(--bg-surface-subtle);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 20px;
    gap: 4px;
}

.auth-tab-btn {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: var(--radius-xs);
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    transition: all 0.2s ease;
}

.auth-tab-btn.active {
    background: var(--bg-surface-elevated);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

/* Live Generation Terminal */
.live-dot {
    animation: livePulse 1.6s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 6px #10b981; }
    50% { opacity: 0.4; transform: scale(0.85); box-shadow: 0 0 0 transparent; }
}

/* Character x Episode Matrix Grid */
.matrix-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    margin-bottom: 28px;
    box-shadow: var(--shadow-sm);
}

.matrix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 700px;
}

.matrix-table th,
.matrix-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    vertical-align: top;
}

.matrix-table th:last-child,
.matrix-table td:last-child {
    border-right: none;
}

.matrix-table tbody tr:last-child td {
    border-bottom: none;
}

.matrix-corner {
    background: var(--bg-surface-subtle);
    color: var(--text-primary);
    font-weight: 800;
    font-size: 0.95rem;
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 190px;
}

.matrix-col-header {
    background: var(--bg-surface-subtle);
    text-align: center;
    min-width: 220px;
    transition: background 0.2s ease;
}

.matrix-col-header.col-written {
    background: rgba(99, 102, 241, 0.12);
    border-bottom: 3px solid var(--accent);
}

.matrix-char-cell {
    background: var(--bg-surface);
    position: sticky;
    left: 0;
    z-index: 1;
    font-weight: 700;
}

.matrix-goal-cell {
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.matrix-goal-cell.cell-pov {
    background: rgba(99, 102, 241, 0.08);
    border: 2px solid var(--accent) !important;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.matrix-goal-cell.cell-written {
    color: var(--text-primary);
}

/* ==================== FLOATING GLOBAL HELP & GUIDE BUTTON ==================== */
.floating-help-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-accent);
    border-radius: 9999px;
    font-size: 0.88rem;
    font-weight: 700;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 14px rgba(99, 102, 241, 0.25);
    cursor: pointer;
    transition: all 0.25s ease;
    backdrop-filter: blur(8px);
}

.floating-help-btn:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 28px rgba(99, 102, 241, 0.4);
}




