:root {
  --bg: #fbfbfa; --panel: #ffffff; --line: #e4e4e0; --text: #1b1b19; --muted: #6b6b66;
  --accent: #2f5fd0; --accent-soft: #e9effc; --ok: #1f7a47; --ok-soft: #e4f4ea;
  --bad: #b3261e; --bad-soft: #fbe9e7; --warn: #8a5a00; --warn-soft: #fbf1d8;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514; --panel: #1d1d1b; --line: #33332f; --text: #ecece8; --muted: #9a9a93;
    --accent: #8fb0ff; --accent-soft: #232c44; --ok: #6fd09a; --ok-soft: #1a3325;
    --bad: #ff8f86; --bad-soft: #40201d; --warn: #e6b450; --warn-soft: #3a2e12;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
textarea { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 10px; box-sizing: border-box; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 6px;
  padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button.danger { border-color: var(--bad); color: var(--bad); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary { color: #111; } }
button:disabled { opacity: .5; cursor: default; }
input, select { border: 1px solid var(--line); background: var(--panel); border-radius: 6px;
  padding: 6px 10px; }
h1 { font-size: 20px; margin: 0 0 16px; } h2 { font-size: 15px; margin: 24px 0 8px; }
.muted { color: var(--muted); } .mono { font-family: var(--mono); font-size: 12.5px; }
.layout { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 16px 12px; background: var(--panel); }
.side .brand { font-weight: 600; margin: 0 8px 16px; }
.side a { display: block; padding: 6px 8px; border-radius: 6px; color: var(--text); }
.side a.on { background: var(--accent-soft); color: var(--accent); }
.side select { width: 100%; margin-bottom: 12px; }
.side .foot { margin-top: 24px; padding: 0 8px; font-size: 12.5px; }
.main { padding: 24px 32px; max-width: 1180px; width: 100%; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
table { width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line);
  vertical-align: top; }
th { font-weight: 500; color: var(--muted); font-size: 12.5px; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--accent-soft); }
td.clip { max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  background: var(--line); margin-right: 4px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.kind { background: var(--accent-soft); color: var(--accent); font-family: var(--mono); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px;
  margin: 6px 0; overflow: auto; max-height: 360px; white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); font-size: 12.5px; }
.bubble { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 10px 0;
  max-width: 760px; white-space: pre-wrap; word-break: break-word; background: var(--panel); }
.bubble.user { margin-left: auto; background: var(--accent-soft); border-color: transparent; }
.bubble .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
details.tool { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; max-width: 760px;
  background: var(--panel); }
details.tool.failed { border-color: var(--bad); }
details.tool summary { padding: 8px 12px; cursor: pointer; }
details.tool .in { padding: 0 12px 10px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 4px 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.timeline .line { display: grid; grid-template-columns: 220px 1fr 70px; gap: 8px;
  align-items: center; padding: 3px 0; }
.timeline .track { position: relative; height: 12px; background: var(--bg); border-radius: 3px; }
.timeline .bar { position: absolute; top: 0; height: 12px; border-radius: 3px;
  background: var(--accent); min-width: 2px; }
.timeline .bar.error { background: var(--bad); }
.timeline .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree { display: grid; grid-template-columns: minmax(280px, 2fr) 3fr; gap: 16px; }
.tree .node { padding: 5px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.tree .node:hover, .tree .node.on { background: var(--accent-soft); }
.steps li { margin: 6px 0; }
.check { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.auth { max-width: 380px; margin: 12vh auto; }
.auth input { width: 100%; margin-bottom: 10px; }
.error { color: var(--bad); margin: 8px 0; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
textarea.prompt { width: 100%; min-height: 150px; font-family: var(--mono); font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: var(--bg);
  color: var(--text); resize: vertical; }
