/* Montage — UI layer. Scandinavian, quiet, tactile. */

:root {
	--ink: #1c1b19;
	--ink-2: #5d5850;
	--ink-3: #8e877c;
	--paper: rgba(250, 248, 244, 0.72);
	--paper-strong: rgba(252, 251, 248, 0.9);
	--paper-solid: #faf8f4;
	--line: rgba(28, 27, 25, 0.08);
	--line-strong: rgba(28, 27, 25, 0.14);
	--chip: rgba(28, 27, 25, 0.05);
	--chip-hover: rgba(28, 27, 25, 0.09);
	--accent: #b4552d;
	--accent-ink: #ffffff;
	--accent-soft: rgba(180, 85, 45, 0.12);
	--ok: #4f7a5a;
	--shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset, 0 18px 40px -18px rgba(60, 44, 28, 0.28), 0 2px 8px rgba(60, 44, 28, 0.06);
	--blur: blur(22px) saturate(1.25);
	--radius: 18px;
	--radius-sm: 11px;
	--font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
	--mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
	--gutter: 22px;
	--bg: #e9e4dc;
	--halo: 0 0 10px rgba(250, 247, 241, 0.9), 0 0 2px rgba(250, 247, 241, 0.9);
	color-scheme: light;
}

:root[data-theme="dark"] {
	--ink: #f4f0e9;
	--ink-2: #bcb4a8;
	--ink-3: #9b9387;
	--paper: rgba(20, 19, 18, 0.74);
	--paper-strong: rgba(22, 21, 20, 0.92);
	--paper-solid: #1d1b19;
	--line: rgba(255, 248, 236, 0.08);
	--line-strong: rgba(255, 248, 236, 0.16);
	--chip: rgba(255, 248, 236, 0.06);
	--chip-hover: rgba(255, 248, 236, 0.11);
	--accent: #e39064;
	--accent-ink: #1c1309;
	--accent-soft: rgba(227, 144, 100, 0.16);
	--shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 18px 44px -18px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.2);
	--bg: #14161b;
	--halo: 0 0 10px rgba(10, 10, 12, 0.85), 0 0 2px rgba(10, 10, 12, 0.85);
	color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden]:not(.finale):not(.overlay) { display: none !important; }
html, body {
	margin: 0;
	height: 100%;
	overflow: hidden;
	background: var(--bg);
	color: var(--ink);
	font-family: var(--font);
	font-size: 14px;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
	transition: background-color .8s ease;
}
button { font: inherit; color: inherit; }
svg { display: block; }

#gl {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	touch-action: none;
	outline: none;
}

/* ———————————————————— Shared atoms ———————————————————— */

.eyebrow {
	font-family: var(--mono);
	font-size: 10.5px;
	font-weight: 500;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--ink-3);
}
.eyebrow.accent { color: var(--accent); }
.eyebrow b { color: var(--ink); font-weight: 600; }
.dot { opacity: .5; padding: 0 .1em; }
.label {
	font-family: var(--mono);
	font-size: 10px;
	font-weight: 500;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--ink-3);
}

.card {
	background: var(--paper);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	transition: background-color .8s ease, border-color .8s ease, box-shadow .8s ease;
}

.btn {
	appearance: none;
	border: 1px solid transparent;
	border-radius: 999px;
	padding: 8px 14px;
	font-size: 12.5px;
	font-weight: 650;
	letter-spacing: 0.005em;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	transition: background-color .2s ease, color .2s ease, opacity .2s ease, transform .15s ease, border-color .2s;
	white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--paper-solid); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); }
.btn.primary:disabled { opacity: .28; cursor: default; transform: none; }
.btn.primary.ready { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -6px var(--accent); }
.btn.ghost { background: var(--chip); }
.btn.ghost:hover { background: var(--chip-hover); }
.btn.ghost.skip { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -8px var(--accent); }
.btn.ghost.skip:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.task-actions { flex-wrap: wrap; }
.btn.tiny { padding: 5px 10px 5px 8px; font-size: 11.5px; background: var(--chip); }
.btn.tiny:hover { background: var(--chip-hover); }
.btn.tiny svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.icon-btn {
	appearance: none;
	border: 0;
	width: 36px;
	height: 36px;
	flex: 0 0 auto;
	border-radius: 50%;
	background: var(--chip);
	display: grid;
	place-items: center;
	cursor: pointer;
	transition: background-color .2s, transform .15s, color .2s;
}
.icon-btn:hover { background: var(--chip-hover); }
.icon-btn:active { transform: scale(.95); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.seg {
	display: flex;
	padding: 3px;
	gap: 2px;
	background: var(--chip);
	border-radius: 999px;
}
.seg button {
	appearance: none;
	border: 0;
	background: transparent;
	flex: 1 1 0;
	border-radius: 999px;
	padding: 8px 10px;
	font-size: 12.5px;
	font-weight: 650;
	color: var(--ink-2);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	white-space: nowrap;
	transition: background-color .25s, color .25s, box-shadow .25s;
}
.seg button:hover { color: var(--ink); }
.seg button.on {
	background: var(--paper-solid);
	color: var(--ink);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 4px 12px -4px rgba(60, 44, 28, 0.18);
}
.seg button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.seg.small button { padding: 6px 8px; font-size: 11.5px; }
.seg.small button svg { width: 13px; height: 13px; }

/* ———————————————————— Layout ———————————————————— */

.hud { position: fixed; z-index: 5; }
.hud-left {
	top: var(--gutter);
	left: var(--gutter);
	width: 336px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-height: calc(100vh - 2 * var(--gutter) - 24px);
	pointer-events: none;
}
.hud-left > * { pointer-events: auto; }

/* identity: the Montage logo stands on its own, the piece gets a card like everything else */
.ident { display: flex; flex-direction: column; gap: 10px; }
.logo {
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 10px 6px 22px;
	pointer-events: none;
	/* no glow: over the 3D view the logo turns negative when what's behind it is dark (see App._logoTone) */
	color: #1c1b19;
	transition: color .5s ease;
}
.logo.negative { color: #f4f0e9; }
.logo-mark { width: 38px; height: 38px; flex: none; }
.logo-word {
	font-size: 29px;
	font-weight: 800;
	letter-spacing: -0.05em;
	line-height: 1;
	transform: translateY(-1px);
}
.piece-card { padding: 13px 16px 13px; }
.piece-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.piece-card h1 {
	margin: 0;
	font-size: 24px;
	line-height: 1.05;
	font-weight: 800;
	letter-spacing: -0.03em;
	color: var(--ink);
	transition: color .8s;
}
.piece-no { font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
.piece-sub { margin-top: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
/* the Montage mark next to the wordmark (veil) */
.brand-line { display: flex; align-items: center; gap: 6px; }
.brand-line .mark { width: 15px; height: 15px; color: var(--ink); flex: none; transform: translateY(-0.5px); }
.brand-word { font-family: Manrope, Helvetica, Arial, sans-serif; font-size: 13px; font-weight: 800; letter-spacing: -0.02em; text-transform: none; color: var(--ink); }
.mk-acc { fill: var(--accent); }
.veil .brand-line { justify-content: center; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
	padding: 10px 12px 9px;
	border-radius: 14px;
	background: var(--paper);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	border: 1px solid var(--line);
	display: flex;
	flex-direction: column;
	gap: 2px;
	transition: background-color .8s, border-color .8s;
}
.stat-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.stat-value { font-family: var(--mono); font-size: 20px; font-weight: 500; letter-spacing: -0.02em; }
.stat-value b { font-weight: 600; transition: color .3s; }
.stat-value b.bump { color: var(--accent); }
.stat-value small { font-size: 12px; color: var(--ink-3); margin-left: 1px; }

.step-card { padding: 15px 16px 14px; }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pill {
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 600;
	padding: 3px 8px;
	border-radius: 999px;
	background: var(--accent-soft);
	color: var(--accent);
	white-space: nowrap;
}
.step-text { margin: 8px 0 0; font-size: 14px; line-height: 1.5; color: var(--ink); text-wrap: pretty; }
.step-text em { font-style: normal; color: var(--accent); font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips:empty { display: none; }
.chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 9px 4px 5px;
	border-radius: 999px;
	background: var(--chip);
	font-size: 11.5px;
	font-weight: 600;
	color: var(--ink-2);
}
.chip img { width: 20px; height: 20px; border-radius: 50%; background: #fff; object-fit: contain; }
.chip b { font-family: var(--mono); color: var(--ink); font-weight: 600; }

.build-task { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.task-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 650; }
.task-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 1.8s infinite; flex: 0 0 auto; }
.build-task.done .task-dot { background: var(--ok); animation: none; }
@keyframes pulse {
	0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
	70% { box-shadow: 0 0 0 7px transparent; }
	100% { box-shadow: 0 0 0 0 transparent; }
}
.bar { margin-top: 9px; height: 4px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .35s cubic-bezier(.2, .8, .2, 1); }
.build-task.done .bar i { background: var(--ok); }
.task-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 11px; }

.manual-card { padding: 12px 12px 12px; display: flex; flex-direction: column; gap: 9px; min-height: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.manual-frame {
	appearance: none;
	border: 0;
	padding: 0;
	display: block;
	width: 100%;
	aspect-ratio: 4 / 3;
	background: #ffffff;
	border-radius: var(--radius-sm);
	overflow: hidden;
	cursor: zoom-in;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06) inset;
	position: relative;
}
.manual-frame canvas { width: 100%; height: 100%; display: block; transition: opacity .25s ease; }
.manual-frame.swap canvas { opacity: 0; }

/* Right control card */
.controls {
	top: var(--gutter);
	right: var(--gutter);
	width: 352px;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.ctl-row { display: flex; flex-direction: column; gap: 7px; }
.pieces { display: flex; gap: 6px; }
.piece {
	appearance: none;
	flex: 1 1 0;
	border: 1px solid var(--line);
	background: transparent;
	border-radius: 12px;
	padding: 7px 10px 6px;
	text-align: left;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	gap: 1px;
	transition: background-color .2s, border-color .2s;
}
.piece b { font-size: 12.5px; font-weight: 800; letter-spacing: .02em; }
.piece small { font-family: var(--mono); font-size: 9.5px; color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; }
.piece.on { background: var(--paper-solid); border-color: var(--line-strong); box-shadow: 0 4px 14px -6px rgba(60, 44, 28, 0.25); }
.piece:disabled { cursor: default; opacity: .5; }
.piece:disabled b { font-weight: 700; }

.mode button { padding: 9px 10px; }

.stepnav { display: flex; align-items: center; gap: 8px; }
.stepnav-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; padding: 0 2px; }
.stepnav-title b { font-size: 15.5px; font-weight: 750; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepnav-title span { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); letter-spacing: .04em; }
.icon-btn.play { background: var(--ink); color: var(--paper-solid); }
.icon-btn.play:hover { background: color-mix(in srgb, var(--ink) 85%, var(--accent)); }
.icon-btn.play svg { fill: currentColor; stroke: currentColor; }
.icon-btn.play .i-pause { fill: none; stroke-width: 2.4; }
.icon-btn.play .i-pause, .icon-btn.play.playing .i-play { display: none; }
.icon-btn.play.playing .i-pause { display: block; }

.timeline { padding: 0 2px; user-select: none; -webkit-user-select: none; }
.tl-labels { position: relative; height: 14px; margin: 0 7px; }
.tl-labels button {
	appearance: none;
	position: absolute;
	top: 0;
	transform: translateX(-50%);
	border: 0;
	background: none;
	padding: 0 3px;
	font-family: var(--mono);
	font-size: 9.5px;
	color: var(--ink-3);
	cursor: pointer;
	line-height: 14px;
	transition: color .2s;
}
.tl-labels button:hover, .tl-labels button.on { color: var(--ink); }
.tl-labels button.on { font-weight: 600; color: var(--accent); }
.tl-track {
	position: relative;
	height: 26px;
	margin: 0 7px;
	cursor: pointer;
	touch-action: none;
}
.tl-track::before {
	content: '';
	position: absolute;
	left: 0; right: 0; top: 50%;
	height: 3px;
	transform: translateY(-50%);
	border-radius: 3px;
	background: var(--chip-hover);
}
.tl-fill {
	position: absolute;
	left: 0; top: 50%;
	height: 3px;
	width: 0;
	transform: translateY(-50%);
	border-radius: 3px;
	background: var(--accent);
}
.tl-ticks { position: absolute; inset: 0; }
.tl-ticks i {
	position: absolute;
	top: 50%;
	width: 1px;
	height: 9px;
	transform: translate(-50%, -50%);
	background: var(--line-strong);
}
.tl-ticks i.passed { background: color-mix(in srgb, var(--accent) 60%, transparent); }
.tl-thumb {
	position: absolute;
	top: 50%;
	left: 0;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--paper-solid);
	border: 1px solid var(--line-strong);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
	transform: translate(-50%, -50%);
	transition: transform .15s;
}
.tl-track:hover .tl-thumb, .tl-track.drag .tl-thumb { transform: translate(-50%, -50%) scale(1.15); }
.timeline.locked .tl-track { cursor: default; }
.timeline.locked .tl-thumb { display: none; }

.settings { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 9px; }
.settings > summary { list-style: none; cursor: pointer; display: none; }
.settings > summary::-webkit-details-marker { display: none; }
.set { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 10px; }
.swatches { display: flex; gap: 8px; padding: 2px 0; }
.swatches button {
	appearance: none;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	border: 0;
	cursor: pointer;
	background: var(--c);
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12) inset, 0 0 0 0 var(--ink);
	transition: box-shadow .2s, transform .15s;
	position: relative;
}
.swatches button:hover { transform: scale(1.06); }
.swatches button.on { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12) inset, 0 0 0 2px var(--paper-solid), 0 0 0 3.5px var(--ink); }
.swatch-name { font-size: 11.5px; color: var(--ink-2); align-self: center; margin-left: 4px; font-weight: 600; }

.tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tool {
	appearance: none;
	border: 0;
	background: var(--chip);
	border-radius: 12px;
	padding: 8px 4px 7px;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	font-size: 10.5px;
	font-weight: 650;
	color: var(--ink-2);
	transition: background-color .2s, color .2s;
}
.tool:hover { background: var(--chip-hover); color: var(--ink); }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool[aria-pressed="true"] { color: var(--ink); }
#tXray[aria-pressed="true"], #tCinema[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
#tSound .i-off { display: none; }
#tSound[aria-pressed="false"] .i-on { display: none; }
#tSound[aria-pressed="false"] .i-off { display: block; }

/* ———————————————————— Floating ———————————————————— */

.tooltip {
	position: fixed;
	z-index: 20;
	left: 0; top: 0;
	pointer-events: none;
	padding: 7px 11px 8px;
	border-radius: 12px;
	background: var(--paper-strong);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	border: 1px solid var(--line);
	box-shadow: var(--shadow);
	display: flex;
	flex-direction: column;
	gap: 1px;
	white-space: nowrap;
	transform: translate(14px, 14px);
}
.tooltip b { font-size: 12.5px; font-weight: 750; }
.tooltip b i { font-style: normal; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; background: var(--ink); color: var(--paper-solid); font-family: var(--mono); font-size: 10.5px; margin-right: 6px; vertical-align: 1px; }
.tooltip span { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }

.toast {
	position: fixed;
	z-index: 15;
	top: var(--gutter);
	left: 50%;
	transform: translate(-50%, -8px);
	opacity: 0;
	padding: 9px 16px 9px 12px;
	border-radius: 999px;
	background: var(--ink);
	color: var(--paper-solid);
	font-size: 13px;
	font-weight: 650;
	display: flex;
	align-items: center;
	gap: 8px;
	box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.45);
	transition: opacity .35s ease, transform .35s cubic-bezier(.2, .8, .2, 1);
	pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .tick { width: 18px; height: 18px; border-radius: 50%; background: var(--ok); display: grid; place-items: center; }
.toast .tick svg { width: 11px; height: 11px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.hint {
	position: fixed;
	z-index: 4;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 12px;
	font-weight: 600;
	color: var(--ink-2);
	padding: 7px 14px;
	border-radius: 999px;
	background: var(--paper);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	border: 1px solid var(--line);
	transition: opacity 1s ease;
	pointer-events: none;
	white-space: nowrap;
}
.hint.gone { opacity: 0; }

.lift-cue {
	position: fixed;
	z-index: 6;
	left: 0; top: 0;
	transform: translate(-50%, -50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	pointer-events: none;
	color: var(--accent);
	font-size: 12px;
	font-weight: 750;
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.lift-cue svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; animation: nudge 1.4s ease-in-out infinite; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15)); }
.lift-cue span { padding: 4px 10px; border-radius: 999px; background: var(--paper-strong); box-shadow: var(--shadow); text-shadow: none; }
@keyframes nudge { 0%, 100% { transform: translateY(4px); } 50% { transform: translateY(-6px); } }

.legal {
	position: fixed;
	z-index: 3;
	left: var(--gutter);
	bottom: 14px;
	max-width: 336px;
	padding: 6px 10px;
	border-radius: 10px;
	background: var(--paper);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	font-size: 10.5px;
	line-height: 1.4;
	color: var(--ink-2);
	pointer-events: none;
	transition: color .8s, background-color .8s;
}
/* design credit, bottom right */
.credit {
	position: fixed;
	z-index: 3;
	right: var(--gutter);
	bottom: 14px;
	padding: 6px 10px;
	border-radius: 10px;
	background: var(--paper);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	font-family: var(--mono);
	font-size: 10px;
	font-weight: 500;
	letter-spacing: .14em;
	line-height: 1.4;
	text-transform: uppercase;
	text-decoration: none;
	color: var(--ink-2);
	transition: color .25s, background-color .8s, opacity .5s;
}
.credit:hover { color: var(--accent); }
.credit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body.cinema .credit, body.phase-intro .credit, body.phase-transit .credit { opacity: 0; pointer-events: none; }

/* Finale */
.finale {
	position: fixed;
	z-index: 12;
	left: 50%;
	bottom: 34px;
	transform: translateX(-50%);
	width: min(440px, calc(100vw - 32px));
	transition: opacity .6s ease, transform .6s cubic-bezier(.2, .8, .2, 1);
}
.finale[hidden] { display: block; opacity: 0; transform: translate(-50%, 16px); pointer-events: none; }
.finale-card { padding: 20px 22px 18px; position: relative; }
.finale-card h2 { margin: 6px 0 4px; font-size: 26px; font-weight: 800; letter-spacing: -0.025em; }
.finale-card p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.finale-stats { display: flex; gap: 18px; margin: 14px 0 16px; }
.finale-stats div { display: flex; flex-direction: column; }
.finale-stats b { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.finale-stats span { font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.finale-actions { display: flex; gap: 8px; }
.close {
	appearance: none;
	position: absolute;
	top: 12px;
	right: 12px;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	border: 0;
	background: var(--chip);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	color: var(--ink-2);
}
.close:hover { background: var(--chip-hover); color: var(--ink); }

/* Overlays */
.overlay {
	position: fixed;
	inset: 0;
	z-index: 30;
	display: grid;
	place-items: center;
	padding: 24px;
	background: rgba(24, 20, 16, 0.32);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	transition: opacity .3s ease;
}
.overlay[hidden] { display: grid; opacity: 0; pointer-events: none; }
.manual-book {
	width: min(920px, 100%);
	background: #ffffff;
	color: #1c1b19;
	border-radius: 20px;
	box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.5);
	padding: 16px 18px 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	transform: translateY(0);
	transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}
.overlay[hidden] .manual-book, .overlay[hidden] .help-card { transform: translateY(12px); }
.book-head { display: flex; align-items: center; justify-content: space-between; position: relative; min-height: 30px; }
.book-head .close { position: static; }
.manual-book .eyebrow { color: #8e877c; }
.manual-book .eyebrow b { color: #1c1b19; }
.manual-book .close { background: rgba(0, 0, 0, 0.05); color: #5d5850; }
.book-page { aspect-ratio: 4 / 3; width: 100%; max-height: calc(100vh - 170px); }
.book-page canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.book-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.book-nav span { font-size: 13px; font-weight: 650; color: #5d5850; text-align: center; }
.manual-book .icon-btn { background: rgba(0, 0, 0, 0.05); color: #1c1b19; }
.manual-book .icon-btn:hover { background: rgba(0, 0, 0, 0.09); }

.help-card { width: min(440px, 100%); padding: 16px 20px 20px; background: var(--paper-strong); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; margin: 12px 0 14px; align-items: center; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--ink-2); font-size: 13px; }
kbd {
	font-family: var(--mono);
	font-size: 11px;
	padding: 3px 7px;
	border-radius: 6px;
	background: var(--chip);
	border: 1px solid var(--line);
	border-bottom-width: 2px;
}
.help-note { margin: 0; font-size: 12.5px; color: var(--ink-2); padding-top: 12px; border-top: 1px solid var(--line); }

/* Loader */
/* piece swap: the stage fades to the room colour with the incoming piece's name */
.veil {
	position: fixed;
	inset: 0;
	z-index: 2;
	display: grid;
	place-items: center;
	background: var(--bg);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity .42s ease, visibility .42s;
}
.veil.on { opacity: 1; visibility: visible; pointer-events: auto; }
.veil-inner { text-align: center; transform: translateY(6px); transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
.veil.on .veil-inner { transform: none; }
.veil-title { font-size: 52px; font-weight: 800; letter-spacing: -0.035em; color: var(--ink); margin: 8px 0 6px; }
.veil-sub { font-size: 13px; font-weight: 600; color: var(--ink-3); }

.loader {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: grid;
	place-items: center;
	background: #eee9e1;
	transition: opacity .9s ease, visibility .9s;
}
.loader.done { opacity: 0; visibility: hidden; }
.loader-inner { width: 240px; text-align: center; }
.loader-title { font-size: 44px; font-weight: 800; letter-spacing: -0.045em; color: #1c1b19; margin: 4px 0 6px; }
.loader-tag { font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: #8e877c; margin-bottom: 22px; }
/* the piece line only shows when a link opens a piece directly */
.loader-piece { display: none; margin: -14px 0 22px; }
.loader.linked .loader-piece { display: block; }
/* loading = assembling: the stems slide in, the diagonal drops, the last panel settles and breathes */
.loader-mark { width: 64px; height: 64px; display: block; margin: 0 auto 10px; overflow: visible; }
.loader-mark .mk-s, .loader-mark .mk-d { fill: #1c1b19; }
.loader-mark .mk-a { fill: #d0673a; }
.loader-mark .mk-sl { animation: mk-left .7s cubic-bezier(.2, .7, .2, 1) both; }
.loader-mark .mk-sr { animation: mk-right .7s cubic-bezier(.2, .7, .2, 1) .08s both; }
.loader-mark .mk-d { animation: mk-drop .7s cubic-bezier(.2, .7, .2, 1) .22s both; }
.loader-mark .mk-a { animation: mk-drop-a .9s cubic-bezier(.2, .8, .2, 1) .42s both, mk-breathe 1.4s ease-in-out 1.32s infinite alternate; }
@keyframes mk-left { from { transform: translateX(-7px); opacity: 0; } }
@keyframes mk-right { from { transform: translateX(7px); opacity: 0; } }
@keyframes mk-drop { from { transform: translateY(-9px); opacity: 0; } }
@keyframes mk-drop-a { from { transform: translateY(-16px); opacity: 0; } }
@keyframes mk-breathe { to { transform: translateY(2.6px); } }
@media (prefers-reduced-motion: reduce) { .loader-mark * { animation: none !important; } }
.loader-bar { height: 2px; background: rgba(0, 0, 0, 0.08); border-radius: 2px; overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 30%; background: #1c1b19; border-radius: 2px; animation: load 1.3s cubic-bezier(.6, 0, .4, 1) infinite; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
.loader-note { margin-top: 14px; font-size: 12px; color: #8e877c; font-weight: 600; }
.loader.error .loader-bar { display: none; }
.loader.error .loader-note { color: #b4552d; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; font-size: 15px; }

/* Cursor states set from JS */
body.cur-grab #gl { cursor: grab; }
body.cur-grabbing #gl { cursor: grabbing; }
body.cur-pointer #gl { cursor: pointer; }
body.cur-lift #gl { cursor: ns-resize; }

/* Drawing view tones down the HUD glass a bit */
body.view-drawing { --bg: #ffffff; }

/* ———————————————————— Responsive ———————————————————— */

@media (max-width: 1100px) {
	.hud-left { width: 300px; }
	.controls { width: 320px; }
	.logo-mark { width: 34px; height: 34px; }
	.logo-word { font-size: 26px; }
}

@media (max-height: 820px) and (min-width: 761px) {
	.logo { padding: 6px 6px 14px; }
	.manual-frame { aspect-ratio: 16 / 10; }
	.controls { gap: 10px; }
}

@media (max-width: 760px) {
	:root { --gutter: 12px; }
	html, body { font-size: 13px; }
	.hud-left { width: auto; right: var(--gutter); gap: 8px; }
	/* logo and piece card share one row */
	.ident { flex-direction: row; align-items: center; gap: 12px; }
	.logo { padding: 0 2px; gap: 7px; }
	.logo-mark { width: 26px; height: 26px; }
	.logo-word { font-size: 20px; }
	.piece-card { flex: 1; min-width: 0; padding: 8px 12px 8px; border-radius: 14px; }
	.piece-card h1 { font-size: 17px; }
	.piece-sub { margin-top: 1px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
	.stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
	.stat { padding: 7px 9px 6px; border-radius: 12px; }
	.stat-value { font-size: 16px; }
	.manual-card { display: none; }
	.step-card {
		position: fixed;
		left: var(--gutter);
		right: var(--gutter);
		bottom: calc(var(--ctl-h, 220px) + var(--gutter) + 8px);
		padding: 12px 14px;
	}
	.step-text { font-size: 13px; margin-top: 5px; }
	.chips { display: none; }
	.controls {
		top: auto;
		left: var(--gutter);
		right: var(--gutter);
		bottom: calc(var(--gutter) + env(safe-area-inset-bottom));
		width: auto;
		padding: 10px;
		gap: 9px;
	}
	.ctl-row { display: none; }
	.settings { padding-top: 8px; }
	.settings > summary { display: block; }
	.settings:not([open]) { gap: 0; }
	.set { grid-template-columns: 46px 1fr; }
	.tools { grid-template-columns: repeat(6, 1fr); }
	.tool span { display: none; }
	.legal, .hint { display: none; }
	/* phones: the controls sit at the bottom, so the credit shows in the chooser only */
	body.phase-app .credit { display: none; }
	body.phase-chooser .credit { bottom: 8px; padding: 4px 8px; font-size: 9px; }
	.finale { bottom: auto; top: 120px; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.mobile-only { display: none !important; }
@media (max-width: 760px) { .mobile-only { display: flex !important; } }


/* ———————— Speed chip ———————— */
.speed-chip {
	appearance: none;
	border: 0;
	height: 26px;
	min-width: 34px;
	padding: 0 8px;
	border-radius: 999px;
	background: var(--chip);
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 600;
	color: var(--ink-2);
	cursor: pointer;
	transition: background-color .2s, color .2s;
}
.speed-chip:hover { background: var(--chip-hover); color: var(--ink); }
.speed-chip.fast { background: var(--accent-soft); color: var(--accent); }

/* ———————— Cinema layout ———————— */
.hud-left, .controls, .legal, .hint {
	transition: transform .75s cubic-bezier(.2, .8, .2, 1), opacity .5s ease, background-color .8s ease, border-color .8s ease;
}
body.cinema .hud-left { transform: translateX(calc(-100% - 48px)); opacity: 0; pointer-events: none; }
body.cinema .controls { transform: translateX(calc(100% + 48px)); opacity: 0; pointer-events: none; }
body.cinema .legal, body.cinema .hint { opacity: 0; }
body.cinema.peek-left .hud-left { transform: none; opacity: 1; pointer-events: auto; }
body.cinema.peek-right .controls { transform: none; opacity: 1; pointer-events: auto; }
body.cinema.idle #gl { cursor: none; }

.film-shade {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	height: 300px;
	z-index: 7;
	pointer-events: none;
	background: linear-gradient(to top, rgba(12, 11, 10, 0.5), rgba(12, 11, 10, 0.18) 45%, rgba(12, 11, 10, 0));
	opacity: 0;
	transition: opacity .8s ease;
}
body.cinema .film-shade { opacity: 1; }

.filmbar {
	position: fixed;
	z-index: 8;
	left: 50%;
	bottom: calc(22px + env(safe-area-inset-bottom));
	width: min(820px, calc(100vw - 48px));
	transform: translate(-50%, 24px);
	opacity: 0;
	pointer-events: none;
	display: flex;
	flex-direction: column;
	gap: 14px;
	transition: opacity .6s ease, transform .75s cubic-bezier(.2, .8, .2, 1);
	color: #fbf8f2;
}
body.cinema .filmbar { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

.fb-caption {
	display: flex;
	align-items: flex-start;
	gap: 16px;
	transition: opacity .35s ease, transform .45s cubic-bezier(.2, .8, .2, 1);
	text-shadow: 0 1px 14px rgba(0, 0, 0, 0.35);
}
.fb-caption.swap { opacity: 0; transform: translateY(6px); }
.fb-no {
	font-family: var(--mono);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: .08em;
	padding-top: 9px;
	color: #f0b48f;
}
.fb-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fb-text b { font-size: 30px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; }
.fb-text span { font-size: 14.5px; font-weight: 500; line-height: 1.45; color: rgba(251, 248, 242, 0.88); max-width: 640px; text-wrap: pretty; }

.fb-row {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 7px 8px 7px 7px;
	border-radius: 999px;
	background: rgba(20, 19, 18, 0.42);
	-webkit-backdrop-filter: blur(18px) saturate(1.3);
	backdrop-filter: blur(18px) saturate(1.3);
	border: 1px solid rgba(255, 255, 255, 0.1);
	transition: opacity .6s ease;
}
body.cinema.idle .fb-row { opacity: 0.25; }
body.cinema.idle .filmbar:hover .fb-row { opacity: 1; }
.fb-btn {
	appearance: none;
	border: 0;
	height: 34px;
	min-width: 34px;
	padding: 0 10px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.1);
	color: #fbf8f2;
	display: grid;
	place-items: center;
	cursor: pointer;
	font-family: var(--mono);
	font-size: 12px;
	font-weight: 600;
	transition: background-color .2s;
}
.fb-btn:hover { background: rgba(255, 255, 255, 0.2); }
.fb-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#fbPlay { background: #fbf8f2; color: #1c1b19; padding: 0; }
#fbPlay svg { fill: currentColor; }
#fbPlay .i-pause { fill: none; stroke-width: 2.4; }
#fbPlay .i-pause, #fbPlay.playing .i-play { display: none; }
#fbPlay.playing .i-pause { display: block; }
.fb-speed.fast { background: rgba(240, 180, 143, 0.28); color: #ffd3b8; }
.fb-track { position: relative; flex: 1 1 auto; height: 24px; cursor: pointer; touch-action: none; }
.fb-track::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 3px; transform: translateY(-50%); border-radius: 3px; background: rgba(255, 255, 255, 0.22); }
.fb-fill { position: absolute; left: 0; top: 50%; height: 3px; width: 0; transform: translateY(-50%); border-radius: 3px; background: #f0b48f; }
.fb-ticks { position: absolute; inset: 0; }
.fb-ticks i { position: absolute; top: 50%; width: 1px; height: 8px; transform: translate(-50%, -50%); background: rgba(255, 255, 255, 0.35); }
.fb-time { font-family: var(--mono); font-size: 11.5px; color: rgba(251, 248, 242, 0.8); white-space: nowrap; min-width: 86px; text-align: right; }

@media (max-width: 760px) {
	.filmbar { width: calc(100vw - 24px); bottom: calc(12px + env(safe-area-inset-bottom)); gap: 10px; }
	.fb-text b { font-size: 21px; }
	.fb-text span { font-size: 12.5px; }
	.fb-time { display: none; }
	body.cinema .step-card { transform: translateY(calc(100% + 340px)); opacity: 0; pointer-events: none; }
	.step-card { transition: transform .75s cubic-bezier(.2, .8, .2, 1), opacity .5s ease; }
	body.cinema .controls { transform: translateY(calc(100% + 40px)); }
	body.cinema .hud-left { transform: translateY(-140%); }
}

/* ———————— Intro & chooser ———————— */
/* the app's panels stay out of the way until a piece is chosen */
body.phase-intro .hud-left, body.phase-chooser .hud-left, body.phase-transit .hud-left { transform: translateX(calc(-100% - 48px)); opacity: 0; pointer-events: none; }
body.phase-intro .controls, body.phase-chooser .controls, body.phase-transit .controls { transform: translateX(calc(100% + 48px)); opacity: 0; pointer-events: none; }
body.phase-intro :is(.legal, .hint, .filmbar, .film-shade, .toast, .finale, .lift-cue),
body.phase-chooser :is(.legal, .hint, .filmbar, .film-shade, .toast, .finale, .lift-cue),
body.phase-transit :is(.legal, .hint, .filmbar, .film-shade, .toast, .finale, .lift-cue) { opacity: 0 !important; pointer-events: none !important; }
.loader.quick { transition: opacity .45s ease, visibility .45s; }
.loader :is(.loader-bar, .loader-note, .loader-piece) { transition: opacity .3s ease; }
.loader.title :is(.loader-bar, .loader-note, .loader-piece) { opacity: 0; }
.app-logo { pointer-events: auto; cursor: pointer; border-radius: 14px; }
.app-logo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctl-head { display: flex; align-items: baseline; justify-content: space-between; }
.link-btn {
	appearance: none; border: 0; background: none; padding: 0; cursor: pointer;
	font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
	transition: color .2s;
}
.link-btn:hover { color: var(--accent); }

.intro { position: fixed; inset: 0; z-index: 40; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .4s, visibility .4s; }
body.phase-intro .intro { opacity: 1; visibility: visible; }
/* captions sit on a card, like the rest of the interface */
.reel-caption {
	position: absolute;
	left: clamp(20px, 5vw, 80px);
	bottom: clamp(36px, 10vh, 110px);
	max-width: min(84vw, 980px);
	padding: 0.3em 0.48em 0.36em;
	border-radius: 0.36em;
	border: 1px solid var(--line);
	background: var(--paper-strong);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	box-shadow: var(--shadow);
	display: flex;
	flex-direction: column;
	gap: 0.42em;
	font-size: clamp(28px, 3.5vw, 50px);
	color: var(--ink);
	opacity: 0;
	transform: translateY(14px);
	transition: opacity .35s ease, transform .55s cubic-bezier(.2, .8, .2, 1);
}
.reel-caption.in { opacity: 1; transform: none; }
.cap-title { font-weight: 800; letter-spacing: -0.045em; line-height: 1; }
.cap-title .w { display: inline-block; opacity: 0; transform: translateY(0.3em); transition: opacity .45s ease, transform .6s cubic-bezier(.2, .8, .2, 1); }
.reel-caption.in .cap-title .w { opacity: 1; transform: none; }
.cap-line {
	font-size: clamp(14px, 0.36em, 19px);
	font-weight: 500;
	letter-spacing: -0.005em;
	line-height: 1.35;
	color: var(--ink-2);
	opacity: 0;
	transform: translateY(6px);
	transition: opacity .5s ease, transform .6s cubic-bezier(.2, .8, .2, 1);
}
.reel-caption.in .cap-line { opacity: 1; transform: none; }
.skip-intro {
	position: absolute;
	top: var(--gutter);
	right: var(--gutter);
	pointer-events: auto;
	appearance: none;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 6px;
	padding: 9px 14px 8px;
	border-radius: 12px;
	border: 1px solid var(--line);
	background: var(--paper);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	font-family: var(--mono);
	font-size: 10.5px;
	font-weight: 500;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--ink);
	cursor: pointer;
	transition: background-color .2s, border-color .2s;
}
.skip-intro:hover { background: var(--paper-strong); border-color: var(--line-strong); }
.skip-bar { display: block; height: 2px; border-radius: 2px; background: var(--line); overflow: hidden; }
.skip-bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }

.chooser { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.ch-top {
	position: absolute;
	top: var(--gutter);
	left: var(--gutter);
	right: var(--gutter);
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	opacity: 0;
	transition: opacity .8s ease;
}
body.phase-chooser .ch-top, body.phase-intro.reel-logo .ch-top { opacity: 1; }
.ch-tools { display: flex; gap: 8px; padding-top: 10px; opacity: 0; transition: opacity .5s; }
body.phase-chooser .ch-tools { opacity: 1; pointer-events: auto; }
.ch-btn {
	appearance: none;
	display: flex;
	align-items: center;
	gap: 7px;
	height: 34px;
	padding: 0 13px 0 11px;
	border-radius: 999px;
	border: 1px solid var(--line);
	background: var(--paper);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	font-family: var(--mono);
	font-size: 10.5px;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--ink-2);
	cursor: pointer;
	transition: color .2s, background-color .2s, border-color .2s;
}
.ch-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ch-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.ch-btn[aria-pressed="false"] { color: var(--ink-3); }
.ch-btn[aria-pressed="false"] svg path:last-child { opacity: .25; }

.ch-cards {
	position: absolute;
	left: 50%;
	bottom: 46px;
	display: grid;
	grid-template-columns: repeat(3, 290px);
	gap: 12px;
	transform: translate(-50%, 28px);
	opacity: 0;
	transition: transform .8s cubic-bezier(.2, .8, .2, 1), opacity .5s ease;
}
body.phase-chooser .ch-cards { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; transition-delay: .15s; }
.pc {
	position: relative;
	padding: 16px 18px 16px;
	border-radius: var(--radius);
	border: 1px solid var(--line);
	background: var(--paper);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	cursor: pointer;
	transition: transform .35s cubic-bezier(.2, .8, .2, 1), border-color .25s, box-shadow .35s, background-color .25s;
}
.pc.on { transform: translateY(-6px); border-color: rgba(208, 103, 58, 0.55); background: var(--paper-strong); box-shadow: var(--shadow); }
.pc-no { font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.pc h2 { margin: 6px 0 0; font-size: 28px; line-height: 1; font-weight: 800; letter-spacing: -0.035em; color: var(--ink); }
.pc-sub { margin-top: 5px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.pc-meta { display: flex; gap: 12px; margin-top: 12px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); letter-spacing: .02em; }
.pc-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.pc-btn {
	appearance: none;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	height: 40px;
	border-radius: 12px;
	border: 1px solid var(--line-strong);
	background: transparent;
	font-family: var(--font);
	font-size: 13.5px;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--ink);
	cursor: pointer;
	transition: background-color .2s, color .2s, border-color .2s;
}
.pc-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pc-watch svg { fill: currentColor; stroke: none; }
.pc-btn:hover { background: var(--chip); }
.pc.on .pc-watch { background: var(--ink); border-color: var(--ink); color: var(--paper-solid); }
.pc.on .pc-watch:hover { background: var(--accent); border-color: var(--accent); }
.pc-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ch-legal {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 14px;
	margin: 0;
	text-align: center;
	opacity: 0;
	transition: opacity .6s;
}
.ch-legal span {
	display: inline-block;
	max-width: calc(100vw - 32px);
	padding: 5px 10px;
	border-radius: 10px;
	background: var(--paper);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	font-size: 10.5px;
	line-height: 1.4;
	color: var(--ink-2);
}
body.phase-chooser .ch-legal { opacity: 1; }

@media (max-width: 1000px) and (min-width: 761px) {
	.ch-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); width: calc(100vw - 2 * var(--gutter)); }
}
@media (max-width: 760px) {
	.reel-caption { left: 20px; bottom: 64px; }
	.skip-intro { padding: 8px 12px 7px; }
	.ch-btn span { display: none; }
	.ch-btn { padding: 0 9px; }
	.ch-cards {
		left: 0;
		right: 0;
		bottom: 34px;
		display: grid;
		grid-template-columns: none;
		grid-auto-flow: column;
		grid-auto-columns: 78vw;
		gap: 10px;
		padding: 10px 11vw 8px;
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		scrollbar-width: none;
		transform: translateY(28px);
	}
	.ch-cards::-webkit-scrollbar { display: none; }
	body.phase-chooser .ch-cards { transform: none; }
	.pc { scroll-snap-align: center; }
	.pc h2 { font-size: 24px; }
	.ch-legal { bottom: 8px; left: var(--gutter); right: auto; text-align: left; }
	.ch-legal span { font-size: 9.5px; max-width: calc(100vw - 2 * var(--gutter) - 150px); }
	.reel-caption { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
	.reel-caption span, .ch-cards, .pc { transition: none; }
}

/* ———————— Inspect: exploded view and dimensions ———————— */
.toggles { display: flex; gap: 6px; }
.toggle {
	appearance: none;
	flex: 1 1 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	height: 30px;
	padding: 0 8px;
	border-radius: 10px;
	border: 1px solid var(--line);
	background: transparent;
	font-family: var(--font);
	font-size: 12px;
	font-weight: 600;
	color: var(--ink-2);
	cursor: pointer;
	transition: background-color .2s, color .2s, border-color .2s;
}
.toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.toggle:hover { color: var(--ink); border-color: var(--line-strong); }
.toggle[aria-pressed="true"] { background: var(--paper-solid); color: var(--ink); border-color: var(--line-strong); box-shadow: 0 4px 14px -8px rgba(60, 44, 28, 0.35); }
.toggle[aria-pressed="true"] svg { color: var(--accent); }

.dims, .dim-labels { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0; }
.dims { width: 100%; height: 100%; overflow: visible; }
.dims .ext { stroke: var(--ink); stroke-width: 0.9; opacity: 0.5; }
.dims .dim { stroke: var(--ink); stroke-width: 1.25; }
.dims .arrow { fill: var(--ink); }
.dim-label {
	position: absolute;
	left: 0;
	top: 0;
	padding: 3px 8px 3px;
	border-radius: 8px;
	border: 1px solid var(--line);
	background: var(--paper-strong);
	-webkit-backdrop-filter: var(--blur);
	backdrop-filter: var(--blur);
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 500;
	letter-spacing: .04em;
	color: var(--ink);
	white-space: nowrap;
}
/* on the drawing's white paper the dimensions are always ink */
body.view-drawing .dims, body.view-drawing .dim-labels { --ink: #171717; --line: rgba(0, 0, 0, 0.12); --paper-strong: #ffffff; }
