
.shell {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

.shell-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.85rem 1.25rem;
	border-bottom: 1px solid var(--border);
	background: color-mix(in srgb, var(--panel) 88%, transparent);
	backdrop-filter: blur(7px);
}

[data-theme="dark"] .shell-header {
	background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.brand {
	font-weight: 700;
	letter-spacing: 0.02em;
}

.header-actions {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.shell-body {
	display: grid;
	grid-template-columns: 230px 1fr;
	height: calc(100vh - 57px);
	flex: 1;
}

.shell-nav {
	border-right: 1px solid var(--border);
	padding: 1rem 0.75rem;
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	background: color-mix(in srgb, var(--panel) 65%, transparent);
}

.nav-item {
	padding: 0.65rem 0.75rem;
	border-radius: 10px;
	color: var(--muted);
}

.nav-item:hover {
	background: var(--bg);
	color: var(--ink);
}

.nav-item-active {
	background: var(--brand);
	color: #f7fff7;
}

.nav-section-title {
	margin-top: 0.5rem;
	padding: 0.25rem 0.75rem;
	font-size: var(--font-size-xs);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--muted);
}

.nav-divider {
	height: 1px;
	background: var(--border);
	margin: 0.5rem 0;
}

.shell-content {
	padding: 1.25rem;
	overflow-x: hidden;
	display: flex;
	flex-direction: column;
	min-height: 0;
	height: 100%;
}

.eyebrow {
	margin: 0;
	font-size: var(--font-size-xs);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--muted);
}

.home-page,
.settings-page {
	max-width: 1240px;
}

.home-hero {
	display: flex;
	justify-content: space-between;
	gap: var(--space-4);
	align-items: flex-start;
	padding: var(--space-4);
}

.home-hero-actions {
	display: flex;
	gap: var(--space-2);
	flex-wrap: wrap;
}

.home-summary-grid,
.home-project-grid,
.home-session-grid {
	display: grid;
	gap: var(--space-4);
}

.home-summary-grid {
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.home-summary-card {
	padding: var(--space-4);
}

.home-project-grid,
.home-session-grid {
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.home-section {
	padding: var(--space-4);
}

.home-section h2,
.settings-header h1,
.settings-panel h2 {
	margin: 0;
}

.home-section h3,
.home-section p {
	margin: 0;
}

@media (max-width: 767px) {
	.home-hero,
	.home-summary-card,
	.home-section {
		padding: var(--space-3);
	}
}

.row-tight {
	gap: var(--space-2);
}

.settings-tabs {
	display: flex;
	gap: var(--space-2);
	flex-wrap: wrap;
}

.settings-tab {
	padding: 0.6rem 0.9rem;
	border-radius: 999px;
	border: 1px solid var(--border);
	color: var(--muted);
	background: var(--panel);
}

.settings-tab.active {
	background: var(--brand);
	color: white;
	border-color: transparent;
}

.settings-panel {
	padding: 1.5rem;
}

.settings-actions,
.form-actions {
	display: flex;
	gap: var(--space-3);
	align-items: center;
	flex-wrap: wrap;
}

.error-text {
	color: var(--danger);
}

.success-text {
	color: var(--success);
}

.small {
	padding: 0.42rem 0.7rem;
	min-height: 38px;
}

.session-card,
.project-card,
.recent-session-item {
	box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

/* Responsive Shell */
@media (max-width: 767px) {
	.shell-body {
		grid-template-columns: 1fr;
		grid-template-rows: auto 1fr;
	}

	.shell-nav {
		flex-direction: row;
		flex-wrap: wrap;
		gap: 0.25rem;
		padding: 0.5rem;
		border-right: none;
		border-bottom: 1px solid var(--border);
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.nav-item {
		padding: 0.5rem 0.75rem;
		white-space: nowrap;
		font-size: var(--font-size-sm);
	}

	.shell-content {
		padding: var(--space-4);
		height: 100%;
	}
}

.stack {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.muted {
	color: var(--muted);
}

.card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
	gap: var(--space-4);
}

@media (min-width: 768px) {
	.card-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 1024px) {
	.card-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.card {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
}

.card-sm {
	padding: var(--space-3);
}

.card-md {
	padding: var(--space-4);
}

.card-lg {
	padding: var(--space-5);
}

.card-elevated {
	box-shadow: var(--shadow-sm);
}

.card-borderless {
	border-color: transparent;
}

.card-label {
	margin: 0;
	color: var(--muted);
}

.card-value {
	margin: 0.45rem 0 0;
	font-size: 1.6rem;
	font-weight: 700;
}

.quick-actions {
	display: flex;
	gap: 0.6rem;
}

.primary-button,
.secondary-button,
.ghost-button {
	border-radius: 10px;
	border: 1px solid transparent;
	padding: 0.58rem 0.85rem;
	cursor: pointer;
	font: inherit;
}

.primary-button {
	background: var(--brand);
	color: white;
}

.primary-button:hover {
	background: var(--brand-strong);
}

.secondary-button {
	border-color: var(--border);
	background: var(--panel);
}

.ghost-button {
	border-color: var(--border);
	background: transparent;
}

.user-chip {
	border: 1px solid var(--border);
	background: var(--panel);
	border-radius: 999px;
	padding: 0.35rem 0.7rem;
	font-size: 0.9rem;
}

.center-screen {
	min-height: 55vh;
	display: grid;
	place-content: center;
	text-align: center;
}

.page-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
	gap: var(--space-3);
}

@media (max-width: 767px) {
	.page-header {
		flex-direction: column;
		align-items: flex-start;
	}
}

.project-list {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.project-card {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0;
	padding: var(--space-4);
}

.project-info h3 {
	margin: 0 0 0.35rem;
}

.project-info p {
	margin: 0;
}

.project-actions {
	display: flex;
	gap: 0.5rem;
	align-items: center;
	flex-shrink: 0;
}

.delete-confirm {
	display: flex;
	gap: 0.5rem;
	align-items: center;
}

.danger-button {
	border-radius: 10px;
	border: 1px solid transparent;
	padding: 0.58rem 0.85rem;
	cursor: pointer;
	font: inherit;
	background: #b91c1c;
	color: white;
}

.danger-text {
	color: #b91c1c;
}

.error-text {
	color: #b91c1c;
	margin: 0;
}

/* ─── Dialog / Modal System ───
 * .dialog-* is the canonical implementation.
 * .modal-overlay and .modal-content are deprecated aliases kept for backward compatibility.
 */
.dialog-overlay {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--space-4);
	background: rgba(0, 0, 0, 0.45);
	backdrop-filter: blur(2px);
}

.modal-overlay {
	/* deprecated alias */
	position: fixed;
	inset: 0;
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--space-4);
	background: rgba(0, 0, 0, 0.45);
	backdrop-filter: blur(2px);
}

.dialog,
.modal-content,
.commit-dialog {
	width: 100%;
	max-width: 32rem;
	max-height: calc(100vh - var(--space-8));
	max-height: calc(100dvh - var(--space-8));
	display: flex;
	flex-direction: column;
	min-height: 0;
	overflow: hidden;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-xl);
}

.modal-content {
	/* deprecated alias */
}

.dialog-lg {
	max-width: 48rem;
}

.dialog-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
	padding: var(--space-4);
	border-bottom: 1px solid var(--border);
}

.dialog-header h2,
.dialog-header h3 {
	margin: 0;
	font-size: var(--font-size-lg);
	line-height: var(--line-height-tight);
}

.dialog-body,
.modal-body {
	flex: 1;
	min-height: 0;
	overflow: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: var(--space-4);
}

.dialog-footer,
.dialog-actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: var(--space-3);
	padding: var(--space-4);
	border-top: 1px solid var(--border);
}

.dialog-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--touch-target);
	height: var(--touch-target);
	padding: 0;
	background: transparent;
	border: none;
	border-radius: var(--radius-md);
	color: var(--muted);
	cursor: pointer;
}

.dialog-close:hover {
	background: var(--bg);
	color: var(--ink);
}

@media (max-width: 767px) {
	.dialog-overlay,
	.modal-overlay {
		align-items: flex-end;
		padding: 0;
	}

	.dialog,
	.modal-content,
	.commit-dialog {
		max-width: 100%;
		max-height: calc(100vh - var(--space-6));
		max-height: calc(100dvh - var(--space-6));
		border-radius: var(--radius-lg) var(--radius-lg) 0 0;
	}
}

.dialog h2 {
	margin: 0 0 1rem;
}

.form-field,
.form-group {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	margin-bottom: var(--space-4);
}

.form-field:last-child,
.form-group:last-child {
	margin-bottom: 0;
}

.form-field input,
.form-field textarea,
.form-field select,
.form-group input,
.form-group textarea,
.form-group select {
	padding: var(--space-2) var(--space-3);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	font: inherit;
	background: var(--panel);
	color: var(--ink);
	width: 100%;
}

.form-row {
	display: flex;
	align-items: flex-start;
	gap: var(--space-3);
}

.form-row .form-field,
.form-row .form-group {
	flex: 1;
	margin-bottom: 0;
}

/* Shared config section — used by Tool Workshop and Config Profiles */
.config-section {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	padding: var(--space-4);
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
}

.config-section-title {
	margin: 0 0 var(--space-1);
	font-size: var(--font-size-base);
	font-weight: 600;
	line-height: var(--line-height-tight);
	color: var(--ink);
}

.config-section-subtitle {
	margin: calc(var(--space-1) * -1) 0 var(--space-2);
	font-size: var(--font-size-sm);
	color: var(--muted);
	line-height: var(--line-height-normal);
}

.config-section > .config-section-title + .config-section-subtitle {
	margin-top: calc(var(--space-2) * -1);
}

.config-section-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--space-3);
	margin-bottom: var(--space-2);
}

.config-section-header .config-section-title {
	margin-bottom: 0;
}

.config-section-actions {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: var(--space-3);
	margin-top: var(--space-2);
	padding: var(--space-3) var(--space-4);
	border-top: 1px solid var(--border);
	background: var(--panel);
	position: sticky;
	bottom: 0;
	z-index: 10;
}

/* Legacy alias for existing consumers */
.form-section {
	padding: var(--space-4);
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
}

.form-section > h4:first-child,
.form-section > h3:first-child {
	margin-top: 0;
	margin-bottom: var(--space-3);
}

.form-help {
	display: block;
	font-size: var(--font-size-sm);
	color: var(--muted);
	margin-top: var(--space-1);
	line-height: var(--line-height-normal);
}

.text-error {
	color: var(--danger);
	font-size: var(--font-size-sm);
	line-height: var(--line-height-normal);
}

.keys-list {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.key-card {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 1rem;
}

.key-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 0.5rem;
}

.key-header h3 {
	margin: 0;
}

.key-meta {
	margin-bottom: 0.75rem;
}

.key-public {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.5rem;
	background: #f5f3ee;
	border-radius: 8px;
}

.key-public code {
	font-size: 0.85rem;
	word-break: break-all;
	flex: 1;
}

.error {
	color: #b91c1c;
	padding: 0.75rem;
	background: #fef2f2;
	border-radius: 10px;
}

/* The 860px breakpoint is deprecated; mobile layout is handled at 767px above. */
@media (max-width: 767px) {
	.card-grid {
		grid-template-columns: 1fr;
	}

	.quick-actions {
		flex-direction: column;
	}

	.project-card {
		flex-direction: column;
	}
}

/* URL Validation Styles */
.valid-url {
	border-color: var(--success, #16a34a) !important;
	background-color: var(--success-light, #f0fdf4) !important;
}

.needs-parsing-url {
	border-color: var(--warning, #ca8a04) !important;
	background-color: var(--warning-light, #fefce8) !important;
}

.invalid-url {
	border-color: var(--danger, #dc2626) !important;
	background-color: var(--danger-light, #fef2f2) !important;
}

.validation-status {
	font-size: 0.85rem;
	margin-top: 0.25rem;
	display: block;
}

.validation-status.valid {
	color: var(--success, #16a34a);
}

.validation-status.warning {
	color: var(--warning, #ca8a04);
}

.validation-status.invalid {
	color: #dc2626;
}

.validation-status.validating {
	color: var(--muted);
}

.url-suggestion {
	margin-top: 0.5rem;
	padding: 0.5rem;
	background: #fefce8;
	border-radius: 8px;
	border: 1px solid #fde047;
}

.suggestion-actions {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-top: 0.35rem;
}

.suggested-url {
	font-size: 0.85rem;
	color: #854d0e;
	flex: 1;
	word-break: break-all;
}

.secondary-button.small {
	padding: 0.35rem 0.6rem;
	font-size: 0.85rem;
}

/* Merge Dialog */
.merge-form {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.merge-form .form-field {
	display: flex;
	flex-direction: column;
	gap: 0.375rem;
}

.merge-form label {
	font-size: 0.875rem;
	font-weight: 500;
}

.merge-form select,
.merge-form input,
.merge-form textarea {
	padding: 0.5rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: var(--bg);
	color: var(--ink);
	font-family: inherit;
	font-size: 0.875rem;
}

.merge-form textarea {
	resize: vertical;
}

.input-disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.success-text {
	color: #10b981;
	font-size: 0.875rem;
	padding: 0.5rem;
	background: rgba(16, 185, 129, 0.1);
	border-radius: 4px;
}

/* Settings Layout */
.settings-layout {
	display: flex;
	gap: 2rem;
	padding: 1.5rem 0;
}

.settings-sidebar {
	width: 200px;
	flex-shrink: 0;
}

.settings-nav {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.settings-nav-link {
	padding: 0.625rem 1rem;
	border-radius: 8px;
	color: var(--muted);
	text-decoration: none;
	font-size: 0.95rem;
	transition: all 0.2s;
}

.settings-nav-link:hover {
	background: var(--bg);
	color: var(--ink);
}

.settings-nav-link.active {
	background: var(--brand);
	color: white;
	font-weight: 500;
}

.settings-content {
	flex: 1;
	min-width: 0;
}

.settings-panel {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 1.5rem;
}

/* Mobile responsiveness */
@media (max-width: 767px) {
	.settings-layout {
		flex-direction: column;
		gap: 1rem;
	}

	.settings-sidebar {
		width: 100%;
	}

	.settings-nav {
		flex-direction: row;
		overflow-x: auto;
		padding-bottom: 0.5rem;
	}

	.settings-nav-link {
		white-space: nowrap;
		padding: 0.5rem 0.75rem;
		font-size: 0.875rem;
	}

	.workspace-header {
		flex-direction: column;
		gap: 1rem;
		align-items: flex-start;
	}

	.workspace-header-actions {
		width: 100%;
		justify-content: flex-start;
	}
}

.settings-panel h2 {
	margin: 0 0 1.25rem;
	font-size: 1.25rem;
}

.settings-breadcrumb {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.9rem;
	color: var(--muted);
	margin-bottom: 1rem;
}

.settings-breadcrumb a {
	color: var(--brand);
	text-decoration: none;
}

.settings-breadcrumb a:hover {
	text-decoration: underline;
}

.project-settings-page {
	padding: 1.5rem;
}

/* Repositories Settings Tab */
.repositories-settings-tab h2 {
	margin: 0 0 1.25rem;
	font-size: 1.25rem;
}

.repositories-list {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.repository-card {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 1rem;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 10px;
}

.repository-info h3 {
	margin: 0 0 0.25rem;
	font-size: 1rem;
}

.repository-info p {
	margin: 0 0 0.5rem;
	font-size: 0.85rem;
	color: var(--muted);
}

.repo-type {
	font-size: 0.75rem;
	padding: 0.2rem 0.5rem;
	background: var(--brand);
	color: white;
	border-radius: 999px;
}

/* Commit Dialog */
.commit-dialog {
	width: 100%;
	max-width: 600px;
}

.file-info {
	margin: 0 0 1rem;
	color: var(--muted);
}

.diff-preview {
	margin-bottom: 1.5rem;
}

.diff-preview h4 {
	margin: 0 0 0.75rem;
	font-size: 0.9rem;
	color: var(--muted);
}

.diff-content {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	overflow: auto;
	max-height: 300px;
	font-family: "Fira Code", "Monaco", "Courier New", monospace;
	font-size: 13px;
}

.diff-line {
	display: flex;
	padding: 0.15rem 0.5rem;
	gap: 0.5rem;
}

.diff-line-number {
	color: var(--muted);
	min-width: 2rem;
	text-align: right;
	user-select: none;
}

.diff-marker {
	width: 1rem;
	text-align: center;
	font-weight: bold;
}

.diff-added {
	background: rgba(16, 185, 129, 0.1);
}

.diff-added .diff-marker {
	color: #059669;
}

.diff-removed {
	background: rgba(239, 68, 68, 0.1);
}

.diff-removed .diff-marker {
	color: #dc2626;
}

.diff-same {
	background: transparent;
}

.warning-message {
	padding: 0.75rem;
	background: rgba(245, 158, 11, 0.1);
	color: #d97706;
	border-radius: 8px;
	margin-bottom: 1rem;
}

/* Icon System */
.icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	vertical-align: middle;
}

.icon svg {
	display: block;
}

.icon-sm {
	width: 16px;
	height: 16px;
}

.icon-md {
	width: 20px;
	height: 20px;
}

.icon-lg {
	width: 24px;
	height: 24px;
}

.icon-xl {
	width: 32px;
	height: 32px;
}

/* Button icons */
button .icon,
a .icon {
	margin-right: 0.35rem;
}

button .icon:last-child,
a .icon:last-child {
	margin-right: 0;
}

/* Navigation icons */
.nav-item .icon {
	margin-right: 0.5rem;
}

/* Status badge icons */
.status-badge .icon {
	margin-right: 0.25rem;
}

/* ─── Tool Starter ─── */
.tool-starter {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
}

.tool-starter-context {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: var(--space-3);
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

.context-row {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	flex-wrap: wrap;
}

.context-label {
	font-size: var(--font-size-sm);
	color: var(--muted);
	min-width: 80px;
}

.context-value {
	font-weight: 500;
}

.ssh-key-status {
	padding: var(--space-2);
	background: var(--bg);
	border-radius: 8px;
}

.ssh-key-status .success-text,
.ssh-key-status .warning-text {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	font-size: var(--font-size-sm);
}

/* ─── Instance Chips ─── */
.instance-chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2);
	margin-top: var(--space-2);
}

.instance-chip {
	display: inline-flex;
	align-items: center;
	gap: var(--space-1);
	padding: 0.2rem 0.5rem;
	border-radius: 999px;
	font-size: var(--font-size-sm);
	background: var(--bg);
	border: 1px solid var(--border);
}

.instance-chip.running {
	background: var(--success-light);
	border-color: var(--success);
	color: var(--success);
}

.instance-chip.starting,
.instance-chip.building,
.instance-chip.probing {
	background: var(--warning-light);
	border-color: var(--warning);
	color: var(--warning);
}

.instance-chip.error,
.instance-chip.unhealthy,
.instance-chip.stopped {
	background: var(--danger-light);
	border-color: var(--danger);
	color: var(--danger);
}

.instance-chip a {
	font-size: 0.75rem;
	opacity: 0.7;
}

.instance-chip a:hover {
	opacity: 1;
}

/* ─── Tool Starter Header ─── */
.tool-starter-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: var(--space-3);
	padding-bottom: var(--space-2);
	border-bottom: 1px solid var(--border);
}

.tool-starter-header h4 {
	margin: 0;
}

/* ─── Floating Action Button ─── */
.start-tool-fab {
	position: fixed;
	bottom: 2rem;
	right: 2rem;
	z-index: 100;
	width: 3.5rem;
	height: 3.5rem;
	border-radius: 50%;
	background: var(--primary);
	color: var(--primary-fg);
	border: none;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition:
		transform 0.15s ease,
		box-shadow 0.15s ease;
}

.start-tool-fab:hover {
	transform: scale(1.08);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.start-tool-fab:active {
	transform: scale(0.95);
}

.start-tool-modal {
	max-width: 480px;
	width: 90vw;
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: var(--space-3);
}

.modal-header h3 {
	margin: 0;
}

@media (max-width: 640px) {
	.start-tool-fab {
		bottom: calc(var(--mobile-nav-height) + var(--space-3));
		right: var(--space-4);
		width: 3rem;
		height: 3rem;
	}
}
/* ─── Primitive Buttons ─── */
.btn,
.primary-button,
.secondary-button,
.ghost-button,
.button-secondary {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	min-height: var(--touch-target);
	padding: var(--space-2) var(--space-4);
	border: 1px solid transparent;
	border-radius: var(--radius-md);
	font-size: var(--font-size-sm);
	font-weight: 500;
	line-height: var(--line-height-tight);
	background: var(--panel);
	color: var(--ink);
	cursor: pointer;
	font-family: inherit;
	transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.ghost-button:focus-visible,
.button-secondary:focus-visible {
	outline: 2px solid var(--brand);
	outline-offset: 2px;
}

.btn-primary,
.primary-button {
	background: var(--brand);
	color: var(--primary-fg);
	border-color: var(--brand);
}

.btn-primary:hover,
.primary-button:hover {
	background: var(--brand-strong);
	border-color: var(--brand-strong);
}

.btn-secondary,
.secondary-button,
.ghost-button,
.button-secondary {
	background: var(--panel);
	color: var(--ink);
	border-color: var(--border);
}

.btn-secondary:hover,
.secondary-button:hover,
.ghost-button:hover,
.button-secondary:hover {
	background: var(--bg);
}

.btn-danger {
	background: var(--danger);
	color: white;
	border-color: var(--danger);
}

.btn-danger:hover {
	background: color-mix(in srgb, var(--danger) 85%, black);
	border-color: color-mix(in srgb, var(--danger) 85%, black);
}

.btn-sm {
	min-height: calc(var(--touch-target) - 8px);
	padding: var(--space-1) var(--space-3);
	font-size: var(--font-size-xs);
}

.btn-icon {
	padding: var(--space-2);
	min-width: var(--touch-target);
	min-height: var(--touch-target);
}

.btn:disabled,
.btn[aria-disabled="true"] {
	opacity: 0.55;
	cursor: not-allowed;
}

/* ─── Link Button ─── */
.link-button {
	display: inline-flex;
	align-items: center;
	gap: var(--space-1);
	padding: 0;
	background: transparent;
	border: none;
	color: var(--brand);
	font-size: inherit;
	font-weight: 500;
	cursor: pointer;
	text-decoration: none;
}

.link-button:hover {
	text-decoration: underline;
}

.link-button:focus-visible {
	outline: 2px solid var(--brand);
	outline-offset: 2px;
	border-radius: var(--radius-sm);
}

/* ─── Form Inputs ─── */
.form-input,
.form-textarea {
	width: 100%;
	min-height: var(--touch-target);
	padding: var(--space-2) var(--space-3);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	background: var(--panel);
	color: var(--ink);
	font-size: var(--font-size-base);
	line-height: var(--line-height-normal);
	font-family: inherit;
}

.form-input:focus,
.form-textarea:focus {
	outline: none;
	border-color: var(--brand);
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 20%, transparent);
}

.form-input::placeholder,
.form-textarea::placeholder {
	color: var(--muted);
}

.form-textarea {
	min-height: 6rem;
	resize: vertical;
}

/* ─── Checkbox Label ─── */
.checkbox-label {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	min-height: var(--touch-target);
	font-size: var(--font-size-sm);
	color: var(--ink);
	cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
	width: 1.125rem;
	height: 1.125rem;
	accent-color: var(--brand);
}

.checkbox-label-compact {
	min-height: auto;
	font-size: var(--font-size-xs);
}

/* ─── Hint ─── */
.hint {
	font-size: var(--font-size-sm);
	color: var(--muted);
	line-height: var(--line-height-normal);
}

/* ─── Error Message ─── */
.form-error,
.error-message {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	padding: var(--space-2) var(--space-3);
	border-radius: var(--radius-md);
	background: var(--danger-light);
	color: var(--danger);
	font-size: var(--font-size-sm);
	line-height: var(--line-height-normal);
}

/* ─── Alert Banners ─── */
.alert {
	display: flex;
	align-items: flex-start;
	gap: var(--space-3);
	padding: var(--space-3) var(--space-4);
	border-radius: var(--radius-md);
	border: 1px solid var(--border);
	background: var(--panel);
	color: var(--ink);
	font-size: var(--font-size-sm);
	line-height: var(--line-height-normal);
}

.alert-error {
	background: var(--danger-light);
	border-color: color-mix(in srgb, var(--danger) 30%, transparent);
	color: var(--danger);
}

.alert-warning {
	background: var(--warning-light);
	border-color: color-mix(in srgb, var(--warning) 30%, transparent);
	color: var(--warning);
}

.alert-info {
	background: var(--info-light);
	border-color: color-mix(in srgb, var(--info) 30%, transparent);
	color: var(--info);
}

.alert-success {
	background: var(--success-light);
	border-color: color-mix(in srgb, var(--success) 30%, transparent);
	color: var(--success);
}

/* ─── Loading State ─── */
.loading-state {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	padding: var(--space-4);
	color: var(--muted);
	font-size: var(--font-size-sm);
}

/* ─── Badges ─── */
.badge {
	display: inline-flex;
	align-items: center;
	gap: var(--space-1);
	padding: var(--space-1) var(--space-2);
	border-radius: var(--radius-full);
	font-size: var(--font-size-xs);
	font-weight: 600;
	line-height: var(--line-height-tight);
	background: var(--bg);
	color: var(--muted);
	border: 1px solid var(--border);
}

.badge-success {
	background: var(--success-light);
	color: var(--success);
	border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.badge-secondary {
	background: var(--info-light);
	color: var(--info);
	border-color: color-mix(in srgb, var(--info) 30%, transparent);
}

/* ─── Text Utilities ─── */
.text-muted {
	color: var(--muted);
}

/* ─── Status Badges ─── */
.status-badge {
	display: inline-flex;
	align-items: center;
	gap: var(--space-1);
	padding: var(--space-1) var(--space-2);
	border-radius: var(--radius-full);
	font-size: var(--font-size-xs);
	font-weight: 600;
	text-transform: capitalize;
	line-height: var(--line-height-tight);
	background: var(--bg);
	color: var(--muted);
	border: 1px solid var(--border);
}

.status-badge::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
}

.status-badge--running,
.status-badge--success {
	background: var(--success-light);
	color: var(--success);
	border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.status-badge--error,
.status-badge--failed {
	background: var(--danger-light);
	color: var(--danger);
	border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.status-badge--warning {
	background: var(--warning-light);
	color: var(--warning);
	border-color: color-mix(in srgb, var(--warning) 30%, transparent);
}

.status-badge--info,
.status-badge--pending,
.status-badge--idle {
	background: var(--info-light);
	color: var(--info);
	border-color: color-mix(in srgb, var(--info) 30%, transparent);
}

/* Legacy instance-chip alias */
.instance-chip {
	display: inline-flex;
	align-items: center;
	gap: var(--space-1);
	padding: var(--space-1) var(--space-2);
	border-radius: var(--radius-full);
	font-size: var(--font-size-xs);
	font-weight: 600;
	text-transform: capitalize;
	line-height: var(--line-height-tight);
	background: var(--bg);
	color: var(--muted);
	border: 1px solid var(--border);
}

.instance-chip::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
}

.instance-chip.running {
	background: var(--success-light);
	color: var(--success);
	border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.instance-chip.starting,
.instance-chip.building,
.instance-chip.probing {
	background: var(--warning-light);
	color: var(--warning);
	border-color: color-mix(in srgb, var(--warning) 30%, transparent);
}

.instance-chip.error,
.instance-chip.unhealthy,
.instance-chip.stopped {
	background: var(--danger-light);
	color: var(--danger);
	border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

/* ─── Focus States ─── */
.nav-item:focus-visible,
.mobile-nav-item:focus-visible,
.tab:focus-visible,
.tree-entry:focus-visible,
.btn:focus-visible,
.form-input:focus-visible,
.form-textarea:focus-visible,
.link-button:focus-visible,
.checkbox-label input:focus-visible {
	outline: 2px solid var(--brand);
	outline-offset: 2px;
}

/* ─── Profile Avatar Section ─── */
.profile-avatar-section {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-3);
	padding: var(--space-4);
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
}

.avatar-preview,
.avatar-placeholder {
	width: 6rem;
	height: 6rem;
	border-radius: var(--radius-full);
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--bg);
	border: 2px solid var(--border);
}

.avatar-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.avatar-placeholder {
	font-size: var(--font-size-2xl);
	font-weight: 600;
	color: var(--muted);
}

/* ─── Mobile Back Button (detail views) ─── */
.mobile-detail-back {
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--touch-target);
	height: var(--touch-target);
	padding: 0;
	background: transparent;
	border: none;
	color: var(--ink);
	cursor: pointer;
	border-radius: var(--radius-md);
}

.mobile-detail-back:hover {
	background: var(--bg);
}

.mobile-detail-back:focus-visible {
	outline: 2px solid var(--brand);
	outline-offset: 2px;
}

/* Legacy text-error alias used in manifest editor and tool type editor */
.text-error {
	color: var(--danger);
	font-size: var(--font-size-sm);
}

/* Legacy button-secondary alias used in manifest editor and config profile editor */
.button-secondary {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	min-height: var(--touch-target);
	padding: var(--space-2) var(--space-4);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	font-size: var(--font-size-sm);
	font-weight: 500;
	line-height: var(--line-height-tight);
	background: var(--panel);
	color: var(--ink);
	cursor: pointer;
	font-family: inherit;
	transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.button-secondary:hover {
	background: var(--bg);
}

.button-secondary:focus-visible {
	outline: 2px solid var(--brand);
	outline-offset: 2px;
}
