:root {
    --bg-cream: #fff8f2;
    --bg-panel: rgba(255, 255, 255, 0.9);
    --card-border: rgba(255, 176, 130, 0.28);
    --ink-strong: #2f355c;
    --ink-soft: #5f678b;
    --peach: #ff9f7b;
    --pink: #ffcfdd;
    --blue: #8fd6ff;
    --mint: #bff0d2;
    --danger: #d85c63;
    --shadow-soft: 0 18px 45px rgba(89, 65, 104, 0.12);
    --shadow-card: 0 10px 28px rgba(62, 52, 93, 0.08);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --font-ui: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
}

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

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font-ui);
    color: var(--ink-strong);
    background:
        radial-gradient(circle at top left, rgba(255, 205, 178, 0.7), transparent 28%),
        radial-gradient(circle at top right, rgba(143, 214, 255, 0.5), transparent 24%),
        linear-gradient(180deg, #fffdfb 0%, #fff5ef 44%, #fff1ec 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

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

input,
textarea,
select {
    width: 100%;
    border: 1px solid rgba(95, 103, 139, 0.18);
    border-radius: var(--radius-sm);
    padding: 0.85rem 0.95rem;
    background: rgba(255, 255, 255, 0.95);
    color: var(--ink-strong);
}

textarea {
    resize: vertical;
}

label span {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink-soft);
}

.app-shell {
    padding: 1.2rem;
}

.page-wrap {
    max-width: 1480px;
    margin: 0 auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.2rem;
    padding: 1rem 1.2rem;
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
}

.brand-mark small {
    display: block;
    color: var(--ink-soft);
}

.brand-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--peach), var(--pink));
    color: #fff;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(255, 159, 123, 0.32);
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.site-nav a {
    padding: 0.65rem 1rem;
    border-radius: 999px;
    color: var(--ink-soft);
    transition: 0.2s ease;
}

.site-nav a.is-active,
.site-nav a:hover {
    background: rgba(255, 159, 123, 0.16);
    color: var(--ink-strong);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.65rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 245, 239, 0.92);
}

.user-pill small {
    display: block;
    color: var(--ink-soft);
}

.flash {
    margin-bottom: 1rem;
    padding: 0.95rem 1.15rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    box-shadow: var(--shadow-card);
}

.flash-success {
    background: rgba(191, 240, 210, 0.92);
}

.flash-error {
    background: rgba(255, 207, 221, 0.95);
}

.card {
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    background: var(--bg-panel);
    box-shadow: var(--shadow-card);
    padding: 1.35rem;
}

.page-grid {
    display: grid;
    gap: 1rem;
}

.intro-card,
.split-card {
    display: grid;
    gap: 1rem;
}

.split-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hero-kicker {
    display: inline-flex;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: rgba(143, 214, 255, 0.24);
    color: var(--ink-soft);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: baseline;
}

.inline-form,
.stack-form,
.button-row,
.editor-actions {
    display: flex;
    gap: 0.8rem;
}

.stack-form {
    flex-direction: column;
}

.grow-field {
    flex: 1;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.8rem 1.1rem;
    border: 0;
    border-radius: 999px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.button-primary {
    color: #fff;
    background: linear-gradient(135deg, #ff8d68, #ff6ba3);
    box-shadow: 0 12px 22px rgba(255, 120, 119, 0.3);
}

.button-soft {
    color: var(--ink-strong);
    background: rgba(143, 214, 255, 0.22);
}

.button-danger {
    color: #fff;
    background: linear-gradient(135deg, #de6b67, #c64766);
}

.button-large {
    min-height: 52px;
    font-size: 1rem;
}

.field-help {
    margin: -0.2rem 0 0;
    color: var(--ink-soft);
    font-size: 0.92rem;
    line-height: 1.5;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.prompt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.guide-card {
    display: grid;
    gap: 0.85rem;
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 176, 130, 0.18);
    background: rgba(255, 255, 255, 0.84);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.guide-card.is-active {
    transform: translateY(-1px);
    border-color: rgba(255, 107, 163, 0.4);
    box-shadow: 0 12px 28px rgba(255, 107, 163, 0.12);
}

.prompt-card {
    display: grid;
    gap: 0.85rem;
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 176, 130, 0.18);
    background: rgba(255, 255, 255, 0.84);
}

.guide-facts {
    display: grid;
    gap: 0.45rem;
    font-size: 0.94rem;
    color: var(--ink-soft);
}

.guide-facts p {
    margin: 0;
}

.guide-facts strong {
    color: var(--ink-strong);
}

.prompt-box {
    min-height: 190px;
    resize: vertical;
    line-height: 1.55;
    font-size: 0.94rem;
    color: var(--ink-strong);
    background: rgba(255, 250, 246, 0.96);
}

.project-grid,
.asset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.project-card,
.asset-card {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 176, 130, 0.18);
}

.project-meta,
.project-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.status-pill {
    display: inline-flex;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: rgba(191, 240, 210, 0.58);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: capitalize;
}

.asset-thumb {
    overflow: hidden;
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255, 245, 239, 0.9), rgba(255, 236, 227, 0.7));
    aspect-ratio: 1 / 1;
}

.empty-state {
    padding: 1.3rem;
    border-radius: var(--radius-lg);
    background: rgba(255, 245, 239, 0.7);
    text-align: center;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.85rem 0.8rem;
    border-bottom: 1px solid rgba(95, 103, 139, 0.12);
    text-align: left;
}

.auth-layout {
    min-height: calc(100vh - 150px);
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(480px, 100%);
    padding: 2rem;
    background:
        radial-gradient(circle at top right, rgba(255, 207, 221, 0.58), transparent 28%),
        rgba(255, 255, 255, 0.92);
}

.error-state {
    min-height: calc(100vh - 2.4rem);
    display: grid;
    place-items: center;
}

.editor-page {
    display: grid;
    gap: 1rem;
}

.editor-topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
}

.editor-actions {
    flex-wrap: wrap;
    align-items: end;
}

.compact-field {
    width: 110px;
}

.editor-layout {
    display: grid;
    grid-template-columns: 300px minmax(320px, 1fr) 300px;
    gap: 1rem;
    align-items: start;
}

.editor-sidebar {
    display: grid;
    gap: 1rem;
}

.tool-panel {
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: rgba(255, 250, 246, 0.88);
    border: 1px solid rgba(255, 176, 130, 0.16);
}

.guide-panel .button {
    width: 100%;
}

.editor-stage-card {
    display: grid;
    gap: 1rem;
}

.stage-frame {
    display: grid;
    place-items: center;
    padding: 1.2rem;
    overflow-x: auto;
    border-radius: var(--radius-xl);
    background:
        radial-gradient(circle at top, rgba(143, 214, 255, 0.18), transparent 42%),
        linear-gradient(180deg, rgba(255, 248, 242, 1), rgba(255, 240, 231, 0.95));
}

#editor-stage {
    width: 360px;
    height: 640px;
    border-radius: 32px;
    overflow: hidden;
    box-shadow: 0 20px 44px rgba(57, 53, 83, 0.18);
    background: linear-gradient(180deg, #fcefe6, #fff8f3);
}

.editor-status-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--ink-soft);
}

.chip-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.chip-button {
    display: grid;
    gap: 0.55rem;
    padding: 0.65rem;
    border: 1px solid rgba(95, 103, 139, 0.14);
    border-radius: var(--radius-md);
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.chip-button.is-active {
    border-color: rgba(255, 107, 163, 0.4);
    box-shadow: 0 10px 24px rgba(255, 107, 163, 0.12);
}

.chip-preview {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 12px;
    background:
        linear-gradient(135deg, rgba(255, 207, 221, 0.64), rgba(143, 214, 255, 0.48));
    background-size: cover;
    background-position: center;
}

.scene-item-list {
    display: grid;
    gap: 0.55rem;
}

.scene-item {
    width: 100%;
    padding: 0.8rem 0.95rem;
    border: 1px solid rgba(95, 103, 139, 0.12);
    border-radius: var(--radius-md);
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.scene-item.is-active {
    background: rgba(191, 240, 210, 0.5);
}

.is-hidden {
    display: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 1080px) {
    .site-header,
    .editor-topbar,
    .split-card {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .editor-layout {
        grid-template-columns: 1fr;
    }

    .editor-sidebar {
        order: 2;
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding: 0.75rem;
    }

    .site-header {
        padding: 1rem;
    }

    .site-nav {
        width: 100%;
    }

    .site-nav a {
        flex: 1;
        text-align: center;
    }

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

    .editor-status-row,
    .section-heading,
    .inline-form,
    .button-row {
        flex-direction: column;
        align-items: stretch;
    }

    #editor-stage {
        width: min(100%, 360px);
    }
}
