: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;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background:
        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%);
    min-height: 100vh;
}

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

.app-shell {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    padding: 24px;
}

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

.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: #d9e3f7;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    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 rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
}

.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,
.icon-btn {
    border: 0;
    border-radius: 14px;
    padding: 13px 16px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

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

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

.secondary-btn {
    background: rgba(64, 217, 255, 0.12);
    color: #c7f7ff;
}

.ghost-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.small-btn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    padding: 10px 12px;
    font-size: 13px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(64, 217, 255, 0.12);
    color: #d8fbff;
    font-size: 12px;
    font-weight: 700;
}

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

.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: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 540px);
    overflow: auto;
}

.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: block;
    width: 100%;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.035);
    border-radius: 18px;
    padding: 14px;
    color: var(--text);
    cursor: pointer;
}

.project-item.active {
    border-color: rgba(64, 217, 255, 0.45);
    background: rgba(64, 217, 255, 0.09);
}

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

.project-item span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.hero-metrics {
    display: flex;
    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);
}

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

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

.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-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;
}

.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: 22px 0;
}

.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-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.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;
}

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

.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);
}

.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;
    }
}

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

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

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