:root {
  color-scheme: dark;
  --bg: #090b0d;
  --panel: #101316;
  --panel-2: #15191d;
  --panel-3: #1b2025;
  --line: #262c32;
  --line-soft: #1d2227;
  --text: #f0f3f5;
  --muted: #8e989f;
  --muted-2: #657079;
  --accent: #9df5c4;
  --accent-strong: #65e9a0;
  --blue: #84b9ff;
  --amber: #ffc66d;
  --danger: #ff8b8b;
  --radius: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
  overflow: hidden;
}

button, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: .65rem .9rem;
  background: var(--accent);
  color: #07120c;
  border-radius: 6px;
}
.skip-link:focus { top: 1rem; }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(480px, 1fr) 360px;
  grid-template-rows: 58px 1fr;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #0c0f11;
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 760; letter-spacing: .08em; font-size: .9rem; }
.brand-section { color: var(--muted-2); font-weight: 550; }
.brand-mark { width: 23px; height: 23px; display: grid; gap: 2px; align-content: end; }
.brand-mark i { display: block; height: 4px; background: var(--accent); border-radius: 1px; }
.brand-mark i:nth-child(1) { width: 9px; }
.brand-mark i:nth-child(2) { width: 16px; }
.brand-mark i:nth-child(3) { width: 23px; }

.topbar-status { display: flex; align-items: center; gap: 10px; font-size: .78rem; }
.status-chip, .usage-chip { border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; color: var(--muted); }
.status-chip { display: flex; align-items: center; gap: 7px; }
.usage-chip b { color: var(--accent); }
.pulse-dot, .connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-strong); box-shadow: 0 0 0 3px rgba(101,233,160,.11); }
.avatar-stack { display: flex; margin-left: 3px; }
.avatar-stack span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--panel-3); border: 2px solid #0c0f11; font-size: .68rem; font-weight: 750; }
.avatar-stack span + span { margin-left: -7px; color: var(--blue); }

.sidebar, .inspector { min-height: 0; background: var(--panel); }
.sidebar { border-right: 1px solid var(--line); padding: 14px 12px; display: flex; flex-direction: column; overflow-y: auto; }
.inspector { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }

.new-task-button { width: 100%; display: flex; align-items: center; gap: 8px; border: 1px solid #3d4d44; background: #17221c; color: var(--accent); padding: 10px 11px; border-radius: 7px; font-weight: 700; }
.new-task-button kbd { margin-left: auto; color: #88a293; background: #0f1612; border: 1px solid #2a3b31; border-radius: 4px; padding: 1px 6px; font-size: .68rem; }

.primary-nav { display: grid; gap: 3px; margin-top: 15px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 10px; color: var(--muted); border: 0; background: transparent; padding: 9px 10px; border-radius: 6px; text-align: left; font-size: .87rem; }
.nav-item:hover, .nav-item.active { background: var(--panel-2); color: var(--text); }
.nav-icon { width: 19px; color: var(--muted-2); text-align: center; }
.nav-count { margin-left: auto; background: var(--panel-3); border-radius: 999px; min-width: 23px; padding: 1px 6px; text-align: center; font-size: .7rem; }

.sidebar-section { margin-top: 24px; }
.agent-section { min-height: 0; }
.section-label-row, .budget-heading, .review-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-label { margin: 0 0 8px; color: var(--muted-2); letter-spacing: .12em; font-size: .68rem; font-weight: 750; }
.icon-button { color: var(--muted-2); background: none; border: 0; padding: 3px; }

.project-card { width: 100%; display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); background: var(--panel-2); padding: 9px; border-radius: 7px; text-align: left; color: var(--text); }
.project-card.active { border-color: #35423c; }
.project-glyph { width: 34px; height: 34px; display: grid; place-items: center; background: #233229; color: var(--accent); border-radius: 6px; font-size: .72rem; font-weight: 800; }
.project-card strong, .project-card small { display: block; }
.project-card strong { font-size: .84rem; }
.project-card small { color: var(--muted-2); font-size: .7rem; margin-top: 1px; }

.agent-list { display: grid; gap: 2px; }
.agent-row { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 6px; color: var(--muted); font-size: .82rem; }
.agent-row.active { background: var(--panel-2); color: var(--text); }
.agent-token { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; font-size: .63rem; font-weight: 800; color: var(--blue); }
.agent-row.active .agent-token { color: var(--accent); border-color: #385047; }
.agent-state { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: #3c454c; }
.agent-row.active .agent-state { background: var(--accent-strong); }

.budget-card { margin-top: auto; border: 1px solid var(--line); border-radius: 8px; padding: 11px; background: #0d1012; }
.budget-heading { color: var(--muted); font-size: .72rem; }
.budget-heading strong { color: var(--text); }
.budget-track { height: 4px; margin-top: 9px; background: #252b30; border-radius: 3px; overflow: hidden; }
.budget-track span { display: block; width: 0%; height: 100%; background: var(--accent-strong); transition: width .3s ease; }
.budget-card p { margin: 7px 0 0; color: var(--muted-2); font-size: .67rem; }
.budget-card p b { color: var(--muted); }

.workspace { min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.workspace-header { min-height: 82px; display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; border-bottom: 1px solid var(--line-soft); }
.eyebrow-row { display: flex; gap: 7px; color: var(--muted-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .7rem; }
h1 { margin: 5px 0 0; font-size: 1.08rem; line-height: 1.25; letter-spacing: -.01em; }
.workspace-actions { display: flex; align-items: center; gap: 8px; }
.quiet-button { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 6px; padding: 8px 10px; font-size: .77rem; }
.model-button { display: flex; align-items: center; gap: 8px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; text-align: left; }
.model-mark { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 6px; background: #252b34; color: var(--blue); font-weight: 800; }
.model-button small, .model-button b { display: block; }
.model-button small { color: var(--muted-2); font-size: .61rem; }
.model-button b { font-size: .72rem; }

.mode-banner { margin: 14px 22px 0; display: flex; align-items: center; gap: 9px; border: 1px solid #3e4733; border-radius: 7px; padding: 8px 10px; color: #b8c1aa; background: #171a12; font-size: .76rem; }
.mode-banner strong { color: #e3ebce; }
.mode-banner button { margin-left: auto; background: none; border: 0; color: #8f987f; font-size: 1.2rem; line-height: 1; }
.mode-icon { color: var(--amber); }

.conversation { flex: 1; overflow-y: auto; padding: 22px; scrollbar-color: #30363c transparent; }
.message { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 11px; max-width: 760px; margin: 0 auto 24px; }
.message-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 7px; background: var(--panel-3); color: var(--blue); font-size: .66rem; font-weight: 800; border: 1px solid var(--line); }
.message-avatar.lead { color: var(--accent); background: #16221b; border-color: #2c4337; }
.message-avatar.user { color: #f0d2ff; background: #281d2d; border-color: #45304d; }
.message-meta { display: flex; align-items: center; gap: 9px; margin: 2px 0 6px; font-size: .78rem; }
.message-meta span { color: var(--muted-2); font-size: .68rem; }
.message-body p { margin: 0; color: #c7ced3; font-size: .91rem; line-height: 1.62; }
.capability-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.capability-row span { border: 1px solid var(--line); border-radius: 4px; padding: 3px 7px; color: var(--muted); font-size: .67rem; }
.task-progress { margin-top: 13px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.progress-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--line-soft); font-size: .76rem; color: var(--muted); }
.progress-item:last-child { border-bottom: 0; }
.progress-item.complete { color: #c5d5cb; }
.progress-mark { width: 17px; color: var(--accent); text-align: center; }

.composer { margin: 0 22px 20px; border: 1px solid #343b42; border-radius: 10px; background: var(--panel); box-shadow: 0 16px 48px rgba(0,0,0,.22); }
.composer:focus-within { border-color: #4c6559; }
.composer-topline { display: flex; justify-content: space-between; padding: 10px 12px 0; color: var(--muted-2); font-size: .68rem; }
.composer-topline label { color: var(--muted); font-weight: 700; }
.composer textarea { width: 100%; min-height: 78px; resize: vertical; border: 0; outline: 0; background: transparent; color: var(--text); padding: 8px 12px; line-height: 1.5; }
.composer textarea::placeholder { color: #586168; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line-soft); padding: 8px; }
.composer-options { display: flex; align-items: center; gap: 7px; }
.select-label { color: var(--muted-2); font-size: .69rem; }
.composer select { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 5px; padding: 5px 24px 5px 7px; font-size: .7rem; }
.safety-label { display: flex; align-items: center; gap: 6px; color: var(--muted-2); font-size: .67rem; }
.safety-label span { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.run-button { border: 0; background: var(--accent); color: #07120c; border-radius: 6px; padding: 8px 12px; font-weight: 780; font-size: .76rem; }
.run-button:hover { background: var(--accent-strong); }
.run-button:disabled { opacity: .45; cursor: wait; }

.inspector-tabs { min-height: 47px; display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); padding: 0 10px; }
.inspector-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted-2); font-size: .73rem; }
.inspector-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.inspector-panel { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.empty-state { min-height: 320px; display: grid; place-content: center; text-align: center; padding: 30px; }
.empty-glyph { width: 43px; height: 43px; display: grid; place-items: center; margin: 0 auto 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted-2); background: var(--panel-2); }
.empty-state h2 { margin: 0; font-size: .88rem; }
.empty-state p { margin: 7px auto 0; color: var(--muted-2); font-size: .74rem; max-width: 220px; }
.hidden { display: none !important; }
.review-heading { margin-bottom: 10px; }
.review-heading > div { display: flex; gap: 7px; align-items: center; min-width: 0; }
.review-heading strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-status { width: 19px; height: 19px; display: grid; place-items: center; border-radius: 4px; background: #473914; color: var(--amber); font-size: .62rem; font-weight: 800; }
.review-state { color: var(--amber); font-size: .55rem; letter-spacing: .07em; }
.diff-view { max-height: 360px; overflow: auto; margin: 0; border: 1px solid var(--line); border-radius: 7px; padding: 10px; background: #0b0e10; color: #bad3c5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .68rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.risk-note { margin-top: 10px; border: 1px solid #354139; background: #121913; border-radius: 7px; padding: 9px 10px; }
.risk-note strong { color: var(--accent); font-size: .7rem; }
.risk-note p { margin: 3px 0 0; color: #8d9b92; font-size: .68rem; }
.approval-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 7px; margin-top: 11px; }
.approval-actions button { border-radius: 6px; padding: 8px; font-size: .72rem; font-weight: 700; }
.reject-button { border: 1px solid #4b3030; color: var(--danger); background: #1b1212; }
.approve-button { border: 1px solid var(--accent); color: #07120c; background: var(--accent); }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { display: grid; grid-template-columns: 12px 1fr; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.activity-list strong, .activity-list small { display: block; }
.activity-list strong { font-size: .75rem; }
.activity-list small { color: var(--muted-2); font-size: .66rem; margin-top: 2px; }
.activity-dot { width: 7px; height: 7px; border: 1px solid var(--muted-2); border-radius: 50%; margin-top: 5px; }
.activity-dot.complete { background: var(--accent); border-color: var(--accent); }
.activity-dot.active { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255,198,109,.1); }
.context-card { border: 1px solid var(--line); border-radius: 8px; padding: 11px; margin-bottom: 10px; background: #0d1012; }
.context-card dl { margin: 0; }
.context-card dl div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: .72rem; }
.context-card dl div:last-child { border: 0; }
.context-card dt { color: var(--muted); }
.context-card dd { margin: 0; color: var(--text); }
.context-card > strong, .context-card > small { display: block; }
.context-card > strong { font-size: .76rem; }
.context-card > small { color: var(--muted-2); font-size: .67rem; margin-top: 4px; }
.inspector-footer { min-height: 42px; display: flex; align-items: center; gap: 7px; border-top: 1px solid var(--line); padding: 0 14px; color: var(--muted-2); font-size: .66rem; }
.inspector-footer #latency-label { margin-left: auto; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 50; display: grid; gap: 8px; }
.toast { width: min(340px, calc(100vw - 36px)); border: 1px solid var(--line); border-left: 3px solid var(--accent); background: #151a1d; border-radius: 7px; padding: 10px 12px; box-shadow: 0 12px 35px rgba(0,0,0,.35); font-size: .78rem; animation: toast-in .18s ease-out; }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 220px 1fr; }
  .inspector { position: fixed; right: 0; top: 58px; bottom: 0; width: 350px; box-shadow: -18px 0 50px rgba(0,0,0,.35); transform: translateX(calc(100% - 8px)); transition: transform .2s ease; z-index: 20; }
  .inspector:focus-within, .inspector:hover { transform: translateX(0); }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-shell { min-height: 100vh; height: auto; grid-template-columns: 1fr; grid-template-rows: 58px auto 1fr; }
  .topbar-status .status-chip, .usage-chip { display: none; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 9px 12px; }
  .primary-nav, .sidebar-section, .budget-card { display: none; }
  .new-task-button { max-width: 210px; }
  .workspace { min-height: calc(100vh - 112px); }
  .workspace-header { padding: 12px 14px; }
  .model-button, .quiet-button { display: none; }
  .mode-banner, .composer { margin-left: 12px; margin-right: 12px; }
  .conversation { padding: 18px 12px; }
  .composer-footer { align-items: flex-end; }
  .composer-options { align-items: flex-start; flex-direction: column; }
  .safety-label { display: none; }
  .inspector { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
