@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@400..700&family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap');

:root {
    --bg-color: #f4f1ea;       /* Parchment */
    --text-color: #333;      /* Ink */
    --container-bg: rgba(255, 255, 255, 0.5); /* White transparent */
    --card-bg: #fff;         /* White */
    --ink: #333;
    --parchment: #f4f1ea;
    --white: #fff;
    --black: #000;
}

body.dark-mode {
    --bg-color: #333;        /* Ink */
    --text-color: #f4f1ea;   /* Parchment */
    --container-bg: rgba(0, 0, 0, 0.5); /* Black transparent */
    --card-bg: #000;         /* Black */
    --ink: #f4f1ea;
    --parchment: #333;
    --white: #000;
    --black: #fff;
}

html {
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Playfair Display', serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 800px;
    padding: 2rem;
    background: var(--container-bg);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 100%;
    transition: background 0.3s ease;
}

h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

@media (max-width: 600px) {
    h1 {
        font-size: 2.2rem;
    }
    .container {
        padding: 1rem;
        margin: 0;
        border-radius: 0;
    }
    .btn {
        width: 100%;
        margin-bottom: 10px;
        display: block;
    }
    #finalize-form {
        width: 100%;
    }
    #finalize-btn {
        padding: 15px 30px;
        font-size: 1.2em;
        border-radius: 8px;
    }
}

.quote {
    font-family: 'Dancing Script', cursive;
    font-size: 1.8rem;
    margin: 2rem 0;
    color: var(--text-color);
    opacity: 0.8;
}

.btn {
    display: inline-block;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease, color 0.3s ease;
    border: none;
    cursor: pointer;
    text-align: center;
    background-color: var(--ink);
    color: var(--white);
    font-family: 'Georgia', serif;
}

.btn:hover {
    opacity: 0.8;
}

.btn-primary {
    background-color: #28a745;
    color: #fff;
}

.btn-primary:hover {
    background-color: #218838;
}

.btn-purple {
    background-color: #6f42c1 !important;
    color: white !important;
}

.btn-red {
    background-color: #dc3545 !important;
    color: white !important;
}

.btn-pink {
    background-color: #e83e8c !important;
    color: white !important;
}

.btn-yellow {
    background-color: #ffc107 !important;
    color: #212529 !important;
}

.btn-orange {
    background-color: #fd7e14 !important;
    color: white !important;
}

/* Dark Mode Button Overrides */
/* Buttons WITHOUT a specific color class should adopt the theme's ink/white values */
body.dark-mode .btn:not(.btn-primary):not(.btn-save):not(.btn-blue):not(.btn-purple):not(.btn-d4a373):not(.btn-regen):not(.btn-typeset):not(.btn-gray):not(.btn-red):not(.btn-pink):not(.btn-yellow):not(.btn-orange) {
    background-color: var(--ink) !important;
    color: var(--white) !important;
}

/* Colored buttons should keep their colors in dark mode but ensure text is white for contrast */
body.dark-mode .btn-primary,
body.dark-mode .btn-save,
body.dark-mode .btn-blue,
body.dark-mode .btn-purple,
body.dark-mode .btn-d4a373,
body.dark-mode .btn-regen,
body.dark-mode .btn-typeset,
body.dark-mode .btn-gray,
body.dark-mode .btn-red,
body.dark-mode .btn-pink,
body.dark-mode .btn-orange {
    color: #fff !important;
}

body.dark-mode .btn-yellow {
    color: #212529 !important;
}

body.dark-mode .text-muted {
    color: #aaa; /* Lighter muted text for dark mode */
}

.emojis {
    font-size: 2.5rem;
    margin: 1rem 0;
}

footer {
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.6;
}

/* Loading Animation */
.ghost-typewriter {
    display: inline-block;
    animation: ghost-type 0.6s infinite ease-in-out alternate;
}

@keyframes ghost-type {
    0% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-10px) rotate(2deg); }
    100% { transform: translateY(0) rotate(-2deg); }
}

/* Scroll Containers and Content Boxes */
.scroll-container, .content-box, textarea, input {
    background-color: var(--card-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--text-color) !important;
}

.dark-mode-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--ink);
    color: var(--white);
    border: none;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    z-index: 10000;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* AI Editor Spinner */
.scribe-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #d4a373;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Edit Report Display */
#report-display {
    margin: 20px auto;
    padding: 15px;
    background: #fff8e7;
    border: 1px solid #d4a373;
    border-radius: 8px;
    font-family: 'Georgia', serif;
    max-width: 800px;
    text-align: left;
    white-space: normal;
    color: #3e2723;
    max-height: 400px;
    overflow-y: auto;
}

body.dark-mode #report-display {
    background: #2d2d2d; /* Charcoal */
    border-color: #555;
    color: #e0e0e0;
}

/* Diff Highlighting */
.diff-added {
    color: #155724;
    background-color: #d4edda;
    padding: 2px 0;
}

.diff-removed {
    color: #721c24;
    background-color: #f8d7da;
    padding: 2px 0;
    text-decoration: line-through;
}

body.dark-mode .diff-added {
    color: #d4edda;
    background-color: #1e4620;
}

body.dark-mode .diff-removed {
    color: #f8d7da;
    background-color: #4b1c20;
}

.diff-info {
    color: #0366d6;
    background-color: #f1f8ff;
}

body.dark-mode .diff-info {
    color: #79b8ff;
    background-color: #051e3c;
}

/* --- Consolidated Styles from Templates --- */

/* Scribe Loading Animation */
.scribe-loading-container {
    display: none;
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    pointer-events: none;
    text-align: center;
}

.scribe-loading-ghost {
    font-size: 4rem;
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.1));
}

.scribe-loading-text {
    font-family: 'Dancing Script', cursive;
    font-size: 1.2rem;
    color: #555;
    margin-top: 5px;
}

/* Config Styles */
.config-container { max-width: 800px; margin: 0 auto; padding: 20px; }
.config-section { margin-bottom: 30px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.tile { position: relative; border: 2px solid var(--text-color); border-radius: 8px; cursor: pointer; transition: all 0.3s; background: var(--card-bg); color: var(--text-color); }
.tile input { position: absolute; opacity: 0; cursor: pointer; }
.tile-content { padding: 15px; text-align: center; }
.tile input:checked + .tile-content { background-color: #007bff; color: white; border-color: #007bff; border-radius: 6px; }
.inputs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 15px; }
.input-group { display: flex; flex-direction: column; }
.input-group label { margin-bottom: 5px; font-weight: bold; }
.input-group input { padding: 8px; border: 1px solid var(--text-color); border-radius: 4px; text-align: center; width: 60px; background: var(--card-bg); color: var(--text-color); }
.stepper { display: flex; align-items: center; gap: 5px; }
.stepper button { 
    width: 35px; 
    height: 35px; 
    border: 1px solid var(--text-color); 
    background: var(--ink); 
    color: var(--white);
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}
.stepper button:active { background: #ddd; }
.stepper input { margin: 0; }

/* Novel and Container Widths */
.novel-container { max-width: 1000px; margin: 0 auto; padding: 20px; }
.novel-container-full { max-width: 100%; margin: 0 auto; padding: 20px; }

/* Edit and Action Groups */
.edit-selector-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}
.actions { 
    margin-top: 50px; 
    display: flex; 
    gap: 12px; 
    justify-content: center; 
    flex-wrap: wrap;
}

/* Scroll Containers and Content Boxes */
.scroll-container { 
    border: 1px solid var(--text-color); 
    border-radius: 8px; 
    padding: 20px; 
    background: var(--card-bg); 
    margin-bottom: 30px; 
    overflow-y: auto; 
}
.scroll-container-max300 { max-height: 300px; }
.scroll-container-max500 { max-height: 500px; }

.content-box-novel { 
    background: var(--card-bg); 
    border: 1px solid var(--text-color); 
    padding: 30px; 
    border-radius: 4px; 
    margin-bottom: 15px; 
    font-family: 'Georgia', serif; 
    font-size: 1.1em; 
    line-height: 1.8; 
    contain: content; 
}

/* Typography Overrides */
.text-left { text-align: left; }
.white-space-pre { white-space: pre-wrap; }
.font-georgia { font-family: 'Georgia', serif; }
.font-monospace { font-family: 'Courier New', Courier, monospace; }
.font-dancing { font-family: 'Dancing Script', cursive; }

/* Buttons */
.btn-save { background-color: #28a745 !important; color: white !important; }
.btn-regen { background-color: #28a745 !important; color: white !important; }
.btn-typeset { background-color: #007bff !important; color: white !important; }
.btn-blue { background-color: #007bff !important; color: white !important; }
.btn-gray { background-color: #6c757d !important; color: white !important; }

/* Media Queries */
@media (max-width: 600px) {
    .config-container { padding: 10px; }
    .tiles { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .inputs-grid { grid-template-columns: 1fr; }
    .edit-selector-group, .actions {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100%;
    }
    .btn-full-mobile {
        width: 100% !important;
        margin-bottom: 5px;
    }
    .novel-container { padding: 10px; }
    .scroll-container { padding: 10px; }
    .content-box-novel { padding: 15px; font-size: 1rem; }
}

/* Novel Page Specific */
#chapters-container { max-height: 60vh; }
.chapter-section { margin-bottom: 40px; }
.completed { color: #28a745; text-decoration: line-through; }
.chapter-input-wrapper { display: flex; align-items: center; gap: 10px; }
.chapter-input-wrapper .stepper input {
    text-align: center;
    height: 35px;
    border: 1px solid var(--text-color);
    background: var(--card-bg);
    color: var(--text-color);
    padding: 0 5px;
}

/* Status and Elements Display */
.status-display {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--card-bg);
    border: 1px solid var(--text-color);
    border-radius: 8px;
    text-align: center;
    font-family: 'Courier New', Courier, monospace;
}

.error-section {
    display: none;
    margin-top: 20px;
    padding: 15px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    color: #721c24;
    text-align: left;
    font-family: monospace;
    white-space: pre-wrap;
}

/* Welcome Page Specific */
.project-scroll-container {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 10px;
    margin-top: 10px;
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    font-family: 'Georgia', serif;
}

#scribe-loading-ghost-float {
    display: inline-block;
    animation: ghost-float 3s infinite ease-in-out;
}

@keyframes ghost-float {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.8; }
    50% { transform: translateY(-20px) rotate(5deg); opacity: 1; }
}

/* Utility Classes */
.text-small { font-size: 0.9em; }
.opacity-80 { opacity: 0.8; }
.mb-10 { margin-bottom: 10px; }
.mt-30 { margin-top: 30px; }
.gap-15 { gap: 15px; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.h-100 { height: 100px; }
.p-10 { padding: 10px; }
.br-8 { border-radius: 8px; }
.border-themed { border: 1px solid var(--text-color); }
.bg-card { background: var(--card-bg); }
.text-themed { color: var(--text-color); }
.font-inherit { font-family: inherit; }

.btn-large { padding: 15px 30px; font-size: 1.2em; border-radius: 8px; }
.flex-row-center { display: flex; gap: 15px; justify-content: center; margin-top: 30px; flex-wrap: wrap; }

/* Additional Utility and Component Classes */
.mb-30 { margin-bottom: 30px; }
.h-500 { height: 500px; }
.p-15 { padding: 15px; }
.p-20 { padding: 20px; }
.pl-20 { padding-left: 20px; }
.pb-10 { padding-bottom: 10px; }
.text-base { font-size: 1rem; }
.lh-1-4 { line-height: 1.4; }
.lh-1-8 { line-height: 1.8; }
.bg-f9f9f9 { background: #f9f9f9; }
.border-bottom-eee { border-bottom: 1px solid #eee; }
.off-screen { position: absolute; left: -9999px; }

.error-logs { max-height: 300px; overflow-y: auto; background: rgba(255,255,255,0.3); padding: 10px; border-radius: 4px; }
.author-display { display: none; margin: 20px auto; padding: 15px; background: var(--card-bg); border: 1px solid var(--text-color); border-radius: 8px; font-family: monospace; max-width: 600px; text-align: left; }
.story-details-section, .outline-display-section, .full-novel-section, .story-elements-section, .report-display-section { display: none; margin-top: 30px; border-top: 2px solid #eee; padding-top: 30px; }
.outline-display-section { border-top-color: var(--text-color); }
.story-elements-content { text-align: left; background: var(--card-bg); padding: 20px; border-radius: 8px; border: 1px solid var(--text-color); font-family: monospace; white-space: pre-wrap; overflow-x: auto; max-height: 400px; overflow-y: auto; }

/* Novel Template Specific Classes */
.ai-editing-notice {
    text-align: center;
    padding: 50px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 2px solid var(--text-color);
    margin: 30px 0;
}

.ai-editing-icon { font-size: 4em; margin-bottom: 20px; }
.ai-editing-title { font-family: 'Dancing Script', cursive; font-size: 2.5rem; color: #3e2723; }
.ai-editing-desc { font-size: 1.2rem; line-height: 1.6; color: #5d4037; max-width: 600px; margin: 0 auto 20px auto; }
.ai-editing-hint { font-style: italic; color: #8d6e63; }
.scribe-spinner-margin { margin: 30px auto; }

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.novel-title-input {
    display: none;
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    border: 1px solid var(--text-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    padding: 5px 10px;
    width: 80%;
    font-family: inherit;
}

.edit-textarea-novel {
    width: 100%;
    height: 400px;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-family: 'Georgia', serif;
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 15px;
}

.diff-display {
    display: none;
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: monospace;
    white-space: pre-wrap;
    overflow-x: auto;
    color: #333;
}

.word-count-helper { margin-top: 10px; font-size: 0.9em; color: #555; width: 100%; text-align: center; }
.regen-options-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-bottom: 15px;
    background: #fdfdfd;
    padding: 10px;
    border: 1px dashed #ccc;
    border-radius: 6px;
}
.regen-options-title {
    font-weight: bold;
    color: #444;
    margin-bottom: 5px;
    font-size: 0.95em;
}
.chapter-word-count-display {
    display: none;
    margin: 10px auto;
    padding: 10px;
    background: #fff8e7;
    border: 1px solid #d4a373;
    border-radius: 8px;
    font-family: 'Dancing Script', cursive;
    font-size: 1.2rem;
    max-width: 300px;
    text-align: center;
    color: #3e2723;
}

/* Cover Section */
.cover-section { margin-top: 30px; border-top: 2px solid var(--text-color); padding-top: 30px; }
.cover-gallery {
    display: none;
    gap: 15px;
    overflow-x: auto;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 20px;
    align-items: flex-end;
    border: 1px solid var(--text-color);
}
.cover-main-flex {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
}
.cover-img { max-width: 300px; display: none; border-radius: 8px; border: 1px solid var(--text-color); }
.cover-instructions {
    width: 100%;
    height: 100px;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid var(--text-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    margin-bottom: 10px;
}
.cover-actions-container { display: flex; gap: 10px; flex-wrap: wrap; }

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    width: 400px;
    text-align: center;
    border: 1px solid var(--text-color);
}
.color-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 20px 0; }

.cover-text-controls {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--text-color);
    background: rgba(0,0,0,0.05);
    padding: 15px;
    border-radius: 8px;
}
.control-group { margin-bottom: 15px; }
.control-input-themed {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--text-color);
    background: var(--bg-color);
    color: var(--text-color);
}
.control-flex-row { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.control-flex-1 { flex: 1; min-width: 150px; }
.control-w80 { width: 80px; }

/* Additional Missing Utility Classes */
.w-60 { width: 60px; }
.p-5 { padding: 5px; }
.br-4 { border-radius: 4px; }
.border-ccc { border: 1px solid #ccc; }
.display-none { display: none; }
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }

.btn-d4a373 { background-color: #d4a373 !important; color: white !important; }
.btn-purple { background-color: #6f42c1 !important; color: white !important; }

/* Blurb Section Specific */
.blurb-section { margin-top: 30px; border-top: 2px solid var(--text-color); padding-top: 30px; }
.blurb-display { max-height: 200px; margin-bottom: 15px; }
.blurb-edit-area {
    display: none;
    width: 100%;
    height: 200px;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--text-color);
    background: var(--card-bg);
    color: var(--text-color);
    font-family: 'Georgia', serif;
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 15px;
}
.blurb-feedback-container { margin-bottom: 15px; }
.blurb-feedback {
    width: 100%;
    height: 60px;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid var(--text-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
}
.blurb-controls { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; }
.blurb-edit-controls { display: none; gap: 15px; justify-content: center; flex-wrap: wrap; }

/* Large Word Count Display */
.word-count-display-large {
    display: none;
    margin: 20px auto;
    padding: 15px;
    background: #fff8e7;
    border: 1px solid #d4a373;
    border-radius: 8px;
    font-family: 'Dancing Script', cursive;
    font-size: 1.5rem;
    max-width: 400px;
    text-align: center;
    color: #3e2723;
}
.flex-column { display: flex; flex-direction: column; }
.mb-20 { margin-bottom: 20px; }

/* Results Template Specific Classes */
.results-container { max-width: 900px; margin: 0 auto; padding: 20px; }
.feedback-section textarea { width: 100%; height: 100px; padding: 10px; border-radius: 8px; border: 1px solid #ccc; margin-bottom: 10px; }
.finalize-section { margin-top: 50px; text-align: center; border-top: 2px solid #eee; padding-top: 30px; }

.gap-10 { gap: 10px; }

/* Typeset Template Specific Classes */
.typeset-status { margin-bottom: 20px; padding: 15px; background: var(--card-bg); border: 1px solid var(--text-color); border-radius: 8px; text-align: center; font-family: 'Courier New', Courier, monospace; }
.chapter-typeset-info { margin-top: 10px; font-weight: bold; color: #555; }
.emoji-progress-bar { font-size: 2em; margin-top: 10px; display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; }
.warning-status { margin-bottom: 20px; padding: 15px; background: #fff3cd; border: 1px solid #ffeeba; border-radius: 8px; color: #856404; text-align: center; font-family: monospace; display: none; }
.word-count-container { margin-top: 10px; width: 100%; text-align: center; }
.compilation-error-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.jumping { animation: jump 1s infinite; }
@keyframes jump { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* Welcome Template Specific Classes */
.revising-section { margin: 30px 0; padding: 20px; background: #fff8e7; border-radius: 8px; border: 1px solid #d4a373; }
body.dark-mode .revising-section { background: #3a2e22; border-color: #b07f4c; }
.resume-section, .finished-section { margin: 30px 0; padding: 20px; background: var(--container-bg); border-radius: 8px; border: 1px solid var(--text-color); }
.list-style-none { list-style: none; }
.p-0 { padding: 0; }
.my-10 { margin-top: 10px; margin-bottom: 10px; }
.my-20 { margin-top: 20px; margin-bottom: 20px; }
.w-80 { width: 80%; }
.min-w-120 { min-width: 120px; }
.mt-20 { margin-top: 20px; }
.font-italic { font-style: italic; }
.color-ccc { color: #ccc; }
.color-666 { color: #666; }
body.dark-mode .color-666 { color: #aaa; }

.loading-ghost-welcome { font-size: 3em; margin-bottom: 20px; display: inline-block; animation: ghost-float 3s infinite ease-in-out; }
.loading-message-welcome { font-size: 1.5em; max-width: 80%; line-height: 1.6; }

/* Final Muted Utility */
.text-muted { color: #777; }

/* Diff Container Class */
.diff-container { text-align: left; line-height: 1.6; }
.lh-1-6 { line-height: 1.6; }
.display-block { display: block; }

/* Gallery and Dynamic Component Classes */
.gallery-item-wrapper { text-align: center; flex-shrink: 0; position: relative; }
.gallery-img { border-radius: 4px; border: 1px solid var(--text-color); display: block; margin-bottom: 5px; transition: opacity 0.2s; }
.gallery-img-latest { width: 180px; border: 4px solid #007bff; }
.gallery-img-past { width: 100px; opacity: 0.7; cursor: pointer; }
.gallery-img-past:hover { opacity: 1; }
.gallery-aspect-indicator { position: absolute; top: 5px; right: 5px; font-size: 20px; background-color: rgba(255,255,255,0.7); border-radius: 50%; padding: 2px; line-height: 1; }
.gallery-restore-btn { padding: 4px 8px !important; font-size: 0.8em !important; width: 100% !important; }
.btn-small { padding: 4px 8px !important; font-size: 0.8em !important; height: auto !important; line-height: 1.2 !important; min-height: 0 !important; cursor: pointer; }
.gallery-current-label { font-size: 0.8em; font-weight: bold; }

.display-flex { display: flex !important; }
.order-first { order: -1; }

.color-tile { height: 50px; border: 1px solid #ccc; cursor: pointer; }
.modal-overlay-display { display: flex !important; }
.modal-overlay-none { display: none !important; }

.style-tile {
    background-color: rgba(128, 128, 128, 0.1);
    border: 1px solid rgba(128, 128, 128, 0.3);
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.85em;
    padding: 0 5px;
    text-align: center;
    color: var(--text-color);
}
.style-tile:hover {
    background-color: rgba(128, 128, 128, 0.2);
}
.style-tile-selected {
    border-color: #007bff !important;
    background-color: rgba(0, 123, 255, 0.15) !important;
    font-weight: bold !important;
}

/* Welcome Template Specific Styles */
.novel-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}
.novel-buttons-group-main {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}
.novel-buttons-group-matter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}
.novel-buttons-container .btn {
    flex: 1 1 120px;
    text-align: center;
    box-sizing: border-box;
}

@media (max-width: 480px) {
    .novel-buttons-container .btn {
        flex: 1 1 45%;
    }
}

/* Novel Template Text Styling & Modal Styles */
.cover-text-modal-content {
    width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}
.border-bottom-themed {
    border-bottom: 1px solid var(--text-color);
    padding-bottom: 15px;
}
.modal-h4-spacing {
    margin: 5px 0 10px 0;
}
.color-tiles-modal {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}
.selected-style-label {
    margin-top: 5px;
    font-weight: bold;
}
.style-tiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

.novel-info-displays-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.detail-scroll, .results-container .scroll-container {
    max-height: 400px;
    overflow-y: auto;
}

/* Story Elements Preview Page Styles */
.preview-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    text-align: left;
}
.preview-container h1 {
    text-align: center;
    margin-bottom: 10px;
}
.preview-subtitle {
    text-align: center;
    font-size: 1.1em;
    opacity: 0.8;
    margin-bottom: 40px;
    font-family: inherit;
}
.preview-section {
    background: var(--card-bg);
    border: 1px solid var(--text-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}
.preview-section h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.8rem;
    border-bottom: 1px solid var(--text-color);
    padding-bottom: 10px;
}
.preview-list {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}
.preview-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
body.dark-mode .preview-list-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.preview-list-item:last-child {
    border-bottom: none;
}
.preview-element-content {
    flex: 1;
    min-width: 0;
    max-height: 200px;
    overflow: auto;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.02);
}
body.dark-mode .preview-element-content {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}
.preview-element-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.preview-element-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
}
body.dark-mode .preview-element-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}
.preview-element-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}
body.dark-mode .preview-element-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}
.preview-element-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}
body.dark-mode .preview-element-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
.preview-element-content pre {
    margin: 0;
    white-space: pre;
    font-family: monospace;
    font-size: 0.9rem;
    padding: 10px;
    background: transparent;
}
.preview-element-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}
.modal-actions-align {
    justify-content: flex-end;
    margin-top: 15px;
}
.btn-modal-padding {
    padding: 8px 16px;
}
.button-group {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    width: 500px;
    max-width: 90%;
    text-align: left;
    border: 1px solid var(--text-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}
.modal-content h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.5rem;
}
.modal-textarea {
    width: 100%;
    height: 150px;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--text-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 20px;
}

/* Custom spacing for list items in content boxes */
.content-box ul li,
.content-box ol li {
    margin-bottom: 12px;
}
.content-box ul li:last-child,
.content-box ol li:last-child {
    margin-bottom: 0;
}

