/* ── Runtime view ──────────────────────────────────────────────────────────── */

.runtime-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

/* KPI row */
.runtime-kpis {
  display: flex;
  gap: 12px;
}

.rt-kpi {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  min-width: 0;
  text-align: left;
}

.rt-kpi-action {
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.rt-kpi-action:hover,
.rt-kpi-action[aria-expanded="true"] {
  border-color: var(--accent);
  background: oklch(87% 0.19 152 / 7%);
}

.rt-kpi-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rt-kpi-val {
  font: 700 26px/1 var(--font-mono, ui-monospace, monospace);
  color: var(--accent);
  margin-bottom: 4px;
}

.rt-kpi-lbl {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Active tool pills */
.rt-active-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}

.rt-active-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: oklch(87% 0.19 152 / 8%);
  border: 1px solid oklch(87% 0.19 152 / 25%);
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
  font: 12px var(--font-mono, ui-monospace, monospace);
  animation: rt-pill-in 0.15s ease;
}

@keyframes rt-pill-in {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: none; }
}

.rt-pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: rt-pulse-anim 1.2s ease-in-out infinite;
}

@keyframes rt-pulse-anim {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.rt-active-tool { color: var(--accent); }
.rt-active-elapsed { color: var(--text-muted); font-size: 11px; }

/* Filter bar */
.rt-filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rt-filter-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font: 12px ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.rt-filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rt-filter-btn.active {
  border-color: var(--accent);
  background: oklch(87% 0.19 152 / 10%);
  color: var(--accent);
}

.rt-filter-clear {
  margin-left: auto;
  border-color: var(--border);
}

.rt-filter-clear:hover {
  border-color: var(--bad, #ef4444);
  color: var(--bad, #ef4444);
}

/* Feed */
.rt-feed-wrap {
  overflow-y: auto;
  max-height: calc(100vh - 320px);
  min-height: 200px;
}

.rt-feed {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Empty state */
.rt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.rt-empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.rt-empty-title {
  font: 600 15px ui-sans-serif, system-ui, sans-serif;
  margin-bottom: 6px;
}

.rt-empty-sub {
  font-size: 13px;
  max-width: 360px;
  opacity: 0.7;
}

/* Event card */
.rt-ev {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  padding: 8px 12px;
  border-radius: 7px;
  border-left: 3px solid transparent;
  background: var(--surface);
  font-size: 13px;
  animation: rt-ev-in 0.12s ease;
  transition: background 0.15s;
}

.rt-ev:hover { background: var(--surface2, oklch(18% 0.015 240)); }

@keyframes rt-ev-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.rt-ev.sev-ok   { border-left-color: var(--ok); }
.rt-ev.sev-bad  { border-left-color: var(--bad, #ef4444); }
.rt-ev.sev-warn { border-left-color: var(--warn); }
.rt-ev.sev-info { border-left-color: var(--accent); }

.rt-ev-lead {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 7px;
}

.rt-ev-icon { font-size: 14px; flex-shrink: 0; }

.rt-ev-type {
  font: 600 13px var(--font-mono, ui-monospace, monospace);
  color: var(--text);
}

.rt-ev-badge {
  font: 11px var(--font-mono, ui-monospace, monospace);
  padding: 1px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}

.rt-badge-tokens { background: oklch(80% 0.16 80 / 15%); color: var(--warn); }
.rt-badge-dur    { background: var(--surface2, oklch(18% 0.015 240)); color: var(--text-muted); }
.rt-badge-err    { background: oklch(65% 0.22 25 / 15%); color: var(--bad, #ef4444); }

.rt-ev-detail {
  grid-column: 1;
  grid-row: 2;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono, ui-monospace, monospace);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rt-ev-time {
  grid-column: 2;
  grid-row: 1 / 3;
  font: 11px var(--font-mono, ui-monospace, monospace);
  color: var(--text-muted);
  opacity: 0.6;
  align-self: center;
  white-space: nowrap;
}

/* ── MCP Live Activity Strip ─────────────────────────────────────────────────── */
.rt-mcp-strip {
  min-height: 0;
}

/* ── Token telemetry flyout ─────────────────────────────────────────────────── */
.rt-token-flyout-slot {
  position: relative;
}

.rt-token-flyout {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: 0 18px 45px oklch(0% 0 0 / 35%);
  animation: rt-ev-in 0.12s ease;
}

.rt-token-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.rt-token-title {
  font: 700 14px ui-sans-serif, system-ui, sans-serif;
  color: var(--text);
}

.rt-token-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted);
}

.rt-token-error { color: var(--bad, #ef4444); }

.rt-token-close {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  padding: 4px 9px;
  cursor: pointer;
  font-size: 12px;
}

.rt-token-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rt-token-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.rt-token-stat {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px;
  background: var(--bg-panel, transparent);
}

.rt-token-stat span,
.rt-token-row span {
  color: var(--text-muted);
  font-size: 11px;
}

.rt-token-stat strong {
  display: block;
  margin-top: 5px;
  font: 700 20px/1 var(--font-mono, ui-monospace, monospace);
  color: var(--accent);
}

.rt-token-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.rt-token-section-title {
  color: var(--text-muted);
  font: 700 11px var(--font-mono, ui-monospace, monospace);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.rt-token-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--border);
  padding: 6px 0;
  min-width: 0;
}

.rt-token-row strong {
  color: var(--text);
  font: 700 12px var(--font-mono, ui-monospace, monospace);
}

.rt-token-row span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-token-muted {
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px 0;
}

@media (max-width: 900px) {
  .runtime-kpis,
  .rt-token-grid,
  .rt-token-columns {
    grid-template-columns: 1fr;
  }
  .runtime-kpis {
    display: grid;
  }
}

.rt-mcp-strip-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0;
}

.rt-mcp-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 20px;
  padding: 3px 10px 3px 7px;
  font: 11px var(--font-mono, ui-monospace, monospace);
  animation: rt-pill-in 0.15s ease;
  white-space: nowrap;
}

.rt-mcp-active {
  background: oklch(87% 0.19 152 / 8%);
  border: 1px solid oklch(87% 0.19 152 / 28%);
  color: var(--accent);
}

.rt-mcp-long {
  background: oklch(85% 0.18 80 / 8%);
  border: 1px solid oklch(85% 0.18 80 / 35%);
  color: var(--warn);
}

.rt-mcp-done {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  opacity: 0.75;
}

.rt-mcp-err {
  background: oklch(65% 0.22 25 / 8%);
  border: 1px solid oklch(65% 0.22 25 / 25%);
  color: var(--bad, #ef4444);
  opacity: 0.85;
}

.rt-mcp-tool { letter-spacing: 0.01em; }
.rt-mcp-elapsed { opacity: 0.65; font-size: 10px; }

.rt-mcp-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 3px;
}

.rt-mcp-badge-ok  { background: oklch(87% 0.19 152 / 12%); color: var(--ok, #22c55e); }
.rt-mcp-badge-err { background: oklch(65% 0.22 25 / 12%); color: var(--bad, #ef4444); }

/* ── Toast system ─────────────────────────────────────────────────────────────── */
.rt-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.rt-toast {
  padding: 10px 16px;
  border-radius: 8px;
  font: 13px ui-sans-serif, system-ui, sans-serif;
  max-width: 360px;
  box-shadow: 0 4px 16px oklch(0% 0 0 / 40%);
  animation: rt-toast-in 0.2s ease;
  pointer-events: auto;
  transition: opacity 0.4s;
}

.rt-toast-info    { background: var(--surface); border: 1px solid var(--accent); color: var(--text); }
.rt-toast-warn    { background: var(--surface); border: 1px solid var(--warn);   color: var(--warn); }
.rt-toast-bad     { background: var(--surface); border: 1px solid var(--bad, #ef4444); color: var(--bad, #ef4444); }

.rt-toast-fade { opacity: 0; }

@keyframes rt-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ── Upgrade nudge bar ───────────────────────────────────────────────────────── */
.rt-upgrade-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: oklch(85% 0.18 80 / 8%);
  border: 1px solid oklch(85% 0.18 80 / 30%);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}

.rt-upgrade-msg  { flex: 1; color: var(--warn); }
.rt-upgrade-btn  { padding: 4px 12px; border-radius: 6px; background: var(--warn); color: #000; font-weight: 600; font-size: 12px; text-decoration: none; }
.rt-upgrade-dismiss { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 0 4px; }
