:root {
	--bg: #ecebe8;
	--panel: #f6f5f3;
	--line: #d6d4cf;
	--text: #1d1c1a;
	--dim: #75726b;
	--on: #1d1c1a;
	--onText: #f6f5f3;
	--changed: #3a6ea5;
	color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 12.5px/1.35 system-ui, -apple-system, sans-serif; }
button, select, input { font: inherit; color: inherit; }
button {
	background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px; cursor: pointer;
}
button:hover { border-color: #b9b6af; }
button:disabled { opacity: .35; cursor: default; }
button.icon { padding: 1px 5px; min-width: 22px; }
select { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; max-width: 100%; }
a { color: inherit; }

header {
	display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-bottom: 1px solid var(--line);
	position: sticky; top: 0; background: var(--bg); z-index: 5; flex-wrap: wrap;
}
header .name { font-size: 14px; letter-spacing: .02em; margin-right: 6px; }
header #text { width: 52px; text-align: center; font-size: 15px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
header .grow { flex: 1; }
header .sep { width: 6px; }

main {
	display: grid;
	grid-template-columns: clamp(320px, calc(100vh - 44px), min(46vw, 760px)) minmax(0, 1fr) 300px;
	grid-template-areas: "stage spread controls";
	align-items: start;
}
#stage { grid-area: stage; padding: 12px; position: sticky; top: 40px; }
#view { display: block; background: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.06); }
#scrub { display: block; width: 100%; margin: 6px 0 0; accent-color: #4a4843; }
#animbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
#animbar .len { display: flex; align-items: center; gap: 4px; color: var(--dim); font-size: 11.5px; }
#animbar .len input { width: 90px; accent-color: #4a4843; }
#animbar .len output { width: 30px; font-variant-numeric: tabular-nums; }
#animbar .tog { display: flex; align-items: center; gap: 3px; color: var(--dim); font-size: 11.5px; user-select: none; }
#curveed { width: 72px; height: 44px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; cursor: grab; touch-action: none; }
#scrub[hidden] { display: none; }
header .tog { display: flex; align-items: center; gap: 3px; color: var(--dim); font-size: 11.5px; user-select: none; }
#status { color: var(--dim); margin-top: 7px; font-size: 11.5px; min-height: 2.6em; }

#controls {
	grid-area: controls; border-left: 1px solid var(--line); background: var(--panel);
	height: calc(100vh - 40px); overflow-y: auto; position: sticky; top: 40px; padding-bottom: 40px;
}
.sec { border-bottom: 1px solid var(--line); padding: 6px 10px 8px; }
.sechead { display: flex; align-items: center; gap: 4px; position: sticky; top: 0; background: var(--panel); padding: 3px 0; z-index: 1; }
.sechead b { flex: 1; font-size: 12.5px; }
.sechead .from { width: 92px; }
.sechead button { font-size: 11px; padding: 1px 6px; }
.grp { margin-top: 4px; }
.grphead { color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; margin: 6px 0 2px; }
.row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 36px; align-items: center; gap: 6px; min-height: 22px; }
.row label { color: #3d3b37; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; }
.row label:hover { text-decoration: underline; text-decoration-color: #aaa; }
.row.changed label { color: var(--changed); }
.row input[type=range] { width: 100%; margin: 0; accent-color: #4a4843; }
.row output { font-variant-numeric: tabular-nums; color: var(--dim); text-align: right; font-size: 11px; }
.row select { grid-column: 2 / 4; }
.row input[type=color] { grid-column: 2 / 4; width: 100%; height: 22px; padding: 0 2px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.row input[type=checkbox] { justify-self: start; }
.row .seed { grid-column: 2 / 4; display: flex; gap: 6px; align-items: center; }
.row .seed output { text-align: left; }
.row[hidden], .grp[hidden] { display: none; }

#spread { grid-area: spread; padding: 10px 12px 40px; min-width: 0; scroll-margin-top: 44px; }
#modes { display: flex; gap: 4px; flex-wrap: wrap; }
#modes button { border-radius: 4px; }
#modes button.on, .chip.on { background: var(--on); color: var(--onText); border-color: var(--on); }
#bar { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin: 8px 0 10px; min-height: 26px; }
#bar .hint { color: var(--dim); }
#bar .sep { width: 8px; }
#bar input[type=range] { width: 110px; accent-color: #4a4843; }
.chip { padding: 2px 8px; border-radius: 11px; }

#tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { margin: 0; cursor: pointer; position: relative; }
.tile canvas { display: block; width: 100%; aspect-ratio: 1; background: #fff; transition: opacity .2s; }
.tile.pending canvas { opacity: .35; }
.tile:hover canvas { outline: 2px solid #1d1c1a; outline-offset: 2px; }
.tile figcaption { height: 16px; line-height: 16px; margin-top: 4px; color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .x { position: absolute; top: 4px; right: 4px; padding: 0 5px; line-height: 16px; opacity: .0; }
.tile:hover .x { opacity: 1; }

@media (max-width: 1180px) {
	main { grid-template-columns: minmax(0, 1fr) 280px; grid-template-areas: "stage controls" "spread spread"; }
	#controls { height: auto; max-height: calc(100vh - 52px); position: static; align-self: stretch; }
	#stage { position: static; }
}
@media (max-width: 640px) {
	main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "controls" "spread"; }
	#controls { border-left: 0; border-top: 1px solid var(--line); max-height: 60vh; position: static; }
}
