:root {
    --bg-dark: #08090d;
    --bg-card: rgba(22, 20, 31, 0.75);
    --bg-sidebar: #0e0e17;
    --border-color: rgba(255, 120, 37, 0.25);
    --border-highlight: rgba(255, 145, 77, 0.5);
    --primary-orange: #ff7825;
    --primary-hover: #ff914d;
    --accent-purple: #a855f7;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --font-serif: 'Merriweather', serif;
}

/* APP THEMES */
:root[data-app-theme="luxury-gold"] {
    --bg-dark: #0a0907;
    --bg-card: rgba(28, 24, 18, 0.85);
    --bg-sidebar: #120f0a;
    --border-color: rgba(212, 175, 55, 0.3);
    --border-highlight: rgba(255, 215, 0, 0.6);
    --primary-orange: #d4af37;
    --primary-hover: #ffd700;
    --accent-purple: #e5c158;
    --text-main: #fcf8ee;
    --text-muted: #b8ab8e;
}

:root[data-app-theme="shinkai-sunset"] {
    --bg-dark: #0c0d1a;
    --bg-card: rgba(25, 22, 45, 0.8);
    --bg-sidebar: #101124;
    --border-color: rgba(244, 114, 182, 0.3);
    --border-highlight: rgba(251, 146, 60, 0.6);
    --primary-orange: #f43f5e;
    --primary-hover: #fb923c;
    --accent-purple: #c084fc;
    --text-main: #fdf2f8;
    --text-muted: #f472b6;
}

:root[data-app-theme="clean-paper"] {
    --bg-dark: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #f1f5f9;
    --border-color: rgba(203, 213, 225, 0.8);
    --border-highlight: rgba(59, 130, 246, 0.5);
    --primary-orange: #2563eb;
    --primary-hover: #1d4ed8;
    --accent-purple: #7c3aed;
    --text-main: #0f172a;
    --text-muted: #64748b;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.studio-header {
    background: rgba(14, 14, 23, 0.95);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 24px;
    backdrop-filter: blur(12px);
    z-index: 100;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 10px rgba(255, 120, 37, 0.5));
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand-highlight {
    color: var(--primary-hover);
}

.brand-sub {
    display: block;
    font-size: 0.62rem;
    color: var(--accent-purple);
    font-weight: 700;
    letter-spacing: 1.5px;
}

/* Navigation Tabs */
.mode-nav {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-tab:hover {
    color: var(--text-main);
    background: rgba(255, 120, 37, 0.15);
}

.nav-tab.active {
    background: var(--primary-orange);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(255, 120, 37, 0.4);
}

/* Actions */
.header-actions {
    display: flex;
    gap: 10px;
}

.btn-publish-glow {
    background: rgba(37, 211, 102, 0.15);
    border: 1px solid rgba(37, 211, 102, 0.4);
    color: #25d366;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-publish-glow:hover {
    background: #25d366;
    color: #000;
}

.btn-save-glow {
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.4);
    color: var(--accent-purple);
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-save-glow:hover {
    background: var(--accent-purple);
    color: #fff;
}

.btn-action-primary {
    background: linear-gradient(135deg, var(--primary-orange), var(--primary-hover));
    border: none;
    color: #fff;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 120, 37, 0.3);
    transition: all 0.2s ease;
}

.btn-action-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(255, 120, 37, 0.5);
}

/* Workspace Main */
.studio-workspace {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.workspace-tab {
    display: none;
    height: 100%;
    width: 100%;
}

.workspace-tab.active {
    display: flex;
}

/* EDITOR LAYOUT */
.editor-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

.editor-sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    overflow-y: auto;
}

.sidebar-block {
    display: flex;
    flex-direction: column;
}

.block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.block-header h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text-main);
    font-size: 0.88rem;
    margin-bottom: 6px;
}

.sidebar-input:focus {
    border-color: var(--primary-hover);
    outline: none;
}

.btn-icon-add {
    background: rgba(255, 120, 37, 0.2);
    border: 1px solid var(--border-color);
    color: var(--primary-hover);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-icon-add:hover {
    background: var(--primary-orange);
    color: #fff;
}

.chapter-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chapter-item {
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chapter-item:hover {
    background: rgba(255, 120, 37, 0.1);
    border-color: var(--border-color);
}

.chapter-item.active {
    background: rgba(255, 120, 37, 0.2);
    border-color: var(--primary-hover);
}

.ch-info {
    display: flex;
    flex-direction: column;
}

.ch-num {
    font-size: 0.68rem;
    color: var(--accent-purple);
    font-weight: 800;
}

.ch-title {
    font-size: 0.85rem;
    font-weight: 600;
}

.btn-ch-del {
    background: transparent;
    border: none;
    color: #ff0055;
    font-size: 0.9rem;
    cursor: pointer;
    opacity: 0.6;
}

.btn-ch-del:hover {
    opacity: 1;
}

.lore-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.lore-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--text-muted);
}

.btn-text-link {
    background: transparent;
    border: none;
    color: var(--primary-hover);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

/* Editor Main Area */
.editor-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

.editor-toolbar {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: rgba(14, 14, 23, 0.5);
}

.chapter-title-input {
    flex: 1;
    background: transparent;
    border: none;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    outline: none;
}

.formatting-tools {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

.tool-btn:hover {
    background: var(--primary-orange);
}

.tool-separator {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 6px;
}

/* Canvas Area */
.canvas-wrapper {
    flex: 1;
    padding: 24px 40px;
    overflow-y: auto;
    display: flex;
    justify-content: center;
}

.story-textarea {
    width: 100%;
    max-width: 820px;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 1.85;
    resize: none;
    outline: none;
}

.editor-footer-bar {
    padding: 8px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: rgba(14, 14, 23, 0.8);
}

/* VIDEO SUITE LAYOUT */
.engine-switch-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.engine-switch-btn:hover {
    color: var(--text-main);
    background: rgba(255, 120, 37, 0.15);
}

.engine-switch-btn.active {
    background: var(--primary-orange);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(255, 120, 37, 0.4);
}

.video-suite-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

.video-sidebar {
    width: 300px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    overflow-y: auto;
}

.scenes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scene-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.scene-card:hover {
    background: rgba(255, 120, 37, 0.1);
    border-color: var(--primary-hover);
}

.scene-card.active {
    background: rgba(255, 120, 37, 0.2);
    border-color: var(--primary-orange);
}

.scene-card-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--accent-purple);
    margin-bottom: 4px;
}

.scene-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
}

.video-main-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

.video-toolbar {
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(14, 14, 23, 0.5);
}

.video-creator-split {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.prompt-composer-panel {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

.panel-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.prompt-textarea {
    width: 100%;
    height: 110px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    padding: 12px;
    font-family: var(--font-body);
    font-size: 0.92rem;
    resize: none;
    outline: none;
}

.prompt-textarea:focus {
    border-color: var(--primary-hover);
}

.prompt-actions-row {
    display: flex;
    gap: 12px;
}

.timeline-preview-box {
    background: rgba(15, 13, 22, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.timeline-preview-box h4 {
    font-size: 0.9rem;
    font-weight: 700;
}

.video-player-container {
    width: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16/9;
}

.movie-video-element {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.timeline-track {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.vibe-assistant-panel {
    flex: 1;
    width: 100%;
    min-width: 500px;
    display: flex;
    flex-direction: column;
    background: #0c0b12;
}

.panel-header-bar {
    padding: 10px 16px;
    background: rgba(14, 14, 23, 0.9);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 700;
}

.iframe-container {
    flex: 1;
    width: 100%;
    height: 100%;
}

.iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* READER LAYOUT & PAGE FLIP ANIMATION */
.reader-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #0d0c12;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Theme Variants */
.reader-layout.rtheme-light {
    background: #fcfcfc;
    color: #1a1a1a;
}
.reader-layout.rtheme-sepia {
    background: #f4ebd9;
    color: #433422;
}
.reader-layout.rtheme-dark {
    background: #0d0c12;
    color: #f3f4f6;
}

.reader-header-bar {
    padding: 12px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.reader-meta h2 {
    font-size: 1.05rem;
    font-weight: 800;
}

.reader-meta span {
    font-size: 0.8rem;
    opacity: 0.7;
}

.reader-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-reader-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: inherit;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-reader-toggle.active {
    background: var(--primary-orange);
    color: #fff;
    border-color: var(--primary-hover);
}

.theme-selector-group, .font-sizer-group {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.15);
    padding: 3px;
    border-radius: 8px;
}

.theme-btn, .font-btn, .zoom-btn {
    background: transparent;
    border: none;
    color: inherit;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.theme-btn.active, .font-btn.active {
    background: rgba(255, 255, 255, 0.2);
}

/* Stage & Physical 3D Book Flip Stage */
.reader-stage-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 20px;
}

.book-flip-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 950px;
    height: 90%;
    gap: 20px;
    perspective: 1500px;
}

.flip-nav-btn {
    background: rgba(255, 120, 37, 0.15);
    border: 1px solid var(--border-color);
    color: var(--primary-hover);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.flip-nav-btn:hover {
    background: var(--primary-orange);
    color: #fff;
    transform: scale(1.1);
}

/* Physical Book Container */
.physical-book {
    flex: 1;
    height: 100%;
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.book-page {
    flex: 1;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.3s ease;
    position: relative;
}

.reader-layout.rtheme-light .book-page {
    background: #ffffff;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.05);
}
.reader-layout.rtheme-sepia .book-page {
    background: #f8edd9;
    box-shadow: inset 0 0 30px rgba(67, 52, 34, 0.08);
}
.reader-layout.rtheme-dark .book-page {
    background: #14131b;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.4);
}

.left-page {
    border-right: 1px solid rgba(0, 0, 0, 0.15);
}

.book-spine {
    width: 12px;
    background: linear-gradient(90deg, rgba(0,0,0,0.3), rgba(255,255,255,0.05), rgba(0,0,0,0.3));
}

.page-content {
    flex: 1;
    font-family: var(--font-serif);
    font-size: 1.05rem;
    line-height: 1.8;
    overflow: hidden;
}

.page-footer {
    text-align: center;
    font-size: 0.75rem;
    opacity: 0.5;
    margin-top: 10px;
}

/* Vertical Scroll Stage */
.vertical-scroll-stage {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    padding: 30px;
}

.scroll-paper {
    width: 100%;
    max-width: 750px;
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 1.9;
}

/* Feedback & Comments Footer */
.reader-feedback-bar {
    padding: 12px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: rgba(0, 0, 0, 0.2);
}

.rating-box {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 700;
}

.stars-picker {
    display: flex;
    gap: 4px;
    color: #ffc107;
    font-size: 1.3rem;
    cursor: pointer;
}

.star {
    opacity: 0.3;
    transition: transform 0.1s ease, opacity 0.1s ease;
}

.star.active, .star:hover {
    opacity: 1;
    transform: scale(1.15);
}

.comment-input-box {
    display: flex;
    gap: 10px;
    flex: 1;
    max-width: 500px;
}

.comment-input-box input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 8px;
    color: inherit;
    font-size: 0.85rem;
}

/* Placeholder Cards */
.tab-placeholder-card {
    margin: auto;
    text-align: center;
    max-width: 500px;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.placeholder-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.tab-placeholder-card h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.tab-placeholder-card p {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.6;
    margin-bottom: 24px;
}

/* MODAL OVERLAY */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: #14131d;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-textarea {
    width: 100%;
    height: 220px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    padding: 12px;
    font-family: monospace;
    font-size: 0.85rem;
    resize: none;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
}
