:root {
	--bg: #0f1013;
	--panel: #17181d;
	--surface: #1d1f26;
	--surface-hi: #24272f;
	--line: #2b2e38;
	--text: #e7e9ee;
	--muted: #8b90a0;
	--accent: #ffb648;
	--accent-ink: #2a1c05;
	--radius: 12px;
}

* { box-sizing: border-box; }

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

body {
	background: var(--bg);
	color: var(--text);
	font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

.app {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 340px;
	height: 100dvh;
}

/* ---------- stage ---------- */

.stage {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 32px;
	min-width: 0;
	background:
		radial-gradient(1200px 600px at 30% 0%, #1a1c22 0%, var(--bg) 70%);
}

.stage__frame {
	width: 100%;
	max-width: 1100px;
	aspect-ratio: 1100 / 700;
	border-radius: var(--radius);
	overflow: hidden;
	background: #222;
	box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 0 0 1px var(--line);
}

#out {
	display: block;
	width: 100%;
	height: 100%;
}

/* ---------- panel ---------- */

.panel {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 22px 20px;
	overflow-y: auto;
	background: var(--panel);
	border-left: 1px solid var(--line);
}

.panel__head h1 {
	margin: 0;
	font-size: 20px;
	letter-spacing: -.02em;
}

.panel__head p {
	margin: 2px 0 0;
	font-size: 12px;
}

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

.panel__foot {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: auto;
	padding-top: 6px;
}

.card {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 14px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
}

.card__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.card__label {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--muted);
}

/* ---------- controls ---------- */

.segmented {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 4px;
	padding: 4px;
	background: var(--bg);
	border-radius: 10px;
}

.segmented__btn {
	padding: 8px 10px;
	border: 0;
	border-radius: 7px;
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background .15s, color .15s;
}

.segmented__btn:hover { color: var(--text); }

.segmented__btn.is-active {
	background: var(--surface-hi);
	color: var(--text);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

.field label {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	margin-bottom: 6px;
	font-size: 12px;
	color: var(--muted);
}

.field output {
	font-variant-numeric: tabular-nums;
	color: var(--text);
}

input[type="range"] {
	width: 100%;
	height: 18px;
	margin: 0;
	accent-color: var(--accent);
	cursor: pointer;
}

.input {
	width: 100%;
	padding: 9px 11px;
	border: 1px solid var(--line);
	border-radius: 9px;
	background: var(--bg);
	color: var(--text);
	font: inherit;
}

.input:focus {
	outline: none;
	border-color: var(--accent);
}

.check {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 12px;
	color: var(--muted);
	cursor: pointer;
}

.check input { accent-color: var(--accent); }

/* ---------- buttons ---------- */

.btn {
	padding: 10px 12px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--surface-hi);
	color: var(--text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background .15s, border-color .15s, transform .05s;
}

.btn:hover { background: #2c303a; }
.btn:active { transform: translateY(1px); }

.btn--accent {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-ink);
}

.btn--accent:hover { background: #ffc466; }

.btn--ghost {
	background: transparent;
}

.btn--lg { padding: 12px; }

.btn-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}

.link-btn {
	padding: 0;
	border: 0;
	background: none;
	color: var(--accent);
	font: inherit;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
}

.link-btn:hover { text-decoration: underline; }

/* ---------- palettes ---------- */

.palettes {
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 260px;
	overflow-y: auto;
	padding-right: 2px;
}

.palette {
	position: relative;
	padding: 3px;
	border: 1px solid transparent;
	border-radius: 9px;
	background: var(--bg);
	cursor: pointer;
	transition: border-color .15s;
}

.palette:hover { border-color: var(--surface-hi); }
.palette.is-active { border-color: var(--accent); }

.palette__bars {
	display: flex;
	height: 26px;
	border-radius: 6px;
	overflow: hidden;
}

.palette__bar { flex: 1 1 auto; }

.palette__name {
	display: block;
	padding: 4px 6px 2px;
	font-size: 11px;
	color: var(--muted);
}

.palette.is-active .palette__name { color: var(--text); }

.palette__del {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 20px;
	height: 20px;
	display: none;
	place-items: center;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, .65);
	color: #fff;
	font-size: 13px;
	line-height: 1;
	cursor: pointer;
}

.palette:hover .palette__del { display: grid; }
.palette__del:hover { background: #d1495b; }

/* ---------- palette editor ---------- */

.editor[hidden] { display: none; }

.editor {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding-top: 12px;
	border-top: 1px solid var(--line);
}

.stops {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.stop { position: relative; }

.stop input[type="color"] {
	width: 40px;
	height: 34px;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: none;
	cursor: pointer;
}

.stop__del {
	position: absolute;
	top: -6px;
	right: -6px;
	width: 16px;
	height: 16px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 50%;
	background: var(--surface-hi);
	color: var(--text);
	font-size: 11px;
	line-height: 1;
	cursor: pointer;
}

.stop__del:hover { background: #d1495b; }

.editor__actions {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
	.app {
		grid-template-columns: 1fr;
		height: auto;
	}

	.stage { padding: 16px; }

	.panel {
		border-left: 0;
		border-top: 1px solid var(--line);
	}
}
