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

@font-face {
	font-family: 'TypeRig Icons';
	src: url('../assets/fonts/icons/typerig-icons.ttf') format('truetype');
	font-weight: normal;
	font-style: normal;
}

/* -- Variables ---------------------------------------------- */
:root {
	--bg-primary: #1a1a1e;
	--bg-secondary: #222226;
	--bg-tertiary: #2a2a2e;
	--bg-hover: #333338;
	--border: #3a3a40;
	--border-subtle: #2e2e34;
	--text-primary: #e8e8ec;
	--text-secondary: #9898a0;
	--text-dim: #686870;
	--accent: #5b9def;
	--accent-dim: #3a6fb0;
	--accent-bg: rgba(91,157,239,0.08);
	--node-on: #e8e8ec;
	--node-off: #5b9def;
	--node-smooth: #50c878;
	--node-selected: #ff6b6b;
	--handle-line: rgba(91,157,239,0.45);
	--outline-fill: rgba(200,200,210,0.12);
	--outline-stroke: #c8c8d2;
	--metric-line: rgba(255,120,80,0.35);
	--metric-line-adv: rgba(91,157,239,0.45);
	--baseline: rgba(255,120,80,0.25);
	--anchor-color: #ff6b6b;
	--xml-tag: #5b9def;
	--xml-attr: #c792ea;
	--xml-value: #c3e88d;
	--xml-comment: #686870;
	--xml-highlight: rgba(91,157,239,0.15);
	--xml-highlight-border: rgba(91,157,239,0.5);
	--scrollbar-thumb: #3a3a40;
	--scrollbar-track: transparent;
}

/* -- Light Mode ------------------------------------------------ */
[data-theme="light"] {
	--bg-primary: #fafafa;
	--bg-secondary: #ffffff;
	--bg-tertiary: #f0f0f0;
	--bg-hover: #e5e5e5;
	--border: #d0d0d0;
	--border-subtle: #e5e5e5;
	--text-primary: #383a42;
	--text-secondary: #696c77;
	--text-dim: #a0a1a7;
	--accent: #4078f2;
	--accent-dim: #4078f2;
	--accent-bg: rgba(64,120,242,0.08);
	--node-on: #383a42;
	--node-off: #4078f2;
	--node-smooth: #50a14f;
	--node-selected: #e45649;
	--handle-line: rgba(64,120,242,0.45);
	--outline-fill: rgba(56,58,66,0.08);
	--outline-stroke: #383a42;
	--metric-line: rgba(193,132,1,0.35);
	--metric-line-adv: rgba(64,120,242,0.45);
	--baseline: rgba(193,132,1,0.25);
	--anchor-color: #e45649;
	--xml-tag: #4078f2;
	--xml-attr: #a626a4;
	--xml-value: #50a14f;
	--xml-comment: #a0a1a7;
	--xml-highlight: rgba(64,120,242,0.15);
	--xml-highlight-border: rgba(64,120,242,0.5);
	--scrollbar-thumb: #c0c0c0;
}

/* -- Reset -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
	font-family: 'DM Sans', sans-serif;
	background: var(--bg-primary);
	color: var(--text-primary);
	height: 100vh;
	overflow: hidden;
	user-select: none;
	-webkit-font-smoothing: antialiased;
}

/* -- Scrollbar ---------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a50; }

/* -- Layout ------------------------------------------------- */
#app {
	display: grid;
	grid-template-rows: auto 1fr auto;
	height: 100vh;
}

/* -- Toolbar ------------------------------------------------ */
#toolbar {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	background: var(--bg-secondary);
	border-bottom: 1px solid var(--border);
	z-index: 10;
}

#toolbar .logo {
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-weight: 600;
	font-size: 12px;
	color: var(--accent);
	letter-spacing: 0.5px;
	margin-right: 8px;
	white-space: nowrap;
}

#toolbar .separator {
	width: 1px;
	height: 20px;
	background: var(--border);
	margin: 0 4px;
}

.tb-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 5px 10px;
	background: transparent;
	border: 1px solid transparent;
	border-radius: 4px;
	color: var(--text-secondary);
	font-family: 'DM Sans', sans-serif;
	font-size: 12px;
	cursor: pointer;
	transition: all 0.15s;
	white-space: nowrap;
}

.tb-btn:hover {
	background: var(--bg-hover);
	color: var(--text-primary);
	border-color: var(--border);
}

.tb-btn.active {
	background: var(--accent-bg);
	color: var(--accent);
	border-color: var(--accent-dim);
}

.tb-btn svg { width: 14px; height: 14px; }

.tri {
	font-family: 'TypeRig Icons';
	font-size: 18px;
	line-height: 1;
	font-style: normal;
	font-weight: normal;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.tb-group {
	display: flex;
	align-items: center;
	gap: 2px;
}

.tb-spacer { flex: 1; }

/* -- Toolbar dropdowns -------------------------------------- */
.tb-dropdown {
	position: relative;
}

.tb-dropdown-menu {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	margin-top: 4px;
	min-width: 180px;
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 4px 0;
	box-shadow: 0 8px 24px rgba(0,0,0,0.4);
	z-index: 100;
}

.tb-dropdown.open .tb-dropdown-menu { display: block; }

.tb-menu-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 5px 12px 5px 10px;
	font-family: 'DM Sans', sans-serif;
	font-size: 12px;
	color: var(--text-secondary);
	cursor: pointer;
	white-space: nowrap;
	border-left: 2px solid transparent;
}

.tb-menu-item:hover {
	background: var(--bg-hover);
	color: var(--text-primary);
}

.tb-menu-item.active {
	border-left-color: var(--accent);
	color: var(--accent);
}

.tb-menu-item .tri { font-size: 18px; width: 18px; text-align: center; }

.tb-shortcut {
	margin-left: auto;
	font-size: 10px;
	color: var(--text-dim);
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
}

.tb-menu-sep {
	height: 1px;
	background: var(--border-subtle);
	margin: 4px 8px;
}

/* -- Layer icon in toolbar ---------------------------------- */
.tb-layer-icon {
	color: var(--text-dim);
	font-size: 18px;
	margin-right: -2px;
}

/* -- Scope toggle groups ------------------------------------ */
.tb-scope {
	display: inline-flex;
	align-items: center;
	gap: 1px;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 1px;
}

.tb-scope__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 24px;
	padding: 0;
	background: transparent;
	border: none;
	border-radius: 3px;
	color: var(--text-dim);
	cursor: pointer;
	transition: all 0.12s ease;
}

.tb-scope__btn .tri {
	font-size: 18px;
	line-height: 1;
}

.tb-scope__btn:hover {
	background: var(--bg-hover);
	color: var(--text-secondary);
}

.tb-scope__btn.active {
	background: var(--accent-bg);
	color: var(--accent);
}

#glyph-info {
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 12px;
	color: var(--text-dim);
	margin-left: 8px;
}

#glyph-info span { color: var(--text-secondary); }

/* -- Main area ---------------------------------------------- */
#main {
	display: flex;
	overflow: hidden;
	position: relative;
}

/* -- Canvas (original) -------------------------------------- */
#canvas-wrap {
	position: relative;
	overflow: hidden;
	background: var(--bg-primary);
	cursor: default;
	flex: 1;
	min-width: 200px;
}

#canvas-wrap:active { cursor: inherit; }

#glyph-canvas {
	position: absolute;
	top: 0; left: 0;
	width: 100%;
	height: 100%;
}

/* -- Glyph Widget Overlay ----------------------------------- */
#glyph-widgets {
	position: absolute;
	top: 0; left: 0;
	pointer-events: none;
	z-index: 19;
}

#glyph-widgets > .glyph-widget {
	pointer-events: auto;
}

.glyph-widget {
	position: absolute;
	display: none;
	flex-direction: column;
	gap: 4px;
	z-index: 20;
	background: var(--bg-secondary);
	border: 1px solid var(--accent-dim);
	border-radius: 6px;
	padding: 6px;
	box-shadow: 0 4px 12px rgba(0,0,0,0.2);
	backdrop-filter: blur(4px);
	pointer-events: auto;
	min-width: 100px;
}

.glyph-widget.visible { display: flex; }

/* Stacked layout (narrow widgets) */
.glyph-widget.gw-stacked {
	display: grid;
	grid-template-columns: 1fr;
	padding: 4px;
	gap: 3px;
}

.glyph-widget.gw-stacked .gw-row {
	display: contents;
}

.glyph-widget.gw-stacked .gw-field {
	width: 100%;
}

.glyph-widget .gw-row {
	display: flex;
	gap: 4px;
}

.glyph-widget .gw-row + .gw-row {
	margin-top: 4px;
}

.glyph-widget .gw-field {
	display: flex;
	align-items: center;
	gap: 4px;
	background: var(--bg-hover);
	border-radius: 4px;
	padding: 0 6px;
	min-width: 50px;
	height: 24px;
	flex: 1;
}

.glyph-widget .gw-field input {
	pointer-events: auto;
}

/* Layer indicator field */
.glyph-widget .gw-field[data-field="layer"] {
	cursor: default;
}

.glyph-widget .gw-field[data-field="layer"] .gw-value {
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 10px;
	font-weight: 500;
}

.glyph-widget .gw-field[data-field="layer"] .tri {
	color: var(--accent);
}

/* Non-active glyph widgets - grayed out, simplified */
.glyph-widget--readonly {
	background: var(--bg-tertiary);
	border-color: var(--border);
	padding: 4px;
	gap: 3px;
}

.glyph-widget--readonly .gw-field {
	background: var(--bg-primary);
	min-width: 50px;
	height: 22px;
	opacity: 0.8;
}

.glyph-widget--readonly .gw-field--action {
	cursor: pointer;
	min-width: 22px;
	justify-content: center;
}

.glyph-widget--readonly .gw-field--action:hover {
	background: rgba(220,60,60,0.3);
}

.glyph-widget--readonly .gw-field--action:hover .tri {
	color: var(--node-selected);
}

.glyph-widget--readonly .gw-input {
	color: var(--text-dim);
	pointer-events: none;
}

.glyph-widget--readonly .tri {
	color: var(--accent);
	opacity: 0.5;
}

.glyph-widget .gw-value {
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 10px;
	color: var(--text-dim);
	margin-left: 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.glyph-widget .gw-field--action {
	cursor: pointer;
	min-width: 28px;
	justify-content: center;
}

.glyph-widget .gw-field--action:hover {
	background: rgba(220,60,60,0.3);
}

.glyph-widget .tri {
	font-family: 'TypeRig Icons', sans-serif;
	font-size: 18px;
	color: var(--accent);
	width: 18px;
	text-align: center;
}

.glyph-widget .gw-field--action .tri {
	color: var(--text-secondary);
}

.glyph-widget .gw-field--action:hover .gw-icon {
	color: var(--node-selected);
}

.glyph-widget .gw-input {
	flex: 1;
	background: transparent;
	border: none;
	outline: none;
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 10px;
	color: var(--text-primary);
	min-width: 30px;
}

.glyph-widget .gw-input:focus {
	color: var(--accent);
}

.glyph-widget .gw-input::placeholder {
	color: var(--text-dim);
}

.glyph-widget input[type="number"] {
	text-align: left;
	-moz-appearance: textfield;
}

.glyph-widget input[type="number"]::-webkit-outer-spin-button,
.glyph-widget input[type="number"]::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* -- Mark/Flag color selector field ----------------------------- */
.glyph-widget .gw-field--mark {
	cursor: pointer;
	position: relative;
	min-width: 50px;
	height: 24px;
	flex: 1;
	gap: 4px;
}

.glyph-widget .gw-mark-swatch {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	border: 1px solid var(--border);
	flex-shrink: 0;
}

.glyph-widget .gw-mark-swatch--active {
	border-color: transparent;
}

/* Mark dropdown */
.glyph-widget .gw-mark-dropdown {
	display: none;
	position: absolute;
	bottom: calc(100% + 4px);
	left: 50%;
	transform: translateX(-50%);
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 6px;
	box-shadow: 0 4px 16px rgba(0,0,0,0.3);
	z-index: 30;
	width: 150px;
}

.glyph-widget .gw-mark-dropdown.visible {
	display: block;
}

.glyph-widget .gw-mark-option {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 5px 8px;
	border-radius: 4px;
	cursor: pointer;
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 11px;
	color: var(--text-secondary);
}

.glyph-widget .gw-mark-option:hover {
	background: var(--bg-hover);
	color: var(--text-primary);
}

.glyph-widget .gw-mark-dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	flex-shrink: 0;
}

.glyph-widget .gw-mark-dot--clear {
	border: 1px solid var(--text-dim);
	position: relative;
}

.glyph-widget .gw-mark-dot--clear::after {
	content: '';
	position: absolute;
	top: 50%;
	left: -1px;
	right: -1px;
	height: 1px;
	background: var(--text-dim);
	transform: rotate(-45deg);
}

.glyph-widget .gw-mark-label {
	white-space: nowrap;
}

/* -- XML Panel (class-based, multi-instance) ---------------- */
.xml-panel__content {
	flex: 1;
	overflow: auto;
	padding: 0;
	margin: 0;
	border: none;
	outline: none;
	resize: none;
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 12px;
	line-height: 1.65;
	tab-size: 2;
	-moz-tab-size: 2;
	white-space: pre;
	color: var(--text-secondary);
	background: var(--bg-secondary);
	padding: 12px;
	user-select: text;
}

.xml-panel__content:focus { outline: none; }

.xml-panel__content.has-error {
	box-shadow: inset 0 0 0 1px rgba(255,107,107,0.4);
}

/* -- Python Panel (class-based, multi-instance) ------------- */
.py-panel__output {
	flex: 1;
	overflow-y: auto;
	padding: 10px 12px;
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 12px;
	line-height: 1.6;
	user-select: text;
}

.py-entry {
	white-space: pre-wrap;
	word-break: break-all;
	margin-bottom: 4px;
}

.py-input { color: var(--accent); }
.py-output { color: var(--text-secondary); }
.py-error { color: #ff6b6b; }
.py-info { color: var(--text-dim); font-style: italic; }

/* Python input area */
.py-panel__input-wrap {
	border-top: 1px solid var(--border);
	padding: 8px;
	background: var(--bg-tertiary);
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.py-panel__input {
	width: 100%;
	min-height: 28px;
	max-height: 160px;
	padding: 6px 8px;
	background: var(--bg-primary);
	border: 1px solid var(--border);
	border-radius: 4px;
	color: var(--text-primary);
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 12px;
	line-height: 1.5;
	resize: none;
	outline: none;
	overflow-y: auto;
	user-select: text;
}

.py-panel__input:focus { border-color: var(--accent-dim); }
.py-panel__input:disabled { opacity: 0.4; cursor: not-allowed; }
.py-panel__input::placeholder { color: var(--text-dim); }

.py-panel__actions {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 10px;
	color: var(--text-dim);
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
}

.py-panel__actions .hint { margin-left: auto; }

/* Python toolbar buttons */
.py-btn {
	padding: 3px 8px;
	background: var(--bg-hover);
	border: 1px solid var(--border);
	border-radius: 3px;
	color: var(--text-secondary);
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 10px;
	cursor: pointer;
	transition: all 0.12s;
}

.py-btn:hover {
	background: var(--bg-tertiary);
	color: var(--text-primary);
	border-color: var(--accent-dim);
}

.py-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.py-btn--primary {
	background: var(--accent-dim);
	border-color: var(--accent);
	color: var(--text-primary);
}

.py-btn--primary:hover { background: var(--accent); }

/* Python status badge */
.py-status {
	font-size: 10px;
	padding: 1px 6px;
	border-radius: 3px;
}

.py-status--idle { color: var(--text-dim); background: rgba(104,104,112,0.15); }
.py-status--ready { color: #50c878; background: rgba(80,200,120,0.1); }
.py-status--error { color: #ff6b6b; background: rgba(255,107,107,0.1); }

/* -- AI Agent Panel ------------------------------------------ */
.ai-panel {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
}

.ai-panel__header {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px;
	background: var(--bg-tertiary);
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}

.ai-select {
	flex: 1;
	padding: 4px 8px;
	background: var(--bg-primary);
	border: 1px solid var(--border);
	border-radius: 4px;
	color: var(--text-primary);
	font-size: 11px;
	cursor: pointer;
}

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

.ai-btn {
	padding: 4px 10px;
	background: var(--bg-hover);
	border: 1px solid var(--border);
	border-radius: 4px;
	color: var(--text-secondary);
	font-size: 11px;
	cursor: pointer;
	transition: all 0.12s;
}

.ai-btn:hover {
	background: var(--bg-tertiary);
	color: var(--text-primary);
	border-color: var(--accent-dim);
}

.ai-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.ai-btn--primary {
	background: var(--accent-dim);
	border-color: var(--accent);
	color: var(--text-primary);
}

.ai-btn--primary:hover {
	background: var(--accent);
}

.ai-btn--icon {
	padding: 4px 8px;
}

.ai-panel__settings {
	padding: 10px;
	background: var(--bg-secondary);
	border-bottom: 1px solid var(--border);
}

.ai-settings-title {
	font-size: 11px;
	font-weight: 600;
	color: var(--text-secondary);
	margin-bottom: 8px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.ai-settings-group {
	margin-bottom: 10px;
}

.ai-settings-group label {
	display: block;
	font-size: 10px;
	color: var(--text-dim);
	margin-bottom: 4px;
}

.ai-input {
	width: 100%;
	padding: 6px 8px;
	background: var(--bg-primary);
	border: 1px solid var(--border);
	border-radius: 4px;
	color: var(--text-primary);
	font-size: 11px;
}

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

.ai-panel__chat {
	flex: 1;
	overflow-y: auto;
	padding: 10px;
}

.ai-message {
	margin-bottom: 12px;
	padding: 10px 12px;
	border-radius: 8px;
	max-width: 95%;
}

.ai-message--user {
	background: rgba(91, 157, 239, 0.15);
	border: 1px solid rgba(91, 157, 239, 0.3);
	margin-left: auto;
}

.ai-message--assistant {
	background: var(--bg-secondary);
	border: 1px solid var(--border);
}

.ai-message--system {
	background: var(--bg-tertiary);
	border: 1px dashed var(--border);
	font-size: 11px;
}

.ai-message--thinking {
	background: var(--bg-secondary);
	border: 1px solid var(--border);
}

.ai-message--error {
	background: rgba(255, 107, 107, 0.1);
	border: 1px solid rgba(255, 107, 107, 0.3);
	color: #ff6b6b;
}

.ai-message__header {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 11px;
	font-weight: 600;
	color: var(--text-secondary);
	margin-bottom: 6px;
}

.ai-message__content {
	font-size: 12px;
	line-height: 1.6;
	color: var(--text-primary);
	word-break: break-word;
	user-select: text;
	-webkit-user-select: text;
	cursor: text;
}

.ai-message__content .ai-code {
	user-select: text;
	-webkit-user-select: text;
	cursor: text;
}

.ai-message__content .tri {
	font-size: 14px;
	color: var(--text-dim);
}

.ai-code {
	background: var(--bg-primary);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 10px;
	margin: 8px 0;
	overflow-x: auto;
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 11px;
	line-height: 1.5;
	color: var(--accent);
}

.ai-inline-code {
	background: var(--bg-primary);
	padding: 1px 4px;
	border-radius: 3px;
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 11px;
	color: var(--accent);
}

.ai-message__actions {
	display: flex;
	justify-content: flex-end;
	margin-top: 6px;
	gap: 4px;
}

.ai-copy-btn {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	padding: 2px 8px;
	background: var(--bg-primary);
	border: 1px solid var(--border);
	border-radius: 3px;
	color: var(--text-dim);
	font-size: 10px;
	cursor: pointer;
	transition: all 0.12s;
	user-select: none;
	-webkit-user-select: none;
}

.ai-copy-btn:hover {
	color: var(--text-primary);
	border-color: var(--accent-dim);
	background: var(--bg-hover);
}

.ai-copy-btn .tri {
	font-size: 13px;
}

.ai-error-detail {
	background: rgba(255, 107, 107, 0.08);
	border: 1px solid rgba(255, 107, 107, 0.25);
	border-radius: 4px;
	padding: 8px 10px;
	margin: 6px 0;
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 11px;
	line-height: 1.5;
	color: #ff6b6b;
	white-space: pre-wrap;
	word-break: break-word;
	user-select: text;
	-webkit-user-select: text;
	overflow-x: auto;
}

.ai-thinking {
	color: var(--text-dim);
	font-style: italic;
}

.ai-dots::after {
	content: '';
	animation: ai-dots 1.5s infinite;
}

@keyframes ai-dots {
	0%, 20% { content: '.'; }
	40% { content: '..'; }
	60%, 100% { content: '...'; }
}

.ai-panel__input-wrap {
	border-top: 1px solid var(--border);
	padding: 8px;
	background: var(--bg-tertiary);
}

.ai-panel__input {
	width: 100%;
	min-height: 32px;
	max-height: 120px;
	padding: 8px 10px;
	background: var(--bg-primary);
	border: 1px solid var(--border);
	border-radius: 6px;
	color: var(--text-primary);
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 12px;
	line-height: 1.5;
	resize: none;
	outline: none;
}

.ai-panel__input:focus {
	border-color: var(--accent-dim);
}

.ai-panel__input::placeholder {
	color: var(--text-dim);
}

.ai-panel__actions {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 8px;
}

.ai-panel__statusbar {
	padding: 4px 8px;
	background: var(--bg-tertiary);
	border-top: 1px solid var(--border);
	font-size: 10px;
	flex-shrink: 0;
}

.ai-status {
	padding: 1px 6px;
	border-radius: 3px;
}

.ai-status--idle { color: var(--text-dim); background: rgba(104,104,112,0.15); }
.ai-status--ready { color: #50c878; background: rgba(80,200,120,0.1); }
.ai-status--error { color: #ff6b6b; background: rgba(255,107,107,0.1); }
.ai-status--loading { color: var(--accent); background: rgba(91,157,239,0.1); }


/* -- Help Panel ---------------------------------------------- */
.help-panel {
	padding: 12px 14px;
	overflow-y: auto;
	height: 100%;
	font-size: 12px;
	line-height: 1.5;
	color: var(--text-secondary);
	user-select: text;
	-webkit-user-select: text;
}

.help-panel__heading {
	font-size: 12px;
	font-weight: 600;
	color: var(--text-primary);
	margin: 16px 0 6px;
	padding-bottom: 3px;
	border-bottom: 1px solid var(--border);
}

.help-panel__heading:first-child {
	margin-top: 0;
}

.help-panel__text {
	margin: 0 0 4px;
	color: var(--text-secondary);
}

.help-panel__table {
	width: 100%;
	border-collapse: collapse;
	font-size: 11px;
	margin-bottom: 12px;
}

.help-panel__table th {
	text-align: left;
	font-weight: 600;
	color: var(--text-primary);
	padding: 4px 8px 4px 0;
	border-bottom: 1px solid var(--border);
}

.help-panel__table td {
	padding: 3px 8px 3px 0;
	border-bottom: 1px solid var(--bg-tertiary);
	color: var(--text-secondary);
}

.help-panel__key {
	white-space: nowrap;
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 11px;
	color: var(--accent);
}


/* -- XML action bar (Refresh / Apply) ------------------------ */
.xml-panel__actions {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 4px 6px;
	background: var(--bg-tertiary);
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}

.xml-panel__actions .tb-btn {
	padding: 3px 6px;
	font-size: 11px;
}

.ctx-item .tri { font-size: 18px; margin-right: 6px; }

/* -- Node highlighting in textarea (via overlay) ------------ */
#xml-highlight-overlay {
	display: none;
}


/* -- Context menu ------------------------------------------- */
#context-menu {
	display: none;
	position: fixed;
	z-index: 50;
	min-width: 160px;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 4px 0;
	box-shadow: 0 4px 16px rgba(0,0,0,0.4);
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 11px;
}

#context-menu.visible { display: block; }

.ctx-item {
	padding: 6px 14px;
	color: var(--text-secondary);
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.1s, color 0.1s;
}

.ctx-item:hover {
	background: var(--accent-bg);
	color: var(--text-primary);
}

.ctx-separator {
	height: 1px;
	background: var(--border);
	margin: 4px 0;
}
/* -- Status bar --------------------------------------------- */
#statusbar {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 4px 12px;
	background: var(--bg-secondary);
	border-top: 1px solid var(--border);
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 10px;
	color: var(--text-dim);
}

#statusbar .status-item { display: flex; align-items: center; gap: 4px; }
#statusbar .status-label { color: var(--text-dim); }
#statusbar .status-value { color: var(--text-secondary); }

.status-sep {
	width: 1px;
	height: 14px;
	background: var(--border);
	margin: 0 6px;
}

/* -- Transform numeric controls --------------------------------- */
#tf-controls {
	gap: 6px;
	align-items: center;
}

.tf-mode-label {
	font: 600 10px 'IBM Plex Mono', 'JetBrains Mono', monospace;
	color: var(--accent);
	padding: 2px 6px;
	background: var(--accent-bg);
	border-radius: 3px;
	margin-right: 2px;
}

.tf-field {
	display: flex;
	align-items: center;
	gap: 2px;
	font: 10px 'IBM Plex Mono', 'JetBrains Mono', monospace;
	color: var(--text-dim);
}

.tf-field input {
	width: 48px;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: 3px;
	color: var(--text-primary);
	font: 10px 'IBM Plex Mono', 'JetBrains Mono', monospace;
	padding: 2px 4px;
	outline: none;
	-moz-appearance: textfield;
}

.tf-field input::-webkit-inner-spin-button,
.tf-field input::-webkit-outer-spin-button { -webkit-appearance: none; }

.tf-field input:focus { border-color: var(--accent-dim); }

/* -- Drop overlay ------------------------------------------- */
#drop-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(26,26,30,0.92);
	z-index: 100;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	gap: 12px;
}

#drop-overlay.visible { display: flex; }

#drop-overlay .drop-icon {
	width: 56px; height: 56px;
	border: 2px dashed var(--accent-dim);
	border-radius: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
}

#drop-overlay .drop-icon svg { width: 24px; height: 24px; color: var(--accent); }
#drop-overlay .drop-icon .tri { font-size: 32px; color: var(--accent); }

#drop-overlay .drop-text {
	font-size: 14px;
	color: var(--text-secondary);
}

/* -- Empty state -------------------------------------------- */
#empty-state {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	color: var(--text-dim);
	font-size: 13px;
	pointer-events: none;
}

#empty-state.hidden { display: none; }

#empty-state svg { width: 40px; height: 40px; opacity: 0.3; }
#empty-state .tri { font-size: 48px; opacity: 0.3; }
#empty-state .hint { font-size: 11px; opacity: 0.6; }

/* -- Hidden file input -------------------------------------- */
#file-input { display: none; }

/* -- Layer selector ----------------------------------------- */
#layer-select {
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: 4px;
	color: var(--text-secondary);
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 11px;
	padding: 4px 6px;
	cursor: pointer;
	outline: none;
}

#layer-select:focus { border-color: var(--accent-dim); }

/* ===================================================================
   TypeRig Widgets (FRWidget) — Reusable UI Gadget Library
   Imported from FRWidgetidgets - for modification and reuse
   =================================================================== */

:root {
	--frw-bg-primary: #1a1a1e;
	--frw-bg-secondary: #222226;
	--frw-bg-tertiary: #2a2a2e;
	--frw-bg-input: #1e1e22;
	--frw-bg-hover: #333338;
	--frw-bg-active: rgba(91,157,239,0.08);
	--frw-border: #3a3a40;
	--frw-border-subtle: #2e2e34;
	--frw-border-focus: #5b9def;
	--frw-text: #e8e8ec;
	--frw-text-secondary: #9898a0;
	--frw-text-dim: #686870;
	--frw-text-placeholder: #55555d;
	--frw-accent: #5b9def;
	--frw-accent-dim: #3a6fb0;
	--frw-accent-hover: #6eadf5;
	--frw-danger: #ff6b6b;
	--frw-success: #50c878;
	--frw-warning: #f59e0b;
	--frw-radius: 4px;
	--frw-radius-lg: 6px;
	--frw-font: 'DM Sans', system-ui, sans-serif;
	--frw-font-mono: 'JetBrains Mono', monospace;
	--frw-font-icon: 'FRWidget Icons', var(--frw-font-mono);
	--frw-transition: 0.12s ease;
	--frw-shadow: 0 4px 16px rgba(0,0,0,0.35);
	--frw-shadow-sm: 0 2px 6px rgba(0,0,0,0.25);
}

/* -- FRW Light Mode --------------------------------------------- */
[data-theme="light"] {
	--frw-bg-primary: #fafafa;
	--frw-bg-secondary: #ffffff;
	--frw-bg-tertiary: #f0f0f0;
	--frw-bg-input: #f5f5f5;
	--frw-bg-hover: #e5e5e5;
	--frw-bg-active: rgba(64,120,242,0.08);
	--frw-border: #d0d0d0;
	--frw-border-subtle: #e5e5e5;
	--frw-border-focus: #4078f2;
	--frw-text: #383a42;
	--frw-text-secondary: #696c77;
	--frw-text-dim: #a0a1a7;
	--frw-text-placeholder: #b0b0b5;
	--frw-accent: #4078f2;
	--frw-accent-dim: #4078f2;
	--frw-accent-hover: #5b8ef5;
	--frw-danger: #e45649;
	--frw-success: #50a14f;
	--frw-warning: #c18401;
	--frw-shadow: 0 4px 16px rgba(0,0,0,0.12);
	--frw-shadow-sm: 0 2px 6px rgba(0,0,0,0.08);
}

.frw { box-sizing: border-box; font-family: var(--frw-font); }
.frw *, .frw *::before, .frw *::after { box-sizing: border-box; }

.frw-label {
	display: inline-block;
	font-size: 11px;
	color: var(--frw-text-secondary);
	line-height: 1.4;
	user-select: none;
	white-space: nowrap;
}

.frw-label.frw-label--heading {
	font-weight: 600;
	font-size: 12px;
	color: var(--frw-text);
	letter-spacing: 0.02em;
}

.frw-label.frw-label--mono {
	font-family: var(--frw-font-mono);
	font-size: 10px;
}

.frw-label.frw-label--dim {
	color: var(--frw-text-dim);
}

.frw-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	padding: 5px 10px;
	min-height: 26px;
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--frw-radius);
	color: var(--frw-text-secondary);
	font-family: var(--frw-font);
	font-size: 11px;
	cursor: pointer;
	transition: all var(--frw-transition);
	white-space: nowrap;
	user-select: none;
	outline: none;
	line-height: 1;
}

.frw-btn:hover {
	background: var(--frw-bg-hover);
	color: var(--frw-text);
	border-color: var(--frw-border);
}

.frw-btn:active {
	background: var(--frw-bg-tertiary);
}

.frw-btn:focus-visible {
	border-color: var(--frw-border-focus);
	box-shadow: 0 0 0 1px var(--frw-accent-dim);
}

.frw-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
	pointer-events: none;
}

.frw-btn--icon {
	padding: 4px;
	min-width: 26px;
	min-height: 26px;
}

.frw-btn--primary {
	background: var(--frw-accent-dim);
	color: var(--frw-text);
	border-color: var(--frw-accent-dim);
}

.frw-btn--primary:hover {
	background: var(--frw-accent);
	border-color: var(--frw-accent);
}

.frw-btn--compact {
	padding: 3px 6px;
	min-height: 22px;
	font-size: 10px;
	font-family: var(--frw-font-mono);
}

.frw-btn .frw-icon {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
}

.frw-toggle.active {
	background: var(--frw-bg-active);
	color: var(--frw-accent);
	border-color: var(--frw-accent-dim);
}

.frw-spinbox {
	display: inline-flex;
	align-items: stretch;
	border: 1px solid var(--frw-border);
	border-radius: var(--frw-radius);
	overflow: hidden;
	height: 26px;
}

.frw-spinbox__input {
	width: 56px;
	padding: 0 6px;
	border: none;
	background: var(--frw-bg-input);
	color: var(--frw-text);
	font-family: var(--frw-font-mono);
	font-size: 11px;
	text-align: center;
	outline: none;
	-moz-appearance: textfield;
}

.frw-spinbox__input::-webkit-inner-spin-button,
.frw-spinbox__input::-webkit-outer-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.frw-spinbox__input:focus {
	background: var(--frw-bg-primary);
}

.frw-spinbox__arrows {
	display: flex;
	flex-direction: column;
	border-left: 1px solid var(--frw-border-subtle);
}

.frw-spinbox__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 14px;
	flex: 1;
	background: var(--frw-bg-tertiary);
	border: none;
	color: var(--frw-text-dim);
	cursor: pointer;
	font-size: 8px;
	user-select: none;
	transition: all var(--frw-transition);
	padding: 0;
	line-height: 1;
}

.frw-spinbox__btn:hover {
	background: var(--frw-bg-hover);
	color: var(--frw-text);
}

.frw-spinbox__btn:active {
	background: var(--frw-accent-dim);
	color: var(--frw-text);
}

.frw-spinbox__btn--dec { border-top: 1px solid var(--frw-border-subtle); }

.frw-spinbox__suffix {
	display: flex;
	align-items: center;
	padding: 0 5px 0 0;
	background: var(--frw-bg-input);
	color: var(--frw-text-dim);
	font-family: var(--frw-font-mono);
	font-size: 10px;
	user-select: none;
}

.frw-spinbox:focus-within {
	border-color: var(--frw-border-focus);
}

.frw-edit {
	display: inline-flex;
	align-items: center;
	height: 26px;
	border: 1px solid var(--frw-border);
	border-radius: var(--frw-radius);
	overflow: hidden;
	transition: border-color var(--frw-transition);
}

.frw-edit:focus-within {
	border-color: var(--frw-border-focus);
}

.frw-edit__input {
	flex: 1;
	min-width: 0;
	padding: 0 8px;
	border: none;
	background: var(--frw-bg-input);
	color: var(--frw-text);
	font-family: var(--frw-font);
	font-size: 11px;
	outline: none;
	height: 100%;
}

.frw-edit__input::placeholder {
	color: var(--frw-text-placeholder);
}

.frw-edit__input.frw-edit__input--mono {
	font-family: var(--frw-font-mono);
}

.frw-combo {
	position: relative;
	display: inline-block;
	min-width: 100px;
}

.frw-combo__select {
	width: 100%;
	height: 26px;
	padding: 0 24px 0 8px;
	background: var(--frw-bg-input);
	border: 1px solid var(--frw-border);
	border-radius: var(--frw-radius);
	color: var(--frw-text);
	font-family: var(--frw-font);
	font-size: 11px;
	cursor: pointer;
	outline: none;
	appearance: none;
	-webkit-appearance: none;
	transition: border-color var(--frw-transition);
}

.frw-combo__select:focus {
	border-color: var(--frw-border-focus);
}

.frw-combo__select:hover {
	background: var(--frw-bg-tertiary);
}

.frw-combo__select option {
	background: var(--frw-bg-secondary);
	color: var(--frw-text);
}

.frw-combo::after {
	content: '';
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 4px solid var(--frw-text-dim);
	pointer-events: none;
}

.frw-list {
	border: 1px solid var(--frw-border);
	border-radius: var(--frw-radius);
	background: var(--frw-bg-input);
	overflow-y: auto;
	max-height: 180px;
	min-height: 60px;
}

.frw-list__item {
	display: flex;
	align-items: center;
	padding: 4px 8px;
	font-size: 11px;
	color: var(--frw-text-secondary);
	cursor: pointer;
	transition: all var(--frw-transition);
	user-select: none;
	border-bottom: 1px solid var(--frw-border-subtle);
}

.frw-list__item:last-child { border-bottom: none; }

.frw-list__item:hover {
	background: var(--frw-bg-hover);
	color: var(--frw-text);
}

.frw-list__item.active {
	background: var(--frw-bg-active);
	color: var(--frw-accent);
}

.frw-list__item--empty {
	color: var(--frw-text-dim);
	font-style: italic;
	cursor: default;
}

.frw-slider-ctrl {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.frw-slider-ctrl__top {
	display: flex;
	align-items: center;
	gap: 4px;
}

.frw-slider-ctrl__label {
	font-size: 11px;
	color: var(--frw-text-secondary);
	white-space: nowrap;
	min-width: 40px;
}

.frw-slider-ctrl__track-row {
	display: flex;
	align-items: center;
	gap: 6px;
}

.frw-slider-ctrl__minmax {
	width: 44px;
	padding: 0 4px;
	height: 20px;
	border: 1px solid var(--frw-border-subtle);
	border-radius: 3px;
	background: var(--frw-bg-input);
	color: var(--frw-text-dim);
	font-family: var(--frw-font-mono);
	font-size: 10px;
	text-align: center;
	outline: none;
	flex-shrink: 0;
}

.frw-slider-ctrl__minmax:focus {
	border-color: var(--frw-border-focus);
	color: var(--frw-text);
}

.frw-slider-ctrl__slider {
	flex: 1;
	-webkit-appearance: none;
	appearance: none;
	height: 4px;
	border-radius: 2px;
	background: var(--frw-border);
	outline: none;
	cursor: pointer;
}

.frw-slider-ctrl__slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--frw-accent);
	border: 2px solid var(--frw-bg-secondary);
	cursor: grab;
	transition: background var(--frw-transition);
}

.frw-slider-ctrl__slider::-webkit-slider-thumb:hover {
	background: var(--frw-accent-hover);
}

.frw-slider-ctrl__slider::-webkit-slider-thumb:active {
	cursor: grabbing;
}

.frw-slider-ctrl__slider::-moz-range-thumb {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--frw-accent);
	border: 2px solid var(--frw-bg-secondary);
	cursor: grab;
}

.frw-tree {
	border: 1px solid var(--frw-border);
	border-radius: var(--frw-radius);
	background: var(--frw-bg-input);
	overflow-y: auto;
	max-height: 240px;
	font-size: 11px;
}

.frw-tree__node {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 3px 8px;
	color: var(--frw-text-secondary);
	cursor: pointer;
	user-select: none;
	transition: background var(--frw-transition);
}

.frw-tree__node:hover { background: var(--frw-bg-hover); }
.frw-tree__node.active { background: var(--frw-bg-active); color: var(--frw-accent); }

.frw-tree__node--child { padding-left: 24px; }
.frw-tree__node--grandchild { padding-left: 40px; }

.frw-tree__toggle {
	display: inline-flex;
	width: 14px;
	height: 14px;
	align-items: center;
	justify-content: center;
	color: var(--frw-text-dim);
	font-size: 9px;
	flex-shrink: 0;
	transition: transform var(--frw-transition);
}

.frw-tree__toggle.expanded { transform: rotate(90deg); }

.frw-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 11px;
	border: 1px solid var(--frw-border);
	border-radius: var(--frw-radius);
	overflow: hidden;
}

.frw-table th {
	background: var(--frw-bg-tertiary);
	color: var(--frw-text-dim);
	font-weight: 500;
	text-align: left;
	padding: 5px 8px;
	border-bottom: 1px solid var(--frw-border);
	user-select: none;
	white-space: nowrap;
}

.frw-table td {
	padding: 4px 8px;
	color: var(--frw-text-secondary);
	border-bottom: 1px solid var(--frw-border-subtle);
}

.frw-table tr:last-child td { border-bottom: none; }

.frw-table tr:hover td {
	background: var(--frw-bg-hover);
	color: var(--frw-text);
}

.frw-table tr.active td {
	background: var(--frw-bg-active);
	color: var(--frw-accent);
}

.frw-spin-button {
	display: inline-flex;
	align-items: stretch;
	gap: 0;
	border: 1px solid var(--frw-border);
	border-radius: var(--frw-radius);
	overflow: hidden;
	height: 26px;
}

.frw-spin-button .frw-spinbox {
	border: none;
	border-radius: 0;
}

.frw-spin-button .frw-spinbox__input {
	width: 48px;
}

.frw-spin-button__action {
	display: flex;
	align-items: center;
	padding: 0 10px;
	background: var(--frw-bg-tertiary);
	border: none;
	border-left: 1px solid var(--frw-border-subtle);
	color: var(--frw-text-secondary);
	font-family: var(--frw-font);
	font-size: 11px;
	cursor: pointer;
	white-space: nowrap;
	transition: all var(--frw-transition);
}

.frw-spin-button__action:hover {
	background: var(--frw-bg-hover);
	color: var(--frw-text);
}

.frw-spin-button:focus-within {
	border-color: var(--frw-border-focus);
}

.frw-ribbon {
	display: flex;
	flex-wrap: wrap;
	gap: 3px;
	padding: 4px;
	background: var(--frw-bg-secondary);
	border: 1px solid var(--frw-border-subtle);
	border-radius: var(--frw-radius-lg);
}

.frw-dialog-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10000;
	opacity: 0;
	transition: opacity 0.15s ease;
	pointer-events: none;
}

.frw-dialog-backdrop.visible {
	opacity: 1;
	pointer-events: auto;
}

.frw-dialog {
	background: var(--frw-bg-secondary);
	border: 1px solid var(--frw-border);
	border-radius: var(--frw-radius-lg);
	box-shadow: var(--frw-shadow);
	min-width: 280px;
	max-width: 480px;
	overflow: hidden;
	transform: translateY(8px);
	transition: transform 0.15s ease;
}

.frw-dialog-backdrop.visible .frw-dialog {
	transform: translateY(0);
}

.frw-dialog__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	background: var(--frw-bg-tertiary);
	border-bottom: 1px solid var(--frw-border);
}

.frw-dialog__title {
	font-size: 12px;
	font-weight: 600;
	color: var(--frw-text);
}

.frw-dialog__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	background: none;
	border: none;
	color: var(--frw-text-dim);
	cursor: pointer;
	border-radius: 3px;
	font-size: 14px;
	line-height: 1;
	transition: all var(--frw-transition);
}

.frw-dialog__close:hover {
	background: var(--frw-bg-hover);
	color: var(--frw-text);
}

.frw-dialog__body {
	padding: 14px;
	font-size: 12px;
	color: var(--frw-text-secondary);
	line-height: 1.5;
}

.frw-dialog__footer {
	display: flex;
	justify-content: flex-end;
	gap: 6px;
	padding: 10px 14px;
	border-top: 1px solid var(--frw-border-subtle);
}

/* -- Movement Preferences dialog --------------------------------- */
.frw-mvp__row {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 8px;
}

.frw-mvp__icon {
	font-size: 14px;
	flex-shrink: 0;
}

.frw-mvp__toggle {
	width: 100%;
	justify-content: flex-start;
}

.frw-mvp__master-table {
	border-top: 1px solid var(--frw-border-subtle);
	padding-top: 8px;
	margin-top: 2px;
}

.frw-mvp__table-hdr,
.frw-mvp__table-row {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 2px 0;
}

.frw-mvp__table-hdr {
	font-size: 10px;
	color: var(--frw-text-dim);
	border-bottom: 1px solid var(--frw-border-subtle);
	padding-bottom: 4px;
	margin-bottom: 2px;
}

.frw-mvp__table-cell--name {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 11px;
}

.frw-mvp__table-cell--val {
	flex: 0 0 72px;
}

.frw-mvp__table-cell--val .frw-spinbox {
	width: 100%;
}

.frw-mvp__table-row--active .frw-mvp__table-cell--name {
	font-weight: 600;
	color: var(--frw-text);
}

.frw-mvp__empty {
	font-size: 11px;
	color: var(--frw-text-dim);
	padding: 8px 0;
	text-align: center;
}

.frw-icon {
	display: inline-block;
	width: 14px;
	height: 14px;
	flex-shrink: 0;
}

.frw-icon svg {
	width: 100%;
	height: 100%;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.frw-icon-font {
	font-family: var(--frw-font-icon);
	font-size: 18px;
	line-height: 1;
	font-style: normal;
	font-weight: normal;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.frw-group {
	display: flex;
	align-items: center;
	gap: 6px;
}

.frw-group--vertical {
	flex-direction: column;
	align-items: stretch;
}

.frw-separator {
	width: 1px;
	height: 20px;
	background: var(--frw-border);
	flex-shrink: 0;
}

.frw-separator--horizontal {
	width: 100%;
	height: 1px;
}

.frw-spacer { flex: 1; }

.frw-section {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 0;
	margin: 8px 0 4px 0;
	border-bottom: 1px solid var(--frw-border-subtle);
}

.frw-section__title {
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--frw-text-dim);
}

/* -- Group Box ---------------------------------------------------- */
.frw-group {
	background: var(--frw-bg-secondary, var(--bg-tertiary));
	border: 1px solid var(--frw-border, var(--border));
	border-radius: var(--frw-radius, 4px);
	overflow: hidden;
	align-items: stretch;
}

.frw-group__label {
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: var(--frw-text-dim, var(--text-tertiary));
	padding: 8px 3px;
	writing-mode: vertical-rl;
	transform: rotate(180deg);
	border-right: 1px solid var(--frw-border, var(--border));
	user-select: none;
}

.frw-group__content {
	display: flex;
	flex-wrap: wrap;
	gap: 2px;
	padding: 4px 6px 6px;
	flex: 1;
}

.frw-row {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 28px;
}

.frw-row > .frw-label {
	min-width: 60px;
}

/* -- Check Table Widget ----------------------------------------- */
.frw-check-table {
	overflow: auto;
	max-height: 400px;
	border: 1px solid var(--frw-border);
	border-radius: var(--frw-radius);
}

.frw-check-table__table {
	width: 100%;
	border-collapse: collapse;
	font-size: 11px;
}

.frw-check-table__table thead {
	position: sticky;
	top: 0;
	z-index: 1;
}

.frw-check-table__table th {
	background: var(--frw-bg-tertiary);
	color: var(--frw-text-dim);
	font-weight: 500;
	text-align: left;
	padding: 5px 8px;
	border-bottom: 1px solid var(--frw-border);
	user-select: none;
	white-space: nowrap;
}

.frw-check-table__th-check {
	width: 28px;
	text-align: center !important;
}

.frw-check-table__table td {
	padding: 3px 8px;
	color: var(--frw-text-secondary);
	border-bottom: 1px solid var(--frw-border-subtle);
}

.frw-check-table__table tr:last-child td {
	border-bottom: none;
}

.frw-check-table__table tbody tr:hover td {
	background: var(--frw-bg-hover);
	color: var(--frw-text);
}

.frw-check-table__td-check {
	width: 28px;
	text-align: center;
}

.frw-check-table__checkbox {
	appearance: none;
	-webkit-appearance: none;
	width: 14px;
	height: 14px;
	border: 1px solid var(--frw-border);
	border-radius: 3px;
	background: var(--frw-bg-input);
	cursor: pointer;
	vertical-align: middle;
	position: relative;
	transition: all var(--frw-transition);
}

.frw-check-table__checkbox:checked {
	background: var(--frw-accent-dim);
	border-color: var(--frw-accent);
}

.frw-check-table__checkbox:checked::after {
	content: '';
	position: absolute;
	left: 3px;
	top: 1px;
	width: 5px;
	height: 8px;
	border: solid var(--frw-text);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.frw-check-table__checkbox:hover {
	border-color: var(--frw-accent);
}

/* -- Layer Select Dialog ---------------------------------------- */
.frw-lsd__body {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.frw-lsd__toolbar {
	display: flex;
	align-items: center;
	gap: 3px;
}

.frw-lsd__type-btn--master {
	color: #50c878 !important;
	border-color: rgba(0,255,0,0.2) !important;
}

.frw-lsd__type-btn--mask {
	color: #ff6b6b !important;
	border-color: rgba(255,0,0,0.2) !important;
}

.frw-lsd__type-btn--service {
	color: #5b9def !important;
	border-color: rgba(0,0,255,0.2) !important;
}

.frw-lsd__search {
	display: flex;
	align-items: center;
	gap: 4px;
}

.frw-lsd__search .tri {
	font-size: 18px;
	color: var(--frw-text-dim);
}

.frw-lsd__search-input {
	flex: 1;
	height: 24px;
	padding: 0 6px;
	background: var(--frw-bg-input);
	border: 1px solid var(--frw-border);
	border-radius: var(--frw-radius);
	color: var(--frw-text);
	font-family: var(--frw-font);
	font-size: 11px;
	outline: none;
	transition: border-color var(--frw-transition);
}

.frw-lsd__search-input:focus {
	border-color: var(--frw-border-focus);
}

.frw-lsd__search-input::placeholder {
	color: var(--frw-text-placeholder);
}

/* -- Field Dialog shared styles --------------------------------- */
.frw-field-dlg__body {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.frw-field-dlg__msg {
	margin: 0;
	font-size: 12px;
	color: var(--frw-text-secondary);
	line-height: 1.4;
}

/* ===================================================================
   Sidebar Framework
   =================================================================== */

/* -- Sidebar container ---------------------------------------------- */
.fr-sidebar {
	display: none;
	flex-direction: row;
	background: var(--bg-secondary);
	overflow: hidden;
	min-width: 0;
	flex-shrink: 0;
}

.fr-sidebar.visible { display: flex; }

.fr-sidebar--left {
	border-right: 1px solid var(--border);
}

.fr-sidebar--right {
	border-left: 1px solid var(--border);
}

/* -- Vertical tab bar ----------------------------------------------- */
/* Tabs sit on the INSIDE edge of each sidebar (closest to canvas).
   Left sidebar:  tabs on right edge  → border-left on tab bar
   Right sidebar: tabs on left edge   → border-right on tab bar */
.fr-sidebar__tabs {
	display: flex;
	flex-direction: column;
	width: 32px;
	min-width: 32px;
	background: var(--bg-tertiary);
	padding: 4px 0;
	gap: 2px;
	flex-shrink: 0;
}

/* Left sidebar: tab bar is on the right (inner) edge */
.fr-sidebar--left .fr-sidebar__tabs {
	border-left: 1px solid var(--border-subtle);
}

/* Right sidebar: tab bar is on the left (inner) edge */
.fr-sidebar--right .fr-sidebar__tabs {
	border-right: 1px solid var(--border-subtle);
}

.fr-sidebar__tab {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0;
	padding: 8px 2px;
	background: none;
	border: none;
	color: var(--text-dim);
	cursor: pointer;
	transition: color 0.12s, background 0.12s;
	position: relative;
}

/* Active indicator: left sidebar uses right border, right sidebar uses left border */
.fr-sidebar--left .fr-sidebar__tab {
	border-right: 2px solid transparent;
}

.fr-sidebar--right .fr-sidebar__tab {
	border-left: 2px solid transparent;
}

.fr-sidebar__tab:hover {
	color: var(--text-secondary);
	background: var(--bg-hover);
}

.fr-sidebar__tab.active {
	color: var(--accent);
	background: var(--bg-secondary);
}

.fr-sidebar--left .fr-sidebar__tab.active {
	border-right-color: var(--accent);
}

.fr-sidebar--right .fr-sidebar__tab.active {
	border-left-color: var(--accent);
}

/* -- Icon-only mode (default) --------------------------------------- */
.fr-sidebar__tab .tri {
	font-size: 16px;
	line-height: 1;
}

/* Hide label by default (icon-only mode) */
.fr-sidebar__tab-label {
	display: none;
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 9px;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	line-height: 1;
	white-space: nowrap;
}

/* -- Text-only mode (activated via data-sidebar-tabs="text") -------- */
/* Applied on <body> or #app via theme.js flag */
[data-sidebar-tabs="text"] .fr-sidebar__tab .tri {
	display: none;
}

[data-sidebar-tabs="text"] .fr-sidebar__tab-label {
	display: block;
	writing-mode: vertical-lr;
	text-orientation: mixed;
	transform: rotate(180deg);
	padding: 4px 0;
}

[data-sidebar-tabs="text"] .fr-sidebar__tabs {
	width: 24px;
	min-width: 24px;
}

/* -- Content area --------------------------------------------------- */
.fr-sidebar__content {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	min-width: 0;
}

/* -- Tab panels ----------------------------------------------------- */
.fr-sidebar__panel {
	display: none;
	flex-direction: column;
	flex: 1;
	overflow: hidden;
}

.fr-sidebar__panel.active {
	display: flex;
}

.fr-sidebar__panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 6px 8px;
	background: var(--bg-secondary);
	border-bottom: 1px solid var(--border-subtle);
}

.fr-sidebar__panel-title {
	font-size: 11px;
	font-weight: 500;
	color: var(--text-secondary);
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.fr-sidebar__panel-content {
	flex: 1;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

/* -- Resize handle -------------------------------------------------- */
.fr-sidebar__handle {
	display: none;
	width: 5px;
	cursor: col-resize;
	background: var(--border);
	position: relative;
	flex-shrink: 0;
	transition: background 0.12s;
	z-index: 5;
}

.fr-sidebar__handle.visible { display: block; }

.fr-sidebar__handle:hover,
.fr-sidebar__handle.dragging {
	background: var(--accent-dim);
}

.fr-sidebar__handle::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 3px;
	height: 32px;
	border-left: 1px solid var(--text-dim);
	border-right: 1px solid var(--text-dim);
	opacity: 0;
	transition: opacity 0.12s;
}

.fr-sidebar__handle:hover::after,
.fr-sidebar__handle.dragging::after { opacity: 0.5; }

/* -- Panel status bar (bottom of tab content) ----------------------- */
.fr-sidebar__statusbar {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 8px;
	background: var(--bg-tertiary);
	border-top: 1px solid var(--border);
	font-size: 10px;
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	color: var(--text-dim);
	white-space: nowrap;
	flex-shrink: 0;
}

.fr-sidebar__statusbar .parse-status {
	font-size: 10px;
	padding: 1px 6px;
	border-radius: 3px;
	margin-left: 6px;
}

.fr-sidebar__statusbar .parse-status.ok {
	color: #50c878;
	background: rgba(80,200,120,0.1);
}

.fr-sidebar__statusbar .parse-status.error {
	color: #ff6b6b;
	background: rgba(255,107,107,0.1);
}

.fr-sidebar__statusbar .py-status {
	font-size: 10px;
	padding: 1px 6px;
	border-radius: 3px;
}

.fr-sidebar__statusbar .py-status--idle { color: var(--text-dim); background: rgba(104,104,112,0.15); }
.fr-sidebar__statusbar .py-status--ready { color: #50c878; background: rgba(80,200,120,0.1); }
.fr-sidebar__statusbar .py-status--error { color: #ff6b6b; background: rgba(255,107,107,0.1); }

/* ===================================================================
   Unified Glyph Widget (list + grid modes)
   =================================================================== */

/* -- Widget header -------------------------------------------------- */
.glyph-widget-header {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px;
	border-bottom: 1px solid var(--border-subtle);
	flex-shrink: 0;
}

.glyph-widget-header input {
	flex: 1;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: 3px;
	color: var(--text-primary);
	font: 11px 'IBM Plex Mono', 'JetBrains Mono', monospace;
	padding: 4px 6px;
	outline: none;
	min-width: 0;
}

.glyph-widget-header input:focus { border-color: var(--accent-dim); }

.glyph-widget-count {
	font: 10px 'IBM Plex Mono', 'JetBrains Mono', monospace;
	color: var(--text-dim);
	white-space: nowrap;
	flex-shrink: 0;
}

.glyph-widget-mode {
	display: flex;
	align-items: center;
	gap: 1px;
	flex-shrink: 0;
}

.glyph-widget-mode button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 20px;
	padding: 0;
	background: transparent;
	border: 1px solid transparent;
	border-radius: 3px;
	color: var(--text-dim);
	cursor: pointer;
	transition: all 0.12s;
}

.glyph-widget-mode button:hover {
	background: var(--bg-hover);
	color: var(--text-secondary);
}

.glyph-widget-mode button.active {
	background: var(--accent-bg);
	color: var(--accent);
	border-color: var(--accent-dim);
}

.glyph-widget-mode button .tri {
	font-size: 14px;
	line-height: 1;
}

/* -- Glyph list container ------------------------------------------- */
.glyph-widget-list {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
}

/* -- List mode entries ---------------------------------------------- */
.glyph-widget-list--list .gw-entry {
	display: flex;
	align-items: center;
	padding: 2px 8px;
	cursor: pointer;
	font: 11px 'IBM Plex Mono', 'JetBrains Mono', monospace;
	color: var(--text-secondary);
	border-left: 2px solid transparent;
	gap: 4px;
}

.glyph-widget-list--list .gw-entry:hover { background: var(--bg-hover); }

.glyph-widget-list--list .gw-entry.active {
	background: var(--accent-bg);
	border-left-color: var(--accent);
	color: var(--text-primary);
}

.glyph-widget-list--list .gw-entry.in-strip {
	border-left-color: var(--accent-dim);
}

.glyph-widget-list--list .gw-thumb {
	width: 28px;
	height: 36px;
	flex-shrink: 0;
	border-radius: 2px;
	background: rgba(255,255,255,0.03);
}

.glyph-widget-list--list .gw-name {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.glyph-widget-list--list .gw-uni {
	font-size: 9px;
	color: var(--text-dim);
	flex-shrink: 0;
}

.glyph-widget-list--list .gw-dirty {
	width: 5px;
	height: 5px;
	border-radius: 50%;
	flex-shrink: 0;
	opacity: 0;
}

.glyph-widget-list--list .gw-entry.dirty .gw-dirty {
	background: var(--accent);
	opacity: 1;
}

/* -- Grid mode entries ---------------------------------------------- */
.glyph-widget-list--grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
	gap: 3px;
	padding: 4px;
	align-content: start;
}

.glyph-widget-list--grid .gw-entry {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 4px 2px;
	cursor: pointer;
	border-radius: 4px;
	border: 1px solid transparent;
	transition: background 0.1s, border-color 0.1s;
}

.glyph-widget-list--grid .gw-entry:hover {
	background: var(--bg-hover);
}

.glyph-widget-list--grid .gw-entry.active {
	background: var(--accent-bg);
	border-color: var(--accent-dim);
}

.glyph-widget-list--grid .gw-entry.in-strip {
	border-color: var(--accent-dim);
}

.glyph-widget-list--grid .gw-thumb {
	width: 48px;
	height: 48px;
	border-radius: 2px;
	background: rgba(255,255,255,0.03);
}

.glyph-widget-list--grid .gw-name {
	font: 9px 'IBM Plex Mono', 'JetBrains Mono', monospace;
	color: var(--text-secondary);
	text-align: center;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 100%;
	margin-top: 2px;
}

.glyph-widget-list--grid .gw-uni { display: none; }

.glyph-widget-list--grid .gw-dirty {
	position: absolute;
	top: 3px;
	right: 3px;
	width: 5px;
	height: 5px;
	border-radius: 50%;
	opacity: 0;
}

.glyph-widget-list--grid .gw-entry {
	position: relative;
}

.glyph-widget-list--grid .gw-entry.dirty .gw-dirty {
	background: var(--accent);
	opacity: 1;
}

/* -- Mark color tinting (both list and grid) ------------------------ */
.gw-entry.gw-marked {
	background-color: var(--mark-color) !important;
}

.glyph-widget-list--list .gw-entry.gw-marked:hover {
	background-color: var(--mark-color) !important;
	filter: brightness(1.2);
}

.glyph-widget-list--list .gw-entry.gw-marked.active {
	background: linear-gradient(var(--mark-color), var(--mark-color)), var(--accent-bg) !important;
}

.glyph-widget-list--grid .gw-entry.gw-marked:hover {
	background-color: var(--mark-color) !important;
	filter: brightness(1.2);
}

.glyph-widget-list--grid .gw-entry.gw-marked.active {
	background: linear-gradient(var(--mark-color), var(--mark-color)), var(--accent-bg) !important;
}

/* ===================================================================
   Font Info Panel (sidebar tab content)
   =================================================================== */
.font-info-panel {
	padding: 12px;
	overflow-y: auto;
	font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
	font-size: 11px;
}

.font-info-title {
	font-family: 'DM Sans', sans-serif;
	font-size: 14px;
	font-weight: 600;
	color: var(--text-primary);
	margin-bottom: 12px;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--border-subtle);
}

.font-info-section {
	margin-bottom: 12px;
}

.font-info-section-label {
	font-size: 9px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--text-dim);
	margin-bottom: 6px;
	font-weight: 600;
}

.font-info-row {
	display: flex;
	justify-content: space-between;
	padding: 3px 0;
	border-bottom: 1px solid var(--border-subtle);
}

.font-info-row .label {
	color: var(--text-dim);
	font-size: 10px;
}

.font-info-row .value {
	color: var(--text-secondary);
	font-size: 10px;
	text-align: right;
}

/* ===================================================================
   Sidebar Config Tab
   =================================================================== */

/* -- Config tab button separator ------------------------------------ */
.fr-sidebar__tab--config {
	margin-bottom: 4px;
	padding-bottom: 10px;
	border-bottom: 1px solid var(--border-subtle);
}

/* -- Config panel layout -------------------------------------------- */
.fr-sidebar__config-panel {
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.fr-config__list {
	flex: 1;
	overflow-y: auto;
	padding: 4px 0;
}

/* -- Widget checkbox row -------------------------------------------- */
.fr-config__item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 10px;
	cursor: pointer;
	font: 11px 'IBM Plex Mono', 'JetBrains Mono', monospace;
	color: var(--text-secondary);
	transition: background 0.1s;
}

.fr-config__item:hover {
	background: var(--bg-hover);
}

.fr-config__checkbox {
	width: 14px;
	height: 14px;
	accent-color: var(--accent);
	cursor: pointer;
	flex-shrink: 0;
}

.fr-config__icon {
	font-size: 14px;
	color: var(--text-dim);
	flex-shrink: 0;
}

.fr-config__label {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* -- Action button bar (bottom of config panel) --------------------- */
.fr-config__actions {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 2px;
	padding: 6px 8px;
	background: var(--bg-tertiary);
	border-top: 1px solid var(--border);
	flex-shrink: 0;
}

.fr-config__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: 6px;
	color: var(--text-secondary);
	cursor: pointer;
	transition: all 0.12s;
}

.fr-config__btn:hover {
	background: var(--bg-hover);
	color: var(--text-primary);
	border-color: var(--accent-dim);
}

.fr-config__btn:active {
	background: var(--accent-bg);
	color: var(--accent);
	border-color: var(--accent-dim);
}

.fr-config__btn .tri {
	font-size: 16px;
	line-height: 1;
}

.fr-config__btn--close {
	margin-left: auto;
}

.fr-config__btn--close:hover {
	background: #c44;
	color: #fff;
	border-color: #c44;
}

/* ================================================================= */
/* Node Panel                                                        */
/* ================================================================= */

.node-panel {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 6px;
	overflow-y: auto;
	height: 100%;
}

/* -- Move grid layout --------------------------------------------- */
.np-move-grid {
	display: grid;
	grid-template-columns: auto 1fr auto auto;
	gap: 2px;
	align-items: center;
	width: 100%;
}

.np-move-grid__label {
	font-size: 14px;
	color: var(--text-tertiary);
	text-align: center;
	width: 28px;
}

/* ================================================================= */
/* Layer Panel                                                       */
/* ================================================================= */

.layer-panel {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 6px;
	overflow: hidden;
	height: 100%;
}

/* -- Header ------------------------------------------------------- */
.lp-header {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 4px 2px;
	min-height: 28px;
	flex-shrink: 0;
}

.lp-header__icon {
	color: var(--text-dim);
	font-size: 16px;
}

.lp-header__name {
	font-family: 'IBM Plex Mono', monospace;
	font-size: 12px;
	font-weight: 500;
	color: var(--text-primary);
}

/* -- Content options row ------------------------------------------ */
.lp-options .frw-group__content {
	gap: 4px;
}

/* -- Bottom groups: stay compact, don't steal from table ---------- */
.layer-panel > .frw-group {
	flex-shrink: 0;
}

.layer-panel > .lp-options {
	flex-shrink: 0;
}

/* -- Layer Table -------------------------------------------------- */
.lp-table {
	border: 1px solid var(--border);
	border-radius: 4px;
	overflow: hidden;
	flex: 1 1 0;
	min-height: 60px;
	display: flex;
	flex-direction: column;
}

.lp-table__header {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 4px 8px;
	background: var(--bg-tertiary);
	border-bottom: 1px solid var(--border);
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: var(--text-dim);
	user-select: none;
}

.lp-table__hcell--compat {
	width: 18px;
	flex-shrink: 0;
	font-size: 12px;
	text-align: center;
}

.lp-table__hcell--name {
	flex: 1;
}

.lp-table__hcell--type {
	width: 24px;
	flex-shrink: 0;
	text-align: center;
}

.lp-table__body {
	overflow-y: auto;
	flex: 1;
}

.lp-table__row {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 3px 8px;
	cursor: pointer;
	user-select: none;
	border-bottom: 1px solid var(--border-subtle);
	transition: background 0.15s;
}

.lp-table__row:last-child {
	border-bottom: none;
}

.lp-table__row:hover {
	background: var(--bg-hover);
}

.lp-table__row.selected {
	background: var(--accent-bg);
	outline: 1px solid var(--accent-dim);
	outline-offset: -1px;
}

/* -- Active layer name -------------------------------------------- */
.lp-table__cell--active {
	font-weight: 600;
}

/* -- Compatibility row background tinting ------------------------- */
.lp-row-compat--compatible {
	background: rgba(80, 200, 120, 0.04);
	border-left: 2px solid rgba(80, 200, 120, 0.35);
}

.lp-row-compat--semi {
	background: rgba(240, 173, 78, 0.04);
	border-left: 2px solid rgba(240, 173, 78, 0.35);
}

.lp-row-compat--incompatible {
	background: rgba(228, 86, 73, 0.04);
	border-left: 2px solid rgba(228, 86, 73, 0.35);
}

.lp-row-compat--compatible:hover { background: rgba(80, 200, 120, 0.08); }
.lp-row-compat--semi:hover { background: rgba(240, 173, 78, 0.08); }
.lp-row-compat--incompatible:hover { background: rgba(228, 86, 73, 0.08); }

/* -- Drag and drop indicators ------------------------------------- */
.lp-dragging {
	opacity: 0.4;
}

.lp-drop-above {
	box-shadow: 0 -2px 0 0 var(--accent) inset;
}

.lp-drop-below {
	box-shadow: 0 2px 0 0 var(--accent) inset;
}

/* -- Active layer triangle indicator ------------------------------ */
.lp-table__active-indicator {
	width: 0;
	height: 0;
	border-top: 5px solid transparent;
	border-bottom: 5px solid transparent;
	border-left: 7px solid #50c878;
	flex-shrink: 0;
	margin: 0 4px 0 2px;
}

.lp-tri--compatible { border-left-color: #50c878; }
.lp-tri--semi       { border-left-color: #f0ad4e; }
.lp-tri--incompatible { border-left-color: #e45649; }

/* -- Compatibility dot -------------------------------------------- */
.lp-table__compat {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
	margin: 0 4px 0 3px;
}

.lp-compat--compatible {
	background: #50c878;
}

.lp-compat--semi {
	background: #f0ad4e;
}

.lp-compat--incompatible {
	background: #e45649;
}

/* -- Name cell ---------------------------------------------------- */
.lp-table__cell--name {
	flex: 1;
	font-family: 'IBM Plex Mono', monospace;
	font-size: 11px;
	color: var(--text-primary);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* -- Type badge --------------------------------------------------- */
.lp-table__badge {
	width: 18px;
	height: 18px;
	border-radius: 3px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
}

.lp-badge--master {
	background: rgba(0, 255, 0, 0.10);
	color: #50c878;
}

.lp-badge--mask {
	background: rgba(255, 0, 0, 0.10);
	color: #e45649;
}

.lp-badge--service {
	background: rgba(0, 0, 255, 0.10);
	color: #5b9def;
}

/* ================================================================= */
/* LERP AXIS UI                                                       */
/* ================================================================= */

/* -- Lerp header row (the lerp. layer itself) ---------------------- */
.lp-lerp-header {
	border-bottom: none;
}

.lp-lerp-icon {
	font-size: 13px;
	color: var(--accent);
	flex-shrink: 0;
	margin-right: 2px;
}

.lp-lerp-remove {
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	font-weight: 700;
	color: var(--text-dim);
	cursor: pointer;
	border-radius: 3px;
	transition: background 0.15s, color 0.15s;
	line-height: 1;
}

.lp-lerp-remove:hover {
	background: rgba(228, 86, 73, 0.15);
	color: #e45649;
}

/* -- Lerp child rows (indented master names) ----------------------- */
.lp-lerp-child {
	padding-left: 20px;
	border-bottom: none;
	cursor: default;
	opacity: 0.75;
}

.lp-lerp-tree {
	font-family: 'IBM Plex Mono', monospace;
	font-size: 12px;
	color: var(--text-dim);
	flex-shrink: 0;
	width: 14px;
	text-align: center;
	line-height: 1;
}

.lp-lerp-child-name {
	font-size: 10px;
	color: var(--text-secondary);
}

/* -- Lerp blend controls ------------------------------------------ */
.lp-lerp-controls {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 2px 8px 6px 20px;
	border-bottom: 1px solid var(--border-subtle);
	background: var(--bg-tertiary);
}

.lp-lerp-slider-row {
	display: flex;
	align-items: center;
	gap: 6px;
}

.lp-lerp-slider-label {
	font-family: 'IBM Plex Mono', monospace;
	font-size: 10px;
	font-weight: 600;
	color: var(--text-dim);
	width: 10px;
	flex-shrink: 0;
	text-align: center;
}

.lp-lerp-slider {
	flex: 1;
	height: 12px;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
}

.lp-lerp-slider::-webkit-slider-runnable-track {
	height: 1px;
	background: var(--border);
	border-radius: 0;
}

.lp-lerp-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--accent);
	border: none;
	margin-top: -4px;
	cursor: pointer;
}

.lp-lerp-slider::-moz-range-track {
	height: 1px;
	background: var(--border);
	border: none;
	border-radius: 0;
}

.lp-lerp-slider::-moz-range-thumb {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--accent);
	border: none;
	cursor: pointer;
}

.lp-lerp-spin {
	width: 42px;
	flex-shrink: 0;
	font-family: 'IBM Plex Mono', monospace;
	font-size: 10px;
	text-align: center;
	border: 1px solid var(--border);
	border-radius: 3px;
	background: var(--bg-primary);
	color: var(--text-primary);
	padding: 1px 2px;
	outline: none;
}

.lp-lerp-spin:focus {
	border-color: var(--accent);
}
