:root {
  color-scheme: dark;
  --bg: #080b12;
  --rail: #0b0e15;
  --sidebar: #0e121b;
  --surface: #111620;
  --surface-2: #151b27;
  --surface-3: #1a2230;
  --surface-hover: #1d2634;
  --border: #222b3a;
  --border-strong: #303b4e;
  --text: #eef2f8;
  --text-secondary: #a3adbd;
  --text-muted: #727e91;
  --primary: #6c8cff;
  --primary-soft: rgba(108, 140, 255, .13);
  --success: #36d399;
  --success-soft: rgba(54, 211, 153, .12);
  --warning: #f6bd55;
  --warning-soft: rgba(246, 189, 85, .12);
  --danger: #f07178;
  --danger-soft: rgba(240, 113, 120, .12);
  --violet: #a78bfa;
  --shadow: 0 24px 72px rgba(0, 0, 0, .4);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --rail-width: 68px;
  --task-width: 260px;
  --context-width: 332px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --rail: #ffffff;
  --sidebar: #f8f9fc;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #eef2f7;
  --surface-hover: #edf2f8;
  --border: #e0e5ed;
  --border-strong: #cbd3df;
  --text: #172033;
  --text-secondary: #536074;
  --text-muted: #7e8999;
  --primary: #506fe0;
  --primary-soft: rgba(80, 111, 224, .10);
  --success: #159a69;
  --success-soft: rgba(21, 154, 105, .10);
  --warning: #c78316;
  --warning-soft: rgba(199, 131, 22, .10);
  --danger: #d34f59;
  --danger-soft: rgba(211, 79, 89, .09);
  --violet: #7c5fe0;
  --shadow: 0 20px 56px rgba(31, 45, 73, .16);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, textarea { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 2000; padding: 10px 16px; border-radius: 8px; background: var(--text); color: var(--bg); text-decoration: none; transition: top .2s ease; }
.skip-link:focus { top: 12px; }

.workbench-shell { display: grid; grid-template-columns: var(--rail-width) var(--task-width) minmax(520px, 1fr) var(--context-width); height: 100dvh; min-height: 0; }

.activity-rail { position: relative; z-index: 30; display: flex; flex-direction: column; align-items: center; padding: 12px 8px; border-right: 1px solid var(--border); background: var(--rail); }
.product-mark { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 11px; background: linear-gradient(145deg, #7391ff, #5268d9); color: #fff; box-shadow: 0 8px 24px rgba(91, 117, 230, .28); }
.product-mark svg { width: 24px; height: 24px; stroke-width: 1.8; }
.rail-nav, .rail-bottom { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.rail-bottom { margin-top: auto; }
.rail-button, .icon-button, .composer-icon { position: relative; width: 48px; height: 50px; display: grid; place-items: center; padding: 4px 0 3px; border: 0; border-radius: 9px; background: transparent; color: var(--text-muted); cursor: pointer; text-decoration: none; transition: color .18s ease, background-color .18s ease; }
.rail-button { grid-template-rows: 25px 13px; }
.rail-button svg { width: 19px; height: 19px; }
.rail-label { font-size: 9px; line-height: 1; }
.rail-button:hover, .icon-button:hover, .composer-icon:hover { background: var(--surface-hover); color: var(--text); }
.rail-button.is-active { background: var(--primary-soft); color: var(--primary); }
.rail-indicator { position: absolute; left: -10px; top: 9px; bottom: 9px; width: 2px; border-radius: 2px; background: var(--primary); }
.rail-badge { position: absolute; right: 3px; top: 2px; min-width: 15px; height: 15px; padding: 0 4px; border: 2px solid var(--rail); border-radius: 8px; background: var(--danger); color: #fff; font-size: 9px; line-height: 11px; font-weight: 700; }
.user-avatar { width: 44px; height: 44px; padding: 0; border: 1px solid var(--border-strong); border-radius: 50%; background: linear-gradient(145deg, var(--surface-3), var(--surface)); color: var(--text-secondary); font-size: 11px; font-weight: 700; cursor: pointer; }
.sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: block; }

.task-sidebar { position: relative; z-index: 20; display: flex; min-width: 0; flex-direction: column; overflow: hidden; border-right: 1px solid var(--border); background: var(--sidebar); }
.workspace-picker { height: 67px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: inherit; cursor: pointer; text-decoration: none; }
.workspace-picker:hover { background: var(--surface-hover); }
.workspace-picker > svg { width: 16px; margin-left: auto; color: var(--text-muted); }
.workspace-icon { width: 32px; height: 32px; display: grid; flex: 0 0 auto; place-items: center; border: 1px solid rgba(108,140,255,.4); border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.workspace-icon svg { width: 18px; height: 18px; stroke-width: 1.9; }
.workspace-picker strong, .workspace-picker small { display: block; }
.workspace-picker strong { font-size: 13px; }
.workspace-picker small { margin-top: 1px; color: var(--text-muted); font-size: 11px; }
.new-task-button { min-height: 44px; display: flex; align-items: center; gap: 8px; margin: 14px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.new-task-button:hover { border-color: var(--primary); background: var(--primary-soft); }
.new-task-button svg { width: 16px; }
.new-task-button kbd { margin-left: auto; padding: 2px 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); color: var(--text-muted); font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.sidebar-section { padding: 4px 8px 12px; }
.section-label { height: 30px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; color: var(--text-muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.section-count { min-width: 18px; padding: 1px 5px; border-radius: 8px; background: var(--surface-3); text-align: center; }
.task-item { width: 100%; min-height: 54px; display: flex; align-items: flex-start; gap: 9px; padding: 9px 8px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; transition: background-color .18s ease; }
.task-item:hover { background: var(--surface-hover); }
.task-item.is-active { background: var(--primary-soft); }
.task-status { width: 7px; height: 7px; flex: 0 0 auto; margin-top: 6px; border-radius: 50%; }
.status-running { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.status-warning { background: var(--warning); }
.status-success { background: var(--success); }
.status-muted { border: 1px solid var(--text-muted); }
.task-copy { min-width: 0; flex: 1; }
.task-copy strong, .task-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-copy strong { color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.task-item.is-active .task-copy strong { color: var(--text); }
.task-copy small { margin-top: 3px; color: var(--text-muted); font-size: 10px; }
.task-count { min-width: 17px; height: 17px; margin-top: 1px; border-radius: 8px; background: var(--warning); color: #241b08; font-size: 9px; font-weight: 800; line-height: 17px; text-align: center; }
.task-history { overflow-y: auto; }
.agent-runtime { width: calc(100% - 24px); margin: auto 12px 12px; padding: 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: inherit; font-size: 10px; text-align: left; cursor: pointer; }
.agent-runtime:hover { border-color: var(--primary); background: var(--surface-hover); }
.agent-runtime.needs-attention { border-color: rgba(246,189,85,.55); }
.runtime-head, .runtime-row { display: flex; align-items: center; }
.runtime-head { gap: 6px; padding-bottom: 9px; border-bottom: 1px solid var(--border); }
.runtime-head strong { font-size: 11px; }
.runtime-head > span:last-child { margin-left: auto; color: var(--success); }
.live-dot { width: 6px; height: 6px; display: inline-block; flex: 0 0 auto; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.runtime-row { justify-content: space-between; margin-top: 8px; color: var(--text-muted); }
.runtime-row span:last-child { color: var(--text-secondary); }
.permission-chip { padding: 1px 6px; border-radius: 5px; background: var(--warning-soft); color: var(--warning) !important; }
.runtime-cta { display: block; margin-top: 10px; color: var(--primary); font-size: 9px; }

.agent-workspace { min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.workspace-header { height: 67px; display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px 0 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 94%, transparent); }
.title-group, .header-actions { display: flex; align-items: center; gap: 8px; }
.eyebrow { margin-bottom: 2px; color: var(--text-muted); font-size: 10px; }
.workspace-header h1 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 6px; border-radius: 5px; color: var(--primary); background: var(--primary-soft); font-size: 9px; font-weight: 700; }
.status-pill > span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.outline-button, .ghost-button, .primary-button, .text-button, .mode-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 12px; border-radius: 7px; font-size: 11px; font-weight: 600; cursor: pointer; transition: background .18s ease, border-color .18s ease, opacity .18s ease; }
.outline-button, .ghost-button { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-secondary); }
.outline-button:hover, .ghost-button:hover { border-color: var(--primary); color: var(--text); }
.outline-button svg, .primary-button svg { width: 16px; }
.primary-button { border: 1px solid var(--primary); background: var(--primary); color: #fff; box-shadow: 0 6px 18px rgba(83,111,224,.22); }
.primary-button:hover { filter: brightness(1.08); }
.primary-button:disabled { border-color: var(--border-strong); background: var(--surface-3); color: var(--text-muted); box-shadow: none; cursor: not-allowed; }
.outline-button:disabled, .ghost-button:disabled, .send-button:disabled { opacity: .45; cursor: not-allowed; }
.text-button { min-height: 44px; padding: 0 5px; border: 0; background: transparent; color: var(--primary); }
.text-button:hover { text-decoration: underline; }
.mobile-menu { display: none; width: 44px; height: 44px; place-items: center; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); }

.conversation-scroll { min-height: 0; flex: 1; overflow-y: auto; scrollbar-color: var(--border-strong) transparent; }
.conversation { width: min(820px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 34px; }
.goal-card { display: flex; align-items: center; gap: 13px; margin-bottom: 28px; padding: 13px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.goal-icon { width: 36px; height: 36px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.goal-icon svg { width: 18px; }
.goal-copy { min-width: 0; flex: 1; }
.goal-copy > span { color: var(--text-muted); font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.goal-copy h2 { margin: 2px 0; font-size: 13px; font-weight: 650; }
.goal-copy p { margin: 0; overflow: hidden; color: var(--text-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.message { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; margin: 0 0 25px; }
.message-avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; font-size: 10px; font-weight: 700; }
.message-avatar.user { border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-secondary); }
.message-avatar.agent { background: linear-gradient(145deg, #6e8fff, #5368d2); color: #fff; }
.message-avatar.agent svg { width: 18px; }
.message-body { min-width: 0; padding-top: 2px; }
.message-meta { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.message-meta strong { font-size: 12px; }
.message-meta time { margin-left: auto; color: var(--text-muted); font-size: 9px; }
.agent-label { padding: 2px 6px; border-radius: 4px; background: var(--primary-soft); color: var(--primary); font-size: 9px; }
.message-body > p { margin: 0 0 14px; color: var(--text-secondary); font-size: 12px; line-height: 1.75; }

.tool-stack { margin: 15px 0 17px; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.tool-call { min-height: 43px; display: grid; grid-template-columns: 21px minmax(0, 1fr) auto 24px; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.tool-call:last-child { border-bottom: 0; }
.tool-status { width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%; background: var(--success-soft); color: var(--success); }
.tool-status svg { width: 12px; height: 12px; stroke-width: 2.5; }
.tool-call strong, .tool-call small { display: block; }
.tool-call strong { color: var(--text-secondary); font-size: 10px; font-weight: 600; }
.tool-call small { margin-top: 1px; color: var(--text-muted); font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; }
.tool-time { color: var(--text-muted); font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; }
.tool-call button { width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--text-muted); cursor: pointer; }
.tool-call button:hover { background: var(--surface-hover); color: var(--text); }
.tool-call button svg { width: 13px; }

.proposal-card { margin-top: 18px; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 10px 35px rgba(0,0,0,.12); }
.proposal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 17px 18px 14px; }
.proposal-kicker { display: flex; align-items: center; gap: 7px; color: var(--success); font-size: 9px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.proposal-header h3 { margin: 6px 0 3px; font-size: 16px; letter-spacing: -.02em; }
.proposal-header p { margin: 0; color: var(--text-muted); font-size: 10px; }
.risk-label { padding: 4px 8px; border: 1px solid rgba(54,211,153,.28); border-radius: 6px; background: var(--success-soft); color: var(--success); font-size: 9px; font-weight: 700; white-space: nowrap; }
.impact-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 18px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.impact-item { min-width: 0; padding: 11px 12px; border-right: 1px solid var(--border); }
.impact-item:last-child { border-right: 0; }
.impact-item span, .impact-item strong, .impact-item small { display: block; }
.impact-item span { color: var(--text-muted); font-size: 9px; }
.impact-item strong { margin: 4px 0 2px; font: 650 15px ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.impact-item small { color: var(--text-muted); font-size: 8px; }
.positive { color: var(--success) !important; }
.negative { color: var(--danger) !important; }
.allocation-table { margin: 0 18px 14px; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; }
.allocation-row { min-height: 38px; display: grid; grid-template-columns: minmax(190px, 1.5fr) repeat(3, minmax(72px, .65fr)); align-items: center; padding: 0 12px; border-bottom: 1px solid var(--border); color: var(--text-secondary); font-size: 9px; }
.allocation-row:last-child { border-bottom: 0; }
.allocation-row.table-head { min-height: 31px; background: var(--surface-2); color: var(--text-muted); font-size: 8px; font-weight: 700; text-transform: uppercase; }
.allocation-row strong { font: 600 9px ui-monospace, SFMono-Regular, Menlo, monospace; }
.channel-dot { width: 6px; height: 6px; display: inline-block; margin-right: 7px; border-radius: 50%; vertical-align: 1px; }
.muted-dot { background: var(--text-muted); }
.blue-dot { background: var(--primary); }
.violet-dot { background: var(--violet); }
.guardrail-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 18px 15px; padding: 10px 11px; border: 1px solid rgba(246,189,85,.22); border-radius: 8px; background: var(--warning-soft); }
.guardrail-copy { display: flex; align-items: center; gap: 9px; }
.guardrail-copy > svg { width: 18px; flex: 0 0 auto; color: var(--warning); }
.guardrail-copy strong, .guardrail-copy small { display: block; }
.guardrail-copy strong { color: var(--warning); font-size: 9px; }
.guardrail-copy small { margin-top: 2px; color: var(--text-secondary); font-size: 8px; }
.proposal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.proposal-card.is-executed { border-color: rgba(54,211,153,.4); }
.proposal-card.is-executed .proposal-actions { justify-content: space-between; }
.executed-label { display: flex; align-items: center; gap: 7px; color: var(--success); font-size: 10px; font-weight: 700; }
.executed-label svg { width: 16px; }

.suggestion-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 4px 0 0 46px; }
.suggestion-row button { min-height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 16px; background: transparent; color: var(--text-muted); font-size: 9px; cursor: pointer; transition: border-color .18s ease, color .18s ease; }
.suggestion-row button:hover { border-color: var(--primary); color: var(--primary); }

.composer-wrap { flex: 0 0 auto; padding: 10px 20px 11px; background: linear-gradient(to bottom, transparent, var(--bg) 15%); }
.composer { width: min(820px, 100%); margin: 0 auto; padding: 10px 10px 8px 13px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); box-shadow: 0 10px 34px rgba(0,0,0,.18); transition: border-color .18s ease, box-shadow .18s ease; }
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), 0 10px 34px rgba(0,0,0,.18); }
.composer textarea { width: 100%; min-height: 25px; max-height: 120px; display: block; resize: none; overflow-y: auto; padding: 2px 0 7px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; line-height: 1.5; }
.composer textarea::placeholder { color: var(--text-muted); }
.composer-toolbar, .composer-left { display: flex; align-items: center; }
.composer-toolbar { justify-content: space-between; }
.composer-left { gap: 5px; }
.composer-icon { width: 29px; height: 29px; }
.composer-icon svg { width: 15px; }
.mode-button { min-height: 28px; padding: 0 8px; border: 0; background: var(--surface-2); color: var(--text-secondary); font-size: 9px; }
.mode-button svg { width: 12px; }
.context-usage { padding-left: 7px; color: var(--text-muted); font-size: 8px; }
.send-button { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: var(--primary); color: #fff; cursor: pointer; }
.send-button:hover { filter: brightness(1.08); }
.send-button svg { width: 16px; }
.composer-hint { margin: 5px auto 0; color: var(--text-muted); font-size: 8px; text-align: center; }

.context-panel { min-width: 0; overflow-y: auto; border-left: 1px solid var(--border); background: var(--sidebar); scrollbar-color: var(--border-strong) transparent; }
.context-header { min-height: 67px; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 10px 16px; border-bottom: 1px solid var(--border); }
.context-header span, .context-header strong { display: block; }
.context-header span { color: var(--text-muted); font-size: 9px; text-transform: uppercase; letter-spacing: .07em; }
.context-header strong { margin-top: 3px; font-size: 11px; }
.context-close { display: none; }
.icon-button.compact { width: 30px; height: 30px; }
.icon-button.compact svg { width: 15px; }
.context-section { position: relative; padding: 15px 16px; border-bottom: 1px solid var(--border); }
.context-label { color: var(--text-muted); font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.account-select { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 10px; margin-top: 9px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); text-align: left; cursor: pointer; }
.account-select:hover { border-color: var(--border-strong); }
.account-select > svg { width: 14px; margin-left: auto; color: var(--text-muted); }
.account-select strong, .account-select small { display: block; }
.account-select strong { font-size: 11px; }
.account-select small { margin-top: 2px; color: var(--text-muted); font-size: 8px; }
.tiktok-mark { width: 30px; height: 30px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 7px; background: #090b10; color: #fff; font-size: 12px; font-weight: 800; box-shadow: inset -2px 0 #eb466d, inset 2px 0 #38e8e2; }
.account-menu { position: absolute; z-index: 80; left: 16px; right: 16px; top: 82px; display: none; max-height: 220px; overflow-y: auto; padding: 5px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); }
.account-menu.is-open { display: block; }
.account-option { width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; }
.account-option:hover { background: var(--surface-hover); }
.account-option strong, .account-option small { display: block; }
.account-option strong { font-size: 10px; }
.account-option small { color: var(--text-muted); font-size: 8px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-heading > div small { display: block; margin-top: 2px; color: var(--text-muted); font-size: 8px; }
.metric-list { margin-top: 10px; }
.metric-row { min-height: 31px; display: grid; grid-template-columns: 1fr auto 46px; align-items: center; padding: 0 6px; border-radius: 5px; font-size: 9px; }
.metric-row.highlighted { background: var(--danger-soft); }
.metric-row span { color: var(--text-muted); }
.metric-row strong { font: 600 10px ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.metric-row small { text-align: right; color: var(--text-muted); font-size: 8px; }
.spark-chart { margin-top: 13px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.chart-head { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 8px; }
.legend { display: flex; align-items: center; gap: 4px; }
.legend i { width: 9px; height: 2px; display: inline-block; background: var(--primary); }
.legend i:nth-of-type(2) { margin-left: 4px; background: var(--warning); }
.spark-chart > svg { width: 100%; height: 80px; margin-top: 6px; overflow: visible; }
.grid-line { fill: none; stroke: var(--border); stroke-width: 1; }
.target-line { fill: none; stroke: var(--warning); stroke-dasharray: 4 4; stroke-width: 1; }
.chart-area { fill: url(#areaGradient); stroke: none; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-point { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.axis-labels { display: flex; justify-content: space-between; color: var(--text-muted); font: 7px ui-monospace, SFMono-Regular, Menlo, monospace; }
.source-count { padding: 2px 6px; border-radius: 5px; background: var(--surface-3); color: var(--text-muted); font-size: 8px; }
.evidence-list { margin-top: 9px; }
.evidence-list button { width: 100%; min-height: 43px; display: grid; grid-template-columns: 28px 1fr 15px; align-items: center; gap: 9px; padding: 5px 3px; border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; }
.evidence-list button:hover { background: var(--surface-hover); }
.evidence-list button > svg { width: 13px; color: var(--text-muted); }
.evidence-list strong, .evidence-list small { display: block; }
.evidence-list strong { font-size: 9px; }
.evidence-list small { margin-top: 2px; color: var(--text-muted); font-size: 8px; }
.evidence-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; }
.evidence-icon svg { width: 14px; }
.evidence-icon.data { background: var(--primary-soft); color: var(--primary); }
.evidence-icon.history { background: var(--success-soft); color: var(--success); }
.evidence-icon.rule { background: var(--warning-soft); color: var(--warning); }
.plugin-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.plugin-chips span { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text-secondary); font-size: 8px; }
.plugin-status { width: 5px; height: 5px; border-radius: 50%; background: var(--success); }

.modal-backdrop { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(2, 5, 10, .72); backdrop-filter: blur(5px); }
.modal-backdrop[hidden] { display: none; }
.approval-modal { width: min(460px, 100%); padding: 22px; border: 1px solid var(--border-strong); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); }
.modal-icon { width: 40px; height: 40px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 10px; background: var(--warning-soft); color: var(--warning); }
.modal-copy h2 { margin: 7px 0 6px; font-size: 19px; }
.modal-copy p { margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.65; }
.approval-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 18px 0; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: var(--border); }
.approval-summary div { padding: 10px; background: var(--surface-2); }
.approval-summary span, .approval-summary strong { display: block; }
.approval-summary span { color: var(--text-muted); font-size: 8px; }
.approval-summary strong { margin-top: 3px; font-size: 10px; }
.confirm-check { min-height: 42px; display: flex; align-items: center; gap: 9px; padding: 9px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-secondary); font-size: 10px; cursor: pointer; }
.confirm-check[hidden] { display: none; }
.confirm-check input { width: 16px; height: 16px; accent-color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast-region { position: fixed; z-index: 1500; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.toast { min-width: 280px; display: flex; align-items: center; gap: 9px; padding: 11px 13px; border: 1px solid rgba(54,211,153,.35); border-radius: 9px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: 10px; animation: toast-in .25s ease-out; }
.toast svg { width: 16px; color: var(--success); }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }

@media (max-width: 1280px) {
  :root { --task-width: 238px; --context-width: 300px; }
  .conversation { width: min(760px, calc(100% - 32px)); }
  .impact-grid { grid-template-columns: repeat(2, 1fr); }
  .impact-item:nth-child(2) { border-right: 0; }
  .impact-item:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 1080px) {
  .workbench-shell { grid-template-columns: var(--rail-width) var(--task-width) minmax(480px, 1fr); }
  .context-panel { position: fixed; z-index: 50; top: 0; right: 0; bottom: 0; width: min(340px, calc(100vw - 60px)); box-shadow: var(--shadow); transform: translateX(100%); transition: transform .22s ease; }
  .context-panel.is-open { transform: translateX(0); }
}
@media (max-width: 820px) {
  body { overflow: hidden; }
  .workbench-shell { grid-template-columns: var(--rail-width) minmax(0, 1fr); }
  .task-sidebar { position: fixed; z-index: 70; top: 0; bottom: 0; left: var(--rail-width); width: min(280px, calc(100vw - var(--rail-width))); box-shadow: var(--shadow); transform: translateX(calc(-100% - var(--rail-width))); transition: transform .22s ease; }
  .task-sidebar.is-open { transform: translateX(0); }
  .mobile-menu { display: grid; }
  .outline-button { width: 44px; padding: 0; font-size: 0; }
  .conversation { width: calc(100% - 24px); padding-top: 16px; }
  .workspace-header { padding: 0 12px; }
  .goal-copy p { white-space: normal; }
  .allocation-row { grid-template-columns: minmax(150px, 1.5fr) repeat(3, minmax(58px, .65fr)); overflow-x: auto; }
}
@media (max-width: 560px) {
  :root { --rail-width: 52px; }
  .activity-rail { padding-inline: 5px; }
  .product-mark, .rail-button { width: 44px; height: 44px; }
  .workspace-header h1 { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-actions .icon-button:first-child { display: none; }
  .goal-card { align-items: flex-start; }
  .goal-card > .text-button { display: none; }
  .message { grid-template-columns: 28px minmax(0, 1fr); gap: 8px; }
  .message-avatar { width: 28px; height: 28px; }
  .suggestion-row { margin-left: 36px; }
  .proposal-header { padding: 14px; }
  .impact-grid, .allocation-table, .guardrail-row { margin-left: 14px; margin-right: 14px; }
  .allocation-table { overflow-x: auto; }
  .allocation-row { min-width: 510px; }
  .guardrail-row { align-items: flex-start; }
  .guardrail-row > .text-button { display: none; }
  .proposal-actions { padding: 11px 14px; }
  .composer-wrap { padding: 8px; }
  .context-usage { display: none; }
  .approval-summary { grid-template-columns: 1fr; }
}

/* API-driven workbench states and controls. */
select, input { font: inherit; color: inherit; }
.page-state { min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 36px 20px; text-align: center; }
.page-state.compact { min-height: 220px; }
.page-state h2 { margin: 14px 0 8px; font-size: 18px; }
.page-state p { max-width: 540px; margin: 0 0 18px; color: var(--text-secondary); line-height: 1.7; }
.state-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; background: var(--primary-soft); color: var(--primary); }
.state-icon.danger { background: var(--danger-soft); color: var(--danger); }
.state-icon svg { width: 25px; height: 25px; }
.sidebar-skeleton, .metric-skeleton, .conversation-skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: skeleton 1.2s ease-in-out infinite; }
.sidebar-skeleton { height: 150px; margin: 8px; }
.metric-skeleton { height: 110px; }
.conversation-skeleton { height: 420px; }
@keyframes skeleton { to { background-position: -200% 0; } }
.context-control { width: 100%; min-height: 44px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; outline: 0; background: var(--surface-2); color: var(--text); font-size: 11px; }
.context-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.context-control:disabled { opacity: .55; cursor: not-allowed; }
.date-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.date-grid label > span, .field-label { display: block; color: var(--text-secondary); font-size: 10px; }
.date-grid label > span { margin-bottom: 5px; }
.field-label > .context-control { margin-top: 6px; }
.full-width { width: 100%; margin-top: 10px; }
.empty-compact { padding: 18px 8px; color: var(--text-muted); font-size: 10px; text-align: center; }
.inline-error { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px; border: 1px solid rgba(240,113,120,.35); border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 10px; }
.inline-error.block { align-items: flex-start; flex-direction: column; margin: 16px 0; }
.inline-error button { min-height: 44px; border: 0; background: transparent; color: inherit; text-decoration: underline; cursor: pointer; }
.entities-section { min-height: 0; display: flex; flex: 1; flex-direction: column; overflow: hidden; }
.entity-tabs { display: grid; grid-template-columns: repeat(3,1fr); gap: 3px; padding: 3px; border-radius: 7px; background: var(--surface-2); }
.entity-tabs button { min-height: 44px; padding: 0 4px; border: 0; border-radius: 5px; background: transparent; color: var(--text-muted); font-size: 9px; cursor: pointer; }
.entity-tabs button.is-active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.entity-list { min-height: 0; margin-top: 8px; overflow-y: auto; }
.entity-item { padding: 10px 2px; border-bottom: 1px solid var(--border); }
.entity-item > div strong, .entity-item > div small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-item > div strong { font-size: 10px; }
.entity-item > div small { margin-top: 2px; color: var(--text-muted); font-size: 8px; }
.entity-item dl { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; margin: 8px 0 0; }
.entity-item dl div { padding: 5px; border-radius: 5px; background: var(--surface-2); }
.entity-item dt { color: var(--text-muted); font-size: 7px; }
.entity-item dd { margin: 2px 0 0; font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.trace-section { margin: 10px 0 22px 46px; }
.proposal-details { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 18px 14px; }
.proposal-details > div { padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.proposal-details strong { font-size: 9px; }
.proposal-details p { margin: 4px 0 0; color: var(--text-muted); font-size: 8px; line-height: 1.6; }
.danger-button { border-color: rgba(240,113,120,.35); color: var(--danger); }
.monitor-chip { padding: 5px 8px; border-radius: 6px; background: var(--warning-soft); color: var(--warning); font-size: 9px; }
.agent-progress { display: flex; align-items: center; gap: 12px; margin: 18px 0; padding: 14px; border: 1px solid var(--primary); border-radius: 10px; background: var(--primary-soft); }
.agent-progress strong, .agent-progress small { display: block; }
.agent-progress small { margin-top: 3px; color: var(--text-muted); font-size: 9px; }
.progress-spinner { width: 18px; height: 18px; display: inline-block; flex: 0 0 auto; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.progress-spinner.small { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.workbench-dialog { width: min(520px, calc(100vw - 24px)); max-height: min(760px, calc(100dvh - 24px)); padding: 0; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.workbench-dialog::backdrop { background: rgba(2,5,10,.72); backdrop-filter: blur(4px); }
.trace-dialog { width: min(760px, calc(100vw - 24px)); }
.dialog-header { min-height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.dialog-header span { color: var(--text-muted); font-size: 9px; text-transform: uppercase; }
.dialog-header h2 { margin: 2px 0 0; font-size: 16px; }
.dialog-body { max-height: calc(100dvh - 190px); padding: 18px; overflow-y: auto; }
.dialog-body > .field-label + .field-label { margin-top: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.form-error { min-height: 18px; margin: 10px 0 0; color: var(--danger); font-size: 10px; }
.event-list article { display: grid; grid-template-columns: 12px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.event-dot { width: 8px; height: 8px; margin-top: 5px; border: 2px solid var(--primary); border-radius: 50%; }
.event-list strong, .event-list small { display: block; }
.event-list small { margin-top: 2px; color: var(--text-muted); font-size: 9px; }
.event-list pre { max-height: 180px; overflow: auto; margin: 7px 0 0; padding: 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-secondary); font: 9px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.plugin-overview { padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.plugin-overview p { margin: 3px 0; color: var(--text-secondary); font-size: 10px; }
.allowlist-section { margin-top: 16px; }
.allowlist-section h3 { margin: 0 0 8px; font-size: 11px; color: var(--text-primary); }
.allowlist-section > p { margin: 8px 0 0; color: var(--text-tertiary); font-size: 9px; }
.runtime-tool-list { display: flex; flex-wrap: wrap; gap: 6px; }
.runtime-tool-list code { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-raised); color: var(--accent); font-size: 9px; }
.plugin-list article { display: grid; grid-template-columns: 38px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.plugin-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.plugin-list strong { font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.plugin-list p { margin: 3px 0; color: var(--text-secondary); font-size: 9px; }
.plugin-list small { color: var(--warning); font-size: 8px; }
.toast.error { border-color: rgba(240,113,120,.45); }
.toast.success { border-color: rgba(54,211,153,.45); }

.state-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.state-actions a, .dialog-actions a { text-decoration: none; }
.onboarding-state { min-height: 460px; }
.onboarding-grid { width: min(680px, 100%); display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; text-align: left; }
.onboarding-grid > a, .onboarding-grid > button { min-height: 92px; display: flex; flex-direction: column; justify-content: center; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: inherit; cursor: pointer; text-decoration: none; transition: border-color .18s ease, background .18s ease; }
.onboarding-grid > a:hover, .onboarding-grid > button:hover { border-color: var(--primary); background: var(--primary-soft); }
.onboarding-grid strong { font-size: 12px; }
.onboarding-grid span { margin-top: 5px; color: var(--text-muted); font-size: 10px; line-height: 1.5; }
.runtime-dialog { width: min(680px, calc(100vw - 24px)); }
.runtime-status-card { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.runtime-status-card.success { border-color: rgba(54,211,153,.35); }
.runtime-status-card.warning { border-color: rgba(246,189,85,.4); }
.runtime-status-card span, .runtime-status-card strong { display: block; }
.runtime-status-card span { color: var(--text-muted); font-size: 10px; }
.runtime-status-card strong { margin-top: 4px; font-size: 15px; }
.runtime-status-card p { margin: 5px 0 0; color: var(--text-secondary); font-size: 11px; }
.config-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 14px 0; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: var(--border); }
.config-facts div { min-width: 0; padding: 10px; background: var(--surface-2); }
.config-facts dt { color: var(--text-muted); font-size: 9px; }
.config-facts dd { margin: 3px 0 0; overflow-wrap: anywhere; color: var(--text-secondary); font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.config-steps { padding: 12px; border: 1px solid var(--border); border-radius: 9px; }
.config-steps h3 { margin: 0 0 8px; font-size: 12px; }
.config-steps ol { margin: 0; padding-left: 20px; color: var(--text-secondary); font-size: 11px; line-height: 1.7; }
.config-steps code, .security-notice code { padding: 1px 4px; border-radius: 4px; background: var(--surface-3); color: var(--primary); font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.security-notice { margin-top: 14px; padding: 12px; border: 1px solid rgba(246,189,85,.3); border-radius: 9px; background: var(--warning-soft); }
.security-notice strong { font-size: 11px; }
.security-notice p { margin: 5px 0 0; color: var(--text-secondary); font-size: 11px; line-height: 1.65; }
.decision-note { min-height: 84px; margin-top: 6px; padding: 9px 10px; resize: vertical; }
.drawer-scrim { position: fixed; z-index: 60; inset: 0; border: 0; background: rgba(2,5,10,.62); }
.drawer-scrim[hidden] { display: none; }

@media (max-width: 1080px) {
  .agent-workspace { padding-right: 0; }
  .context-panel { z-index: 70; }
  .context-close { display: grid; }
}
@media (max-width: 820px) {
  .context-panel { display: flex; flex-direction: column; }
  .proposal-details { grid-template-columns: 1fr; }
  .proposal-actions { flex-wrap: wrap; }
  .proposal-actions > button { min-height: 44px; }
  .trace-section { margin-left: 36px; }
  .onboarding-grid { grid-template-columns: 1fr; }
  .onboarding-grid > a, .onboarding-grid > button { min-height: 72px; }
}
@media (max-width: 560px) {
  .date-grid { grid-template-columns: 1fr; }
  .impact-grid { grid-template-columns: 1fr 1fr; }
  .workbench-dialog { max-height: calc(100dvh - 12px); }
  .dialog-body { max-height: calc(100dvh - 170px); }
  .config-facts { grid-template-columns: 1fr; }
  .toast-region { left: 8px; right: 8px; bottom: 8px; }
  .toast { min-width: 0; width: 100%; }
}
