/**
 * @imageflow/react-photo-editor — editor.css
 *
 * A faithful reproduction of Adobe Photoshop's "Dark" interface: flat,
 * neutral grays (no glassmorphism on the chrome), square panels, Adobe-blue
 * (#1473e6) accents, panel tab groups, a scrubby-slider aesthetic and tight
 * 11px typography.
 *
 * The whole editor is scoped under `imageflow-editor`; markup uses semantic
 * custom elements styled by tag name — CSS classes are modifiers only
 * (`.active`, `.small`, `.primary`). Native CSS nesting throughout.
 */

imageflow-editor {
	/* --- Photoshop dark palette ---------------------------------------- */
	--ps-chrome: #1e1e1e;         /* menu bar, title, darkest chrome */
	--ps-pasteboard: #404040;     /* canvas gutter behind the document */
	--ps-panel: #323232;          /* panel bodies, tool rail */
	--ps-panel-header: #292929;   /* tab bars, section headers */
	--ps-panel-sub: #2b2b2b;      /* nested / secondary surfaces */
	--ps-field: #191919;          /* text inputs, wells */
	--ps-field-edge: #0d0d0d;     /* inset field border */
	--ps-divider: #1a1a1a;        /* hard separators between regions */
	--ps-edge-light: #3d3d3d;     /* raised 1px highlight */
	--ps-hover: #383838;          /* row / control hover */
	--ps-active: #565656;         /* pressed tool / active control */
	--ps-selected: #4a4a4a;       /* selected layer row */
	--ps-accent: #1473e6;         /* Adobe blue — focus, menu highlight, buttons */
	--ps-accent-hi: #2a82f0;
	--ps-accent-press: #0d64cc;
	--ps-text: #d6d6d6;
	--ps-text-dim: #9a9a9a;
	--ps-text-faint: #6f6f6f;
	--ps-text-disabled: #5a5a5a;
	--ps-icon: #c4c4c4;
	--ps-icon-dim: #8c8c8c;

	/* Layout metrics */
	--ps-menubar-h: 26px;
	--ps-options-h: 30px;
	--ps-tool-w: 34px;
	--ps-tab-h: 26px;
	--ps-status-h: 22px;
	--ps-radius: 2px;
	--ps-radius-lg: 3px;

	position: relative;
	display: grid;
	grid-template-rows: var(--ps-menubar-h) var(--ps-options-h) 1fr var(--ps-status-h);
	width: 100%;
	height: 100%;
	overflow: hidden;
	background: var(--ps-chrome);
	color: var(--ps-text);
	font: 11px/1.4 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
	user-select: none;
	-webkit-font-smoothing: antialiased;
	cursor: default;

	&.dragging { outline: 2px solid var(--ps-accent); outline-offset: -2px; }

	*, *::before, *::after { box-sizing: border-box; }

	/* =====================================================================
	   Workspace: tool rail | canvas column | panel dock
	   ================================================================== */
	imageflow-workspace {
		display: grid;
		grid-template-columns: var(--ps-tool-w) 1fr auto;
		min-height: 0;
		background: var(--ps-divider);
		gap: 1px;
	}

	/* =====================================================================
	   Menu bar
	   ================================================================== */
	imageflow-menubar {
		display: flex;
		align-items: stretch;
		height: var(--ps-menubar-h);
		padding: 0 4px;
		background: var(--ps-chrome);
		border-bottom: 1px solid #000;
		position: relative;
		z-index: 400;

		imageflow-wordmark {
			display: flex;
			align-items: center;
			gap: 6px;
			padding: 0 12px 0 6px;
			font-weight: 600;
			font-size: 11px;
			letter-spacing: 0.2px;
			color: #e6e6e6;
			&::before {
				content: '';
				width: 13px; height: 13px;
				border-radius: 3px;
				background: linear-gradient(135deg, var(--ps-accent), #7b3ff2);
			}
		}

		imageflow-menu-title {
			position: relative;
			display: flex;
			align-items: center;
			padding: 0 9px;
			font-size: 11px;
			color: var(--ps-text);
			cursor: default;
			&:hover, &.active { background: var(--ps-hover); }
			&.active { background: var(--ps-panel-header); }

			> imageflow-menu { position: absolute; top: 100%; left: 0; margin-top: 1px; }
		}
	}

	/* =====================================================================
	   Options bar (context bar under the menu)
	   ================================================================== */
	imageflow-tool-options {
		display: flex;
		align-items: center;
		gap: 10px;
		height: var(--ps-options-h);
		padding: 0 8px;
		background: var(--ps-panel);
		border-bottom: 1px solid var(--ps-divider);
		box-shadow: inset 0 1px 0 var(--ps-edge-light);
		/* Popovers (opacity sliders, color pickers) escape the 30px bar. */
		overflow: visible;
		position: relative;
		z-index: 300;
		white-space: nowrap;
		font-size: 11px;

		imageflow-tool-option {
			position: relative;
			display: inline-flex;
			align-items: center;
			gap: 6px;
			flex: none;
			> imageflow-label { color: var(--ps-text-dim); }
			imageflow-slider { width: 96px; }
		}

		/* Far-left tool-preset chip: active tool icon + caret. */
		imageflow-tool-preset {
			display: inline-flex;
			align-items: center;
			justify-content: center;
			gap: 3px;
			width: 40px; height: 24px;
			flex: none;
			border: 1px solid #232323;
			border-radius: var(--ps-radius);
			background: linear-gradient(#3b3b3b, #333);
			box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
			color: var(--ps-icon);
			cursor: default;
			.caret { color: var(--ps-icon-dim); }
			&:hover { background: linear-gradient(#454545, #3b3b3b); }
		}

		/* Thin vertical separator between option groups. */
		imageflow-opt-sep {
			display: inline-block;
			width: 1px;
			height: 20px;
			flex: none;
			background: var(--ps-divider);
			box-shadow: 1px 0 0 var(--ps-edge-light);
		}

		/* Right-aligns everything after it (Select and Mask…, etc.). */
		imageflow-tool-spacer { display: inline-block; flex: 1; min-width: 8px; }

		/* Typographic prefixes ("тT" before size, "aa" before anti-alias). */
		imageflow-opt-glyph {
			display: inline-flex;
			align-items: baseline;
			color: var(--ps-icon-dim);
			font-size: 14px;
			font-weight: 600;
			font-family: Georgia, 'Times New Roman', serif;
			line-height: 1;
			.tt-small { font-size: 10px; }
			.aa { font-size: 11px; }
		}

		/* The selection combine quad + icon strips. */
		imageflow-button-group { flex: none; }
		imageflow-button-group imageflow-button.icon { width: 26px; height: 24px; padding: 0; }
		imageflow-button.icon { color: var(--ps-icon); }
		imageflow-button.icon.caret { width: 14px; padding: 0; background: none; border-color: transparent; box-shadow: none; }

		/* Brush preset chip: hardness-feathered dot + size + caret. */
		imageflow-brush-chip {
			display: inline-flex;
			align-items: center;
			gap: 5px;
			height: 24px;
			padding: 0 6px;
			border: 1px solid #232323;
			border-radius: var(--ps-radius);
			background: linear-gradient(#3b3b3b, #333);
			box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
			cursor: default;
			&:hover { background: linear-gradient(#454545, #3b3b3b); }
			&.open { background: #2b2b2b; }
			.caret { color: var(--ps-icon-dim); }
		}
		imageflow-brush-dot {
			width: 14px; height: 14px;
			border-radius: 50%;
			background: radial-gradient(circle,
				var(--ps-text) calc(70% - var(--dot-blur, 0%)),
				transparent 72%);
		}
		imageflow-brush-size { font-size: 10px; color: var(--ps-text); font-variant-numeric: tabular-nums; }

		/* Gradient preview chip. */
		imageflow-gradient-chip {
			display: inline-flex;
			align-items: center;
			gap: 4px;
			height: 24px;
			padding: 0 5px;
			flex: none;
			border: 1px solid #232323;
			border-radius: var(--ps-radius);
			background: linear-gradient(#3b3b3b, #333);
			box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
			cursor: default;
			&:hover { background: linear-gradient(#454545, #3b3b3b); }
			.caret { color: var(--ps-icon-dim); }
		}
		imageflow-gradient-preview {
			display: inline-block;
			width: 60px; height: 16px;
			border: 1px solid #000;
			border-radius: 1px;
		}

		/* Small swatches inside the bar (fill/stroke/text color). */
		imageflow-swatch.bar { width: 28px; height: 18px; }

		/* Popovers anchored under an option group. */
		imageflow-popover.under {
			top: calc(100% + 6px); left: 0;
			imageflow-slider { width: 160px; }
		}
		imageflow-popover.under.wide {
			display: flex; flex-direction: column; gap: 6px;
			width: 230px;
			imageflow-panel-row { padding: 0; }
			imageflow-label { min-width: 52px; color: var(--ps-text-dim); }
		}
	}

	/* =====================================================================
	   Tool rail
	   ================================================================== */
	imageflow-toolbar {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 1px;
		padding: 3px 0;
		width: var(--ps-tool-w);
		background: var(--ps-panel);
		/* fly-outs escape to the right, so the rail must not clip */
		overflow: visible;

		/* »-chevron header band (PS's 1/2-column switch — decorative). */
		imageflow-toolbar-header {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
			height: 13px;
			margin-bottom: 2px;
			flex: none;
			font-size: 10px;
			line-height: 1;
			color: var(--ps-icon-dim);
			background: var(--ps-panel-header);
			border-bottom: 1px solid var(--ps-divider);
			cursor: default;
			&:hover { color: var(--ps-text); }
		}

		imageflow-tool-group {
			position: relative;
			display: block;
		}

		imageflow-tool {
			position: relative;
			display: grid;
			place-items: center;
			width: 28px; height: 28px;
			border-radius: var(--ps-radius);
			color: var(--ps-icon);
			cursor: default;
			imageflow-icon { display: grid; place-items: center; }
			&:hover { background: var(--ps-hover); }
			&.active { background: var(--ps-active); color: #f2f2f2; }
		}

		/* group-of-many corner triangle */
		imageflow-tool-tri {
			position: absolute; right: 1px; bottom: 1px;
			width: 0; height: 0;
			border-left: 4px solid transparent;
			border-bottom: 4px solid var(--ps-icon-dim);
			cursor: default;
		}
		imageflow-tool:hover imageflow-tool-tri { border-bottom-color: var(--ps-text); }

		/* section spacers — pure whitespace, like Photoshop */
		imageflow-tool-divider {
			display: block;
			width: 28px; height: 6px;
			background: none;
		}

		imageflow-tool.edit-toolbar { margin-top: 4px; color: var(--ps-icon-dim); }

		imageflow-color-well { margin-top: 8px; }

		imageflow-toolbar-footer {
			display: flex;
			flex-direction: column;
			align-items: center;
			gap: 1px;
			margin-top: 6px;
		}
	}

	/* Tool fly-out panel — flat, opens to the right of its button */
	imageflow-flyout {
		position: absolute;
		top: 0; left: calc(100% + 3px);
		z-index: 50;
		display: flex; flex-direction: column;
		min-width: 190px;
		padding: 3px;
		background: var(--ps-panel-sub);
		border: 1px solid #000;
		border-radius: var(--ps-radius);
		box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);

		imageflow-flyout-item {
			display: grid;
			grid-template-columns: 12px 22px 1fr auto;
			align-items: center;
			gap: 4px;
			height: 24px;
			padding: 0 8px 0 2px;
			border-radius: var(--ps-radius);
			color: var(--ps-text);
			cursor: default;
			imageflow-icon { display: grid; place-items: center; color: var(--ps-icon); }
			&:hover { background: var(--ps-accent); color: #fff; }
			&:hover imageflow-icon { color: #fff; }
			&.active { background: var(--ps-active); }
			&.active imageflow-icon { color: #f2f2f2; }
			&.active:hover { background: var(--ps-accent); }
			&.disabled {
				color: var(--ps-text-disabled);
				imageflow-icon { color: var(--ps-text-disabled); }
				imageflow-flyout-key { color: var(--ps-text-disabled); }
				&:hover { background: var(--ps-hover); color: var(--ps-text-disabled); }
				&:hover imageflow-icon { color: var(--ps-text-disabled); }
			}
		}
		imageflow-flyout-mark {
			display: grid; place-items: center;
			font-size: 8px; line-height: 1;
			color: var(--ps-text);
		}
		imageflow-flyout-name { font-size: 12px; white-space: nowrap; }
		imageflow-flyout-key { color: var(--ps-text-dim); font-size: 11px; }
		imageflow-flyout-item:hover imageflow-flyout-key { color: #dfe8f5; }
	}

	/* =====================================================================
	   Canvas column: tabs, viewport
	   ================================================================== */
	imageflow-canvas-stack.column {
		display: flex;
		flex-direction: column;
		min-width: 0; min-height: 0;
		background: var(--ps-pasteboard);
	}

	imageflow-tabs {
		display: flex;
		align-items: stretch;
		height: var(--ps-tab-h);
		background: var(--ps-chrome);
		border-bottom: 1px solid #000;
		overflow-x: auto;
		&::-webkit-scrollbar { height: 0; }

		imageflow-tab {
			display: inline-flex;
			align-items: center;
			gap: 7px;
			padding: 0 10px 0 12px;
			font-size: 11px;
			color: var(--ps-text-dim);
			background: var(--ps-panel-sub);
			border-right: 1px solid var(--ps-divider);
			max-width: 200px;
			white-space: nowrap;
			&:hover { color: var(--ps-text); }
			/* PS: the active tab is simply lighter and merges into the pasteboard — no accent bar. */
			&.active {
				color: var(--ps-text);
				background: var(--ps-pasteboard);
			}
			imageflow-button.close {
				display: grid; place-items: center;
				width: 15px; height: 15px; border-radius: var(--ps-radius);
				color: var(--ps-text-dim);
				visibility: hidden;
				&:hover { background: var(--ps-hover); color: #fff; }
			}
			&:hover imageflow-button.close, &.active imageflow-button.close { visibility: visible; }
		}
	}

	imageflow-viewport {
		position: relative;
		flex: 1;
		min-height: 0;
		overflow: hidden;
		background: var(--ps-pasteboard);

		imageflow-canvas-stack { position: absolute; inset: 0; }
		imageflow-canvas-stack canvas, > canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

		imageflow-rulers {
			position: absolute; inset: 0;
			pointer-events: none;
			z-index: 30;
			canvas { position: absolute; pointer-events: auto; background: #2b2b2b; touch-action: none; }
			canvas.h { top: 0; left: 20px; height: 20px; width: calc(100% - 20px); cursor: ns-resize; }
			canvas.v { top: 20px; left: 0; width: 20px; height: calc(100% - 20px); cursor: ew-resize; }
			imageflow-ruler.corner {
				position: absolute; top: 0; left: 0; width: 20px; height: 20px;
				background: #2b2b2b; border-right: 1px solid #1a1a1a; border-bottom: 1px solid #1a1a1a;
				pointer-events: auto;
			}
		}
	}

	imageflow-empty-state {
		flex: 1;
		display: flex; flex-direction: column;
		align-items: center; justify-content: center;
		gap: 12px;
		color: var(--ps-text-faint);
		background: var(--ps-pasteboard);
		imageflow-icon { color: #565656; }
		h2 { margin: 0; font-size: 15px; font-weight: 500; color: var(--ps-text-dim); }
		p { margin: 0 0 6px; font-size: 12px; }
		imageflow-button-group { display: flex; gap: 8px; }
	}

	imageflow-dropzone {
		position: absolute; inset: 0;
		display: grid; place-items: center;
		font-size: 16px; font-weight: 600; color: #fff;
		background: color-mix(in srgb, var(--ps-accent) 22%, transparent);
		border: 2px dashed var(--ps-accent);
		pointer-events: none;
		z-index: 500;
	}

	/* =====================================================================
	   Status bar
	   ================================================================== */
	imageflow-statusbar {
		display: flex;
		align-items: center;
		gap: 14px;
		height: var(--ps-status-h);
		padding: 0 10px;
		background: var(--ps-panel);
		border-top: 1px solid var(--ps-divider);
		box-shadow: inset 0 1px 0 var(--ps-edge-light);
		font-size: 11px;
		color: var(--ps-text-dim);

		imageflow-field {
			display: inline-flex; align-items: center;
			position: relative;
			/* PS: the zoom % is an editable textbox in an inset well. */
			&.zoom input {
				width: 58px; height: 18px; padding: 0 6px;
				font: inherit; color: var(--ps-text);
				background: var(--ps-field); border: 1px solid #000; border-radius: 1px;
				box-shadow: inset 0 1px 1px rgba(0,0,0,0.4);
				outline: none;
				&:focus { border-color: var(--ps-accent); }
			}
			&.doc-readout {
				gap: 3px; color: var(--ps-text-dim);
				imageflow-button.chevron {
					width: 14px; height: 16px; display: grid; place-items: center;
					color: var(--ps-text-dim); font-size: 12px;
					&:hover { color: var(--ps-text); }
				}
				imageflow-menu.statusbar-menu {
					position: absolute; left: 0; bottom: 100%; margin-bottom: 4px;
					min-width: 180px;
				}
			}
			&.status { margin-left: auto; color: var(--ps-text-faint); }
			&.dim { opacity: 0.85; }
		}
	}

	/* =====================================================================
	   Panel dock
	   ================================================================== */
	imageflow-panels {
		display: flex;
		flex-direction: column;
		width: 268px;
		background: var(--ps-panel);
		overflow: hidden;
	}

	/* Thin dock header bar with a collapse double-arrow. */
	/* Photoshop tab-group frame: sibling tabs share one strip + one body. */
	imageflow-panel-group {
		display: flex;
		flex-direction: column;
		min-height: 0;
		&.fill { flex: 1; }
		&.collapsed { flex: none; }

		imageflow-panel-tabs {
			display: flex; align-items: stretch;
			height: var(--ps-tab-h); flex: none;
			background: var(--ps-panel-header);
			border-bottom: 1px solid var(--ps-divider);
			imageflow-panel-tab {
				display: inline-flex; align-items: center;
				padding: 0 12px;
				font-size: 11px; font-weight: 500;
				color: var(--ps-text-dim);
				background: var(--ps-panel-header);
				border-right: 1px solid var(--ps-divider);
				white-space: nowrap; cursor: default; user-select: none;
				&:hover { color: var(--ps-text); }
				&.active { color: var(--ps-text); background: var(--ps-panel); }
			}
			imageflow-panel-flyout {
				display: grid; place-items: center;
				width: 24px; margin-left: auto; flex: none;
				color: var(--ps-icon-dim); cursor: default;
				&:hover { color: var(--ps-text); }
			}
		}
	}

	imageflow-panel-group, imageflow-panel {
		display: flex;
		flex-direction: column;
		min-height: 0;
		&.fill { flex: 1; }
		&.collapsed { flex: none; }

		imageflow-panel-header {
			display: flex;
			align-items: center;
			gap: 6px;
			height: var(--ps-tab-h);
			padding: 0 8px 0 6px;
			background: var(--ps-panel-header);
			border-bottom: 1px solid var(--ps-divider);
			box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
			cursor: default;

			imageflow-panel-chevron {
				display: grid; place-items: center;
				width: 14px; height: 14px; color: var(--ps-icon-dim);
				transition: transform 0.12s ease;
			}
			imageflow-panel-title {
				font-size: 11px; font-weight: 600; letter-spacing: 0.2px;
				color: var(--ps-text);
			}
			.tools { margin-left: auto; display: flex; gap: 2px; }
		}
		&.collapsed imageflow-panel-chevron { transform: rotate(-90deg); }

		imageflow-panel-body {
			display: flex; flex-direction: column;
			flex: 1; min-height: 0;
			overflow: auto;
			background: var(--ps-panel);
		}

		imageflow-panel-row {
			display: flex; align-items: center; gap: 8px;
			padding: 5px 8px;
			imageflow-label { color: var(--ps-text-dim); min-width: 54px; }
		}

		/* Generic labelled field inside a panel body (Properties, etc.). */
		imageflow-field {
			display: flex; align-items: center; gap: 8px;
			padding: 4px 8px;
			> imageflow-label, > label { min-width: 46px; color: var(--ps-text-dim); flex: none; }
			> input, > textarea {
				flex: 1; min-width: 0;
				height: 20px; padding: 2px 6px;
				font: inherit; color: var(--ps-text);
				background: var(--ps-field); border: 1px solid #000; border-radius: var(--ps-radius);
				box-shadow: inset 0 1px 1px rgba(0,0,0,0.4); outline: none;
				&:focus { border-color: var(--ps-accent); }
			}
			> textarea { height: auto; min-height: 44px; resize: vertical; }
		}

		imageflow-panel-toolbar {
			display: flex; align-items: center; justify-content: space-between; gap: 2px;
			height: 30px; flex: none;
			padding: 0 8px;
			background: var(--ps-panel-header);
			border-top: 1px solid var(--ps-divider);
			&.layers, &.history { justify-content: flex-end; gap: 4px; }
			imageflow-button {
				display: grid; place-items: center;
				width: 26px; height: 24px; border-radius: var(--ps-radius);
				color: var(--ps-icon);
				background: none; border: none; box-shadow: none;
				&:hover { background: var(--ps-hover); color: #fff; }
				&:disabled, &.disabled { color: var(--ps-text-disabled); pointer-events: none; }
				&.spacer { margin-left: auto; pointer-events: none; }
			}
		}
	}

	/* =====================================================================
	   Layers panel
	   ================================================================== */
	/* --- Filter row + control rows above the list --------------------- */
	imageflow-layer-filter {
		display: flex; align-items: center; gap: 4px;
		height: 28px;
		padding: 0 8px;
		imageflow-select { flex: 1; min-width: 0; height: 22px; }
		imageflow-filter-toggles {
			display: flex; align-items: center; gap: 1px;
			padding: 0 2px;
			border-left: 1px solid var(--ps-divider);
			imageflow-button {
				width: 22px; height: 22px; border-radius: var(--ps-radius);
				color: var(--ps-icon-dim); background: none; border: none; box-shadow: none;
				&:hover { background: var(--ps-hover); color: var(--ps-text); }
				&.active { background: var(--ps-active); color: #fff; }
			}
		}
		imageflow-button.switch {
			width: 24px; height: 22px; margin-left: auto; border-radius: var(--ps-radius);
			color: var(--ps-icon-dim); background: none; border: none; box-shadow: none;
			&:hover { color: var(--ps-text); }
			&.active { color: #e04f4f; }
		}
	}

	imageflow-layer-divider {
		display: block; height: 1px;
		background: var(--ps-divider);
		box-shadow: 0 1px 0 var(--ps-edge-light);
	}

	/* Compact blend/opacity + lock/fill control rows. */
	imageflow-panel-row.lx {
		gap: 6px; padding: 4px 8px; height: 26px;
		> imageflow-label { min-width: auto; flex: none; color: var(--ps-text-dim); }
		imageflow-slider { flex: 1; min-width: 40px; }
		imageflow-select { flex: 1; min-width: 80px; }
		imageflow-lock-toggles {
			display: flex; align-items: center; gap: 2px;
			imageflow-button {
				width: 20px; height: 20px; border-radius: var(--ps-radius);
				color: var(--ps-icon-dim); background: none; border: none; box-shadow: none;
				&:hover { background: var(--ps-hover); color: var(--ps-text); }
				&.active { background: var(--ps-active); color: #fff; }
				&:disabled, &.disabled { color: var(--ps-text-disabled); pointer-events: none; }
			}
		}
		&.lock { justify-content: space-between; }
	}

	/* Compact numeric combo (value + ▾) with a popover slider (Opacity/Fill). */
	imageflow-num-combo {
		position: relative;
		display: inline-flex; align-items: center; gap: 4px;
		flex: none;
		> imageflow-label { color: var(--ps-text-dim); font-size: 11px; }
		&.disabled { opacity: 0.5; pointer-events: none; }
		imageflow-num-combo-field {
			display: inline-flex; align-items: center; justify-content: space-between; gap: 2px;
			width: 56px; height: 20px; padding: 0 4px;
			background: var(--ps-field); border: 1px solid #000; border-radius: var(--ps-radius);
			box-shadow: inset 0 1px 1px rgba(0,0,0,0.4);
			color: var(--ps-text); font-size: 11px; font-variant-numeric: tabular-nums;
			cursor: default;
			.chevron { color: var(--ps-icon-dim); }
			&:hover { border-color: #2a2a2a; }
		}
		imageflow-popover.slider {
			position: absolute; top: 24px; right: 0; z-index: 60;
			width: 160px; padding: 8px 10px;
			background: var(--ps-panel-header); border: 1px solid var(--ps-divider);
			border-radius: var(--ps-radius-lg); box-shadow: 0 6px 18px rgba(0,0,0,0.5);
			imageflow-slider { width: 100%; }
		}
	}

	/* --- Layer list --------------------------------------------------- */
	imageflow-layers { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }

	imageflow-layer-node {
		display: flex; flex-direction: column;
		imageflow-layer-children { display: flex; flex-direction: column; }
	}

	imageflow-layer {
		display: flex;
		align-items: stretch;
		height: 28px;
		border-bottom: 1px solid rgba(0,0,0,0.25);
		position: relative;
		cursor: default;

		&:hover { background: var(--ps-hover); }
		&.active { background: var(--ps-selected); }
		&.invisible imageflow-layer-name, &.invisible imageflow-layer-thumbs { opacity: 0.5; }
		&.dragging { opacity: 0.5; }
		&.drop-above::before, &.drop-below::after {
			content: ''; position: absolute; left: 0; right: 0; height: 2px; background: var(--ps-accent); z-index: 2;
		}
		&.drop-above::before { top: -1px; }
		&.drop-below::after { bottom: -1px; }
		&.drop-into { box-shadow: inset 0 0 0 2px var(--ps-accent); }

		imageflow-layer-gutter {
			display: grid; place-items: center;
			width: 22px; flex: none;
			border-right: 1px solid rgba(0,0,0,0.25);
		}
		imageflow-layer-eye {
			display: grid; place-items: center;
			width: 20px; height: 20px;
			color: var(--ps-icon); flex: none;
			&:hover { color: #fff; }
		}
		&.invisible imageflow-layer-eye { color: var(--ps-icon-dim); }

		imageflow-layer-body {
			display: flex; align-items: center; gap: 8px;
			flex: 1; min-width: 0;
			padding: 0 8px 0 8px;
		}
		imageflow-clip-arrow {
			display: grid; place-items: center;
			width: 12px; flex: none; color: var(--ps-icon-dim);
		}
		imageflow-layer-chevron {
			display: grid; place-items: center;
			width: 12px; flex: none; color: var(--ps-icon-dim);
			transition: transform 0.1s ease;
			&.collapsed { transform: rotate(-90deg); }
		}
		imageflow-layer-thumbs {
			display: flex; align-items: center; gap: 3px; flex: none;
		}
		imageflow-layer-thumb {
			position: relative;
			flex: none;
			width: 24px; height: 24px;
			border: 1px solid #000;
			background-color: #fff;
			background-image: repeating-conic-gradient(#cfcfcf 0% 25%, #ffffff 0% 50%);
			background-size: 8px 8px;
			border-radius: 1px;
			overflow: hidden;
			display: grid; place-items: center;
			canvas, img { width: 100%; height: 100%; object-fit: contain; display: block; }
			/* Smart-object corner badge (Photoshop places it bottom-right). */
			imageflow-so-badge {
				position: absolute; right: 0; bottom: 0;
				display: grid; place-items: center;
				width: 12px; height: 12px;
				background: rgba(20, 115, 230, 0.92); color: #fff;
				border-top-left-radius: 2px;
				/* Linked smart object: teal chain, amber when the file moved on,
				   red when it can no longer be read. */
				&.linked { background: rgba(0, 150, 152, 0.92); }
				&.linked.stale { background: rgba(214, 145, 20, 0.95); }
				&.linked.missing { background: rgba(206, 60, 55, 0.95); }
			}
			&.adjustment { background: var(--ps-panel-sub); color: var(--ps-icon); }
			/* Reveal-all mask well: solid white, no checker. */
			&.mask.reveal { background: #fff; background-image: none; }
			/* Groups render a bare folder glyph — no boxed thumbnail. */
			&.group {
				background: none; border: none; color: var(--ps-icon);
				width: 22px; height: 22px;
			}
		}
		imageflow-layer-link {
			display: grid; place-items: center;
			width: 12px; flex: none; color: var(--ps-icon-dim);
		}
		imageflow-mask-thumb {
			flex: none;
			border: 1px solid #000;
			background-color: #fff;
			background-image: repeating-conic-gradient(#cfcfcf 0% 25%, #ffffff 0% 50%);
			background-size: 10px 10px;
			border-radius: 1px;
			overflow: hidden;
			display: grid; place-items: center;
			canvas { display: block; }
		}
		imageflow-layer-name {
			flex: 1; min-width: 0;
			font-size: 11px; color: var(--ps-text);
			white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
			input {
				width: 100%; font: inherit; color: #fff;
				background: var(--ps-field); border: 1px solid var(--ps-accent);
				border-radius: var(--ps-radius); padding: 1px 4px; outline: none;
			}
		}
		imageflow-layer-badges { display: flex; align-items: center; gap: 6px; flex: none; }
		imageflow-layer-badge {
			display: grid; place-items: center;
			color: var(--ps-icon-dim);
		}
		imageflow-layer-fx {
			display: inline-flex; align-items: center;
			font-size: 11px; font-style: italic; font-weight: 600;
			color: var(--ps-icon);
			cursor: default;
			&:hover { color: #fff; }
		}
		/* fx disclosure chevron, pinned to the row's right edge. */
		imageflow-layer-fx-chevron {
			display: grid; place-items: center;
			width: 14px; flex: none; margin-left: 4px;
			color: var(--ps-icon-dim); cursor: default;
			imageflow-icon { transition: transform 0.1s ease; transform: rotate(-90deg); }
			&.open imageflow-icon { transform: rotate(0deg); }
			&:hover { color: var(--ps-text); }
		}
	}

	/* --- fx effects sub-list ------------------------------------------ */
	imageflow-layer-effects {
		display: flex; flex-direction: column;
		background: color-mix(in srgb, #000 12%, var(--ps-panel));
	}
	imageflow-layer-effect {
		display: flex; align-items: center; gap: 8px;
		height: 22px;
		padding: 0 8px 0 40px;
		border-bottom: 1px solid rgba(0,0,0,0.2);
		imageflow-effect-eye {
			display: grid; place-items: center;
			width: 16px; height: 16px; flex: none;
			color: var(--ps-icon); cursor: default;
			&:hover { color: #fff; }
			&:not(.on) { color: var(--ps-icon-dim); }
		}
		imageflow-layer-name { font-size: 11px; color: var(--ps-text-dim); }
		/* The "Effects" master row sits above the per-effect rows. */
		&.master {
			padding-left: 26px;
			imageflow-layer-name { color: var(--ps-text); }
		}
	}

	/* =====================================================================
	   History panel
	   ================================================================== */
	/* Snapshot row: small document composite + document name. */
	imageflow-history-snapshot {
		display: flex; align-items: center; gap: 8px; flex: none;
		height: 34px; padding: 0 8px;
		imageflow-history-snap-thumb {
			flex: none; width: 32px; height: 24px;
			border: 1px solid #000; border-radius: 1px;
			background: #fff repeating-conic-gradient(#cfcfcf 0% 25%, #ffffff 0% 50%) 0 0 / 8px 8px;
			overflow: hidden; display: grid; place-items: center;
			img { width: 100%; height: 100%; object-fit: contain; display: block; }
			&.empty { background: var(--ps-panel-sub); }
		}
		> imageflow-label { font-size: 11px; color: var(--ps-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
	}
	imageflow-history-divider {
		display: block; height: 1px; flex: none;
		background: var(--ps-divider); box-shadow: 0 1px 0 var(--ps-edge-light);
	}
	imageflow-history-list { display: flex; flex-direction: column; }
	imageflow-history-entry {
		display: flex; align-items: center; gap: 6px;
		height: 22px; padding: 0 8px 0 0;
		font-size: 11px; color: var(--ps-text);
		cursor: default;
		/* Decorative history-brush source well gutter. */
		imageflow-history-well {
			flex: none; width: 20px; height: 100%;
			border-right: 1px solid rgba(0,0,0,0.25);
			background: var(--ps-panel-sub);
		}
		> imageflow-icon { color: var(--ps-icon-dim); flex: none; }
		> imageflow-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
		&:hover { background: var(--ps-hover); }
		&.active { background: var(--ps-selected); }
		&.future { color: var(--ps-text-faint); }
	}

	/* =====================================================================
	   Properties / Adjustments / Info panels
	   ================================================================== */
	imageflow-adjustment-caption {
		display: block; padding: 8px 10px 4px;
		font-size: 11px; font-weight: 600; color: var(--ps-text-dim);
	}
	imageflow-adjustment-grid {
		display: grid;
		grid-template-columns: repeat(4, 1fr);
		gap: 4px;
		padding: 0 10px 10px;
	}
	imageflow-adjustment-tile {
		display: grid; place-items: center;
		aspect-ratio: 1;
		border-radius: var(--ps-radius);
		color: var(--ps-icon);
		cursor: default;
		&:hover { background: var(--ps-hover); color: #fff; }
	}

	/* =====================================================================
	   Properties panel — type header, sections, transform grid
	   ================================================================== */
	imageflow-prop-header {
		display: flex; align-items: center; gap: 8px; flex: none;
		height: 30px; padding: 0 10px;
		border-bottom: 1px solid var(--ps-divider);
		imageflow-prop-icon { display: grid; place-items: center; color: var(--ps-icon); flex: none; }
		imageflow-prop-title { font-size: 11px; font-weight: 700; color: var(--ps-text); }
	}
	imageflow-prop-body { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: auto; }

	imageflow-prop-section {
		display: flex; flex-direction: column; flex: none;
		border-bottom: 1px solid var(--ps-divider);
		imageflow-section-header {
			display: flex; align-items: center; gap: 6px;
			height: 24px; padding: 0 8px;
			cursor: default;
			imageflow-section-chevron {
				display: grid; place-items: center; width: 12px; flex: none;
				color: var(--ps-icon-dim); transition: transform 0.1s ease;
				transform: rotate(-90deg);
				&.open { transform: rotate(0deg); }
			}
			imageflow-section-title { font-size: 11px; font-weight: 700; color: var(--ps-text); }
			imageflow-section-extra { margin-left: auto; display: flex; align-items: center; }
		}
		imageflow-section-body { display: flex; flex-direction: column; padding: 4px 0 8px; }
	}

	/* Properties — Smart Object section */
	imageflow-so-info {
		display: flex; align-items: flex-start; gap: 8px; padding: 2px 8px 6px;
		imageflow-so-icon { flex: none; color: var(--ps-accent); margin-top: 1px; }
		imageflow-label { font-size: 11px; line-height: 1.4; color: var(--ps-text-dim); }
	}
	imageflow-so-actions {
		display: flex; padding: 0 8px;
		.imageflow-so-edit {
			appearance: none; cursor: default;
			font-size: 11px; color: var(--ps-text);
			background: var(--ps-btn, #4b4b4b); border: 1px solid var(--ps-divider);
			border-radius: 3px; padding: 4px 12px; width: 100%;
			&:hover { background: var(--ps-btn-hover, #565656); }
			&:active { background: var(--ps-accent); border-color: var(--ps-accent); color: #fff; }
		}
	}

	imageflow-transform-grid {
		display: grid;
		grid-template-columns: 1fr 22px 1fr;
		align-items: center;
		gap: 6px 6px;
		padding: 4px 10px;
		imageflow-transform-cell {
			display: flex; align-items: center; gap: 6px;
			> imageflow-label { width: 14px; flex: none; color: var(--ps-text-dim); font-size: 11px; }
			imageflow-number { flex: 1; min-width: 0; }
		}
		imageflow-transform-link {
			grid-row: span 2;
			display: grid; place-items: center;
			width: 22px; height: 36px;
			color: var(--ps-icon-dim); cursor: default;
			border-radius: var(--ps-radius);
			&:hover { color: var(--ps-text); }
			&.active { color: var(--ps-accent-hi); }
		}
		imageflow-transform-spacer { display: none; }
	}

	/* Adjustment editor: pinned bottom action bar. */
	imageflow-adjustment-footer {
		display: flex; align-items: center; gap: 2px; flex: none;
		height: 30px; padding: 0 8px;
		background: var(--ps-panel-header);
		border-top: 1px solid var(--ps-divider);
		imageflow-spacer { flex: 1; }
		imageflow-button {
			display: grid; place-items: center;
			width: 26px; height: 24px; border-radius: var(--ps-radius);
			color: var(--ps-icon); background: none; border: none; box-shadow: none;
			&:hover { background: var(--ps-hover); color: #fff; }
			&.active { background: var(--ps-active); color: #fff; }
			&:disabled, &.disabled { color: var(--ps-text-disabled); pointer-events: none; }
		}
	}

	/* Levels luminance histogram. */
	imageflow-histogram {
		display: block; margin: 6px 10px;
		padding: 4px;
		background: var(--ps-field); border: 1px solid #000; border-radius: var(--ps-radius);
		canvas { display: block; width: 100%; height: 90px; image-rendering: pixelated; }
	}

	/* Hue/Saturation rainbow ramp strips. */
	imageflow-huesat-ramps {
		display: flex; flex-direction: column; gap: 6px;
		padding: 8px 10px;
		imageflow-hue-ramp {
			display: block; height: 12px; border-radius: 2px; border: 1px solid #000;
			background: linear-gradient(to right,
				#ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%,
				#0000ff 67%, #ff00ff 83%, #ff0000 100%);
		}
	}

	imageflow-info-row {
		display: flex; align-items: baseline; gap: 8px;
		padding: 3px 10px;
		font-size: 11px;
		imageflow-info-label { min-width: 58px; color: var(--ps-text-dim); }
		imageflow-info-value { color: var(--ps-text); font-variant-numeric: tabular-nums; }
	}

	imageflow-field.about { padding: 10px; color: var(--ps-text-dim); line-height: 1.6; }

	/* =====================================================================
	   Controls — Button
	   ================================================================== */
	imageflow-button {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		gap: 6px;
		height: 24px;
		padding: 0 12px;
		font: inherit; font-size: 11px;
		color: var(--ps-text);
		background: linear-gradient(#3b3b3b, #333);
		border: 1px solid #232323;
		border-radius: var(--ps-radius);
		box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
		cursor: default;
		white-space: nowrap;

		&:hover { background: linear-gradient(#454545, #3b3b3b); }
		&:active { background: #2b2b2b; box-shadow: inset 0 1px 2px rgba(0,0,0,0.4); }
		&.primary {
			color: #fff;
			background: linear-gradient(var(--ps-accent-hi), var(--ps-accent));
			border-color: var(--ps-accent-press);
			&:hover { background: linear-gradient(#3a8ef5, var(--ps-accent-hi)); }
			&:active { background: var(--ps-accent-press); }
		}
		&.ghost { background: none; border-color: transparent; box-shadow: none; padding: 0; height: auto;
			&:hover { background: none; } }
		&.small { height: 20px; padding: 0 8px; }
		&.disabled, &:disabled { color: var(--ps-text-disabled); pointer-events: none;
			background: #2e2e2e; box-shadow: none; }
	}
	imageflow-button-group {
		display: inline-flex;
		imageflow-button { border-radius: 0; margin-left: -1px;
			&:first-child { border-radius: var(--ps-radius) 0 0 var(--ps-radius); margin-left: 0; }
			&:last-child { border-radius: 0 var(--ps-radius) var(--ps-radius) 0; }
			&.active { background: var(--ps-active); color: #fff; z-index: 1; }
		}
	}

	/* Icon inside controls */
	imageflow-icon { display: inline-grid; place-items: center; flex: none; }
	imageflow-icon svg { display: block; }

	/* =====================================================================
	   Controls — Slider (scrubby, Photoshop-flat)
	   ================================================================== */
	imageflow-slider {
		display: inline-flex;
		align-items: center;
		gap: 8px;
		min-width: 40px;
		flex: 1;
		imageflow-label { color: var(--ps-text-dim); }

		imageflow-slider-track {
			position: relative;
			flex: 1;
			height: 4px;
			border-radius: 2px;
			background: var(--ps-field);
			border: 1px solid #000;
			cursor: default;

			imageflow-slider-fill {
				position: absolute; left: 0; top: 0; bottom: 0;
				border-radius: 2px 0 0 2px;
				background: linear-gradient(#8a8a8a, #6f6f6f);
			}
			imageflow-slider-thumb {
				position: absolute; top: 50%;
				width: 11px; height: 11px;
				transform: translate(-50%, -50%);
				background: linear-gradient(#efefef, #cfcfcf);
				border: 1px solid #1a1a1a;
				border-radius: 50%;
				box-shadow: 0 1px 2px rgba(0,0,0,0.5);
			}
			&:hover imageflow-slider-thumb { background: linear-gradient(#fff, #e0e0e0); }
		}
		&.small imageflow-slider-track { height: 3px; }
		.value { min-width: 32px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ps-text); }
	}

	/* =====================================================================
	   Controls — NumberInput / text field
	   ================================================================== */
	imageflow-number, imageflow-field.input {
		display: inline-flex;
		align-items: stretch;
		height: 20px;
		background: var(--ps-field);
		border: 1px solid #000;
		border-radius: var(--ps-radius);
		box-shadow: inset 0 1px 1px rgba(0,0,0,0.4);
		overflow: hidden;
		/* Normalise the text box so value + suffix share one baseline. */
		line-height: 1;

		.scrub {
			display: grid; place-items: center;
			padding: 0 4px; height: 100%;
			color: var(--ps-text-dim);
			cursor: ew-resize;
			border-right: 1px solid #000;
			&:hover { color: var(--ps-text); }
		}
		input {
			width: 46px;
			height: 100%;
			padding: 0 5px;
			font: inherit; font-variant-numeric: tabular-nums;
			line-height: 1;
			text-align: right;
			color: var(--ps-text);
			background: none; border: none; outline: none;
		}
		/* Flex-center the suffix on the same axis as the input's text box. */
		.suffix { display: inline-flex; align-items: center; padding: 0 5px 0 0; color: var(--ps-text-dim); }
		&:focus-within { border-color: var(--ps-accent); box-shadow: 0 0 0 1px var(--ps-accent); }
	}

	/* =====================================================================
	   Controls — Select
	   ================================================================== */
	imageflow-select {
		position: relative;
		display: inline-flex;
		align-items: center;
		height: 20px;
		min-width: 96px;
		padding: 0 6px;
		background: var(--ps-field);
		border: 1px solid #000;
		border-radius: var(--ps-radius);
		box-shadow: inset 0 1px 1px rgba(0,0,0,0.35);
		color: var(--ps-text);
		cursor: default;

		imageflow-select-value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
		&::after {
			content: ''; margin-left: 6px;
			width: 0; height: 0;
			border-left: 3px solid transparent; border-right: 3px solid transparent;
			border-top: 4px solid var(--ps-icon-dim);
		}
		&:hover { border-color: #2a2a2a; }
		&.open { border-color: var(--ps-accent); }
		&.compact { min-width: 72px; }
		&.disabled { color: var(--ps-text-disabled); pointer-events: none; }

		imageflow-options {
			position: absolute; top: 100%; left: 0; margin-top: 2px;
			min-width: 100%;
			max-height: 320px; overflow-y: auto;
			background: var(--ps-panel-sub);
			border: 1px solid #000;
			border-radius: var(--ps-radius);
			box-shadow: 0 8px 24px rgba(0,0,0,0.55);
			z-index: 600;
			padding: 3px;

			imageflow-option {
				display: flex; align-items: center; gap: 7px;
				height: 22px; padding: 0 8px; border-radius: var(--ps-radius);
				white-space: nowrap;
				&:hover { background: var(--ps-accent); color: #fff; }
				&.selected { color: #fff; }
			}
			imageflow-option-group {
				display: block; padding: 5px 8px 2px; margin-top: 2px;
				font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px;
				color: var(--ps-text-faint);
				border-top: 1px solid var(--ps-divider);
				&:first-child { border-top: none; margin-top: 0; }
			}
		}
	}

	/* =====================================================================
	   Font picker — a font-preview family menu (each name in its own face),
	   virtualized + searchable for the full Google Fonts catalog.
	   ===================================================================== */
	imageflow-font-picker {
		position: relative;
		display: inline-flex;
		align-items: center;
		height: 20px;
		min-width: 140px;
		padding: 0 6px;
		background: var(--ps-field);
		border: 1px solid #000;
		border-radius: var(--ps-radius);
		box-shadow: inset 0 1px 1px rgba(0,0,0,0.35);
		color: var(--ps-text);
		cursor: default;

		imageflow-select-value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
		&::after {
			content: ''; margin-left: 6px;
			width: 0; height: 0;
			border-left: 3px solid transparent; border-right: 3px solid transparent;
			border-top: 4px solid var(--ps-icon-dim);
		}
		&:hover { border-color: #2a2a2a; }
		&.open { border-color: var(--ps-accent); }
		&.small { min-width: 120px; }
		&.disabled { color: var(--ps-text-disabled); pointer-events: none; }
	}

	/* Font-picker dropdown — portaled to the editor root so it escapes the
	   panel-body's `overflow:auto` clipping; positioned via inline top/left. */
	imageflow-font-panel {
		position: fixed; margin-top: 2px;
		display: flex; flex-direction: column;
		width: 300px;
			background: var(--ps-panel-sub);
			border: 1px solid #000;
			border-radius: var(--ps-radius);
			box-shadow: 0 8px 24px rgba(0,0,0,0.55);
			z-index: 600;
			padding: 6px;
			cursor: default;
		}

		imageflow-font-search {
			display: flex; align-items: center; gap: 6px;
			padding: 0 7px; height: 26px;
			background: var(--ps-field);
			border: 1px solid #000; border-radius: var(--ps-radius);
			box-shadow: inset 0 1px 1px rgba(0,0,0,0.35);
			color: var(--ps-icon-dim);
			> input {
				flex: 1; min-width: 0;
				background: transparent; border: none; outline: none;
				color: var(--ps-text); font-size: 12px;
			}
		}

		imageflow-font-cats {
			display: flex; flex-wrap: wrap; gap: 3px;
			padding: 6px 0 2px;
			imageflow-font-cat {
				padding: 2px 7px; border-radius: 9px;
				font-size: 10px; text-transform: uppercase; letter-spacing: 0.3px;
				color: var(--ps-text-faint); background: var(--ps-field);
				cursor: default;
				&:hover { color: var(--ps-text); }
				&.active { background: var(--ps-accent); color: #fff; }
			}
		}

		imageflow-font-viewport {
			position: relative; display: block;
			height: 320px; overflow-y: auto; overflow-x: hidden;
			margin-top: 4px;
		}
		imageflow-font-list { position: relative; display: block; width: 100%; }
		imageflow-font-empty {
			display: block; padding: 16px 8px; text-align: center;
			color: var(--ps-text-faint); font-size: 12px;
		}
		imageflow-font-item {
			position: absolute; left: 0; right: 0; top: 0;
			display: flex; align-items: center; gap: 7px;
			height: 30px; padding: 0 9px; border-radius: var(--ps-radius);
			white-space: nowrap; overflow: hidden;
			font-size: 17px; line-height: 1;
			color: var(--ps-text);
			&:hover { background: var(--ps-accent); color: #fff; }
			&.active { background: rgba(20,115,230,0.35); }
			imageflow-font-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
			imageflow-font-badge {
				font-size: 9px; text-transform: uppercase; letter-spacing: 0.3px;
				padding: 1px 5px; border-radius: 8px;
				background: rgba(255,255,255,0.12); color: var(--ps-text-faint);
			}
			.tick { flex: none; }
		}

		imageflow-font-add {
			display: flex; align-items: center; gap: 7px;
			margin-top: 6px; padding: 0 9px; height: 26px;
			border-top: 1px solid var(--ps-divider);
			color: var(--ps-accent); font-size: 12px;
			cursor: default;
			> span { flex: 1; }
			&:hover { color: #fff; }
		}

	/* =====================================================================
	   Controls — Checkbox
	   ================================================================== */
	imageflow-checkbox {
		display: inline-flex; align-items: center; gap: 6px;
		cursor: default;
		imageflow-checkbox-box {
			display: grid; place-items: center;
			width: 14px; height: 14px;
			background: var(--ps-field);
			border: 1px solid #000;
			border-radius: var(--ps-radius);
			box-shadow: inset 0 1px 1px rgba(0,0,0,0.4);
			color: transparent;
		}
		&.checked imageflow-checkbox-box { background: var(--ps-accent); border-color: var(--ps-accent-press); color: #fff; }
	}

	/* =====================================================================
	   Controls — Color well + picker + swatches
	   ================================================================== */
	imageflow-color-well {
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: stretch;
		width: 28px;
		margin: 8px auto 2px;

		/* CC layout: default-colors (left) + swap (right) mini-row on top. */
		imageflow-color-well-mini {
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 13px;
			margin-bottom: 1px;
		}
		imageflow-button.swap, imageflow-button.reset {
			width: 12px; height: 12px; min-width: 0; padding: 0;
			display: grid; place-items: center;
			background: none; border: none; box-shadow: none;
			color: var(--ps-icon-dim);
			cursor: default;
			&:hover { color: var(--ps-text); background: none; }
		}

		imageflow-color-well-swatches {
			position: relative;
			width: 28px; height: 28px;
		}
		imageflow-color-well-swatches > imageflow-swatch {
			/* !important: the [data-tooltip] hook sets position: relative at
			   class specificity — the swatches must stay absolutely stacked. */
			position: absolute !important;
			width: 20px; height: 20px;
			border: 1px solid #101010;
			box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
			border-radius: 0;
			cursor: default;
		}
		imageflow-color-well-swatches > imageflow-swatch.foreground { top: 0; left: 0; z-index: 2; }
		imageflow-color-well-swatches > imageflow-swatch.background { right: 0; bottom: 0; z-index: 1; }

		/* Picker popover anchored to the right of the rail. */
		imageflow-popover.colorwell {
			position: absolute;
			left: calc(100% + 8px);
			bottom: -10px;
			display: flex;
			flex-direction: column;
			gap: 8px;
			imageflow-label.picker-title { font-weight: 600; color: var(--ps-text); }
		}
	}

	/* Premium text inputs — global scope so dialogs AND popovers get the dark field. */
	imageflow-field > input[type="text"], imageflow-dialog-row > input[type="text"] {
		flex: 1; width: 100%; height: 22px; padding: 2px 7px;
		font: inherit; color: var(--ps-text);
		background: var(--ps-field); border: 1px solid #000; border-radius: var(--ps-radius);
		box-shadow: inset 0 1px 1px rgba(0,0,0,0.4); outline: none;
	}
	imageflow-field > input[type="text"]:focus, imageflow-dialog-row > input[type="text"]:focus {
		border-color: var(--ps-accent); box-shadow: 0 0 0 1px var(--ps-accent);
	}

	imageflow-swatch {
		display: inline-block;
		width: 40px; height: 20px;
		border: 1px solid #000;
		border-radius: var(--ps-radius);
		background-image: repeating-conic-gradient(#bcbcbc 0% 25%, #fff 0% 50%);
		background-size: 8px 8px;
		position: relative;
		cursor: default;
		&::after { content: ''; position: absolute; inset: 0; background: var(--swatch-color, #000); }
	}

	imageflow-color-picker {
		display: flex; flex-direction: column; gap: 10px;
		width: 260px;

		imageflow-color-area {
			position: relative;
			height: 180px;
			border-radius: var(--ps-radius);
			cursor: crosshair;
			overflow: hidden;
			background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, var(--picker-hue, #f00));
			imageflow-color-cursor {
				position: absolute; width: 12px; height: 12px;
				border: 2px solid #fff; border-radius: 50%;
				box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
				transform: translate(-50%, -50%);
				pointer-events: none;
			}
		}
		imageflow-color-hue, imageflow-color-alpha {
			position: relative; height: 12px; border-radius: 6px; cursor: pointer;
			imageflow-color-cursor {
				position: absolute; top: 50%; width: 14px; height: 14px;
				border: 2px solid #fff; border-radius: 50%;
				box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
				transform: translate(-50%, -50%);
			}
		}
		imageflow-color-hue {
			background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
		}
		imageflow-color-alpha {
			background: linear-gradient(to right, transparent, var(--picker-color, #000)), repeating-conic-gradient(#bcbcbc 0% 25%, #fff 0% 50%);
			background-size: auto, 8px 8px;
		}
		imageflow-color-inputs {
			display: grid; grid-template-columns: auto minmax(64px, 1.4fr) 1fr 1fr 1fr; gap: 6px; align-items: center;
			imageflow-color-preview > imageflow-swatch { width: 34px; height: 24px; }
		}
	}
	imageflow-swatches {
		display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px;
		imageflow-swatch { width: 100%; height: auto; aspect-ratio: 1; border: 1px solid #000; cursor: default; &:hover { outline: 1px solid #fff; } }
	}

	/* =====================================================================
	   Menus (dropdowns) — flat, blue hover, opaque
	   ================================================================== */
	imageflow-menu {
		display: block;
		min-width: 200px;
		padding: 4px 0;
		background: var(--ps-panel-sub);
		border: 1px solid #000;
		box-shadow: 0 3px 8px rgba(0,0,0,0.55);
		z-index: 500;

		imageflow-menu-item {
			display: flex; align-items: center;
			height: 22px; padding: 0 22px 0 24px;
			position: relative;
			font-size: 11px; color: var(--ps-text);
			white-space: nowrap;
			cursor: default;

			imageflow-menu-check {
				position: absolute; left: 8px;
				display: grid; place-items: center; color: var(--ps-text);
			}
			imageflow-menu-label { flex: 1; }
			imageflow-menu-shortcut { margin-left: 28px; color: var(--ps-text-faint); }

			&:hover { background: var(--ps-accent); color: #fff; }
			&:hover imageflow-menu-shortcut { color: rgba(255,255,255,0.75); }
			&:hover imageflow-menu-check { color: #fff; }
			&.disabled { color: var(--ps-text-disabled); pointer-events: none; }
			&.submenu::after {
				content: ''; position: absolute; right: 8px;
				width: 0; height: 0;
				border-top: 4px solid transparent; border-bottom: 4px solid transparent;
				border-left: 5px solid currentColor;
			}
			/* Fly-out submenu: hidden until hover, opens at the right edge. */
			> imageflow-submenu { display: none; position: absolute; left: 100%; top: -5px; }
			&.submenu:hover > imageflow-submenu,
			&.submenu:focus-within > imageflow-submenu { display: block; }
			/* The inline chevron icon is redundant with the ::after arrow. */
			> imageflow-icon.chevron { display: none; }
		}
		imageflow-menu-separator {
			display: block; height: 1px; margin: 4px 0;
			background: #3a3a3a;
			border: 0;
		}
	}

	/* =====================================================================
	   Dialogs (modals) — Photoshop panel look
	   ================================================================== */
	imageflow-dialogs {
		position: fixed; inset: 0;
		display: grid; place-items: center;
		background: rgba(0,0,0,0.45);
		z-index: 700;
	}
	imageflow-dialog {
		display: flex; flex-direction: column;
		min-width: 340px; max-width: 560px;
		background: var(--ps-panel);
		border: 1px solid #000;
		border-radius: var(--ps-radius-lg);
		box-shadow: 0 20px 60px rgba(0,0,0,0.7), inset 0 1px 0 var(--ps-edge-light);
		overflow: hidden;

		imageflow-dialog-header {
			display: flex; align-items: center;
			height: 30px; padding: 0 12px;
			font-size: 12px; font-weight: 600;
			background: var(--ps-panel-header);
			border-bottom: 1px solid var(--ps-divider);
			.close { margin-left: auto; color: var(--ps-icon-dim); }
			.close:hover { color: #fff; }
		}
		imageflow-dialog-body {
			display: flex; flex-direction: column; gap: 10px;
			padding: 14px 14px;
			max-height: 70vh; overflow: auto;
		}
		imageflow-dialog-footer {
			display: flex; justify-content: flex-end; gap: 8px;
			padding: 10px 14px;
			background: var(--ps-panel-header);
			border-top: 1px solid var(--ps-divider);
		}
		imageflow-dialog-row {
			display: flex; align-items: center; gap: 10px;
		}
		imageflow-dialog-row > imageflow-label { min-width: 96px; color: var(--ps-text-dim); text-align: right; }
		imageflow-dialog-note { color: var(--ps-text-faint); font-size: 11px; }
		imageflow-field { display: flex; align-items: center; flex: 1; }
		imageflow-dialog-preview {
			display: grid; place-items: center;
			background-image: repeating-conic-gradient(#3a3a3a 0% 25%, #444 0% 50%);
			background-size: 16px 16px;
			border: 1px solid #000; border-radius: var(--ps-radius);
		}
		imageflow-dialog-preview canvas { max-width: 100%; display: block; }
	}

	/* Anchor grid (Canvas Size dialog) */
	.anchor-grid {
		display: grid; grid-template-columns: repeat(3, 24px); grid-template-rows: repeat(3, 24px); gap: 2px;
	}
	.anchor-grid imageflow-button { width: 24px; height: 24px; padding: 0; font-size: 13px; }
	/* Selected anchor cell = empty (no arrow, no accent fill), just a pressed inset. */
	.anchor-grid imageflow-button.active { background: var(--ps-field); box-shadow: inset 0 1px 3px rgba(0,0,0,0.6); }

	/* =====================================================================
	   Dialog wide variants + compact button column
	   ================================================================== */
	imageflow-dialog.compact { max-width: 640px; }
	imageflow-dialog.newdoc { max-width: 760px; width: 760px; }
	imageflow-dialog.imagesize, imageflow-dialog.export { max-width: 640px; width: 640px; }
	imageflow-dialog.colorpicker { max-width: 620px; width: 620px; }
	imageflow-dialog.filter { max-width: 560px; }
	imageflow-dialog.restore-session { max-width: 420px; width: 420px; }

	/* ---- Restore Previous Session ------------------------------------- */
	imageflow-restore-lead {
		display: flex; align-items: center; gap: 12px;
		color: var(--ps-text); font-size: 12px; line-height: 1.5;
	}
	imageflow-restore-lead svg { color: var(--ps-accent, #4a90d9); flex: none; }
	imageflow-restore-list {
		display: flex; flex-direction: column; gap: 2px;
		max-height: 200px; overflow: auto;
		padding: 6px; margin-top: 2px;
		background: var(--ps-field); border: 1px solid var(--ps-divider); border-radius: var(--ps-radius);
	}
	imageflow-restore-item {
		display: flex; align-items: center; gap: 8px;
		padding: 4px 6px; border-radius: var(--ps-radius);
		font-size: 12px; color: var(--ps-text);
	}
	imageflow-restore-item svg { color: var(--ps-icon-dim); flex: none; }
	imageflow-restore-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	imageflow-restore-dims { color: var(--ps-text-faint); font-size: 11px; flex: none; }

	imageflow-dialog-split {
		display: flex; align-items: flex-start; gap: 14px;
		padding: 14px;
		imageflow-dialog-body { flex: 1; padding: 0; overflow: visible; }
	}
	imageflow-dialog-buttoncol {
		display: flex; flex-direction: column; gap: 8px; flex: none;
		min-width: 96px;
		imageflow-button { justify-content: center; width: 100%; }
	}

	/* Preview thumbnail panes (Image Size / Export). */
	imageflow-dialog-preview.thumb { width: 200px; height: 200px; flex: none; }
	imageflow-dialog-preview.thumb canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
	imageflow-dialog-preview.filter { width: 100%; height: 240px; }
	imageflow-dialog-preview.filter canvas { max-width: 100%; max-height: 100%; }

	/* ---- New Document -------------------------------------------------- */
	imageflow-dialog.newdoc > imageflow-dialog-body { display: none; }
	imageflow-newdoc-tabs {
		display: flex; align-items: center; gap: 18px;
		height: 40px; padding: 0 18px;
		background: var(--ps-panel-header); border-bottom: 1px solid var(--ps-divider);
		font-size: 12px;
	}
	imageflow-newdoc-tab {
		color: var(--ps-text-dim); cursor: default; padding: 2px 0;
		border-bottom: 2px solid transparent;
		&:hover { color: var(--ps-text); }
		&.active { color: #fff; border-bottom-color: #fff; }
	}
	imageflow-newdoc-cols { display: flex; align-items: stretch; min-height: 360px; }
	imageflow-newdoc-gallery {
		flex: 1; padding: 14px 16px; overflow: auto; max-height: 60vh;
	}
	imageflow-newdoc-gallery-head {
		display: block; font-size: 10px; letter-spacing: 0.5px;
		color: var(--ps-text-faint); margin-bottom: 10px;
	}
	imageflow-newdoc-grid {
		display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
	}
	imageflow-preset-card {
		display: flex; flex-direction: column;
		border: 1px solid transparent; border-radius: var(--ps-radius);
		padding: 4px; cursor: default;
		&:hover { border-color: #555; }
		&.active { border-color: var(--ps-accent); box-shadow: 0 0 0 1px var(--ps-accent); }
	}
	imageflow-preset-thumb {
		display: grid; place-items: center;
		width: 100%; max-height: 96px; min-height: 60px;
		background: var(--ps-field); border: 1px solid #000; border-radius: 2px;
		color: var(--ps-icon-dim); margin-bottom: 6px;
	}
	imageflow-preset-name { font-size: 11px; color: var(--ps-text); }
	imageflow-preset-dims { font-size: 10px; color: var(--ps-text-faint); }
	imageflow-newdoc-details {
		flex: none; width: 260px; padding: 14px 16px;
		background: var(--ps-panel-header); border-left: 1px solid var(--ps-divider);
		display: flex; flex-direction: column; gap: 10px;
	}
	imageflow-newdoc-details-head {
		display: block; font-size: 10px; letter-spacing: 0.5px; color: var(--ps-text-faint);
	}
	imageflow-newdoc-details imageflow-dialog-row {
		display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center;
	}
	imageflow-newdoc-details imageflow-dialog-row > imageflow-label {
		grid-column: 1 / -1; min-width: 0; text-align: left; color: var(--ps-text-dim);
	}
	imageflow-newdoc-orient { display: flex; gap: 4px; }
	imageflow-field.newdoc-name { width: 100%; }

	/* ---- Image Size ---------------------------------------------------- */
	imageflow-imagesize-body { display: flex; gap: 16px; align-items: flex-start; }
	imageflow-imagesize-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; }
	imageflow-imagesize-fields imageflow-dialog-row > imageflow-label { min-width: 84px; }
	imageflow-imagesize-dims { display: flex; align-items: stretch; gap: 6px; }
	imageflow-imagesize-link {
		display: flex; align-items: center; justify-content: center;
		width: 16px; flex: none; color: var(--ps-icon-dim);
		border-left: 1px solid var(--ps-divider); border-top: 1px solid var(--ps-divider);
		border-bottom: 1px solid var(--ps-divider); border-radius: 3px 0 0 3px;
		cursor: default;
		&.linked { color: var(--ps-accent); }
	}
	imageflow-imagesize-rows { flex: 1; display: flex; flex-direction: column; gap: 8px; }
	imageflow-imagesize-fields imageflow-select { min-width: 130px; }

	/* ---- Export -------------------------------------------------------- */
	imageflow-export-body { display: flex; gap: 16px; align-items: flex-start; }
	imageflow-export-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; }
	imageflow-export-legend {
		display: block; font-size: 10px; letter-spacing: 0.5px; color: var(--ps-text-faint);
		margin-top: 6px; border-top: 1px solid var(--ps-divider); padding-top: 8px;
	}

	/* ==== Export As (multi-scale) + Save for Web ======================== */
	/* Added by the export-capabilities work: Export As list rows, the
	   "Add scale" affordance, and the Save-for-Web 2-up optimizer. */
	imageflow-dialog.exportas { max-width: 680px; width: 680px; }
	imageflow-dialog.exportas imageflow-export-fields { max-height: 420px; overflow-y: auto; }
	imageflow-exportas-list { display: flex; flex-direction: column; gap: 10px; }
	imageflow-exportas-row {
		display: block; border: 1px solid var(--ps-divider); border-radius: var(--ps-radius);
		padding: 8px 10px; background: rgba(255, 255, 255, 0.02);
	}
	imageflow-exportas-row > imageflow-dialog-row { margin-bottom: 6px; }
	imageflow-exportas-row > imageflow-dialog-row:last-child { margin-bottom: 0; }
	imageflow-exportas-head {
		display: flex; align-items: center; justify-content: space-between;
		margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--ps-divider);
	}
	imageflow-exportas-dims { font-size: 11px; color: var(--ps-text-dim); font-variant-numeric: tabular-nums; }
	imageflow-field.exportas-suffix { flex: 1; }
	imageflow-field.exportas-suffix > input[type=text] { width: 100%; }
	imageflow-exportas-add {
		display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
		margin-top: 10px; padding: 5px 10px; font-size: 11px; color: var(--ps-text-dim);
		border: 1px dashed var(--ps-divider); border-radius: var(--ps-radius);
	}
	imageflow-exportas-add:hover { color: var(--ps-text); border-color: var(--ps-accent); }

	imageflow-dialog.saveforweb { max-width: 720px; width: 720px; }
	imageflow-sfw-body { display: flex; flex-direction: column; gap: 14px; }
	imageflow-sfw-preview { display: flex; gap: 14px; }
	imageflow-sfw-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; }
	imageflow-sfw-pane-label {
		font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--ps-text-faint);
	}
	imageflow-sfw-pane imageflow-dialog-preview.thumb {
		width: 100%; height: 200px; display: flex; align-items: center; justify-content: center;
	}
	imageflow-sfw-fields { display: flex; flex-direction: column; gap: 8px; }

	/* ---- Filter dialog ------------------------------------------------- */
	imageflow-filter-body { display: flex; gap: 14px; padding: 14px 14px 0; align-items: flex-start; }
	imageflow-filter-left { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
	imageflow-filter-zoom {
		display: flex; align-items: center; justify-content: center; gap: 10px;
		color: var(--ps-text-dim); font-size: 11px;
	}
	imageflow-filter-right { flex: none; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
	imageflow-filter-params {
		display: flex; flex-direction: column; gap: 8px;
		padding: 12px 14px 16px;
	}
	imageflow-filter-param { display: flex; flex-direction: column; gap: 4px; }
	imageflow-filter-param-head {
		display: flex; align-items: center; gap: 8px;
		imageflow-label { min-width: 70px; color: var(--ps-text-dim); }
		imageflow-number { margin-left: auto; }
	}
	/* One value display per param: NumberInput shows it, hide the slider's. */
	imageflow-filter-param imageflow-slider { width: 100%; }
	imageflow-filter-param imageflow-slider > imageflow-label.value { display: none; }

	/* ---- Canvas Size / Fill / Stroke framed groups --------------------- */
	imageflow-canvassize-group {
		display: block; position: relative;
		border: 1px solid var(--ps-divider); border-radius: var(--ps-radius);
		padding: 14px 12px 10px; margin-top: 6px;
	}
	imageflow-canvassize-group > imageflow-dialog-row { margin-bottom: 8px; }
	imageflow-canvassize-group > imageflow-dialog-row:last-child { margin-bottom: 0; }
	imageflow-canvassize-group > imageflow-dialog-note { display: block; margin-left: 12px; }
	imageflow-canvassize-legend {
		position: absolute; top: -8px; left: 8px; padding: 0 6px;
		background: var(--ps-panel); font-size: 11px; color: var(--ps-text-dim);
	}
	imageflow-canvassize-group imageflow-dialog-row > imageflow-label { min-width: 130px; }

	/* Fill/Stroke Location radio buttons */
	imageflow-radio-row { display: flex; gap: 16px; }
	imageflow-radio {
		display: inline-flex; align-items: center; gap: 6px;
		font-size: 11px; color: var(--ps-text-dim); cursor: default;
		&.active { color: var(--ps-text); }
	}
	imageflow-radio-dot {
		width: 12px; height: 12px; border-radius: 50%;
		border: 1px solid #000; background: var(--ps-field);
		box-shadow: inset 0 1px 1px rgba(0,0,0,0.4);
		display: inline-block; position: relative;
	}
	imageflow-radio.active imageflow-radio-dot::after {
		content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--ps-accent);
	}

	/* ---- Color Picker dialog ------------------------------------------ */
	imageflow-cp { display: flex; gap: 12px; padding: 14px; align-items: stretch; }
	/* Standalone SV square (not nested under imageflow-color-picker, so it
	   must carry its own gradient / positioning / cursor styling). */
	imageflow-color-area.cp {
		position: relative; width: 260px; height: 260px; flex: none;
		border-radius: var(--ps-radius); cursor: crosshair; overflow: hidden;
		background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, var(--picker-hue, #f00));
		imageflow-color-cursor {
			position: absolute; width: 12px; height: 12px;
			border: 2px solid #fff; border-radius: 50%;
			box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
			transform: translate(-50%, -50%); pointer-events: none;
		}
	}
	imageflow-cp-hue {
		position: relative; width: 24px; flex: none; border-radius: 2px; cursor: pointer;
		background: linear-gradient(to bottom, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
		imageflow-color-cursor {
			position: absolute; left: 50%; width: 30px; height: 8px;
			border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
			transform: translate(-50%, -50%); pointer-events: none;
		}
	}
	imageflow-cp-right { flex: 1; display: flex; flex-direction: column; gap: 14px; }
	imageflow-cp-preview { display: flex; gap: 12px; align-items: flex-start; }
	imageflow-cp-swatchcol { display: flex; flex-direction: column; }
	imageflow-cp-swatchlabel { font-size: 10px; color: var(--ps-text-faint); text-align: center; }
	imageflow-cp-swatchcol > imageflow-swatch { width: 60px; height: 34px; border-radius: 0; }
	imageflow-cp-swatchcol > imageflow-swatch.cp-new { border-bottom: none; }
	imageflow-cp-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
	imageflow-cp-field {
		display: flex; align-items: center; gap: 6px;
		> imageflow-label { width: 16px; color: var(--ps-text-dim); text-align: right; }
		> imageflow-number { flex: 1; min-width: 0; }
		> imageflow-field { flex: 1; }
	}
	imageflow-cp-field.hex { grid-column: 1 / -1; }
	imageflow-cp-unit { color: var(--ps-text-faint); font-size: 11px; }
	imageflow-cp-footer { padding: 0 14px 14px; }

	/* =====================================================================
	   Popovers, tooltips, misc
	   ================================================================== */
	imageflow-popover {
		position: absolute; z-index: 620;
		padding: 8px;
		background: var(--ps-panel-sub);
		border: 1px solid #000;
		border-radius: var(--ps-radius);
		box-shadow: 0 10px 30px rgba(0,0,0,0.6);
	}

	[data-tooltip] { position: relative; }
	[data-tooltip]:hover::after {
		content: attr(data-tooltip);
		position: absolute; left: 100%; top: 50%;
		transform: translateY(-50%);
		margin-left: 8px;
		padding: 3px 7px;
		font-size: 10px; color: #fff; white-space: nowrap;
		background: #000; border: 1px solid #444; border-radius: var(--ps-radius);
		box-shadow: 0 2px 8px rgba(0,0,0,0.6);
		pointer-events: none;
		z-index: 800;
	}
	imageflow-toolbar [data-tooltip]:hover::after { z-index: 900; }

	imageflow-kbd {
		display: inline-grid; place-items: center;
		min-width: 16px; padding: 1px 4px;
		font-size: 10px; color: var(--ps-text-dim);
		background: var(--ps-field); border: 1px solid #000; border-radius: var(--ps-radius);
	}

	imageflow-spinner {
		display: inline-block; width: 14px; height: 14px;
		border: 2px solid var(--ps-edge-light); border-top-color: var(--ps-accent);
		border-radius: 50%;
		animation: imageflow-spin 0.7s linear infinite;
	}
	@keyframes imageflow-spin { to { transform: rotate(360deg); } }

	/* =====================================================================
	   Scrollbars — thin, unobtrusive
	   ================================================================== */
	*::-webkit-scrollbar { width: 9px; height: 9px; }
	*::-webkit-scrollbar-track { background: var(--ps-divider); }
	*::-webkit-scrollbar-thumb { background: #4a4a4a; border: 2px solid var(--ps-divider); border-radius: 5px; }
	*::-webkit-scrollbar-thumb:hover { background: #5a5a5a; }
	*::-webkit-scrollbar-corner { background: var(--ps-divider); }

	imageflow-label { font-size: 11px; }

	/* In-canvas text editing overlay */
	textarea.imageflow-text-edit {
		position: absolute;
		z-index: 40;
		margin: 0; padding: 0;
		background: transparent;
		border: 1px dotted rgba(255,255,255,0.7);
		outline: none;
		resize: none;
		overflow: hidden;
		white-space: pre;
		caret-color: var(--ps-accent);
	}

	/* Type Mask session: PS shows a rubylith sheet over the canvas while the
	   glyphs are typed — the overlay itself carries the red tint here. */
	textarea.imageflow-text-edit.mask {
		color: rgba(255,0,0,0.75);
		background: rgba(255,0,0,0.12);
		border-color: rgba(255,80,80,0.9);
	}

	/* =====================================================================
	   Character / Paragraph panel — compact PS-style typography fields
	   ================================================================== */
	imageflow-char-grid {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 4px;
		padding: 6px 8px;
	}

	/* Full-width row (font family / style) outside the 2-col grid. */
	imageflow-char-full {
		display: flex;
		padding: 6px 8px 0;
		imageflow-select { flex: 1; min-width: 0; }
	}
	/* A full-width control that lives inside the grid spans both columns. */
	imageflow-char-grid > imageflow-char-full {
		grid-column: 1 / -1;
		padding: 0;
	}

	/* One labelled field: a leading icon + a NumberInput/Select/swatch. */
	imageflow-char-field {
		display: flex;
		align-items: center;
		gap: 5px;
		min-width: 0;
		position: relative;
		> imageflow-icon { color: var(--ps-icon-dim); flex: none; }
		> imageflow-number { flex: 1; min-width: 0; }
		> imageflow-number input { width: 100%; }
		> imageflow-select { flex: 1; min-width: 0; }
		> imageflow-swatch { width: 22px; height: 18px; }
		/* Color popover anchored under the field. */
		> imageflow-popover { position: absolute; top: 100%; left: 0; z-index: 50; margin-top: 4px; }
	}

	/* The "Color:" cell — PS's only text-labelled Character field. */
	imageflow-char-field.color {
		> imageflow-label { color: var(--ps-text-dim); font-size: 11px; flex: none; }
		> imageflow-swatch { width: 40px; height: 20px; flex: none; }
	}

	/* Bottom row: language dropdown | anti-alias dropdown. */
	imageflow-char-langrow {
		display: flex;
		align-items: center;
		gap: 6px;
		padding: 2px 8px 8px;
		> imageflow-select { flex: 1.4; min-width: 0; }
	}
	imageflow-char-aa {
		display: flex;
		align-items: center;
		gap: 4px;
		flex: 1;
		min-width: 0;
		> imageflow-label.aa {
			color: var(--ps-icon-dim); font-size: 13px; font-weight: 600; flex: none;
			i { font-style: normal; font-size: 10px; }
		}
		> imageflow-select { flex: 1; min-width: 0; }
	}

	/* Toggle strip (character style toggles, paragraph alignment). */
	imageflow-char-toggles {
		display: flex;
		align-items: center;
		gap: 0;
		padding: 6px 8px;
		imageflow-button.icon {
			width: 22px; height: 22px;
			border-radius: 0;
			color: var(--ps-icon);
			background: none; border: none; box-shadow: none;
			border-right: 1px solid var(--ps-divider);
			&:first-child { border-radius: var(--ps-radius) 0 0 var(--ps-radius); }
			&:last-child { border-radius: 0 var(--ps-radius) var(--ps-radius) 0; border-right: none; }
			&:hover { background: var(--ps-hover); color: #fff; }
			&.active { background: var(--ps-active); color: #f4f4f4; }
			&.disabled, &:disabled { color: var(--ps-text-disabled); pointer-events: none; }
		}
	}

	/* =====================================================================
	   Pen tool / Paths workflow  (added: Pen + Paths panel + Custom Shape)
	   ================================================================== */

	/* --- Paths panel --- */
	imageflow-path-list {
		display: flex; flex-direction: column;
		flex: 1; min-height: 0; overflow-y: auto;
		padding: 2px 0;
	}
	imageflow-path-row {
		display: flex; align-items: center; gap: 8px;
		height: 40px; padding: 2px 10px;
		cursor: default; color: var(--ps-text);
		border-bottom: 1px solid rgba(0,0,0,0.18);
		&:hover { background: var(--ps-hover); }
		&.active { background: var(--ps-selected); }
		imageflow-path-thumb {
			flex: none; width: 42px; height: 34px;
			display: grid; place-items: center;
			background: color-mix(in srgb, #000 12%, var(--ps-panel));
			border: 1px solid var(--ps-divider);
			> canvas { width: 40px; height: 34px; }
		}
		imageflow-path-name {
			flex: 1; min-width: 0; font-size: 11px;
			white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
			&.work { font-style: italic; color: var(--ps-text-dim); }
		}
		.imageflow-path-name-edit {
			flex: 1; min-width: 0; height: 18px;
			font-size: 11px; color: var(--ps-text);
			background: var(--ps-input, #1e1e1e); border: 1px solid var(--ps-accent);
			border-radius: 2px; padding: 0 4px; outline: none;
		}
	}
	imageflow-panel-toolbar.paths {
		display: flex; align-items: center; gap: 2px; flex: none;
		height: 30px; padding: 0 8px;
		background: var(--ps-panel-header);
		border-top: 1px solid var(--ps-divider);
		imageflow-button {
			display: grid; place-items: center;
			width: 26px; height: 24px; border-radius: var(--ps-radius);
			color: var(--ps-icon); background: none; border: none; box-shadow: none;
			&:hover { background: var(--ps-hover); color: #fff; }
			&:disabled, &.disabled { color: var(--ps-text-disabled); pointer-events: none; }
		}
	}

	/* --- Options-bar hint text (pen / anchor / path-selection tools) --- */
	imageflow-tool-option.hint {
		font-size: 11px; color: var(--ps-text-faint);
		white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
		max-width: 40ch;
	}

	/* ===================================================================== */
	/*  Retouching tools (Clone / Healing / Dodge-Burn / Blur / etc.)        */
	/*  The retouch option bars reuse the brush chip, PopNumber fields and    */
	/*  Select controls; only the wider Patch hint needs its own rule.        */
	/* ===================================================================== */
	imageflow-tool-option.hint.patch-hint,
	imageflow-tool-options imageflow-tool-option.hint:only-child {
		max-width: 60ch;
	}

	/* --- Custom Shape picker (shape/custom options bar) --- */
	imageflow-custom-shape-chip {
		display: inline-flex; align-items: center; gap: 2px;
		height: 22px; padding: 0 4px; cursor: default;
		background: var(--ps-panel-sub); border: 1px solid var(--ps-divider);
		border-radius: var(--ps-radius); color: var(--ps-icon);
		> canvas { width: 22px; height: 22px; }
		&:hover { border-color: var(--ps-accent); }
	}
	imageflow-custom-shape-grid {
		display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px;
		padding: 6px; max-width: 200px;
	}
	imageflow-custom-shape-cell {
		display: grid; place-items: center;
		width: 32px; height: 32px; cursor: default;
		background: var(--ps-panel-sub); border: 1px solid transparent;
		border-radius: var(--ps-radius); color: var(--ps-icon);
		> canvas { width: 28px; height: 28px; }
		&:hover { background: var(--ps-hover); }
		&.active { border-color: var(--ps-accent); background: var(--ps-selected); }
	}

	/* ===================================================================== */
	/*  Advanced Layers UI — Blending Options, Blend If, Styles, colour       */
	/*  labels, layer-row context menu.  (added: advanced-layers feature)     */
	/* ===================================================================== */

	/* --- Blending Options dialog ---------------------------------------- */
	imageflow-dialog.blending-options {
		width: 420px;
		imageflow-dialog-body { display: flex; flex-direction: column; gap: 12px; }
	}
	imageflow-blending-section {
		display: flex; flex-direction: column; gap: 7px;
		padding-bottom: 10px; border-bottom: 1px solid var(--ps-divider);
		&:last-child { border-bottom: none; padding-bottom: 0; }
	}
	imageflow-blending-heading {
		font-weight: 600; color: var(--ps-text); margin-bottom: 2px;
	}
	imageflow-blending-channels {
		display: flex; gap: 14px; align-items: center;
	}

	/* --- Blend-If split slider ------------------------------------------ */
	imageflow-blendif-row {
		display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px;
		> imageflow-label { color: var(--ps-text-dim); }
	}
	imageflow-blendif-track {
		position: relative; height: 26px; margin: 4px 8px 10px;
	}
	imageflow-blendif-gradient {
		position: absolute; left: 0; right: 0; top: 2px; height: 12px;
		border: 1px solid var(--ps-divider); border-radius: 1px;
		background: linear-gradient(to right, #000, #fff);
	}
	imageflow-blendif-handle {
		position: absolute; top: 15px; width: 11px; height: 11px;
		margin-left: -5.5px; cursor: ew-resize; touch-action: none;
		/* Half-triangle pointing up; left/right halves clip to one side so a
		   merged pair reads as a single triangle. */
		&::after {
			content: ''; position: absolute; inset: 0;
			border-left: 5.5px solid transparent;
			border-right: 5.5px solid transparent;
			border-bottom: 9px solid var(--ps-text);
		}
		&.black::after { border-bottom-color: #1c1c1c; }
		&.white::after { border-bottom-color: #f0f0f0; }
		&.left { clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%); }
		&.right { clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%); }
		&:hover::after { filter: brightness(1.3); }
	}

	/* --- Styles panel --------------------------------------------------- */
	imageflow-style-grid {
		display: grid; grid-template-columns: repeat(auto-fill, 40px);
		gap: 6px; padding: 8px; overflow: auto; align-content: start; flex: 1;
	}
	imageflow-style-tile {
		position: relative; width: 40px; height: 40px; cursor: default;
		border: 1px solid var(--ps-divider); border-radius: var(--ps-radius);
		overflow: hidden; background: var(--ps-panel-sub);
		&:hover { border-color: var(--ps-accent); }
		imageflow-icon-button.style-del {
			position: absolute; top: 1px; right: 1px; opacity: 0;
			background: rgba(0, 0, 0, 0.55); border-radius: 2px;
		}
		&:hover imageflow-icon-button.style-del { opacity: 1; }
	}
	imageflow-style-chip {
		display: block; width: 100%; height: 100%;
		box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08),
			inset 0 -6px 10px rgba(0, 0, 0, 0.35), inset 0 6px 8px rgba(255, 255, 255, 0.12);
	}

	/* --- Layer colour labels -------------------------------------------- */
	imageflow-layer-label {
		position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
		background: var(--layer-label, transparent); display: none;
	}
	imageflow-layer { position: relative; }
	imageflow-layer.labeled {
		imageflow-layer-label { display: block; }
		background: color-mix(in srgb, var(--layer-label) 12%, transparent);
		&.active { background: color-mix(in srgb, var(--layer-label) 22%, var(--ps-selected)); }
	}

	/* --- Layer-row context menu ----------------------------------------- */
	imageflow-context-menu {
		position: fixed; z-index: 2000; min-width: 170px; padding: 4px 0;
		background: var(--ps-panel); border: 1px solid var(--ps-divider);
		border-radius: var(--ps-radius-lg); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
		color: var(--ps-text); font-size: 11px;
	}
	imageflow-context-item {
		display: block; padding: 4px 14px; cursor: default; white-space: nowrap;
		&:hover { background: var(--ps-accent); color: #fff; }
		&.disabled { color: var(--ps-text-disabled); pointer-events: none; }
	}
	imageflow-context-separator {
		display: block; height: 1px; margin: 4px 0; background: var(--ps-divider);
	}
	imageflow-context-label {
		display: block; padding: 3px 14px 2px; color: var(--ps-text-dim); font-size: 10px;
	}
	imageflow-context-colors {
		display: flex; gap: 5px; padding: 4px 12px 6px;
	}
	imageflow-context-swatch {
		display: grid; place-items: center;
		width: 15px; height: 15px; border-radius: 50%; cursor: default;
		border: 1px solid var(--ps-divider); color: var(--ps-text-dim);
		&:hover { transform: scale(1.15); }
		&.active { box-shadow: 0 0 0 2px var(--ps-accent); }
	}

	/* =====================================================================
	   Advanced transforms — Puppet Warp / Perspective Warp / Content-Aware
	   Scale options bar. The session name reads as a bold accent label; the
	   rest reuses the standard tool-option controls. (Overlays are drawn on
	   the canvas, not via CSS.)
	   ===================================================================== */
	imageflow-tool-option.session-name {
		font-weight: 600; color: var(--ps-text); letter-spacing: 0.02em;
	}

	/* =====================================================================
	   Type features — variable-font axis sliders, Character/Paragraph style
	   presets, the Glyphs panel, and the Warp Text / Find-Replace dialogs.
	   ===================================================================== */

	/* Type-tool button row at the top of the Character panel */
	imageflow-char-toolrow {
		display: flex; align-items: center; gap: 6px; padding: 4px 8px 6px;
		border-bottom: 1px solid var(--ps-divider); margin-bottom: 4px;
	}
	imageflow-char-toolrow > imageflow-label { font-size: 11px; color: var(--ps-text-dim); }

	/* Variable-font axis sliders (Character panel) */
	imageflow-char-axes {
		display: block; padding: 6px 8px 4px; margin-top: 4px;
		border-top: 1px solid var(--ps-divider);
	}
	imageflow-char-axes-head {
		display: flex; align-items: center; gap: 5px; margin-bottom: 4px;
		font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
		color: var(--ps-text-dim);
	}
	imageflow-char-axis { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
	imageflow-char-axis-label {
		flex: 0 0 84px; display: flex; justify-content: space-between; align-items: baseline;
		font-size: 11px; color: var(--ps-text);
	}
	imageflow-char-axis-label > i { font-style: normal; opacity: 0.5; font-size: 9px; text-transform: uppercase; }
	imageflow-char-axis imageflow-slider { flex: 1 1 auto; min-width: 0; }

	/* OpenType feature toggles that carry a text label instead of an icon
	   (figure styles), matched to the icon buttons they sit beside. */
	imageflow-char-feature {
		display: inline-flex; align-items: center; justify-content: center;
		min-width: 22px; height: 22px; padding: 0 4px;
		font-size: 9px; font-weight: 600; letter-spacing: 0.02em;
		color: var(--ps-icon); cursor: pointer; user-select: none;
		border-right: 1px solid var(--ps-divider);
		&:hover { background: var(--ps-hover); color: #fff; }
		&.active { background: var(--ps-active); color: #f4f4f4; }
		&.disabled { color: var(--ps-text-disabled); pointer-events: none; }
		&:last-child { border-right: none; }
	}

	/* Manual pair-kerning row: left-character index + value in 1/1000 em */
	imageflow-char-kernrow {
		display: flex; align-items: center; gap: 4px; padding: 0 8px 6px;
		imageflow-label { font-size: 11px; color: var(--ps-text-dim); flex: 0 0 auto; }
		imageflow-number { flex: 1 1 0; min-width: 0; }
		imageflow-char-feature { border: 1px solid var(--ps-divider); border-radius: var(--ps-radius); }
	}

	/* Note under a Character-panel control (e.g. shaping data unavailable) */
	imageflow-char-hint {
		display: block; padding: 0 8px 6px;
		font-size: 10px; line-height: 1.35; color: var(--ps-text-dim);
	}

	/* Character / Paragraph style presets */
	imageflow-text-style-list { display: block; overflow: auto; max-height: 300px; }
	imageflow-text-style-row {
		display: flex; flex-direction: column; gap: 1px; padding: 5px 9px; cursor: pointer;
		border-bottom: 1px solid var(--ps-divider);
	}
	imageflow-text-style-row:hover { background: var(--ps-hover); }
	imageflow-text-style-row.active { background: var(--ps-accent); }
	imageflow-text-style-name { font-size: 12px; color: var(--ps-text); }
	imageflow-text-style-sub { font-size: 10px; color: var(--ps-text-dim); }
	imageflow-text-style-row.active imageflow-text-style-sub { color: rgba(255, 255, 255, 0.78); }
	imageflow-text-style-empty { display: block; padding: 14px; text-align: center; font-size: 11px; color: var(--ps-text-dim); }

	/* Glyphs panel */
	imageflow-glyphs-head { display: block; padding: 6px 8px; }
	imageflow-glyphs-section {
		display: block; padding: 5px 8px 2px; font-size: 10px; text-transform: uppercase;
		letter-spacing: 0.04em; color: var(--ps-text-dim);
	}
	imageflow-glyphs-grid {
		display: grid; grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
		gap: 2px; padding: 0 6px;
	}
	imageflow-glyphs-grid.scroll { max-height: 260px; overflow: auto; }
	imageflow-glyph {
		display: flex; align-items: center; justify-content: center; height: 28px;
		font-size: 16px; line-height: 1; color: var(--ps-text); background: var(--ps-input);
		border: 1px solid transparent; cursor: pointer; user-select: none;
	}
	imageflow-glyph:hover { border-color: var(--ps-accent); background: var(--ps-hover); }
	imageflow-glyphs-foot {
		display: block; padding: 6px 8px; font-size: 10px; color: var(--ps-text-dim);
		border-top: 1px solid var(--ps-divider);
	}

	/* Warp Text + Find/Replace dialogs */
	imageflow-warp-orient { display: flex; gap: 6px; }
	imageflow-findreplace-actions { display: flex; gap: 8px; margin-top: 8px; }

	/* =====================================================================
	   Gradient & color — Gradient Editor, Swatches, Color panel, Patterns
	   ================================================================== */

	/* --- Gradient Editor popover --- */
	imageflow-gradient-editor {
		display: flex; flex-direction: column; gap: 10px;
		width: 300px; outline: none;
	}
	imageflow-gradient-presets {
		display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; align-items: center;
	}
	imageflow-gradient-preset {
		display: block; height: 18px; border: 1px solid #000; border-radius: var(--ps-radius);
		cursor: pointer;
		background-image: var(--grad-preview), repeating-conic-gradient(#bcbcbc 0% 25%, #fff 0% 50%);
		background-size: auto, 8px 8px;
		&:hover { outline: 1px solid var(--ps-accent); }
		&.user { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15); }
	}
	imageflow-gradient-bar {
		position: relative; height: 56px; margin: 0 8px;
	}
	imageflow-gradient-track {
		position: absolute; left: 0; right: 0; top: 18px; height: 20px;
		border: 1px solid #000;
		background-image: var(--grad-preview), repeating-conic-gradient(#bcbcbc 0% 25%, #fff 0% 50%);
		background-size: auto, 10px 10px;
	}
	imageflow-gradient-stops {
		position: absolute; left: 0; right: 0; height: 18px;
		&.opacity { top: 0; cursor: copy; }
		&.mid { top: 18px; height: 20px; pointer-events: none; }
		&.color { bottom: 0; cursor: copy; }
	}
	imageflow-gradient-stop {
		position: absolute; width: 12px; height: 14px; transform: translateX(-50%);
		background: var(--stop-color, #000); border: 1px solid #000;
		box-shadow: 0 0 0 1px #fff; cursor: pointer;
		&.active { box-shadow: 0 0 0 1px var(--ps-accent); border-color: var(--ps-accent); z-index: 3; }
		&.opacity { top: 2px; border-radius: 2px 2px 0 0; }
		&.color { bottom: 2px; border-radius: 0 0 2px 2px; }
	}
	imageflow-gradient-midpoint {
		position: absolute; top: 50%; width: 8px; height: 8px; transform: translate(-50%, -50%) rotate(45deg);
		background: #d0d0d0; border: 1px solid #000; cursor: ew-resize; pointer-events: auto;
		&.active { background: var(--ps-accent); }
	}
	imageflow-gradient-row {
		display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
		imageflow-label { color: var(--ps-text-dim); font-size: 10px; }
	}
	imageflow-gradient-fields {
		display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
		border-top: 1px solid var(--ps-divider); padding-top: 8px;
		imageflow-label { color: var(--ps-text-dim); font-size: 10px; }
	}

	/* --- Swatches panel --- */
	imageflow-swatch-set { display: block; padding: 6px 8px; }
	imageflow-swatch-grid {
		display: grid; grid-template-columns: repeat(auto-fill, minmax(18px, 1fr));
		gap: 2px; padding: 0 8px 6px;
		imageflow-swatch {
			width: 100%; height: auto; aspect-ratio: 1; border: 1px solid #000; cursor: pointer;
			border-radius: 0;
			&:hover { outline: 1px solid #fff; }
			&.active { outline: 1px solid var(--ps-accent); z-index: 2; }
		}
	}
	imageflow-label.section {
		display: block; padding: 4px 8px 2px; font-size: 10px; color: var(--ps-text-dim);
	}

	/* --- Color panel --- */
	imageflow-color-panel {
		display: flex; flex-direction: column; gap: 8px; padding: 8px;
	}
	imageflow-color-fgbg {
		display: flex; align-items: center; gap: 6px;
		imageflow-swatch.large { width: 30px; height: 24px; cursor: pointer; border-radius: 0; }
		imageflow-swatch.large.active { outline: 2px solid var(--ps-accent); z-index: 2; }
	}
	imageflow-color-mode-toggle {
		margin-left: auto; padding: 3px 8px; font-size: 10px; cursor: pointer;
		color: var(--ps-text); background: var(--ps-input); border: 1px solid var(--ps-divider);
		border-radius: var(--ps-radius);
		&:hover { background: var(--ps-hover); }
	}
	imageflow-color-slider-row { display: block; }
	imageflow-color-ramp {
		display: block; height: 22px; border: 1px solid #000; border-radius: var(--ps-radius);
		cursor: crosshair; margin-top: 2px;
	}

	/* --- Pattern picker --- */
	imageflow-pattern-picker { display: flex; flex-direction: column; width: 240px; }
	imageflow-pattern-grid {
		display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
		gap: 4px; padding: 8px; max-height: 240px; overflow: auto;
	}
	imageflow-pattern-tile {
		display: block; width: 100%; aspect-ratio: 1; border: 1px solid #000; cursor: pointer;
		background-repeat: repeat; background-size: 24px 24px; image-rendering: pixelated;
		&:hover { outline: 1px solid #fff; }
		&.active { outline: 2px solid var(--ps-accent); z-index: 2; }
	}

	/* --- Brush Settings panel + preset library (options-bar popovers) --- */
	imageflow-popover.brush-settings { width: 268px; max-height: 70vh; overflow: auto; }
	imageflow-brush-panel { display: flex; flex-direction: column; gap: 2px; }
	imageflow-brush-fields {
		display: flex; flex-direction: column; gap: 5px; padding: 4px 0;
		imageflow-slider { width: 140px; }
		imageflow-pattern-picker { width: 100%; }
	}
	imageflow-brush-section {
		border-top: 1px solid #1e1e1e;
		&.open > imageflow-brush-section-head { color: var(--ps-text); }
	}
	imageflow-brush-section-head {
		display: flex; align-items: center; gap: 6px;
		padding: 4px 2px; cursor: default; color: var(--ps-text-dim);
		&:hover { color: var(--ps-text); }
		imageflow-label { min-width: 0; }
	}
	imageflow-brush-presets { display: flex; flex-direction: column; gap: 4px; }
	imageflow-brush-preset-list {
		display: flex; flex-direction: column; gap: 2px;
		max-height: 190px; overflow: auto; padding: 2px 0;
	}
	imageflow-brush-preset {
		display: flex; align-items: center; gap: 6px;
		padding: 2px 4px; border: 1px solid transparent; border-radius: var(--ps-radius);
		cursor: pointer;
		&:hover { background: #3a3a3a; }
		&.active { background: var(--ps-accent); color: #fff; }
	}
	imageflow-brush-thumb {
		display: block; flex: none; width: 88px; height: 30px;
		border: 1px solid #000; background: #fff center/contain no-repeat;
	}
	imageflow-brush-preset-name {
		font-size: 10px; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	}
	imageflow-brush-status { font-size: 10px; color: var(--ps-text-dim); padding: 0 2px; }
	imageflow-panel-toolbar.brushes { display: flex; align-items: center; gap: 4px; }

	/* ===================================================================== */
	/*  Filters (gallery / liquify / blur / smart)                           */
	/* ===================================================================== */

	/* Flip a chevron icon to point up (reused for reorder / move-up). */
	imageflow-button.flip-up imageflow-icon,
	imageflow-icon.flip-up { transform: rotate(180deg); }

	/* --- Smart-filter sub-list under a smart-object layer row --- */
	imageflow-sf-badge {
		display: inline-grid; place-items: center; width: 16px; height: 16px;
		color: var(--ps-icon); cursor: default;
		&:hover { color: #fff; }
		&.tool { width: 15px; height: 15px; color: var(--ps-icon-dim); }
		&.tool:hover { color: #fff; }
	}
	imageflow-layer-smartfilters {
		display: flex; flex-direction: column;
		background: color-mix(in srgb, var(--ps-accent) 8%, var(--ps-panel));
	}
	imageflow-layer-smartfilter {
		display: flex; align-items: center; gap: 8px;
		height: 22px; padding: 0 6px 0 40px;
		border-bottom: 1px solid rgba(0,0,0,0.2);
		imageflow-effect-eye {
			display: grid; place-items: center; width: 16px; height: 16px; flex: none;
			color: var(--ps-icon); cursor: default;
			&:hover { color: #fff; }
			&:not(.on) { color: var(--ps-icon-dim); }
		}
		imageflow-layer-name { font-size: 11px; color: var(--ps-text-dim); flex: 1; }
		&.master { padding-left: 26px; }
		&.master imageflow-layer-name { color: var(--ps-text); }
		&:hover { background: rgba(255,255,255,0.04); }
	}

	/* --- Shared workspace-dialog scaffolding --- */
	imageflow-dialog.filtergallery, imageflow-dialog.liquify, imageflow-dialog.blurgallery {
		width: min(94vw, 1040px); max-width: 94vw;
	}

	/* --- Filter Gallery --- */
	imageflow-fg-body {
		display: grid; grid-template-columns: 1fr 220px 260px; gap: 1px;
		background: #000; height: min(72vh, 640px);
	}
	imageflow-fg-preview {
		display: grid; place-items: center; overflow: auto;
		background: var(--ps-pasteboard, #404040); padding: 12px;
		canvas { max-width: 100%; max-height: 100%; object-fit: contain;
			box-shadow: 0 2px 12px rgba(0,0,0,0.5); }
	}
	imageflow-fg-categories { display: block; overflow: auto; background: var(--ps-panel); padding: 6px; }
	imageflow-fg-category { display: block; margin-bottom: 4px; }
	imageflow-fg-cat-head {
		display: flex; align-items: center; gap: 6px; padding: 4px 6px;
		font-size: 11px; font-weight: 600; color: var(--ps-text); cursor: default;
		text-transform: none;
		imageflow-icon.closed { transform: rotate(-90deg); }
		&:hover { color: #fff; }
	}
	imageflow-fg-grid {
		display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; padding: 4px 2px 8px;
	}
	imageflow-fg-thumb {
		display: flex; flex-direction: column; gap: 3px; cursor: pointer; align-items: center;
		padding: 3px; border: 1px solid transparent; border-radius: var(--ps-radius);
		img, imageflow-fg-thumb-blank {
			display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover;
			background: #2a2a2a; border: 1px solid #000;
		}
		&:hover { border-color: var(--ps-divider); }
		&.selected { border-color: var(--ps-accent); background: color-mix(in srgb, var(--ps-accent) 18%, transparent); }
	}
	imageflow-fg-thumb-label { font-size: 10px; color: var(--ps-text-dim); text-align: center; line-height: 1.1; }
	imageflow-fg-right {
		display: flex; flex-direction: column; gap: 10px; padding: 12px;
		background: var(--ps-panel); overflow: auto;
	}
	imageflow-fg-params { display: flex; flex-direction: column; gap: 8px; }
	imageflow-fg-params-title { font-size: 12px; font-weight: 600; color: var(--ps-text); }
	imageflow-fg-stack {
		margin-top: auto; display: flex; flex-direction: column;
		border: 1px solid #000; background: color-mix(in srgb, #000 12%, var(--ps-panel));
	}
	imageflow-fg-stack-row {
		display: flex; align-items: center; gap: 6px; padding: 3px 6px; cursor: pointer;
		border-bottom: 1px solid rgba(0,0,0,0.25);
		imageflow-effect-eye { display: grid; place-items: center; width: 15px; height: 15px; color: var(--ps-icon); }
		imageflow-layer-name { font-size: 11px; color: var(--ps-text-dim); }
		&.active { background: var(--ps-accent); imageflow-layer-name { color: #fff; } }
		&:hover:not(.active) { background: var(--ps-hover); }
	}
	imageflow-fg-stack-tools {
		display: flex; justify-content: flex-end; gap: 2px; padding: 3px 4px;
		background: var(--ps-panel);
	}

	/* --- Liquify --- */
	imageflow-liquify-body {
		display: grid; grid-template-columns: 44px 1fr 240px; gap: 1px;
		background: #000; height: min(74vh, 660px);
	}
	imageflow-liquify-tools {
		display: flex; flex-direction: column; gap: 2px; padding: 6px 4px;
		background: var(--ps-panel);
	}
	imageflow-liquify-tool {
		display: grid; place-items: center; width: 32px; height: 30px; cursor: pointer;
		color: var(--ps-icon); border: 1px solid transparent; border-radius: var(--ps-radius);
		&:hover { background: var(--ps-hover); color: #fff; }
		&.active { background: var(--ps-accent); color: #fff; }
	}
	imageflow-liquify-canvas {
		display: grid; place-items: center; overflow: auto;
		background: var(--ps-pasteboard, #404040); padding: 12px;
		canvas { max-width: 100%; max-height: 100%; object-fit: contain; cursor: crosshair;
			box-shadow: 0 2px 12px rgba(0,0,0,0.5); touch-action: none; }
	}
	imageflow-liquify-side {
		display: flex; flex-direction: column; gap: 10px; padding: 12px;
		background: var(--ps-panel); overflow: auto;
	}

	/* --- Blur Gallery --- */
	imageflow-bg-body {
		display: grid; grid-template-columns: 1fr 250px; gap: 1px;
		background: #000; height: min(72vh, 620px);
	}
	imageflow-bg-preview {
		display: grid; place-items: center; overflow: auto;
		background: var(--ps-pasteboard, #404040); padding: 12px;
		canvas { max-width: 100%; max-height: 100%; object-fit: contain; cursor: crosshair;
			box-shadow: 0 2px 12px rgba(0,0,0,0.5); touch-action: none; }
	}
	imageflow-bg-side {
		display: flex; flex-direction: column; gap: 10px; padding: 12px;
		background: var(--ps-panel); overflow: auto;
	}

	/* ======================================================================
	   Selections & channels (Channels panel, Color Range, Select and Mask,
	   Quick Mask, measure-tool readouts)
	   ====================================================================== */
	imageflow-channel-list {
		display: flex; flex-direction: column;
		flex: 1; min-height: 0; overflow-y: auto; padding: 2px 0;
	}
	imageflow-channel-row {
		display: flex; align-items: center; gap: 8px;
		height: 34px; padding: 2px 8px;
		cursor: default; color: var(--ps-text);
		border-bottom: 1px solid rgba(0,0,0,0.18);
		&:hover { background: var(--ps-hover); }
		&.active { background: var(--ps-selected); }
		imageflow-channel-eye {
			flex: none; width: 20px; display: grid; place-items: center;
			color: var(--ps-icon); cursor: pointer;
			&.on { color: #fff; }
		}
		imageflow-channel-thumb {
			flex: none; width: 36px; height: 26px;
			display: grid; place-items: center;
			background: color-mix(in srgb, #000 14%, var(--ps-panel));
			border: 1px solid var(--ps-divider);
			> canvas { width: 34px; height: 24px; }
		}
		imageflow-channel-name {
			flex: 1; min-width: 0; font-size: 11px;
			white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
		}
		imageflow-channel-key { flex: none; font-size: 10px; color: var(--ps-text-dim); }
		.imageflow-channel-name-edit {
			flex: 1; min-width: 0; height: 18px;
			font-size: 11px; color: var(--ps-text);
			background: var(--ps-input, #1e1e1e); border: 1px solid var(--ps-accent);
			border-radius: 2px; padding: 0 4px; outline: none;
		}
	}
	imageflow-panel-toolbar.channels {
		display: flex; align-items: center; gap: 2px; flex: none;
		height: 30px; padding: 0 8px;
		background: var(--ps-panel-header);
		border-top: 1px solid var(--ps-divider);
		imageflow-button {
			display: grid; place-items: center;
			width: 26px; height: 24px; border-radius: var(--ps-radius);
			color: var(--ps-icon); background: none; border: none; box-shadow: none;
			&:hover { background: var(--ps-hover); color: #fff; }
			&:disabled, &.disabled { color: var(--ps-text-disabled); pointer-events: none; }
		}
	}

	/* --- Ruler / measure readouts in the options bar --- */
	imageflow-ruler-readout {
		display: inline-flex; align-items: center; min-width: 34px; height: 20px;
		padding: 0 4px; font-size: 11px; color: var(--ps-text);
		background: var(--ps-input, #1e1e1e); border: 1px solid var(--ps-divider);
		border-radius: 2px;
	}

	/* --- Color Range dialog --- */
	imageflow-dialog.colorrange { width: 560px; }
	imageflow-colorrange-body {
		display: grid; grid-template-columns: 230px 1fr; gap: 14px;
	}
	imageflow-colorrange-controls { display: flex; flex-direction: column; gap: 8px; }
	imageflow-colorrange-preview {
		display: grid; place-items: center;
		background: #000; border: 1px solid var(--ps-divider); min-height: 240px;
		> canvas { max-width: 100%; max-height: 320px; object-fit: contain; cursor: crosshair; touch-action: none; }
	}

	/* --- Select and Mask workspace --- */
	imageflow-dialog.selectmask { width: min(90vw, 900px); }
	imageflow-selectmask-body {
		display: grid; grid-template-columns: 1fr 260px; gap: 1px;
		background: #000; height: min(72vh, 620px);
	}
	imageflow-selectmask-canvas {
		display: grid; place-items: center; overflow: auto;
		background: var(--ps-pasteboard, #404040); padding: 12px;
		> canvas { max-width: 100%; max-height: 100%; object-fit: contain;
			box-shadow: 0 2px 12px rgba(0,0,0,0.5); }
		/* Refine Edge Brush active: paint directly on the preview. */
		&.brushing > canvas { cursor: crosshair; touch-action: none; }
	}
	imageflow-selectmask-side {
		display: flex; flex-direction: column; gap: 10px; padding: 12px;
		background: var(--ps-panel); overflow: auto;
	}


	/* =====================================================================
	   Workspace panels — History snapshots, Navigator, Actions
	   (+ their Batch / Variables / New Action dialogs)
	   ================================================================== */

	/* --- History: snapshot rows + options flyout ---------------------- */
	imageflow-history-snapshot {
		cursor: default;
		&:hover { background: var(--ps-hover); }
		&.active { background: var(--ps-selected); }
		> input {
			flex: 1; min-width: 0; height: 18px; padding: 1px 4px;
			font: inherit; font-size: 11px; color: var(--ps-text);
			background: var(--ps-field); border: 1px solid var(--ps-accent); border-radius: var(--ps-radius);
			outline: none;
		}
	}
	imageflow-history-options {
		display: flex; align-items: center; flex: none;
		padding: 6px 8px;
		border-top: 1px solid var(--ps-divider);
		background: var(--ps-panel-sub, var(--ps-panel));
	}

	/* --- Navigator ---------------------------------------------------- */
	imageflow-navigator-view {
		position: relative; display: block; flex: none;
		margin: 10px auto 8px;
		background: #1a1a1a repeating-conic-gradient(#3a3a3a 0% 25%, #2e2e2e 0% 50%) 0 0 / 12px 12px;
		border: 1px solid #000;
		touch-action: none; cursor: crosshair; overflow: hidden;
		> img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
	}
	imageflow-navigator-rect {
		position: absolute; display: block;
		border: 1px solid #ff3b30;
		box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
		pointer-events: none;
	}
	imageflow-navigator-controls {
		display: flex; align-items: center; gap: 6px; flex: none;
		padding: 0 8px 8px;
		> imageflow-icon { color: var(--ps-icon); flex: none; }
		> imageflow-slider { flex: 1; min-width: 0; }
		/* The slider is logarithmic — its raw readout would be meaningless, so
		   the percentage field above is the single source of truth. */
		imageflow-slider > imageflow-label.value { display: none; }
	}
	imageflow-navigator-hint {
		display: block; flex: none;
		padding: 0 8px 8px;
		font-size: 11px; color: var(--ps-text-dim);
	}

	/* --- Actions ------------------------------------------------------ */
	imageflow-actions-list {
		display: flex; flex-direction: column; flex: 1; min-height: 0;
		overflow: auto;
	}
	imageflow-actions-set, imageflow-actions-action { display: flex; flex-direction: column; }
	imageflow-actions-row {
		display: flex; align-items: center; gap: 4px;
		min-height: 21px; padding: 0 6px;
		font-size: 11px; color: var(--ps-text);
		cursor: default;
		> imageflow-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
		> imageflow-icon { color: var(--ps-icon); flex: none; }
		> imageflow-button.icon { width: 18px; height: 18px; opacity: 0; }
		> input {
			flex: 1; min-width: 0; height: 17px; padding: 0 4px;
			font: inherit; font-size: 11px; color: var(--ps-text);
			background: var(--ps-field); border: 1px solid var(--ps-accent); border-radius: var(--ps-radius);
			outline: none;
		}
		&:hover { background: var(--ps-hover); }
		&:hover > imageflow-button.icon { opacity: 1; }
		&.active { background: var(--ps-selected); }
		&.action { padding-left: 12px; }
		&.recording > imageflow-label { color: #ff5b50; }
		&.step { padding-left: 30px; color: var(--ps-text-dim); }
		&.step.empty { font-style: italic; color: var(--ps-text-faint); }
	}
	imageflow-actions-chevron {
		display: grid; place-items: center; flex: none;
		width: 12px; height: 12px; color: var(--ps-icon-dim);
	}
	imageflow-actions-count {
		flex: none; font-size: 10px; color: var(--ps-text-faint); padding-right: 2px;
	}
	/* CSS-drawn transport glyphs (stop square, record dot, play/step triangles). */
	imageflow-actions-glyph {
		display: grid; place-items: center; flex: none;
		width: 22px; height: 22px; border-radius: var(--ps-radius);
		cursor: default;
		&:hover { background: var(--ps-hover); }
		&.disabled { opacity: 0.35; pointer-events: none; }
		&::before { content: ''; display: block; }
		&.stop::before { width: 9px; height: 9px; background: var(--ps-icon); border-radius: 1px; }
		&.record::before { width: 10px; height: 10px; background: var(--ps-icon); border-radius: 50%; }
		&.record.on::before { background: #ff3b30; }
		&.play::before,
		&.step::before {
			width: 0; height: 0;
			border-left: 9px solid var(--ps-icon);
			border-top: 5.5px solid transparent; border-bottom: 5.5px solid transparent;
		}
		&.step::after { content: ''; display: block; width: 2px; height: 11px; background: var(--ps-icon); margin-left: 1px; }
		&.step { grid-auto-flow: column; }
	}
	imageflow-panel-toolbar.actions { justify-content: flex-start; gap: 2px; }

	/* --- Batch dialog ------------------------------------------------- */
	imageflow-dialog.batch { width: 460px; }
	imageflow-dialog.newaction { width: 340px; }
	imageflow-batch-progress {
		display: block; height: 6px; margin: 8px 0;
		background: var(--ps-field); border: 1px solid #000; border-radius: 2px; overflow: hidden;
	}
	imageflow-batch-bar { display: block; height: 100%; background: var(--ps-accent); transition: width 0.1s linear; }
	imageflow-batch-report {
		display: flex; flex-direction: column; gap: 2px;
		max-height: 180px; overflow: auto;
	}
	imageflow-batch-row {
		display: flex; align-items: center; justify-content: space-between; gap: 8px;
		font-size: 11px; color: var(--ps-text);
		> imageflow-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
		> imageflow-value { color: var(--ps-text-dim); flex: none; }
		&.error > imageflow-value { color: #ff6b60; }
	}
	/* Framed Source / Destination groups (Photoshop's grouped Batch panels). */
	imageflow-batch-group {
		display: block; margin: 8px 0; padding: 6px 8px 8px;
		border: 1px solid var(--ps-divider); border-radius: var(--ps-radius);
	}
	imageflow-batch-legend {
		display: block; margin-bottom: 4px;
		font-size: 11px; font-weight: 600; color: var(--ps-text-dim);
	}
	imageflow-batch-actions {
		display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0;
		> imageflow-value { font-size: 11px; color: var(--ps-text-dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	}

	/* --- Variables dialog --------------------------------------------- */
	imageflow-dialog.variables { width: 620px; }
	imageflow-variables-section {
		display: flex; flex-direction: column; gap: 6px;
		padding: 8px 0;
		border-bottom: 1px solid var(--ps-divider);
	}
	imageflow-variables-def {
		display: grid; grid-template-columns: 120px 1fr 140px 24px; gap: 6px; align-items: center;
	}
	/* Pixel-replacement settings, spanning the whole definition row. */
	imageflow-variables-pixel {
		grid-column: 1 / -1;
		display: grid; grid-template-columns: 140px 140px 1fr; gap: 6px; align-items: center;
		padding-left: 12px;
	}
	imageflow-variables-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
	imageflow-variables-pool {
		display: flex; flex-wrap: wrap; gap: 4px; max-height: 64px; overflow: auto;
	}
	imageflow-variables-chip {
		display: block; padding: 1px 6px; border-radius: 9px;
		background: var(--ps-field); border: 1px solid var(--ps-divider);
		font-size: 10px; color: var(--ps-text-dim); white-space: nowrap;
	}
	imageflow-variables-table {
		display: flex; flex-direction: column; gap: 4px;
		max-height: 200px; overflow: auto;
	}
	imageflow-variables-row {
		display: flex; align-items: center; gap: 6px;
		padding: 2px 4px; border-radius: var(--ps-radius);
		font-size: 11px; color: var(--ps-text); cursor: default;
		> imageflow-label { flex: none; width: 60px; color: var(--ps-text-dim); }
		> imageflow-field { flex: 1; min-width: 0; }
		&:hover { background: var(--ps-hover); }
		&.active { background: var(--ps-selected); }
	}

	/* --- Match Color dialog ------------------------------------------- */
	imageflow-dialog.matchcolor {
		width: 460px;
		imageflow-dialog-preview.thumb { width: 100%; height: 200px; margin-bottom: 8px; }
		imageflow-dialog-row > imageflow-label { min-width: 104px; }
	}

	/* =====================================================================
	   AI Features settings (Edit ▸ Preferences…)
	   Per-task model picker with disabled options + current/unavailable
	   badges, and the model-cache manager.
	   ===================================================================== */
	imageflow-dialog.preferences { width: 620px; }

	/* Preferences pane switcher. */
	imageflow-prefs-tabs {
		display: flex; gap: 2px; flex: none;
		padding: 0 12px; border-bottom: 1px solid var(--ps-divider); background: var(--ps-panel);
	}
	imageflow-prefs-tab {
		padding: 7px 12px; font-size: 11px; color: var(--ps-text-dim);
		border-bottom: 2px solid transparent; cursor: pointer; user-select: none;
		&:hover { color: var(--ps-text); }
		&.active { color: var(--ps-text); border-bottom-color: var(--ps-accent); }
		&:focus-visible { outline: 1px solid var(--ps-accent); outline-offset: -2px; }
	}
	imageflow-ai-settings {
		display: flex; flex-direction: column; gap: 14px;
	}
	imageflow-ai-section {
		display: flex; flex-direction: column; gap: 8px;
		padding-bottom: 12px;
		border-bottom: 1px solid var(--ps-divider);
		&:last-child { border-bottom: none; padding-bottom: 0; }
	}
	imageflow-ai-section-head {
		font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
		color: var(--ps-text-dim);
	}
	imageflow-ai-banner {
		padding: 7px 9px; border-radius: var(--ps-radius);
		background: rgba(20, 115, 230, 0.12);
		border: 1px solid rgba(20, 115, 230, 0.4);
		color: var(--ps-text); font-size: 11px;
	}
	imageflow-ai-note {
		color: var(--ps-text-faint); font-size: 10px; line-height: 1.5;
	}

	/* --- Per-task model picker ---------------------------------------- */
	imageflow-ai-task {
		display: grid;
		grid-template-columns: 130px 1fr;
		grid-template-rows: auto auto;
		column-gap: 10px; row-gap: 2px;
		align-items: center;
	}
	imageflow-ai-task-label {
		grid-row: 1; grid-column: 1;
		color: var(--ps-text-dim); font-size: 11px;
	}
	imageflow-ai-meta {
		grid-row: 2; grid-column: 2;
		color: var(--ps-text-faint); font-size: 10px;
		overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
	}
	imageflow-ai-select {
		grid-row: 1; grid-column: 2;
		position: relative;
		display: inline-flex; align-items: center;
		height: 22px; min-width: 0;
		padding: 0 6px;
		background: var(--ps-field);
		border: 1px solid #000;
		border-radius: var(--ps-radius);
		box-shadow: inset 0 1px 1px rgba(0,0,0,0.35);
		color: var(--ps-text); cursor: default;

		imageflow-ai-select-value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
		&::after {
			content: ''; margin-left: 6px;
			width: 0; height: 0;
			border-left: 3px solid transparent; border-right: 3px solid transparent;
			border-top: 4px solid var(--ps-icon-dim);
		}
		&:hover { border-color: #2a2a2a; }
		&.open { border-color: var(--ps-accent); }

		imageflow-ai-options {
			position: absolute; top: 100%; left: 0; margin-top: 2px;
			min-width: 100%; max-height: 320px; overflow-y: auto;
			background: var(--ps-panel-sub);
			border: 1px solid #000; border-radius: var(--ps-radius);
			box-shadow: 0 8px 24px rgba(0,0,0,0.55);
			z-index: 600; padding: 3px;

			imageflow-ai-option {
				display: flex; align-items: center; gap: 7px;
				min-height: 22px; padding: 3px 8px; border-radius: var(--ps-radius);
				white-space: nowrap; cursor: default;
				imageflow-ai-option-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
				&:hover { background: var(--ps-accent); color: #fff; }
				&.active { color: #fff; }
				&.incompatible {
					color: var(--ps-text-disabled); cursor: not-allowed;
					&:hover { background: transparent; color: var(--ps-text-disabled); }
				}
			}
		}
	}
	/* Pill badge on a picker option (Active / Unavailable). */
	imageflow-ai-badge {
		flex: none;
		font-size: 9px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
		padding: 2px 7px; border-radius: 999px; line-height: 1;
		&.current { background: var(--ps-accent); color: #fff; }
		&.muted { background: transparent; color: var(--ps-text-faint); border: 1px solid var(--ps-divider); }
	}
	imageflow-ai-option:hover imageflow-ai-badge.current { background: #fff; color: var(--ps-accent); }

	/* --- Storage / host rows ------------------------------------------ */
	imageflow-ai-row {
		display: flex; align-items: center; gap: 10px;
	}
	imageflow-ai-row-label {
		flex: none; width: 130px; color: var(--ps-text-dim); font-size: 11px;
	}
	imageflow-ai-row-value {
		flex: 1; color: var(--ps-text); font-size: 11px;
		font-variant-numeric: tabular-nums;
	}

	/* =====================================================================
	   Keyboard Shortcuts settings (Edit ▸ Preferences… ▸ Keyboard Shortcuts)
	   Searchable, menu-grouped command list; each row rebinds by capturing
	   the next chord, with an inline conflict prompt.
	   ===================================================================== */
	imageflow-sc-pane { display: block; }
	imageflow-sc-toolbar {
		display: flex; align-items: center; gap: 8px;
		position: sticky; top: 0; z-index: 1;
		padding-bottom: 10px; margin-bottom: 4px;
		background: var(--ps-panel); border-bottom: 1px solid var(--ps-divider);
		> input[type="text"] { flex: 1; min-width: 0; }
	}
	imageflow-sc-count {
		flex: none; font-size: 10px; color: var(--ps-text-faint);
		font-variant-numeric: tabular-nums;
	}
	imageflow-sc-empty {
		display: block; padding: 24px 8px; text-align: center;
		font-size: 11px; color: var(--ps-text-faint);
	}
	imageflow-sc-group { display: block; margin-top: 14px; }
	imageflow-sc-group-head {
		display: block; padding: 4px 0 6px;
		font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
		color: var(--ps-text-faint);
	}
	imageflow-sc-row {
		display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
		padding: 3px 6px; border-radius: 3px;
		/* Clears the sticky search bar when a row is scrolled into view. */
		scroll-margin-top: 44px;
		&:hover { background: var(--ps-hover); }
		/* A customised binding is marked by the accent rail, not by colour
		   alone — it stays legible for colour-blind users. */
		&.customised { box-shadow: inset 2px 0 0 var(--ps-accent); }
	}
	imageflow-sc-label {
		flex: 1; min-width: 0; font-size: 11px; color: var(--ps-text);
		overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
	}
	imageflow-sc-binding {
		flex: none; min-width: 86px; text-align: center;
		padding: 3px 8px; border: 1px solid var(--ps-divider); border-radius: 3px;
		background: var(--ps-field); color: var(--ps-text);
		font-size: 11px; font-variant-numeric: tabular-nums; cursor: pointer;
		&:hover { border-color: var(--ps-accent); }
		&.recording {
			border-color: var(--ps-accent); color: var(--ps-accent-hi);
			background: color-mix(in srgb, var(--ps-accent) 18%, transparent);
		}
		&:focus-visible { outline: 1px solid var(--ps-accent); outline-offset: 1px; }
	}
	imageflow-sc-none { color: var(--ps-text-faint); font-style: italic; }
	/* Row actions stay out of the way until the row is engaged — the list is
	   long, and a button on every line drowns out the bindings themselves. */
	imageflow-sc-actions {
		flex: none; display: flex; gap: 4px; min-width: 0;
		visibility: hidden;
	}
	imageflow-sc-row:hover imageflow-sc-actions,
	imageflow-sc-row:focus-within imageflow-sc-actions,
	imageflow-sc-row.customised imageflow-sc-actions { visibility: visible; }
	imageflow-sc-clash {
		flex-basis: 100%; margin: 4px 0 2px;
		padding: 7px 9px; border-radius: 3px;
		background: color-mix(in srgb, #c8871a 16%, transparent);
		border: 1px solid color-mix(in srgb, #c8871a 45%, transparent);
		font-size: 11px; color: var(--ps-text);
		> strong { font-weight: 600; }
	}
	imageflow-sc-clash-actions { display: flex; gap: 6px; margin-top: 6px; }

}
