/* Copyright (c) Microsoft Corporation. Licensed under the MIT License. */

/* ---------------------------------------------------------------------------
   Flow companion. Locked to August Drawbridge (Darker) — navy surfaces, one indigo accent.
   Radius rule: panels 14px, controls 10px, chips 7px, round targets pill.
   --------------------------------------------------------------------------- */

:root {
	color-scheme: dark;

	--bg: #0d0e15;
	--surface: #131520;
	--surface-2: #1c1f30;
	--surface-3: #252a41;
	--border: #252a41;
	--border-strong: #444b6f;

	--text: #c3cdfe;
	--text-2: #b8cdfe;
	--text-3: #5e6587;

	--accent: #4961da;
	--accent-hi: #7289fd;
	--accent-ink: #e1e6ff;
	--accent-wash: rgba(73, 97, 218, .18);

	--ok: #67c9e4;
	--warn: #75d5f0;
	--danger: #ec407a;
	--danger-wash: rgba(236, 64, 122, .12);

	--r-lg: 14px;
	--r: 10px;
	--r-sm: 7px;
	--r-pill: 999px;

	--rail: 268px;
	--doc: 400px;
	--ease: cubic-bezier(.16, 1, .3, 1);
	--safe-b: env(safe-area-inset-bottom, 0px);
	--safe-t: env(safe-area-inset-top, 0px);
	--safe-l: env(safe-area-inset-left, 0px);
	--safe-r: env(safe-area-inset-right, 0px);

	--sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	--mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	touch-action: manipulation;
}

html, body {
	height: 100%;
	height: -webkit-fill-available;
	margin: 0;
	overflow: hidden;
	overscroll-behavior: none;
}

body {
	position: relative;
	width: 100%;
	font: 400 14px/1.6 var(--sans);
	background: var(--bg);
	color: var(--text);
	-webkit-tap-highlight-color: transparent;
	-webkit-font-smoothing: antialiased;
	-webkit-touch-callout: none;
}

html.keyboard-open { --safe-b: 0px; }

button, input, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border: 3px solid transparent; background-clip: content-box; border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* --- Shared controls ----------------------------------------------------- */

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 7px;
	min-height: 34px; padding: 0 12px;
	border: 1px solid var(--border); border-radius: var(--r);
	background: var(--surface-2); color: var(--text);
	transition: background .14s var(--ease), border-color .14s var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hi); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.quiet { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn.quiet:hover { color: var(--text); border-color: var(--border-strong); }

.icon-btn {
	display: inline-grid; place-items: center;
	width: 34px; height: 34px; flex: 0 0 auto;
	border: 0; border-radius: var(--r-pill);
	background: transparent; color: var(--text-2);
	transition: background .14s var(--ease), color .14s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: .4; cursor: default; }

#attachBtn { position: relative; overflow: hidden; cursor: pointer; }
#fileInput {
	position: absolute; inset: 0; opacity: 0;
	width: 100%; height: 100%; font-size: 0; cursor: pointer;
}

.field {
	width: 100%; min-width: 0; padding: 8px 11px;
	background: var(--surface); color: var(--text);
	border: 1px solid var(--border); border-radius: var(--r);
}
.field::placeholder { color: var(--text-3); }
.field:focus { outline: none; border-color: var(--border-strong); }

.eyebrow {
	font-size: 10px; font-weight: 600; letter-spacing: .09em;
	text-transform: uppercase; color: var(--text-3);
}

/* --- Shell --------------------------------------------------------------- */

/* Covers exactly the visible part of the page, which ends at the keyboard
   when it is up (app.js sets --vvt and --vvh from the visual viewport). */
#app {
	position: fixed;
	top: var(--vvt, 0px);
	left: 0;
	right: 0;
	height: var(--vvh, 100%);
	width: 100%;
	min-height: 0;
	overflow: hidden;
	display: grid;
	grid-template-columns: var(--rail) minmax(0, 1fr);
	transition: grid-template-columns .22s var(--ease);
}

#app.doc-open { grid-template-columns: var(--rail) minmax(0, 1fr) var(--doc); }

/* --- Sidebar ------------------------------------------------------------- */

.rail {
	display: flex; flex-direction: column; min-height: 0;
	background: var(--surface);
	border-right: 1px solid var(--border);
	padding-top: var(--safe-t);
	padding-left: var(--safe-l);
}

.rail-top { display: flex; align-items: center; gap: 6px; padding: 12px 10px 10px 14px; }
.mark {
	display: block; width: 24px; height: 24px; flex: 0 0 auto;
	border-radius: 6px; overflow: hidden; background: #050505;
}
.mark img { width: 100%; height: 100%; display: block; object-fit: cover; }
.wordmark { font-size: 14px; font-weight: 620; letter-spacing: -.2px; margin-right: auto; }

.workspace {
	display: flex; align-items: center; gap: 8px; width: calc(100% - 20px);
	margin: 0 10px 10px; padding: 7px 10px;
	border: 1px solid var(--border); border-radius: var(--r);
	background: var(--surface-2); color: var(--text-2); text-align: left;
	transition: border-color .14s var(--ease);
}
.workspace:hover { border-color: var(--border-strong); color: var(--text); }
.workspace .codicon { font-size: 14px; flex: 0 0 auto; }
.workspace-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
/* Another project has an unread chat: a dot before the chevron. */
.workspace .codicon-chevron-down { order: 1; }
.workspace.unread::after, .workspace-option.unread::after {
	content: ''; width: 7px; height: 7px; flex: 0 0 auto;
	border-radius: var(--r-pill); background: var(--accent);
}

.workspace-search { position: relative; flex: 0 0 auto; margin: 0 0 10px; }
.workspace-search .codicon {
	position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
	font-size: 14px; color: var(--text-3); pointer-events: none;
}
.card .workspace-search .field { margin: 0; padding-left: 34px; background: var(--surface-2); }

.workspace-list {
	display: flex; flex-direction: column; gap: 4px;
	flex: 1 1 auto; min-height: 120px; max-height: none;
	overflow: auto; overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	margin: 0 0 4px; padding: 0; list-style: none;
}
.workspace-row { display: flex; align-items: stretch; gap: 4px; flex: 0 0 auto; }
.workspace-option {
	display: flex; align-items: center; gap: 10px;
	flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px;
	border: 1px solid var(--border); border-radius: var(--r);
	background: var(--surface-2); color: var(--text);
	text-align: left; touch-action: manipulation;
}
.workspace-option:hover { border-color: var(--border-strong); }
.workspace-option.active { border-color: var(--border-strong); background: var(--surface-3); }
.workspace-option[aria-selected='true'] {
	border-color: var(--accent); background: var(--surface-3);
}
.workspace-option .codicon { font-size: 16px; color: var(--text-2); flex: 0 0 auto; }
.workspace-option[aria-selected='true'] .codicon { color: var(--accent-hi); }
.workspace-option-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.workspace-option-name, .workspace-option-path { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.workspace-option-name { font-size: 15px; }
.workspace-option-name mark { background: none; color: var(--accent-hi); font-weight: 650; }
.workspace-option-path { font-size: 11.5px; color: var(--text-3); font-family: var(--mono); }
.workspace-option-check { margin-left: auto; font-size: 16px; color: var(--accent-hi); order: 1; }

.workspace-remove, .workspace-remove-spacer { flex: 0 0 44px; }
.workspace-remove {
	display: grid; place-items: center; padding: 0;
	border: 1px solid transparent; border-radius: var(--r);
	background: transparent; color: var(--text-3);
	font-size: 13px; touch-action: manipulation;
	transition: color .14s var(--ease), background .14s var(--ease), border-color .14s var(--ease);
}
.workspace-remove .codicon { font-size: 15px; }
.workspace-remove:hover:not(:disabled) { color: var(--danger); background: var(--danger-wash); }
.workspace-remove.confirm {
	flex-basis: auto; padding: 0 12px;
	border-color: var(--danger); background: var(--danger-wash); color: var(--text);
}
.workspace-remove:disabled { opacity: .5; cursor: default; }
.workspace-remove.confirm:disabled { opacity: 1; }

.workspace-empty {
	display: flex; flex-direction: column; align-items: center; gap: 12px;
	padding: 22px 12px; color: var(--text-2); font-size: 13.5px; text-align: center;
}
#workspaceError { flex: 0 0 auto; }

.rail-actions { display: flex; gap: 6px; padding: 0 10px 10px; }
#newSession { flex: 1; justify-content: flex-start; }
#newGeneralSession {
	width: 34px; height: 34px; border-radius: var(--r);
	border: 1px solid var(--border); background: var(--surface-2);
}
#newGeneralSession:hover { border-color: var(--border-strong); color: var(--text); }

.rail-search { position: relative; padding: 0 10px 10px; }
.rail-search .codicon { position: absolute; left: 20px; top: 50%; transform: translateY(-60%); font-size: 13px; color: var(--text-3); pointer-events: none; }
.rail-search .field { padding-left: 30px; font-size: 13px; background: transparent; }

.rail-list { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 0 10px 16px; list-style: none; margin: 0; }
.rail-list .group { margin: 12px 0 6px; padding-left: 8px; }
.rail-list .group:first-child { margin-top: 0; }

.session {
	display: block; width: 100%; text-align: left;
	padding: 8px 10px; margin-bottom: 2px;
	border: 0; border-radius: var(--r-sm);
	background: transparent; color: var(--text-2);
	transition: background .14s var(--ease), color .14s var(--ease);
}
.session:hover { background: var(--surface-2); color: var(--text); }
.session[aria-current='true'] { background: var(--surface-3); color: var(--text); }
.session-title {
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
	overflow: hidden; font-size: 13px; line-height: 1.45;
}
.session.unread { position: relative; padding-right: 24px; color: var(--text); }
.session.unread .session-title { font-weight: 600; }
.session.unread::after {
	content: ''; position: absolute; top: 14px; right: 10px;
	width: 7px; height: 7px; border-radius: var(--r-pill); background: var(--accent);
}
.session-meta { display: flex; align-items: center; gap: 5px; min-width: 0; margin-top: 3px; font-size: 11px; color: var(--text-3); white-space: nowrap; }
.session-meta > * { flex: 0 0 auto; }
.session-meta .dot { width: 5px; height: 5px; border-radius: var(--r-pill); background: var(--accent); flex: 0 0 auto; }

.rail-empty { padding: 24px 12px; text-align: center; color: var(--text-3); font-size: 13px; }

.rail-foot {
	display: flex; align-items: center; gap: 8px;
	padding: 10px 14px calc(10px + var(--safe-b));
	border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2);
}
.status { display: inline-flex; align-items: center; gap: 7px; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: var(--r-pill); background: currentColor; }
.status.online { color: var(--ok); }
.status.offline { color: var(--text-3); }
.status.reconnecting { color: var(--warn); }
.rail-foot .icon-btn { width: 28px; height: 28px; }
.rail-foot #hostsBtn { margin-left: auto; }

.session-host { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--accent-hi); }
.session-host.offline { color: var(--text-3); }

.host-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.host-row {
	display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px;
	border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2);
}
.host-row.active { border-color: var(--accent); background: var(--surface-3); }
.host-rank { width: 16px; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.host-dot { width: 7px; height: 7px; border-radius: var(--r-pill); background: var(--text-3); flex: 0 0 auto; }
.host-dot.online { background: var(--ok); }
.host-text {
	flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start;
	margin: -6px 0; padding: 6px 0; border: 0; background: none; text-align: left;
}
.host-text:disabled { cursor: default; }
.host-text:not(:disabled):hover .host-name { color: var(--accent-hi); }
.host-text .host-name { max-width: 100%; }
.host-name { font-size: 15px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.host-state { font-size: 12px; color: var(--text-2); }
.host-row .icon-btn { width: 36px; height: 36px; }
.host-empty { color: var(--text-2); font-size: 13.5px; padding: 8px 0; }
.card p.host-note-line { margin: 10px 0 0; font-size: 12px; color: var(--text-3); }

/* --- Chat column --------------------------------------------------------- */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }

.chat-head {
	display: flex; align-items: center; gap: 10px;
	padding: calc(10px + var(--safe-t)) 16px 10px;
	border-bottom: 1px solid var(--border);
}
.chat-head h1 {
	flex: 1; min-width: 0; margin: 0;
	font-size: 14px; font-weight: 550; letter-spacing: -.1px;
	overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
#activity { font-size: 12px; color: var(--text-3); white-space: nowrap; }
#activity.busy { color: var(--accent-hi); }

.transcript {
	flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 28px max(20px, calc((100% - 760px) / 2)) 12px;
	scroll-behavior: auto;
}

/* --- Empty state --------------------------------------------------------- */

.empty { display: flex; flex-direction: column; align-items: flex-start; padding-top: min(14vh, 120px); }
.empty .mark { width: 42px; height: 42px; border-radius: 10px; margin-bottom: 18px; }
.empty h2 { margin: 0 0 8px; font-size: 24px; font-weight: 600; letter-spacing: -.5px; }
.empty p { margin: 0; color: var(--text-2); max-width: 46ch; }
.empty kbd {
	font: 500 11px/1 var(--mono); padding: 3px 5px; border-radius: 5px;
	background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}

/* --- Messages ------------------------------------------------------------ */

.msg { margin: 0 0 22px; overflow-wrap: anywhere; animation: msg-in .24s var(--ease); }
@keyframes msg-in { from { transform: translateY(6px); } }

.msg .role { display: block; margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--text-3); }

.msg.user {
	width: fit-content; max-width: 88%; margin-left: auto; margin-bottom: 26px;
	padding: 11px 15px; border-radius: var(--r);
	background: var(--surface-2); border: 1px solid var(--border);
}
.msg.user .role { display: none; }
.msg.user .body { display: grid; gap: 8px; }
.msg-images, .msg-files { display: flex; flex-wrap: wrap; gap: 6px; }
.msg-images img {
	display: block; max-width: min(240px, 70vw); max-height: 180px;
	object-fit: cover; border-radius: var(--r-sm);
	border: 1px solid var(--border); background: var(--bg);
}
.msg-files span, .attach-file {
	display: inline-flex; align-items: center; gap: 6px;
	max-width: 220px; min-height: 32px; padding: 5px 10px;
	border: 1px solid var(--border); border-radius: var(--r-sm);
	background: var(--surface-2); color: var(--text-2); font-size: 12px;
}
.msg-files span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-file { position: relative; padding-right: 28px; background: var(--surface); }
.attach-file .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg.assistant.streaming .body > :last-child::after {
	content: ''; display: inline-block; width: 7px; height: 1em;
	margin-left: 3px; vertical-align: -2px;
	background: var(--accent-hi); animation: caret 1.05s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* Tools and thought sit below prose — a compact log, not chat cards. */
.tool-stack { display: flex; flex-direction: column; gap: 3px; margin: 0 0 16px; }
.msg.reasoning, .msg.tool, .msg.patch { margin: 0; animation: none; }

.disclosure {
	border: 1px solid var(--border); border-radius: var(--r-sm);
	background: var(--surface-2); overflow: hidden;
}
.disclosure > summary {
	display: flex; align-items: center; gap: 6px;
	padding: 4px 8px; list-style: none; cursor: pointer;
	font-size: 12px; font-weight: 600; color: var(--text-2);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { color: var(--text); }
.disclosure > summary .chev { margin-left: auto; font-size: 11px; transition: transform .16s var(--ease); }
.disclosure[open] > summary .chev { transform: rotate(90deg); }
.disclosure > summary .codicon { font-size: 12px; flex: 0 0 auto; color: var(--text-3); }
.disclosure .inner { padding: 6px 8px 8px; border-top: 1px solid var(--border); }
.disclosure .inner .body { font-size: 12px; line-height: 1.5; color: var(--text-2); }

.tool-row {
	display: flex; align-items: center; gap: 6px;
	min-height: 26px; padding: 3px 8px;
	border: 1px solid var(--border); border-radius: var(--r-sm);
	background: var(--surface-2); font-size: 12px; line-height: 1.3; color: var(--text-3);
}
.tool-row .glyph { font-size: 12px; flex: 0 0 auto; color: var(--text-3); }
.tool-row .name { font: 600 12px/1.3 var(--sans); color: var(--text-2); flex: 0 0 auto; }
.tool-row .detail { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-3); }
.tool-row .state { margin-left: auto; flex: 0 0 auto; font-size: 12px; }
.tool-row.running .name, .tool-row.running .detail { color: var(--text-2); }
.tool-row.running .state { color: var(--accent-hi); }
.tool-row.completed .state { color: var(--ok); }
.tool-row.failed { border-color: var(--danger); }
.tool-row.failed .state { color: var(--danger); }

.msg.patch .role { margin: 0 0 4px; font-size: 11px; font-weight: 600; }
.patch-files { display: flex; flex-wrap: wrap; gap: 4px; }
.patch-files span {
	display: inline-flex; align-items: center; gap: 5px;
	padding: 2px 7px; border-radius: var(--r-sm);
	background: var(--surface-2); border: 1px solid var(--border);
	font: 400 11px/1.4 var(--mono); color: var(--text-3);
}

.notice {
	display: flex; gap: 10px; align-items: flex-start;
	padding: 12px 14px; margin: 0 0 22px;
	border: 1px solid var(--border); border-radius: var(--r);
	background: var(--surface); font-size: 13px; color: var(--text-2);
}
.notice .codicon { font-size: 15px; margin-top: 1px; flex: 0 0 auto; color: var(--text-3); }
.notice.error { border-color: var(--danger); background: var(--danger-wash); color: var(--text); }
.notice.error .codicon { color: var(--danger); }
.notice .grow { flex: 1; min-width: 0; }
.notice .btn { min-height: 28px; padding: 0 10px; font-size: 12px; }

.btn.earlier { display: flex; margin: 0 auto 22px; font-size: 13px; }

.steer-divider {
	display: flex; align-items: center; gap: 10px;
	margin: 4px 0 14px;
	font-size: 11px; font-weight: 600; letter-spacing: .5px;
	text-transform: uppercase; color: var(--text-3);
}
.steer-divider::before, .steer-divider::after {
	content: ''; flex: 1; height: 1px; background: var(--border-strong);
}
.steer-divider .steer-now {
	width: 22px; height: 22px;
	background: var(--accent); color: var(--accent-ink);
	touch-action: manipulation;
}
.steer-divider .steer-now:hover:not(:disabled) { background: var(--accent-hi); color: var(--accent-ink); }
.steer-divider .steer-now .codicon { font-size: 12px; }
.msg.user.pending { opacity: .78; }

.waiting {
	margin: 0 0 22px;
	animation: msg-in .24s var(--ease);
}
.waiting .role {
	display: block; margin: 0 0 8px;
	font-size: 12px; font-weight: 600; color: var(--text-3);
}
.waiting .dots {
	display: inline-flex; align-items: center; gap: 5px; height: 14px;
}
.waiting .dots i {
	width: 6px; height: 6px; border-radius: var(--r-pill);
	background: var(--accent-hi);
	animation: wait-dot 1s ease-in-out infinite;
}
.waiting .dots i:nth-child(2) { animation-delay: .16s; }
.waiting .dots i:nth-child(3) { animation-delay: .32s; }
@keyframes wait-dot {
	0%, 80%, 100% { opacity: .28; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-3px); }
}

/* --- Markdown prose ------------------------------------------------------ */

.body > :first-child { margin-top: 0; }
.body > :last-child,
.body :last-child { margin-bottom: 0; }
.body p { margin: 0 0 14px; }
.body ul, .body ol { margin: 0 0 14px; padding-left: 22px; }
.body li { margin: 4px 0; }
.body li::marker { color: var(--text-3); }
.body h1, .body h2, .body h3, .body h4 { margin: 24px 0 10px; line-height: 1.35; font-weight: 600; letter-spacing: -.2px; }
.body h1 { font-size: 20px; }
.body h2 { font-size: 17px; }
.body h3, .body h4 { font-size: 15px; }
.body a { color: var(--accent-hi); text-underline-offset: 3px; }
.body strong { color: #e1e6ff; font-weight: 600; }
.body code { font: 400 12.5px/1.5 var(--mono); background: var(--surface-3); border-radius: 5px; padding: 2px 5px; word-break: break-word; }
.body pre {
	position: relative; overflow: auto; margin: 0 0 16px;
	padding: 34px 14px 14px;
	border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
}
.body pre code { background: transparent; padding: 0; font-size: 12.5px; line-height: 1.65; }
.copy-code {
	position: absolute; right: 6px; top: 5px;
	min-height: 24px; padding: 0 8px; border: 0; border-radius: var(--r-sm);
	background: transparent; color: var(--text-3); font-size: 11px;
}
.copy-code:hover { background: var(--surface-3); color: var(--text); }
.body blockquote { margin: 0 0 14px; padding-left: 14px; border-left: 2px solid var(--border-strong); color: var(--text-2); }
.body table { display: block; overflow-x: auto; border-collapse: collapse; margin: 0 0 16px; font-size: 13px; }
.body th, .body td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.body th { background: var(--surface-2); font-weight: 600; }
.body img { max-width: 100%; height: auto; border-radius: var(--r-sm); }
.body hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }

/* --- Skeleton ------------------------------------------------------------ */

.skeleton { display: grid; gap: 12px; }
.skeleton i { display: block; height: 13px; border-radius: 6px; background: var(--surface-2); }
.skeleton i:nth-child(1) { width: 32%; }
.skeleton i:nth-child(2) { width: 88%; }
.skeleton i:nth-child(3) { width: 74%; }
.skeleton i:nth-child(4) { width: 56%; }

/* --- Scroll pin ---------------------------------------------------------- */

.to-bottom {
	position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
	display: inline-flex; align-items: center; gap: 6px;
	min-height: 30px; padding: 0 12px; border-radius: var(--r-pill);
	border: 1px solid var(--border-strong); background: var(--surface-2);
	color: var(--text-2); font-size: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .38);
}
.to-bottom:hover { color: var(--text); }
.chat-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* --- Approval ------------------------------------------------------------ */

.approval {
	margin: 0 max(20px, calc((100% - 760px) / 2)) 10px;
	padding: 14px 16px; max-height: 42vh; overflow: auto;
	border: 1px solid var(--accent); border-radius: var(--r-lg);
	background: var(--surface); box-shadow: 0 0 0 3px var(--accent-wash);
}
.approval-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; font-weight: 600; }
.approval-head .codicon { color: var(--accent-hi); font-size: 15px; }
.approval-head .queue { margin-left: auto; font-size: 11px; font-weight: 400; color: var(--text-3); }
.approval .target { margin: 0 0 12px; font: 400 12.5px/1.55 var(--mono); color: var(--text-2); overflow-wrap: anywhere; }
.approval .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.approval fieldset { border: 0; border-top: 1px solid var(--border); margin: 12px 0; padding: 12px 0 0; }
.approval legend { padding: 0; font-size: 13px; font-weight: 550; }
.approval .choice {
	display: flex; align-items: center; gap: 10px; min-height: 38px;
	padding: 4px 8px; border-radius: var(--r-sm); font-size: 13px; cursor: pointer;
}
.approval .choice:hover { background: var(--surface-2); }
.approval input[type='text'] { margin-top: 8px; }
.approval .error { margin: 10px 0 0; color: var(--danger); font-size: 12.5px; }
.approval .error:empty { display: none; }

/* --- Composer ------------------------------------------------------------ */

.composer-wrap { flex-shrink: 0; padding: 0 max(20px, calc((100% - 760px) / 2)) calc(10px + var(--safe-b)); }

.composer {
	display: flex; flex-direction: column;
	border: 1px solid var(--border); border-radius: var(--r-lg);
	background: var(--surface);
	transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.composer:focus-within { border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--accent-wash); }
.composer.drop-target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }

.attach-strip { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px 0; }
.attach-thumb {
	position: relative; width: 64px; height: 64px; flex: 0 0 auto;
	border-radius: var(--r-sm); overflow: visible;
}
.attach-thumb img {
	display: block; width: 64px; height: 64px; object-fit: cover;
	border-radius: var(--r-sm); border: 1px solid var(--border);
	background: var(--surface-2);
}
.attach-thumb .icon-btn,
.attach-file .icon-btn {
	position: absolute; top: -7px; right: -7px;
	width: 22px; height: 22px; background: var(--surface-3); color: var(--text);
	box-shadow: 0 0 0 2px var(--surface);
}
.attach-thumb .icon-btn .codicon,
.attach-file .icon-btn .codicon { font-size: 11px; }

.composer textarea {
	resize: none; border: 0; outline: 0; background: transparent;
	padding: 13px 15px 4px; min-height: 50px; max-height: 190px; font-size: 15px; line-height: 1.55;
}
.composer textarea::placeholder { color: var(--text-3); }

.composer-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px 8px 10px; }
.composer-bar .grow { flex: 1; min-width: 0; }

.model-btn {
	display: none; align-items: center; gap: 6px;
	min-width: 0; max-width: 100%; height: 34px; padding: 0 10px 0 8px;
	border: 0; border-radius: var(--r-pill);
	background: var(--surface-2); color: var(--text-2);
	touch-action: manipulation;
}
.model-btn .codicon { font-size: 13px; color: var(--text-3); flex: 0 0 auto; }
.model-btn-label {
	min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
	font-size: 13px; color: var(--text);
}
/* Reasoning effort keeps its room; the model name truncates first. */
.model-btn-effort { flex: 0 0 auto; white-space: nowrap; font-size: 13px; color: var(--text-2); }
.model-btn-effort::before { content: '· '; color: var(--text-3); }
.model-btn:hover { background: var(--surface-3); color: var(--text); }

.pickers { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; }
#modelOptions { display: contents; }
.picker-field { display: contents; }
.picker-field > span { display: none; }
.pickers select {
	max-width: min(210px, 100%); min-width: 0; min-height: 30px; padding: 0 6px;
	border: 0; border-radius: var(--r-sm);
	background: transparent; color: var(--text-2); font-size: 12.5px;
	transition: background .14s var(--ease), color .14s var(--ease);
}
.pickers select:hover { background: var(--surface-2); color: var(--text); }

/* Existing sessions are read-only about their provider and model. */
.session-chip { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; padding-left: 2px; }
.session-chip .part {
	display: inline-flex; align-items: center; gap: 6px; min-width: 0;
	font-size: 12.5px; color: var(--text-2); white-space: nowrap;
}
.session-chip .part .codicon { font-size: 12px; color: var(--text-3); flex: 0 0 auto; }
.session-chip .part.model { flex: 1 1 auto; overflow: hidden; }
#chipModel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-chip .sep { width: 1px; height: 13px; background: var(--border-strong); flex: 0 0 auto; }
.session-chip select {
	min-height: 28px; padding: 0 6px; border: 0; border-radius: var(--r-sm);
	background: transparent; color: var(--text-2); font-size: 12.5px; flex: 0 0 auto;
}
.session-chip select:hover { background: var(--surface-2); color: var(--text); }

#send { background: var(--accent); color: var(--accent-ink); touch-action: manipulation; }
#send:hover:not(:disabled) { background: var(--accent-hi); }
#send:disabled { background: var(--surface-3); color: var(--text-2); }
#stop { background: var(--surface-3); color: var(--text); touch-action: manipulation; }

.voice-btn { touch-action: manipulation; }
.voice-btn.recording { color: var(--danger); background: var(--danger-wash); }
.voice-btn.recording .codicon { animation: ap-pulse 1.4s ease-in-out infinite; }
.voice-timer { font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--danger); }
#stop:hover:not(:disabled) { background: var(--border-strong); }
#stop:disabled { background: transparent; }

.composer-foot {
	display: flex; align-items: center; gap: 10px;
	padding: 7px 4px 0; min-height: 22px;
	font-size: 11px; color: var(--text-3);
}
.composer-foot .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#retryCatalog { min-height: 22px; padding: 0 8px; font-size: 11px; }

/* --- Document panel ------------------------------------------------------ */

.doc {
	display: flex; flex-direction: column; min-width: 0; min-height: 0;
	background: var(--surface); border-left: 1px solid var(--border);
	padding-top: var(--safe-t); padding-right: var(--safe-r);
}
.doc-head { display: flex; align-items: center; gap: 4px; padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--border); }
.doc-head .title { flex: 1; min-width: 0; }
.doc-head .title strong { display: block; font-size: 13px; font-weight: 600; }
.doc-head .title span { display: block; font: 400 11px/1.4 var(--mono); color: var(--text-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.doc-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 20px 20px calc(24px + var(--safe-b)); }
.doc-body .body { font-size: 13.5px; }
.doc-edit {
	flex: 1; min-height: 0; width: 100%; resize: none;
	padding: 16px 18px calc(18px + var(--safe-b));
	border: 0; outline: 0; background: var(--bg);
	font: 400 13px/1.7 var(--mono);
}
.doc-note { padding: 8px 16px; font-size: 12px; color: var(--danger); }
.doc-note:empty { display: none; }
#docBtn.has-plan { color: var(--accent-hi); }
#docBtn.unread, #menuBtn.unread { position: relative; }
#docBtn.unread::after, #menuBtn.unread::after {
	content: ''; position: absolute; top: 5px; right: 5px;
	width: 7px; height: 7px; border-radius: var(--r-pill);
	background: var(--accent); border: 2px solid var(--bg);
}

/* --- Overlays ------------------------------------------------------------ */

.scrim { position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .55); }

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, .66); padding: 24px; }
.card {
	width: min(430px, calc(100% - 32px)); padding: 26px;
	border: 1px solid var(--border-strong); border-radius: var(--r-lg);
	background: var(--surface); color: var(--text);
}
dialog.card {
	padding: 26px;
	max-height: min(86vh, 720px);
	max-height: min(86dvh, 720px);
	flex-direction: column;
	overflow: hidden;
}
dialog.card:not([open]) { display: none; }
dialog.card[open] { display: flex; }
dialog.card::backdrop { background: rgba(0, 0, 0, .66); }
dialog.card h2, dialog.card p { flex: 0 0 auto; }
#workspaceDialog .dialog-actions { flex: 0 0 auto; margin-top: 12px; }
.card h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; letter-spacing: -.3px; }
.card p { margin: 0 0 16px; color: var(--text-2); font-size: 13.5px; }
.card label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--text-2); }
.card .field { padding: 11px 12px; font-size: 16px; margin-bottom: 4px; }
.card .error { margin: 8px 0 0; color: var(--danger); font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

dialog.card.sheet { width: min(430px, calc(100% - 32px)); }
#modelDialog h2 { margin-bottom: 4px; font-size: 18px; }
#modelDialog p { margin-bottom: 18px; font-size: 13px; }
.picker-sheet { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px 2px; }
.picker-sheet .pickers {
	display: flex; flex-direction: column; align-items: stretch; gap: 16px; flex-wrap: nowrap;
}
.picker-sheet .picker-field {
	display: flex; flex-direction: column; align-items: stretch; gap: 7px; margin: 0;
}
.picker-sheet .picker-field > span {
	display: block; font-size: 12px; font-weight: 500; color: var(--text-2);
}
.picker-sheet .pickers select {
	width: 100%; max-width: none; min-height: 44px; padding: 0 38px 0 12px;
	appearance: none; -webkit-appearance: none;
	border: 1px solid var(--border); border-radius: var(--r);
	background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%237289fd' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
	color: var(--text); font-size: 16px;
}
.picker-sheet .pickers select:disabled { opacity: .5; cursor: default; }
/* Short choices (Mode, Reasoning) are one tap in the sheet; their selects stay the source of truth. */
.segments { display: none; }
.picker-sheet select[data-segmented] { display: none; }
.picker-sheet .segments {
	display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px;
	padding: 3px; border: 1px solid var(--border); border-radius: var(--r);
	background: var(--surface-2);
}
.segments button {
	min-width: 0; min-height: 38px; padding: 0 4px;
	border: 0; border-radius: var(--r-sm);
	background: transparent; color: var(--text-2); font-size: 14px;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	touch-action: manipulation;
	transition: background .14s var(--ease), color .14s var(--ease);
}
.segments button:hover:not(:disabled) { color: var(--text); }
.segments button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segments button:disabled { opacity: .5; cursor: default; }
#modelDialog .dialog-actions { flex: 0 0 auto; }

/* --- Autopilot ------------------------------------------------------------ */

.main { position: relative; }

/* Status looks shared by pills, rail dots and the ending card. */
.ap-pill {
	display: inline-flex; align-items: center; gap: 6px;
	padding: 3px 10px; border-radius: var(--r-pill);
	font-size: 12px; font-weight: 600; white-space: nowrap;
	background: var(--surface-3); color: var(--text-2);
}
.ap-pill::before { content: ''; width: 6px; height: 6px; border-radius: var(--r-pill); background: currentColor; }
.ap-pill.active { background: var(--accent-wash); color: var(--accent-hi); }
.ap-pill.active::before { animation: ap-pulse 1.4s ease-in-out infinite; }
.ap-pill.needs { background: rgba(255, 196, 92, .16); color: #ffc45c; }
.ap-pill.done { background: rgba(103, 201, 228, .14); color: var(--ok); }
.ap-pill.bad { background: var(--danger-wash); color: var(--danger); }
@keyframes ap-pulse { 50% { opacity: .35; } }

/* Runs in the chat list */
.session.view.needs { background: rgba(255, 196, 92, .07); }
.session.view.needs .session-meta { color: #ffc45c; }
.session-meta .dot.needs { background: #ffc45c; }

#menuBtn.ap-badge { position: relative; }
#menuBtn.ap-badge::after {
	content: ''; position: absolute; top: 5px; right: 5px;
	width: 8px; height: 8px; border-radius: var(--r-pill);
	background: #ffc45c; border: 2px solid var(--bg);
}

/* Banner: a toast under the header, over whatever is showing. */
.ap-banner {
	position: absolute; z-index: 12; left: 50%; transform: translateX(-50%);
	top: calc(var(--safe-t) + 58px); width: min(640px, calc(100% - 24px));
	display: flex; align-items: center; gap: 10px;
	padding: 8px 8px 8px 14px; border-radius: var(--r-lg);
	border: 1px solid var(--border-strong); background: var(--surface-2);
	box-shadow: 0 12px 34px rgba(0, 0, 0, .45); font-size: 13px;
	animation: msg-in .24s var(--ease);
}
.ap-banner .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-banner strong { color: var(--text); font-weight: 600; }
.ap-banner > .codicon { font-size: 16px; }
.ap-banner.needs { border-color: #ffc45c; }
.ap-banner.needs > .codicon { color: #ffc45c; }
.ap-banner.done > .codicon { color: var(--ok); }
.ap-banner.bad { border-color: var(--danger); }
.ap-banner.bad > .codicon { color: var(--danger); }
.ap-banner .btn { min-height: 30px; }
.ap-banner .icon-btn { width: 30px; height: 30px; }

.ap-folder-notice {
	display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 6px 6px 6px 12px;
	border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
	font-size: 12.5px; color: var(--text-2);
}
.ap-folder-notice > .codicon { color: var(--accent-hi); }
.ap-folder-notice .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-folder-notice .btn { min-height: 28px; padding: 0 10px; font-size: 12px; }

/* Slash menu above the composer */
.composer-wrap { position: relative; }
.slash-menu {
	position: absolute; z-index: 9; bottom: calc(100% - 4px);
	left: max(20px, calc((100% - 760px) / 2)); width: min(420px, calc(100% - 40px));
	display: flex; flex-direction: column; gap: 2px; padding: 6px;
	border: 1px solid var(--border-strong); border-radius: var(--r-lg);
	background: var(--surface-2); box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
}
.slash-item {
	display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
	padding: 8px 10px; border: 0; border-radius: var(--r-sm);
	background: transparent; color: var(--text); text-align: left;
}
.slash-item.active, .slash-item:hover { background: var(--surface-3); }
.slash-item:disabled { opacity: .5; cursor: default; }
.slash-name { font: 600 13px/1.4 var(--mono); color: var(--accent-hi); }
.slash-detail { font-size: 12px; color: var(--text-2); }

/* The sheet */
dialog.card.ap-sheet { width: min(560px, calc(100% - 32px)); padding: 22px 24px; }
.ap-sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex: 0 0 auto; }
.ap-sheet-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; }
.ap-sheet-head h2 .codicon { font-size: 18px; color: var(--accent-hi); }
.ap-step { margin-left: auto; font-size: 12px; color: var(--text-3); }
.ap-sheet-head .icon-btn { margin-right: -8px; }
.ap-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; margin: 0 -24px; padding: 0 24px 2px; }
.ap-scroll > label, .ap-card > label { margin-top: 14px; }
.ap-scroll > label:first-child { margin-top: 0; }
.ap-scroll textarea.field { font-size: 15px; resize: vertical; line-height: 1.5; }
.field.mono, .mono { font-family: var(--mono) !important; font-size: 13px !important; }
.ap-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; font-size: 13px; color: var(--text-2); }
.ap-label, .ap-label-line { font-size: 12px; color: var(--text-2); }
.ap-label { width: 64px; flex: 0 0 auto; }
.ap-label-line { display: block; margin: 14px 0 6px; }
.ap-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 14px; }
.ap-row .btn { min-height: 30px; }
.ap-harness { margin: 14px 0 0; padding: 0; border: 0; }
.ap-harness legend { padding: 0; margin-bottom: 6px; font-size: 12px; color: var(--text-2); }
.ap-pickers { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-options { display: contents; }
.ap-pickers select {
	min-height: 38px; max-width: 100%; padding: 6px 10px;
	border: 1px solid var(--border); border-radius: var(--r);
	background: var(--surface-2); color: var(--text); font-size: 14px;
}
.ap-loading { align-self: center; font-size: 12px; color: var(--text-3); }
.ap-limits .field { width: 72px; padding: 6px 8px; font-size: 14px; margin: 0; text-align: center; }
.ap-schedule { flex-wrap: wrap; }
.ap-schedule .ap-toggle { display: flex; align-items: center; gap: 8px; margin: 0; }
.ap-schedule input[type="datetime-local"] { flex: 1; min-width: 180px; margin: 0; padding: 6px 10px; font-size: 14px; }
.ap-scheduled { padding: 14px 2px 8px; }
.ap-scheduled h2 { margin: 0 0 8px; font-size: 16px; }
.ap-scheduled .ap-row { margin-top: 10px; }
.card p.ap-note { margin: 14px 0 0; font-size: 12.5px; color: var(--text-2); }
.card p.ap-note + p.ap-note { margin-top: 6px; }
.card p.ap-note.error { color: var(--danger); }
.card p.ap-note strong { color: var(--text); }
.ap-drafting { display: flex; align-items: center; gap: 10px; padding: 18px 2px; color: var(--accent-hi); font-size: 14px; }
.ap-question { padding: 4px 0 8px; }
.ap-question-text { margin: 0 0 12px !important; color: var(--text) !important; font-size: 14px !important; }
.ap-answer { display: flex; gap: 8px; margin-top: 10px; }
.ap-answer .field { flex: 1; margin: 0; font-size: 15px; }
.ap-commands { display: flex; flex-direction: column; gap: 6px; }
.ap-command { display: flex; align-items: center; gap: 4px; }
.ap-command .field { flex: 1; margin: 0; padding: 9px 10px; }
.ap-add { align-self: flex-start; margin-top: 6px; min-height: 30px; font-size: 12.5px; }
.ap-notes { margin-top: 14px; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); font-size: 13px; }
.ap-notes .ap-label-line { margin-top: 0; }
.ap-revise { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.ap-revise .btn { margin-top: 6px; }
.ap-sheet .dialog-actions {
	position: sticky; bottom: 0; z-index: 1; flex: 0 0 auto; align-items: center;
	margin-top: 14px; padding: 12px 0 2px; background: var(--surface);
}
.ap-sheet .dialog-actions .grow { flex: 1; }

/* A run in the chat column: the chat's own body and composer step aside. */
#app.external-view .main > .chat-body,
#app.external-view .main > .approval,
#app.external-view .main > .composer-wrap { display: none !important; }
.run-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.run-tabs {
	display: flex; gap: 2px; padding: 6px max(20px, calc((100% - 760px) / 2)) 0;
	border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none;
}
.run-tabs [role='tab'] {
	padding: 6px 10px 8px; border: 0; border-bottom: 2px solid transparent;
	background: transparent; color: var(--text-3); font-size: 12.5px; font-weight: 550; white-space: nowrap;
}
.run-tabs [role='tab']:hover { color: var(--text); }
.run-tabs [role='tab'][aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent-hi); }
.run-body {
	flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 24px max(20px, calc((100% - 760px) / 2)) 12px;
}
.run-body .msg { animation: none; }
.run-needs { border-color: #ffc45c; box-shadow: 0 0 0 3px rgba(255, 196, 92, .14); }
.run-needs .approval-head .codicon { color: #ffc45c; }
.run-needs .actions .btn { min-height: 34px; }
.run-finish { margin: 0 max(20px, calc((100% - 760px) / 2)) 4px; }
.run-finish .msg { margin: 0; }
.ap-msg .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ap-msg .error { margin: 8px 0 0; color: var(--danger); font-size: 12.5px; }
.ap-msg .error:empty { display: none; }
.ap-hint { margin: 10px 0 0; font-size: 12px; color: var(--text-3); }
.run-chip { flex: 1 1 auto; display: inline-flex; align-items: center; gap: 7px; min-width: 0; padding-left: 4px; font-size: 12.5px; color: var(--text-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.run-chip .codicon { color: var(--accent-hi); font-size: 14px; flex: 0 0 auto; }
#runSend { background: var(--accent); color: var(--accent-ink); touch-action: manipulation; }
#runSend:hover:not(:disabled) { background: var(--accent-hi); }
#runSend:disabled { background: var(--surface-3); color: var(--text-2); }
#runStop { background: var(--surface-3); color: var(--text); touch-action: manipulation; }
#runStop:hover { background: var(--border-strong); }
#runInput:disabled { opacity: .6; }

.ap-conversation { display: flex; flex-direction: column; min-width: 0; }
.ap-body { min-width: 0; overflow-wrap: anywhere; overflow: hidden; }
/* Consecutive Autopilot messages read as one: the label shows once. */
.ap-msg + .ap-msg { margin-top: -12px; }
.ap-msg + .ap-msg > .role { display: none; }
.ap-activity {
	display: flex; align-items: center; gap: 10px; margin: 0 0 22px;
	font-size: 13.5px; color: var(--accent-hi);
}
.ap-cardbox {
	display: flex; flex-direction: column; gap: 4px; padding: 16px;
	border: 1px solid #ffc45c; border-radius: var(--r-lg); background: var(--surface);
	box-shadow: 0 0 0 3px rgba(255, 196, 92, .1); overflow-wrap: anywhere;
}
.ap-card-intro { margin: 0 0 6px !important; color: var(--text-2); font-size: 13px; }
.ap-field { display: flex; flex-direction: column; }
.ap-cardbox .field { font-size: 14px; resize: vertical; line-height: 1.5; }
.ap-cardbox .ap-label-line { margin: 10px 0 5px; }
.ap-toggle { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; cursor: pointer; }
.ap-cardbox .actions { display: flex; gap: 8px; margin-top: 14px; }
.ap-cardbox .error { margin: 6px 0 0; color: var(--danger); font-size: 13px; }
.ap-cardbox .error:empty { display: none; }
.ap-agreed { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.ap-agreed > summary {
	display: flex; align-items: center; gap: 10px; padding: 10px 14px; list-style: none; cursor: pointer;
	font-size: 13px; color: var(--text-2); min-width: 0;
}
.ap-agreed > summary > span:not(.codicon) { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--mono); font-size: 12.5px; }
.ap-agreed > summary::-webkit-details-marker { display: none; }
.ap-agreed > summary > .codicon-checklist { color: var(--ok); }
.ap-agreed > summary > .codicon-chevron-right { color: var(--text-3); transition: transform .16s var(--ease); }
.ap-agreed[open] > summary > .codicon-chevron-right { transform: rotate(90deg); }
.ap-agreed > .ap-card-facts { padding: 2px 14px 6px; }
.ap-agreed > .ap-hint { margin: 0; padding: 0 14px 12px; }
.ap-more { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; }
.ap-more > summary { cursor: pointer; font-size: 12.5px; color: var(--text-2); list-style: revert; }
.ap-more[open] > summary { margin-bottom: 4px; }
.ap-file-list li { display: flex; align-items: center; gap: 4px; }
.ap-file-list li > .ap-file { flex: 1; min-width: 0; }
.ap-download { width: 30px; height: 30px; flex: 0 0 auto; }

.ap-muted { color: var(--text-3); font-size: 13px; }
.ap-warn { color: #ffc45c; font-size: 13px; }
.ap-round { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.ap-round > summary {
	display: flex; align-items: center; gap: 10px; padding: 11px 14px;
	list-style: none; cursor: pointer; min-width: 0;
}
.ap-round > summary::-webkit-details-marker { display: none; }
.ap-round > summary > .codicon-chevron-right { margin-left: auto; color: var(--text-3); transition: transform .16s var(--ease); }
.ap-round[open] > summary > .codicon-chevron-right { transform: rotate(90deg); }
.ap-round-mark { font-size: 15px; flex: 0 0 auto; }
.ap-round-mark.ok { color: var(--ok); }
.ap-round-mark.bad { color: var(--danger); }
.ap-round-mark.muted { color: var(--accent-hi); }
.ap-round-name { font-weight: 600; font-size: 13.5px; flex: 0 0 auto; }
.ap-round-text { min-width: 0; font-size: 12.5px; color: var(--text-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ap-round-body { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 14px; min-width: 0; overflow-wrap: anywhere; }
.ap-section h3 { margin: 0 0 6px; }
.ap-section .body { font-size: 13.5px; }
.ap-flags { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.ap-flags li { padding: 6px 10px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); overflow-wrap: anywhere; }
.ap-flags li.bad { background: var(--danger-wash); color: var(--text); }
.ap-flags li.warn { background: rgba(255, 196, 92, .1); color: #ffc45c; }
.ap-checks { display: flex; flex-direction: column; gap: 4px; }
.ap-check { border-radius: var(--r-sm); background: var(--surface-2); }
.ap-check > summary { display: flex; align-items: center; gap: 8px; padding: 7px 10px; list-style: none; cursor: pointer; min-width: 0; }
.ap-check > summary::-webkit-details-marker { display: none; }
.ap-check.ok > summary > .codicon { color: var(--ok); }
.ap-check.bad > summary > .codicon { color: var(--danger); }
.ap-check-command { flex: 1; min-width: 0; font: 400 12.5px/1.5 var(--mono); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); }
.ap-check-meta { flex: 0 0 auto; font-size: 11.5px; color: var(--text-3); }
.ap-tail {
	margin: 0; padding: 10px 12px; max-height: 280px; overflow: auto;
	border-top: 1px solid var(--border); font: 400 11.5px/1.55 var(--mono); color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere;
}
.ap-file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.ap-file-list li { overflow-wrap: anywhere; }
.ap-file {
	display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px;
	border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); text-align: left;
}
.ap-file:hover { background: var(--surface-2); color: var(--text); }
.ap-file .codicon-diff-added { color: var(--ok); }
.ap-file .codicon-diff-removed { color: var(--danger); }
.ap-file .codicon-diff-modified { color: var(--accent-hi); }
.ap-file-path { flex: 1; min-width: 0; font: 400 12.5px/1.5 var(--mono); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ap-file-counts { flex: 0 0 auto; font: 400 11.5px/1.5 var(--mono); color: var(--text-3); }
#apUndoDialog .ap-file-list { flex: 1 1 auto; min-height: 0; overflow: auto; font: 400 12.5px/1.6 var(--mono); }

.ap-ending { padding: 16px; border-radius: var(--r-lg); border: 1px solid var(--border-strong); background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.ap-ending.done { border-color: var(--ok); }
.ap-ending.bad { border-color: var(--danger); }
.ap-ending-head { display: flex; align-items: center; gap: 10px; }
.ap-ending-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.ap-ending-head .codicon { font-size: 20px; color: var(--text-2); }
.ap-ending.done .ap-ending-head .codicon { color: var(--ok); }
.ap-ending.bad .ap-ending-head .codicon { color: var(--danger); }
.ap-ending-reason { margin: 0; color: var(--text-2); font-size: 13.5px; }
.ap-ending .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-card-facts { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; }
.ap-card-facts dt { color: var(--text-3); }
.ap-card-facts dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.ap-transcript { padding-top: 4px; overflow-wrap: anywhere; }

@media (max-width: 900px) {
	.run-body, .run-tabs { padding-left: 16px; padding-right: 16px; }
	.run-view .run-needs,
	.run-view .run-finish { margin: 0 16px 10px; }
	dialog.card.ap-sheet { width: 100%; padding: 20px 18px calc(16px + var(--safe-b)); }
	.ap-scroll { margin: 0 -18px; padding: 0 18px 2px; }
	.slash-menu { left: 16px; width: calc(100% - 32px); }
	.ap-card-facts { grid-template-columns: 1fr; gap: 2px; }
	.ap-card-facts dd { margin-bottom: 8px; }
}

/* --- Responsive ---------------------------------------------------------- */

@media (min-width: 901px) {
	#menuBtn, #closeRail, .scrim { display: none !important; }
	.rail[hidden] { display: flex !important; }
}

@media (max-width: 900px) {
	#app, #app.doc-open { grid-template-columns: minmax(0, 1fr); }
	.rail[hidden] { display: flex !important; }
	.scrim[hidden] { display: block !important; }
	.rail {
		position: fixed; inset: 0 auto 0 0; z-index: 20;
		width: min(300px, 86vw); border-right: 1px solid var(--border);
		box-shadow: 0 0 40px rgba(0, 0, 0, .5);
		transform: translate3d(-100%, 0, 0);
		visibility: hidden;
		pointer-events: none;
		transition: transform .28s var(--ease), visibility .28s var(--ease);
	}
	.rail.is-open {
		transform: translate3d(0, 0, 0);
		visibility: visible;
		pointer-events: auto;
	}
	.scrim {
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		transition: opacity .28s var(--ease), visibility .28s var(--ease);
	}
	.scrim.is-open {
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
	}
	.doc {
		position: fixed; inset: 0; z-index: 25; border-left: 0;
		padding-left: var(--safe-l);
	}
	.doc-head #docClose { order: -1; margin-right: 4px; }
	.transcript, .approval, .composer-wrap { padding-left: 16px; padding-right: 16px; }
	.approval { margin-left: 0; margin-right: 0; }
	.empty { padding-top: 12vh; }
	.empty h2 { font-size: 21px; }
	/* Tight icons so the model name has the room. Stop only shows while a turn is running. */
	.composer-bar { flex-wrap: nowrap; gap: 2px; padding: 6px 6px 6px 8px; }
	.composer-bar .grow { display: none; }
	.composer-bar .icon-btn { width: 34px; height: 34px; }
	.composer-bar .voice-timer { padding: 0 2px; }
	#stop:disabled { display: none; }
	.composer-bar .model-btn { display: inline-flex; flex: 1 1 auto; gap: 4px; height: 34px; margin-right: 4px; padding: 0 8px 0 11px; }
	.composer-bar .model-btn > .codicon-chip { display: none; }
	#pickersSlot { display: none; }
	.session-chip { display: none !important; }
	dialog.card.sheet {
		width: 100%; max-width: none; margin: auto 0 0;
		border-radius: var(--r-lg) var(--r-lg) 0 0;
		padding: 20px 18px calc(14px + var(--safe-b));
	}
	#modelDialog .dialog-actions { margin-top: 20px; }
	#modelDialog .dialog-actions .btn { flex: 1; min-height: 44px; }
}

@media (pointer: coarse) {
	.icon-btn { width: 40px; height: 40px; }
	.btn { min-height: 40px; }
	.model-btn { height: 40px; }
	.pickers select, .session-chip select { min-height: 36px; }
	.composer textarea { font-size: 16px; }
	.rail-foot .icon-btn { width: 34px; height: 34px; }
}

@media (max-width: 480px) {
	.chat-head { padding-left: 12px; padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
	.btn:active { transform: none; }
}

/* --- Settings sheet --- */
.sheet-scroll {
	flex: 1 1 auto; min-height: 0; overflow-y: auto;
	margin: 0 -6px; padding: 0 6px;
	overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.card h3.sheet-heading { margin: 0 0 6px; font-size: 15px; font-weight: 600; }

/* --- Usage (settings sheet): the IDE's Usage board, one provider per block --- */
.usage-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.usage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.card .usage-head h3.sheet-heading { margin: 0; flex: 1 1 auto; }
.usage-stamp { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
#usageRefresh { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.card .usage-section > p { margin: 0 0 12px; font-size: 13px; }
.card .usage-section > p.error { color: var(--danger); }
.usage-board { display: flex; flex-direction: column; gap: 10px; transition: opacity .16s var(--ease); }
.usage-board.loading { opacity: .55; }
.usage-card { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.usage-card-head { display: flex; align-items: baseline; gap: 8px; }
.usage-name { font-size: 14.5px; font-weight: 600; letter-spacing: -.2px; }
.usage-plan { font-size: 11.5px; color: var(--text-3); }
.card p.usage-note { margin: 6px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.usage-note a { color: var(--accent-hi); text-decoration: none; }
.usage-cluster { margin-top: 12px; }
.usage-cluster-name { margin-bottom: 8px; font-size: 11px; color: var(--text-3); }
.usage-meter + .usage-meter { margin-top: 12px; }
.usage-meter-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.usage-meter-label { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.usage-meter-value { flex: 0 0 auto; font: 500 13px var(--mono); font-variant-numeric: tabular-nums; }
.usage-meter-reset { margin: 2px 0 6px; min-height: 16px; font-size: 11.5px; color: var(--text-3); }
.usage-track { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.usage-fill { height: 100%; border-radius: 2px; background: var(--accent-hi); transition: width .35s var(--ease); }
.usage-track.warn { background: rgba(240, 180, 70, .18); }
.usage-fill.warn { background: #f0b446; }
.usage-track.bad { background: var(--danger-wash); }
.usage-fill.bad { background: var(--danger); }

/* --- Push notifications (settings sheet) --- */
.push-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.card .push-section p { margin: 0 0 10px; font-size: 13px; }
.card .push-section p.error { color: var(--danger); }
.push-actions { display: flex; gap: 8px; }

/* Keep plan approval within reach in both the chat and the mobile file panel. */
.plan-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.plan-actions > span { flex: 1; min-width: 120px; font-size: 12px; color: var(--text-2); }
.doc-build { order: 1; flex-shrink: 0; margin: 12px 16px calc(12px + var(--safe-b)); }

/* --- Autopilot activity canvas -------------------------------------------- */
.run-body.run-body-visualization { padding: 20px; }
.ap-viz { width: 100%; max-width: 1160px; margin: 0 auto; }
.ap-viz-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ap-viz-eyebrow { color: var(--accent-hi); font: 10px/1.4 var(--mono); letter-spacing: .12em; }
.ap-viz-heading h2 { margin: 5px 0 0; font-size: 20px; line-height: 1.3; font-weight: 550; letter-spacing: -.025em; }
.ap-viz-head .btn { flex-shrink: 0; font-size: 11px; min-height: 36px; }
.ap-viz-summary { margin-top: 16px; font-size: 11px; color: var(--text-2); line-height: 1.8; }
.ap-viz-summary::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #91a0bb; margin-right: 7px; }
.ap-viz-summary[data-connection='live']::before { background: var(--ok); box-shadow: 0 0 9px #67c9e450; }
.ap-viz-note { margin: 5px 0 12px; color: #91a0bb; font-size: 11px; line-height: 1.6; }
.ap-viz-stage { position: relative; width: 100%; height: 540px; overflow: hidden; border: 1px solid #20323d; border-radius: var(--r-lg); background: radial-gradient(ellipse at 48% 45%, #122632 0%, #0b141e 45%, #080d14 100%); }
.ap-viz-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.ap-viz-canvas:active { cursor: grabbing; }
.ap-viz-map-info { position: absolute; top: 18px; left: 18px; color: #92aebc; font: 9px/1.5 var(--mono); letter-spacing: .08em; pointer-events: none; }
.ap-viz-map-hint { position: absolute; bottom: 17px; left: 16px; right: 16px; text-align: center; color: #849aa9; font: 10px/1.5 var(--mono); pointer-events: none; }
.ap-viz-controls { position: absolute; top: 10px; right: 10px; display: flex; gap: 3px; padding: 3px; border: 1px solid #293b46; border-radius: 7px; background: #0c1721ed; }
.ap-viz-controls button { min-width: 32px; min-height: 32px; border: 0; border-radius: 4px; background: transparent; color: #b8d4df; font: 12px var(--mono); cursor: pointer; }
.ap-viz-controls button:hover { background: #213744; color: white; }
.ap-viz-files { margin: 0 0 12px; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; color: #91a0bb; font-size: 11px; }
.ap-viz-files summary { cursor: pointer; }
.ap-viz-file-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 0 16px; max-height: 200px; overflow: auto; margin-top: 8px; }
.ap-viz-file { grid-column: 1 / -1; justify-self: start; max-width: 100%; border: 0; padding: 4px 0; color: #89cabb; background: transparent; text-align: left; overflow-wrap: anywhere; font: 10px/1.5 var(--mono); cursor: pointer; }
.ap-viz-file:hover { text-decoration: underline; }
.ap-viz-details > .ap-viz-selected-file { color: #b9efdf; font-family: var(--mono); }
.ap-viz-legend { display: flex; justify-content: center; gap: 17px; flex-wrap: wrap; margin: 12px 0 22px; color: #91a0bb; font-size: 10px; }
.ap-viz-key::before { content: ''; display: inline-block; width: 5px; height: 5px; margin-right: 6px; background: var(--activity-color); border-radius: 2px; }
.ap-viz-agents { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ap-viz-agent { min-height: 36px; padding: 5px 10px; background: transparent; border: 1px solid var(--border); border-radius: var(--r-sm); color: #91a0bb; font-size: 11px; max-width: 100%; overflow-wrap: anywhere; text-align: left; }
.ap-viz-agent[aria-pressed='true'] { color: var(--text); background: var(--accent-wash); border-color: var(--accent); }
.ap-viz-details { padding: 16px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow-wrap: anywhere; }
.ap-viz-details h3 { margin: 0; font-size: 13px; font-weight: 600; }
.ap-viz-details > p { color: #91a0bb; margin: 4px 0 12px; font-size: 11px; }
.ap-viz-activity { list-style: none; margin: 0; padding: 0; }
.ap-viz-activity li { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.ap-viz-tool-name { color: var(--activity-color); font-size: 11px; }
.ap-viz-tool-title { grid-column: 1; color: var(--text-2); font-size: 11px; white-space: pre-wrap; }
.ap-viz-tool-state { grid-column: 2; grid-row: 1 / 3; align-self: center; color: #91a0bb; font: 10px var(--mono); }
.ap-viz-tool-state.completed { color: var(--ok); }
.ap-viz-tool-state.failed { color: var(--danger); }
@media (max-width: 600px) {
	.run-body.run-body-visualization { padding: 16px 10px; }
	.ap-viz-heading h2 { font-size: 17px; }
	.ap-viz-eyebrow { font-size: 9px; letter-spacing: .06em; }
	.ap-viz-head .btn { max-width: 102px; padding: 4px 8px; line-height: 1.4; }
	.ap-viz-legend { gap: 12px; }
}
