:root {
	--bg: #F5F6F7;
	--panel: #FFFFFF;
	--ink: #111214;
	--muted: #5F6368;
	--line: #E2E4E8;
	--accent: #2457FF;
	--accent-soft: #EAF0FF;
	--warm: #FF5A1F;
	--ok: #0E7C66;
	--bad: #C62828;
	--add: #E7F6EF;
	--del: #FDECEC;
	--code: #F1F2F4;
	color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0D0E10;
		--panel: #16181B;
		--ink: #F5F6F7;
		--muted: #A8ADB5;
		--line: #2A2D32;
		--accent: #5B82FF;
		--accent-soft: #1B2547;
		--ok: #4CC9A6;
		--bad: #FF6B6B;
		--add: #12301F;
		--del: #3A1618;
		--code: #1F2226;
		color-scheme: dark;
	}
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 15px/1.5 Inter, system-ui, sans-serif;
	display: flex;
	flex-direction: column;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
code, pre { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; }

.bar {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 10px 16px;
	background: var(--panel);
	border-bottom: 1px solid var(--line);
	min-height: 56px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-family: "Space Grotesk", Inter, sans-serif; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.bar-project { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.bar-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--bad); }
.bar { position: relative; }
.bar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.pop {
	position: absolute; top: calc(100% + 8px); right: 16px; z-index: 20; width: min(400px, calc(100vw - 32px));
	max-height: min(70vh, 560px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
	padding: 16px; box-shadow: 0 30px 60px -30px rgba(0,0,0,.45); display: grid; gap: 10px; align-content: start;
}
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pop h2 { margin: 0; font: 700 18px/1.2 "Space Grotesk", Inter, sans-serif; letter-spacing: -0.02em; }
.pop-note { margin: 0; color: var(--muted); font-size: 14px; }
.pop { grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
.versions { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.versions li { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.versions li:hover { background: var(--code); }
.versions .v-text { flex: 1; min-width: 0; }
.versions .v-msg { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.versions .v-time { font-size: 12px; color: var(--muted); }
.versions .v-now { font-size: 12px; font-weight: 600; color: var(--ok); }
.pub-msg { margin: 0; font-weight: 500; }
.pub-msg.error { color: var(--bad); }
.pub-url { font-weight: 600; color: var(--accent); overflow-wrap: anywhere; }
.pub-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pub-log summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.pub-log pre { margin: 8px 0 0; max-height: 220px; overflow: auto; background: var(--code); padding: 10px; border-radius: 10px; white-space: pre-wrap; font-size: 12px; }
.acc { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.acc li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 4px 10px; padding: 12px; border-radius: 14px; background: var(--code); align-items: start; }
.acc-mark { grid-row: span 3; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; background: var(--line); color: var(--muted); }
.acc-mark.ok { background: var(--ok); color: #fff; }
.acc-mark.todo { background: var(--warm); color: #fff; }
.acc-title { font-weight: 600; }
.acc-title span { color: var(--muted); font-weight: 500; }
.acc-detail { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.acc-detail a { color: var(--accent); font-weight: 600; }
.acc-code { font: 700 22px/1.2 "JetBrains Mono", monospace; letter-spacing: .08em; color: var(--ink); }
.acc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.badge { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--warm); margin-left: 6px; vertical-align: middle; }
.saved { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--muted); }
.saved button { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 12px; padding: 4px; }
.saved button:disabled { display: none; }

.primary, .ghost, .stop {
	border-radius: 980px;
	padding: 0 18px;
	min-height: 40px;
	font-weight: 600;
	border: 0;
}
.primary { background: var(--accent); color: #fff; }
.primary:disabled { opacity: .5; cursor: default; }
.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.ghost:hover { box-shadow: inset 0 0 0 1px var(--muted); }
.stop { background: var(--ink); color: var(--panel); }
.icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); }
.icon:hover:not(:disabled) { background: var(--code); color: var(--ink); }
.icon:disabled { opacity: .4; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Pairing */
.pair { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.pair-card { width: 100%; max-width: 480px; background: var(--panel); border-radius: 24px; padding: 32px; box-shadow: 0 1px 0 var(--line), 0 30px 60px -40px rgba(0,0,0,.35); }
.pair h1 { margin: 0 0 8px; font: 700 30px/1.1 "Space Grotesk", Inter, sans-serif; letter-spacing: -0.03em; }
.lead { margin: 0 0 20px; color: var(--muted); }
.steps { margin: 0 0 24px; padding-left: 20px; display: grid; gap: 6px; }
.steps code { background: var(--code); padding: 2px 6px; border-radius: 6px; }
.pair-form label { display: block; font-weight: 600; margin-bottom: 6px; }
.pair-row { display: flex; gap: 8px; }
.pair-row input {
	flex: 1; min-width: 0; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
	padding: 0 14px; font: 600 20px/1 "JetBrains Mono", monospace; letter-spacing: .12em; text-transform: uppercase;
}
.pair-row .primary { min-height: 48px; }
.msg { min-height: 1.5em; margin: 10px 0 0; color: var(--bad); font-size: 14px; }

/* Workspace */
.work { flex: 1; display: flex; min-height: 0; }
.chat { width: 440px; flex: 0 0 auto; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
.log { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.log > * { flex-shrink: 0; }
.empty h2 { margin: 24px 0 6px; font: 700 24px/1.15 "Space Grotesk", Inter, sans-serif; letter-spacing: -0.03em; }
.empty p { margin: 0 0 16px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 0; border-radius: 980px; background: var(--code); color: var(--ink); padding: 8px 14px; font-size: 14px; font-weight: 500; }
.chips button:hover { background: var(--accent-soft); }

.m-user { align-self: flex-end; max-width: 88%; background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 18px 18px 4px 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.m-text { overflow-wrap: anywhere; }
.m-text p { margin: 0 0 8px; }
.m-text p:last-child { margin-bottom: 0; }
.m-text code { background: var(--code); padding: 1px 5px; border-radius: 5px; }
.m-text pre { background: var(--code); padding: 10px 12px; border-radius: 10px; overflow-x: auto; margin: 0 0 8px; }
.m-text pre code { background: none; padding: 0; }
.m-text ul, .m-text ol { margin: 0 0 8px; padding-left: 20px; }

.tool { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 14px; }
.tool > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; }
.tool > summary::-webkit-details-marker { display: none; }
.tool-icon { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; background: var(--code); color: var(--muted); flex: 0 0 auto; font-size: 12px; }
.tool-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-title b { font-weight: 600; }
.tool-state { font-size: 12px; color: var(--muted); }
.tool-state.ok { color: var(--ok); }
.tool-state.bad { color: var(--bad); }
.tool-body { border-top: 1px solid var(--line); max-height: 360px; overflow: auto; }
.tool-body pre { margin: 0; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.out { color: var(--muted); }

.diff { margin: 0; padding: 6px 0; font: 12.5px/1.5 "JetBrains Mono", monospace; }
.diff div { padding: 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff .a { background: var(--add); }
.diff .d { background: var(--del); }
.diff .a::before { content: "+ "; color: var(--ok); }
.diff .d::before { content: "- "; color: var(--bad); }
.diff .c::before { content: "  "; }

.ask { border: 2px solid var(--accent); border-radius: 14px; padding: 12px 14px; background: var(--accent-soft); display: grid; gap: 8px; }
.ask-title { font-weight: 600; }
.ask-detail { max-height: 280px; overflow: auto; background: var(--panel); border-radius: 10px; }
.ask-detail pre { margin: 0; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ask-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ask-actions .primary, .ask-actions .ghost { min-height: 36px; }
.ask.done { border-color: var(--line); background: transparent; }
.ask-result { font-size: 13px; color: var(--muted); }

.notice { font-size: 13px; padding: 8px 12px; border-radius: 10px; background: var(--code); white-space: pre-wrap; }
.notice.error { background: var(--del); }
.turn-end { font-size: 12px; color: var(--muted); text-align: center; }
.working { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.working::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warm); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { .working::before { animation: none; } }

.composer { border-top: 1px solid var(--line); padding: 12px; display: grid; gap: 8px; }
.composer textarea {
	width: 100%; resize: none; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--bg); color: var(--ink);
	font: inherit; min-height: 72px; max-height: 240px;
}
.composer-row { display: flex; align-items: center; gap: 8px; }
.hint { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.model select { font: inherit; font-size: 13px; font-weight: 500; color: var(--ink); background: var(--code); border: 0; border-radius: 980px; padding: 7px 10px; min-height: 34px; cursor: pointer; }

.preview { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.preview-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.preview-bar .ghost { min-height: 36px; padding: 0 14px; }
.url { flex: 1; min-width: 0; font: 13px "JetBrains Mono", monospace; color: var(--muted); background: var(--bg); border-radius: 980px; padding: 7px 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frame-wrap { flex: 1; position: relative; min-height: 0; }
.frame-wrap iframe { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.frame-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; color: var(--muted); }
.frame-empty p { max-width: 360px; margin: 0; }
.frame-empty pre { max-width: min(720px, 100%); max-height: 50%; overflow: auto; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0; white-space: pre-wrap; }

@media (max-width: 860px) {
	.work { flex-direction: column; }
	.chat { width: auto; flex: 1 1 60%; border-right: 0; border-bottom: 1px solid var(--line); }
	.preview { flex: 1 1 40%; min-height: 280px; }
	.bar-sub { display: none; }
	.bar { flex-wrap: wrap; }
}

.pair-card .legal { margin: 18px 0 0; font-size: 13px; color: var(--muted); }
.pair-card .legal a { color: inherit; }

/* Sign-in and account */
.google { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-weight: 600; text-decoration: none; }
.google:hover { border-color: var(--muted); }
.or { text-align: center; color: var(--muted); margin: 14px 0; font-size: 14px; }
.pair-row input.email { font: 500 16px/1 Inter, system-ui, sans-serif; letter-spacing: 0; text-transform: none; }
.msg.ok { color: var(--ink); }
.who { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.who button, .me button.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; }
.limit { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.limit-title { margin: 0 0 8px; font-weight: 600; }
.apps { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.apps li { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.apps .a-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.apps .a-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.apps button { flex: 0 0 auto; }
.me { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; display: grid; gap: 8px; min-width: 0; }
.me .me-line { color: var(--muted); overflow-wrap: anywhere; }
