@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

/* Design language: Metal Sketch (dark workshop around a light paper canvas). */
:root {
	--app-bg: #0a0a0a;
	--canvas-frame-bg: #101010;
	--panel-bg: #141414;
	--panel-elevated: #1c1c1c;
	--panel-input: #222222;
	--panel-border: #2e2e2e;
	--panel-text: #f2f2f2;
	--panel-muted: #8d8d8d;
	--panel-track: #3a3a3a;
	--accent: #ff2d2d;
	--accent-soft: #ff4444;
	--warn: #ff9a3d;
	--panel-width: 320px;
	--row-h: 28px;
	--font-sans: "IBM Plex Sans", "Segoe UI", sans-serif;
	font-family: var(--font-sans);
	color: var(--panel-text);
	background: var(--app-bg);
	font-synthesis: none;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

html, body {
	width: 100%;
	height: 100%;
	margin: 0;
	overflow: hidden;
	background: var(--app-bg);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
button:disabled { opacity: 0.35; cursor: not-allowed; }
[hidden] { display: none !important; }
p, h2 { margin: 0; }

.app-shell {
	display: grid;
	grid-template-columns: var(--panel-width) minmax(0, 1fr);
	width: 100%;
	height: 100%;
}

/* ===== Canvas frame ===== */

.canvas-frame {
	position: relative;
	min-width: 0;
	min-height: 0;
	background:
		radial-gradient(circle at 30% 0%, rgba(255, 45, 45, 0.06), transparent 42%),
		var(--canvas-frame-bg);
	overflow: hidden;
}

.view { position: absolute; inset: 0; }
.stage { position: absolute; inset: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sheet-stage canvas { cursor: crosshair; }

.stage-head {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 4;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 14px 16px;
	pointer-events: none;
}
.stage-head > * { pointer-events: auto; }
.canvas-frame.on-light .stage-head { padding-right: 60px; }
.canvas-frame.on-light:has(#drawView.orn-open) .stage-head { padding-right: 248px; }
.stage-char { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.big-char { font-size: 22px; font-weight: 600; line-height: 1; color: #fff; min-width: 16px; }
.stage-meta { font-size: 11px; color: var(--panel-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.canvas-frame.on-light .big-char { color: #111113; }
.canvas-frame.on-light .stage-meta { color: #6b6b6b; }

.stage-head-right {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-left: auto;
	flex-shrink: 0;
}
.btn-launch {
	height: 28px;
	padding: 0 12px;
	border-radius: 6px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
	color: #fff;
	background: #2f6fed;
	flex-shrink: 0;
}
.btn-launch:hover:not(:disabled) { background: #4b84f5; }

.stage-tabs {
	display: flex;
	gap: 4px;
	padding: 4px;
	border-radius: 9px;
	background: rgba(20, 20, 20, 0.88);
	border: 1px solid var(--panel-border);
	backdrop-filter: blur(8px);
	overflow-x: auto;
}
.stage-tabs button {
	height: 26px;
	padding: 0 10px;
	border-radius: 6px;
	font-size: 11px;
	font-weight: 600;
	color: #bbb;
	white-space: nowrap;
}
.stage-tabs button .n { margin-left: 6px; color: #666; font-variant-numeric: tabular-nums; }
.stage-tabs button.active { background: #2a1216; color: #fff; box-shadow: inset 0 0 0 1px var(--accent); }
.stage-tabs button.active .n { color: var(--accent-soft); }
.min-progress {
	position: absolute;
	right: 16px;
	bottom: 16px;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 6px 6px 12px;
	border-radius: 10px;
	background: rgba(20, 20, 20, 0.88);
	border: 1px solid var(--panel-border);
	backdrop-filter: blur(8px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
	font-size: 11px;
	font-weight: 600;
	color: var(--panel-muted);
	white-space: nowrap;
}
.min-progress[hidden] { display: none; }
.min-bar { width: 140px; height: 6px; border-radius: 3px; background: #2a2a2a; overflow: hidden; }
.min-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--accent); transition: width .25s ease; }
.min-progress.ready .min-bar i { background: #4cd964; }
.min-progress b { color: #fff; min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
.min-badge {
	height: 34px;
	padding: 0 10px;
	border-radius: 7px;
	border: 1px solid #3a3a3a;
	color: #bbb;
	font-size: 11px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}
.min-badge:hover { color: #fff; border-color: #555; }
.min-progress.ready .min-badge { color: #4cd964; border-color: rgba(76, 217, 100, 0.45); background: rgba(76, 217, 100, 0.1); cursor: default; }

.stage-empty {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 24px;
	text-align: center;
	color: #6a6a6a;
	font-size: 13px;
}
.glyph-view { display: flex; flex-direction: column; gap: 12px; padding: 58px 24px 76px; }
.preview-bar.glyph-bar { grid-template-columns: auto 200px auto auto; }
.glyph-filled { padding-left: 12px; border-left: 1px solid var(--panel-border); white-space: nowrap; }
.glyph-filled b { color: #fff; font-size: 13px; }
.glyph-filled em { font-style: normal; opacity: .55; }
.glyph-legend b { color: #fff; font-weight: 700; min-width: 1ch; }
.glyph-legend { display: flex; gap: 12px; padding-left: 12px; border-left: 1px solid var(--panel-border); white-space: nowrap; }
.glyph-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: #777; }
.dot.trace { background: #4cd964; }
.dot.drawn { background: var(--accent); }
.dot.auto { background: #5ac8fa; }
.dot.dup { background: #ff9a3d; }
.dot.none { background: transparent; box-shadow: inset 0 0 0 1px #555; }
.glyph-grid {
	position: relative;
	--cell: 168px;
	flex: 1;
	min-height: 0;
	overflow: auto;
	padding: 2px 4px 12px;
	scrollbar-color: #333 transparent;
}
.glyph-grid::-webkit-scrollbar { width: 8px; }
.glyph-grid::-webkit-scrollbar-thumb { background: #333; border-radius: 8px; }
.gsec + .gsec { margin-top: 18px; }
.gsec-head {
	display: flex;
	align-items: baseline;
	gap: 8px;
	margin: 0 0 8px 2px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #9a9a9a;
}
.gsec-head .n { color: #5f5f5f; font-variant-numeric: tabular-nums; }
.gcells { display: grid; grid-template-columns: repeat(auto-fill, var(--cell)); gap: 6px; }
.gcell {
	position: relative;
	display: flex;
	flex-direction: column;
	width: var(--cell);
	padding: 0;
	border-radius: 7px;
	overflow: hidden;
	background: #1a1a1a;
	border: 1px solid #2a2a2a;
	text-align: left;
}
.gcell canvas { display: block; width: 100%; height: calc(var(--cell) * 1.1); }
.gcell-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 20px;
	padding: 0 7px;
	font-size: 11px;
	font-weight: 600;
	color: #bdbdbd;
}
.gcell:hover { border-color: #555; }
.gcell:not(.missing) canvas { cursor: ns-resize; }
.gcell.dragging, .gcell.dragging canvas { cursor: grabbing; }
.gcell.missing .gcell-foot { color: #6a6a6a; }
.gcell.dup .gcell-foot { color: #ff9a3d; }
.gcell.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.gcell.selected .gcell-foot { background: #2a1216; color: #fff; }
.gcell.active { box-shadow: 0 0 0 2px var(--accent); }

.ctx-menu {
	position: fixed;
	z-index: 60;
	min-width: 200px;
	padding: 4px;
	border-radius: 8px;
	background: var(--panel-elevated);
	border: 1px solid #444;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.ctx-menu button {
	display: flex;
	width: 100%;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 6px 10px;
	border: 0;
	border-radius: 5px;
	background: none;
	color: #e6e6e6;
	font: inherit;
	font-size: 12px;
	text-align: left;
	cursor: pointer;
}
.ctx-menu button:hover:not(:disabled) { background: #2a1216; color: #fff; }
.ctx-menu button:disabled { opacity: 1; color: #5a5a5a; cursor: default; }
.ctx-menu kbd { font: inherit; font-size: 11px; color: #8a8a8a; }
.ctx-menu button[hidden], .ctx-sep[hidden] { display: none; }
.ctx-sep { height: 1px; margin: 4px 6px; background: #3a3a3a; }
.ctx-row { display: flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; font-size: 12px; color: #e6e6e6; }
.ctx-row > span { margin-right: auto; }
.ctx-menu .ctx-row button { width: auto; padding: 4px 8px; border: 1px solid #444; font-size: 11px; font-weight: 600; }
.ctx-row[hidden] { display: none; }
.ctx-menu button[aria-expanded='true'] { background: #2a1216; color: #fff; }
.ctx-sub { min-width: 0; width: 272px; }
.ctx-sub-head { margin: 4px 6px 6px; font-size: 11px; color: #8a8a8a; }
.ctx-sub-head b { color: #fff; }
.ctx-sub-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 0 2px 4px; }
.ctx-menu .ctx-sub-grid button { justify-content: center; padding: 6px 0; border: 1px solid #3a3a3a; font-size: 11px; font-weight: 600; }
.ctx-menu .ctx-sub-grid button.has { color: #8be39f; }

.stage-empty p { max-width: 380px; line-height: 1.5; }
.stage-empty .ghost-char { font-size: 140px; line-height: 1; font-weight: 600; color: #1e1e1e; }
.stage-empty .actions { display: flex; gap: 6px; }

.canvas-fab {
	position: absolute;
	left: 16px;
	bottom: 16px;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px;
	border-radius: 10px;
	background: rgba(20, 20, 20, 0.88);
	border: 1px solid var(--panel-border);
	backdrop-filter: blur(8px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.canvas-fab button {
	min-width: 64px;
	height: 34px;
	padding: 0 10px;
	border-radius: 7px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #cfcfcf;
	background: var(--panel-elevated);
	border: 1px solid #333;
}
.canvas-fab button:hover { color: #fff; border-color: #444; }
.canvas-fab button.active { color: #fff; background: #2a1216; border-color: var(--accent); }
.canvas-fab .fab-icon { min-width: 34px; font-size: 16px; padding: 0; }
.fab-sep { width: 1px; height: 22px; background: var(--panel-border); margin: 0 2px; }

/* draw view (Fontxsis LITE engine) */
.draw-stage canvas { position: absolute; inset: 0; }
.draw-metrics { position: absolute; pointer-events: none; }
.draw-stage.in-card { inset: 0 0 auto 0; height: calc(var(--cell) * 1.1); z-index: 1; overflow: hidden; cursor: default; }
.gcell .draw-stage.in-card canvas { width: 100%; height: 100%; }
.draw-ink { touch-action: none; }
.draw-stage[data-tool='select'] .draw-ink,
.draw-stage[data-tool='edit'] .draw-ink { cursor: default; }
.draw-stage[data-tool='pen'] .draw-ink,
.draw-stage[data-tool='draw'] .draw-ink,
.draw-stage[data-tool='rect'] .draw-ink,
.draw-stage[data-tool='ellipse'] .draw-ink { cursor: crosshair; }
.draw-stage[data-tool='brush'] .draw-ink { cursor: none; }
.draw-stage .draw-knife { pointer-events: none; width: 100%; height: 100%; }
.draw-stage[data-tool='knife'],
.draw-stage[data-tool='knife'] .draw-ink {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23111827' stroke='%23fff' stroke-width='.8' d='M3.17 20.38a.75.75 0 0 1-.53-1.28L17.89 3.84a.75.75 0 0 1 1.06 0l2.41 2.41a.75.75 0 0 1 0 1.06l-3.91 3.91 2.17 2.17a.75.75 0 0 1 .05 1c-.2.24-5.02 5.99-16.5 5.99ZM18.42 5.44 5 18.82c7.59-.46 11.68-3.66 13-4.9l-2.17-2.17a.75.75 0 0 1 0-1.06l3.91-3.91-1.32-1.34Z'/%3E%3C/svg%3E") 3 20, crosshair;
}

.app-shell.with-rail { grid-template-columns: 52px var(--panel-width) minmax(0, 1fr); }
.draw-rail {
	order: -2;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	min-height: 0;
	padding: 10px 7px;
	overflow-y: auto;
	background: var(--panel-bg);
	border-right: 1px solid #0d0d0d;
}
.rail-btn {
	width: 36px;
	height: 36px;
	display: grid;
	place-items: center;
	border-radius: 7px;
	color: #bdbdbd;
	border: 1px solid transparent;
}
.rail-btn:hover { color: #fff; background: #222; }
.rail-btn.active { color: #fff; background: #2a1216; border-color: var(--accent); }
.rail-sep { flex: none; width: 28px; height: 1px; margin: 3px 0; background: var(--panel-border); }
.rail-btn { flex: none; }

.draw-zoom {
	position: absolute;
	right: 16px;
	bottom: 16px;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 4px;
	border-radius: 10px;
	background: rgba(20, 20, 20, 0.88);
	border: 1px solid var(--panel-border);
	backdrop-filter: blur(8px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.draw-zoom button {
	height: 30px;
	min-width: 30px;
	display: grid;
	place-items: center;
	border-radius: 7px;
	color: #bdbdbd;
	font-size: 11px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}
.draw-zoom button:hover { color: #fff; background: #222; }
.draw-zoom .zoom-level { min-width: 52px; }
/* Edit Glyphs › ornament dock (right) */
#drawView { --orn-w: 44px; }
#drawView.orn-open { --orn-w: 232px; }
#drawView > .draw-stage { right: var(--orn-w); }
#drawView > .draw-zoom { right: calc(var(--orn-w) + 16px); }
#drawView > .draw-sticky:not(.in-card) { left: calc((100% - var(--orn-w)) / 2); }
.orn-dock { position: absolute; top: 0; right: 0; bottom: 0; z-index: 5; width: var(--orn-w); display: flex; flex-direction: column; gap: 10px; padding: 10px; background: var(--panel-bg); border-left: 1px solid #0d0d0d; overflow: hidden; }
.orn-head { display: flex; align-items: center; gap: 6px; min-height: 26px; font-size: 12px; white-space: nowrap; }
.orn-toggle { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; color: #bdbdbd; border: 1px solid #333; }
.orn-toggle:hover { color: #fff; border-color: #555; }
.orn-dock .orn-toggle[aria-expanded='true'] { color: var(--accent-soft); border-color: var(--accent); }
.orn-count { font-size: 11px; font-weight: 700; color: var(--accent-soft); font-variant-numeric: tabular-nums; }
.orn-import { margin-left: auto; height: 24px; padding: 0 8px; border-radius: 6px; font-size: 11px; font-weight: 600; color: #ddd; border: 1px solid #3a3a3a; }
.orn-import:hover { color: #fff; border-color: #666; }
#drawView:not(.orn-open) .orn-head > :not(.orn-toggle),
#drawView:not(.orn-open) .orn-grid,
#drawView:not(.orn-open) .orn-empty { display: none; }
.orn-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; min-height: 0; overflow-y: auto; align-content: start; }
.orn-grid:empty { display: none; }
.orn-card { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 8px; background: #f2f2f2; border: 1px solid #333; cursor: copy; }
.orn-card:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.orn-card canvas { max-width: 100%; max-height: 100%; }
.orn-del { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; display: none; place-items: center; border-radius: 50%; font-size: 13px; line-height: 1; color: #fff; background: rgba(0, 0, 0, 0.7); cursor: pointer; }
.orn-card:hover .orn-del { display: grid; }
.orn-del:hover { background: var(--accent); }
.orn-empty { display: grid; gap: 6px; padding: 14px 6px; text-align: center; color: var(--panel-muted); font-size: 11px; line-height: 1.45; }
.orn-empty p { margin: 0; font-size: 12px; font-weight: 600; color: #ddd; }
.draw-stage.panning .draw-ink { cursor: grab; }
.draw-stage.panning.pan-drag .draw-ink { cursor: grabbing; }

.draw-sticky {
	position: absolute;
	top: 14px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 6;
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 4px;
	border-radius: 9px;
	background: rgba(20, 20, 20, 0.92);
	border: 1px solid var(--panel-border);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.draw-sticky button {
	height: 28px;
	min-width: 30px;
	padding: 0 10px;
	border-radius: 6px;
	font-size: 11px;
	font-weight: 600;
	color: #d0d0d0;
	background: var(--panel-elevated);
	border: 1px solid #333;
}
.draw-sticky button:hover { color: #fff; border-color: #555; }
.draw-sticky button svg { display: block; width: 16px; height: 16px; margin: 0 auto; }
.draw-sticky button.active { color: #fff; background: #2a1216; border-color: var(--accent); }
.draw-sticky button.danger { color: #ff8080; }
.draw-sticky.in-card { transform: none; z-index: 5; }
.sticky-sep { width: 1px; height: 20px; background: var(--panel-border); margin: 0 2px; }

.brush-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 10px; }
.brush-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	padding: 6px 4px 5px;
	border-radius: 6px;
	background: var(--panel-input);
	border: 1px solid #333;
	color: #cfcfcf;
}
.brush-card:hover { border-color: #555; color: #fff; }
.brush-card.active { border-color: var(--accent); background: #2a1216; color: #fff; }
.brush-svg { display: block; width: 52px; height: 22px; }
.brush-svg svg { width: 100%; height: 100%; }
.brush-name { font-size: 10px; font-weight: 600; }

/* preview view */
.preview-view { display: flex; flex-direction: column; padding: 64px 32px 84px; }
.preview-input {
	align-self: center;
	width: min(560px, 100%);
	height: 34px;
	padding: 0 12px;
	border-radius: 7px;
	background: var(--panel-input);
	border: 1px solid #333;
	color: #fff;
	font-size: 13px;
	outline: none;
	text-align: center;
}
.preview-input:focus { border-color: #666; }
.preview-stage {
	flex: 1;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}
.preview-bar {
	align-self: center;
	display: grid;
	grid-template-columns: auto 260px auto;
	align-items: center;
	gap: 12px;
	padding: 6px 12px;
	border-radius: 9px;
	background: rgba(20, 20, 20, 0.88);
	border: 1px solid var(--panel-border);
	font-size: 11px;
	font-weight: 600;
	color: var(--panel-muted);
}
.preview-stage { overflow: auto; align-items: safe center; scrollbar-color: #333 transparent; }
.preview-stage::-webkit-scrollbar { width: 8px; }
.preview-stage::-webkit-scrollbar-thumb { background: #333; border-radius: 8px; }
#previewRender {
	max-width: 100%;
	min-width: 1ch;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	text-align: center;
	color: #f2f2f2;
	line-height: 1.15;
	font-size: 140px;
	outline: none;
	caret-color: var(--accent);
	cursor: text;
}
#previewRender:empty::before { content: attr(data-placeholder); color: #3a3a3a; }
#previewRender[data-case='upper'] { text-transform: uppercase; }
#previewRender[data-case='lower'] { text-transform: lowercase; }
.preview-tools { display: flex; gap: 4px; padding-left: 12px; border-left: 1px solid var(--panel-border); }
.preview-tools button {
	height: 26px;
	min-width: 34px;
	padding: 0 10px;
	border-radius: 6px;
	font-size: 11px;
	font-weight: 600;
	color: #cfcfcf;
	background: var(--panel-elevated);
	border: 1px solid #333;
}
.preview-tools button:hover { color: #fff; border-color: #555; }
.preview-tools button.active { color: #fff; background: #2a1216; border-color: var(--accent); }
.preview-view .preview-bar { grid-template-columns: auto 260px auto; }
.preview-features { display: flex; gap: 4px; margin-left: 4px; padding-left: 8px; border-left: 1px solid var(--panel-border); }
.preview-features:empty { display: none; }
.gcell-add { justify-content: space-between; border-style: dashed; background: transparent; }
.gcell-add .gcell-plus { height: calc(var(--cell) * 1.1); display: grid; place-items: center; font-size: 34px; font-weight: 300; color: #6a6a6a; }
.gcell-add:hover .gcell-plus { color: #fff; }
.dialog.ot-dialog { width: min(520px, calc(100vw - 48px)); }
.ot-dialog .seg { flex-wrap: wrap; }
.ot-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fimg-conflict-foot { display: flex; justify-content: flex-end; gap: 8px; }
.fimg-conflict-foot #fimgConflictCancel { margin-right: auto; }
.ot-name { font-size: 12px; color: var(--panel-muted); font-variant-numeric: tabular-nums; }
.seg.fmt-seg { grid-template-columns: repeat(4, 1fr); }
.seg.fmt-seg button { padding: 0; font-size: 10px; letter-spacing: .02em; color: #777; background: var(--panel-input); border-color: #333; accent-color: var(--accent); }
.seg.fmt-seg button.active { color: #fff; background: #2a1216; border-color: var(--accent); }
.seg.fmt-seg button:focus { outline: none; }
.seg.fmt-seg button:focus-visible { outline: 1px solid var(--accent-soft); outline-offset: 1px; }
.insp-btn { justify-self: start; height: 26px; padding: 0 12px; font-size: 12px; }
.insp-btns { display: flex; gap: 6px; }
.dialog.info-dialog { width: min(560px, calc(100vw - 48px)); }
.info-dialog #fiTabs { margin-bottom: 16px; }
.info-dialog textarea.insp-input { height: auto; padding: 6px 8px; font-size: 12px; line-height: 1.45; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.info-version { display: flex; align-items: center; gap: 6px; }
.info-version .insp-input { width: 72px; }
.info-hint { margin-left: 8px; font-size: 12px; color: var(--panel-muted); font-variant-numeric: tabular-nums; }
.info-check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12px; color: var(--panel-text); }
.preview-stage { position: relative; }
.kern-pop {
	position: absolute;
	z-index: 5;
	width: 230px;
	padding: 8px 10px;
	border-radius: 9px;
	background: rgba(20, 20, 20, 0.94);
	border: 1px solid var(--panel-border);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
	font-size: 11px;
	color: #777;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}
.kern-pop[hidden], .kern-mark[hidden] { display: none; }
.kern-pop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.kern-pop input:disabled { opacity: .35; }
.kern-name { min-width: 24px; font-weight: 700; color: #aaa; }
.kern-pop.on .kern-name { color: #fff; }
.kern-mode { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.kern-pop button { height: 20px; padding: 0 8px; border-radius: 5px; font-size: 11px; font-weight: 600; color: #ccc; border: 1px solid #3a3a3a; background: transparent; }
.kern-pop button:hover { color: #fff; border-color: var(--accent); }
.kern-pop button[hidden] { display: none; }
.kern-mark { position: absolute; z-index: 4; width: 0; border-left: 1px dashed var(--accent); pointer-events: none; }
.alt-pick {
	position: absolute;
	z-index: 5;
	display: flex;
	gap: 4px;
	max-width: 560px;
	padding: 5px;
	overflow-x: auto;
	border-radius: 9px;
	background: rgba(20, 20, 20, 0.94);
	border: 1px solid var(--panel-border);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.alt-pick[hidden] { display: none; }
.alt-pick button {
	flex: none;
	display: flex;
	flex-direction: column;
	align-items: center;
	min-width: 44px;
	padding: 4px 6px 3px;
	border-radius: 6px;
	border: 1px solid #333;
	background: transparent;
	color: #eee;
}
.alt-pick button:hover { border-color: #666; }
.alt-pick button.active { border-color: var(--accent); background: rgba(255, 45, 45, 0.12); }
.alt-pick-glyph { font-size: 28px; line-height: 1.15; font-feature-settings: normal; }
.alt-pick-name { font-size: 9px; font-weight: 600; color: #888; letter-spacing: .02em; }

/* ===== Dark inspector ===== */

.side-panel {
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 0;
	background: var(--panel-bg);
	color: var(--panel-text);
	border-right: 1px solid #0d0d0d;
	order: -1;
}

.panel-tabs {
	display: grid;
	grid-template-columns: 1fr 1fr;
	height: 42px;
	border-bottom: 1px solid var(--panel-border);
	flex-shrink: 0;
}
.panel-tabs button { font-size: 13px; font-weight: 500; color: var(--panel-muted); }
.panel-tabs button.active { color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.tab-count { margin-left: 4px; font-size: 11px; color: #666; font-variant-numeric: tabular-nums; }
.panel-tabs button.active .tab-count { color: var(--accent-soft); }

.panel-brand {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 12px 10px;
	border-bottom: 1px solid var(--panel-border);
	flex-shrink: 0;
}
.panel-brand-mark { width: 18px; height: 18px; border-radius: 3px; background: var(--accent); flex-shrink: 0; }
.panel-brand-title {
	flex: 1;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.01em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.panel-brand-title span { color: var(--accent-soft); }
.panel-brand .btn-ghost, .panel-brand .btn-accent { padding: 0 9px; }

.btn-ghost, .btn-accent {
	height: 28px;
	padding: 0 12px;
	border-radius: 6px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
}
.btn-ghost { color: #fff; background: #2a2a2a; border: 1px solid #444; }
.btn-ghost:hover:not(:disabled) { background: #333; }
.btn-accent { color: #fff; background: var(--accent); }
.btn-accent:hover:not(:disabled) { background: #ff3d3d; }
.btn-ghost.sm, .btn-accent.sm { height: 24px; padding: 0 9px; font-size: 10px; }
.btn-ghost.full, .btn-accent.full { width: 100%; }

.panel-scroll { flex: 1; min-height: 0; overflow: auto; padding-bottom: 20px; }
.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-thumb { background: #333; border-radius: 8px; }

.section-head {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px 6px;
	color: var(--panel-muted);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-align: left;
}
.section-head .chev { width: 10px; color: #666; font-size: 9px; transform: rotate(90deg); transition: transform 120ms ease; }
.section.collapsed .chev { transform: rotate(0deg); }
.section-meta { margin-left: auto; font-weight: 500; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-body { padding: 0 12px 8px; }
.section.collapsed .section-body { display: none; }

.insp-row {
	display: grid;
	grid-template-columns: 104px minmax(0, 1fr);
	align-items: center;
	gap: 10px;
	min-height: var(--row-h);
	margin-bottom: 6px;
}
.insp-row > span { color: var(--panel-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insp-hint { color: #666; font-size: 10px; line-height: 1.45; margin: 2px 0 6px; }
.kern-classes { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
.kern-classes:empty { display: none; }
.kern-classes button {
	height: 22px; padding: 0 8px; border-radius: 5px; border: 1px solid #333;
	background: var(--panel-input); color: #ccc; font-size: 11px; font-variant-numeric: tabular-nums;
}
.kern-classes button:hover { border-color: var(--accent); color: #fff; }

.insp-slider { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
.insp-slider input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0; }
.insp-slider input[type='range']::-webkit-slider-runnable-track { height: 2px; background: var(--panel-track); border-radius: 2px; }
.insp-slider input[type='range']::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 8px;
	height: 14px;
	margin-top: -6px;
	border-radius: 2px;
	background: #fff;
	border: none;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.insp-slider input[type='range']::-moz-range-track { height: 2px; background: var(--panel-track); border-radius: 2px; border: none; }
.insp-slider input[type='range']::-moz-range-thumb { width: 8px; height: 14px; border-radius: 2px; background: #fff; border: none; }
.insp-slider input[type='range']:disabled { opacity: 0.35; }

.insp-value {
	height: 22px;
	min-width: 44px;
	padding: 0 6px;
	display: grid;
	place-items: center;
	border-radius: 4px;
	background: var(--panel-input);
	border: 1px solid #333;
	color: #fff;
	font-size: 11px;
	font-variant-numeric: tabular-nums;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.insp-warn { min-width: 0; padding: 3px 0; text-align: left; font-size: 11px; line-height: 1.35; color: var(--warn); }
.insp-warn:hover { color: #ffbe80; text-decoration: underline; }
.insp-value.wide { display: block; line-height: 20px; width: 100%; min-width: 0; text-align: left; }

.insp-input {
	height: 26px;
	width: 100%;
	min-width: 0;
	border-radius: 5px;
	background: var(--panel-input);
	border: 1px solid #333;
	color: #fff;
	padding: 0 8px;
	font-size: 12px;
	outline: none;
}
.insp-input:focus { border-color: #666; }
.insp-input.char { width: 52px; text-align: center; font-size: 14px; font-weight: 600; }
.insp-input:disabled { opacity: 0.35; }

.insp-toggle {
	justify-self: end;
	width: 34px;
	height: 20px;
	border-radius: 4px;
	background: #2a2a2a;
	border: 1px solid #444;
	position: relative;
	transition: background 120ms ease, border-color 120ms ease;
}
.insp-toggle::after {
	content: '';
	position: absolute;
	top: 2px;
	left: 2px;
	width: 14px;
	height: 14px;
	border-radius: 2px;
	background: #666;
	transition: transform 120ms ease, background 120ms ease;
}
.insp-toggle[data-checked] { background: #3a3a3a; border-color: #666; }
.insp-toggle[data-checked]::after { transform: translateX(14px); background: #fff; }

.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.seg button {
	height: 26px;
	border-radius: 5px;
	background: var(--panel-input);
	border: 1px solid #333;
	color: #bbb;
	font-size: 11px;
	font-weight: 600;
}
.seg button:hover:not(:disabled) { color: #fff; border-color: #555; }
.seg button.active { color: #fff; border-color: #777; background: #2e2e2e; }

/* sources */
/* left-dock tool buttons (Fontxsis-style menu grid) */
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-top: 2px; }
.tool-btn {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	height: 32px;
	padding: 0 10px;
	border-radius: 6px;
	background: #1f1f1f;
	border: 1px solid #3a3a3a;
	color: #eee;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
}
.tool-btn:hover { background: #262626; border-color: #555; }
.tool-btn.active { color: #fff; background: #2a1216; border-color: var(--accent); }
.tool-btn:disabled { opacity: 0.5; cursor: progress; }
.tool-btn svg { width: 15px; height: 15px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn span { overflow: hidden; text-overflow: ellipsis; }
.tool-meta { margin-left: auto; font-style: normal; font-weight: 600; font-size: 10px; letter-spacing: 0; color: #777; font-variant-numeric: tabular-nums; }
.tool-btn.active .tool-meta { color: var(--accent-soft); }

/* floating panel (js/float.js) */
.fpanel {
	position: fixed;
	inset: auto;
	margin: 0;
	width: min(340px, calc(100vw - 16px));
	max-height: calc(100vh - 16px);
	display: none;
	flex-direction: column;
	padding: 0;
	border: 1px solid var(--panel-border);
	border-radius: 10px;
	background: var(--panel-bg);
	color: var(--panel-text);
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
.fpanel[open] { display: flex; }
.fpanel:focus { outline: none; }
.fpanel-head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 9px 8px 9px 12px;
	border-bottom: 1px solid var(--panel-border);
	cursor: grab;
	user-select: none;
	touch-action: none;
}
.fpanel.dragging .fpanel-head { cursor: grabbing; }
.fpanel-title { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.fpanel-hint { flex: 1; min-width: 0; font-size: 10px; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fpanel-x { width: 24px; height: 24px; border-radius: 5px; color: #999; font-size: 16px; line-height: 1; }
.fpanel-x:hover { color: #fff; background: #2a2a2a; }
.fpanel-body { padding: 10px 12px 12px; overflow: auto; }

.sources { display: flex; flex-direction: column; gap: 6px; }
.source {
	display: grid;
	grid-template-columns: 36px minmax(0, 1fr) auto;
	align-items: center;
	gap: 10px;
	padding: 8px;
	border-radius: 8px;
	background: var(--panel-elevated);
	border: 1px solid var(--panel-border);
}
.source.over { border-color: var(--accent); background: #2a1216; }
.source.active { border-color: #555; }
.source-thumb {
	width: 36px;
	height: 36px;
	border-radius: 5px;
	background: #f7f7f7;
	display: grid;
	place-items: center;
	overflow: hidden;
	color: #888;
	font-size: 9px;
	font-weight: 700;
}
.source-thumb.empty { background: var(--panel-input); border: 1px dashed #3a3a3a; color: #666; }
.source-thumb img { width: 100%; height: 100%; object-fit: cover; }
.source-main { min-width: 0; }
.source-name { display: block; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-sub { display: block; font-size: 10px; color: var(--panel-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-sub.ok { color: #9be39b; }
.source-sub.bad { color: var(--warn); }
.source-sub.busy { color: var(--accent-soft); }
.source-actions { display: flex; gap: 4px; }
.source input[type='file'] { display: none; }
/* ===== Free image (Fontxsis › Import › Free image) ===== */

.free-view { display: flex; flex-direction: column; gap: 12px; padding: 58px 24px 76px; }
.free-view [hidden] { display: none !important; }
.preview-bar.free-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.free-targets { display: flex; gap: 4px; }
.free-targets button, .free-upload, .free-clear { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 6px; font-size: 11px; font-weight: 600; color: #cfcfcf; background: var(--panel-elevated); border: 1px solid #333; }
.free-targets button b { font-size: 14px; color: #fff; }
.free-targets button:hover, .free-upload:hover, .free-clear:hover { color: #fff; border-color: #555; }
.free-targets button.active { color: #fff; background: #2a1216; border-color: var(--accent); }
.free-upload { border-style: dashed; }
.fimg-file { font-weight: 600; color: #333; }
.fimg-info { position: absolute; left: 12px; top: 10px; display: flex; flex-direction: column; gap: 2px; max-width: calc(50% - 160px); font-size: 11px; color: #666; pointer-events: none; }
.fimg-info span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fimg-stat { display: flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid #2f5f3a; background: #13261a; color: #8be39f; font-size: 11px; font-weight: 600; white-space: nowrap; }
.fimg-stat b { font-size: 15px; color: #fff; font-variant-numeric: tabular-nums; }
.fimg-stat.bad { border-color: #6b3a14; background: #2a1a0c; color: var(--warn); }
.fimg-stage { position: relative; flex: 1; min-height: 0; border-radius: 4px; overflow: hidden; background: #f7f7f7; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65); }
.fimg-stage.over { outline: 2px dashed var(--accent); outline-offset: -4px; }
.fimg-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; gap: 8px; color: #555; }
.fimg-empty p { margin: 0; font-size: 18px; font-weight: 700; color: #222; }
.fimg-empty small { font-size: 12px; }
.fimg-canvas-wrap { position: absolute; inset: 0; }
.fimg-canvas-wrap canvas { display: block; cursor: default; }
.fimg-sticky { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border-radius: 10px; background: var(--panel-bg); border: 1px solid #333; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.fimg-sel-count { min-width: 18px; font-size: 12px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.fimg-sticky button { height: 26px; padding: 0 10px; border-radius: 6px; font-size: 12px; font-weight: 600; color: #ddd; border: 1px solid #3a3a3a; }
.fimg-sticky button:hover:not(:disabled) { color: #fff; border-color: #666; }
.fimg-sticky button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.fimg-sep { width: 1px; height: 18px; background: #3a3a3a; }
.fimg-assign { position: absolute; top: 54px; left: 50%; transform: translateX(-50%); width: 320px; max-height: calc(100% - 64px); display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 10px; background: var(--panel-bg); border: 1px solid #3a3a3a; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45); }
.fimg-assign-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.fimg-assign-head button { font-size: 18px; line-height: 1; color: #aaa; }
.fimg-assign p { margin: 0; font-size: 11px; color: var(--panel-muted); }
.fimg-assign-filter { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--panel-muted); }
.fimg-assign-filter select { flex: 1; }
.fimg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 4px; min-height: 0; overflow: auto; }
.fimg-char { height: 30px; border-radius: 5px; font-size: 14px; font-weight: 600; color: #ddd; background: var(--panel-input); border: 1px solid #333; }
.fimg-char.wide { grid-column: span 2; font-size: 12px; }
.fimg-char.has { color: #8be39f; }
.fimg-char:hover { border-color: #666; color: #fff; }
.fimg-char.active { border-color: var(--accent); background: #2a1216; color: #fff; }
.fimg-empty-grid { grid-column: 1 / -1; margin: 0; font-size: 11px; color: var(--panel-muted); }
.fimg-assign-actions { display: flex; justify-content: flex-end; gap: 6px; }
.fimg-assign.fimg-ot { top: 54px; right: 12px; left: auto; transform: none; width: 280px; }
.fimg-ot-key { margin-left: auto; margin-right: 4px; font-size: 12px; font-weight: 700; color: var(--accent-soft); font-variant-numeric: tabular-nums; }
.fimg-ot .fimg-assign-filter input { width: 44px; flex: none; text-align: center; font-size: 14px; font-weight: 700; }
.fimg-ot-guess { display: flex; flex-wrap: wrap; gap: 4px; min-height: 0; font-size: 11px; color: var(--panel-muted); }
.fimg-ot-guess:empty { display: none; }
.fimg-ot-guess button { height: 22px; padding: 0 8px; border-radius: 5px; font-size: 11px; font-weight: 600; color: #ddd; background: var(--panel-input); border: 1px solid #333; }
.fimg-ot-guess button:hover { color: #fff; border-color: #666; }
.fimg-ot-guess button.active { border-color: var(--accent); background: #2a1216; color: #fff; }
.fimg-ot-tags { grid-template-columns: repeat(5, 1fr); }
.fimg-ot-tags .fimg-char { font-size: 12px; }
.fimg-ot-tags .fimg-char.next { border-color: var(--accent-soft); }
.fimg-ot-tags .fimg-char:disabled { opacity: .35; cursor: default; }
.fimg-ot-liga { display: flex; align-items: center; gap: 6px; padding-top: 8px; border-top: 1px solid var(--panel-border); font-size: 11px; color: #ccc; }
.fimg-ot-liga input { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; }
.fimg-ot-liga button { flex: none; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; }
.fimg-hud { position: absolute; right: 10px; bottom: 10px; display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 8px; background: var(--panel-bg); border: 1px solid #333; }
.fimg-hud button { min-width: 26px; height: 24px; padding: 0 6px; border-radius: 5px; font-size: 12px; font-weight: 600; color: #ddd; }
.fimg-hud button:hover { background: #2a2a2a; color: #fff; }
.fimg-hud span { min-width: 44px; text-align: center; font-size: 11px; color: #aaa; font-variant-numeric: tabular-nums; }
.fimg-status:empty { display: none; }
.fimg-status.bad { font-weight: 600; color: #c2410c; }

/* characters tab */
.char-groups { padding: 4px 12px 12px; }
.char-group + .char-group { margin-top: 14px; }
.char-group-head { display: flex; justify-content: space-between; padding: 6px 0 8px; color: var(--panel-muted); font-size: 11px; font-weight: 600; }
.char-group-head .n { color: #666; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.tile {
	position: relative;
	aspect-ratio: 1;
	display: grid;
	place-items: center;
	border-radius: 6px;
	background: var(--panel-elevated);
	border: 1px solid var(--panel-border);
	color: #fff;
	font-size: 20px;
	line-height: 1;
}
.tile:hover { border-color: #555; }
.tile.missing { background: transparent; border-style: dashed; border-color: #2e2e2e; color: #4a4a4a; font-size: 15px; }
.tile.selected { border-color: var(--accent); background: #2a1216; }
.tile.dup::after { content: ''; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--warn); }

.panel-footer-hint {
	margin-top: auto;
	padding: 10px 12px;
	border-top: 1px solid var(--panel-border);
	color: #666;
	font-size: 10px;
	letter-spacing: 0.02em;
	flex-shrink: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ===== Dialog ===== */

.dialog {
	width: min(980px, calc(100vw - 48px));
	max-height: calc(100vh - 48px);
	padding: 20px;
	border: 1px solid var(--panel-border);
	border-radius: 12px;
	background: var(--panel-bg);
	color: var(--panel-text);
	box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.dialog-head h2 { font-size: 16px; font-weight: 700; }
.dialog-head p { margin-top: 4px; font-size: 12px; color: var(--panel-muted); line-height: 1.5; }
.dialog-head b { color: #fff; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { color: var(--panel-muted); font-size: 11px; font-weight: 600; }
.field textarea {
	resize: vertical;
	padding: 8px 10px;
	border-radius: 6px;
	background: var(--panel-input);
	border: 1px solid #333;
	color: #fff;
	font-size: 13px;
	outline: none;
}
.field textarea:focus { border-color: #666; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.template {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 10px;
	border-radius: 8px;
	background: var(--panel-elevated);
	border: 1px solid var(--panel-border);
}
.template-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; font-weight: 600; }
.template-head small { color: var(--panel-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.template img { width: 100%; border-radius: 4px; background: #fff; }
.template .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	z-index: 50;
	padding: 9px 14px;
	border-radius: 8px;
	background: var(--panel-elevated);
	border: 1px solid #444;
	color: #fff;
	font-size: 12px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

@media (max-width: 860px) {
	html, body { overflow: auto; }
	.app-shell { grid-template-columns: 1fr; grid-template-rows: 62vh auto; height: auto; min-height: 100%; }
	.side-panel { height: auto; border-right: 0; border-top: 1px solid #0d0d0d; order: 0; }
	.app-shell.with-rail { grid-template-columns: 1fr; grid-template-rows: auto 62vh auto; }
	.draw-rail { flex-direction: row; flex-wrap: wrap; justify-content: center; border-right: 0; border-bottom: 1px solid #0d0d0d; }
	.rail-sep { width: 1px; height: 28px; margin: 0 3px; }
	.panel-scroll { overflow: visible; }
}
