@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Claude Code theme colors (from theme.ts dark mode) */
  --claude: rgb(215,119,87);
  --claude-shimmer: rgb(235,159,127);
  --permission: rgb(87,105,247);
  --permission-shimmer: rgb(127,145,255);
  --success: rgb(44,122,57);
  --error: rgb(171,43,63);
  --warning: rgb(200,150,50);
  --plan: rgb(0,102,102);
  --cyan-subagent: rgb(0,180,180);
  --subtle: rgb(100,100,100);
  --bg: rgb(16,16,16);
  --bg-card: rgb(24,24,24);
  --bg-user: rgb(55,55,55);
  --bg-tool: rgb(30,30,30);
  --text: rgb(210,210,210);
  --text-dim: rgb(130,130,130);
  --text-bright: rgb(240,240,240);
  --border: rgb(37,43,42);
  --border-accent: rgb(47,53,52);

  /* ── Tool-row category colors (13 + unknown fallback) ──
     Referenced by .tool-row-{category} .tool-row-icon rules below.
     Keep in sync with CATEGORY_LABELS in tool-taxonomy.js. */
  --cat-shell:     rgb(215,140,60);   /* warm orange — terminal / running */
  --cat-read:      rgb(80, 180, 210); /* cyan — reading docs */
  --cat-write:     rgb(90, 190, 130); /* green — creating new */
  --cat-edit:      rgb(220,160,80);   /* amber — modifying */
  --cat-search:    rgb(170,120,220);  /* purple — querying */
  --cat-fetch:     rgb(140,100,220);  /* purple-blue — external */
  --cat-todo:      rgb(140,140,140);  /* neutral gray — checklist */
  --cat-plan:      rgb(90,180,200);   /* teal — meta / strategy */
  --cat-subagent:  rgb(220,100,180);  /* magenta — spawning agents */
  --cat-question:  rgb(100,150,230);  /* blue — needs user input */
  --cat-message:   rgb(0,180,180);    /* cyan — cross-platform comms */
  --cat-mcp:       rgb(130,130,140);  /* cool gray — external MCP */
  --cat-unknown:   rgb(120,120,120);  /* gray — fallback */

  /* Agent brand colors */
  --agent-claude: rgb(215,119,87);
  --agent-codex: rgb(16,163,127);
  --agent-factory: rgb(139,92,246);
  --agent-gemini: rgb(66,133,244);
  --agent-cursor: rgb(0,229,160);
  --agent-copilot: rgb(110,64,201);
  --agent-openclaw: rgb(234,88,12);
  --agent-opencode: rgb(16,185,129);
  --agent-unknown: rgb(100,100,100);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Code / mono font used inside code blocks, inline code, Bash commands etc. */
code, pre, kbd, samp, .mono {
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', 'Consolas', monospace;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 14px; font-weight: 600; color: var(--text-bright); }
#event-count { font-size: 12px; color: var(--text-dim); }

.header-right { display: flex; align-items: center; gap: 8px; }
#connection-label { font-size: 12px; color: var(--text-dim); }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--error); }

/* ============================================
   Two-column layout
   ============================================ */
#layout {
  display: flex;
  height: calc(100vh - 49px); /* header is ~49px */
  overflow: hidden;
}

#sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sidebar-title { font-weight: 600; }
#session-count {
  background: var(--bg-tool);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  color: var(--text-dim);
}

#session-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.sidebar-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

.session-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.1s;
}
.session-item:hover { background: var(--bg-tool); }
.session-item.active { background: var(--bg-tool); }
.session-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  width: 2px;
  height: 100%;
  background: var(--success);
  margin-left: -14px;
}
.session-item { position: relative; }

.session-row1 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.session-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.session-status.running { background: var(--success); animation: blink 1.8s infinite; }
.session-status.idle    { background: var(--text-dim); }
.session-status.blocked { background: var(--warning); animation: blink 0.8s infinite; }

.session-id {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: auto;
}
.session-time {
  font-size: 10px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: right;
}
.session-time.live-elapsed {
  color: var(--success);
  font-weight: 500;
}
.session-preview {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 10px;
}

#main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Focused-session header — thin, minimal, CodexMonitor-style */
#session-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--bg);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 11px;
  color: var(--text-dim);
}
.session-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.session-header-agent { display: none; }  /* Hidden — no need to repeat per-bubble */
.session-header-id {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.session-header-cwd {
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}

#event-feed {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 14px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* When a session is focused, flip to natural chat order (newest at bottom)
   and open up the gap between bubbles. Tool rows stay tight together like
   a Codex/Claude tool run log. */
#event-feed.session-focused {
  flex-direction: column-reverse;
  padding: 16px 32px 16px 32px;
}
#event-feed.session-focused .chat-bubble {
  margin-top: 14px;
  margin-bottom: 14px;
}
#event-feed.session-focused .tool-row {
  margin: 1px 0;
}
#event-feed.session-focused .tool-row + .tool-row {
  margin-top: 0;
}
#event-feed.session-focused .turn-complete {
  margin: 10px 0;
}
/* Turn separators are only useful inside a focused session — hide in the
   firehose view to avoid confusing the global event log */
#event-feed:not(.session-focused) .turn-complete {
  display: none !important;
}

/* ============================================
   Chat bubbles (CodexMonitor-aligned)
   ============================================ */

.chat-bubble {
  border: none;
  background: transparent;
  display: block;
  padding: 0;
}
.chat-bubble:hover { background: transparent; }

.bubble-row {
  display: flex;
  width: 100%;
}
.chat-bubble-user .bubble-row  { justify-content: flex-end; }
.chat-bubble-assistant .bubble-row { justify-content: flex-start; }

.bubble {
  position: relative;
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* User message — a clearly visible blue bubble, right-aligned */
.bubble-user {
  max-width: min(72%, 560px);
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(90, 120, 220, 0.22);
  border: 1px solid rgba(90, 120, 220, 0.32);
  color: var(--text-bright);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

/* Assistant message — no bubble, just indented text flowing in the document */
.bubble-assistant {
  max-width: 100%;
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text);
}

.bubble-content {
  /* Markdown lives here; see .markdown block below for element styling */
}

.bubble-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 10px;
  color: var(--text-dim);
}
.bubble-user .bubble-meta { justify-content: flex-end; }

.bubble-agent {
  /* reuses .agent-badge styles */
  font-size: 9px;
}

.bubble-time {
  font-variant-numeric: tabular-nums;
}

.bubble-copy {
  position: absolute;
  right: 8px;
  bottom: -10px;
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease, color 160ms ease;
  font-family: inherit;
}
.chat-bubble:hover .bubble-copy {
  opacity: 1;
  transform: translateY(0);
}
.bubble-copy:hover { color: var(--text-bright); }
.bubble-copy.is-copied { color: var(--success); }

/* ============================================
   Markdown rendering (assistant bubble interior)
   ============================================ */
.markdown {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  overflow-wrap: anywhere;
}
.markdown > *:first-child { margin-top: 0; }
.markdown > *:last-child { margin-bottom: 0; }
.markdown > * + * { margin-top: 8px; }

.markdown p { margin: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  font-size: 1em;
  font-weight: 650;
  letter-spacing: 0.01em;
  margin: 0;
  color: var(--text-bright);
}
.markdown ul, .markdown ol {
  margin: 0;
  padding-left: 20px;
}
.markdown li { margin-top: 3px; }
.markdown li:first-child { margin-top: 0; }

.markdown a {
  color: rgb(196, 154, 255);
  text-decoration: none;
  border-bottom: 1px solid rgba(196,154,255,0.3);
}
.markdown a:hover { border-bottom-color: rgb(196,154,255); }

.markdown blockquote {
  margin: 0;
  padding: 6px 10px;
  border-left: 2px solid var(--border-accent);
  background: rgba(255,255,255,0.02);
  border-radius: 0 6px 6px 0;
  color: var(--text-dim);
}

.markdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* inline code */
.markdown :not(pre) > code {
  background: var(--bg-tool);
  border: 1px solid var(--border-accent);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
  font-family: inherit;
  color: var(--text-bright);
}

/* Code block wrapper (added by enhanceCodeBlocks JS) */
.markdown-codeblock {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
  margin: 8px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.markdown-codeblock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: var(--bg-tool);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.markdown-codeblock-lang {
  font-weight: 500;
}
.markdown-codeblock-copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.markdown-codeblock-copy:hover { color: var(--text-bright); background: rgba(255,255,255,0.04); }
.markdown-codeblock-copy.is-copied { color: var(--success); }
.markdown-codeblock pre {
  margin: 0;
  padding: 10px 12px 12px;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text);
  overflow-x: auto;
  background: transparent;
}
.markdown-codeblock pre code {
  background: none;
  border: none;
  padding: 0;
}

/* ============================================
   Turn separator — "—— Done in 42s ——"
   ============================================ */
.turn-complete {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 4px;
}
.turn-complete-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border));
}
.turn-complete-label {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   Session bottom — status bar + composer
   ============================================ */
#session-bottom {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 5;
}

/* Status bar container: sits above the composer. Holds a CodexMonitor-
   style "Working…" pill when thinking/running, and a plain idle summary
   when not. */
#session-status-bar {
  display: flex;
  align-items: center;
  padding: 10px 16px 4px;
  background: var(--bg);
}

/* Working pill — capsule with spinner + timer + shimmer label */
.working {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 11px;
}

.working-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--text-bright);
  animation: working-spin 0.9s linear infinite;
  flex-shrink: 0;
}
@keyframes working-spin { to { transform: rotate(360deg); } }

.working-timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-bright);
  font-variant-numeric: tabular-nums;
}

.working-text {
  position: relative;
  color: transparent;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.3),
    rgba(255,255,255,0.95),
    rgba(255,255,255,0.3)
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: working-shimmer 2.2s ease-in-out infinite;
}
@keyframes working-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.working-text-static {
  color: var(--text-dim);
}

/* Blocked pill — static amber dot instead of spinner */
.working-blocked {
  border-color: rgba(200,150,50,0.35);
  background: rgba(200,150,50,0.06);
}
.working-blocked .working-text-static {
  color: var(--warning);
}

/* Idle state: no pill, just an inline row */
.working-idle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  font-size: 11px;
}
.working-idle .session-status { width: 7px; height: 7px; }

/* Composer row */
#session-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
}
.composer-input {
  flex: 1;
  padding: 9px 12px;
  font-size: 13px;
}
.composer-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.composer-error {
  position: absolute;
  bottom: 60px;
  left: 16px;
  background: rgba(171,43,63,0.15);
  border: 1px solid var(--error);
  color: rgb(255,160,160);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  z-index: 100;
}

/* ============================================
   New Session modal
   ============================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
}
.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.form-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-top: 4px;
}
.form-input,
.form-textarea {
  background: var(--bg-tool);
  border: 1px solid var(--border-accent);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.12s;
}
.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: rgba(255,255,255,0.18);
}
.form-textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}
.form-error {
  font-size: 12px;
  color: rgb(255,160,160);
  min-height: 16px;
}

/* Agent picker — list of clickable rows with checkmark on right */
.agent-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.agent-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.1s;
}
.agent-option:hover { background: var(--bg-tool); }
.agent-option.selected { background: var(--bg-tool); border-color: var(--border-accent); }
.agent-option .option-check {
  width: 16px;
  height: 16px;
  opacity: 0;
  color: var(--text-dim);
}
.agent-option.selected .option-check { opacity: 1; }

/* Primary button (for composer + header) */
.btn-primary {
  border-color: var(--border-accent);
  color: var(--text-bright);
}
.btn-primary:hover { background: var(--bg-tool); }

/* Ghost button (header/filter) */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 4px;
}
.btn-ghost:hover { background: var(--bg-tool); color: var(--text); }

/* ============================================
   Event Card — expandable row
   ============================================ */
.event-card {
  border-bottom: none;
  transition: background 0.15s;
}
.event-card:hover { background: rgba(255,255,255,0.02); border-radius: 6px; }
.event-card.expanded { background: rgba(255,255,255,0.03); border-radius: 6px; }
.event-card.highlight { background: rgba(87,105,247,0.12); transition: background 0.3s; border-radius: 6px; }

/* ============================================
   Tool row — minimal CodexMonitor inline
   ● ToolLabel · argument
   ============================================ */
.tool-row {
  padding: 0;
}
.tool-row-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  min-width: 0;
}
.tool-row-line:hover {
  color: var(--text);
  background: rgba(255,255,255,0.02);
  border-radius: 4px;
}

.tool-row-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--cat-unknown);
  align-self: center;
}

/* ── Category colors (base "completed" state) ──────────────── */
.tool-row.tool-row-shell    .tool-row-icon { background: var(--cat-shell); }
.tool-row.tool-row-read     .tool-row-icon { background: var(--cat-read); }
.tool-row.tool-row-write    .tool-row-icon { background: var(--cat-write); }
.tool-row.tool-row-edit     .tool-row-icon { background: var(--cat-edit); }
.tool-row.tool-row-search   .tool-row-icon { background: var(--cat-search); }
.tool-row.tool-row-fetch    .tool-row-icon { background: var(--cat-fetch); }
.tool-row.tool-row-todo     .tool-row-icon { background: var(--cat-todo); }
.tool-row.tool-row-plan     .tool-row-icon { background: var(--cat-plan); }
.tool-row.tool-row-subagent .tool-row-icon { background: var(--cat-subagent); }
.tool-row.tool-row-question .tool-row-icon { background: var(--cat-question); }
.tool-row.tool-row-message  .tool-row-icon { background: var(--cat-message); }
.tool-row.tool-row-mcp      .tool-row-icon { background: var(--cat-mcp); }

/* Unknown → HOLLOW circle (border only, no fill). This is deliberately
   different from Todo's solid gray dot so users can tell "we couldn't
   classify this" apart from "this is a todo entry". */
.tool-row.tool-row-unknown .tool-row-icon {
  background: transparent;
  border: 1px solid var(--cat-unknown);
  width: 7px;
  height: 7px;
  box-sizing: border-box;
}

/* ── Status overrides (running / failed win over category color) ──
   Written AFTER category rules so CSS cascade resolves to status at
   equal specificity. Also explicitly reset border/box-sizing so the
   unknown-hollow style (border only) gets filled back in for running. */
.tool-row.tool-row-running .tool-row-icon {
  background: var(--warning);
  border: none;
  box-shadow: 0 0 6px rgba(215,140,60,0.45);
  animation: tool-pulse 1.1s ease-in-out infinite;
}
.tool-row.tool-row-failed .tool-row-icon {
  background: var(--error);
  border: none;
  box-shadow: 0 0 5px rgba(171,43,63,0.4);
}
@keyframes tool-pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.15); }
}

/* Failed rows also dim the label/value slightly */
.tool-row.tool-row-failed .tool-row-name  { color: rgb(255,160,160); }
.tool-row.tool-row-failed .tool-row-value { opacity: 0.7; }

.tool-row-name {
  color: var(--text-bright);
  font-weight: 500;
  flex-shrink: 0;
  font-size: 12px;
  min-width: 44px;
}
.tool-row-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-dim);
}
/* Monospace for paths / commands / diffs */
.tool-row-value.mono {
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
  font-size: 11px;
}

/* Clickable header row (fallback for non-tool non-bubble events) */
.card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
}

/* In focused view:
   - Tool-call rows have their own compact .tool-row-line layout
   - Chat bubbles have their own layout
   - LIFECYCLE events (SessionStart, SessionEnd, SubagentStart/Stop,
     Notification, PermissionRequest, Elicitation, PreCompact, etc.) still
     use the old .card-row format. We hide the per-row agent badge +
     session short id + timestamp (those are redundant when the session is
     already focused) but KEEP the event-name badge and expand-arrow so
     users can actually tell what type of event each row is. */
#event-feed.session-focused .event-card:not(.chat-bubble):not(.tool-row) .agent-badge,
#event-feed.session-focused .event-card:not(.chat-bubble):not(.tool-row) .card-session,
#event-feed.session-focused .event-card:not(.chat-bubble):not(.tool-row) .card-time {
  display: none;
}
/* Make the event-name badge more readable in focused view */
#event-feed.session-focused .event-card:not(.chat-bubble):not(.tool-row) .event-badge {
  background: transparent;
  padding: 0;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 500;
}

.card-summary {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
}
.sum-tool { color: var(--text-bright); font-weight: 600; margin-right: 6px; }
.sum-tool.gateway-reply { color: var(--cyan-subagent); }
.sum-desc { color: var(--text-dim); }
.sum-prompt { color: #d2a8ff; font-style: italic; }

.expand-arrow {
  color: var(--text-dim);
  font-size: 10px;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  transition: transform 0.15s;
}

.card-time {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.card-session {
  font-size: 11px;
  color: var(--text-dim);
  font-family: inherit;
}

/* Expanded detail panel */
.card-detail {
  padding: 8px 16px 12px 36px;
  border-top: 1px solid rgba(255,255,255,0.04);
}

.detail-section {
  margin-bottom: 10px;
}

.detail-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.detail-json {
  background: var(--bg-tool);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-dim);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.detail-json.output { border-left: 2px solid var(--success); color: var(--text); }
.detail-json.error-block { border-left: 2px solid var(--error); color: rgb(255,160,160); }

/* Timeline */
.timeline {
  border-left: 2px solid var(--border);
  padding-left: 12px;
  margin-top: 4px;
}
.timeline-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 11px;
}
.timeline-item:hover { background: rgba(255,255,255,0.05); }
.timeline-item.current { background: rgba(87,105,247,0.1); border-left: 2px solid var(--permission); margin-left: -14px; padding-left: 18px; }
.tl-time { color: var(--text-dim); flex-shrink: 0; }
.tl-name { color: var(--text); }

/* ============================================
   Agent badge — small colored pill
   ============================================ */
.agent-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
}
.agent-claude { background: var(--agent-claude); color: #1a0e00; }
.agent-codex { background: var(--agent-codex); color: #fff; }
.agent-factory { background: var(--agent-factory); color: #fff; }
.agent-gemini { background: var(--agent-gemini); color: #fff; }
.agent-cursor { background: var(--agent-cursor); color: #0a0a0a; }
.agent-copilot { background: var(--agent-copilot); color: #fff; }
.agent-qoder { background: #f97316; color: #fff; }
.agent-codebuddy { background: #ec4899; color: #fff; }
.agent-hermes { background: #e74c3c; color: #fff; }
.agent-openclaw { background: var(--agent-openclaw); color: #fff; }
.agent-opencode { background: var(--agent-opencode); color: #fff; }
.agent-unknown { background: var(--agent-unknown); color: #ccc; }

/* ============================================
   Status indicator — ⏺ dot like Claude Code
   ============================================ */
.status-indicator {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  font-size: 10px;
  line-height: 1;
}
.status-indicator.success { color: var(--success); }
.status-indicator.error { color: var(--error); }
.status-indicator.pending { color: var(--warning); animation: blink 1s infinite; }
.status-indicator.info { color: var(--permission); }
.status-indicator.dim { color: var(--text-dim); }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ============================================
   Event type badge — subtle inline label
   ============================================ */
.event-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
}

/* ============================================
   Tool name in detail
   ============================================ */
.tool-name {
  font-weight: 700;
  color: var(--text-bright);
  font-size: 13px;
}

.tool-desc {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 2px;
}

/* Toggle button */
.toggle-btn {
  font-size: 11px;
  color: var(--permission);
  cursor: pointer;
  margin-top: 4px;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}
.toggle-btn:hover { text-decoration: underline; }

/* ============================================
   User prompt — highlighted background
   ============================================ */
.user-prompt-text {
  background: var(--bg-user);
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--text-bright);
  font-size: 13px;
}

/* ============================================
   Assistant message — from Stop events
   ============================================ */
.assistant-msg {
  color: var(--claude);
  font-size: 12px;
  margin-top: 4px;
  padding: 6px 10px;
  border-left: 2px solid var(--claude);
  background: rgba(215,119,87,0.06);
  border-radius: 0 4px 4px 0;
}
.assistant-msg.gateway-msg {
  color: var(--cyan-subagent);
  border-left-color: var(--cyan-subagent);
  background: rgba(0,180,180,0.06);
}

/* ============================================
   Error message
   ============================================ */
.error-msg {
  color: rgb(255,160,160);
  font-size: 12px;
  margin-top: 4px;
  padding: 6px 10px;
  border-left: 2px solid var(--error);
  background: rgba(171,43,63,0.1);
  border-radius: 0 4px 4px 0;
}

/* ============================================
   Decision / Permission UI — Paseo-aligned
   spacing[2]=8px spacing[3]=12px spacing[1]=4px
   borderRadius.md=6px borderRadius.lg=8px
   ============================================ */

/* Card container — surface1 bg, 12px pad, 8px gap, 8px radius */
.decision-block {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Title line (Permission Required / Plan / …) */
.decision-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-bright);
  line-height: 1.55;
}

/* Description line */
.decision-desc {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
}

/* "How would you like to proceed?" hint */
.question-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  margin-bottom: 4px;
}

/* Question text (Notification / Elicitation message) */
.question-text {
  font-size: 13px;
  color: var(--text-bright);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Options list — gap 4px between items (spacing[1]) */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Option row — 8px v, 12px h padding; 6px radius; check on RIGHT */
.option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, opacity 0.1s;
}
.option-item:hover   { background: var(--bg-tool); }
.option-item.selected{ background: var(--bg-tool); }
.option-item.loading { opacity: 0.5; pointer-events: none; }

.option-label {
  font-size: 12px;
  color: var(--text);
  flex: 1;
  line-height: 1.5;
}
.option-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Check icon — RIGHT side, only visible when selected */
.option-check {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0;
  text-align: center;
  margin-left: 8px;
}
.option-item.selected .option-check { opacity: 1; }

/* "Other…" free-text input below options list */
.other-input {
  width: 100%;
  border: 1px solid var(--border-accent);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  font-family: inherit;
  background: var(--bg-tool);
  color: var(--text);
  transition: border-color 0.12s;
}
.other-input:focus { outline: none; border-color: rgba(255,255,255,0.18); }

/* Actions row — horizontal, gap 8px */
.decision-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

/* ── Button — Paseo exact spec ─────────────────────────────
   paddingVertical: spacing[2]=8px
   paddingHorizontal: spacing[3]=12px
   borderRadius: borderRadius.md=6px
   fontSize: sm=12px  fontWeight: normal
   borderWidth: 1  borderColor: borderAccent
   bg: surface1  hover bg: surface2
   pressed: opacity 0.9   disabled: opacity 0.5
   ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  border: 1px solid var(--border-accent);
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-dim);          /* foregroundMuted — default (deny) */
  transition: background 0.1s, opacity 0.1s;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover   { background: var(--bg-tool); }
.btn:active  { opacity: 0.9; }
.btn:disabled{ opacity: 0.5; cursor: default; pointer-events: none; }

/* Primary action (Allow / Accept / Implement) — foreground (bright) text */
.btn-allow { color: var(--text-bright); }

/* Deny — same as .btn base (foregroundMuted), no extra styling */
.btn-deny { /* inherits foregroundMuted color from .btn */ }

/* Legacy .btn-option alias */
.btn-option { color: var(--text-dim); }

/* Loading — spinner replaces all child content */
.btn-loading { pointer-events: none; }
.btn-loading > * { display: none; }
.btn-loading::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.55s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Already-decided inline label */
.decision-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* No colored backgrounds — match Paseo's neutral style */
.decision-allowed { color: var(--text-dim); }
.decision-denied  { color: var(--text-dim); }
.decision-answered{ color: var(--text-dim); }

/* ============================================
   Session / lifecycle events — subtle
   ============================================ */
.lifecycle-info {
  color: var(--text-dim);
  font-size: 12px;
}

/* ============================================
   Subagent — cyan accent like Claude Code
   ============================================ */
.subagent-info {
  color: var(--cyan-subagent);
  font-size: 12px;
  font-weight: 500;
}

/* ============================================
   Blocking card highlight
   ============================================ */
.event-card.blocking {
  border-left: 2px solid var(--permission);
  padding-left: 8px;
  background: rgba(87,105,247,0.03);
}
.event-card.decided { opacity: 0.5; }

/* ============================================
   Empty state
   ============================================ */
/* Text input for answers */
.text-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-tool);
  border: 1px solid var(--border-accent);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  transition: border-color 0.12s;
  min-width: 0;
}
.text-input:focus { outline: none; border-color: rgba(255,255,255,0.18); }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}
.empty-state h2 { font-size: 16px; margin-bottom: 8px; color: var(--subtle); }
.empty-state p { font-size: 13px; }
.empty-state .logo { font-size: 28px; color: var(--claude); margin-bottom: 12px; }

/* ============================================
   Raw JSON overlay
   ============================================ */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
#overlay-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
#overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
}
.overlay-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  font-family: inherit;
}
.overlay-close:hover { color: var(--text-bright); }
#overlay-content {
  padding: 16px;
  overflow-y: auto;
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============================================
   Specialized tool-row detail renderers
   (shell output / todo checklist / patch summary / edit diff)
   ============================================ */

/* Shell command block — mono with category-colored left stripe */
.detail-shell-command {
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
  font-size: 11px;
  background: var(--bg-tool);
  border-left: 2px solid var(--cat-shell);
  padding: 6px 10px;
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  border-radius: 0 4px 4px 0;
}
.detail-label-muted {
  color: var(--text-dim);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 9px;
}

/* Shell output block — a bit more prominent, capped for long runs */
.detail-shell-output {
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 10px;
  margin: 0;
  color: var(--text);
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border-radius: 4px;
  line-height: 1.45;
}

/* Todo checklist — vertical list with colored status glyphs */
.detail-todo-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}
.detail-todo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 3px 0;
  font-size: 12px;
  line-height: 1.5;
}
.detail-todo-check {
  width: 14px;
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
  font-size: 12px;
  text-align: center;
  font-weight: 700;
}
.detail-todo-item.todo-completed .detail-todo-check   { color: var(--success); }
.detail-todo-item.todo-cancelled .detail-todo-check   { color: var(--error); }
.detail-todo-item.todo-in_progress .detail-todo-check {
  color: var(--warning);
  animation: tool-pulse 1.2s ease-in-out infinite;
}
.detail-todo-item.todo-pending .detail-todo-check     { color: var(--text-dim); }

.detail-todo-item.todo-completed .detail-todo-text {
  color: var(--text-dim);
  text-decoration: line-through;
  text-decoration-color: rgba(255,255,255,0.18);
}
.detail-todo-item.todo-cancelled .detail-todo-text {
  color: var(--text-dim);
  text-decoration: line-through;
  text-decoration-color: rgba(171,43,63,0.35);
  opacity: 0.65;
}
.detail-todo-item.todo-in_progress .detail-todo-text { color: var(--text-bright); font-weight: 500; }
.detail-todo-item.todo-pending .detail-todo-text     { color: var(--text); }
.detail-todo-text { flex: 1; }

/* Patch / edit file summary — one row per changed file */
.detail-patch-files {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detail-patch-file {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 3px;
  background: var(--bg-tool);
}
.detail-patch-kind {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  width: 12px;
  text-align: center;
  flex-shrink: 0;
}
.detail-patch-file.patch-add    .detail-patch-kind { color: var(--success); }
.detail-patch-file.patch-delete .detail-patch-kind { color: var(--error); }
.detail-patch-file.patch-update .detail-patch-kind { color: var(--cat-edit); }
.detail-patch-path {
  color: var(--text);
  word-break: break-all;
  font-size: 11px;
}

/* Edit removed / added diff blocks */
.detail-edit-removed {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: rgba(171,43,63,0.08);
  border-left: 2px solid var(--error);
  padding: 6px 10px;
  color: rgb(255,170,170);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  border-radius: 0 4px 4px 0;
  max-height: 200px;
  overflow: auto;
  line-height: 1.45;
}
.detail-edit-added {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: rgba(44,122,57,0.08);
  border-left: 2px solid var(--success);
  padding: 6px 10px;
  color: rgb(170,220,180);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 4px 0 0 0;
  border-radius: 0 4px 4px 0;
  max-height: 200px;
  overflow: auto;
  line-height: 1.45;
}
.detail-multiedit-item {
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.detail-multiedit-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
