:root {
    --bg: #09111f;
    --bg-soft: #101b2f;
    --panel: rgba(10, 18, 35, 0.84);
    --line: rgba(255, 255, 255, 0.08);
    --text: #eef4ff;
    --muted: #9eb0d0;
    --primary: #6d7cff;
    --primary-2: #40d9ff;
    --success: #34d399;
    --danger: #fb7185;
    --shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
    --radius: 22px;
    --surface-soft: rgba(255, 255, 255, 0.04);
    --surface-soft-2: rgba(255, 255, 255, 0.05);
    --surface-strong: rgba(255, 255, 255, 0.06);
    --border-soft: rgba(255, 255, 255, 0.1);
    --accent-soft: rgba(64, 217, 255, 0.12);
    --accent-soft-2: rgba(64, 217, 255, 0.1);
    --text-soft: #d9e3f7;
    --page-bg:
        radial-gradient(circle at top left, rgba(64, 217, 255, 0.15), transparent 30%),
        radial-gradient(circle at top right, rgba(109, 124, 255, 0.25), transparent 32%),
        linear-gradient(180deg, #07101d 0%, #08101c 35%, #0c1424 100%);
}

body[data-theme="light"] {
    --bg: #eef4fb;
    --bg-soft: #ffffff;
    --panel: rgba(255, 255, 255, 0.92);
    --line: rgba(15, 23, 42, 0.1);
    --text: #132033;
    --muted: #5f718d;

    .comfy-shell {
        max-width: 1680px;
    }

    .comfy-page {
        display: flex;
        flex-direction: column;
        gap: 22px;
    }

    .comfy-control-panel {
        padding: 24px;
    }

    .comfy-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px;
    }

    .comfy-toolbar {
        display: flex;
        gap: 12px;
        flex-wrap: wrap;
        margin-top: 18px;
    }

    .comfy-status-box {
        margin-top: 18px;
        padding: 16px 18px;
        border-radius: 16px;
        border: 1px solid var(--line);
        background: var(--surface-soft);
        color: var(--text);
    }

    .comfy-status-box.is-error {
        border-color: rgba(251, 113, 133, 0.3);
        color: #ffd5dc;
    }

    .comfy-scene-box,
    .comfy-output-box {
        gap: 18px;
    }

    .comfy-scene-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
        gap: 18px;
    }

    .comfy-scene-copy {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .comfy-copy-block {
        padding: 18px;
        border-radius: 18px;
        border: 1px solid var(--line);
        background: var(--surface-soft);
    }

    .comfy-pre {
        margin: 10px 0 0;
        white-space: pre-wrap;
        line-height: 1.7;
        color: var(--text);
        font-family: inherit;
    }

    .comfy-scene-images,
    .comfy-output-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 14px;
    }

    .comfy-image-card,
    .comfy-output-card {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 14px;
        border-radius: 18px;
        border: 1px solid var(--line);
        background: var(--surface-soft);
    }

    .comfy-image-card img,
    .comfy-output-card img,
    .comfy-output-card video {
        width: 100%;
        display: block;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid var(--line);
    }

    .comfy-output-card video,
    .comfy-image-card img,
    .comfy-output-card img {
        min-height: 220px;
        object-fit: cover;
    }

    .comfy-topbar-actions {
        gap: 10px;
    }
    --shadow: 0 18px 46px rgba(15, 23, 42, 0.08);
    --surface-soft: rgba(15, 23, 42, 0.03);
    --surface-soft-2: rgba(15, 23, 42, 0.04);
    --surface-strong: rgba(15, 23, 42, 0.06);
    --border-soft: rgba(15, 23, 42, 0.12);
    --accent-soft: rgba(64, 217, 255, 0.16);
    --accent-soft-2: rgba(64, 217, 255, 0.12);
    --text-soft: #22324b;
    --page-bg:
        radial-gradient(circle at top left, rgba(64, 217, 255, 0.12), transparent 26%),
        radial-gradient(circle at top right, rgba(109, 124, 255, 0.16), transparent 28%),
        linear-gradient(180deg, #f6f9fd 0%, #eef3fb 40%, #e7eef8 100%);
}

    body[data-theme="light"] .comfy-copy-block,
    body[data-theme="light"] .comfy-image-card,
    body[data-theme="light"] .comfy-output-card,
    body[data-theme="light"] .comfy-status-box,
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background: var(--page-bg);
    min-height: 100vh;
}

button,
input,
textarea,
select {
    font: inherit;
}

.app-shell {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px;
    width: min(100%, 1680px);
    margin: 0 auto;
}

.sidebar,
.main-content,
.app-view {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.topbar {
    position: relative;
    overflow: hidden;
    padding: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.topbar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(9, 17, 31, 0.78) 0%, rgba(9, 17, 31, 0.58) 45%, rgba(9, 17, 31, 0.72) 100%);
    pointer-events: none;
}

.topbar-video-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.topbar-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
    filter: saturate(0.92) blur(1px);
}

.topbar-brand-logo-wrap {
    position: relative;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 64px;
}

.topbar-logo {
    display: block;
    max-width: min(28vw, 168px);
    max-height: 64px;
    width: auto;
    height: auto;
    opacity: 1;
    filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.18));
}

.topbar-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 0;
    position: relative;
    z-index: 1;
}

.topbar-brand .eyebrow {
    margin-bottom: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.sidebar {
    position: sticky;
    top: 24px;
    align-self: start;
    height: calc(100vh - 48px);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
    scrollbar-gutter: stable;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.brand-block,
.create-panel,
.list-panel,
.hero,
.project-detail {
    padding: 24px;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(109, 124, 255, 0.15);
    color: #cad5ff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.brand-block h1,
.hero h2,
.project-detail h2,
.panel-header h2 {
    margin: 0 0 8px;
}

.brand-block p,
.hero p,
.panel-header p,
.project-meta p,
.empty-copy,
.image-meta,
.scene-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.panel-header {
    margin-bottom: 16px;
}

.stacked-form,
.project-edit-form,
.scene-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
    color: var(--text-soft);
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--border-soft);
    background: var(--surface-soft);
    color: var(--text);
    border-radius: 14px;
    padding: 13px 14px;
    outline: none;
}

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

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(64, 217, 255, 0.55);
    box-shadow: 0 0 0 4px rgba(64, 217, 255, 0.12);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.toggle-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.toggle-option {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--border-soft);
    background: var(--surface-soft);
}

.toggle-option input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary-2);
}

.toggle-option span {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toggle-option small {
    color: var(--muted);
    line-height: 1.4;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.small-btn,
.download-link,
.icon-btn,
.toolbar-btn {
    border: 0;
    border-radius: 14px;
    padding: 13px 16px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.small-btn:hover,
.download-link:hover,
.icon-btn:hover,
.toolbar-btn:hover {
    transform: translateY(-1px);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    font-weight: 700;
}

.secondary-btn {
    background: var(--accent-soft);
    color: var(--text);
}

.ghost-btn {
    background: var(--surface-soft-2);
    color: var(--text);
}

.small-btn {
    background: var(--surface-strong);
    color: var(--text);
    padding: 10px 12px;
    font-size: 13px;
}

.download-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-strong);
    color: var(--text);
    padding: 10px 12px;
    font-size: 13px;
    text-decoration: none;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--accent-soft);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
}

.icon-btn svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    background: var(--surface-soft-2);
    border: 1px solid var(--line);
}

.toolbar-btn.is-compact {
    padding: 10px 12px;
    font-size: 13px;
}

.toolbar-btn-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: currentColor;
}

.toolbar-btn-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.toolbar-btn.tone-primary {
    background: linear-gradient(135deg, rgba(109, 124, 255, 0.24), rgba(64, 217, 255, 0.22));
    border-color: rgba(64, 217, 255, 0.26);
    color: #eff9ff;
}

.toolbar-btn.tone-secondary {
    background: rgba(64, 217, 255, 0.1);
    border-color: rgba(64, 217, 255, 0.22);
    color: #d2f8ff;
}

.toolbar-btn.tone-ghost {
    background: var(--surface-soft);
    border-color: var(--line);
}

.toolbar-btn.tone-danger {
    background: rgba(251, 113, 133, 0.1);
    border-color: rgba(251, 113, 133, 0.2);
    color: #ffdce3;
}

.icon-btn:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

.icon-btn.is-busy {
    background: rgba(109, 124, 255, 0.18);
}

.icon-btn.is-busy svg,
.icon-btn.is-busy span {
    opacity: 0.65;
}

.project-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    max-height: none;
    overflow: visible;
    padding-right: 0;
}

.create-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.create-actions .primary-btn,
.create-actions .ghost-btn {
    flex: 1 1 240px;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.prompt-action-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.project-item {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    min-height: 220px;
    aspect-ratio: 1 / 1;
    text-align: left;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--surface-soft-2), var(--surface-soft));
    border-radius: 24px;
    padding: 20px;
    color: var(--text);
    cursor: pointer;
}

.project-item-add,
.project-item-empty {
    align-items: center;
    justify-content: center;
    text-align: center;
}

.project-item-add {
    border-style: dashed;
    border-color: rgba(64, 217, 255, 0.34);
    background: linear-gradient(180deg, rgba(64, 217, 255, 0.08), rgba(109, 124, 255, 0.08));
}

.project-item-empty {
    cursor: default;
}

.project-item-add-icon {
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    color: #eff8ff;
}

.project-item-add-icon svg {
    width: 30px;
    height: 30px;
    fill: currentColor;
}

.project-item.active {
    border-color: rgba(64, 217, 255, 0.45);
    background: rgba(64, 217, 255, 0.09);
    box-shadow: 0 0 0 1px rgba(64, 217, 255, 0.18), 0 12px 30px rgba(64, 217, 255, 0.08);
}

.project-item strong,
.metric-number {
    display: block;
}

.project-item-top,
.project-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.project-item-model,
.project-item-bottom {
    color: var(--muted);
    font-size: 13px;
}

body[data-theme="light"] .eyebrow {
    background: rgba(109, 124, 255, 0.1);
    color: #4556a8;
}

body[data-theme="light"] .topbar::after {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.62) 45%, rgba(255, 255, 255, 0.76) 100%);
}

body[data-theme="light"] .flow-pill,
body[data-theme="light"] .hero-metrics div,
body[data-theme="light"] .meta-pill,
body[data-theme="light"] .color-tag,
body[data-theme="light"] .reference-upload,
body[data-theme="light"] .scene-image,
body[data-theme="light"] .project-meta,
body[data-theme="light"] .project-style-card,
body[data-theme="light"] .master-prompt,
body[data-theme="light"] .scene-card,
body[data-theme="light"] .toggle-option,
body[data-theme="light"] .file-dropzone,
body[data-theme="light"] .scene-drag-handle,
body[data-theme="light"] .project-section-box,
body[data-theme="light"] .project-header.is-collapsed,
body[data-theme="light"] .project-sticky-bar {
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(15, 23, 42, 0.1);
    color: var(--text);
}

body[data-theme="light"] .project-status-pill {
    background: rgba(109, 124, 255, 0.12);
    color: #3f4f95;
}

body[data-theme="light"] .primary-btn,
body[data-theme="light"] .secondary-btn,
body[data-theme="light"] .icon-btn,
body[data-theme="light"] .toolbar-btn.tone-primary,
body[data-theme="light"] .toolbar-btn.tone-secondary {
    color: #0f172a;
}

body[data-theme="light"] .toolbar-btn.tone-primary,
body[data-theme="light"] .toolbar-btn.tone-secondary {
    border-color: rgba(15, 23, 42, 0.12);
}

body[data-theme="light"] .restriction-tag {
    background: rgba(64, 217, 255, 0.14);
    color: #1f5670;
}

body[data-theme="light"] .scene-badge {
    background: rgba(109, 124, 255, 0.12);
    color: #4b5ca8;
}

body[data-theme="light"] .transition-badge {
    background: rgba(185, 131, 255, 0.14);
    color: #75519f;
}

body[data-theme="light"] .image-placeholder {
    background: rgba(15, 23, 42, 0.02);
    border-color: rgba(15, 23, 42, 0.14);
}

body[data-theme="light"] .toast,
body[data-theme="light"] .modal-card {
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    border-color: rgba(15, 23, 42, 0.1);
}

.project-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(109, 124, 255, 0.14);
    color: #dce4ff;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.project-status-pill.is-large {
    padding: 9px 12px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
    gap: 24px;
}

.hero-copy {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.hero-flow {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.flow-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #dbe9ff;
    font-size: 13px;
    font-weight: 600;
}

.hero-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.hero-metrics div {
    min-width: 110px;
    padding: 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.05);
    text-align: center;
}

.hero-metrics strong {
    display: block;
    font-size: 28px;
    font-weight: 800;
}

.hero-metrics span {
    color: var(--muted);
    font-size: 13px;
}

.project-detail {
    min-height: calc(100vh - 170px);
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.create-view {
    min-height: calc(100vh - 170px);
    display: grid;
    place-items: center;
}

.create-view-shell {
    width: min(100%, 760px);
}

.create-view-card {
    padding: 32px;
}

.create-view-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.dashboard-list-panel {
    padding: 24px;
}

.project-sticky-bar {
    position: sticky;
    top: 18px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding: 14px 16px;
    border: 1px solid rgba(64, 217, 255, 0.18);
    border-radius: 18px;
    background: rgba(9, 17, 31, 0.92);
    backdrop-filter: blur(18px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

.project-section-box {
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    padding: 22px;
}

.scene-section-box {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.project-sticky-summary {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.project-sticky-summary strong {
    font-size: 18px;
}

.project-sticky-summary span:last-child {
    color: var(--muted);
    font-size: 13px;
}

.project-sticky-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.empty-state {
    display: grid;
    place-items: center;
    text-align: center;
}

.project-header {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 24px;
}

.project-header-top {
    grid-column: 1 / -1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 0 2px;
}

.project-header-body {
    display: contents;
}

.project-header.is-collapsed {
    grid-template-columns: 1fr;
}

.project-header.is-collapsed .project-header-body {
    display: none;
}

.project-meta,
.project-style-card,
.master-prompt,
.scene-card {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 20px;
}

.project-overview-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.project-overview-head,
.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.project-status-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.project-updated-label,
.section-mini-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.project-summary-stack {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.project-actions-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.compact-top-gap {
    margin-top: 16px;
}

.project-style-card img,
.scene-image img {
    width: 100%;
    display: block;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
}

.project-style-card img {
    min-height: 220px;
    max-height: 300px;
}

.project-style-preview,
.project-style-upload,
.project-style-summary {
    margin-top: 14px;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.meta-pill {
    padding: 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.meta-pill span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.master-prompt {
    margin: 0;
}

.master-prompt-top {
    align-items: flex-start;
}

.master-prompt-actions-top {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.master-prompt.is-collapsed .master-prompt-body {
    display: none;
}

.master-prompt,
.scene-form label {
    position: relative;
}

.is-loading-box::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 18px;
    border: 2px solid rgba(64, 217, 255, 0.7);
    box-shadow: 0 0 14px rgba(64, 217, 255, 0.28), 0 0 24px rgba(109, 124, 255, 0.16);
    animation: pulse-loading-border 1.2s ease-in-out infinite;
    pointer-events: none;
}

.is-loading-box {
    border-radius: 18px;
    box-shadow: 0 0 0 1px rgba(64, 217, 255, 0.2), 0 0 20px rgba(64, 217, 255, 0.1);
}

@keyframes pulse-loading-border {
    0%,
    100% {
        opacity: 0.45;
        box-shadow: 0 0 10px rgba(64, 217, 255, 0.18), 0 0 18px rgba(109, 124, 255, 0.08);
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 18px rgba(64, 217, 255, 0.34), 0 0 30px rgba(109, 124, 255, 0.18);
    }
}

.master-prompt pre,
.scene-text {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.7;
    font-family: inherit;
    color: #e8eeff;
}

.master-prompt-input {
    min-height: 180px;
}

.scene-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.scene-section-header {
    margin: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.scene-section-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.scene-type-hint {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(64, 217, 255, 0.18);
    background: rgba(64, 217, 255, 0.07);
    color: #dff8ff;
}

.scene-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.025));
}

.scene-card.is-collapsed .scene-body {
    display: none;
}

.scene-card.is-dragging {
    opacity: 0.45;
}

.scene-card.is-drop-target {
    border-color: rgba(64, 217, 255, 0.44);
    box-shadow: 0 0 0 2px rgba(64, 217, 255, 0.18), 0 18px 30px rgba(64, 217, 255, 0.08);
}

.transition-scene {
    border-color: rgba(185, 131, 255, 0.22);
    background:
        radial-gradient(circle at top right, rgba(185, 131, 255, 0.14), transparent 36%),
        linear-gradient(180deg, rgba(109, 124, 255, 0.07), rgba(255, 255, 255, 0.025));
}

.transition-scene .scene-type-hint {
    border-color: rgba(185, 131, 255, 0.26);
    background: rgba(185, 131, 255, 0.09);
    color: #f0e4ff;
}

.scene-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.scene-heading {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scene-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.scene-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px dashed rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: #dce6ff;
    cursor: grab;
}

.scene-drag-handle:active {
    cursor: grabbing;
}

.scene-drag-handle svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.scene-heading h3,
.project-style-card h3,
.master-prompt h3,
.scene-section-header h3 {
    margin: 0;
}

.scene-subtitle {
    max-width: 70ch;
}

.scene-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(109, 124, 255, 0.16);
    color: #d8ddff;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.transition-badge {
    background: rgba(185, 131, 255, 0.18);
    color: #f1ddff;
}

.scene-actions,
.inline-actions,
.image-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.scene-actions {
    justify-content: flex-end;
}

.scene-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 18px;
}

.scene-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.scene-image {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.scene-image img {
    min-height: 220px;
    max-height: 280px;
}

.scene-image.is-generating::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 18px;
    padding: 2px;
    background: conic-gradient(from 0deg, rgba(64, 217, 255, 0.15), rgba(64, 217, 255, 0.95), rgba(109, 124, 255, 0.95), rgba(64, 217, 255, 0.15));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: spin-border 1.1s linear infinite;
    pointer-events: none;
}

.scene-image.is-generating {
    box-shadow: 0 0 0 1px rgba(64, 217, 255, 0.18), 0 0 28px rgba(64, 217, 255, 0.12);
}

.generating-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(64, 217, 255, 0.16);
    color: #d6faff;
    font-size: 12px;
    font-weight: 700;
}

@keyframes spin-border {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.image-placeholder {
    min-height: 220px;
    border-radius: 16px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    display: grid;
    place-items: center;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.02);
}

.reference-upload {
    padding: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.14);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
}

.file-dropzone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 110px;
    padding: 14px;
    border: 1px dashed rgba(64, 217, 255, 0.32);
    border-radius: 16px;
    background: rgba(64, 217, 255, 0.05);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.file-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-dropzone-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #dff8ff;
    pointer-events: none;
}

.file-dropzone-content small {
    color: var(--muted);
}

.file-dropzone.is-dragover {
    border-color: rgba(64, 217, 255, 0.8);
    background: rgba(64, 217, 255, 0.12);
    box-shadow: 0 0 0 3px rgba(64, 217, 255, 0.12);
}

.color-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.restriction-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.restriction-tag {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(64, 217, 255, 0.12);
    color: #cbf8ff;
    font-size: 13px;
    font-weight: 600;
}

.color-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 13px;
}

.color-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    min-width: 280px;
    max-width: 420px;
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(9, 17, 31, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(3, 8, 18, 0.7);
    backdrop-filter: blur(8px);
}

.modal-card {
    width: min(100%, 720px);
    padding: 24px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(10, 18, 35, 0.96);
    box-shadow: var(--shadow);
}

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

.modal-header h3 {
    margin: 0;
}

.modal-close-btn {
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    font-size: 24px;
    line-height: 1;
}

.modal-textarea {
    min-height: 220px;
    margin-top: 16px;
}

.modal-actions {
    justify-content: flex-end;
    margin-top: 16px;
}

.loading {
    opacity: 0.65;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

@media (max-width: 1200px) {
    .app-shell,
    .project-header,
    .scene-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .hero {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .app-shell {
        padding: 14px;
    }

    .topbar-logo {
        max-width: 120px;
        max-height: 48px;
    }

    .grid-2,
    .toggle-grid,
    .meta-grid,
    .scene-images,
    .hero {
        grid-template-columns: 1fr;
        display: grid;
    }

    .project-item-top,
    .project-item-bottom,
    .create-view-header,
    .topbar,
    .project-header-top,
    .master-prompt-top,
    .project-sticky-bar,
    .project-overview-head,
    .scene-section-header,
    .section-header,
    .scene-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .project-status-stack,
    .project-sticky-actions,
    .scene-actions,
    .master-prompt-actions-top {
        align-items: flex-start;
        justify-content: flex-start;
    }

    .hero-metrics {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}
