:root {
  color-scheme: light;
  --canvas: #ffffff;
  --surface: #f6f8fb;
  --surface-raised: #ffffff;
  --surface-soft: #f7f9fc;
  --surface-code: #f3f6f9;
  --text: #323130;
  --muted: #626c79;
  --quiet: #84909e;
  --line: #e1e7ed;
  --line-strong: #b7c0ca;
  --input-border: #7a8795;
  --accent: #0078d4;
  --accent-hover: #075b9a;
  --accent-soft: #e5f0fb;
  --accent-soft-hover: #d9eafa;
  --hover: #f1f6fb;
  --good: #28603b;
  --good-soft: #edf7f0;
  --warning: #81520e;
  --warning-soft: #fff5df;
  --danger: #a52a32;
  --danger-soft: #fff0f1;
  --thread-running: oklch(89% .05 250);
  --thread-unread: oklch(89% .05 155);
  --thread-failed: oklch(89% .05 25);
  --glass: rgb(250 252 255 / 64%);
  --glass-header: rgb(250 252 255 / 42%);
  --glass-header-filter: blur(2px) saturate(105%);
  --glass-highlight: rgb(255 255 255 / 65%);
  --shadow-control: 0 1px 2px rgb(25 50 78 / 8%);
  --shadow-float: 0 2px 5px rgb(25 50 78 / 8%), 0 10px 26px rgb(25 50 78 / 12%);
  --font-ui: "Segoe UI", -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", sans-serif;
  --font-code: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  --radius-control: 4px;
  --radius-float: 6px;
  --header-height: 48px;
  --motion-fast: 120ms;
  --motion-enter: 200ms;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --bg: var(--canvas);
  --panel: var(--surface-raised);
  --mint: var(--accent);
  --green: var(--good);
  --amber: var(--warning);
  --red: var(--danger);
  --shadow: var(--shadow-float);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #1f2226;
  --surface: #24272b;
  --surface-raised: #282b30;
  --surface-soft: #24272b;
  --surface-code: #1b1e22;
  --text: #e9edf2;
  --muted: #a7b1bf;
  --quiet: #828d9a;
  --line: #343c46;
  --line-strong: #687583;
  --input-border: #8e99a5;
  --accent: #6cb8f6;
  --accent-hover: #8cc8f7;
  --accent-soft: #20374b;
  --accent-soft-hover: #28445c;
  --hover: #242e38;
  --good: #9acaac;
  --good-soft: #21352a;
  --warning: #e6bd77;
  --warning-soft: #3b3020;
  --danger: #f1a5ad;
  --danger-soft: #40252a;
  --thread-running: oklch(42% .07 250);
  --thread-unread: oklch(42% .07 155);
  --thread-failed: oklch(42% .07 25);
  --glass: rgb(40 44 50 / 68%);
  --glass-header: rgb(40 44 50 / 46%);
  --glass-highlight: rgb(255 255 255 / 8%);
  --shadow-control: 0 1px 2px rgb(0 0 0 / 24%);
  --shadow-float: 0 0 0 1px var(--line), 0 4px 12px rgb(0 0 0 / 24%), 0 12px 32px rgb(0 0 0 / 28%);
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--canvas); color: var(--text); font-family: var(--font-ui); font-size: 14px; letter-spacing: -.005em; }
body { min-height: 100vh; margin: 0; background: var(--canvas); }
body[data-view="agentView"] { height: 100dvh; min-height: 0; overflow: hidden; }
body[data-view="agentView"] > .topbar { display: none; }
body[data-view="agentView"] > main { height: 100dvh; min-height: 0; overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, summary, select { cursor: pointer; }
a { color: var(--accent-hover); }
code, pre { font-family: var(--font-code); }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.ambient { display: none; }

/* Global shell */
.topbar { position: sticky; z-index: 40; top: 0; display: flex; align-items: center; height: var(--header-height); padding: 0 20px; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); background: var(--glass-header); box-shadow: inset 0 1px var(--glass-highlight), 0 1px 3px rgb(25 50 78 / 4%); backdrop-filter: var(--glass-header-filter); -webkit-backdrop-filter: var(--glass-header-filter); }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--text); text-decoration: none; font-size: 17px; font-weight: 650; }
.mark { display: grid; place-items: center; width: 24px; height: 24px; color: var(--accent); font-size: 15px; font-style: italic; font-weight: 750; transform: skew(-8deg); }
.brand-section { min-width: 0; margin-left: 2px; padding-left: 12px; border-left: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
.global-nav { display: flex; align-self: stretch; gap: 2px; margin-left: 28px; }
.global-nav-item { position: relative; min-width: 62px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.global-nav-item:hover { color: var(--text); background: var(--hover); }
.global-nav-item.active { color: var(--text); font-weight: 600; }
.global-nav-item.active::after { position: absolute; right: 12px; bottom: -1px; left: 12px; height: 2px; background: var(--accent); content: ""; }
.server-state { display: flex; align-items: center; gap: 7px; min-width: 0; margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--warning); }
.dot.ok { background: var(--good); }
.dot.bad { background: var(--danger); }
.topbar-action { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; margin-left: 14px; padding: 4px 9px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-raised); box-shadow: var(--shadow-control); color: var(--muted); font-size: 11px; }
.topbar-action:hover { color: var(--accent); background: var(--hover); }
.topbar > #logoutButton { margin-left: 6px; }
main { width: 100%; min-width: 0; }
.dashboard, .workspace, .runtime-console { width: min(1440px, 100%); margin: 0 auto; }
.dashboard { padding: 30px 28px 64px; }
.workspace { padding: 0 24px 28px; }
.runtime-console { padding: 30px 28px 64px; }
.agent-console { width: 100%; height: 100%; min-height: 0; margin: 0; overflow: hidden; }

/* Shared typography, controls, and feedback */
h1, h2, h3, p { overflow-wrap: anywhere; }
.eyebrow { margin: 0; color: var(--muted); font-size: 9px; font-weight: 650; letter-spacing: .13em; text-transform: uppercase; }
.muted, .hint { color: var(--muted); }
.compact { margin: 8px 0; font-size: 11px; }
.title { color: var(--text); font-size: 14px; font-weight: 600; }
.sub { color: var(--muted); font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
.code { font: 600 20px/1 var(--font-code); letter-spacing: .12em; }
.error, .error-text { color: var(--danger); }
.primary, .secondary, .ghost, .danger, .approve, .back-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 32px; padding: 6px 12px; border: 1px solid transparent; border-radius: var(--radius-control); background: transparent; font-size: 12px; line-height: 1.2; text-decoration: none; transition: background-color var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast), box-shadow var(--motion-fast); }
.primary, .approve { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 1px rgb(255 255 255 / 18%), var(--shadow-control); color: #fff; font-weight: 600; }
.primary:hover, .approve:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.secondary { border-color: var(--line-strong); background: var(--surface-raised); box-shadow: var(--shadow-control); }
.secondary:hover, .ghost:hover, .back-button:hover { background: var(--hover); color: var(--accent); }
.ghost, .back-button { border-color: transparent; color: var(--muted); }
.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); color: var(--danger); }
.danger:hover { background: var(--danger-soft); }
button:disabled, .primary:disabled, .approve:disabled { cursor: not-allowed; opacity: .48; box-shadow: none; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea { min-width: 0; border: 1px solid var(--input-border); border-radius: var(--radius-control); background: var(--canvas); color: var(--text); outline: 0; }
input, select { min-height: 34px; padding: 6px 9px; }
textarea { padding: 9px 11px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent); }
.badge { display: inline-flex; align-items: center; width: max-content; min-height: 22px; padding: 2px 7px; border-radius: 3px; background: var(--surface); color: var(--muted); font-size: 10px; line-height: 1; }
.badge::before { width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: currentColor; content: ""; }
.badge.online { background: var(--good-soft); color: var(--good); }
.badge.offline { background: var(--surface); color: var(--muted); }
.badge.revoked { background: var(--danger-soft); color: var(--danger); }
.result-ok { color: var(--good); }
.result-fail { color: var(--danger); }
.empty { padding: 32px 18px; border: 1px dashed var(--line); color: var(--muted); text-align: center; font-size: 12px; }

/* Authentication */
.login-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, 390px); align-items: center; gap: clamp(48px, 8vw, 120px); width: min(1120px, calc(100% - 48px)); min-height: calc(100vh - var(--header-height)); margin: 0 auto; padding: 52px 0; }
.login-copy { max-width: 630px; }
.login-copy h1, .setup h1 { margin: 15px 0 22px; font-size: clamp(42px, 6vw, 68px); font-weight: 650; line-height: 1.07; letter-spacing: -.045em; }
.login-copy h1 em { color: var(--accent); font-style: normal; }
.login-copy > p:not(.eyebrow) { max-width: 580px; color: var(--muted); font-size: 16px; line-height: 1.8; }
.trust-line { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 34px; }
.trust-line span { color: var(--muted); font-size: 11px; }
.trust-line span::before { margin-right: 7px; color: var(--good); content: "✓"; }
.login-card, .setup { display: flex; flex-direction: column; gap: 20px; border: 1px solid var(--line); border-radius: var(--radius-float); background: var(--surface-raised); box-shadow: var(--shadow-float); padding: 28px; }
.login-card h2 { margin: 6px 0 5px; font-size: 22px; font-weight: 600; }
.login-card .muted { margin: 0; font-size: 12px; line-height: 1.6; }
.login-card label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
.login-card .primary { width: 100%; min-height: 38px; justify-content: space-between; }
.setup { width: min(680px, calc(100% - 40px)); margin: 80px auto; }
.setup h1 { font-size: 34px; }

/* Dashboard */
.hero-row, .workspace-bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.hero-row { margin-bottom: 24px; }
.hero-row h1 { margin: 7px 0 5px; font-size: 30px; font-weight: 620; letter-spacing: -.025em; }
.hero-row p:last-child { margin: 0; font-size: 12px; }
.hero-actions, .agent-side-actions, .conversation-actions, .actions, .node-actions, .shell-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.metrics, .workspace-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 24px; border: 1px solid var(--line); background: var(--surface-raised); }
.metrics article, .workspace-metrics article { min-width: 0; padding: 17px 20px; border-right: 1px solid var(--line); }
.metrics article:last-child, .workspace-metrics article:last-child { border-right: 0; }
.metrics span, .workspace-metrics span { display: block; color: var(--muted); font-size: 10px; }
.metrics strong, .workspace-metrics strong { display: block; margin: 7px 0 4px; font-size: 27px; font-weight: 560; font-variant-numeric: tabular-nums; }
.metrics strong.word { font-size: 22px; }
.metrics small, .workspace-metrics small { display: block; color: var(--quiet); font-size: 9px; line-height: 1.5; }
.panel { margin: 0 0 18px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-raised); }
.panel:not(details) { padding: 20px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.panel h2, .panel-head h2 { margin: 4px 0 0; font-size: 18px; font-weight: 600; }
.panel .hint { font-size: 10px; }
.install-panel { padding: 0; }
.install-panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; padding: 0 18px; list-style: none; font-weight: 600; }
.install-panel > summary::-webkit-details-marker { display: none; }
.install-panel[open] > summary { border-bottom: 1px solid var(--line); }
.install-panel > summary > span:first-child { color: var(--accent-hover); }
.install-panel > :not(summary) { margin-right: 18px; margin-left: 18px; }
.install-panel > p { color: var(--muted); font-size: 11px; line-height: 1.7; }
.install-panel > a { display: inline-block; margin-bottom: 18px; font-size: 11px; }
.install-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 18px; margin-bottom: 18px; background: var(--line); border: 1px solid var(--line); }
.install-grid article { min-width: 0; padding: 17px; background: var(--surface-raised); }
.install-grid h3 { margin: 0 0 7px; font-size: 13px; font-weight: 600; }
.install-grid p { min-height: 38px; margin: 0 0 10px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.install-grid pre { min-height: 104px; margin: 0 0 10px; padding: 11px; overflow-wrap: anywhere; white-space: pre-wrap; border: 1px solid var(--line); background: var(--surface-code); color: var(--text); font-size: 10px; line-height: 1.65; }
.enrollment-list { display: grid; border-top: 1px solid var(--line); }
.enrollment { display: grid; grid-template-columns: minmax(180px, 1.3fr) 130px minmax(140px, .8fr) minmax(180px, 1fr) auto; align-items: center; gap: 18px; min-height: 68px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.enrollment:last-child { border-bottom: 0; }
.node-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.node-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--canvas); transition: border-color var(--motion-fast), box-shadow var(--motion-fast); }
.node-card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); box-shadow: var(--shadow-control); }
.node-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 15px 15px 12px; }
.node-top > div { min-width: 0; }
.node-top .title { margin-bottom: 4px; }
.node-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.node-meta > div { min-width: 0; padding: 10px 12px; border-right: 1px solid var(--line); }
.node-meta > div:last-child { border-right: 0; }
.node-meta small, .node-meta span { display: block; }
.node-meta small { margin-bottom: 4px; color: var(--muted); font-size: 9px; }
.node-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.capabilities { display: flex; flex-wrap: wrap; gap: 5px; padding: 11px 15px; }
.capabilities span { padding: 3px 6px; border-radius: 3px; background: var(--accent-soft); color: var(--accent-hover); font: 9px/1.3 var(--font-code); }
.node-user-metadata { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 15px 11px; }
.node-user-metadata:empty { display: none; }
.node-user-metadata span { padding: 3px 6px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font: 9px/1.3 var(--font-code); }
.node-user-metadata .node-alias { border-color: color-mix(in srgb, var(--accent) 32%, var(--line)); color: var(--accent-hover); }
.node-actions { justify-content: flex-end; padding: 0 15px 13px; }
.toggle { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { position: relative; width: 28px; height: 16px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.toggle span::after { position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); content: ""; transition: transform var(--motion-fast); }
.toggle input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.toggle input:checked + span::after { transform: translateX(12px); background: var(--accent); }
.table-wrap { overflow: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { padding: 9px 11px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }

/* Device and Agent workspace shells */
.workspace-bar { position: sticky; z-index: 20; top: var(--header-height); align-items: center; min-height: 66px; margin: 0 -24px; padding: 9px 24px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--canvas) 95%, transparent); backdrop-filter: blur(3px); }
.workspace-identity { display: flex; align-items: center; gap: 11px; min-width: 0; margin-right: auto; }
.workspace-identity > div { min-width: 0; }
.workspace-identity h1 { margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; font-weight: 600; }
.workspace-identity p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.back-button { margin-right: 4px; padding-left: 4px; }
.workspace-tabs { display: flex; gap: 24px; min-height: 46px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.workspace-tab { position: relative; padding: 0 2px; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.workspace-tab:hover { color: var(--text); }
.workspace-tab.active { color: var(--text); font-weight: 600; }
.workspace-tab.active::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--accent); content: ""; }
.workspace-notice { margin: 0 0 14px; padding: 9px 12px; border-left: 2px solid var(--accent); background: var(--surface); color: var(--muted); font-size: 11px; white-space: pre-line; }
.workspace-notice.warning { border-left-color: var(--warning); color: var(--warning); }
.workspace-notice.error { border-left-color: var(--danger); color: var(--danger); }
.workspace-panel { animation: surface-in var(--motion-enter) var(--ease-out); }
.workspace-metrics { margin-bottom: 18px; }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); }
.tool-card { min-width: 0; padding: 20px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-raised); }
.tool-card:nth-child(2n) { border-right: 0; }
.tool-card:nth-last-child(-n+2) { border-bottom: 0; }
.tool-card h2 { margin: 5px 0 16px; font-size: 17px; font-weight: 600; }
.facts { display: grid; grid-template-columns: minmax(100px, .7fr) minmax(0, 1.3fr); margin: 0; font-size: 11px; }
.facts dt, .facts dd { margin: 0; padding: 7px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { overflow-wrap: anywhere; font-family: var(--font-code); }
.resource-list { display: grid; gap: 16px; margin-top: 17px; }
.resource-meter { display: grid; gap: 7px; }
.resource-meter-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.resource-label { font-size: 11px; font-weight: 600; }
.resource-value { color: var(--muted); font-size: 9px; line-height: 1.5; text-align: right; }
.meter-track { height: 4px; overflow: hidden; background: var(--line); }
.meter-fill { display: block; height: 100%; background: var(--accent); }
.meter-fill.warning { background: var(--warning); }
.meter-fill.critical { background: var(--danger); }
.network-list { display: grid; }
.network-interface { border-bottom: 1px solid var(--line); }
.network-interface summary { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; list-style: none; font-size: 11px; }
.network-interface summary::-webkit-details-marker { display: none; }
.network-interface summary::before { color: var(--accent); content: "›"; }
.network-interface[open] summary::before { transform: rotate(90deg); }
.network-interface summary span { margin-left: auto; color: var(--muted); font-family: var(--font-code); }
.network-addresses { display: grid; gap: 6px; padding: 0 0 12px 15px; color: var(--muted); font-size: 10px; }
.network-line { display: block; padding: 7px 0; border-bottom: 1px solid var(--line); color: var(--text); font-size: 10px; }

/* Files */
.file-toolbar { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 10px; }
.file-toolbar label { display: grid; flex: 1; gap: 5px; color: var(--muted); font-size: 10px; }
.file-root-note { margin: 0 0 12px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.breadcrumbs { display: flex; align-items: center; gap: 3px; min-height: 36px; overflow-x: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.breadcrumb { padding: 5px 7px; border: 0; background: transparent; color: var(--accent-hover); font: 10px var(--font-code); white-space: nowrap; }
.breadcrumb:hover { background: var(--hover); }
.breadcrumb-separator { color: var(--quiet); }
.file-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); min-height: 560px; border: 1px solid var(--line); border-top: 0; }
.file-list-card { min-width: 0; border-right: 1px solid var(--line); }
.file-list-head, .file-row { display: grid; grid-template-columns: minmax(180px, 1fr) 100px 150px; align-items: center; }
.file-list-head { min-height: 34px; background: var(--surface-soft); color: var(--muted); font-size: 9px; font-weight: 600; }
.file-list-head > *, .file-row > * { padding: 0 12px; }
.file-row { width: 100%; min-height: 40px; border: 0; border-bottom: 1px solid var(--line); background: var(--canvas); text-align: left; font-size: 11px; }
.file-row:hover { background: var(--hover); }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-icon { display: inline-block; width: 18px; color: var(--muted); }
.file-size, .file-time { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.file-loading { padding: 30px; color: var(--muted); text-align: center; }
.preview-card { min-width: 0; background: var(--surface-raised); }
.preview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.preview-head h2 { margin: 4px 0 0; font-size: 15px; }
.preview-meta { padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.55; }
.file-preview { min-height: 420px; max-height: 65vh; margin: 0; padding: 16px; overflow: auto; background: var(--surface-code); color: var(--text); font-size: 11px; line-height: 1.65; white-space: pre-wrap; }

/* Shell */
.shell-card { border: 1px solid var(--line); background: var(--surface-raised); }
.shell-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.shell-head h2 { margin: 4px 0 3px; font-size: 17px; }
.shell-head p { margin: 0; font-size: 10px; }
.shell-warning { margin: 0; padding: 9px 16px; border-bottom: 1px solid var(--line); background: var(--warning-soft); color: var(--warning); font-size: 10px; line-height: 1.6; }
.terminal-output { height: min(66vh, 720px); min-height: 380px; padding: 10px; background: #1f2226; }
.terminal-output .xterm-viewport { scrollbar-color: #687583 #1f2226; }
.shell-input-hint { margin: 0; padding: 8px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }

/* Dynamic tools debugger */
.debug-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.debug-intro h2 { margin: 5px 0 6px; font-size: 19px; }
.debug-intro p:last-child { margin: 0; color: var(--muted); font-size: 11px; }
.debug-legend { display: flex; gap: 13px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.debug-legend i { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; }
.debug-legend i.available { background: var(--good); }
.debug-legend i.unavailable { background: var(--quiet); }
.debug-warning { margin: 0 0 14px; padding: 9px 12px; border-left: 2px solid var(--warning); background: var(--warning-soft); color: var(--warning); font-size: 10px; }
.debug-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); border: 1px solid var(--line); }
.debug-tool-pane { min-width: 0; border-right: 1px solid var(--line); background: var(--surface); }
.debug-pane-head { display: grid; gap: 3px; padding: 14px; border-bottom: 1px solid var(--line); }
.debug-pane-head span { font: 600 11px var(--font-code); }
.debug-pane-head small { color: var(--muted); font-size: 9px; }
.debug-tool-list { display: grid; padding: 6px 0; }
.debug-tool { display: grid; gap: 3px; width: 100%; padding: 10px 14px; border: 0; border-left: 2px solid transparent; background: transparent; text-align: left; }
.debug-tool:hover { background: var(--hover); }
.debug-tool.active { border-left-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); }
.debug-tool-title { font: 600 11px var(--font-code); }
.debug-tool small { color: var(--muted); font-size: 9px; }
.debug-main { min-width: 0; background: var(--canvas); }
.debug-schema-card, .debug-call-card, .debug-result-card { padding: 18px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface-raised); }
.debug-result-card { border-bottom: 0; }
.debug-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.debug-card-head h2 { margin: 4px 0 8px; font-size: 16px; }
.debug-availability { color: var(--muted); font-size: 10px; }
.debug-availability.available { color: var(--good); }
.debug-availability.unavailable { color: var(--danger); }
.debug-actions { display: flex; flex-wrap: wrap; gap: 5px; margin: 12px 0; }
.debug-action { min-height: 28px; padding: 5px 9px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--canvas); font: 10px var(--font-code); }
.debug-action:hover, .debug-action.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); }
.schema-details, .debug-advanced { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.schema-details summary, .debug-advanced summary { color: var(--muted); font-size: 10px; }
.debug-code { max-height: 420px; margin: 10px 0 0; padding: 13px; overflow: auto; border: 1px solid var(--line); background: var(--surface-code); color: var(--text); font: 10px/1.65 var(--font-code); white-space: pre-wrap; }
.debug-result-image { display: block; max-width: 100%; max-height: 600px; margin-top: 14px; border: 1px solid var(--line); }
.debug-result-meta { color: var(--muted); font-size: 10px; }
.timeout-field { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; }
.timeout-field input { width: 104px; }
.debug-preset-head { display: flex; justify-content: space-between; margin: 13px 0 9px; color: var(--muted); font-size: 10px; }
.debug-preset-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.debug-preset-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; color: var(--muted); font-size: 9px; }
.debug-preset-field.wide { grid-column: 1 / -1; }
.debug-preset-field.checkbox { flex-direction: row; align-items: center; min-height: 34px; }
.debug-preset-field input:not([type="checkbox"]), .debug-preset-field select, .debug-preset-field textarea { width: 100%; font: 10px/1.45 var(--font-code); }
.debug-preset-field textarea { resize: vertical; }
.debug-editor { width: 100%; min-height: 170px; resize: vertical; font: 10px/1.55 var(--font-code); }
.debug-call-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 12px; }
.debug-call-actions .muted { font-size: 10px; }
.debug-no-params { grid-column: 1 / -1; color: var(--muted); font-size: 10px; }

/* Dedicated conversation shell and runtime/import page */
.chat-shell { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; height: 100%; min-height: 0; overflow: hidden; background: var(--canvas); isolation: isolate; }
.chat-drawer { position: absolute; z-index: 32; inset: 0 auto 0 0; display: flex; flex-direction: column; width: min(340px, 88vw); min-height: 0; overflow: hidden; border-right: 1px solid var(--line); background: var(--glass); box-shadow: var(--shadow-float); backdrop-filter: blur(14px) saturate(125%); -webkit-backdrop-filter: blur(14px) saturate(125%); transform: translateX(-100%); visibility: hidden; transition: transform var(--motion-enter) var(--ease-out), visibility 0s var(--motion-enter); pointer-events: none; }
.chat-drawer, .chat-drawer .agent-thread-list, .chat-drawer-backdrop { touch-action: pan-y pinch-zoom; }
.chat-drawer.open { transform: none; visibility: visible; transition-delay: 0s; pointer-events: auto; }
.chat-drawer-backdrop { position: absolute; z-index: 31; inset: 0; padding: 0; border: 0; background: rgb(18 31 47 / 18%); opacity: 0; transition: opacity var(--motion-fast); pointer-events: none; }
.chat-drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.chat-shell.drawer-dragging { user-select: none; -webkit-user-select: none; }
.chat-shell.drawer-dragging .chat-drawer { visibility: visible; transition: none; will-change: transform; }
.chat-shell.drawer-dragging .chat-drawer-backdrop { transition: none; will-change: opacity; }
.chat-drawer-nav { display: flex; align-items: center; gap: 8px; min-height: 44px; flex: none; padding: 0 8px; border-bottom: 1px solid var(--line); }
.chat-nav-link { display: flex; align-items: center; gap: 9px; min-width: 0; min-height: 42px; padding: 6px 8px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--text); text-align: left; }
.chat-nav-link:hover { background: var(--hover); color: var(--accent-hover); }
.chat-drawer-nav .chat-nav-link { flex: 1; font-weight: 650; }
.chat-drawer-nav .mark { flex: none; }
.chat-icon-button { display: inline-grid; place-items: center; width: 36px; min-width: 36px; height: 36px; min-height: 36px; padding: 0; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--muted); font-size: 20px; }
.chat-icon-button:hover { background: var(--hover); color: var(--accent-hover); }
.chat-icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.45; }
.chat-drawer-footer { flex: none; padding: 4px 8px; border-top: 1px solid var(--line); }
.sidebar-account { min-width: 0; font-size: 11px; }
.sidebar-account-list { max-height: min(30dvh, 240px); overflow-y: auto; overscroll-behavior: contain; }
.sidebar-account-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 38px; padding: 7px 8px; border: 0; background: transparent; text-align: left; }
.sidebar-account-row:hover, .sidebar-account-row[aria-expanded="true"] { background: var(--hover); }
.sidebar-account-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.sidebar-account-row > span { flex: none; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.spend-bar { fill: var(--accent); fill-opacity: .18; }
@media (pointer: coarse) { .sidebar-account-row { min-height: 44px; } }
@media (forced-colors: active) { .spend-bar { fill: Canvas; stroke: CanvasText; fill-opacity: 1; } }
.sidebar-account-heading { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sidebar-account-heading strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.sidebar-account-heading .chat-icon-button { width: 28px; min-width: 28px; height: 28px; min-height: 28px; font-size: 18px; }
.sidebar-account-plan { color: var(--accent); font-size: 9px; font-weight: 650; }
.sidebar-account-node { margin: 0 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }
.sidebar-account dl { display: grid; gap: 5px; margin: 0; font-variant-numeric: tabular-nums; }
.sidebar-account dl > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sidebar-account dt { color: var(--muted); }
.sidebar-account dd { margin: 0; text-align: right; }
.sidebar-account [data-account-remaining] { font-weight: 650; color: var(--accent); }
.sidebar-account meter { display: block; width: 100%; height: 4px; margin-top: 9px; border: 0; background: var(--line); }
.sidebar-account meter::-webkit-meter-bar { border: 0; border-radius: 0; background: var(--line); }
.sidebar-account meter::-webkit-meter-optimum-value { background: var(--accent); }
.sidebar-account meter::-moz-meter-bar { background: var(--accent); }
.sidebar-account-status { margin: 3px 0 0; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.chat-manage-link { width: 100%; }
.chat-manage-link.danger { color: var(--danger); }
.chat-manage-link > span:last-child { display: grid; gap: 3px; min-width: 0; }
.chat-manage-link strong { font-size: 11px; font-weight: 600; }
.chat-manage-link small { color: var(--muted); font-size: 9px; }
.runtime-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.runtime-page-head h1 { margin: 7px 0 5px; font-size: 30px; font-weight: 620; letter-spacing: -.025em; }
.runtime-page-head p:last-child { margin: 0; font-size: 12px; }
.runtime-page-actions { display: flex; gap: 7px; }
.runtime-grid { display: grid; grid-template-columns: minmax(290px, 360px) minmax(0, 1fr); align-items: start; gap: 18px; }
.runtime-card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-raised); }
.runtime-card h2 { margin: 4px 0 13px; font-size: 17px; font-weight: 600; }
.runtime-card label { display: grid; gap: 5px; margin-top: 10px; color: var(--muted); font-size: 10px; }
.runtime-card input, .runtime-card select { width: 100%; }
.runtime-setting { width: 100%; margin-top: 8px; }
.agent-side-actions { margin-top: 8px; }
.agent-side-actions button { flex: 1; }
.runtime-card > .muted { margin: 10px 0 0; font-size: 10px; line-height: 1.6; }
.agent-side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.agent-side-head .ghost { margin-top: -5px; padding: 5px 7px; }
.agent-side-caption { margin: -5px 0 10px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.thread-browser { display: flex; flex: 1; flex-direction: column; min-height: 0; padding: 6px 0 0; overflow: hidden; }
.thread-browser h2 { margin: 4px 0 8px; font-size: 15px; font-weight: 600; }
.thread-browser .agent-side-head { padding: 0 14px 8px; }
.agent-thread-list, .local-session-list { display: grid; min-height: 0; overflow-y: auto; }
.agent-thread-list { flex: 1; align-content: start; }
.agent-thread-row { --thread-row-background: var(--surface); position: relative; display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; }
.agent-thread { min-width: 0; display: grid; gap: 3px; width: 100%; padding: 8px 8px 8px 20px; border: 0; background: transparent; text-align: left; }
.agent-thread-row:hover { box-shadow: inset 0 0 0 1px var(--line-strong); }
.agent-thread-row[data-unread="true"] { --thread-row-background: var(--thread-unread); background: var(--thread-row-background); }
.agent-thread-row[data-state="running"] { --thread-row-background: var(--thread-running); background: var(--thread-row-background); }
.agent-thread-row[data-state="failed"] { --thread-row-background: var(--thread-failed); background: var(--thread-row-background); }
.agent-thread-row[data-state="unknown"], .agent-thread-row[data-state="interrupted"] { --thread-row-background: var(--surface-soft); background: var(--thread-row-background); }
.agent-thread-row:has(.agent-thread.active) { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 68%, var(--line-strong)); }
.agent-thread-row[data-unread="true"] strong { font-weight: 650; }
.agent-thread { container: thread-row / inline-size; }
.thread-meta { display: flex; align-items: baseline; gap: .3em; min-width: 0; }
.thread-meta .thread-state-label { flex: 1; min-width: 0; }
.thread-token-usage, .thread-cost { flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.thread-token-usage[hidden], .thread-cost[hidden] { display: none; }
@container thread-row (max-width: 260px) {
  .thread-project-threads .agent-thread .thread-token-usage { font-size: 0; }
  .thread-token-usage::after { content: attr(data-compact); font-size: 10px; }
}
@container thread-row (max-width: 190px) { .thread-token-usage { display: none; } }
.thread-state-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-thread-row[data-state="running"] .thread-state-label,
.agent-thread-row[data-state="idle"][data-unread="true"] .thread-state-label,
.agent-thread-row[data-state="failed"] .thread-state-label { color: var(--text); font-weight: 600; }
.agent-thread strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
.local-session strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.agent-thread span, .local-session span { color: var(--muted); font-size: 9px; }
.agent-thread small, .local-session small { overflow-wrap: anywhere; color: var(--quiet); font: 8px/1.45 var(--font-code); white-space: normal; }
.agent-list-empty { padding: 28px 14px; color: var(--muted); text-align: center; font-size: 10px; }
.import-card > button { width: 100%; margin-top: 9px; }
.session-filters { display: grid; grid-template-columns: minmax(130px, .6fr) minmax(130px, .6fr) minmax(220px, 1.4fr); gap: 10px; }
.local-session-list { max-height: min(58vh, 680px); margin-top: 12px; border-top: 1px solid var(--line); }
.local-session { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.local-session > div { display: grid; gap: 3px; min-width: 0; }
.local-session button { padding: 5px 7px; }
progress { width: 100%; accent-color: var(--accent); }
.conversation-card { --conversation-overlay-height: 48px; --conversation-inline-start: 24px; --conversation-inline-end: 24px; --conversation-scrollbar-width: 0px; display: grid; grid-template-areas: "conversation-head" "conversation-notice" "conversation-scroll" "conversation-composer"; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; min-width: 0; width: 100%; height: 100%; min-height: 0; overflow: hidden; background: var(--canvas); }
/* Only the navigation button floats over the reading surface. */
.conversation-head { position: relative; grid-area: conversation-head; z-index: 3; justify-self: start; align-self: start; display: flex; margin: 6px 0 0 9px; }
.drawer-toggle, .conversation-menu-toggle, .conversation-details-toggle { background: var(--glass-header); box-shadow: inset 0 1px var(--glass-highlight); backdrop-filter: var(--glass-header-filter); -webkit-backdrop-filter: var(--glass-header-filter); }
#conversationConnection { margin: 0; padding: 4px 2px; color: var(--warning); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.conversation-card > .workspace-notice { grid-area: conversation-notice; z-index: 3; margin: 8px 16px 0; }
.conversation-notices { grid-area: conversation-notice; z-index: 3; display: flex; flex-direction: column; min-width: 0; }
.conversation-notices > .workspace-notice { margin: 8px 16px 0; }
.conversation-compatibility { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.conversation-compatibility[hidden] { display: none; }
.conversation-scroll { grid-area: 1 / 1 / 4 / 2; min-height: 0; overflow-y: auto; overflow-x: hidden; overflow-anchor: none; overscroll-behavior: contain; scrollbar-gutter: stable; scroll-padding-top: calc(var(--conversation-overlay-height) + 8px); padding: calc(var(--conversation-overlay-height) + 16px) var(--conversation-inline-end) 0 var(--conversation-inline-start); display: flex; flex-direction: column; background: var(--canvas); }
.conversation-trace { display: flex; flex: 1 0 auto; flex-direction: column; gap: 10px; width: min(100%, 808px); margin: 0 auto; padding: 0 0 10px; }
.conversation-empty { margin: auto; padding: 36px; color: var(--muted); text-align: center; font-size: 12px; }
.trace-card{flex:0 0 auto;align-self:center;width:min(100%,808px);max-width:808px;overflow:visible;background:transparent}
.trace-card.user { align-self: flex-end; width: auto; max-width: min(87%, 680px); }
.trace-card.compaction { margin-block: -3px; padding: 0; color: var(--muted); text-align: center; font-size: 11px; }
.trace-card.compaction .trace-body { padding: 0; color: var(--muted); font: 11px/1.4 var(--font-ui); }
.trace-card.assistant { align-self: center; }
.trace-card.image figure { margin: 0; min-height: 48px; }
.trace-card.image .trace-image-preview { display: block; width: fit-content; max-width: 100%; margin: 0; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.trace-card.image img { display: block; max-width: 100%; max-height: min(180px, 28dvh); width: auto; height: auto; border-radius: 4px; }
.trace-card.image img[hidden], .trace-card.image [hidden] { display: none; }
.trace-card.image figcaption { margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; color: var(--muted); font: 11px/1.5 var(--font-ui); }
.trace-image-status { color: var(--muted); font: 12px/1.5 var(--font-ui); }
.trace-card.image button { margin-left: 8px; }
.conversation-trace > :not(.user) + .trace-card.user, .conversation-trace > .trace-card.user + :not(.user) { margin-top: 6px; }
.trace-card.tool, .trace-card.reasoning, .trace-card.system, .trace-card.error { width: min(100%, 808px); }
.trace-card.system { padding: 8px 11px; border-left: 2px solid var(--line); background: var(--surface); }
.trace-card.error { padding: 8px 11px; border-left: 2px solid var(--danger); background: var(--danger-soft); }
.trace-dismiss { margin-top: 6px; padding: 3px 7px; font-size: 12px; }
.trace-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; margin-bottom: 4px; }
.trace-kind { color: var(--muted); font-size: 11px; font-weight: 500; }
.trace-status { color: var(--quiet); font-size: 12px; line-height: 16px; }
.trace-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; flex: none; }
.trace-copy { display: inline-grid; place-items: center; width: 28px; min-width: 28px; min-height: 28px; padding: 0; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--muted); }
.trace-copy svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.25; }
.trace-copy:hover { background: var(--hover); color: var(--accent); }
.trace-copy:disabled { cursor: wait; opacity: .5; }
.trace-footer { display: flex; align-items: center; gap: 7px; min-height: 22px; margin-top: 2px; color: var(--quiet); font-size: 12px; line-height: 16px; font-variant-numeric: tabular-nums; }
.trace-footer .trace-copy { position: relative; width: 24px; min-width: 24px; min-height: 24px; margin-left: -3px; }
.trace-completed:not([hidden]) + .trace-elapsed:not([hidden])::before,
.trace-completed:not([hidden]) + .trace-cost:not([hidden])::before,
.trace-elapsed:not([hidden]) + .trace-cost:not([hidden])::before { margin-right: 8px; content: "·"; }
.trace-body { margin: 0; overflow: visible; overflow-wrap: anywhere; color: var(--text); font: 12px/1.6 var(--font-code); white-space: pre-wrap; }
.trace-card.user .trace-body { padding: 8px 12px; border-radius: 7px; background: var(--accent-soft); font: 14px/1.6 var(--font-ui); line-height: calc(1.6em + 1px); }
.trace-card.assistant .trace-body { font: 15px/1.6 var(--font-ui); line-height: calc(1.6em + 1px); }
.trace-card.system .trace-head, .trace-card.error .trace-head { margin-bottom: 2px; }
.trace-card-empty .trace-head { margin-bottom: 0; }
.trace-detail > .trace-head { margin: 0; padding: 3px 8px; cursor: pointer; list-style: none; }
.trace-detail > .trace-head::-webkit-details-marker { display: none; }
.trace-detail > .trace-head .trace-kind { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 13px; line-height: 15px; }
.trace-detail > .trace-head .trace-kind::before { display: inline-block; margin-right: 7px; color: var(--accent); content: "›"; }
.trace-detail[open] > .trace-head .trace-kind::before { transform: rotate(90deg); }
.trace-detail[open] > .trace-head { border-bottom: 1px solid var(--line); }
.trace-detail .trace-body { padding: 7px 10px; background: var(--surface-code); font-size: 10px; }
.trace-card.reasoning { border-left: 2px solid var(--line); }
.trace-card.reasoning .trace-detail > .trace-head { padding-left: 10px; }
.trace-card.reasoning .trace-kind { font-weight: 500; }
.trace-card.activity-failed { border-left-color: var(--danger); }
.trace-card.activity-failed .trace-kind { color: var(--danger); }
.markdown-body { white-space: normal; }
.trace-body.markdown-body { overflow-wrap: anywhere; white-space: normal; font-family: var(--font-ui); }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 9px; white-space: pre-wrap; }
.markdown-body ul, .markdown-body ol { margin: 6px 0 10px; padding-left: 23px; }
.markdown-body li { margin: 2px 0; padding-left: 2px; }
.markdown-body li::marker { color: var(--muted); }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 18px 0 8px; color: var(--text); line-height: 1.4; font-family: var(--font-ui); font-weight: 600; }
.markdown-body h1 { font-size: 22px; }
.markdown-body h2 { font-size: 20px; }
.markdown-body h3 { font-size: 17px; }
.markdown-body h4 { font-size: 15px; }
.markdown-body :not(pre) > code { padding: 1px 4px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); color: var(--text); font: .86em/1.5 var(--font-code); }
.markdown-body pre { margin: 10px 0; padding: 12px; overflow: auto; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-code); white-space: pre; }
.markdown-body pre code { padding: 0; border: 0; background: transparent; color: inherit; font: 11px/1.55 var(--font-code); }
.markdown-body blockquote { margin: 10px 0; padding: 7px 12px; border-left: 2px solid var(--accent); background: var(--surface); color: var(--muted); }
.markdown-body a { color: var(--accent-hover); text-underline-offset: 2px; }
.markdown-body hr { margin: 14px 0; border: 0; border-top: 1px solid var(--line); }
.trace-table-scroll { width: max-content; max-width: 100%; margin: 10px 0; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-control); }
.trace-card.assistant > .markdown-body > .trace-table-scroll { max-width: var(--conversation-table-width, 100%); translate: min(0px, calc((min(808px, var(--conversation-table-width, 100%)) - 100%) / 2)) 0; }
.markdown-body table { width: max-content; margin: 0; border: 0; border-collapse: collapse; font-size: inherit; line-height: inherit; }
.markdown-body th, .markdown-body td { max-width: 34em; padding: 9px 11px; border: 0; border-bottom: 1px solid var(--line); text-align: left; white-space: normal; overflow-wrap: anywhere; }
.markdown-body th { position: static; background: var(--surface); color: var(--text); font-size: inherit; font-weight: 600; }
.history-loader{flex:0 0 auto;display:flex;align-items:center;justify-content:center;min-height:40px;padding:0 0 10px}
.history-load-status { color: var(--muted); font-size: 10px; }
.history-load-button { min-height: 30px; padding: 5px 11px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-raised); color: var(--accent-hover); font-size: 10px; }
.history-load-button:hover { background: var(--hover); }
.tool-group { flex: 0 0 auto; width: 100%; min-width: 0; margin: -3px 0; border: 0; background: transparent; }
.tool-group-summary { display: flex; align-items: center; gap: 10px; min-height: 24px; padding: 1px 0; cursor: pointer; list-style: none; color: var(--muted); white-space: nowrap; }
.tool-group-summary::-webkit-details-marker { display: none; }
.tool-group-total { display: flex; flex: none; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 500; }
.tool-group-total::before { color: var(--accent); font-size: 16px; content: "›"; }
.tool-group[open] .tool-group-total::before { transform: rotate(90deg); }
.tool-group-counts { flex: 0 1 auto; min-width: 0; max-width: 28%; overflow: hidden; text-overflow: ellipsis; font: 11px/1.4 var(--font-code); }
.tool-group-latest { flex: 1; min-width: 0; overflow: hidden; color: var(--muted); font-size: 13px; line-height: 16.5px; text-overflow: ellipsis; }
.tool-group-items{display:grid;gap:1px;padding:0;border-top:1px solid var(--line);background:var(--line)}
.tool-group .trace-card.tool { width: 100%; max-width: 100%; border-left: 0; background: var(--canvas); }
.has-running-tool { border-color: color-mix(in srgb, var(--accent) 38%, var(--line)); }
.has-running-tool .tool-group-latest { color: var(--accent-hover); }
.conversation-compose-area { grid-area: conversation-composer; min-width: 0; padding: 0 calc(var(--conversation-inline-end) + var(--conversation-scrollbar-width)) 0 var(--conversation-inline-start); }
.conversation-composer { position: relative; z-index: 4; width: min(100%, 808px); margin: 0 auto; padding: 4px 0 max(8px, env(safe-area-inset-bottom)); border: 0; background: var(--canvas); }
.conversation-progress { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 2px 6px; color: var(--muted); font-size: 10px; }
#conversationProgressText { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#conversationProgressTime { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.reply-spinner { width: 11px; height: 11px; flex: none; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: reply-spin 1s linear infinite; }
.activity-unknown .reply-spinner { animation: none; border-color: var(--muted); border-style: dotted; }
.conversation-drop-zone { border: 1px solid color-mix(in srgb, var(--input-border) 55%, var(--canvas)); border-radius: 8px; background: var(--canvas); box-shadow: 0 2px 8px rgb(22 34 52 / 4%); transition: border-color var(--motion-fast), box-shadow var(--motion-fast); }
.conversation-drop-zone.dragging { border-color: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent), 0 3px 12px rgb(22 34 52 / 5%); }
.conversation-drop-zone.dragging { background: var(--accent-soft); }
.composer-input-row { display: block; min-height: 42px; padding: 5px 10px 0; }
.composer-toolbar { display: flex; align-items: center; gap: 3px; min-width: 0; min-height: 40px; padding: 1px 4px 4px; }
.composer-choice { position: relative; min-width: 0; }
.composer-model-choice { flex: 0 1 auto; }
.composer-effort-choice { flex: none; }
.composer-choice-toggle { display: flex; align-items: center; gap: 4px; min-width: 0; height: 32px; padding: 4px 7px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--muted); font: 11px var(--font-ui); }
.composer-choice-toggle:hover:not(:disabled), .composer-choice-toggle[aria-expanded="true"] { background: var(--hover); color: var(--text); }
.composer-choice-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.composer-choice-toggle:disabled { color: var(--quiet); cursor: default; }
.composer-choice-toggle svg { flex: none; width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }
.composer-choice-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-model-choice .composer-choice-toggle { max-width: min(300px, 36vw); }
.composer-effort-choice .composer-choice-toggle { max-width: 150px; }
.composer-submit-slot { margin-left: auto; }
.composer-choice-menu { position: fixed; z-index: 90; inset: auto; width: min(360px, calc(100vw - 16px)); max-height: min(320px, calc(100dvh - 24px)); margin: 0; padding: 5px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-float); background: var(--glass); color: var(--text); box-shadow: var(--shadow-float); backdrop-filter: blur(14px) saturate(125%); -webkit-backdrop-filter: blur(14px) saturate(125%); }
.composer-effort-menu { width: min(280px, calc(100vw - 16px)); }
.composer-choice-option { position: relative; display: grid; gap: 2px; width: 100%; min-height: 38px; padding: 7px 28px 7px 9px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--text); text-align: left; }
.composer-choice-option:hover, .composer-choice-option:focus-visible { background: var(--hover); outline: 0; }
.composer-choice-option[aria-selected="true"] { background: var(--accent-soft); }
.composer-choice-option[aria-selected="true"]::after { position: absolute; top: 50%; right: 9px; color: var(--accent); font-size: 13px; content: "✓"; transform: translateY(-50%); }
.composer-choice-option strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.composer-choice-option small { overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.conversation-composer .conversation-drop-zone textarea { display: block; width: 100%; height: 36px; min-height: 36px; max-height: 144px; padding: 7px 0; resize: none; overflow-y: hidden; border: 0; background: transparent; box-shadow: none; font: 14px/22px var(--font-ui); }
.conversation-composer .conversation-drop-zone textarea:focus { outline: none; box-shadow: none; }
.composer-icon { display: inline-grid; place-items: center; width: 36px; min-width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 6px; }
.composer-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.composer-attach { border: 0; background: transparent; color: var(--muted); }
.composer-attach:hover { background: var(--hover); color: var(--accent); }
.composer-send { min-width: 36px; box-shadow: none; }
.composer-cancel { display: inline-grid; place-items: center; width: 24px; min-width: 24px; min-height: 24px; padding: 0; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--danger); font-size: 17px; }
.composer-cancel:hover { background: var(--danger-soft); }
.conversation-attachments { display: flex; flex-wrap: wrap; gap: 6px; max-height: 145px; padding: 7px 7px 1px; overflow: auto; }
.conversation-attachment { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 7px; max-width: 100%; padding: 6px 7px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); font-size: 9px; }
.attachment-kind { padding: 2px 5px; border-radius: 3px; background: var(--canvas); color: var(--muted); }
.attachment-name { max-width: 260px; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.conversation-attachment small { color: var(--muted); }
.attachment-remove { padding: 0 3px; border: 0; background: transparent; color: var(--muted); font-size: 15px; }
.attachment-remove:hover { color: var(--danger); }

/* File links and preview overlay */
.node-file-link, .node-file-code-link, .node-file-image-link { cursor: pointer; }
.node-file-link::after { font-size: .78em; text-decoration: none; content: " ↗"; }
.node-file-code-link { display: inline; padding: 0; border: 0; background: transparent; color: inherit; }
.node-file-code-link:hover code, .node-file-image-link:hover { border-color: var(--accent); color: var(--accent-hover); }
.node-file-image-link { display: inline-flex; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--accent-hover); }
.node-file-dialog { width: min(980px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-float); background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-float); }
.node-file-dialog::backdrop { background: rgb(24 38 56 / 22%); }
.node-file-dialog-shell { display: flex; flex-direction: column; min-height: 260px; max-height: calc(100dvh - 30px); }
.node-file-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 15px 17px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.node-file-dialog-head h2 { margin: 4px 0 3px; font-size: 18px; }
.node-file-dialog-head p:last-child { margin: 0; font-size: 9px; }
.node-file-loading, .node-file-unsupported { margin: auto; padding: 42px; color: var(--muted); text-align: center; font-size: 11px; }
.node-file-media { display: block; max-width: 100%; max-height: calc(100dvh - 190px); margin: auto; object-fit: contain; background: #1f2226; }
.node-file-audio { width: min(640px, calc(100% - 36px)); margin: auto; }
.node-file-frame { width: 100%; min-height: min(70dvh, 760px); border: 0; background: #fff; }
.node-file-text { min-height: 240px; margin: 0; padding: 17px; overflow: auto; background: var(--surface-code); color: var(--text); font: 11px/1.65 var(--font-code); overflow-wrap: anywhere; white-space: pre-wrap; }
.node-file-dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 13px; border-top: 1px solid var(--line); }
.node-file-dialog-actions > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 9px var(--font-code); }
.toast { position: fixed; z-index: 100; right: 18px; bottom: 18px; max-width: min(420px, calc(100vw - 36px)); padding: 9px 13px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--glass); box-shadow: var(--shadow-float); color: var(--text); font-size: 11px; backdrop-filter: blur(3px); animation: surface-in var(--motion-enter) var(--ease-out); }
@keyframes surface-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes reply-spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .brand-section { display: none; }
  .node-grid { grid-template-columns: 1fr; }
  .install-grid { grid-template-columns: 1fr; }
  .install-grid p, .install-grid pre { min-height: 0; }
  .enrollment { grid-template-columns: 1fr 110px 1fr auto; }
  .enrollment > :nth-child(4) { display: none; }
  .debug-layout { grid-template-columns: 190px minmax(0, 1fr); }
}
@media (min-width: 1100px) {
  .chat-shell.sidebar-open { grid-template-columns: var(--sidebar-width, 300px) minmax(0, 1fr); }
  .chat-drawer { position: relative; inset: auto; grid-area: 1 / 1; width: var(--sidebar-width, 300px); background: var(--surface); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; transition: none; }
  .chat-drawer:not(.open) { display: none; }
  .chat-drawer-backdrop { display: none; }
  .conversation-card { grid-row: 1; grid-column: -2 / -1; }
}
@media (max-width: 820px) {
  .topbar { padding: 0 12px; }
  .server-state { display: none; }
  .global-nav { margin-left: auto; }
  .topbar-action { margin-left: 6px; }
  .dashboard { padding: 24px 16px 52px; }
  .workspace { padding: 0 14px 20px; }
  .runtime-console { padding: 24px 16px 48px; }
  .workspace-bar { margin: 0 -14px; padding: 9px 14px; }
  .metrics, .workspace-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics article:nth-child(2), .workspace-metrics article:nth-child(2) { border-right: 0; }
  .metrics article:nth-child(-n+2), .workspace-metrics article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .overview-grid { grid-template-columns: 1fr; }
  .tool-card, .tool-card:nth-child(2n), .tool-card:nth-last-child(-n+2) { border-right: 0; border-bottom: 1px solid var(--line); }
  .tool-card:last-child { border-bottom: 0; }
  .file-layout { grid-template-columns: 1fr; }
  .file-list-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .runtime-grid { grid-template-columns: 1fr; }
  .session-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .session-search { grid-column: 1 / -1; }
  .debug-layout { grid-template-columns: 1fr; }
  .debug-tool-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .debug-tool-list { display: flex; overflow-x: auto; padding: 5px; }
  .debug-tool { min-width: 130px; border-bottom: 2px solid transparent; border-left: 0; }
  .debug-tool.active { border-bottom-color: var(--accent); border-left: 0; }
}
@media (max-width: 680px) {
  .topbar-action-label { display: none; }
  .topbar-action { width: 30px; padding: 4px; justify-content: center; }
  .topbar > #logoutButton { width: 30px; padding: 4px; overflow: hidden; font-size: 0; }
  .topbar > #logoutButton::before { font-size: 15px; content: "↪"; }
  .global-nav-item { min-width: 52px; padding: 0 8px; }
  .login-shell { grid-template-columns: 1fr; width: min(520px, calc(100% - 32px)); min-height: auto; padding: 48px 0; }
  .login-copy h1 { font-size: 42px; }
  .trust-line { gap: 9px 16px; margin-top: 25px; }
  .hero-row { flex-direction: column; }
  .hero-actions, .runtime-page-actions { width: 100%; }
  .hero-actions button, .runtime-page-actions button { flex: 1; }
  .runtime-page-head { flex-direction: column; }
  .runtime-page-head h1 { font-size: 25px; }
  .runtime-card { padding: 16px; }
  .session-filters { grid-template-columns: 1fr; }
  .session-search { grid-column: 1; }
  .panel:not(details) { padding: 15px; }
  .panel-head { flex-direction: column; }
  .enrollment { grid-template-columns: 1fr auto; gap: 10px; }
  .enrollment > :nth-child(3), .enrollment > :nth-child(4) { display: none; }
  .node-meta { grid-template-columns: 1fr; }
  .node-meta > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .node-meta > div:last-child { border-bottom: 0; }
  .workspace-bar { flex-wrap: wrap; }
  .workspace-identity { order: -1; width: 100%; }
  .workspace-tabs { gap: 16px; overflow-x: auto; }
  .workspace-tab { flex: none; }
  .file-list-head, .file-row { grid-template-columns: minmax(150px, 1fr) 80px; }
  .file-list-head > :last-child, .file-row > :last-child { display: none; }
  .shell-head, .debug-intro, .debug-card-head { flex-direction: column; }
  .terminal-output { min-height: 340px; height: 58vh; }
  .chat-drawer { width: min(340px, 92vw); }
  .conversation-card { --conversation-inline-start: 12px; --conversation-inline-end: 12px; height: 100%; min-height: 0; }
  .conversation-scroll { padding-top: calc(var(--conversation-overlay-height) + 12px); }
  .tool-group-counts { display: none; }
  .trace-card.user { max-width: 94%; }
  .trace-card, .trace-card.assistant, .trace-card.tool, .trace-card.reasoning, .trace-card.error, .tool-group { width: 100%; max-width: 100%; }
  .trace-card.assistant .trace-body { font-size: 14px; }
  .trace-copy { width: 40px; min-width: 40px; min-height: 40px; margin-left: -7px; }
  .trace-footer .trace-copy { width: 24px; min-width: 24px; min-height: 24px; margin-left: -3px; }
  .trace-footer .trace-copy::after { position: absolute; inset: -8px; content: ""; }
  .tool-group-counts { text-align: left; }
  .tool-group-latest { grid-column: 1; }
  .conversation-composer { padding: 4px 0 max(8px, env(safe-area-inset-bottom)); }
  .conversation-drop-zone { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 0 3px; padding: 3px; }
  .conversation-attachments { grid-column: 1 / -1; }
  .composer-input-row { grid-column: 2; grid-row: 2; align-self: center; min-width: 0; min-height: 40px; padding: 2px 0; }
  .composer-toolbar { display: contents; }
  .composer-choice { display: none; }
  .composer-attach { grid-column: 1; grid-row: 2; }
  .composer-submit-slot { grid-column: 3; grid-row: 2; margin-left: 0; }
  .composer-icon { width: 40px; min-width: 40px; height: 40px; min-height: 40px; }
  .attachment-name { max-width: 145px; }
  .debug-preset-fields { grid-template-columns: 1fr; }
  .debug-preset-field.wide, .debug-no-params { grid-column: 1; }
  .debug-call-actions { align-items: stretch; flex-direction: column; }
  .node-file-dialog { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
  .node-file-dialog-shell { max-height: calc(100dvh - 14px); }
  .node-file-dialog-actions { align-items: stretch; flex-direction: column; }
}
/* Installed/mobile shell: leave room for cutouts, gestures and the soft keyboard. */
.pwa-install-dialog { width: min(400px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-float); color: var(--text); background: var(--surface-raised); box-shadow: var(--shadow-float); }
.pwa-install-dialog::backdrop { background: rgb(18 31 47 / 30%); }
.pwa-install-dialog h2 { margin: 0 0 12px; font-size: 20px; }
.pwa-install-dialog p { margin: 0 0 20px; line-height: 1.7; color: var(--muted); }
.pwa-install-dialog button { min-height: 44px; }
@media (pointer: coarse) {
  html:has(body[data-view="agentView"]) { overscroll-behavior-y: none; }
  body[data-view="agentView"] { position: fixed; top: var(--app-viewport-top, 0px); width: 100%; height: var(--app-viewport-height, 100dvh); overscroll-behavior-y: none; }
  body[data-view="agentView"] > main { height: 100%; }
  .topbar { height: calc(var(--header-height) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .conversation-head { margin-top: calc(4px + env(safe-area-inset-top)); margin-left: max(9px, env(safe-area-inset-left)); }
  .chat-drawer { padding-left: env(safe-area-inset-left); }
  .chat-drawer-nav { min-height: calc(44px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  .chat-drawer-footer { padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .conversation-card { --conversation-inline-start: max(12px, env(safe-area-inset-left)); --conversation-inline-end: max(12px, env(safe-area-inset-right)); }
  .conversation-scroll { scrollbar-gutter: auto; }
  .chat-icon-button, .composer-icon { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .conversation-composer { padding-left: 0; padding-right: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (prefers-reduced-transparency: reduce) { .topbar, .workspace-bar, .drawer-toggle, .conversation-menu-toggle, .chat-drawer, .toast, .composer-choice-menu { background: var(--surface-raised); backdrop-filter: none; -webkit-backdrop-filter: none; } }
@media (forced-colors: active) { .topbar, .workspace-bar, .drawer-toggle, .conversation-menu-toggle, .chat-drawer, .toast, .node-file-dialog, .composer-choice-menu { background: Canvas; box-shadow: none; backdrop-filter: none; } .global-nav-item.active::after, .workspace-tab.active::after { background: Highlight; } .primary, .approve, .badge, .capabilities span, .trace-card.user .trace-body { border: 1px solid CanvasText; } }

/* Project navigation and conversation actions */
.chat-drawer-nav .chat-nav-link { min-height: 36px; font-size: 14px; }
.sidebar-new-thread { margin: 0; padding: 4px 8px; min-height: 36px; font-size: 12px; white-space: nowrap; }
.sidebar-account-toggle { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; width: 100%; min-height: 44px; padding: 4px 8px; border: 0; background: transparent; text-align: left; }
.sidebar-account-toggle:hover { background: var(--hover); }
.sidebar-account-toggle > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-account-summary-email] { font-size: 12px; font-weight: 600; }
[data-account-summary-remaining] { font-size: 11px; color: var(--muted); }
[data-account-summary-plan] { font-size: 10px; color: var(--accent); }
[data-account-summary-credits] { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar-popover { position: fixed; inset: auto; width: min(320px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); margin: 0; padding: 14px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-float); background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-float); }
.account-popover { width: min(460px, calc(100vw - 16px)); }
.account-history { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.account-history-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; }
.account-history-heading select { width: auto; min-height: 30px; padding: 3px 6px; font-size: 12px; }
.account-history-empty { display: grid; place-items: center; min-height: 110px; margin: 8px 0; color: var(--muted); font-size: 12px; text-align: center; }
.account-history-empty[hidden] { display: none; }
.quota-chart { display: block; width: 100%; height: auto; max-height: 180px; margin-top: 8px; overflow: visible; color: var(--muted); touch-action: pan-y; }
.quota-chart:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.quota-chart text { fill: currentColor; font-family: var(--font-ui); font-size: 16px; }
.quota-grid { stroke: var(--line); stroke-width: 1; }
.quota-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.quota-reference { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 5 4; opacity: .65; vector-effect: non-scaling-stroke; pointer-events: none; }
.quota-legend { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.quota-dot, .quota-marker { fill: var(--accent); }
.quota-marker { stroke: var(--surface-raised); stroke-width: 2; }
.quota-tooltip { pointer-events: none; }
.quota-tooltip rect { fill: var(--surface-raised); stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.quota-tooltip text { font-size: 18px; font-variant-numeric: tabular-nums; }
.quota-tooltip .quota-tooltip-value { fill: var(--text); font-size: 21px; font-weight: 600; }
@media (forced-colors: active) { .quota-line, .quota-grid, .quota-reference { stroke: CanvasText; } .quota-dot, .quota-marker { fill: Highlight; } }
.sidebar-popover-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; min-width: 0; font-size: 14px; }
.sidebar-popover-head > strong { min-width: 0; overflow-wrap: anywhere; }
.sidebar-popover-head .chat-icon-button { width: 28px; min-width: 28px; height: 28px; min-height: 28px; }
.sidebar-nav-menu { width: 210px; padding: 5px; }
.sidebar-nav-menu > button { display: block; width: 100%; min-height: 36px; padding: 8px 10px; border: 0; background: transparent; text-align: left; font-size: 13px; }
.sidebar-nav-menu > button:hover, .sidebar-nav-menu > button:focus-visible { background: var(--hover); }
.sidebar-nav-menu hr { margin: 5px; border: 0; border-top: 1px solid var(--line); }
.navigation-facts { margin: 0; font-size: 12px; }
.navigation-facts > div + div { margin-top: 16px; }
.navigation-facts dt { display: flex; align-items: center; justify-content: space-between; min-height: 24px; color: var(--muted); font-size: 11px; }
.navigation-facts dd { margin: 3px 0 0; line-height: 1.6; overflow-wrap: anywhere; user-select: text; }
.navigation-copy { margin: 0; padding: 2px 5px; min-height: 24px; font-size: 11px; }
.conversation-details { position: fixed; inset: 0 0 0 auto; width: min(340px, 88vw); max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; overflow: hidden; border: 0; border-left: 1px solid var(--line); border-radius: 0; background: var(--glass); color: var(--text); box-shadow: var(--shadow-float); backdrop-filter: blur(14px) saturate(125%); -webkit-backdrop-filter: blur(14px) saturate(125%); transform: translateX(100%); transition: transform var(--motion-enter) var(--ease-out); touch-action: pan-y pinch-zoom; }
.conversation-details[open] { display: flex; flex-direction: column; }
.conversation-details.revealed { transform: none; }
.conversation-details.details-dragging { transition: none; user-select: none; -webkit-user-select: none; }
.conversation-details-head { display: flex; align-items: center; justify-content: space-between; flex: none; min-height: 44px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.conversation-details-body { flex: 1; min-height: 0; padding: 16px; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y pinch-zoom; }
.conversation-details-settings { display: grid; gap: 8px; margin: 16px 0; }
.conversation-details-settings label { font-size: 12px; color: var(--muted); }
.conversation-details-settings select { width: 100%; min-width: 0; min-height: 44px; }
.conversation-details-settings p { margin: 0; }
.conversation-token-usage { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.conversation-token-usage h4 { margin: 0 0 12px; font-size: 13px; font-weight: 600; }
.conversation-token-usage .navigation-facts > div + div { margin-top: 12px; }
.conversation-token-usage dd { font-variant-numeric: tabular-nums; }
#conversationTokenUsageComponents:not([hidden]) { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.conversation-cost { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.conversation-cost > strong { display: block; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.conversation-cost > p, .conversation-cost > a { font-size: 11px; line-height: 1.6; }
.conversation-cost > p { margin: 8px 0; overflow-wrap: anywhere; }
.conversation-cost > p:empty { display: none; }
.conversation-details::backdrop { background: rgb(18 31 47 / 18%); opacity: 0; transition: opacity var(--motion-enter); touch-action: pan-y pinch-zoom; }
.conversation-details.revealed::backdrop { opacity: var(--details-shade, 1); }
.conversation-details.details-dragging::backdrop { transition: none; }
.conversation-details h3 { margin: 0 0 18px; font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.conversation-details-body > .muted { font-size: 12px; }
@media (min-width: 1100px) {
  .chat-shell.details-open { grid-template-columns: minmax(0, 1fr) 300px; }
  .chat-shell.sidebar-open.details-open { grid-template-columns: var(--sidebar-width, 300px) minmax(0, 1fr) 300px; }
  .chat-shell.details-open .conversation-card { grid-column: 1; }
  .chat-shell.sidebar-open.details-open .conversation-card { grid-column: 2; }
  .conversation-details[open] { position: relative; inset: auto; grid-row: 1; grid-column: -2 / -1; width: auto; height: 100%; min-height: 0; background: var(--surface); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; transform: none; transition: none; }
}
@media (max-width: 600px) {
  .sidebar-popover { inset: auto 8px max(8px, env(safe-area-inset-bottom)) !important; width: auto; margin: 0; max-height: min(76dvh, 720px); }
  .conversation-details { width: min(340px, 92vw); padding-right: env(safe-area-inset-right); }
  .conversation-details-head { min-height: calc(44px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  .conversation-details-body { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .sidebar-popover::backdrop { background: rgb(18 31 47 / 12%); }
}
@media (min-width: 1100px) and (hover: hover) and (pointer: fine) {
  .project-heading-actions { opacity: 0; pointer-events: none; }
  .thread-project-summary:hover .project-heading-actions, .thread-project-summary:focus-within .project-heading-actions { opacity: 1; pointer-events: auto; }
}
@media (max-width: 600px), (pointer: coarse) {
  .thread-project-summary { min-height: 44px !important; grid-template-columns: minmax(0, 1fr) auto auto 80px 8px !important; }
  .project-heading-actions .chat-icon-button { width: 40px !important; min-width: 40px !important; height: 44px !important; min-height: 44px !important; }
  .chat-drawer-nav .chat-nav-link, .sidebar-new-thread, .sidebar-nav-menu > button { min-height: 44px; }
  .sidebar-popover-head .chat-icon-button, .navigation-copy { min-height: 44px; min-width: 44px; }
  .conversation-details-head .chat-icon-button { min-height: 44px; min-width: 44px; }
}
.project-create-actions { display: flex; gap: 3px; }
.thread-browser .agent-side-head { align-items: center; padding-bottom: 12px; }
.thread-browser .agent-side-head h2 { margin: 0; }
.project-create-actions .ghost { margin: 0; min-height: 32px; }
.thread-project { min-width: 0; margin-bottom: 4px; }
.thread-project-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 56px 8px; align-items: center; gap: 4px; min-height: 36px; padding: 0 14px; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent); background: transparent; list-style: none; cursor: pointer; }
.thread-project-summary:hover { background: color-mix(in srgb, var(--hover) 60%, transparent); }
.thread-project-summary::-webkit-details-marker { display: none; }
.thread-project-summary::before { grid-area: 1 / 5; content: ""; width: 6px; height: 6px; margin: 0 3px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); }
.thread-project[open] > .thread-project-summary::before { transform: rotate(45deg); }
.thread-project-identity { grid-area: 1 / 1; display: grid; min-width: 0; }
.thread-project-identity strong { color: var(--accent-hover); font-size: 14px; font-weight: 650; }
.thread-project-identity > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-project-location { grid-area: 2 / 1 / auto / -1; display: flex; align-items: center; gap: 4px; min-width: 0; color: var(--muted); font-size: 10px; }
.thread-project-machine { max-width: 65px; font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-project-platform { flex: none; padding: 0 3px; border: 1px solid var(--line-strong); border-radius: 3px; font-size: 9px; line-height: 1.4; }
.thread-project-path { flex: 1; min-width: 0; overflow: hidden; direction: rtl; text-align: left; text-overflow: ellipsis; white-space: nowrap; }

.project-heading-actions { grid-column: 4; display: flex; }
.project-heading-actions .chat-icon-button { width: 28px; min-width: 28px; height: 28px; min-height: 28px; }
.thread-project-threads { margin: 4px 8px 6px; }
.thread-project-threads .agent-thread-row { position: relative; margin-block: 2px; border-radius: var(--radius-control); }
.thread-project-threads .agent-thread { min-height: 48px; padding-left: 8px; border-radius: var(--radius-control); }
.thread-project-threads .agent-thread span { font-size: 10px; }
.thread-project-empty { margin: 0; padding: 10px 9px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.thread-project-history { margin-top: 4px; }
.thread-project-history-summary { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 32px; padding: 0 8px; border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); border-radius: 0 0 var(--radius-control) var(--radius-control); color: var(--muted); font-size: 11px; list-style: none; cursor: pointer; }
.thread-project-history-summary:hover { color: var(--text); background: color-mix(in srgb, var(--hover) 60%, transparent); }
.thread-project-history-summary::-webkit-details-marker { display: none; }
.thread-project-history-summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translate(-1px, -1px); }
.thread-project-history[open] > .thread-project-history-summary::before { transform: rotate(225deg) translate(-1px, -1px); }
.thread-project-history[open] > .thread-project-history-summary { border-radius: 0; }
.thread-project-history-threads { margin-top: 2px; }
.thread-page-more { display: block; width: 100%; min-height: 32px; margin: 4px 0; color: var(--muted); font-size: 11px; }
.thread-subagents { min-width: 0; margin: 0 0 4px 8px; }
.thread-subagents-summary { display: flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 6px; border-radius: var(--radius-control); color: var(--muted); font-size: 11px; list-style: none; cursor: pointer; }
.thread-subagents-summary::-webkit-details-marker { display: none; }
.thread-subagents-summary::before { content: ""; flex: none; width: 5px; height: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); }
.thread-subagents[open] > .thread-subagents-summary::before { transform: rotate(45deg); }
.thread-subagents-summary:hover { color: var(--text); background: var(--hover); }
.thread-subagents-label { flex: none; }
.thread-subagents-activity { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 10px; }
.thread-subagent-threads { min-width: 0; padding-left: 7px; border-left: 1px solid var(--line-strong); }
.thread-subagent-threads .thread-subagent-threads .thread-subagents { margin-left: 0; }
@media (max-width: 600px), (pointer: coarse) {
  .thread-subagents-summary { min-height: 44px; }
}
.thread-menu-toggle { position: absolute; z-index: 1; right: 3px; top: 1px; width: 30px; height: 27px; margin: 0; border: 0; border-radius: 0 var(--radius-control) 0 0; background: var(--thread-row-background); }
.thread-menu-toggle::before { content: ""; position: absolute; pointer-events: none; right: 100%; top: 0; bottom: 0; width: 24px; background: linear-gradient(to right, transparent, var(--thread-row-background)); }
.thread-menu-toggle:hover { background: var(--thread-row-background); color: var(--accent); }
.sidebar-resize { display: none; position: absolute; z-index: 34; top: 0; bottom: 0; left: calc(var(--sidebar-width, 300px) - 3px); width: 6px; cursor: col-resize; touch-action: none; }
.sidebar-resize:hover, .sidebar-resize:focus-visible, .sidebar-resizing .sidebar-resize { background: var(--accent); opacity: .6; }
.sidebar-resizing, .sidebar-resizing * { cursor: col-resize !important; user-select: none !important; }
@media (min-width: 1100px) { .sidebar-open .sidebar-resize { display: block; } }
@media (hover: hover) and (pointer: fine) {
  .agent-thread-row .thread-menu-toggle { opacity: 0; pointer-events: none; }
  .agent-thread-row:hover .thread-menu-toggle, .agent-thread-row:focus-within .thread-menu-toggle { opacity: 1; pointer-events: auto; }
}
.conversation-menu-toggle { grid-area: conversation-head; justify-self: end; align-self: start; z-index: 3; margin: 6px 9px 0 0; }
.conversation-details-toggle { grid-area: conversation-head; justify-self: end; align-self: start; z-index: 3; margin: 6px 51px 0 0; }
.conversation-details-toggle[aria-expanded="true"] { color: var(--accent); }
@media (display-mode: standalone) {
  .conversation-menu-toggle, .conversation-details-toggle { margin-top: calc(4px + env(safe-area-inset-top)); }
}
@media (prefers-reduced-transparency: reduce) {
  .conversation-details, .conversation-details-toggle { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .thread-project-summary:hover { background: var(--hover); }
}
@media (forced-colors: active) {
  .conversation-details, .conversation-details-toggle { background: Canvas; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .thread-project-summary, .thread-project-history-summary { border-color: CanvasText; }
}
.composer-submit-slot { display: grid; place-items: center; }
.composer-stop { appearance: none; border: 0; box-shadow: none; color: var(--text); background: transparent; }
.composer-stop:hover { background: var(--hover); }
.composer-stop svg { fill: currentColor; stroke: none; }
.thread-options-menu { position: fixed; inset: auto; width: 194px; margin: 0; padding: 5px; border: 1px solid var(--line); border-radius: var(--radius-control); color: var(--text); background: var(--surface-raised); box-shadow: var(--shadow-float); }
.thread-options-menu .thread-delete-action { color: var(--danger); }
.thread-options-menu > * { display: block; width: 100%; min-height: 36px; padding: 8px 10px; border: 0; border-radius: var(--radius-control); color: var(--text); background: transparent; font-size: 13px; text-align: left; text-decoration: none; }
.thread-options-menu > *:hover, .thread-options-menu > *:focus-visible { background: var(--hover); }
.chat-edit-dialog { width: min(420px, calc(100% - 28px)); max-height: calc(100dvh - 28px); padding: 20px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-control); color: var(--text); background: var(--surface-raised); box-shadow: var(--shadow-float); }
.chat-edit-dialog::backdrop { background: rgb(18 31 47 / 25%); }
.chat-edit-dialog h2 { margin: 0 0 18px; font-size: 18px; }
.chat-edit-dialog label { display: block; margin: 12px 0 6px; font-size: 12px; }
.chat-edit-dialog input, .chat-edit-dialog select, .chat-edit-dialog textarea { width: 100%; min-height: 40px; }
.chat-edit-dialog textarea { padding: 9px 10px; resize: vertical; font: 11px/1.5 var(--font-code); }
.chat-edit-dialog p { font-size: 12px; }
.chat-edit-error { color: var(--danger); }
.chat-edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@media (pointer: coarse) {
  .conversation-menu-toggle { margin-top: calc(4px + env(safe-area-inset-top)); margin-right: max(9px, env(safe-area-inset-right)); }
  .thread-options-menu > *, .chat-edit-actions button, .project-create-actions .ghost { min-height: 44px; }
}

.conversation-draft-status { display: block; min-height: 1em; font-size: 11px; color: var(--muted); }
.conversation-draft-status:empty { display: none; }
.conversation-draft-status.draft-error { color: var(--danger); }

#forkProgress, #resumeProgress { display: flex; align-items: center; flex-wrap: wrap; gap: 0.65rem; }
#forkProgress.hidden, #resumeProgress.hidden { display: none; }
#forkProgressBar, #resumeProgressBar { width: 9rem; max-width: 100%; accent-color: var(--accent); }
#resumeProgressText { min-width: 0; font-variant-numeric: tabular-nums; }
#resumeProgressCancel { flex: none; }

/* Diagrams share the conversation reading surface; wide graphs scroll locally. */
.markdown-body .trace-diagram { margin: 16px 0; min-width: 0; }
.trace-diagram-preview { max-width: 100%; overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-raised); }
.markdown-body .trace-diagram-preview img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.markdown-body .trace-diagram-expanded img { max-width: none; }
.trace-diagram-zoom { float: right; margin-top: 6px; padding: 0 4px; background: transparent; color: var(--muted); border: 0; font-size: 12px; }
.trace-diagram-preview:empty ~ .trace-diagram-zoom { display: none; }
.trace-diagram-preview:empty { display: none; }
.trace-diagram details { margin-top: 6px; }
.trace-diagram summary { width: fit-content; color: var(--muted); cursor: pointer; font-size: 12px; }
.trace-diagram-status { color: var(--muted); font-size: 12px; }

.codex-accounts-list { border-top: 1px solid var(--line); }
.codex-account-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 16px; width: 100%; padding: 14px 4px; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.codex-account-row:hover { background: var(--hover); }
.codex-account-row > span { min-width: 0; overflow-wrap: anywhere; }
.codex-account-row strong, .codex-account-row small { display: block; }
.codex-account-row small { color: var(--muted); margin-top: 4px; }
.codex-account-dialog { width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 24px; color: var(--text); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-float); }
.codex-account-dialog form { display: grid; gap: 12px; }
.codex-account-dialog label { display: grid; gap: 5px; }
.codex-account-dialog details > label { margin-top: 12px; }
.codex-account-dialog .actions { flex-wrap: wrap; }
.codex-account-dialog [hidden] { display: none; }
.composer-account-choice { max-width: 155px; min-width: 60px; }
.composer-account-choice select { padding: 5px; width: 100%; border: 0; color: var(--muted); background-color: transparent; font-size: 12px; text-overflow: ellipsis; }
@media (max-width: 640px) {
  .codex-account-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .codex-account-row > span:last-child { grid-column: 1 / -1; font-size: 12px; }
  .codex-accounts-panel .panel-head { align-items: start; flex-wrap: wrap; gap: 12px; }
  .codex-accounts-panel .actions { flex-wrap: wrap; }
  .composer-account-choice { max-width: 92px; }
}
