/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --bg-color: #0f172a;
    --bg-secondary: #1e293b;
    --card-bg: #1e293b;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --border-radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background-color: var(--bg-secondary);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-color);
    background-color: rgba(99, 102, 241, 0.1);
}

.nav-links a.active {
    color: var(--primary-color);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.card h2 {
    margin-bottom: 1.25rem;
    font-size: 1.25rem;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
}

.alert-success {
    background-color: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.alert-error {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--warning-color);
    color: var(--warning-color);
}

.alert a {
    color: inherit;
    font-weight: 600;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group input:disabled,
.form-group select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #475569;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: var(--danger-hover);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

/* Generator Layout */
.generator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .generator-layout {
        grid-template-columns: 1fr;
    }
}

.generator-form {
    position: sticky;
    top: 80px;
    height: fit-content;
}

/* Character Info */
.character-info {
    background-color: var(--bg-color);
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.25rem;
}

.character-label {
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.character-name {
    color: var(--primary-color);
    font-weight: 600;
}

/* Progress */
.progress-container {
    margin-top: 1.5rem;
}

.progress-bar {
    height: 8px;
    background-color: var(--bg-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.3s;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.progress-text {
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
}

/* Preview Area */
.preview-content {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.preview-result {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.preview-image-container {
    border-radius: var(--border-radius);
    overflow: hidden;
}

.preview-image-container img {
    width: 100%;
    height: auto;
    display: block;
}

.preview-audio-container audio {
    width: 100%;
}

.preview-text-container h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.story-text {
    background-color: var(--bg-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    font-size: 0.9375rem;
    line-height: 1.7;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.preview-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Reference Images */
.reference-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.ref-image-item {
    position: relative;
}

.ref-image-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.ref-image-item .delete-form {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
}

.upload-form {
    grid-column: 1 / -1;
}

.info-text {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.gallery-item {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.gallery-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.gallery-info {
    padding: 1rem;
}

.gallery-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.meta-item {
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.meta-date {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.gallery-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.gallery-actions {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
}

.gallery-actions .btn {
    flex: 1;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
    position: relative;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.modal-small {
    max-width: 400px;
    text-align: center;
}

.modal-small h3 {
    margin-bottom: 1rem;
}

.modal-small p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-image img {
    width: 100%;
    border-radius: var(--border-radius);
}

.modal-audio audio {
    width: 100%;
}

.modal-text h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Page Title */
h1 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

/* ==================== SETTINGS PAGE (Compact) ==================== */

.settings-container {
    max-width: 1100px;
    padding: 1.5rem;
}

.settings-container .card {
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.settings-container .card h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0;
    overflow-x: auto;
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
    white-space: nowrap;
}

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

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

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

/* Section Description */
.section-desc {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.8125rem;
}

/* Form Grid - Two columns */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-grid.single-col {
    grid-template-columns: 1fr;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Compact Form Groups */
.settings-container .form-group {
    margin-bottom: 0.75rem;
}

.settings-container .form-group label {
    font-size: 0.75rem;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}

.settings-container .form-group input,
.settings-container .form-group select,
.settings-container .form-group textarea {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.settings-container textarea {
    min-height: 70px;
}

/* Input with Icon/Button */
.input-with-icon {
    display: flex;
    gap: 0.35rem;
}

.input-with-icon input {
    flex: 1;
}

.toggle-password {
    padding: 0.5rem 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.toggle-password:hover {
    color: var(--text-color);
    border-color: var(--primary-color);
}

.input-with-btn {
    display: flex;
    gap: 0.5rem;
}

.input-with-btn select {
    flex: 1;
}

/* Form Hint */
.form-hint {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-hint code {
    background: rgba(99, 102, 241, 0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.65rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.form-actions .btn {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

/* Settings Grid - Compact */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

/* Setting Item (Sliders) - Compact */
.setting-item {
    background: var(--bg-color);
    padding: 0.75rem;
    border-radius: var(--border-radius);
}

.setting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.setting-header label {
    font-weight: 500;
    font-size: 0.75rem;
    margin: 0;
}

.setting-value {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 600;
}

.setting-item .form-hint {
    margin-top: 0.35rem;
    font-size: 0.65rem;
}

/* Range Slider - Compact */
input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Toggle Switch - Compact */
.toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.toggle input {
    display: none;
}

.toggle-slider {
    width: 36px;
    height: 20px;
    background: var(--border-color);
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

.toggle-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Character Layout - Compact */
.character-layout {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .character-layout {
        grid-template-columns: 1fr;
    }
}

.character-info-section {
    display: flex;
    flex-direction: column;
}

.reference-section h3 {
    font-size: 0.875rem;
    margin-bottom: 0.35rem;
}

/* Reference Grid (Settings) - Compact */
.reference-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.reference-grid .ref-image-item {
    position: relative;
    aspect-ratio: 1;
}

.reference-grid .ref-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.ref-delete-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 20px;
    height: 20px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.ref-image-item:hover .ref-delete-btn {
    opacity: 1;
}

/* Upload Area - Compact */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-placeholder {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.upload-icon {
    font-size: 1.25rem;
    color: var(--primary-color);
}

/* Options Grid - Compact */
.options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 800px) {
    .options-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .options-grid {
        grid-template-columns: 1fr;
    }
}

.option-section h3 {
    font-size: 0.875rem;
    margin-bottom: 0.2rem;
}

.option-section .form-hint {
    margin-bottom: 0.5rem;
}

/* Tag Input - Compact */
.tag-input-container {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.4rem;
    min-height: 80px;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
}

.tag-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    font-size: 0.875rem;
}

.tag-remove:hover {
    opacity: 1;
}

.tag-input-container input {
    width: 100%;
    background: transparent;
    border: none;
    padding: 0.35rem;
    color: var(--text-color);
    font-size: 0.8125rem;
}

.tag-input-container input:focus {
    outline: none;
}

/* Subjects List */
.subjects-list {
    margin-bottom: 0.75rem;
}

.subject-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
}

.subject-item .subject-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.subject-item .subject-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subject-item .subject-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.subject-upload-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 0.5rem;
}

.subject-name-input {
    flex: 1;
    min-width: 150px;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.875rem;
}

.subject-name-input::placeholder {
    color: var(--text-muted);
}

.subject-name-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.upload-area-inline {
    min-height: auto;
    padding: 0;
    border: none;
    background: none;
    flex-shrink: 0;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-success {
    background: var(--success-color);
}

.toast-error {
    background: var(--danger-color);
}

.toast-info {
    background: var(--primary-color);
}

.toast.hidden {
    display: none;
}

/* ==================== GENERATE PAGE ==================== */

.generate-container {
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 80px);
    justify-content: center;
    padding-top: 1rem;
    padding-bottom: 2rem;
}

.generate-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    width: 100%;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.character-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.character-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--primary-color);
}

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

.character-details h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    color: var(--text-color);
}

.character-details p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.generate-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
    .generate-options {
        grid-template-columns: 1fr;
    }
}

.background-selector {
    margin-bottom: 1.5rem;
}

.background-selector > label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 500;
    color: var(--text-color);
}

.background-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
}

.background-item {
    aspect-ratio: 1;
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid var(--border-color);
    transition: all 0.2s;
}

.background-item:hover {
    border-color: var(--primary-color);
}

.background-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.background-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bg-none {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.btn-generate {
    width: 100%;
    padding: 1rem;
    font-size: 1.125rem;
}

.btn-generate .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    margin-right: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.generate-progress {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.progress-status {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.75rem;
}

/* ==================== SETTINGS BACKGROUNDS ==================== */

.prompt-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.background-grid-settings {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.bg-image-item {
    position: relative;
    aspect-ratio: 16/9;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.bg-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bg-delete-btn {
    position: absolute;
    top: 0.375rem;
    right: 0.375rem;
    width: 24px;
    height: 24px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.bg-image-item:hover .bg-delete-btn {
    opacity: 1;
}

/* Subsection Title - Compact */
.subsection-title {
    font-size: 0.8125rem;
    color: var(--text-color);
    margin-top: 1rem;
    margin-bottom: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* ==================== MUSIC LIST (Compact) ==================== */

.music-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.no-music {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 0.75rem;
    font-size: 0.8125rem;
}

/* Speech Pattern */
.speech-pattern-display {
    margin-bottom: 1rem;
}

.speech-pattern-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
}

.music-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-color);
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.music-item:hover {
    border-color: var(--primary-color);
}

.music-item.selected {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.music-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.music-icon {
    font-size: 1rem;
    color: var(--primary-color);
}

.music-name {
    font-weight: 500;
    font-size: 0.8125rem;
}

.music-actions {
    display: flex;
    gap: 0.35rem;
}

.music-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
}

.music-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 0.35rem;
}

.music-selected-badge {
    background: var(--primary-color);
    color: white;
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
    border-radius: 8px;
    margin-left: 0.35rem;
    text-transform: uppercase;
    font-weight: 600;
}

/* Prompt Placeholders - Compact */
.prompt-placeholders {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.placeholder-title {
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.placeholder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.35rem;
}

.placeholder-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    padding: 0.2rem 0;
}

.placeholder-item code {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-color);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.65rem;
    white-space: nowrap;
}

.placeholder-item span {
    color: var(--text-muted);
    font-size: 0.65rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== CINEMATIC EXPERIENCE ==================== */

/* Cinematic Page Base */
.cinematic-page {
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    background: #000;
}

.cinematic-page .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
    border-bottom: none;
    padding: 1.5rem 2rem;
    z-index: 100;
    transition: opacity 0.5s ease;
}

.cinematic-page .navbar:hover {
    background: linear-gradient(to bottom, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.3) 100%);
}

.cinematic-page .nav-brand {
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.9);
}

.cinematic-page .nav-links a {
    color: rgba(255,255,255,0.6);
    font-weight: 300;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.875rem;
    padding: 0.5rem 1.25rem;
    border-radius: 0;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
}

.cinematic-page .nav-links a:hover,
.cinematic-page .nav-links a.active {
    color: rgba(255,255,255,1);
    background: transparent;
    border-bottom-color: rgba(255,255,255,0.5);
}

/* Cinematic Background Slideshow */
.cinematic-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.cinematic-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 2s ease-in-out;
    will-change: opacity, transform;
}

.cinematic-slide.active {
    opacity: 1;
}

.cinematic-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.4) saturate(0.8);
}

.cinematic-slide.ken-burns-1 img {
    animation: kenBurns1 20s ease-in-out infinite;
}

.cinematic-slide.ken-burns-2 img {
    animation: kenBurns2 20s ease-in-out infinite;
}

.cinematic-slide.ken-burns-3 img {
    animation: kenBurns3 20s ease-in-out infinite;
}

.cinematic-slide.ken-burns-4 img {
    animation: kenBurns4 20s ease-in-out infinite;
}

@keyframes kenBurns1 {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.15) translate(-2%, -1%); }
}

@keyframes kenBurns2 {
    0% { transform: scale(1.1) translate(-1%, 0); }
    100% { transform: scale(1) translate(1%, 1%); }
}

@keyframes kenBurns3 {
    0% { transform: scale(1) translate(0, -1%); }
    100% { transform: scale(1.12) translate(1%, 0); }
}

@keyframes kenBurns4 {
    0% { transform: scale(1.15) translate(1%, 1%); }
    100% { transform: scale(1) translate(-1%, -1%); }
}

/* Cinematic Overlays */
.cinematic-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.cinematic-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.7) 100%),
        linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, transparent 20%, transparent 80%, rgba(0,0,0,0.5) 100%);
}

.cinematic-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0,0,0,0.03) 2px,
        rgba(0,0,0,0.03) 4px
    );
    animation: scanlines 10s linear infinite;
}

@keyframes scanlines {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

/* Film Grain Effect */
.film-grain {
    position: fixed;
    top: -100%;
    left: -100%;
    width: 300%;
    height: 300%;
    z-index: 2;
    pointer-events: none;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    animation: grain 0.5s steps(1) infinite;
}

@keyframes grain {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-1%, -1%); }
    20% { transform: translate(1%, 1%); }
    30% { transform: translate(-1%, 1%); }
    40% { transform: translate(1%, -1%); }
    50% { transform: translate(-1%, 0); }
    60% { transform: translate(1%, 0); }
    70% { transform: translate(0, 1%); }
    80% { transform: translate(0, -1%); }
    90% { transform: translate(1%, 1%); }
}

/* ==================== CINEMATIC GENERATE PAGE ==================== */

.cinematic-generate {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem 2rem;
}

.cinematic-card {
    background: rgba(15, 20, 30, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    max-width: 520px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow:
        0 25px 50px rgba(0,0,0,0.5),
        0 0 100px rgba(99, 102, 241, 0.1),
        inset 0 1px 0 rgba(255,255,255,0.05);
    animation: cardAppear 1s ease-out;
}

@keyframes cardAppear {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cinematic-card .character-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.cinematic-card .character-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow:
        0 0 20px rgba(99, 102, 241, 0.3),
        0 5px 20px rgba(0,0,0,0.4);
    transition: all 0.5s ease;
    flex-shrink: 0;
}

.cinematic-card .character-avatar:hover {
    border-color: rgba(99, 102, 241, 0.5);
    transform: scale(1.05);
    box-shadow:
        0 0 30px rgba(99, 102, 241, 0.5),
        0 10px 30px rgba(0,0,0,0.5);
}

.cinematic-card .character-details h1 {
    font-size: 1.25rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.95);
    margin-bottom: 0.15rem;
}

.cinematic-card .character-details p {
    color: rgba(255,255,255,0.4);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.cinematic-card .generate-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.cinematic-card .form-group {
    margin-bottom: 0;
}

.cinematic-card .form-group label {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    margin-bottom: 0.4rem;
}

.cinematic-card .form-group select {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    color: rgba(255,255,255,0.9);
    font-size: 0.85rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.cinematic-card .form-group select:hover {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(0,0,0,0.5);
}

.cinematic-card .form-group select:focus {
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
    outline: none;
}

.cinematic-card .form-group select option {
    background: #1a1f2e;
    color: white;
}

.cinematic-card .background-selector {
    margin-bottom: 1rem;
}

.cinematic-card .background-selector > label {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    margin-bottom: 0.4rem;
    display: block;
}

.cinematic-card .background-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.35rem;
}

.cinematic-card .background-item {
    aspect-ratio: 1;
    border-radius: 6px;
    border: 2px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
    overflow: hidden;
}

.cinematic-card .background-item:hover {
    border-color: rgba(99, 102, 241, 0.5);
    transform: scale(1.05);
}

.cinematic-card .background-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.cinematic-card .bg-none {
    background: rgba(255,255,255,0.05);
    font-size: 0.55rem;
    color: rgba(255,255,255,0.4);
}

/* Cinematic Generate Button */
.cinematic-btn {
    width: 100%;
    padding: 0.85rem 1.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--primary-color) 0%, #818cf8 100%);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.4s ease;
}

.cinematic-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.cinematic-btn:hover::before {
    left: 100%;
}

.cinematic-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow:
        0 10px 40px rgba(99, 102, 241, 0.4),
        0 0 60px rgba(99, 102, 241, 0.2);
}

.cinematic-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cinematic-btn .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    margin-right: 0.75rem;
}

.cinematic-btn .btn-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Cinematic Progress */
.cinematic-card .generate-progress {
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: 1rem;
    padding-top: 1rem;
}

.cinematic-card .progress-bar {
    height: 3px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}

.cinematic-card .progress-fill {
    background: linear-gradient(90deg, var(--primary-color), #818cf8, var(--primary-color));
    background-size: 200% 100%;
    animation: progressShine 2s ease infinite;
}

@keyframes progressShine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.cinematic-card .progress-status {
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    margin-top: 0.5rem;
}

/* Alert in Cinematic Mode */
.cinematic-generate .alert {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 10px;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    max-width: 520px;
    text-align: center;
    font-size: 0.85rem;
}

/* Empty Background State */
.cinematic-empty-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(129, 140, 248, 0.1) 0%, transparent 50%),
        linear-gradient(135deg, #0a0a12 0%, #151520 50%, #0a0a12 100%);
    z-index: 0;
}

/* ==================== CINEMATIC GALLERY PAGE ==================== */

.cinematic-gallery {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    padding: 8rem 3rem 3rem;
}

.cinematic-gallery-header {
    text-align: center;
    margin-bottom: 4rem;
    animation: fadeInUp 0.8s ease-out;
}

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

.cinematic-gallery-header h1 {
    font-size: 3rem;
    font-weight: 200;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.9);
    margin-bottom: 0.5rem;
}

.cinematic-gallery-header p {
    color: rgba(255,255,255,0.4);
    font-size: 0.875rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* Cinematic Gallery Grid */
.cinematic-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Cinematic Gallery Item - Movie Poster Style */
.cinematic-gallery-item {
    position: relative;
    background: rgba(15, 20, 30, 0.6);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    animation: itemAppear 0.6s ease-out backwards;
    cursor: pointer;
}

.cinematic-gallery-item:nth-child(1) { animation-delay: 0.1s; }
.cinematic-gallery-item:nth-child(2) { animation-delay: 0.15s; }
.cinematic-gallery-item:nth-child(3) { animation-delay: 0.2s; }
.cinematic-gallery-item:nth-child(4) { animation-delay: 0.25s; }
.cinematic-gallery-item:nth-child(5) { animation-delay: 0.3s; }
.cinematic-gallery-item:nth-child(6) { animation-delay: 0.35s; }

@keyframes itemAppear {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cinematic-gallery-item:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow:
        0 30px 60px rgba(0,0,0,0.5),
        0 0 80px rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
}

.cinematic-gallery-image {
    position: relative;
    aspect-ratio: 3/4;
    overflow: hidden;
    display: block;
}

.cinematic-gallery-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.7s ease;
    filter: brightness(0.9);
}

.cinematic-gallery-item:hover .cinematic-gallery-image img {
    transform: scale(1.08);
    filter: brightness(1);
}

/* Image Overlay Gradient */
.cinematic-gallery-image::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70%;
    background: linear-gradient(to top, rgba(10,10,18,0.98) 0%, rgba(10,10,18,0.7) 40%, transparent 100%);
    pointer-events: none;
}

/* Play Button Overlay */
.cinematic-play-overlay {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 60px;
    height: 60px;
    background: rgba(99, 102, 241, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.4s ease;
    z-index: 2;
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.5);
}

.cinematic-play-overlay::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 18px solid white;
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    margin-left: 4px;
}

.cinematic-gallery-item:hover .cinematic-play-overlay {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Gallery Info Section */
.cinematic-gallery-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem;
    z-index: 3;
}

.cinematic-gallery-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.cinematic-type-badge {
    background: linear-gradient(135deg, var(--primary-color) 0%, #818cf8 100%);
    color: white;
    padding: 0.35rem 0.875rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.cinematic-date {
    color: rgba(255,255,255,0.4);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.cinematic-gallery-story-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.cinematic-gallery-title {
    color: rgba(255,255,255,0.9);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 0.25rem;
}

.cinematic-gallery-subtitle {
    color: rgba(255,255,255,0.4);
    font-size: 0.8rem;
}

/* Gallery Actions */
.cinematic-gallery-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 5;
}

.cinematic-gallery-item:hover .cinematic-gallery-actions {
    opacity: 1;
    transform: translateY(0);
}

.cinematic-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.cinematic-action-btn:hover {
    background: rgba(99, 102, 241, 0.8);
    border-color: rgba(99, 102, 241, 0.5);
    color: white;
    transform: scale(1.1);
}

.cinematic-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.8);
    border-color: rgba(239, 68, 68, 0.5);
}

/* Cinematic Empty State */
.cinematic-empty-state {
    text-align: center;
    padding: 6rem 2rem;
    animation: fadeInUp 0.8s ease-out;
}

.cinematic-empty-state p {
    font-size: 1.25rem;
    color: rgba(255,255,255,0.5);
    margin-bottom: 2rem;
    letter-spacing: 0.1em;
}

.cinematic-empty-state .btn {
    padding: 1rem 2rem;
    font-size: 0.875rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* Cinematic Modal */
.cinematic-page .modal {
    z-index: 1000;
}

.cinematic-page .modal-backdrop {
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(10px);
}

.cinematic-page .modal-content {
    background: rgba(20, 25, 35, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.6);
    max-width: 600px;
}

.cinematic-page .modal-close {
    color: rgba(255,255,255,0.5);
    font-size: 1.75rem;
}

.cinematic-page .modal-close:hover {
    color: white;
}

.cinematic-page .modal-small {
    background: rgba(20, 25, 35, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    max-width: 400px;
    padding: 2rem;
}

.cinematic-page .modal-small h3 {
    color: rgba(255,255,255,0.9);
    font-weight: 400;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

.cinematic-page .modal-small p {
    color: rgba(255,255,255,0.5);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.cinematic-page .modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.cinematic-page .modal-actions .btn {
    min-width: 100px;
    padding: 0.75rem 1.5rem;
}

.cinematic-page .modal-text {
    max-height: 300px;
    overflow-y: auto;
}

.cinematic-page .modal-text h3 {
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.cinematic-page .modal-text .story-text {
    color: rgba(255,255,255,0.85);
    line-height: 1.8;
    font-size: 0.95rem;
}

/* Responsive Cinematic */
@media (max-width: 768px) {
    .cinematic-page .navbar {
        padding: 1rem 1.5rem;
    }

    .cinematic-page .nav-brand {
        font-size: 1rem;
        letter-spacing: 0.2em;
    }

    .cinematic-page .nav-links {
        gap: 0.5rem;
    }

    .cinematic-page .nav-links a {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    .cinematic-generate {
        padding: 5rem 1rem 1rem;
    }

    .cinematic-card {
        padding: 1.25rem;
        border-radius: 14px;
    }

    .cinematic-card .character-avatar {
        width: 48px;
        height: 48px;
    }

    .cinematic-card .character-details h1 {
        font-size: 1.1rem;
    }

    .cinematic-card .generate-options {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .cinematic-card .form-group select {
        padding: 0.5rem 0.6rem;
        font-size: 0.8rem;
    }

    .cinematic-card .background-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .cinematic-btn {
        padding: 0.7rem 1rem;
        font-size: 0.75rem;
    }

    .cinematic-gallery {
        padding: 6rem 1rem 2rem;
    }

    .cinematic-gallery-header h1 {
        font-size: 1.75rem;
        letter-spacing: 0.2em;
    }

    .cinematic-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }
}

/* Large screens - expand card */
@media (min-width: 1400px) {
    .cinematic-card {
        max-width: 580px;
        padding: 2rem;
    }

    .cinematic-card .character-avatar {
        width: 64px;
        height: 64px;
    }

    .cinematic-card .character-details h1 {
        font-size: 1.4rem;
    }

    .cinematic-card .generate-options {
        gap: 1rem;
    }

    .cinematic-card .form-group select {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .cinematic-btn {
        padding: 1rem 1.5rem;
        font-size: 0.85rem;
    }
}

/* Medium screens */
@media (min-width: 769px) and (max-width: 1024px) {
    .cinematic-card {
        max-width: 480px;
        padding: 1.25rem;
    }

    .cinematic-card .generate-options {
        gap: 0.6rem;
    }

    .cinematic-card .form-group select {
        padding: 0.55rem 0.7rem;
        font-size: 0.8rem;
    }

    .cinematic-card .background-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Small height screens - ultra compact */
@media (max-height: 700px) {
    .cinematic-generate {
        padding: 4rem 1rem 1rem;
    }

    .cinematic-card {
        padding: 1rem;
    }

    .cinematic-card .character-header {
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
        gap: 0.75rem;
    }

    .cinematic-card .character-avatar {
        width: 40px;
        height: 40px;
    }

    .cinematic-card .character-details h1 {
        font-size: 1rem;
    }

    .cinematic-card .character-details p {
        font-size: 0.6rem;
    }

    .cinematic-card .generate-options {
        margin-bottom: 0.75rem;
        gap: 0.5rem;
    }

    .cinematic-card .form-group label {
        font-size: 0.6rem;
        margin-bottom: 0.25rem;
    }

    .cinematic-card .form-group select {
        padding: 0.45rem 0.5rem;
        font-size: 0.75rem;
        border-radius: 6px;
    }

    .cinematic-card .background-selector {
        margin-bottom: 0.75rem;
    }

    .cinematic-card .background-grid {
        gap: 0.25rem;
    }

    .cinematic-btn {
        padding: 0.6rem 1rem;
        font-size: 0.7rem;
        border-radius: 8px;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    .cinematic-card {
        padding: 1rem;
        border-radius: 12px;
    }

    .cinematic-card .character-header {
        gap: 0.75rem;
    }

    .cinematic-card .character-avatar {
        width: 40px;
        height: 40px;
    }

    .cinematic-card .character-details h1 {
        font-size: 1rem;
    }

    .cinematic-card .background-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==================== WELCOME SCREEN OVERLAY ==================== */

.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(10, 15, 30, 0.95) 0%, rgba(0, 0, 0, 0.98) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease;
}

.welcome-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.welcome-overlay.hidden {
    display: none;
}

.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 3rem;
    cursor: pointer;
    text-align: center;
}

.welcome-avatar {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid rgba(99, 102, 241, 0.5);
    box-shadow:
        0 0 60px rgba(99, 102, 241, 0.3),
        0 0 120px rgba(99, 102, 241, 0.15),
        inset 0 0 30px rgba(0, 0, 0, 0.3);
    animation: avatarGlow 3s ease-in-out infinite;
    transition: all 0.4s ease;
}

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

.welcome-content:hover .welcome-avatar {
    border-color: rgba(99, 102, 241, 0.8);
    box-shadow:
        0 0 80px rgba(99, 102, 241, 0.5),
        0 0 150px rgba(99, 102, 241, 0.25),
        inset 0 0 30px rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}

.welcome-content:hover .welcome-avatar img {
    transform: scale(1.1);
}

@keyframes avatarGlow {
    0%, 100% {
        box-shadow:
            0 0 60px rgba(99, 102, 241, 0.3),
            0 0 120px rgba(99, 102, 241, 0.15),
            inset 0 0 30px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow:
            0 0 80px rgba(99, 102, 241, 0.4),
            0 0 140px rgba(99, 102, 241, 0.2),
            inset 0 0 30px rgba(0, 0, 0, 0.3);
    }
}

.welcome-name {
    font-size: 2.5rem;
    font-weight: 300;
    color: white;
    margin: 0;
    letter-spacing: 0.1em;
    text-shadow: 0 0 30px rgba(99, 102, 241, 0.5);
}

.welcome-subtitle {
    font-size: 1rem;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

.welcome-btn {
    margin-top: 1.5rem;
    padding: 1rem 3rem;
    background: rgba(99, 102, 241, 0.2);
    border: 2px solid rgba(99, 102, 241, 0.4);
    border-radius: 50px;
    color: white;
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.4s ease;
    animation: btnPulse 2s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
    }
    50% {
        box-shadow: 0 0 40px rgba(99, 102, 241, 0.4);
    }
}

.welcome-btn:hover {
    background: rgba(99, 102, 241, 0.4);
    border-color: rgba(99, 102, 241, 0.7);
    transform: scale(1.05);
    box-shadow: 0 0 50px rgba(99, 102, 241, 0.5);
}

/* Ambient Music Settings Display */
.ambient-music-display {
    margin-bottom: 0.75rem;
}

.ambient-music-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-color);
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

/* Mobile adjustments for welcome overlay */
@media (max-width: 768px) {
    .welcome-content {
        padding: 2rem;
        gap: 1rem;
    }

    .welcome-avatar {
        width: 140px;
        height: 140px;
    }

    .welcome-name {
        font-size: 1.8rem;
    }

    .welcome-subtitle {
        font-size: 0.85rem;
    }

    .welcome-btn {
        padding: 0.8rem 2rem;
        font-size: 0.95rem;
    }
}

@media (max-width: 400px) {
    .welcome-avatar {
        width: 120px;
        height: 120px;
    }

    .welcome-name {
        font-size: 1.5rem;
    }

    .welcome-btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.85rem;
    }
}

/* ==================== SUPPLEMENTAL STORY INPUT ==================== */

.supplemental-section {
    margin-bottom: 1rem;
}

.supplemental-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: rgba(255,255,255,0.03);
    border: 1px dashed rgba(255,255,255,0.15);
    border-radius: 8px;
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.supplemental-toggle:hover {
    border-color: rgba(99, 102, 241, 0.4);
    color: rgba(255,255,255,0.7);
    background: rgba(99, 102, 241, 0.05);
}

.supplemental-toggle.active {
    border-color: rgba(99, 102, 241, 0.3);
    border-style: solid;
    background: rgba(99, 102, 241, 0.05);
    color: rgba(255,255,255,0.7);
}

.supplemental-icon {
    font-size: 1rem;
    color: var(--primary-color);
    transition: transform 0.3s ease;
}

.supplemental-toggle.active .supplemental-icon {
    transform: rotate(45deg);
}

.supplemental-input {
    margin-top: 0.5rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.supplemental-input textarea {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 0.75rem;
    color: rgba(255,255,255,0.9);
    font-size: 0.85rem;
    resize: vertical;
    min-height: 60px;
    transition: all 0.3s ease;
}

.supplemental-input textarea:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

.supplemental-input textarea::placeholder {
    color: rgba(255,255,255,0.35);
    font-style: italic;
}

.supplemental-input textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile adjustments for supplemental input */
@media (max-width: 768px) {
    .supplemental-toggle {
        padding: 0.5rem 0.6rem;
        font-size: 0.7rem;
    }

    .supplemental-input textarea {
        padding: 0.6rem;
        font-size: 0.8rem;
    }
}

/* ==================== PIN INPUT FOR WELCOME SCREEN ==================== */

.welcome-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.pin-input {
    width: 200px;
    padding: 0.85rem 1.25rem;
    font-size: 1.25rem;
    text-align: center;
    letter-spacing: 0.3em;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: white;
    outline: none;
    transition: all 0.3s ease;
}

.pin-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.9rem;
    letter-spacing: 0.1em;
}

.pin-input:focus {
    border-color: rgba(99, 102, 241, 0.6);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.2);
}

.pin-error {
    color: #ef4444;
    font-size: 0.85rem;
    margin: 0;
    animation: fadeIn 0.3s ease;
}

/* Shake animation for invalid input */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease;
}

/* Mobile adjustments for PIN */
@media (max-width: 768px) {
    .pin-input {
        width: 180px;
        padding: 0.75rem 1rem;
        font-size: 1.1rem;
    }
}

@media (max-width: 400px) {
    .pin-input {
        width: 160px;
        padding: 0.65rem 0.85rem;
        font-size: 1rem;
    }
}

/* ==================== MUSIC CONTROL BUTTON ==================== */

.music-control {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 500;
    opacity: 0.6;
    transition: all 0.3s ease;
}

.music-control:hover {
    opacity: 1;
}

.music-control.playing {
    opacity: 0.9;
}

.music-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(15, 20, 30, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.music-toggle:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: rgba(99, 102, 241, 0.5);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(99, 102, 241, 0.3);
}

.music-control.playing .music-toggle {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    animation: musicPulse 2s ease-in-out infinite;
}

@keyframes musicPulse {
    0%, 100% {
        box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
    }
    50% {
        box-shadow: 0 0 25px rgba(99, 102, 241, 0.4);
    }
}

.music-icon {
    font-size: 1.25rem;
    line-height: 1;
}

/* Mobile adjustments for music control */
@media (max-width: 768px) {
    .music-control {
        bottom: 1.5rem;
        right: 1.5rem;
    }

    .music-toggle {
        width: 42px;
        height: 42px;
    }

    .music-icon {
        font-size: 1.1rem;
    }
}

@media (max-width: 400px) {
    .music-control {
        bottom: 1rem;
        right: 1rem;
    }

    .music-toggle {
        width: 38px;
        height: 38px;
    }

    .music-icon {
        font-size: 1rem;
    }
}

/* Input hint for settings */
.input-hint {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ==================== ADMIN PIN OVERLAY (Settings Page) ==================== */

.admin-pin-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

.admin-pin-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.admin-pin-overlay.hidden {
    display: none;
}

.admin-pin-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 3rem;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.admin-pin-icon {
    font-size: 3rem;
    line-height: 1;
}

.admin-pin-content h2 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-color);
    margin: 0;
}

.admin-pin-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.admin-pin-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.admin-pin-input {
    width: 180px;
    padding: 0.75rem 1rem;
    font-size: 1.25rem;
    text-align: center;
    letter-spacing: 0.3em;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-color);
    outline: none;
    transition: all 0.3s ease;
}

.admin-pin-input::placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
    letter-spacing: 0.1em;
}

.admin-pin-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.admin-pin-error {
    color: var(--danger-color);
    font-size: 0.85rem;
    margin: 0;
}

.admin-pin-btn {
    padding: 0.75rem 2rem;
    background: var(--primary-color);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 140px;
}

.admin-pin-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

.admin-pin-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.admin-pin-back {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.2s ease;
    margin-top: 0.5rem;
}

.admin-pin-back:hover {
    color: var(--primary-color);
}

/* ==================== COMBO INPUT (Select + Manual Entry) ==================== */

.combo-input {
    position: relative;
    width: 100%;
}

.combo-input input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.combo-input input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.combo-input input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.05);
}

.combo-input input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Style datalist dropdown (browser-specific) */
.combo-input input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.5;
    cursor: pointer;
}

/* Settings page combo input */
.settings-container .combo-input input {
    background: var(--bg-color);
    border-color: var(--border-color);
    color: var(--text-color);
}

.settings-container .combo-input input::placeholder {
    color: var(--text-muted);
}

.settings-container .combo-input input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
