:root {
  color-scheme: light dark;
  --bg: #fff;
  --panel: #fff;
  --text: #111;
  --muted: #666;
  --weak: #777;
  --line: #ddd;
  --soft-line: #eee;
  --soft: #f7f7f7;
  --code: #f4f4f4;
  --own: #f1fbf2;
  --active-bg: #111;
  --active-text: #fff;
  --danger: #d00;
  --danger-soft: #d002;
  --offline-glow: #d006;
  --shadow: #0003;
  --scrim: #0005;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #18222d;
    --panel: #202b36;
    --text: #f4f7fb;
    --muted: #b5bec8;
    --weak: #8f9aa5;
    --line: #334251;
    --soft-line: #2a3744;
    --soft: #202b36;
    --code: #111922;
    --own: #18352b;
    --active-bg: #e7edf4;
    --active-text: #111922;
    --danger: #ff5555;
    --danger-soft: #ff555522;
    --offline-glow: #ff333388;
    --shadow: #0008;
    --scrim: #0009;
  }
}
:root[data-theme='0'] { color-scheme: light; }
:root[data-theme='1'] {
  color-scheme: dark;
  --bg: #18222d;
  --panel: #202b36;
  --text: #f4f7fb;
  --muted: #b5bec8;
  --weak: #8f9aa5;
  --line: #334251;
  --soft-line: #2a3744;
  --soft: #202b36;
  --code: #111922;
  --own: #18352b;
  --active-bg: #e7edf4;
  --active-text: #111922;
  --danger: #ff5555;
  --danger-soft: #ff555522;
  --offline-glow: #ff333388;
  --shadow: #0008;
  --scrim: #0009;
}
* { box-sizing: border-box; }
html, body {
  height: var(--app-height, 100dvh);
  overflow: hidden;
}
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  overflow: hidden;
}
button, textarea { font: inherit; }
button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
}
#app {
  display: grid;
  grid-template-columns: var(--sidebar-width, 280px) 1fr;
  height: var(--app-height, 100dvh);
  width: 100vw;
}
#sidebarResize {
  cursor: col-resize;
  inset: 0 auto 0 calc(var(--sidebar-width, 280px) - 3px);
  position: fixed;
  width: 6px;
  z-index: 30;
}
#sidebarResize:hover,
body.sidebar-resizing #sidebarResize {
  background: color-mix(in srgb, var(--active-bg) 18%, transparent);
}
body.sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}
#channels {
  align-content: start;
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: grid;
  gap: 3px;
  overflow: auto;
  padding: 10px;
}
main {
  display: grid;
  grid-column: 2;
  grid-template-rows: auto 1fr auto auto;
  min-height: 0;
  min-width: 0;
}
#scrim { display: none; }
#topbar {
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 48px;
  padding: 6px 10px;
}
#menu { display: none; }
#menu {
  block-size: 38px;
  inline-size: 38px;
  line-height: 1;
  padding: 0;
}
#title {
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#channelHead {
  display: grid;
  gap: 0;
  line-height: 1.05;
  min-width: 0;
}
#channelInfo,
#channelSecrets,
#channelHosts,
#channelResources {
  font-size: 12px;
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#channelInfo *,
#channelSecrets *,
#channelHosts *,
#channelResources * {
  display: inline;
  line-height: inherit;
  margin: 0;
  padding: 0;
}
.channel-head-line {
  display: block !important;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-head-line * {
  white-space: nowrap;
}
#logwrap {
  min-height: 0;
  min-width: 0;
  overflow: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 10px max(10px, env(safe-area-inset-right)) 12px max(10px, env(safe-area-inset-left));
  position: relative;
  -webkit-overflow-scrolling: touch;
}
#loadHistory {
  justify-self: end;
  font-size: 18px;
  inline-size: 38px;
  line-height: 1;
  max-width: 38px;
  min-height: 38px;
  min-width: 38px;
  padding: 0;
}
#log {
  display: grid;
  gap: 4px;
  min-width: 0;
  overflow-x: hidden;
}
#log {
  max-width: 80ch;
}
#log,
#progress {
  min-width: 0;
}
#progress {
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.25;
  margin: 0 max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
  overflow: visible;
  padding: 5px 6px;
}
#scrollBottom {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border-color: var(--soft-line);
  border-radius: 999px;
  bottom: 14px;
  box-shadow: 0 4px 18px var(--shadow);
  font-size: 18px;
  height: 38px;
  min-height: 38px;
  min-width: 38px;
  padding: 0;
  position: sticky;
  float: right;
  right: 10px;
  width: 38px;
  z-index: 5;
}
#scrollBottom[hidden] {
  display: none;
}
#progress:empty {
  display: none;
}
#form {
  background: var(--bg);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0;
  grid-template-columns: 1fr auto auto auto;
  padding: 3px max(3px, env(safe-area-inset-right)) max(3px, env(safe-area-inset-bottom)) max(3px, env(safe-area-inset-left));
  transition: background .12s, border-color .12s, box-shadow .12s;
}
#form > * + * {
  margin-left: 5px;
}
#form.voice-recording {
  background: color-mix(in srgb, var(--danger) 8%, var(--bg));
  border-color: color-mix(in srgb, var(--danger) 80%, var(--line));
  box-shadow: 0 -2px 18px color-mix(in srgb, var(--danger) 22%, transparent);
}
#form.archived {
  background: color-mix(in srgb, var(--weak) 9%, var(--bg));
}
#form.archived textarea,
#form.archived button {
  cursor: not-allowed;
  opacity: .45;
}
textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  height: 44px;
  min-height: 44px;
  min-width: 0;
  overflow: auto;
  resize: none;
  max-height: calc(1.35em * 70 + 14px);
}
#audioRecord {
  align-self: stretch;
  min-width: 54px;
  line-height: 1;
  box-shadow: inset 0 0 0 calc(1px + 10px * var(--level, 0)) color-mix(in srgb, var(--danger) 36%, transparent);
  padding: 0;
  transition: background .12s, color .12s, box-shadow .05s;
}
#audioCancel {
  align-self: stretch;
  color: var(--danger);
  font-size: 26px;
  line-height: 1;
  min-width: 44px;
  padding: 0;
}
#audioCancel[hidden] {
  display: none;
}
#audioRecord.recording {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 50%, var(--line));
  color: var(--danger);
  font-size: 24px;
  font-weight: 800;
}
#audioRecord.sending {
  opacity: .55;
}
#form.voice-recording button[type='button']:last-child {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  font-weight: 700;
  min-width: 52px;
  padding: 0 8px;
}
#form button[type='submit'] {
  min-width: 44px;
  padding: 0;
}
.channel-row {
  align-items: center;
  display: grid;
  gap: 4px;
  grid-template-columns: minmax(0, 1fr) repeat(var(--actions, 1), 28px);
}
.agent-row {
  display: block;
  position: relative;
}
.agent-row .agent-link {
  padding-right: 4px;
}
.agent-row .sidebar-action {
  position: absolute;
  top: 0;
}
.agent-row .sidebar-action:nth-of-type(2) { right: calc((var(--actions, 1) - 1) * 32px); }
.agent-row .sidebar-action:nth-of-type(3) { right: calc((var(--actions, 1) - 2) * 32px); }
.agent-row .sidebar-action:nth-of-type(4) { right: calc((var(--actions, 1) - 3) * 32px); }
.agent-row .sidebar-action:nth-of-type(5) { right: calc((var(--actions, 1) - 4) * 32px); }
.agent-row .sidebar-action:nth-of-type(6) { right: calc((var(--actions, 1) - 5) * 32px); }
.agent-row .sidebar-action:nth-of-type(7) { right: calc((var(--actions, 1) - 6) * 32px); }
.channel-link,
.agent-link {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  padding: 6px 4px;
  text-align: left;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-link {
  background: transparent;
  border: 0;
  display: block;
  width: 100%;
}
.channel-link.active,
.agent-link.selected {
  background: var(--active-bg);
  color: var(--active-text);
}
.channel-link.unread { font-weight: 800; }
.channel-link.archived-task,
.agent-link.archived-task {
  color: var(--weak);
  text-decoration: line-through;
}
.channel-link.running,
.agent-link.running {
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--active-bg) 55%, transparent);
  font-weight: 700;
}
.agent-link.idle { color: var(--weak); }
.channel-link.archived-task.active { color: var(--active-text); }
.archived-separator { color: var(--weak); }
.sidebar-action {
  background: transparent;
  border: 0;
  color: var(--text);
  min-height: 32px;
  min-width: 28px;
  padding: 0 5px;
}
.agent-row .sidebar-action {
  opacity: 0;
  pointer-events: none;
}
.agent-row:hover .sidebar-action,
.agent-row:focus-within .sidebar-action {
  opacity: 1;
  pointer-events: auto;
}
.agent-row:hover .agent-link,
.agent-row:focus-within .agent-link {
  box-sizing: border-box;
  padding-right: 4px;
  width: calc(100% - var(--actions, 1) * 32px);
}
details { margin-top: 10px; }
summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 5px 0;
}
.approval { color: var(--muted); font-size: 12px; margin-top: 4px; }
.approval button { font-size: 12px; min-height: 26px; padding: 1px 5px; }
.approval.executed { color: #17803b; }
.approval.rejected,
.approval.failed { color: #b42318; }
.calls {
  display: inline;
  font-size: inherit;
  line-height: inherit;
  min-height: 0;
  padding: 0;
}
.notyf { z-index: 10000; }
.helper-notify {
  display: grid;
  gap: 3px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.helper-notify-title {
  color: #fff;
}
.helper-notify-body {
  color: #ddd;
}
dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  max-height: calc(100dvh - 32px);
  max-width: calc(100vw - 24px);
  overflow: hidden;
  width: min(900px, calc(100vw - 24px));
}
dialog[open] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}
dialog form[method='dialog'] { margin-top: 10px; }
dialog form[method='dialog'] button {
  width: 100%;
}
#taskText,
#jsonText,
#statusText,
#promptText {
  overflow: auto;
}
dialog pre {
  font-size: 12px;
  line-height: 1.25;
  margin: 0;
  max-height: calc(100dvh - 96px);
  overflow: auto;
  white-space: pre-wrap;
}
.prompt-parts {
  display: grid;
  gap: 12px;
  white-space: normal;
}
.prompt-parts section {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.prompt-parts h3 {
  font-size: 12px;
  margin: 0;
}
.prompt-parts pre {
  background: var(--code);
  border: 1px solid var(--line);
  max-height: none;
  overflow: visible;
  padding: 8px;
}
.json-view {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.json-toolbar {
  display: flex;
  gap: 6px;
  justify-content: end;
}
.json-toolbar button {
  font-size: 12px;
  min-height: 28px;
  padding: 2px 8px;
}
.json-toolbar button:disabled {
  background: var(--active-bg);
  color: var(--active-text);
  cursor: default;
}
.json-pretty {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.json-compact {
  gap: 5px;
}
.json-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 8px;
}
.json-compact .json-card {
  gap: 3px;
  padding: 5px 6px;
}
.json-card h3 {
  font-size: 13px;
  line-height: 1.2;
  margin: 0 0 2px;
  overflow-wrap: anywhere;
}
.json-card blockquote {
  border-left: 2px solid var(--line);
  margin: 0;
  padding-left: 8px;
}
.json-kpis,
.json-object,
.json-list {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.json-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(90px, 0.35fr) minmax(0, 1fr);
  min-width: 0;
}
.json-label {
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.json-muted { color: var(--weak); }
.json-string,
.json-number,
.json-bool,
.json-null {
  min-width: 0;
  overflow-wrap: anywhere;
}
.json-details {
  min-width: 0;
}
.json-details summary {
  padding: 2px 0;
}
.json-inline {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.json-mcp-debug {
  display: grid;
  font-size: 75%;
  gap: 2px;
}
.json-mcp-row {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.json-mcp-tools,
.json-mcp-tools * {
  white-space: nowrap;
}
.json-mcp-server {
  font-weight: 600;
}
.json-call {
  border-top: 1px solid var(--soft-line);
  min-width: 0;
  padding: 5px 0;
}
.json-compact .json-call {
  padding: 3px 0;
}
.json-call:first-child {
  border-top: 0;
}
.json-call summary {
  align-items: baseline;
  display: flex;
  gap: 8px;
  min-width: 0;
  padding: 2px 0;
}
.json-call-name {
  flex: 0 0 auto;
  font-weight: 700;
}
.json-message-chain {
  display: grid;
  gap: 4px;
}
.json-chain-line {
  align-items: baseline;
  display: flex;
  gap: 6px;
  min-width: 0;
}
.json-chain-title {
  flex: 0 0 auto;
}
.json-chain-line code {
  background: var(--code);
  border: 1px solid var(--soft-line);
  border-radius: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  padding: 1px 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.json-call-args {
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.json-event-line {
  align-items: baseline;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.json-event-line > * {
  min-width: 0;
}
.json-event-line .json-muted {
  overflow-wrap: anywhere;
}
.json-event-time {
  color: var(--muted);
  flex: 0 0 42px;
  font-variant-numeric: tabular-nums;
}
.json-event-mcps {
  flex-basis: 100%;
  padding-left: 50px;
}
.json-event-body {
  margin-left: 50px;
  margin-top: 3px;
  min-width: 0;
}
.json-input-event .json-event-body {
  margin-left: 0;
}
.json-event-body > code {
  background: var(--code);
  border: 1px solid var(--soft-line);
  border-radius: 4px;
  overflow-wrap: anywhere;
  padding: 1px 4px;
  white-space: normal;
}
.json-tool-args {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.json-tool-field {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.json-path {
  background: var(--code);
  border: 1px solid var(--soft-line);
  border-radius: 4px;
  display: block;
  overflow-wrap: anywhere;
  padding: 1px 4px;
  width: fit-content;
}
.json-edit {
  border-left: 2px solid var(--soft-line);
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-left: 8px;
}
.json-edit-old .json-raw {
  border-left-color: var(--danger);
}
.json-edit-new .json-raw {
  border-left-color: var(--ok);
}
.json-event-line code {
  background: var(--code);
  border: 1px solid var(--soft-line);
  border-radius: 4px;
  padding: 0 3px;
}
.json-raw,
.json-text,
.json-md {
  background: var(--code);
  border: 1px solid var(--line);
  margin: 0;
  padding: 8px;
}
.json-raw-document {
  display: grid;
  gap: 1em;
}
.json-info .json-raw {
  max-height: 12em;
  overflow: auto;
  padding: 5px;
}
.json-compact .json-raw {
  padding: 5px;
}
#progress .json-toolbar {
  justify-content: start;
}
#progress .json-card {
  background: var(--panel);
}
#progress .json-tool .json-details:not([open]) {
  display: none;
}
.progress-agent {
  align-items: baseline;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  font: inherit;
  gap: 7px;
  min-height: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 0;
  text-align: left;
  white-space: normal;
  width: 100%;
}
.progress-agent + .progress-agent {
  margin-top: 3px;
}
.progress-time,
.progress-tool-state {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.progress-kind,
.progress-tool-name {
  background: var(--code);
  border: 1px solid var(--soft-line);
  border-radius: 4px;
  padding: 0 3px;
}
.progress-agent-name {
  font-weight: 800;
}
.progress-context {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.progress-tools {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}
.progress-turn {
  color: var(--muted);
  font-weight: 800;
  padding: 0 2px;
}
.progress-tool {
  min-width: 0;
  overflow-wrap: anywhere;
}
body.offline::after {
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--danger) 80%, transparent),
    inset 0 0 28px 10px var(--offline-glow);
  content: "";
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 9999;
}
body.localhost::before {
  box-shadow: 0 0 50px 8px color-mix(in srgb, #12a150 100%, transparent);
  content: "";
  height: 0;
  inset: 0 0 auto 0;
  pointer-events: none;
  position: fixed;
  z-index: 10000;
}
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  #sidebarResize { display: none; }
  #channels {
    background: var(--bg);
    box-shadow: 0 0 24px var(--shadow);
    height: var(--app-height, 100dvh);
    left: 0;
    max-width: 88vw;
    position: fixed;
    top: 0;
    transform: translateX(-105%);
    transition: transform .12s ease-out;
    width: 320px;
    z-index: 20;
  }
  body.sidebar-open #channels { transform: translateX(0); }
  #scrim {
    background: var(--scrim);
    display: block;
    height: var(--app-height, 100dvh);
    inset: 0 0 auto 0;
    opacity: 0;
    pointer-events: none;
    position: fixed;
    transition: opacity .12s ease-out;
    z-index: 15;
  }
  body.sidebar-open #scrim {
    opacity: 1;
    pointer-events: auto;
  }
  #menu { display: inline-block; }
  main { grid-column: 1; }
  #topbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  main {
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: var(--app-height, 100dvh);
  }
  #logwrap { padding-bottom: 12px; }
  #form {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
  }
  textarea { min-height: 44px; }
  #form button { min-height: 42px; }
}
