/* ComicMaker — Creative Comic Studio */

:root {
    --coral: #FF6B6B;
    --coral-light: #FF8E8E;
    --coral-dark: #E55555;
    --navy: #0f1729;
    --navy-light: #1a2540;
    --navy-card: #151e35;
    --surface: #1c2742;
    --surface-hover: #243050;
    --text: #e8eaf0;
    --text-muted: #8892a8;
    --text-dim: #5a6478;
    --gold: #FFD93D;
    --green: #6BCB77;
    --purple: #B983FF;
    --border: rgba(255,255,255,0.06);
}

* { box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    background: var(--navy);
    color: var(--text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* ── Hero ── */
.brand-title {
    font-family: 'Bangers', 'Plus Jakarta Sans', cursive;
    font-size: 5.5rem;
    letter-spacing: 0.06em;
    color: white;
    text-shadow: 4px 4px 0 var(--coral), 8px 8px 0 rgba(0,0,0,0.3);
    line-height: 1;
}
.brand-subtitle {
    font-size: 1.25rem;
    color: rgba(255,255,255,0.75);
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.7;
    font-weight: 500;
}

.hero-section {
    position: relative;
    min-height: calc(100vh - 47px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow: hidden;
}
.hero-bg {
    position: absolute; inset: 0;
    background: url('/static/img/hero-bg.png') center/cover no-repeat;
    opacity: 0.3;
    pointer-events: none;
}
.hero-overlay {
    position: absolute; inset: 0;
    background:
        linear-gradient(180deg, rgba(15,23,41,0.4) 0%, rgba(15,23,41,0.7) 50%, rgba(15,23,41,0.95) 100%),
        radial-gradient(ellipse 80% 60% at 50% 30%, rgba(255,107,107,0.1) 0%, transparent 70%);
    pointer-events: none;
}
.hero-content { position: relative; z-index: 1; text-align: center; }

/* ── Buttons ── */
.btn-coral {
    background: var(--coral); color: white; border: none;
    padding: 0.9rem 2.5rem; font-size: 1.1rem; font-weight: 700;
    border-radius: 14px; cursor: pointer; transition: all 0.2s;
    display: inline-flex; align-items: center; gap: 0.5rem;
    text-decoration: none; font-family: inherit;
    box-shadow: 0 4px 20px rgba(255,107,107,0.35);
}
.btn-coral:hover { background: var(--coral-light); transform: translateY(-2px); box-shadow: 0 6px 28px rgba(255,107,107,0.45); }
.btn-coral:active { transform: translateY(0); }
.btn-coral:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
    background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.8);
    border: 1px solid rgba(255,255,255,0.15);
    padding: 0.75rem 1.5rem; font-size: 0.95rem; font-weight: 600;
    border-radius: 14px; cursor: pointer; transition: all 0.2s;
    text-decoration: none; font-family: inherit;
}
.btn-ghost:hover { background: rgba(255,255,255,0.12); color: white; border-color: rgba(255,255,255,0.25); }

.btn-sm { padding: 0.45rem 1rem; font-size: 0.8rem; border-radius: 8px; }

/* ── Feature Cards ── */
.features-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem; max-width: 750px; margin: 3rem auto 0;
}
.feature-card {
    background: rgba(21,30,53,0.85); backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 18px; padding: 1.75rem 1.5rem; text-align: center;
    transition: all 0.25s;
}
.feature-card:hover { background: rgba(28,39,66,0.9); border-color: rgba(255,107,107,0.25); transform: translateY(-4px); box-shadow: 0 8px 30px rgba(0,0,0,0.3); }
.feature-card .icon { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; }
.feature-card h3 { font-size: 1rem; font-weight: 700; margin: 0 0 0.4rem; color: white; }
.feature-card p { font-size: 0.82rem; color: var(--text-muted); margin: 0; line-height: 1.5; }

/* ── Recent Comics ── */
.recent-section { position: relative; z-index: 1; max-width: 800px; width: 100%; margin-top: 3rem; }
.recent-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.recent-header span { font-size: 0.8rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.recent-header a { font-size: 0.8rem; color: var(--coral); text-decoration: none; font-weight: 500; }
.recent-header a:hover { text-decoration: underline; }
.recent-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }

.comic-card {
    background: var(--navy-card); border: 1px solid var(--border);
    border-radius: 12px; overflow: hidden; cursor: pointer; transition: all 0.25s;
}
.comic-card:hover { transform: translateY(-4px); box-shadow: 0 8px 30px rgba(0,0,0,0.4); border-color: rgba(255,107,107,0.2); }
.comic-card .thumb { width: 100%; aspect-ratio: 2/3; background: var(--surface); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.comic-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.comic-card .thumb .placeholder { font-size: 2rem; opacity: 0.15; }
.comic-card .info { padding: 0.6rem 0.75rem; }
.comic-card .info .title { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comic-card .info .meta { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.15rem; }

/* ═══════════════════════════════════
   CHAT — CENTERED WINDOW OVER BG
   ═══════════════════════════════════ */
.chat-fullscreen {
    position: relative;
    height: 100vh;
    overflow: hidden;
}
.chat-bg {
    position: absolute; inset: 0;
    background: url('/static/img/chat-bg.png') center/cover no-repeat;
    opacity: 0.35;
}
.chat-bg-overlay {
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at center, rgba(15,23,41,0.5) 30%, rgba(15,23,41,0.85) 100%);
}

.chat-window {
    position: relative; z-index: 1;
    width: 75%;
    max-width: 960px;
    height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: rgba(15,23,41,0.95);
    border-left: 1px solid rgba(255,255,255,0.08);
    border-right: 1px solid rgba(255,255,255,0.08);
}

.chat-header {
    display: flex; align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0; gap: 0.75rem;
}
.chat-header .back {
    color: var(--text-muted); font-size: 0.85rem; cursor: pointer;
    background: none; border: none; padding: 0.3rem 0.6rem;
    border-radius: 8px; font-family: inherit;
}
.chat-header .back:hover { background: var(--surface); color: var(--text); }
.chat-header .title-area { flex: 1; text-align: center; }
.chat-header .title-area h2 { font-size: 0.95rem; font-weight: 700; margin: 0; color: var(--text); }
.chat-header .title-area p { font-size: 0.7rem; color: var(--text-dim); margin: 0.1rem 0 0; }

/* Messages */
.chat-messages { flex: 1; overflow-y: auto; padding: 1.25rem; scroll-behavior: smooth; }

.msg {
    display: flex; gap: 0.6rem; margin-bottom: 0.85rem;
    max-width: 88%; animation: msgIn 0.3s ease;
}
.msg.user { margin-left: auto; flex-direction: row-reverse; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.msg .avatar {
    width: 30px; height: 30px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 0.85rem;
}
.msg.assistant .avatar { background: linear-gradient(135deg, var(--coral), var(--purple)); }
.msg.user .avatar { background: var(--surface); }

.msg .bubble {
    padding: 0.7rem 1rem; border-radius: 14px;
    font-size: 0.88rem; line-height: 1.6;
    white-space: pre-wrap; word-break: break-word;
}
.msg.assistant .bubble { background: rgba(21,30,53,0.9); border: 1px solid var(--border); border-top-left-radius: 4px; color: var(--text); }
.msg.user .bubble { background: var(--coral); color: white; border-top-right-radius: 4px; }

/* Empty State */
.chat-empty {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100%; padding: 2rem;
    text-align: center;
}
.chat-empty .illustration { width: 100px; height: 100px; border-radius: 20px; overflow: hidden; margin-bottom: 1.25rem; opacity: 0.85; }
.chat-empty .illustration img { width: 100%; height: 100%; object-fit: cover; }
.chat-empty h3 { font-size: 1.1rem; font-weight: 700; margin: 0 0 0.4rem; }
.chat-empty p { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 1.25rem; max-width: 300px; }

.suggestions { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.suggestion {
    background: rgba(21,30,53,0.8); border: 1px solid var(--border);
    color: var(--text-muted); padding: 0.45rem 0.85rem;
    border-radius: 20px; font-size: 0.78rem; cursor: pointer; transition: all 0.2s;
}
.suggestion:hover { background: var(--surface); color: var(--coral); border-color: rgba(255,107,107,0.3); }

/* Input */
.chat-input-area {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-input-row {
    display: flex; gap: 0.5rem; align-items: center;
}
.chat-input-row input[type="text"] {
    flex: 1; background: rgba(28,39,66,0.8); border: 1px solid var(--border);
    color: var(--text); padding: 0.7rem 1rem; border-radius: 12px;
    font-size: 0.9rem; font-family: inherit; outline: none; transition: border-color 0.2s;
}
.chat-input-row input[type="text"]:focus { border-color: var(--coral); }
.chat-input-row input[type="text"]::placeholder { color: var(--text-dim); }
.chat-input-row .send-btn {
    background: var(--coral); border: none; color: white;
    width: 42px; height: 42px; border-radius: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; transition: all 0.2s; flex-shrink: 0;
}
.chat-input-row .send-btn:hover { background: var(--coral-light); }
.chat-input-row .send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.chat-input-row .attach-btn {
    background: none; border: 1px solid var(--border); color: var(--text-dim);
    width: 42px; height: 42px; border-radius: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; transition: all 0.2s; flex-shrink: 0;
}
.chat-input-row .attach-btn:hover { background: var(--surface); color: var(--text); border-color: rgba(255,255,255,0.15); }

/* Image preview strip */
.image-previews {
    display: flex; gap: 0.5rem; padding: 0.5rem 0 0;
    max-width: 100%; overflow-x: auto;
}
.image-previews:empty { display: none; }
.img-preview {
    position: relative; width: 60px; height: 60px;
    border-radius: 8px; overflow: hidden; flex-shrink: 0;
    border: 1px solid var(--border);
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-preview .remove-img {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: rgba(0,0,0,0.7); color: white; border: none;
    font-size: 0.65rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.img-preview .remove-img:hover { background: var(--coral); }

/* Images in chat bubbles */
.bubble-images {
    display: flex; gap: 0.4rem; margin-bottom: 0.4rem; flex-wrap: wrap;
}
.bubble-images img {
    width: 80px; height: 80px; object-fit: cover;
    border-radius: 8px; border: 1px solid rgba(255,255,255,0.1);
}

/* ── Inline CTA in Chat ── */
.chat-cta {
    padding: 0.5rem 0 0.75rem;
}
.chat-cta .btn-coral {
    animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 4px 20px rgba(255,107,107,0.35); }
    50% { box-shadow: 0 4px 30px rgba(255,107,107,0.6), 0 0 40px rgba(255,107,107,0.15); }
}

/* ── Config Modal (before generating) ── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s ease;
}
.modal-card {
    background: var(--navy-card); border: 1px solid var(--border);
    border-radius: 20px; padding: 2rem; width: 420px; max-width: 90vw;
    animation: modalIn 0.3s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-card h2 { font-size: 1.2rem; font-weight: 800; margin: 0 0 0.3rem; }
.modal-card .modal-sub { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 1.25rem; }

.style-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 1.25rem; }
.style-card {
    background: var(--surface); border: 2px solid transparent;
    border-radius: 10px; padding: 0.6rem 0.4rem; text-align: center;
    cursor: pointer; transition: all 0.2s;
    font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
}
.style-card:hover { background: var(--surface-hover); color: var(--text); }
.style-card.active { border-color: var(--coral); background: rgba(255,107,107,0.1); color: var(--coral); }
.style-card .style-icon { font-size: 1.3rem; display: block; margin-bottom: 0.2rem; }

.config-row {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem;
}
.config-row:last-child { margin-bottom: 0; }
.config-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.config-row select, .config-row input[type="number"] {
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); padding: 0.45rem 0.6rem; border-radius: 8px;
    font-size: 0.85rem; font-family: inherit; outline: none; width: 130px; text-align: center;
}
.config-row select:focus, .config-row input:focus { border-color: var(--coral); }
.config-row input[type="file"] { font-size: 0.72rem; color: var(--text-muted); width: 150px; }

.modal-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.modal-actions .btn-coral { flex: 1; justify-content: center; }
.modal-actions .btn-ghost { padding: 0.85rem 1.5rem; }

.modal-cost { text-align: center; font-size: 0.72rem; color: var(--text-dim); margin-top: 0.6rem; }

/* ── Generating ── */
.gen-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.gen-card {
    background: var(--navy-card); border: 1px solid var(--border);
    border-radius: 20px; padding: 2.5rem; max-width: 650px; width: 100%;
}
.gen-card h2 { font-size: 1.5rem; font-weight: 800; margin: 0 0 0.5rem; }
.gen-status { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.gen-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
.gen-thumb {
    aspect-ratio: 2/3; border-radius: 10px; overflow: hidden;
    background: var(--surface); display: flex; align-items: center; justify-content: center;
}
.gen-thumb img { width: 100%; height: 100%; object-fit: cover; animation: fadeIn 0.5s ease; }
.gen-thumb .num { color: var(--text-dim); font-weight: 600; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--coral); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar { width: 100%; height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: linear-gradient(90deg, var(--coral), var(--purple)); border-radius: 3px; transition: width 0.5s ease; }
.gen-cost { text-align: right; font-size: 0.75rem; color: var(--text-dim); margin-top: 0.5rem; }

/* ── Result ── */
.result-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.result-card {
    background: var(--navy-card); border: 1px solid var(--border);
    border-radius: 20px; padding: 2.5rem; max-width: 800px; width: 100%; text-align: center;
}
.result-card h2 { font-size: 1.8rem; font-weight: 800; margin: 0 0 1rem; }
.result-badges { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.5rem; }
.badge { padding: 0.35rem 0.8rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }
.badge.coral { background: rgba(255,107,107,0.15); color: var(--coral); border-color: rgba(255,107,107,0.2); }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 2rem; }
.result-grid img { width: 100%; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.3); transition: transform 0.2s; }
.result-grid img:hover { transform: scale(1.03); }
.result-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

/* ── Gallery ── */
.gallery-container { max-width: 900px; margin: 0 auto; padding: 2rem; }
.gallery-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.gallery-header h2 { flex: 1; font-size: 1.3rem; font-weight: 800; margin: 0; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }

/* ── Form shared ── */
.form-group { margin-bottom: 1rem; }
.form-group .form-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: 0.05em; }
.form-group textarea, .form-group input, .form-group select {
    width: 100%; background: var(--surface); border: 1px solid var(--border);
    color: var(--text); padding: 0.65rem 0.8rem; border-radius: 10px;
    font-size: 0.9rem; font-family: inherit; outline: none; transition: border-color 0.2s;
}
.form-group textarea:focus, .form-group input:focus, .form-group select:focus { border-color: var(--coral); }
.form-group textarea { resize: vertical; min-height: 100px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.alert-error { background: rgba(255,107,107,0.1); border: 1px solid rgba(255,107,107,0.2); color: var(--coral); padding: 0.6rem 1rem; border-radius: 10px; font-size: 0.85rem; margin-bottom: 1rem; }

/* ═══════════════════════════════════
   DASHBOARD — Production Control
   ═══════════════════════════════════ */
.dash-fullscreen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--navy);
}

.dash-header {
    display: flex; align-items: center;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(15,23,41,0.95);
    flex-shrink: 0; gap: 0.75rem;
    backdrop-filter: blur(12px);
    z-index: 10;
}
.dash-header .back {
    color: var(--text-muted); font-size: 0.85rem; cursor: pointer;
    background: none; border: none; padding: 0.3rem 0.6rem;
    border-radius: 8px; font-family: inherit;
}
.dash-header .back:hover { background: var(--surface); color: var(--text); }
.dash-header h2 { flex: 1; text-align: center; font-size: 1rem; font-weight: 700; margin: 0; }

.dash-scroll {
    flex: 1; overflow-y: auto; padding: 1.5rem;
    scroll-behavior: smooth;
}

.dash-container {
    max-width: 800px; margin: 0 auto;
}

.dash-section {
    background: var(--navy-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease;
}
.dash-section h3 {
    font-size: 0.95rem; font-weight: 700; margin: 0 0 1rem;
    color: var(--text);
    display: flex; align-items: center; gap: 0.4rem;
}

/* ── Characters grid ── */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.char-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 0.75rem;
    text-align: center;
    transition: all 0.2s;
    position: relative;
}
.char-card:hover { border-color: rgba(255,255,255,0.15); }
.char-card.editing {
    grid-column: 1 / -1;
    text-align: left;
    padding: 1rem;
}

.char-avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    margin: 0 auto 0.5rem;
    overflow: hidden;
    background: var(--navy-card);
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--border);
}
.char-avatar img { width: 100%; height: 100%; object-fit: cover; }
.char-avatar-placeholder {
    font-size: 1.2rem; font-weight: 700;
    color: var(--coral); opacity: 0.7;
}

.char-name { font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 0.15rem; }
.char-role { font-size: 0.7rem; color: var(--text-dim); margin-bottom: 0.4rem; }

.char-edit-btn {
    font-size: 0.7rem; color: var(--text-muted); background: none;
    border: none; cursor: pointer; font-family: inherit;
    padding: 0.2rem 0.4rem; border-radius: 4px;
}
.char-edit-btn:hover { color: var(--coral); background: rgba(255,107,107,0.1); }

.char-card.add-card {
    border-style: dashed;
    border-color: rgba(255,255,255,0.12);
    cursor: pointer;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 120px;
    color: var(--text-dim);
    transition: all 0.2s;
}
.char-card.add-card:hover { border-color: var(--coral); color: var(--coral); background: rgba(255,107,107,0.05); }
.char-card.add-card .add-icon { font-size: 1.5rem; margin-bottom: 0.2rem; }

/* Character edit form */
.char-edit-form { display: flex; flex-direction: column; gap: 0.5rem; }
.char-edit-form input, .char-edit-form textarea {
    width: 100%; background: var(--navy-card); border: 1px solid var(--border);
    color: var(--text); padding: 0.5rem 0.7rem; border-radius: 8px;
    font-size: 0.82rem; font-family: inherit; outline: none;
}
.char-edit-form input:focus, .char-edit-form textarea:focus { border-color: var(--coral); }
.char-edit-form textarea { resize: vertical; min-height: 60px; }

/* ── Pages list ── */
.pages-list { display: flex; flex-direction: column; gap: 0.5rem; }

.page-row {
    display: flex; align-items: flex-start; gap: 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    transition: border-color 0.2s;
}
.page-row:hover { border-color: rgba(255,255,255,0.12); }

.page-num {
    width: 28px; height: 28px;
    background: var(--navy-card); border: 1px solid var(--border);
    border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; color: var(--coral);
    margin-top: 0.15rem;
}

.page-desc {
    flex: 1; background: transparent; border: none;
    color: var(--text); padding: 0.2rem 0;
    font-size: 0.85rem; font-family: inherit; outline: none;
    resize: vertical; min-height: 2.4em; line-height: 1.5;
}
.page-desc::placeholder { color: var(--text-dim); }

.page-del {
    width: 24px; height: 24px;
    background: none; border: none; color: var(--text-dim);
    cursor: pointer; font-size: 1rem; flex-shrink: 0;
    border-radius: 4px; margin-top: 0.15rem;
    display: flex; align-items: center; justify-content: center;
}
.page-del:hover { color: var(--coral); background: rgba(255,107,107,0.1); }

/* ── Character photo ── */
.char-photo-upload { margin-top: 0.4rem; }
.char-photo-preview {
    width: 60px; height: 60px; border-radius: 8px; object-fit: cover;
    border: 1px solid var(--border); display: block; margin-bottom: 0.3rem;
}

/* ── Script review ── */
.script-pages { display: flex; flex-direction: column; gap: 0.75rem; }

.script-page {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; overflow: hidden;
}
.script-page-header {
    padding: 0.6rem 0.8rem; font-size: 0.82rem; font-weight: 700;
    background: rgba(255,107,107,0.08); color: var(--coral);
    border-bottom: 1px solid var(--border);
}

.script-panel {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
}
.script-panel:last-child { border-bottom: none; }

.panel-header {
    display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.3rem;
}
.panel-num {
    font-size: 0.7rem; font-weight: 700; color: var(--coral);
    background: rgba(255,107,107,0.1); padding: 0.15rem 0.4rem;
    border-radius: 4px;
}
.panel-shot, .panel-mood {
    font-size: 0.65rem; color: var(--text-dim);
    background: var(--navy-card); padding: 0.1rem 0.3rem; border-radius: 3px;
}

.panel-desc {
    font-size: 0.78rem; color: var(--text); line-height: 1.5;
    margin: 0.2rem 0 0.3rem; white-space: pre-wrap;
}
.panel-prompt-hint {
    font-size: 0.7rem; color: var(--purple); font-style: italic;
    margin: 0 0 0.3rem; line-height: 1.4;
    padding: 0.3rem 0.5rem; background: rgba(185,131,255,0.08);
    border-radius: 4px;
}

.panel-dialogues { margin-top: 0.3rem; }
.script-dialogue {
    font-size: 0.75rem; color: var(--text-muted); padding: 0.15rem 0;
    display: flex; gap: 0.3rem; align-items: baseline;
}
.dl-type {
    font-size: 0.6rem; color: var(--text-dim); text-transform: uppercase;
    background: var(--navy-card); padding: 0.1rem 0.3rem; border-radius: 3px;
    flex-shrink: 0;
}

/* ── Dashboard generate ── */
.dash-generate {
    text-align: center;
    padding: 1rem 0 2rem;
}
.btn-lg {
    padding: 1rem 3rem;
    font-size: 1.15rem;
    border-radius: 16px;
}

.loading-dots::after { content: ''; animation: dots 1.5s steps(4) infinite; }
@keyframes dots { 0%{content:''} 25%{content:'.'} 50%{content:'..'} 75%{content:'...'} }

/* Indeterminate progress bar animation */
@keyframes indeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}
.progress-bar .fill[style*="animation"] {
    width: 40% !important;
}

/* Script preview stream in loading screen */
.script-preview-stream {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
    max-height: 120px;
    overflow: hidden;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 3px; }

/* ═══════════════════════════════════
   LOADING SCREEN
   ═══════════════════════════════════ */
.loading-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
}

/* ═══════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════ */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse 80% 60% at 50% 30%, rgba(255,107,107,0.08) 0%, transparent 70%),
        var(--navy);
    padding: 2rem;
}
.login-card {
    background: var(--navy-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    animation: modalIn 0.4s ease;
}
.login-brand {
    font-family: 'Bangers', 'Plus Jakarta Sans', cursive;
    font-size: 3.5rem;
    letter-spacing: 0.06em;
    color: white;
    text-shadow: 3px 3px 0 var(--coral), 6px 6px 0 rgba(0,0,0,0.3);
    line-height: 1;
    margin: 0 0 1rem;
}
.login-tagline {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0 0 2rem;
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.85rem 1.5rem;
    background: white;
    color: #333;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.google-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.google-btn svg {
    flex-shrink: 0;
}

.dev-login {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.dev-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    text-align: center;
}
.dev-input:focus {
    border-color: var(--coral);
}
.dev-input::placeholder {
    color: var(--text-dim);
}

/* ═══════════════════════════════════
   APP HEADER (user bar)
   ═══════════════════════════════════ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.25rem;
    background: rgba(15,23,41,0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.header-brand {
    font-family: 'Bangers', 'Plus Jakarta Sans', cursive;
    font-size: 1.5rem;
    letter-spacing: 0.04em;
    color: white;
    text-shadow: 2px 2px 0 var(--coral);
    text-decoration: none;
    transition: opacity 0.2s;
}
.header-brand:hover { opacity: 0.85; }

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
}
.user-avatar-placeholder {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--coral);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}
.user-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.logout-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
}
.logout-link:hover {
    color: var(--coral);
    background: rgba(255,107,107,0.1);
}

/* Adjust fullscreen views when header is present */
.chat-fullscreen.has-header {
    height: calc(100vh - 47px);
}
.chat-fullscreen.has-header .chat-window {
    height: calc(100vh - 47px);
}
.dash-fullscreen.has-header {
    height: calc(100vh - 47px);
}

@media (max-width: 640px) {
    .brand-title { font-size: 3.5rem; }
    .features-grid { grid-template-columns: 1fr; max-width: 280px; }
    .recent-grid { grid-template-columns: repeat(2, 1fr); }
    .gen-grid, .result-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .chat-window { width: 100%; border: none; }
    .msg { max-width: 92%; }
    .floating-generate { right: 1rem; bottom: 75px; }
    .modal-card { padding: 1.5rem; }
    .style-grid { grid-template-columns: repeat(2, 1fr); }
    .char-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-scroll { padding: 1rem; }
    .dash-section { padding: 1rem; }
    .btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }
    .login-card { padding: 2rem 1.5rem; }
    .login-brand { font-size: 2.8rem; }
    .user-name { display: none; }
    .header-brand { font-size: 1.2rem; }
}
