:root {
	--bg: #1e1e1e;
	--bg-2: #252526;
	--bg-3: #2d2d2d;
	--border: #3c3c3c;
	--text: #cccccc;
	--text-dim: #858585;
	--accent: #d4a057;
	--danger: #c54646;
	--ok: #6aab73;
	--user: #2a3340;
	--assistant: #252526;
	--safe-bottom: env(safe-area-inset-bottom, 0px);
	--safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
	font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	background: var(--bg);
	color: var(--text);
	-webkit-tap-highlight-color: transparent;
}

#app {
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 100dvh;
}

.top {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: calc(10px + var(--safe-top)) 14px 10px;
	background: var(--bg-2);
	border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; letter-spacing: 0.02em; }
.status {
	margin-left: auto;
	font-size: 12px;
	padding: 3px 8px;
	border-radius: 999px;
	background: var(--bg-3);
	color: var(--text-dim);
}
.status.online { color: var(--ok); }
.status.offline { color: var(--danger); }
.status.reconnecting { color: var(--accent); }

.icon-btn, .text-btn, button {
	background: var(--bg-3);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 8px 12px;
	font: inherit;
	min-height: 40px;
}
.text-btn { min-height: 32px; padding: 4px 8px; font-size: 13px; }
button:active { opacity: 0.8; }

.drawer {
	position: fixed;
	z-index: 20;
	top: 0;
	left: 0;
	bottom: 0;
	width: min(86vw, 340px);
	background: var(--bg-2);
	border-right: 1px solid var(--border);
	padding: calc(56px + var(--safe-top)) 12px 16px;
	overflow: auto;
}
.drawer section { margin-bottom: 20px; }
.drawer h2 {
	display: inline-block;
	margin: 0 8px 8px 0;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--text-dim);
}
.scrim {
	position: fixed;
	inset: 0;
	z-index: 15;
	background: rgba(0, 0, 0, 0.45);
}

.list { list-style: none; margin: 0; padding: 0; }
.list li {
	padding: 10px 8px;
	border-radius: 6px;
	cursor: pointer;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.list li.active, .list li:active { background: var(--bg-3); }
.tree li { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.tree .dir { color: var(--accent); }

.main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.transcript {
	flex: 1;
	overflow: auto;
	padding: 12px 14px 8px;
	-webkit-overflow-scrolling: touch;
}
.msg {
	margin: 0 0 12px;
	padding: 10px 12px;
	border-radius: 10px;
	background: var(--assistant);
	white-space: pre-wrap;
	word-break: break-word;
}
.msg.user { background: var(--user); }
.msg .kind {
	display: block;
	font-size: 11px;
	color: var(--text-dim);
	margin-bottom: 4px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.msg.tool { border-left: 3px solid var(--accent); }
.msg.patch { border-left: 3px solid var(--ok); }

.approval {
	margin: 0 14px 8px;
	padding: 12px;
	border: 1px solid var(--accent);
	border-radius: 10px;
	background: var(--bg-2);
}
.approval .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.composer {
	display: grid;
	grid-template-columns: auto 1fr auto;
	gap: 8px;
	padding: 10px 12px calc(10px + var(--safe-bottom));
	background: var(--bg-2);
	border-top: 1px solid var(--border);
}
.composer textarea {
	resize: none;
	min-height: 44px;
	max-height: 140px;
	padding: 10px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--text);
	font: inherit;
}
.composer select {
	background: var(--bg);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 0 8px;
}

.file-bar {
	display: flex;
	gap: 8px;
	align-items: center;
	padding: 8px 12px;
	border-bottom: 1px solid var(--border);
	background: var(--bg-2);
}
.file-path {
	flex: 1;
	font-family: ui-monospace, Menlo, monospace;
	font-size: 12px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
#editor {
	flex: 1;
	width: 100%;
	border: 0;
	resize: none;
	padding: 12px;
	background: var(--bg);
	color: var(--text);
	font: 13px/1.5 ui-monospace, Menlo, monospace;
}

.modal {
	position: fixed;
	inset: 0;
	z-index: 40;
	display: grid;
	place-items: center;
	background: rgba(0, 0, 0, 0.55);
	padding: 24px;
}
.modal[hidden], [hidden] { display: none !important; }
.card {
	width: min(420px, 100%);
	background: var(--bg-2);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 22px;
}
.card h1 { margin: 0 0 8px; font-size: 22px; }
.card p { color: var(--text-dim); }
.card input {
	width: 100%;
	margin: 12px 0;
	padding: 12px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--text);
	font: inherit;
}
.error { color: var(--danger); }

@media (min-width: 880px) {
	.icon-btn { display: none; }
	.drawer {
		position: static;
		width: 280px;
		padding: 12px;
		display: block !important;
	}
	#app { flex-direction: row; flex-wrap: wrap; }
	.top { width: 100%; }
	.main { flex: 1; }
	.scrim { display: none !important; }
}
