
.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: #ece7df;
	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;
}

.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-project-grid,
.home-session-grid {
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

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

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

.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: 14px;
	padding: 1rem;
}

.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;
	justify-content: space-between;
	align-items: flex-start;
	gap: 1rem;
}

.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-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.35);
	display: grid;
	place-content: center;
	z-index: 50;
}

.dialog {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: var(--space-5);
	width: min(560px, 100vw - 2rem);
	max-height: min(800px, 100vh - 2rem);
	overflow-y: auto;
}

.dialog-lg {
	width: min(800px, 100vw - 2rem);
}

@media (max-width: 767px) {
	.dialog {
		width: 100vw;
		height: 100vh;
		max-height: 100vh;
		border-radius: 0;
		padding: var(--space-4);
	}

	.dialog-overlay {
		padding: 0;
	}
}

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

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

.form-field input,
.form-field textarea,
.form-field select {
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--border);
	border-radius: 10px;
	font: inherit;
	background: var(--panel);
	color: var(--ink);
}

.dialog-actions {
	display: flex;
	justify-content: flex-end;
	gap: 0.6rem;
}

.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;
}

.form-group {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.form-group input {
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--border);
	border-radius: 10px;
	font: inherit;
}

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

@media (max-width: 860px) {
	.shell-body {
		grid-template-columns: 1fr;
	}

	.shell-nav {
		flex-direction: row;
		overflow-x: auto;
		border-right: 0;
		border-bottom: 1px solid var(--border);
	}

	.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;
}

/* Modal Styles */
.modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
}

.modal-content {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 1.5rem;
	min-width: 400px;
	max-width: 600px;
	max-height: 80vh;
	overflow: auto;
}

.modal-content h2 {
	margin: 0 0 1rem 0;
	font-size: 1.25rem;
}

.modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 0.75rem;
	margin-top: 1.5rem;
}

/* 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: 768px) {
	.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 */
.dialog-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	padding: 1rem;
}

.commit-dialog {
	background: var(--panel);
	border-radius: 14px;
	width: 100%;
	max-width: 600px;
	max-height: 90vh;
	overflow: auto;
	box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

.dialog-header h3 {
	margin: 0;
	font-size: 1.1rem;
}

.dialog-close {
	background: none;
	border: none;
	font-size: 1.5rem;
	cursor: pointer;
	color: var(--muted);
	padding: 0;
	width: 2rem;
	height: 2rem;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 6px;
}

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

.dialog-body {
	padding: 1.5rem;
}

.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;
}

.dialog-footer {
	display: flex;
	justify-content: flex-end;
	gap: 0.75rem;
	padding: 1rem 1.5rem;
	border-top: 1px solid var(--border);
}

/* 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: 5rem; /* above mobile tab bar */
		right: 1rem;
		width: 3rem;
		height: 3rem;
	}
}
