/* OpenAI Playground inspired -- light, dense, monospaced ids */
:root {
  --bg: #ffffff;
  --bg-subtle: #f7f7f8;
  --bg-sunken: #f0f0f1;
  --border: #e5e5e5;
  --border-strong: #d1d1d3;
  --text: #0d0d0d;
  --text-muted: #6e6e80;
  --text-faint: #9b9ba4;
  --accent: #10a37f;
  --accent-bg: #e9f7f2;
  --warn: #b45309;
  --pink: #c026d3;
  --blue: #2563eb;
  --orange: #d97706;
  --row-hover: #f4f4f5;
  --code-bg: #f7f7f8;

  --font-sans: "Söhne", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Cascadia Code", "Roboto Mono", monospace;

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }

.copy-toast-container {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 20000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.copy-toast {
  background: #0d0d0d;
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.20);
  font-size: 12.5px;
  line-height: 1.2;
  animation: copyToastIn 160ms ease-out;
}
.copy-toast-anchored {
  position: fixed;
  z-index: 20000;
  pointer-events: none;
}
.copy-toast.leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 160ms ease, transform 160ms ease;
}
@keyframes copyToastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-rows: 48px 1fr;
  height: 100vh;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}
.topbar .brand .dot {
  width: 18px; height: 18px; border-radius: 5px;
  background: #0d0d0d;
  display: grid; place-items: center;
  color: white; font-size: 11px; font-weight: 700;
}
.topbar .breadcrumb {
  color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.topbar .breadcrumb .chev { color: var(--text-faint); }
.topbar .breadcrumb .current { color: var(--text); font-weight: 500; }
.topbar .spacer { flex: 1; }
.topbar .actions { display: flex; gap: 6px; align-items: center; }
.user-pref {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 26px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
}
.user-pref-label {
  padding: 0 6px 0 5px;
  color: var(--text-muted);
  font-size: 11.5px;
}
.user-pref button {
  height: 20px;
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  cursor: pointer;
}
.user-pref button:hover { color: var(--text); background: var(--row-hover); }
.user-pref button.active {
  background: white;
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

.tabs {
  display: flex; gap: 2px; margin-left: 12px;
}
.tabs button {
  background: transparent; border: 0;
  padding: 6px 10px; border-radius: var(--r-sm);
  color: var(--text-muted); font-size: 13px;
  cursor: pointer;
}
.tabs button:hover { background: var(--row-hover); color: var(--text); }
.tabs button.active { background: var(--bg-sunken); color: var(--text); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm);
  height: 28px; padding: 0 10px;
  font-size: 12.5px; cursor: pointer; color: var(--text);
  transition: background 80ms ease, border-color 80ms ease;
}
.btn:hover { background: var(--row-hover); }
.btn.primary {
  background: #0d0d0d; color: white; border-color: #0d0d0d;
}
.btn.primary:hover { background: #1f1f24; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--row-hover); color: var(--text); }
.btn.sm { height: 24px; padding: 0 8px; font-size: 11.5px; }
.btn.icon { width: 28px; padding: 0; justify-content: center; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---------- columns ---------- */
.cols {
  display: grid;
  grid-template-columns: 288px 1fr 380px;
  height: 100%;
  min-height: 0;
}
/* When drag-resizing is wired (Playground app injects --left-w / --right-w
   onto the .cols element), the grid switches to a 5-column layout where
   columns 2 and 4 are 0-width gutter hit-zones. The gutter element styles
   its own visible 5-px hover stripe via ::after so the grid track itself
   stays 0px and doesn't push siblings around. */
.cols.resizable {
  grid-template-columns: var(--left-w, 288px) 0 1fr 0 var(--right-w, 380px);
}
.col {
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.col.left { border-right: 1px solid var(--border); background: var(--bg-subtle); }
.col.right { border-left: 1px solid var(--border); background: var(--bg-subtle); }
.col.mid { background: var(--bg); }

/* Drag-handle between columns. The element itself is 0-wide in the grid;
   ::before is a wider invisible hit-zone (8px each side) so the user can
   grab the line easily, and ::after is a 1px visible stripe that lights up
   on hover. Sits on top of the column borders via z-index so the cursor
   stays col-resize across the whole hit-zone. */
.gutter {
  position: relative;
  width: 0;
  z-index: 5;
}
.gutter::before {
  content: "";
  position: absolute; top: 0; bottom: 0;
  left: -5px; right: -5px;
  cursor: col-resize;
}
.gutter::after {
  content: "";
  position: absolute; top: 0; bottom: 0;
  left: -1px; width: 2px;
  background: transparent;
  transition: background 80ms ease;
  pointer-events: none;
}
.gutter:hover::after,
.gutter:active::after {
  background: var(--accent);
}

.col .scroll { overflow-y: auto; flex: 1; min-height: 0; }
.col .scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.col .scroll::-webkit-scrollbar-thumb { background: #d8d8dd; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.col .scroll::-webkit-scrollbar-thumb:hover { background: #b5b5be; background-clip: padding-box; border: 2px solid transparent; }

/* ---------- left panel sections ---------- */
.section {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
}
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.section-title .right-actions { display: flex; gap: 2px; }
.system-pop-section {
  position: relative;
  overflow: visible;
}
.system-pop-section.open {
  z-index: 50;
}
.system-pop-trigger {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: white;
  color: var(--text-muted);
  padding: 7px 8px;
  cursor: pointer;
  text-align: left;
}
.system-pop-trigger:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.system-pop-trigger span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.system-pop-trigger b {
  flex-shrink: 0;
  border: 1px solid #d8e7df;
  border-radius: 999px;
  background: #f3fbf6;
  color: #10643c;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 600;
}
.system-popover {
  position: fixed;
  z-index: 1200;
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: white;
  box-shadow: 0 18px 42px rgba(0,0,0,0.16);
  padding: 10px;
  overflow: auto;
}
.system-popover-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.system-popover-head .ttl {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.system-popover-head .sub {
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-muted);
}
.system-popover-head .btn {
  margin-left: auto;
}

/* agent picker */
.agent-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 10px;
  cursor: pointer;
  display: flex; align-items: flex-start; gap: 10px;
  transition: border-color 80ms ease, box-shadow 80ms ease;
}
.agent-card + .agent-card { margin-top: 6px; }
.agent-card:hover { border-color: var(--border-strong); }
.agent-card.active {
  border-color: #0d0d0d;
  box-shadow: 0 0 0 1px #0d0d0d inset;
}
.agent-card .avatar {
  width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600; color: white;
  flex-shrink: 0;
}
.agent-card .meta { min-width: 0; flex: 1; }
.agent-card .name {
  font-weight: 600; font-size: 13px; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.agent-card .desc {
  font-size: 11.5px; color: var(--text-muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.agent-card .check {
  color: var(--accent); flex-shrink: 0; opacity: 0;
}
.agent-card.active .check { opacity: 1; }

.add-agent-row {
  display: flex; gap: 6px; margin-top: 8px;
}
.add-agent-row .btn { flex: 1; justify-content: center; }

/* skill list */
.tool-list { display: flex; flex-direction: column; gap: 4px; }
.tool-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  position: relative;
}
.tool-row:hover { background: var(--row-hover); }
.tool-row .icon {
  width: 20px; height: 20px; border-radius: 5px;
  display: grid; place-items: center;
  font-size: 11px; color: white; font-weight: 600;
  flex-shrink: 0;
}
.tool-row .name { font-size: 12.5px; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-row .tag {
  font-size: 10px; color: var(--text-muted); font-family: var(--font-mono);
  padding: 1px 5px; background: var(--bg-sunken); border-radius: 4px;
}
.tool-row .switch { flex-shrink: 0; }
.section-count {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.local-tool-search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-sunken);
  color: var(--text-muted);
  margin-bottom: 6px;
}
.local-tool-search input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  width: 100%;
  min-width: 0;
}
.local-tool-list {
  max-height: 220px;
  overflow: auto;
  padding-right: 2px;
}
.local-tool-group .group-label {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
  padding: 5px 2px 3px;
}
.local-tool-row .meta {
  flex: 1;
  min-width: 0;
}
.local-tool-row .desc {
  font-size: 10.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty-mini {
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px;
}

/* toggle switch */
.switch {
  width: 26px; height: 14px; border-radius: 999px;
  background: #d1d1d3; position: relative; cursor: pointer;
  transition: background 120ms ease;
  flex-shrink: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 10px; height: 10px; border-radius: 50%;
  background: white; transition: transform 120ms ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(12px); }

/* form rows */
.field { margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--text-muted); margin-bottom: 4px;
}
.field label .val { font-family: var(--font-mono); color: var(--text); }
.field .hint {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-faint);
}
.select, .input, .textarea {
  width: 100%; background: white;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 6px 8px; font-size: 12.5px; color: var(--text);
  outline: none;
}
.select:focus, .input:focus, .textarea:focus {
  border-color: #0d0d0d;
}
.prompt-template-editor {
  display: grid;
  gap: 8px;
}
.prompt-vars {
  display: grid;
  gap: 8px;
}
.prompt-vars-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.prompt-vars-head .desc {
  min-width: 0;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 11.5px;
}
.prompt-vars-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.prompt-vars-label {
  color: var(--text-muted);
  font-size: 11.5px;
  min-width: 56px;
}
.prompt-var-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.prompt-var-chip {
  max-width: 100%;
  border: 1px solid #d8e7df;
  background: #f3fbf6;
  color: #10643c;
  border-radius: 6px;
  padding: 3px 7px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
button.prompt-var-chip {
  cursor: pointer;
  text-align: left;
}
button.prompt-var-chip:hover {
  border-color: #93c7aa;
  background: #e8f7ee;
}
.prompt-var-chip.builtin {
  border-color: var(--border);
  background: #f8f8f8;
  color: var(--text-muted);
}
.prompt-var-chip.selected {
  border-color: #0d0d0d;
  background: white;
  color: var(--text);
  box-shadow: 0 0 0 2px rgba(13,13,13,0.05);
}
button.prompt-var-chip.builtin:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.prompt-var-chip.condition {
  border-color: #d8dde8;
  background: #f6f8fc;
  color: #34466c;
}
.prompt-insert-panel {
  display: grid;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: #fbfbfb;
  padding: 8px;
}
.prompt-insert-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.prompt-insert-title code {
  min-width: 0;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 400;
  overflow-wrap: anywhere;
}
.prompt-insert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.prompt-action-btn {
  border: 1px solid #cfe4db;
  border-radius: var(--r-sm);
  background: #f0faf5;
  color: #0b6840;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.prompt-action-btn:hover {
  border-color: #8ec6a9;
  background: #e4f6ec;
}
.prompt-action-btn.condition {
  border-color: #d8dde8;
  background: #f5f7fc;
  color: #34466c;
}
.prompt-action-btn.condition:hover {
  border-color: #aebad3;
  background: #eef2fb;
}
.prompt-insert-help {
  display: grid;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.35;
}
.prompt-insert-help b {
  color: var(--text);
  font-weight: 600;
}
.prompt-var-empty {
  color: var(--text-muted);
  font-size: 12px;
}
.prompt-preview {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: #fafafa;
  overflow: hidden;
}
.prompt-preview summary {
  cursor: pointer;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.prompt-preview pre {
  margin: 0;
  padding: 9px;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.45;
  background: white;
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4l3 3 3-3' stroke='%236e6e80' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 22px;
}
.trace-select-filter {
  display: inline-flex;
  align-items: center;
  height: 28px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}
.trace-select-filter > span {
  padding-left: 8px;
}
.trace-select-filter select {
  appearance: auto;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 0 7px 0 5px;
  outline: none;
}
.trace-date-filter {
  height: 28px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 0 6px;
  outline: none;
}
.trace-date-filter:focus,
.trace-select-filter:focus-within {
  border-color: var(--text);
}
.slider {
  -webkit-appearance: none; width: 100%; height: 4px;
  background: var(--border-strong); border-radius: 999px; outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #0d0d0d; cursor: pointer;
}

/* ---------- chat ---------- */
.chat-head {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.chat-head .title {
  font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.chat-head .badge {
  font-size: 11px; color: var(--text-muted); font-family: var(--font-mono);
  padding: 2px 7px; background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: 999px;
}
.chat-head .thread-id-field {
  min-width: 150px; max-width: min(320px, 32vw); height: 25px;
  display: flex; align-items: center; gap: 6px;
  padding: 2px 7px; background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-muted); font: 11px var(--font-mono);
}
.chat-head .thread-id-field:focus-within {
  border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 14%, transparent);
}
.chat-head .thread-id-field input {
  min-width: 0; width: 100%; padding: 0; border: 0; outline: 0;
  background: transparent; color: var(--text); font: inherit;
}
.chat-head .thread-id-field input:disabled { cursor: not-allowed; opacity: .55; }
.chat-head .spacer { flex: 1; }

.messages { padding: 20px 20px 16px; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 12px; max-width: 100%; }
.msg .av {
  width: 26px; height: 26px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.msg .av.user { background: #0d0d0d; }
.msg .body { min-width: 0; flex: 1; }
.msg .who {
  font-weight: 600; font-size: 12.5px; color: var(--text);
  display: flex; align-items: center; gap: 8px; margin-bottom: 3px;
}
.msg .who .when { color: var(--text-faint); font-weight: 400; font-size: 11.5px; font-family: var(--font-mono); }
.msg .who .msg-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.msg .who .markdown-toggle {
  height: 22px;
  padding: 0 7px;
  font-size: 11px;
}
.msg .who .markdown-toggle.active {
  background: var(--bg-sunken);
  border-color: var(--border);
  color: var(--text);
}
.msg .content {
  font-size: 14px; line-height: 1.55; color: var(--text);
  white-space: pre-wrap; word-wrap: break-word;
}
.msg .content code {
  font-family: var(--font-mono); font-size: 12.5px;
  background: var(--code-bg); padding: 1px 5px; border-radius: 4px;
}
.msg .markdown-preview {
  white-space: normal;
  overflow-wrap: anywhere;
}
.msg .markdown-preview > *:first-child { margin-top: 0; }
.msg .markdown-preview > *:last-child { margin-bottom: 0; }
.msg .markdown-preview h1,
.msg .markdown-preview h2,
.msg .markdown-preview h3,
.msg .markdown-preview h4 {
  margin: 14px 0 7px;
  line-height: 1.25;
  font-weight: 650;
}
.msg .markdown-preview h1 { font-size: 20px; }
.msg .markdown-preview h2 { font-size: 17px; }
.msg .markdown-preview h3 { font-size: 15px; }
.msg .markdown-preview h4 { font-size: 14px; }
.msg .markdown-preview p { margin: 0 0 10px; }
.msg .markdown-preview ul {
  margin: 0 0 10px 18px;
  padding: 0;
}
.msg .markdown-preview li { margin: 3px 0; }
.msg .markdown-preview blockquote {
  margin: 10px 0;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}
.msg .markdown-preview blockquote p {
  margin: 5px 0;
}
.msg .markdown-preview img {
  display: block;
  max-width: min(100%, 760px);
  max-height: 520px;
  width: auto;
  height: auto;
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: white;
  object-fit: contain;
}
.msg .markdown-preview a { color: var(--accent); text-decoration: none; }
.msg .markdown-preview a:hover { text-decoration: underline; }
.msg .markdown-preview pre {
  margin: 10px 0;
  padding: 10px 12px;
  overflow: auto;
  border-radius: var(--r-sm);
  background: var(--code-bg);
  white-space: pre;
}
.msg .markdown-preview pre code {
  padding: 0;
  background: transparent;
  border-radius: 0;
}
.msg .markdown-preview table {
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: 13px;
  display: block;
  overflow-x: auto;
}
.msg .markdown-preview th,
.msg .markdown-preview td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
.msg .markdown-preview th {
  background: var(--bg-subtle);
  font-weight: 650;
}
.msg .stats {
  margin-top: 8px;
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: var(--text-faint); font-family: var(--font-mono);
}
.msg .stats .stat { display: inline-flex; align-items: center; gap: 4px; }
.msg .stats .stat svg { opacity: 0.6; }
.msg .stats .sep { color: var(--text-faint); opacity: 0.4; }
.msg .stats .stat.status-failed { color: #b91c1c; }
.msg .stats .stat.status-cancelled { color: var(--orange); }
.msg .stats .stat.status-timeout { color: var(--orange); }

/* Inline alert banner inside an assistant message bubble (e.g. max-rounds
   hit). Stands apart visually from the reply text without commandeering the
   whole row. */
.msg-alert {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 6px 10px;
  border-radius: var(--r-sm);
  background: #fff7ed; color: #9a3412;
  border: 1px solid #fed7aa;
  font-size: 12px;
}
.msg-alert.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.msg-alert svg { opacity: 0.7; }

.reasoning-block {
  margin-top: 8px;
  border: 1px solid #d7dde8;
  border-radius: var(--r-md);
  background: #f8fafc;
  overflow: hidden;
}
.reasoning-block.active {
  border-color: #b8c7df;
  background: #f6f9ff;
}
.reasoning-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  border-bottom: 1px solid rgba(148, 163, 184, 0.26);
}
.reasoning-head svg { opacity: 0.65; }
.reasoning-body {
  padding: 8px 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 220px;
  overflow: auto;
}

.process-block {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fafafa;
  overflow: hidden;
}
.process-head {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.process-head:hover { background: var(--bg-sunken, #f3f4f6); }
.process-head svg { opacity: 0.65; flex-shrink: 0; }
.process-meta {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}
.process-error {
  margin-left: auto;
  color: #b91c1c;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.process-body {
  padding: 8px;
  border-top: 1px solid var(--border);
  background: white;
}
.process-body .tool-invocation:first-child { margin-top: 0; }
.process-body .tool-invocation:last-child { margin-bottom: 0; }

/* PR C — download chips for output assets (PPT / DOCX / etc.) the
   skill script wrote under workspace/output/. Rendered below the
   assistant reply content. */
.msg-assets {
  margin-top: 10px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.msg-asset-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-mono);
}
.msg-asset-chip:hover {
  background: var(--bg-sunken, #f3f4f6);
  border-color: var(--accent);
  color: var(--accent);
}
.msg-asset-chip .nm { font-weight: 500; }
.msg-asset-chip .sz { color: var(--text-muted); font-size: 11px; }
.msg-asset-chip svg { opacity: 0.6; }
.msg-asset-chip .rotate-180 { transform: rotate(180deg); }

/* HITL (docs/HIL-design.md 场景1) — inline human-input form shown inside the
   assistant bubble when the run pauses on `ask_human`. Accent-tinted card so
   it reads as "action required", distinct from the plain reply content. */
.human-input {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--r-md, 10px);
  background: var(--accent-bg, #eef6f2);
}
.human-input .hi-head {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--accent);
}
.human-input .hi-head svg { opacity: 0.85; }
.human-input .hi-prompt {
  margin-top: 6px; font-size: 13px; color: var(--text); line-height: 1.5;
}
.human-input .hi-fields {
  margin-top: 10px; display: flex; flex-direction: column; gap: 8px;
}
.human-input .hi-field { display: flex; flex-direction: column; gap: 3px; }
.human-input .hi-label {
  font-size: 11.5px; color: var(--text-muted); font-weight: 500;
}
.human-input .hi-field input {
  padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: white; color: var(--text); font-size: 13px;
  font-family: inherit;
}
.human-input .hi-field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg, #d1fae5);
}
.human-input .hi-field input:disabled { opacity: 0.6; }
.human-input .hi-checkbox-options { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.human-input .hi-checkbox-option { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.human-input .hi-checkbox-option input[type="checkbox"] { width: auto; padding: 0; margin: 0; }
.human-input .hi-actions {
  margin-top: 10px; display: flex; justify-content: flex-end;
  gap: 6px; flex-wrap: wrap;
}
.human-input.tool-approval {
  border-color: var(--warn);
  background: #fff7ed;
}
.human-input.tool-approval .hi-head { color: var(--warn); }
.tool-approval .ta-meta { color: var(--text-muted); font-weight: 400; }
.tool-approval .ta-json {
  margin-top: 10px;
  width: 100%;
  min-height: 112px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: white;
  color: var(--text);
  font: 12px/1.45 var(--font-mono);
}
.tool-approval .ta-json:focus,
.tool-approval .ta-reason:focus {
  outline: none;
  border-color: var(--warn);
  box-shadow: 0 0 0 2px #ffedd5;
}
.tool-approval .ta-reason {
  margin-top: 8px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: white;
  font-size: 13px;
}

/* Footer line under assistant reply listing which skills the run actually
   activated. Mirrors ChatGPT's "Used X tools" line. */
.msg-skills {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 6px; padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-sunken);
  font-size: 10.5px; color: var(--text-muted);
  font-family: var(--font-mono);
}
.msg-skills svg { opacity: 0.6; }

.msg-error {
  margin-top: 8px; padding: 8px 10px;
  border-radius: var(--r-sm);
  background: #fef2f2; color: #991b1b;
  border: 1px solid #fecaca;
  font-size: 12px; font-family: var(--font-mono);
}

/* `round N` pill on a tool invocation card — only shown when the LLM
   went through several rounds in one run. */
.tool-invocation .head .round-badge {
  font-size: 10px; font-family: var(--font-mono);
  padding: 1px 6px; border-radius: 4px;
  background: var(--accent-bg); color: var(--accent);
  font-weight: 500;
}

.tool-invocation {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: white;
  overflow: hidden;
}
.tool-invocation .head {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 10px;
  background: var(--bg-subtle);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.tool-invocation .head.expandable { cursor: pointer; }
.tool-invocation .head.expandable:hover { background: var(--bg-sunken, #eef0f3); }
.tool-invocation .head .ic {
  width: 16px; height: 16px; border-radius: 4px;
  display: grid; place-items: center; color: white; font-size: 10px;
  flex-shrink: 0;
}
.tool-invocation .head .nm { font-weight: 600; flex-shrink: 0; }
.tool-invocation .head .args {
  color: var(--text-muted);
  font-family: var(--font-mono); font-size: 11.5px;
  min-width: 0; flex: 1;
  /* PR ui-args-wrap: previously `white-space: nowrap + ellipsis` made
     long arg JSON (e.g. skill_write_file content blob) overflow the
     panel as a single line. Wrap + 2-line clamp with ellipsis keeps
     short args dense and long ones contained; click head to expand. */
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}
.tool-invocation .head.expanded .args {
  -webkit-line-clamp: unset;
  display: block;
  white-space: pre-wrap;
}
.tool-invocation .head .args-chevron {
  flex-shrink: 0;
  color: var(--text-muted); font-size: 11px;
  user-select: none;
}
.tool-invocation .args-pretty {
  margin: 0; padding: 8px 10px;
  background: var(--bg-sunken, #fafbfc);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow: auto;
}
.tool-invocation .head .dur {
  font-size: 11px; color: var(--text-faint); font-family: var(--font-mono);
  flex-shrink: 0;
}
.tool-invocation .body {
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: pre-wrap; word-wrap: break-word;
  max-height: 140px; overflow: auto;
}
/* pr-tool-error-visibility-ui: actual error message from result_text.
   Visually distinct from the .body one-liner (which is "✗ error (N B)") —
   subtle red tint + slightly tighter type so a stack trace / "ERROR:
   script not found:" reads at a glance without dominating the bubble. */
.tool-invocation .tool-error-body {
  margin: 0;
  padding: 8px 10px;
  background: rgba(220, 38, 38, 0.06);   /* very light red */
  border-top: 1px solid rgba(220, 38, 38, 0.18);
  font-family: var(--font-mono);
  font-size: 11px;
  color: #991b1b;                         /* dark red text for contrast */
  white-space: pre-wrap; word-break: break-word;
  max-height: 240px; overflow: auto;
}

/* composer */
.composer-wrap {
  border-top: 1px solid var(--border);
  padding: 12px 20px 14px;
  background: var(--bg);
}
.run-context-panel {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: white;
  padding: 8px;
  margin-bottom: 8px;
}
.run-context-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 650; color: var(--text);
  margin-bottom: 7px;
  min-width: 0;
}
.run-context-head em {
  color: var(--text-muted);
  font-style: normal;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.run-context-head b {
  margin-left: auto;
  border: 1px solid #d8e7df;
  border-radius: 999px;
  padding: 2px 7px;
  color: #10643c;
  background: #f3fbf6;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.run-context-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.run-context-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.run-context-row code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}
.run-context-row input,
.run-context-add-row input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
  min-width: 0;
}
.run-context-row input:focus,
.run-context-add-row input:focus {
  border-color: #0d0d0d;
}
.run-context-row .btn.icon {
  width: 28px;
  height: 28px;
  padding: 0;
}
.run-context-empty {
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 12px;
  padding: 7px 8px;
}
.run-context-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.run-context-add-row .btn {
  width: 104px;
  white-space: nowrap;
}
@media (max-width: 980px) {
  .run-context-row { grid-template-columns: minmax(96px, 140px) minmax(0, 1fr) 28px; }
}
@media (max-width: 560px) {
  .run-context-row {
    grid-template-columns: minmax(0, 1fr) 28px;
  }
  .run-context-row code {
    grid-column: 1 / -1;
  }
  .run-context-add-row {
    grid-template-columns: minmax(0, 1fr) 104px;
  }
}
.composer {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: white;
  transition: border-color 80ms ease, box-shadow 80ms ease;
}
.composer:focus-within {
  border-color: #0d0d0d;
  box-shadow: 0 0 0 3px rgba(13,13,13,0.06);
}
.composer textarea {
  width: 100%; resize: none;
  border: 0; outline: none; background: transparent;
  padding: 12px 14px 4px;
  font-size: 14px; line-height: 1.5;
  min-height: 44px; max-height: 200px;
}
.composer-bottom {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 10px;
}
.composer-bottom .chips {
  display: flex; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 0;
  align-items: center;
}
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px 2px 6px;
  font-size: 11.5px;
  color: var(--text);
  background: white;
  cursor: pointer;
  height: 22px;
}
.chip:hover { background: var(--row-hover); }
.chip.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.chip .ic {
  width: 14px; height: 14px; border-radius: 3px;
  display: grid; place-items: center; color: white; font-size: 9px;
}
.chip .x { color: var(--text-faint); margin-left: 1px; font-size: 11px; }
.chip-add {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; color: var(--text-muted);
  background: transparent; border: 1px dashed var(--border-strong);
  border-radius: 999px; padding: 2px 8px; cursor: pointer; height: 22px;
}
.chip-add:hover { color: var(--text); border-color: var(--text-muted); }

.composer-popover {
  position: absolute;
  bottom: calc(100% + 6px); left: 0;
  background: white; border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  min-width: 240px;
  padding: 6px;
  z-index: 20;
}
.composer-popover .group-label {
  font-size: 10.5px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.06em; padding: 6px 8px 4px;
}
.popover-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 12.5px;
}
.popover-row:hover { background: var(--row-hover); }
.popover-row .check {
  margin-left: auto; color: var(--accent); opacity: 0;
}
.popover-badge {
  margin-left: 2px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.4;
}
.popover-row.on .check { opacity: 1; }
.popover-empty {
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 12px;
}

/* PR pg-system-prompt-preview: collapsible "what the LLM sees" header
   at the top of the Observability panel. Visually neutral when collapsed
   so the more-used stats panel stays primary; expanded shows the prompt
   as a scrollable <pre> with monospace + tight line height. */
.system-prompt-section {
  border-bottom: 1px solid var(--border);
}
.system-prompt-head {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
  text-align: left;
}
.system-prompt-head:hover { background: var(--bg-sunken, #f3f4f6); }
.system-prompt-head .label { font-weight: 600; }
.system-prompt-head .hint {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--text-faint);
  font-weight: 400;
}
.system-prompt-body {
  padding: 0 14px 12px;
  border-top: 1px solid var(--border);
}
.system-prompt-body .prompt-text {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--bg-sunken, #f8fafb);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}
.system-prompt-body .loading { padding: 10px 0; color: var(--text-muted); font-size: 12px; }
.system-prompt-body .err { padding: 10px 0; color: #991b1b; font-size: 12px; }

/* ---------- logs ---------- */
.logs-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.logs-head .title { font-weight: 600; font-size: 13px; }
.logs-head .live {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; color: var(--accent); font-family: var(--font-mono);
  background: var(--accent-bg); padding: 1px 6px; border-radius: 999px;
}
.logs-head .live .dotpulse {
  width: 6px; height: 6px; background: var(--accent); border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.run-card {
  margin: 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.right-scroll {
  overflow: auto;
}
.right-scroll .run-card {
  min-width: 0;
}
.workspace-files-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.workspace-browser { padding: 12px; }
.workspace-files-head {
  min-height: 43px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.workspace-files-head > div { display: grid; gap: 2px; }
.workspace-files-head .workspace-files-actions { display: flex; align-items: center; gap: 6px; }
.workspace-files-actions select {
  max-width: 112px;
  height: 24px;
  padding: 0 22px 0 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text-muted);
  font: 10px var(--font-mono);
}
.workspace-files-head strong { font-size: 12px; font-weight: 600; }
.workspace-files-head span { font-size: 10px; color: var(--text-faint); }
.workspace-sync-live { display: inline-flex; align-items: center; gap: 5px; color: var(--accent) !important; }
.workspace-sync-live > span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.workspace-file-list { max-height: 360px; overflow: auto; }
.workspace-file-row {
  min-height: 34px;
  padding: 0 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 24px;
  gap: 7px;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}
.workspace-file-row:last-child { border-bottom: 0; }
.workspace-file-row:hover { background: var(--row-hover); }
.workspace-file-name, .workspace-file-download, .workspace-preview-head button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.workspace-file-name {
  min-width: 0;
  padding: 7px 0;
  display: flex;
  align-items: center;
  gap: 7px;
  text-align: left;
  cursor: default;
}
.workspace-file-name.markdown { color: var(--accent); cursor: pointer; }
.workspace-file-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 10.5px; }
.workspace-file-size { white-space: nowrap; font-family: var(--font-mono); font-size: 9.5px; color: var(--text-faint); }
.workspace-file-download { width: 24px; height: 24px; padding: 0; display: grid; place-items: center; border-radius: 4px; }
.workspace-file-download:hover, .workspace-preview-head button:hover { background: var(--bg-subtle); color: var(--text); }
.workspace-files-empty, .workspace-files-error { padding: 24px 12px; text-align: center; font-size: 11px; color: var(--text-faint); }
.workspace-files-error { color: #b91c1c; overflow-wrap: anywhere; }
.history-load-error {
  margin: 10px 14px 0;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 11px;
}
.history-load-error button { border: 0; background: transparent; color: inherit; font-weight: 600; cursor: pointer; }
.workspace-preview {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-rows: 42px minmax(0, 1fr);
  background: #fff;
}
.workspace-preview-head { padding: 0 10px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.workspace-preview-head > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 11px; }
.workspace-preview-head > div { display: flex; gap: 3px; }
.workspace-preview-head button { width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border-radius: 5px; }
.workspace-preview-body { min-height: 0; overflow: auto; padding: 14px; }
.workspace-preview-body .markdown-preview { font-size: 12px; }
.run-card .head {
  padding: 9px 12px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border);
  background: white;
}
.run-card .head .turn {
  font-weight: 600; font-size: 12.5px;
}
.run-card .head .ids {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted);
  display: flex; gap: 8px; flex-wrap: wrap;
}
.run-card .head .ids span { white-space: nowrap; }
.run-card .head .ids .k { color: var(--text-faint); }
.run-card .head .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.run-card .head .dur {
  font-family: var(--font-mono); font-size: 11px; color: var(--text);
  background: var(--bg-subtle); padding: 2px 6px; border-radius: 4px;
}
.run-card .head .turn-usage {
  margin-top: 4px; color: var(--text-muted); font-family: var(--font-mono);
  font-size: 10px; white-space: nowrap;
}

.timeline { padding: 8px 0; }
.tl-item {
  display: grid; grid-template-columns: 18px 1fr auto; gap: 8px;
  padding: 4px 12px;
  font-size: 11.5px;
  align-items: center;
}
.tl-item .gut {
  position: relative; height: 100%; display: grid; place-items: center;
}
.tl-item .gut .node {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  z-index: 1;
}
.tl-item .gut::before {
  content: ""; position: absolute; left: 50%; top: -4px; bottom: -4px;
  width: 1px; background: var(--border);
  transform: translateX(-50%);
}
.tl-item:first-child .gut::before { top: 50%; }
.tl-item:last-child .gut::before { bottom: 50%; }
.tl-item .gut.tool .node { background: var(--blue); }
.tl-item .gut.llm .node { background: var(--pink); }
.tl-item .gut.final .node { background: var(--accent); }
.tl-item .label {
  display: flex; align-items: center; gap: 6px;
  min-width: 0;
}
.tl-item .label .kind {
  font-family: var(--font-mono); font-size: 10px;
  padding: 1px 5px; border-radius: 3px;
  flex-shrink: 0;
}
.tl-item .label .kind.tool { background: #eaf1ff; color: var(--blue); }
.tl-item .label .kind.llm { background: #fbe7fd; color: var(--pink); }
.tl-item .label .kind.final { background: var(--accent-bg); color: var(--accent); }
.tl-item .label .name { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-item .dur {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted);
}

.json-block {
  margin: 0 12px 12px;
  min-width: 0;
  max-width: calc(100% - 24px);
}
.json-block .jb-head {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 0 4px;
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.json-block .jb-head .copy {
  margin-left: auto; cursor: pointer;
  font-size: 10.5px; color: var(--text-muted);
  padding: 2px 6px; border-radius: 4px;
}
.json-block .jb-head .copy:hover { background: var(--row-hover); color: var(--text); }
.json-block pre {
  margin: 0;
  background: #0d0d0d;
  color: #e5e5e5;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  overflow: auto;
  white-space: pre;
  width: 100%;
  max-width: 100%;
  max-height: 280px;
}
.json-block pre .k { color: #9cdcfe; }
.json-block pre .s { color: #ce9178; }
.json-block pre .n { color: #b5cea8; }
.json-block pre .b { color: #569cd6; }
.model-io-block .mi-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  background: var(--bg-subtle);
  border-radius: 4px;
  padding: 1px 5px;
}
.model-io-body {
  display: grid;
  gap: 8px;
}
.mi-call {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  min-width: 0;
  overflow: hidden;
}
.mi-head,
.mi-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mi-head {
  min-height: 34px;
  padding: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style-position: inside;
}
.mi-head span:last-child,
.mi-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}
.mi-meta {
  justify-content: flex-start;
  padding: 0 8px 6px;
}
.mi-call .json-block {
  margin: 6px 0 0;
}
.mi-section {
  margin: 0 8px 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.mi-section-title {
  display: flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 8px;
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  cursor: pointer;
  list-style-position: inside;
}
.mi-items {
  display: grid;
  gap: 6px;
  padding: 0 8px 8px;
}
.mi-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  position: relative;
}
.mi-item summary {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 58px 5px 8px;
  cursor: pointer;
  font-size: 11.5px;
  color: var(--text);
  list-style-position: inside;
}
.mi-item summary .mono {
  font-size: 10.5px;
  color: var(--text-muted);
}
.mi-copy {
  position: absolute;
  top: 5px;
  right: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-muted);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  cursor: pointer;
}
.mi-copy:hover {
  color: var(--text);
  background: var(--row-hover);
}
.mi-item pre {
  margin: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  max-height: 240px;
}
.mi-item pre.text {
  background: white;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.mi-empty,
.mi-error {
  padding: 8px 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
}
.mi-error {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

/* empty state */
.empty {
  flex: 1; display: grid; place-items: center;
  color: var(--text-muted); text-align: center; padding: 40px;
}
.empty .icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--bg-subtle); display: grid; place-items: center;
  margin: 0 auto 12px; color: var(--text-muted);
}
.empty h3 { font-size: 14px; font-weight: 600; color: var(--text); margin: 0 0 4px; }
.empty p { font-size: 12.5px; margin: 0; max-width: 240px; }

/* misc utility */
.row { display: flex; align-items: center; gap: 8px; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); }
.dim { color: var(--text-faint); }
.kbd {
  font-family: var(--font-mono); font-size: 10.5px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 4px;
  padding: 0 5px; height: 18px; line-height: 16px; display: inline-block;
  color: var(--text-muted);
}

/* typing dots */
.typing {
  display: inline-flex; gap: 3px; align-items: center;
  padding: 2px 0;
}
.typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* relative anchor used by popover */
.rel { position: relative; }
