:root {
    color-scheme: dark;
    --bg: #07111f;
    --bg-soft: rgba(10, 21, 38, 0.82);
    --panel: rgba(6, 13, 24, 0.82);
    --line: rgba(208, 234, 255, 0.12);
    --text: #f4f7fb;
    --muted: #95aabd;
    --accent: #7ae7ff;
    --accent-strong: #ffd166;
    --danger: #ff7a7a;
    --shadow: 0 26px 70px rgba(0, 0, 0, 0.34);
    --radius: 4px;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(122, 231, 255, 0.14), transparent 35%),
        radial-gradient(circle at top right, rgba(255, 209, 102, 0.12), transparent 30%),
        linear-gradient(145deg, #040a12, #091425 45%, #08182a);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 30px 30px;
    mask-image: radial-gradient(circle at center, black 28%, transparent 100%);
}

.shell {
    display: grid;
    gap: 10px;
    min-height: 100vh;
    padding: 10px;
    max-width: 1500px;
    margin: 0 auto;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
}

.topbar-actions,
.button-row,
.toolbar-actions,
.inline-row,
.section-head,
.collapsible-head,
.setup-card-head,
.setup-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-actions,
.toolbar-actions {
    justify-content: flex-end;
}

.layout {
    display: grid;
    grid-template-columns: minmax(420px, 540px) minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
}

body.booth-mode .layout {
    grid-template-columns: minmax(390px, 430px) minmax(0, 1fr);
}

.controls {
    display: grid;
    gap: 10px;
    align-content: start;
}

.sidebar-controls {
    position: sticky;
    top: 10px;
    align-self: start;
    max-height: calc(100vh - 20px);
    overflow: auto;
    padding-right: 2px;
}

.workspace {
    min-width: 0;
}

.strip-card {
    padding: 10px;
}

.section-head {
    justify-content: space-between;
    margin-bottom: 8px;
}

.collapsible-panel {
    padding: 0;
}

.collapsible-head {
    justify-content: space-between;
    list-style: none;
    margin: 0;
    padding: 10px;
    cursor: pointer;
}

.collapsible-head::-webkit-details-marker {
    display: none;
}

.collapsible-body {
    padding: 0 10px 10px;
}

.section-title,
.section-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.section-head h2,
.topbar h1,
.stage-toolbar h2,
.editor-head h3 {
    margin: 0;
    letter-spacing: -0.03em;
}

.section-head h2 {
    font-size: 0.98rem;
}

.eyebrow {
    margin: 0 0 4px;
    font-size: 0.66rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
}

.topbar h1 {
    font-size: clamp(1.35rem, 1.6vw, 1.8rem);
}

.lede,
.microcopy {
    margin: 0;
    color: var(--muted);
}

.microcopy {
    font-size: 0.76rem;
}

.control-grid {
    display: grid;
    gap: 10px;
}

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

.control-grid-compact {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.span-2 {
    grid-column: span 2;
}

.span-3 {
    grid-column: span 3;
}

label {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 0.78rem;
}

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

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--text);
    background: rgba(6, 13, 24, 0.92);
}

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

input[type="color"] {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: rgba(6, 13, 24, 0.92);
    padding: 2px;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent-strong);
}

output {
    color: var(--text);
    font-size: 0.8rem;
}

button {
    padding: 8px 11px;
    border: 0;
    border-radius: 4px;
    color: #06111b;
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(122, 231, 255, 0.16);
    transition: transform 160ms ease, opacity 160ms ease;
}

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

button:disabled {
    opacity: 0.55;
    cursor: wait;
}

.ghost-button {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    box-shadow: none;
}

.toggle {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.toggle input {
    width: 18px;
    height: 18px;
}

.stage {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 14px;
    min-width: 0;
}

body.booth-mode .stage {
    display: none;
}

.stage-toolbar,
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
}

.status-bar {
    color: var(--muted);
}

.status-bar p {
    margin: 0;
}

.live-pill {
    padding: 8px 12px;
    border: 1px solid rgba(122, 231, 255, 0.22);
    border-radius: 999px;
    color: var(--text);
    background: rgba(122, 231, 255, 0.08);
    font-size: 0.88rem;
    font-weight: 700;
}

.canvas-frame {
    position: relative;
    min-height: 520px;
    display: grid;
    place-items: center;
    padding: 18px;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 0%, rgba(122, 231, 255, 0.14), transparent 40%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
}

.canvas-frame::after {
    content: "";
    position: absolute;
    inset: 14px;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    pointer-events: none;
}

canvas {
    width: min(100%, 1200px);
    max-height: 100%;
    border-radius: 4px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.44);
    background: #03070d;
}

.scene-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.scene-card {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: rgba(6, 13, 24, 0.7);
    cursor: pointer;
    transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

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

.scene-card.is-selected {
    border-color: rgba(122, 231, 255, 0.5);
}

.scene-card.is-live {
    border-color: rgba(255, 209, 102, 0.62);
    box-shadow: inset 0 0 0 1px rgba(255, 209, 102, 0.22);
}

.scene-thumb {
    position: relative;
    aspect-ratio: 16 / 8.4;
    overflow: hidden;
    border-radius: 4px;
    background:
        linear-gradient(135deg, rgba(122, 231, 255, 0.14), rgba(255, 209, 102, 0.12)),
        #07111f;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.scene-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.scene-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: rgba(244, 247, 251, 0.72);
    font-size: 0.8rem;
    text-transform: capitalize;
    letter-spacing: 0.04em;
}

.scene-thumb-overlay {
    position: absolute;
    inset: auto 0 0 0;
    padding: 8px;
    background: linear-gradient(180deg, transparent, rgba(2, 5, 10, 0.82));
}

.scene-thumb-overlay strong,
.scene-thumb-overlay span {
    display: block;
}

.scene-thumb-overlay strong {
    font-size: 0.86rem;
}

.scene-thumb-overlay span {
    font-size: 0.72rem;
    color: rgba(244, 247, 251, 0.78);
}

.scene-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 6px;
    font-size: 0.76rem;
    color: var(--muted);
}

.hotkey-chip {
    padding: 4px 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    font-size: 0.72rem;
}

.editor-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.section-icon {
    margin-right: 8px;
    color: var(--accent);
    font-size: 0.92em;
}

.output-panel .control-grid-compact {
    align-items: start;
}

.editor-panel .editor-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
}

.scenes-panel .microcopy,
.setup-library-panel .microcopy {
    font-size: 0.72rem;
}

.setup-library-list {
    display: grid;
    gap: 8px;
    max-height: 250px;
    overflow: auto;
}

.setup-card {
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid rgba(208, 234, 255, 0.08);
    border-radius: 4px;
    background: rgba(4, 10, 18, 0.4);
}

.setup-card-head,
.setup-card-actions {
    justify-content: space-between;
}

.setup-card strong,
.setup-card small {
    display: block;
}

.setup-card strong {
    font-size: 0.86rem;
}

.setup-card small {
    color: var(--muted);
    font-size: 0.72rem;
}

.setup-card-actions {
    justify-content: flex-end;
}

.setup-card-actions button {
    padding: 6px 9px;
}

.empty-state {
    padding: 10px;
    border: 1px dashed rgba(208, 234, 255, 0.12);
    border-radius: 4px;
    color: var(--muted);
    font-size: 0.76rem;
    text-align: left;
}

.toast-stack {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1000;
    display: grid;
    gap: 10px;
    width: min(360px, calc(100vw - 24px));
    pointer-events: none;
}

.toast {
    padding: 12px 14px;
    border: 1px solid rgba(208, 234, 255, 0.16);
    border-radius: 4px;
    background: rgba(5, 12, 22, 0.92);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
    transform: translateY(0);
    opacity: 1;
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-exit {
    opacity: 0;
    transform: translateY(10px);
}

.toast strong,
.toast span {
    display: block;
}

.toast strong {
    margin-bottom: 3px;
    font-size: 0.86rem;
    color: var(--text);
}

.toast span {
    font-size: 0.76rem;
    color: var(--muted);
}

.scene-field.is-hidden,
#sceneLogoControls.is-hidden,
#sceneOverlayControls.is-hidden {
    display: none;
}

#sceneLogoControls,
#sceneOverlayControls {
    padding: 8px;
    border: 1px solid rgba(208, 234, 255, 0.08);
    border-radius: 4px;
    background: rgba(4, 10, 18, 0.32);
}

body.popout-mode .topbar,
body.popout-mode .controls,
body.popout-mode .workspace,
body.popout-mode .toast-stack,
body.popout-mode .stage-toolbar,
body.popout-mode .status-bar {
    display: none;
}

body.popout-mode .shell {
    padding: 0;
}

body.popout-mode .layout {
    grid-template-columns: 1fr;
    gap: 0;
}

body.popout-mode .stage {
    grid-column: 1 / -1;
    gap: 0;
    min-height: 100vh;
}

body.popout-mode .canvas-frame {
    min-height: 100vh;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #03070d;
}

body.popout-mode .canvas-frame::after {
    display: none;
}

body.popout-mode canvas {
    width: min(100vw, 100%);
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
}

@media (max-width: 1360px) {
    .layout {
        grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
    }

    .control-grid-compact,
    .editor-panel .editor-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .control-grid-2 {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar-controls {
        position: static;
        max-height: none;
        overflow: visible;
    }

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

    .control-grid-compact,
    .editor-panel .editor-grid,
    .span-2,
    .span-3 {
        grid-template-columns: 1fr;
        grid-column: span 1;
    }

    .canvas-frame {
        min-height: 420px;
    }
}

@media (max-width: 720px) {
    .shell {
        padding: 12px;
        gap: 12px;
    }

    .topbar,
    .stage-toolbar,
    .status-bar,
    .editor-head,
    .section-head,
    .inline-row,
    .topbar-actions,
    .button-row,
    .toolbar-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .scene-grid,
    .control-grid-2,
    .control-grid-compact,
    .editor-panel .editor-grid {
        grid-template-columns: 1fr;
    }
}
