:root {
	--bg: #0f1115;
	--bg2: #161a21;
	--bg3: #1d222b;
	--line: #2a303b;
	--fg: #e6e9ef;
	--muted: #8b93a3;
	--accent: #6c8cff;
	--accent2: #4a68e0;
	--ok: #3ec28f;
	--warn: #e0a93e;
	--bad: #ef5d6c;
	--vclip: #3a5bb8;
	--aclip: #2f8f6b;
	--radius: 8px;
	color-scheme: dark;
}
* {
	box-sizing: border-box;
}
html,
body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--fg);
	font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#app {
	height: 100%;
}
a {
	color: var(--accent);
	text-decoration: none;
}
h1 {
	font-size: 22px;
	margin: 0;
}
h3 {
	margin: 0 0 8px;
	font-size: 15px;
}
h4 {
	margin: 12px 0 6px;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--muted);
}
p {
	margin: 6px 0;
}
.muted {
	color: var(--muted);
}
.small {
	font-size: 12px;
}
.mono {
	font-family: ui-monospace, Menlo, Consolas, monospace;
}
.grow {
	flex: 1;
}
.ellipsis {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
}
.center {
	min-height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}
.error {
	background: rgba(239, 93, 108, 0.12);
	border: 1px solid rgba(239, 93, 108, 0.4);
	color: #ff9aa4;
	padding: 8px 10px;
	border-radius: var(--radius);
	margin: 8px 0;
	word-break: break-word;
}
.error.inline {
	background: none;
	border: 0;
	padding: 0;
	margin: 0;
}

/* shell */
.shell {
	min-height: 100%;
}
.topbar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 20px;
	background: var(--bg2);
	border-bottom: 1px solid var(--line);
	position: sticky;
	top: 0;
	z-index: 20;
}
.brand {
	font-weight: 700;
	font-size: 16px;
	color: var(--fg);
}
.page {
	max-width: 1180px;
	margin: 0 auto;
	padding: 20px;
}
.page-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 16px;
}

/* controls */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	background: var(--bg3);
	color: var(--fg);
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 7px 12px;
	font: inherit;
	cursor: pointer;
	white-space: nowrap;
	user-select: none;
}
.btn:hover {
	border-color: #3a4252;
	background: #232936;
}
.btn.primary {
	background: var(--accent2);
	border-color: var(--accent);
	color: #fff;
}
.btn.primary:hover {
	background: var(--accent);
}
.btn.ghost {
	background: transparent;
	border-color: transparent;
}
.btn.ghost:hover {
	background: var(--bg3);
}
.btn.danger {
	color: #ff9aa4;
	border-color: rgba(239, 93, 108, 0.5);
}
.btn.sm {
	padding: 4px 9px;
	font-size: 13px;
}
.btn.xs {
	padding: 2px 6px;
	font-size: 12px;
}
.btn.lg {
	padding: 10px 18px;
	font-size: 15px;
}
.btn:disabled,
.btn.disabled {
	opacity: 0.45;
	pointer-events: none;
}
input,
select,
textarea {
	background: var(--bg);
	color: var(--fg);
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 7px 9px;
	font: inherit;
	width: 100%;
	min-width: 0;
}
input:focus,
select:focus,
textarea:focus {
	outline: none;
	border-color: var(--accent);
}
input[type="checkbox"] {
	width: auto;
}
input[type="range"] {
	padding: 0;
	accent-color: var(--accent);
}
textarea {
	resize: vertical;
}
label {
	display: block;
	margin: 8px 0;
	color: var(--muted);
	font-size: 12px;
}
label > input,
label > select,
label > textarea {
	margin-top: 4px;
	color: var(--fg);
	font-size: 14px;
}
label.check {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--fg);
	font-size: 13px;
	margin: 0;
}
.short {
	max-width: 110px;
}
.row {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 8px 0;
}
.row.wrap {
	flex-wrap: wrap;
}

/* cards & grids */
.card {
	background: var(--bg2);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 14px;
	margin-bottom: 14px;
}
.grid {
	display: grid;
	gap: 14px;
}
.grid.cards {
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.grid.two {
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.grid.assets {
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.grid .card {
	margin: 0;
}
.channel-card {
	display: block;
	color: var(--fg);
}
.channel-card:hover {
	border-color: var(--accent);
}
.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-top: 10px;
}
.chip {
	background: var(--bg3);
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: 1px 8px;
	font-size: 11px;
	font-weight: 600;
}
.tabs {
	display: flex;
	gap: 4px;
	border-bottom: 1px solid var(--line);
	margin-bottom: 14px;
}
.tab {
	background: none;
	color: var(--muted);
	border: 0;
	border-bottom: 2px solid transparent;
	padding: 8px 12px;
	font: inherit;
	cursor: pointer;
}
.tab.active {
	color: var(--fg);
	border-bottom-color: var(--accent);
}
.small-tabs {
	margin-bottom: 8px;
}
.small-tabs .tab {
	padding: 5px 8px;
	font-size: 13px;
}

/* video & asset cards */
.video-card {
	position: relative;
	padding: 0;
	cursor: pointer;
	overflow: hidden;
}
.video-card:hover {
	border-color: var(--accent);
}
.thumb {
	aspect-ratio: 16 / 9;
	background: #000;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}
.thumb img,
.thumb video {
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.big {
	font-size: 36px;
	color: var(--muted);
}
.video-meta {
	padding: 10px 12px;
}
.del {
	position: absolute;
	top: 6px;
	right: 6px;
	background: rgba(0, 0, 0, 0.55) !important;
}
.asset-card {
	position: relative;
	padding: 8px;
}
.asset-card .small {
	padding-top: 6px;
}
.thumb-preview {
	max-width: 260px;
	width: 100%;
	border-radius: 6px;
	margin-top: 8px;
	display: block;
}
.badge {
	display: inline-block;
	border-radius: 4px;
	padding: 0 6px;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	background: var(--bg3);
	border: 1px solid var(--line);
	color: var(--muted);
}
.badge.rendered,
.badge.done {
	color: var(--ok);
	border-color: rgba(62, 194, 143, 0.5);
}
.badge.rendering,
.badge.queued {
	color: var(--warn);
	border-color: rgba(224, 169, 62, 0.5);
}
.badge.failed {
	color: var(--bad);
	border-color: rgba(239, 93, 108, 0.5);
}

/* uploads, bars, pills */
.uploads {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 8px 0;
}
.upload-row {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 12px;
}
.upload-row.err {
	color: #ff9aa4;
}
.upload-name {
	max-width: 40%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.bar {
	flex: 1;
	height: 8px;
	background: var(--bg3);
	border-radius: 4px;
	overflow: hidden;
}
.bar-fill {
	height: 100%;
	background: var(--accent);
	transition: width 0.3s;
}
.file-pill {
	display: flex;
	align-items: center;
	gap: 6px;
	background: var(--bg3);
	border-radius: 6px;
	padding: 2px 4px 2px 10px;
	margin: 4px 0;
	font-size: 12px;
}
.file-pill .ellipsis {
	flex: 1;
}

/* login, wizard, playlists */
.login {
	width: 100%;
	max-width: 380px;
}
.login h1 {
	margin-bottom: 4px;
}
.wizard {
	max-width: 860px;
}
.prompts {
	display: grid;
	gap: 8px;
	margin-top: 8px;
}
.prompts p {
	margin: 2px 0 0;
}
.playlist {
	padding: 0;
}
.pl-head {
	padding: 10px 14px;
	margin: 0;
	cursor: pointer;
}
.tracks {
	width: 100%;
	border-collapse: collapse;
	border-top: 1px solid var(--line);
}
.tracks td {
	padding: 6px 14px;
	border-bottom: 1px solid var(--line);
	vertical-align: middle;
}
.tracks tr:last-child td {
	border-bottom: 0;
}
.settings {
	margin-bottom: 16px;
}

/* modal */
.modal-back {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
	padding: 20px;
}
.modal {
	background: var(--bg2);
	border: 1px solid var(--line);
	border-radius: 10px;
	width: 100%;
	max-width: 520px;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
}
.modal.wide {
	max-width: 760px;
}
.modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
}
.modal-head h3 {
	margin: 0;
}
.modal-body {
	padding: 16px;
	overflow: auto;
}
.render-summary {
	margin-bottom: 8px;
}
.render-row {
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 8px 10px;
	margin: 8px 0;
}
.render-row .row {
	margin: 0 0 4px;
}
.render-row .bar {
	margin: 6px 0 2px;
	flex: none;
}
.render-player {
	width: 100%;
	margin-top: 8px;
	border-radius: 6px;
	background: #000;
}

/* ------------------------------ editor ------------------------------ */
.editor {
	height: 100vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.ed-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px;
	background: var(--bg2);
	border-bottom: 1px solid var(--line);
	white-space: nowrap;
}
.ed-title {
	flex: 0 1 260px;
	min-width: 90px;
	width: 260px;
	font-weight: 600;
}
.save-state {
	font-size: 12px;
	color: var(--muted);
}
.save-state.dirty,
.save-state.saving {
	color: var(--warn);
}
.save-state.error {
	color: var(--bad);
}
.transport {
	display: flex;
	align-items: center;
	gap: 8px;
}
.transport .play {
	min-width: 40px;
}
.transport .time {
	min-width: 130px;
}
.ed-body {
	flex: 1;
	min-height: 0;
	display: grid;
	grid-template-columns: 250px minmax(0, 1fr) 280px;
}
.ed-left,
.ed-right {
	background: var(--bg2);
	overflow-y: auto;
	padding: 10px;
}
.ed-left {
	border-right: 1px solid var(--line);
}
.ed-right {
	border-left: 1px solid var(--line);
}
.ed-center {
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 0;
}

/* preview */
.preview-wrap {
	flex: 1;
	min-height: 120px;
	background: #07080b;
	display: flex;
	align-items: center;
	justify-content: center;
	container-type: size;
	padding: 8px;
}
.stage {
	position: relative;
	background: #000;
	overflow: hidden;
	aspect-ratio: var(--ar, 1.7778);
	width: min(100cqw, calc(100cqh * var(--ar, 1.7778)));
	container-type: inline-size;
}
.layer {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}
.wm {
	position: absolute;
	pointer-events: none;
}
.stage-empty {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #444b59;
	font-size: 4cqw;
}

/* timeline */
.ed-timeline {
	height: 300px;
	min-height: 140px;
	border-top: 1px solid var(--line);
	background: var(--bg);
	display: flex;
	flex-direction: column;
	min-width: 0;
}
.tl-scroll {
	flex: 1;
	overflow: auto;
	position: relative;
}
.tl-inner {
	position: relative;
	min-height: 100%;
}
.ruler {
	position: sticky;
	top: 0;
	z-index: 6;
	height: 26px;
	background: var(--bg2);
	border-bottom: 1px solid var(--line);
	cursor: pointer;
}
.ruler-corner {
	position: sticky;
	left: 0;
	height: 100%;
	background: var(--bg2);
	border-right: 1px solid var(--line);
	z-index: 8;
}
.tick {
	position: absolute;
	top: 0;
	bottom: 0;
	border-left: 1px solid #343b49;
	padding-left: 4px;
	font-size: 10px;
	color: var(--muted);
	pointer-events: none;
}
.end-marker {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 2px;
	background: var(--warn);
	opacity: 0.7;
	pointer-events: none;
}
.lane-row {
	display: flex;
	border-bottom: 1px solid var(--line);
	position: relative;
}
.lane-label {
	position: sticky;
	left: 0;
	z-index: 5;
	flex: none;
	background: var(--bg2);
	border-right: 1px solid var(--line);
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 0 4px;
}
.lane-name {
	background: transparent;
	border: 0;
	padding: 2px 4px;
	font-size: 12px;
	min-width: 0;
}
.lane-name:focus {
	background: var(--bg);
}
.lane {
	position: relative;
	flex: none;
	height: 54px;
	background: repeating-linear-gradient(90deg, transparent 0 99px, rgba(255, 255, 255, 0.025) 99px 100px);
}
.lane-row.audio .lane {
	height: 44px;
}
.lane-row.muted-track .lane {
	opacity: 0.4;
}
.add-row .lane-label {
	position: static;
	border-right: 0;
	width: auto !important;
	background: transparent;
}
.clip {
	position: absolute;
	top: 3px;
	bottom: 3px;
	border-radius: 5px;
	background: var(--vclip);
	border: 1px solid rgba(255, 255, 255, 0.18);
	overflow: hidden;
	cursor: grab;
	touch-action: none;
	user-select: none;
	display: flex;
	align-items: center;
}
.clip.audio {
	background: var(--aclip);
}
.clip.image {
	background-color: #5a4a9a;
	background-repeat: repeat-x;
}
.clip.missing {
	background: #6b2630;
}
.clip.sel {
	border-color: #fff;
	box-shadow: 0 0 0 1px #fff;
	z-index: 3;
}
.clip:active {
	cursor: grabbing;
}
.clip-label {
	position: relative;
	padding: 0 8px;
	font-size: 11px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
	pointer-events: none;
}
.loop-marks {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background-image: linear-gradient(90deg, transparent calc(100% - 2px), rgba(255, 255, 255, 0.45) calc(100% - 2px));
	background-repeat: repeat-x;
}
.fade {
	position: absolute;
	top: 0;
	bottom: 0;
	pointer-events: none;
	max-width: 100%;
}
.fade.fin {
	left: 0;
	background: linear-gradient(90deg, rgba(0, 0, 0, 0.7), transparent);
}
.fade.fout {
	right: 0;
	background: linear-gradient(270deg, rgba(0, 0, 0, 0.7), transparent);
}
.handle {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 8px;
	cursor: ew-resize;
	z-index: 2;
	background: rgba(255, 255, 255, 0);
}
.handle:hover {
	background: rgba(255, 255, 255, 0.35);
}
.handle.l {
	left: 0;
}
.handle.r {
	right: 0;
}
.playhead {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 2px;
	margin-left: -1px;
	background: var(--bad);
	z-index: 7;
	pointer-events: none;
}
.playhead::before {
	content: "";
	position: absolute;
	top: 0;
	left: -5px;
	border: 6px solid transparent;
	border-top-color: var(--bad);
}

/* library */
.lib-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
}
.lib-tile {
	position: relative;
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 4px;
	cursor: grab;
}
.lib-tile:hover {
	border-color: var(--accent);
}
.lib-thumb {
	aspect-ratio: 16 / 9;
	background: #000;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	border-radius: 4px;
}
.lib-thumb img,
.lib-thumb video {
	width: 100%;
	height: 100%;
	object-fit: cover;
	pointer-events: none;
}
.lib-name {
	font-size: 12px;
	margin-top: 4px;
}
.lib-add {
	position: absolute;
	left: 8px;
	bottom: 34px;
}
.lib-tile .del {
	top: 8px;
	right: 8px;
}
.ai-box textarea {
	margin: 8px 0 4px;
}
.prompt-item {
	border-bottom: 1px solid var(--line);
	padding: 6px 0;
}
.prompt-item .row {
	flex-wrap: wrap;
	margin: 4px 0 0;
}

/* inspector */
.inspector h3 {
	margin-bottom: 2px;
}
.insp-section {
	border-top: 1px solid var(--line);
	margin-top: 10px;
	padding-top: 4px;
}
.num {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 6px 0;
}
.num span {
	width: 78px;
	flex: none;
}
.num input {
	margin: 0;
	flex: 1;
	min-width: 0;
}
/* two fields side by side (e.g. Width / Height): label above the input so the input keeps its width */
.row > .num {
	flex: 1;
	min-width: 0;
	flex-direction: column;
	align-items: stretch;
	gap: 3px;
}
.row > .num span {
	width: auto;
}
.num em {
	font-style: normal;
	width: 38px;
	flex: none;
	text-align: right;
	color: var(--muted);
}

@media (max-width: 1100px) {
	.ed-body {
		grid-template-columns: 200px minmax(0, 1fr) 230px;
	}
	.ed-title {
		width: 160px;
	}
}
