/* ══════════════════════════════════════════════════
   Context Analytics Dashboard — Metallic Hardware Aesthetic
   Responsive: mobile-first, breakpoints at 640/1024
   ══════════════════════════════════════════════════ */

:root {
  /* ── Surface depth hierarchy (darkest → lightest) ── */
  --bg:       #0e0e11;   /* outermost shell — near-black warm */
  --well:     #0c0c10;   /* recessed wells — deepest inset areas */
  --surface:  #18181c;   /* mid surface — main faceplate */
  --surface2: #1f1f24;   /* raised surface — where controls sit */
  --surface3: #28282e;   /* elevated surface — hover states, active cards */

  /* ── Text hierarchy ── */
  --text:     #d8d8dc;   /* primary text — bright but not pure white */
  --text-hi:  #eaeaee;   /* high-emphasis — values, numbers, active labels */
  --muted:    #6b6b74;   /* secondary text — labels, metadata */
  --dim:      #44444c;   /* tertiary text — hints, disabled */

  /* ── Border system (bezel simulation) ── */
  --border:        rgba(255, 255, 255, 0.07);  /* standard border */
  --border-hover:  rgba(255, 255, 255, 0.14);  /* hover state */
  --bezel-hi:      rgba(255, 255, 255, 0.10);  /* top/left highlight edge */
  --bezel-lo:      rgba(0, 0, 0, 0.50);        /* bottom/right shadow edge */
  --bezel-ring:    rgba(255, 255, 255, 0.05);  /* inner bezel ring */

  /* ── Accent & status ── */
  --accent:      #8b5cf6;
  --accent-dim:  rgba(139, 92, 246, 0.15);
  --accent-text: #a78bfa;
  --urgent:      #ef4444;
  --medium:      #f59e0b;
  --ok:          #22c55e;

  /* ── Typography ── */
  --mono: "Berkeley Mono", "SF Mono", ui-monospace, SFMono-Regular, Menlo,
    Monaco, Consolas, monospace;
  --font-display: 'Doto', var(--mono);

  /* ── Shape & motion ── */
  --radius:    6px;       /* default corner radius — hardware-rounded */
  --radius-sm: 4px;       /* small elements — badges, chips */
  --radius-lg: 10px;      /* large containers — panels, overlays */
  --topbar-h:  41px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* ── Inset / raised shadow presets ── */
  --shadow-well:   inset 0 3px 8px rgba(0, 0, 0, 0.55), inset 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-raised: 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-bezel:  inset 0 1px 0 var(--bezel-hi), inset 0 -1px 0 var(--bezel-lo);
}

@media (min-width: 640px) {
  :root {
    --topbar-h: 41px;
  }
}

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

::selection {
  background: var(--accent-dim);
  color: var(--text);
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* subtle noise-like texture via radial gradient */
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(255,255,255,0.015) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(255,255,255,0.008) 0%, transparent 50%);
}

/* ── Topbar ── */

#topbar {
  flex-shrink: 0;
  border-bottom: 1px solid var(--bezel-lo);
  background: var(--surface);
  position: relative;
  z-index: 10;
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),       /* top highlight edge */
    0 1px 4px rgba(0, 0, 0, 0.4);        /* drop shadow below */
}

#brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  flex-shrink: 0;
  align-self: center;
  background: linear-gradient(180deg, #e8eaee 0%, #9ca0a8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

#nav-sep {
  width: 1px;
  height: 20px;
  background: linear-gradient(180deg, var(--bezel-hi), var(--bezel-lo));
  margin: 0 6px;
  flex-shrink: 0;
  align-self: center;
  border-radius: 1px;
}

#status {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  min-width: 0;
  transition: color 0.6s ease-out;
  flex-shrink: 1;
  margin-right: 8px;
  align-self: center;
}

#nav-spacer {
  flex: 1;
}

/* Session selector — mini LCD readout in metallic chassis */
.session-select-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  align-self: center;
  /* outer chassis bezel */
  background: linear-gradient(180deg, #2a2a30 0%, #1e1e24 100%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.14);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-lg);
  padding: 3px;
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  margin-right: 8px;
}

.session-select-label {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
  padding-left: 5px;
  text-transform: uppercase;
  white-space: nowrap;
}

#global-session {
  padding: 4px 26px 4px 10px;
  border-radius: 7px;
  /* LCD screen */
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  outline: 1px solid rgba(0, 0, 0, 0.20);
  background: linear-gradient(180deg, #c0c4c8 0%, #c8ccd0 40%, #c4c8cc 70%, #bcc0c4 100%);
  color: #1a1e28;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  appearance: none;
  -webkit-appearance: none;
  /* dark chevron for LCD */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%231a1e28'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 8px 5px;
  max-width: 240px;
  min-width: 140px;
  cursor: pointer;
  transition: box-shadow 0.15s, background 0.15s;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.08),
    inset 0 -1px 0 rgba(255, 255, 255, 0.5);
  text-shadow: none;
  outline-offset: -1px;
}

#global-session:hover {
  background: linear-gradient(180deg, #c8ccd0 0%, #d0d4d8 40%, #ccd0d4 70%, #c4c8cc 100%);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.06),
    inset 0 -1px 0 rgba(255, 255, 255, 0.6);
}

#global-session:focus {
  border-color: rgba(139, 92, 246, 0.60);
  outline-color: rgba(139, 92, 246, 0.30);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.08),
    inset 0 -1px 0 rgba(255, 255, 255, 0.5),
    0 0 0 2px rgba(139, 92, 246, 0.15);
}

#global-session option {
  background: #2a2a30;
  color: var(--text);
  font-family: var(--mono);
  font-weight: 500;
}

.session-kbd {
  font-size: 9px;
  font-family: var(--font-display);
  font-weight: 700;
  color: #1a1e28;
  /* LCD pill inside the chassis */
  background: linear-gradient(180deg, #c0c4c8 0%, #b8bcc0 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  outline: 1px solid rgba(0, 0, 0, 0.20);
  border-radius: 5px;
  padding: 2px 6px;
  line-height: 1.3;
  pointer-events: none;
  margin-left: 3px;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.06),
    inset 0 -1px 0 rgba(255, 255, 255, 0.4);
}

/* Search — LCD readout input */
#search {
  width: 180px;
  min-width: 180px;
  padding: 5px 10px;
  margin-left: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top-color: rgba(255, 255, 255, 0.22);
  outline: none;
  background: linear-gradient(180deg, var(--surface2), var(--surface));
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  transition: width 0.2s var(--ease), box-shadow 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
  align-self: center;
  box-shadow: var(--shadow-raised), var(--shadow-bezel);
  text-shadow: none;
}

#search:focus {
  border-color: rgba(167, 139, 250, 0.52);
  background: var(--surface2);
  width: 220px;
  box-shadow:
    var(--shadow-raised),
    var(--shadow-bezel),
    0 0 0 2px rgba(139, 92, 246, 0.15);
}

#search::placeholder {
  color: var(--dim);
  font-weight: 500;
}

#clock {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  display: none;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

@media (min-width: 640px) {
  #search {
    width: 180px;
    min-width: 180px;
  }

  #search:focus {
    width: 220px;
  }

  #clock {
    display: block;
  }
}

/* ── Nav ── */

#nav {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  height: 44px;
}

#nav::-webkit-scrollbar {
  display: none;
}

/* Nav button group — buttons sit inside a shared recessed capsule track */
.nav {
  background: transparent;
  border: none;
  border-bottom: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  border-radius: var(--radius-sm);
  margin: 0 1px;
  position: relative;
}

.nav:hover {
  color: var(--text);
  background: var(--surface2);
}

.nav.active {
  color: var(--text-hi);
  background: var(--surface3);
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    inset 0 -1px 0 var(--bezel-lo),
    0 1px 3px rgba(0, 0, 0, 0.3);
  border-bottom: none;
}

/* subtle accent indicator on active tab */
.nav.active::after {
  content: '';
  position: absolute;
  bottom: 1px;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  box-shadow: 0 0 6px var(--accent-dim);
}

@media (min-width: 640px) {
  .nav {
    font-size: 11px;
    padding: 6px 14px;
  }
}

/* ── Layout ── */

#layout {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

#main {
  flex: 1;
  padding: clamp(10px, 2vw, 24px);
  overflow: auto;
  min-height: 0;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

/* ── Layout resizer ── */

#layout-resizer {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: var(--bg);
  position: relative;
  z-index: 5;
  border-left: 1px solid var(--bezel-hi);
  border-right: 1px solid var(--bezel-lo);
  box-shadow:
    inset 1px 0 0 var(--bezel-hi),
    inset -1px 0 0 var(--bezel-lo),
    inset 0 0 4px rgba(0, 0, 0, 0.5);
}

#layout-resizer:hover,
#layout-resizer.dragging {
  border-left-color: rgba(255, 255, 255, 0.08);
}

#layout-resizer::after {
  content: '';
  position: absolute;
  inset: 0 -3px;
}

@media (max-width: 639px) {
  #layout-resizer {
    display: none;
  }
}

/* ── Turn Flow panel (left side, mirrors #detail) ── */

#turnflow {
  border-right: none;
  background: var(--surface);
  min-height: 0;
  display: flex;
  position: relative;
  flex-shrink: 0;
  transition: width 0.3s var(--ease);
  will-change: width;
  box-shadow:
    inset -1px 0 0 var(--bezel-lo),
    inset 0 1px 0 var(--bezel-hi);
  overflow: hidden;
}

#turnflow.tf-panel-open {
  width: 320px;
}

#turnflow.tf-panel-closed {
  width: 28px;
}

#tf-toggle {
  position: absolute;
  right: 0;
  top: 0;
  width: 28px;
  height: 100%;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  z-index: 2;
  writing-mode: vertical-rl;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0;
  transition: color 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

#turnflow.tf-panel-open #tf-toggle {
  opacity: 0;
  pointer-events: none;
}

#tf-toggle:hover {
  color: var(--text);
}

#tf-toggle::after {
  content: "turns";
}

#turnflow.tf-panel-open #tf-toggle::before {
  content: "\2039";
  writing-mode: horizontal-tb;
  position: absolute;
  top: 8px;
  right: 50%;
  transform: translateX(50%);
  font-size: 14px;
  color: var(--dim);
}

#turnflow.tf-panel-closed #tf-toggle::before {
  content: "\203A";
  writing-mode: horizontal-tb;
  position: absolute;
  top: 8px;
  right: 50%;
  transform: translateX(50%);
  font-size: 14px;
  color: var(--dim);
}

#tf-inner {
  display: flex;
  flex: 1;
  min-width: 0;
  margin-right: 0;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.25s ease-out 0.08s, transform 0.3s var(--ease);
}

#turnflow.tf-panel-closed #tf-inner {
  opacity: 0;
  transform: translateX(-20px);
  pointer-events: none;
}

/* list pane */
#tf-convo-pane {
  position: relative;
  width: 220px;
  min-width: 180px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--bezel-lo);
  background: var(--surface);
  transition: width 0.25s var(--ease);
  will-change: width;
  box-shadow: inset -1px 0 0 var(--bezel-hi);
}

#tf-convo-pane.tf-convo-hidden {
  width: 28px;
  min-width: 28px;
  border-right: none;
  overflow: hidden;
}

/* vertical toggle/label button on right edge — mirrors #tf-toggle */
#tf-convo-toggle {
  position: absolute;
  right: 0;
  top: 0;
  width: 28px;
  height: 100%;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  z-index: 2;
  writing-mode: vertical-rl;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0;
  transition: color 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

/* when open: fade out vertical strip (header close button takes over) */
#tf-convo-pane:not(.tf-convo-hidden) #tf-convo-toggle {
  opacity: 0;
  pointer-events: none;
}

#tf-convo-toggle::after {
  content: "convos";
}

/* chevron indicator when collapsed */
#tf-convo-toggle::before {
  content: "\203A";
  writing-mode: horizontal-tb;
  position: absolute;
  top: 8px;
  right: 50%;
  transform: translateX(50%);
  font-size: 14px;
  color: var(--dim);
}

#tf-convo-toggle:hover {
  color: var(--text);
}

#tf-convo-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#tf-convo-pane.tf-convo-hidden #tf-convo-inner {
  display: none;
}

#tf-convo-inner > #ce-convo-flow {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--well);
}

#tf-list-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  -webkit-overflow-scrolling: touch;
}

#tf-list-pane > #ce-turn-flow {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* scale animation only on rows, not the whole pane */

/* ── Turn Detail panel (standalone, parallel to turnflow) ── */
#tf-detail-pane {
  position: relative;
  width: 320px;
  flex-shrink: 0;
  border-right: none;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    inset 1px 0 0 var(--bezel-hi),
    inset -1px 0 0 var(--bezel-lo);
  min-height: 0;
  transition: width 0.25s var(--ease);
  will-change: width;
}

#tf-detail-pane.tf-detail-hidden {
  width: 28px;
  min-width: 28px;
  border-right: none;
  overflow: hidden;
}

#tf-detail-pane.tf-detail-hidden #tfd-resizer {
  display: none;
}

#tfd-resizer {
  width: 6px;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
  border-left: 1px solid rgba(255, 255, 255, 0.04);
}

#tfd-resizer:hover,
#tfd-resizer.dragging {
  border-left-color: rgba(255, 255, 255, 0.08);
}

#tfd-resizer::after {
  content: '';
  position: absolute;
  inset: 0 0 0 -4px;
}

/* vertical close/label button on right edge — mirrors #tf-toggle */
#tf-detail-close {
  position: absolute;
  right: 0;
  top: 0;
  width: 28px;
  height: 100%;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  z-index: 2;
  writing-mode: vertical-rl;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0;
  transition: color 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

/* when open: fade out vertical strip (header close button takes over) */
#tf-detail-pane:not(.tf-detail-hidden) #tf-detail-close {
  opacity: 0;
  pointer-events: none;
}

#tf-detail-close::after {
  content: "details";
}

/* chevron indicator when collapsed */
#tf-detail-close::before {
  content: "\2039";
  writing-mode: horizontal-tb;
  position: absolute;
  top: 8px;
  right: 50%;
  transform: translateX(50%);
  font-size: 14px;
  color: var(--dim);
}

#tf-detail-close:hover {
  color: var(--text);
}

#tf-detail-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#tf-detail-pane.tf-detail-hidden #tf-detail-inner {
  display: none;
}

#tf-detail-body {
  flex: 1;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--well);
  box-shadow: var(--shadow-well);
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.06) 0%, transparent 60px),
    linear-gradient(0deg, rgba(0,0,0,0.04) 0%, transparent 40px);
}

.tf-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  min-height: 44px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--bezel-lo);
  flex-shrink: 0;
  background: var(--surface);
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),      /* top highlight */
    0 1px 0 var(--bezel-ring);           /* subtle bottom glow */
}

/* .tf-panel-footer removed (dead code) */

.tf-panel-header .tf-panel-title {
  margin-bottom: 0;
  flex: 1;
}

.tf-header-action {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, transform 0.15s;
  flex-shrink: 0;
}

.tf-header-action:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.tf-header-action:active {
  transform: scale(0.95);
}

.tf-header-action:disabled {
  cursor: wait;
  opacity: 0.5;
}

.tf-header-action.is-refreshing {
  animation: ocSpin 0.9s linear infinite;
}

.tf-close-btn {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  font-family: var(--mono);
  line-height: 1;
  transition: color 0.15s, transform 0.2s var(--ease);
  flex-shrink: 0;
}

.tf-close-btn:hover {
  color: var(--text);
  transform: translateX(-2px);
}

.tf-close-btn:active {
  transform: translateX(-1px) scale(0.9);
}

.tf-panel-title {
  font-family: 'Doto', var(--mono);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 12px;
  background: linear-gradient(180deg, #e2e8f0 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}

/* ── Metal toggle switch ── */
/* .tf-toggle-switch / .tf-toggle-label / .tf-toggle-track / .tf-toggle-knob removed (dead code) */

.tf-detail-header {
  margin-bottom: 12px;
}

.tf-panel-subtitle {
  font-size: 10px;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--dim);
  margin-top: 4px;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.4;
}

/* Turn Flow resizer */
#tf-convo-resizer {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 5;
  border-left: 1px solid rgba(255, 255, 255, 0.04);
  border-right: 1px solid rgba(0, 0, 0, 0.15);
}

#tf-convo-resizer:hover,
#tf-convo-resizer.dragging {
  border-left-color: rgba(255, 255, 255, 0.08);
}

#tf-convo-resizer::after {
  content: '';
  position: absolute;
  inset: 0 -3px;
}

#tf-resizer {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 5;
  border-left: 1px solid rgba(255, 255, 255, 0.04);
  border-right: 1px solid rgba(0, 0, 0, 0.15);
}

#tf-resizer:hover,
#tf-resizer.dragging {
  border-left-color: rgba(255, 255, 255, 0.08);
}

#tf-resizer::after {
  content: '';
  position: absolute;
  inset: 0 -3px;
}

@media (max-width: 639px) {
  #turnflow {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    width: 0 !important;
    border-right: none;
    transition: width 0.25s var(--ease);
  }

  #turnflow.tf-panel-open {
    width: calc(100vw - 40px) !important;
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.5);
  }

  #turnflow.tf-panel-closed {
    width: 0 !important;
  }

  #tf-toggle {
    display: none;
  }

  #tf-inner {
    margin-right: 0;
  }

  #tf-resizer {
    display: none !important;
  }

  /* turn detail pane on mobile: hidden (use detail panel instead) */
  #tf-detail-pane {
    display: none !important;
  }

  #tfd-resizer {
    display: none !important;
  }
}

/* ── Mobile floating action buttons ── */

.mobile-fab-row {
  display: none;
}

@media (max-width: 639px) {
  .mobile-fab-row {
    display: flex;
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 101;
    gap: 10px;
  }

  .mobile-fab {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.12s;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-fab:active {
    transform: scale(0.92);
  }

  .mobile-fab:hover,
  .mobile-fab.fab-active {
    background: var(--surface2);
    border-color: var(--accent);
    color: var(--accent-text);
  }
}

@media (min-width: 1024px) {
  #turnflow.tf-panel-open {
    width: 360px;
  }
}

@media (min-width: 1440px) {
  #turnflow.tf-panel-open {
    width: 400px;
  }

  #detail.detail-open {
    width: 400px;
  }

  #tf-detail-pane {
    width: 380px;
  }
}

/* ── Detail panel ── */

#detail {
  border-left: 1px solid var(--bezel-lo);
  background: var(--surface);
  min-height: 0;
  display: flex;
  position: relative;
  flex-shrink: 0;
  transition: width 0.25s var(--ease);
  will-change: width;
  box-shadow:
    inset 1px 0 0 var(--bezel-hi);
}

#detail.detail-open {
  width: 340px;
}

#detail.detail-closed {
  width: 28px;
}

#detail-toggle {
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 100%;
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  z-index: 2;
  writing-mode: vertical-rl;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0;
  transition: background 0.1s, color 0.1s;
  -webkit-tap-highlight-color: transparent;
}

#detail-toggle:hover {
  color: var(--text);
}

#detail-toggle::after {
  content: "details";
}

#detail.detail-open #detail-toggle::before {
  content: "\203A";
  writing-mode: horizontal-tb;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: var(--dim);
}

#detail.detail-closed #detail-toggle::before {
  content: "\2039";
  writing-mode: horizontal-tb;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: var(--dim);
}

#detail-inner {
  padding: 16px 16px 16px 42px;
  overflow: auto;
  flex: 1;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.15s ease-out;
  background: var(--well);
  box-shadow: var(--shadow-well);
}

#detail.detail-closed #detail-inner {
  display: none;
}

/* .detail-title replaced by .tf-panel-header .tf-panel-title inside #detail */
.detail-header-bar {
  margin-bottom: 0;
}
.detail-header-bar .tf-panel-title {
  margin-bottom: 0;
  flex: 1;
}

/* mobile: detail becomes a slide-over */
@media (max-width: 639px) {
  #detail {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    width: 0 !important;
    transition: width 0.25s var(--ease);
    border-left: none;
  }

  #detail.detail-open {
    width: calc(100vw - 40px) !important;
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
  }

  #detail.detail-closed {
    width: 0 !important;
  }

  #detail-toggle {
    display: none;
  }

  #detail-inner {
    padding: 14px;
  }

  #detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
  }

  #detail-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (min-width: 640px) {
  #detail-overlay {
    display: none !important;
  }
}

@media (min-width: 1024px) {
  #detail.detail-open {
    width: 380px;
  }
}

/* ── Shared: muted, timestamps ── */

.muted {
  color: var(--muted);
  font-size: 12px;
}

.ts {
  cursor: default;
  border-bottom: 1px dotted var(--dim);
  transition: color 0.1s;
}

.ts:hover {
  color: var(--text);
}

/* ── Detail structured view ── */

#detail-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-header {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.detail-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 10px;
  background: linear-gradient(
    135deg,
    rgba(139,92,246,0.06) 5%,
    rgba(139,92,246,0.14) 15%,
    rgba(139,92,246,0.09) 35%,
    rgba(139,92,246,0.12) 50%,
    rgba(139,92,246,0.09) 65%,
    rgba(139,92,246,0.14) 85%,
    rgba(139,92,246,0.06) 95%
  );
  border: 1px solid rgba(139, 92, 246, 0.22);
  border-top-color: rgba(139, 92, 246, 0.32);
  border-bottom-color: rgba(0, 0, 0, 0.35);
  color: var(--accent-text);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(139, 92, 246, 0.10),
    inset 0 1px 0 rgba(139, 92, 246, 0.10),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.detail-badge-name {
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.25);
  border-top-color: rgba(34, 197, 94, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg,
    rgba(34,197,94,0.06) 5%, rgba(34,197,94,0.14) 15%, rgba(34,197,94,0.08) 35%,
    rgba(34,197,94,0.12) 50%, rgba(34,197,94,0.08) 65%, rgba(34,197,94,0.14) 85%,
    rgba(34,197,94,0.06) 95%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(34, 197, 94, 0.12),
    inset 0 1px 0 rgba(34, 197, 94, 0.10),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

.detail-path {
  display: flex;
  gap: 2px;
  align-items: center;
  flex-wrap: wrap;
}

.detail-crumb {
  font-size: 11px;
  color: var(--muted);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg,
    #1a1a1a 5%, #252525 15%, #202020 35%, #242424 50%,
    #202020 65%, #252525 85%, #1a1a1a 95%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-top-color: rgba(255, 255, 255, 0.10);
  border-bottom-color: rgba(0, 0, 0, 0.2);
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.detail-crumb-sep {
  color: var(--dim);
  font-size: 10px;
  padding: 0 1px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top-color: rgba(255, 255, 255, 0.12);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.4),
    0 0 0 0.5px rgba(0, 0, 0, 0.2);
}

.detail-stat {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

.detail-stat-icon {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.detail-stat-body {
  min-width: 0;
}

.detail-stat-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.detail-stat-value {
  font-size: 13px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-hi);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.detail-section {
  display: flex;
  flex-direction: column;
}

.detail-purpose {
  padding: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.detail-row:last-child {
  border-bottom: none;
  box-shadow: none;
}

.detail-row-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex-shrink: 0;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.detail-row-value {
  font-size: 12px;
  color: var(--text);
  text-align: right;
  word-break: break-all;
  min-width: 0;
}

.detail-collapsible {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top-color: rgba(255, 255, 255, 0.12);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(0, 0, 0, 0.25);
}

.detail-collapsible-title {
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  transition: color 0.15s, background 0.12s, box-shadow 0.12s;
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    inset 0 -1px 0 var(--bezel-lo);
  text-shadow: 0 1px 0 rgba(0,0,0,0.5);
}

.detail-collapsible-title:hover {
  color: var(--text);
  background: var(--surface3);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.10),
    inset 0 -1px 0 var(--bezel-lo);
}

/* title text takes remaining space, pushes copy button right */
.dc-title-text {
  flex: 1;
  min-width: 0;
}

/* action buttons on collapsible headers */
.dc-expand-btn,
.dc-copy-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--dim);
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
  transform: scale(0.85);
}

.detail-collapsible-title:hover .dc-expand-btn,
.detail-collapsible-title:hover .dc-copy-btn {
  opacity: 1;
  transform: scale(1);
}

.detail-collapsible[open] > .detail-collapsible-title .dc-expand-btn,
.detail-collapsible[open] > .detail-collapsible-title .dc-copy-btn,
.detail-collapsible-title:focus-within .dc-expand-btn,
.detail-collapsible-title:focus-within .dc-copy-btn {
  opacity: 1;
  transform: scale(1);
}

.dc-expand-btn:hover,
.dc-copy-btn:hover {
  color: var(--text);
  background: var(--surface2);
  border-color: rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.14);
  border-bottom-color: rgba(0, 0, 0, 0.25);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

.dc-copy-btn:active {
  transform: scale(0.92);
  background: var(--well);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.dc-expand-btn:active {
  transform: scale(0.92);
  background: var(--well);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.dc-expand-icon {
  display: block;
  width: 10px;
  height: 10px;
  position: relative;
}

.dc-expand-icon::before,
.dc-expand-icon::after {
  content: '';
  position: absolute;
  border-color: currentColor;
  border-style: solid;
  width: 6px;
  height: 6px;
}

.dc-expand-icon::before {
  top: 0;
  right: 0;
  border-width: 1.2px 1.2px 0 0;
}

.dc-expand-icon::after {
  bottom: 0;
  left: 0;
  border-width: 0 0 1.2px 1.2px;
}

/* copy icon — two overlapping squares */
.dc-copy-icon {
  display: block;
  width: 10px;
  height: 10px;
  position: relative;
}

.dc-copy-icon::before,
.dc-copy-icon::after {
  content: '';
  position: absolute;
  border: 1.2px solid currentColor;
  border-radius: 1.5px;
}

.dc-copy-icon::before {
  width: 7px;
  height: 7px;
  bottom: 0;
  left: 0;
}

.dc-copy-icon::after {
  width: 7px;
  height: 7px;
  top: 0;
  right: 0;
  background: var(--surface2);
}

/* copied state — checkmark */
.dc-copy-btn.dc-copied {
  opacity: 1;
  color: #22c55e;
  transform: scale(1);
}

.dc-copy-btn.dc-copy-failed {
  opacity: 1;
  color: #f87171;
  transform: scale(1);
}

.dc-copy-btn.dc-copied .dc-copy-icon::before,
.dc-copy-btn.dc-copied .dc-copy-icon::after {
  display: none;
}

.dc-copy-btn.dc-copied .dc-copy-icon {
  animation: dcCheck 0.3s var(--ease);
}

.dc-copy-btn.dc-copied .dc-copy-icon::before {
  display: block;
  border: none;
  width: 4px;
  height: 8px;
  border-right: 2px solid #22c55e;
  border-bottom: 2px solid #22c55e;
  border-radius: 0;
  transform: rotate(45deg);
  top: 0;
  left: 3px;
  bottom: auto;
  right: auto;
}

@keyframes dcCheck {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.detail-collapsible-title::-webkit-details-marker {
  display: none;
}

.detail-collapsible-title::before {
  content: "\203A";
  font-size: 14px;
  color: var(--dim);
  transition: transform 0.15s var(--ease), color 0.15s;
  display: inline-block;
  width: 12px;
  flex-shrink: 0;
  text-shadow:
    0 1px 0 rgba(0,0,0,0.6),
    0 -1px 0 rgba(255,255,255,0.06);
}

.detail-collapsible[open] > .detail-collapsible-title {
  background: var(--surface3);
  color: var(--text);
}

.detail-collapsible[open] > .detail-collapsible-title::before {
  transform: rotate(90deg);
  color: var(--muted);
}

.detail-collapsible-title:hover::before {
  color: var(--muted);
}

.detail-collapsible-body {
  padding: 12px 14px;
  background: var(--well);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.5), var(--shadow-well);
}

/* more breathing room when body contains markdown */
.detail-collapsible-body > .detail-markdown {
  padding: 2px 0;
}

/* scrollable content limit — generous since parent panel scrolls */
.detail-collapsible-body > .detail-markdown:only-child {
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* When body only contains a JSON viewer — remove double-box */
.detail-collapsible-body > .jt-viewer:only-child {
  border: none;
  border-radius: 0;
  margin: -12px -14px;
}
.detail-collapsible-body > .jt-viewer:only-child > .jt-toolbar {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* truncation note at bottom of content section */
.detail-trunc-note {
  font-size: 10px;
  color: var(--dim);
  font-style: italic;
  padding: 6px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

/* ── Markdown in detail ── */

.detail-markdown {
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  max-width: 100%;
}

/* first/last child margin collapse */
.detail-markdown > :first-child {
  margin-top: 0;
}

.detail-markdown > :last-child {
  margin-bottom: 0;
}

.detail-markdown br {
  display: block;
  content: "";
  margin: 2px 0;
}

/* ─ block elements ─ */

.detail-markdown p {
  margin: 8px 0;
}

.detail-markdown strong,
.detail-markdown b {
  color: var(--text);
  font-weight: 600;
}

.detail-markdown em,
.detail-markdown i {
  color: #b0b0b0;
  font-style: italic;
}

/* ─ links ─ */

.detail-markdown a {
  color: var(--accent-text);
  text-decoration: none;
  border-bottom: 1px solid rgba(139, 92, 246, 0.25);
  transition: border-color 0.15s, color 0.15s;
}

.detail-markdown a:hover {
  border-bottom-color: rgba(139, 92, 246, 0.6);
  color: #c4b5fd;
}

/* ─ headings ─ */

.detail-markdown h1,
.detail-markdown h2,
.detail-markdown h3,
.detail-markdown h4,
.detail-markdown h5,
.detail-markdown h6 {
  font-family: var(--mono);
  color: var(--text);
  margin: 14px 0 6px;
  line-height: 1.35;
}

.detail-markdown h1 {
  font-size: 15px;
  font-weight: 600;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.detail-markdown h2 {
  font-size: 14px;
  font-weight: 600;
}

.detail-markdown h3 {
  font-size: 13px;
  font-weight: 600;
  color: #b0b0b0;
}

.detail-markdown h4,
.detail-markdown h5,
.detail-markdown h6 {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ─ lists ─ */

.detail-markdown ul,
.detail-markdown ol {
  margin: 6px 0;
  padding-left: 20px;
}

.detail-markdown ul {
  list-style: none;
}

.detail-markdown ul > li {
  position: relative;
  padding-left: 2px;
}

.detail-markdown ul > li::before {
  content: "\2022";
  color: var(--dim);
  position: absolute;
  left: -14px;
  top: 0;
}

.detail-markdown ol {
  list-style: decimal;
}

.detail-markdown ol > li::marker {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
}

.detail-markdown li {
  margin: 3px 0;
}

.detail-markdown li > ul,
.detail-markdown li > ol {
  margin: 2px 0;
}

/* ─ inline code ─ */

.detail-markdown code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  color: var(--accent-text);
  white-space: nowrap;
}

/* ─ code blocks ─ */

.detail-markdown pre {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(0, 0, 0, 0.3);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  tab-size: 2;
}

.detail-markdown pre code {
  padding: 0;
  background: none;
  border: none;
  color: #9a9a9a;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre;
  font-family: var(--mono);
}

/* ─ blockquotes ─ */

.detail-markdown blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 2px solid var(--accent);
  background: rgba(139, 92, 246, 0.04);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: #b0b0b0;
}

.detail-markdown blockquote p {
  margin: 4px 0;
}

/* ─ horizontal rules ─ */

.detail-markdown hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* ─ tables ─ */

.detail-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 11px;
  font-family: var(--mono);
}

.detail-markdown th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-hover);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}

.detail-markdown td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.detail-markdown tr:last-child td {
  border-bottom: none;
}

/* ─ images ─ */

.detail-markdown img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 6px 0;
}

/* ─ key-value lines (custom) ─ */

.detail-markdown .kv-line {
  display: flex;
  gap: 6px;
  align-items: baseline;
  padding: 2px 0;
}

.detail-markdown .kv-key {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  flex-shrink: 0;
  font-weight: 500;
}

.detail-markdown .kv-val {
  color: var(--text);
}

/* ─ conversation message blocks (custom) ─ */

.detail-markdown .msg-block {
  margin: 4px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
  overflow: hidden;
}

.detail-markdown .msg-block + .msg-block {
  margin-top: 2px;
}

.detail-markdown .msg-block.msg-open {
  border-color: rgba(255, 255, 255, 0.08);
}

/* body hidden by default, shown when .msg-open */
.detail-markdown .msg-block .msg-body {
  display: none;
}

.detail-markdown .msg-block.msg-open .msg-body {
  display: block;
}

.detail-markdown .msg-role {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.1s;
}

.detail-markdown .msg-role::before {
  content: '\25B8';
  font-size: 7px;
  color: var(--dim);
  transition: transform 0.12s;
  flex-shrink: 0;
}

.detail-markdown .msg-block.msg-open > .msg-role::before {
  transform: rotate(90deg);
}

.detail-markdown .msg-role:hover {
  background: rgba(255, 255, 255, 0.02);
}

.detail-markdown .msg-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
  color: var(--dim);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.detail-markdown .msg-block.msg-open .msg-preview {
  display: none;
}

.detail-markdown .msg-role-user {
  color: var(--accent-text);
}

.detail-markdown .msg-role-assistant {
  color: var(--ok);
}

.detail-markdown .msg-role-system {
  color: var(--medium);
}

.detail-markdown .msg-role-tool {
  color: #22d3ee;
}

.detail-markdown .msg-role-idx {
  color: var(--dim);
  font-size: 9px;
}

.detail-markdown .msg-body {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
  max-height: 50vh;
  overflow: auto;
  padding: 6px 10px 8px;
}

/* markdown inside conversation blocks inherits detail-markdown styles */
.detail-markdown .msg-body p {
  margin: 0.4em 0;
}

.detail-markdown .msg-body p:first-child {
  margin-top: 0;
}

.detail-markdown .msg-body p:last-child {
  margin-bottom: 0;
}

.detail-markdown .msg-body pre {
  margin: 0.5em 0;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
  overflow-x: auto;
  font-size: 11px;
  line-height: 1.5;
}

.detail-markdown .msg-body code {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 1px 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
}

.detail-markdown .msg-body pre code {
  padding: 0;
  background: none;
}

.detail-markdown .msg-body::-webkit-scrollbar {
  width: 4px;
}

.detail-markdown .msg-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
}

#expanded-reader-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 18px;
  background: rgba(5, 5, 8, 0.78);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease-out;
}

#expanded-reader-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.expanded-reader-dialog {
  width: min(1180px, 100%);
  height: 100%;
  background: linear-gradient(180deg, rgba(40, 40, 46, 0.96) 0%, rgba(17, 17, 21, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top-color: rgba(255, 255, 255, 0.18);
  border-bottom-color: rgba(0, 0, 0, 0.48);
  border-radius: 18px;
  box-shadow:
    0 22px 80px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  outline: none;
}

.expanded-reader-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%),
    var(--surface2);
}

.expanded-reader-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.expanded-reader-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

#expanded-reader-title {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 20px;
  line-height: 1.25;
  color: var(--text-hi);
}

#expanded-reader-close {
  flex-shrink: 0;
  min-width: 40px;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.16);
  border-bottom-color: rgba(0, 0, 0, 0.28);
  background: var(--surface3);
  color: var(--text);
  font-family: var(--mono);
  font-size: 18px;
  cursor: pointer;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

#expanded-reader-close:hover {
  background: #31313a;
}

#expanded-reader-meta {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

#expanded-reader-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.015) 0%, rgba(255, 255, 255, 0) 100%),
    var(--well);
}

.expanded-reader-body {
  width: min(980px, 100%);
  margin: 0 auto;
}

.expanded-reader-body > :first-child {
  margin-top: 0;
}

.expanded-reader-body .detail-markdown {
  font-size: 14px;
  line-height: 1.9;
}

.expanded-reader-body .detail-markdown .msg-body {
  max-height: none;
  overflow: visible;
}

.expanded-reader-body .jt-viewer {
  border-radius: 14px;
}

@media (max-width: 639px) {
  #expanded-reader-overlay {
    padding: 0;
  }

  .expanded-reader-dialog {
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .expanded-reader-header {
    padding: 16px 16px 12px;
  }

  #expanded-reader-content {
    padding: 16px;
  }

  #expanded-reader-title {
    font-size: 17px;
  }
}

/* ─ simple markdown fallback classes ─ */

.detail-markdown .md-h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 12px 0 4px;
  color: var(--text);
  font-family: var(--mono);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.detail-markdown .md-h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 10px 0 4px;
  color: var(--text);
  font-family: var(--mono);
}

.detail-markdown .md-h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 8px 0 2px;
  color: #b0b0b0;
  font-family: var(--mono);
}

.detail-markdown .md-line {
  margin: 2px 0;
}

.detail-markdown .md-list {
  margin: 4px 0;
  padding-left: 16px;
  list-style: none;
}

.detail-markdown .md-list li {
  margin: 2px 0;
  color: var(--text);
  position: relative;
}

.detail-markdown .md-list li::before {
  content: "\2022";
  color: var(--dim);
  margin-right: 6px;
  margin-left: -12px;
}

.detail-markdown .md-code {
  font-size: 0.88em;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  color: var(--accent-text);
}

.detail-json {
  font-size: 11px;
  white-space: pre-wrap;
  color: var(--muted);
  margin: 0;
  max-height: 300px;
  overflow: auto;
}

#detail-pre {
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  color: var(--muted);
}

/* ── JSON Tree Viewer ── */

.jt-viewer {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top-color: rgba(255, 255, 255, 0.12);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-lg);
  background: var(--well);
  overflow: hidden;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(0, 0, 0, 0.25);
}

.jt-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 4px 6px;
  background: var(--surface2);
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    0 1px 2px rgba(0, 0, 0, 0.4);
}

.jt-copy-btn {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: linear-gradient(135deg,
    #1a1a1a 5%, #2a2a2a 15%, #222 35%, #282828 50%,
    #222 65%, #2a2a2a 85%, #1a1a1a 95%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.15);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  transition: color 0.12s, box-shadow 0.12s, background 0.12s;
}

.jt-copy-btn:hover {
  color: var(--text);
  background: var(--surface2);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}

.jt-copy-btn:active {
  background: var(--well);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
  transform: translateY(0.5px);
}

.jt-copy-btn.jt-copy-failed {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.35);
}

.jt-tree {
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  overflow: auto;
  max-height: 400px;
  background: var(--well);
  box-shadow: var(--shadow-well);
}

.jt-node {
  display: inline;
}

.jt-node[open] > .jt-toggle > .jt-count {
  display: none;
}

.jt-node:not([open]) > .jt-children,
.jt-node:not([open]) > .jt-brace:last-child {
  display: none;
}

.jt-toggle {
  display: inline;
  cursor: pointer;
  list-style: none;
}

.jt-toggle::-webkit-details-marker { display: none; }

.jt-toggle::before {
  content: "\25B6";
  font-size: 8px;
  color: var(--dim);
  margin-right: 4px;
  display: inline-block;
  transition: transform 0.12s, color 0.12s;
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.5),
    0 -1px 0 rgba(255, 255, 255, 0.04);
}

.jt-toggle:hover::before {
  color: var(--muted);
}

.jt-node[open] > .jt-toggle::before {
  transform: rotate(90deg);
  color: var(--muted);
}

.jt-children {
  padding-left: 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: -1px 0 0 rgba(0, 0, 0, 0.2);
}

.jt-entry {
  display: block;
}

.jt-key { color: #e2e8f0; font-weight: 600; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); }
.jt-str { color: #94a3b8; }
.jt-str-long { color: #94a3b8; cursor: pointer; opacity: 0.7; }
.jt-str-long:hover { opacity: 1; }
.jt-num { color: #cbd5e1; font-weight: 500; }
.jt-bool { color: #a1a1aa; font-weight: 600; }
.jt-null { color: #52525b; font-style: italic; }
.jt-brace { color: #52525b; }
.jt-colon { color: #52525b; }
.jt-comma { color: #3f3f46; }
.jt-count { color: #52525b; font-size: 9px; margin: 0 4px; font-weight: 600; }

/* ── Copyable values ── */

.detail-copyable {
  cursor: pointer;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  transition: color 0.12s, border-color 0.12s;
}

.detail-copyable:hover {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
}

.detail-copyable.copied {
  color: #22c55e;
  border-bottom-color: #22c55e;
}

.detail-copyable.copied::after {
  content: " copied";
  font-size: 9px;
  color: #22c55e;
}

.detail-copyable.copy-failed {
  color: #f87171;
  border-bottom-color: #f87171;
}

.detail-copyable.copy-failed::after {
  content: " copy failed";
  font-size: 9px;
  color: #f87171;
}

/* Nav shortcut badges removed — numbers caused wrapping on narrow viewports */

/* ── List / Activity ── */

.list {
  display: flex;
  flex-direction: column;
}

.item {
  padding: 10px clamp(10px, 2vw, 20px);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.item:active {
  background: rgba(255, 255, 255, 0.04);
}

.item:first-child {
  border-top: 1px solid var(--border);
}

.item-title {
  font-size: 13px;
  margin-bottom: 4px;
  line-height: 1.45;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.item-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.5;
}

.prompt-runtime-view {
  padding: 14px clamp(10px, 2vw, 20px) 28px;
  overflow: auto;
}

.prompt-runtime-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-bezel);
}

.prompt-runtime-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-hi);
  margin-bottom: 6px;
}

.prompt-runtime-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.prompt-runtime-errors {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius);
  color: var(--medium);
  background: rgba(245, 158, 11, 0.08);
  font-size: 11px;
  line-height: 1.5;
}

.prompt-bundle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.prompt-bundle-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-bezel);
}

.prompt-bundle-summary {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(0,0,0,0.14));
}

.prompt-bundle-summary::-webkit-details-marker {
  display: none;
}

.prompt-bundle-summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--well);
}

.prompt-bundle-summary {
  grid-template-columns: auto minmax(160px, 1fr) auto;
}

.prompt-bundle-panel[open] > .prompt-bundle-summary::before {
  content: "-";
  color: var(--accent-text);
}

.prompt-bundle-summary:hover {
  background: rgba(255, 255, 255, 0.035);
}

.prompt-bundle-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-hi);
}

.prompt-bundle-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.prompt-bundle-body {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  background: var(--well);
}

.prompt-bundle-description {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.prompt-bundle-actions {
  margin-bottom: 10px;
}

.prompt-sections-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prompt-section-block {
  position: relative;
  padding: 20px 14px 12px;
  border: 1px dotted rgba(216, 216, 220, 0.22);
  border-radius: var(--radius-lg);
  color: var(--text);
  background: rgba(255, 255, 255, 0.01);
}

.prompt-section-label {
  position: absolute;
  top: -9px;
  left: 12px;
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 1px 7px;
  border: 1px dotted rgba(216, 216, 220, 0.22);
  border-radius: 999px;
  color: var(--text);
  background: var(--well);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.prompt-section-meta {
  position: absolute;
  top: -9px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 1px 7px;
  border: 1px dotted rgba(216, 216, 220, 0.16);
  border-radius: 999px;
  color: rgba(216, 216, 220, 0.52);
  background: var(--well);
  font-size: 10px;
}

.prompt-section-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.prompt-section-vars span {
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--accent-text);
  background: var(--accent-dim);
  border: 1px solid rgba(139, 92, 246, 0.2);
  font-size: 10px;
}

.prompt-section-content {
  max-height: none;
  overflow: visible;
  white-space: pre-wrap;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  color: var(--text);
  background: transparent;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.62;
}

.prompt-inspect-btn {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface3);
  font-family: var(--mono);
  font-size: 10px;
  cursor: pointer;
}

.prompt-inspect-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-hi);
}

.prompt-empty-panel {
  padding: 42px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: var(--well);
}

.prompt-runtime-raw {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-bezel);
}

/* -- Trigger observability view -- */
.trigger-view {
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 14px clamp(10px, 2vw, 18px) 28px;
}

.trigger-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 46px;
  padding: 0 0 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.trigger-page-title,
.trigger-detail-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-hi);
  margin-bottom: 3px;
}

.trigger-page-subtitle,
.trigger-detail-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.trigger-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.trigger-refresh-btn,
.trigger-inspect-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  padding: 6px 9px;
  cursor: pointer;
  box-shadow: var(--shadow-bezel);
}

.trigger-refresh-btn:hover,
.trigger-inspect-btn:hover {
  border-color: var(--border-hover);
  background: var(--surface3);
}

.trigger-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
  margin-bottom: 0;
}

.trigger-stat {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  padding: 5px 8px;
  box-shadow: none;
}

.trigger-stat-value {
  color: var(--text-hi);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

.trigger-stat-label {
  color: var(--muted);
  font-size: 7px;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.trigger-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(360px, 410px);
  gap: 12px;
  align-items: start;
}

.trigger-list-panel,
.trigger-detail-wrap {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-bezel);
  overflow: hidden;
}

.trigger-detail-wrap {
  position: sticky;
  top: 10px;
  max-height: calc(100vh - var(--topbar-h) - 22px);
  overflow: auto;
}

.trigger-section-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--surface2);
}

.trigger-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: rgba(255, 255, 255, 0.018);
}

.trigger-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.32fr);
  gap: 14px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
  cursor: pointer;
  font-family: var(--mono);
}

.trigger-row:hover {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(255, 255, 255, 0.10);
}

.trigger-row-active {
  background: rgba(34, 197, 94, 0.055);
  border-color: rgba(34, 197, 94, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(34, 197, 94, 0.10);
}

.trigger-row-main,
.trigger-row-metrics,
.trigger-fire-meta {
  min-width: 0;
}

.trigger-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 5px;
}

.trigger-title {
  color: var(--text-hi);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trigger-condition,
.trigger-prompt,
.trigger-row-subline,
.trigger-row-metrics,
.trigger-fire-meta,
.trigger-fire-id {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.trigger-row-subline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--dim);
  margin-bottom: 6px;
}

.trigger-condition,
.trigger-prompt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 5px;
}

.trigger-condition {
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  padding: 5px 7px;
}

.trigger-row-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 5px;
}

.trigger-metric {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  background: var(--well);
  padding: 4px 6px;
}

.trigger-metric span,
.trigger-metric strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trigger-metric span {
  color: var(--dim);
  font-size: 7px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.trigger-metric strong {
  color: var(--text-hi);
  font-size: 9px;
  font-weight: 700;
  margin-top: 1px;
}

.trigger-detail-panel {
  padding: 10px;
}

.trigger-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.trigger-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 10px;
}

.trigger-detail-grid .trigger-stat {
  background: var(--well);
}

.trigger-detail-section {
  border-top: 1px solid var(--border);
  padding-top: 9px;
  margin-top: 9px;
}

.trigger-section-title {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.trigger-kv {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 6px 10px;
  font-size: 10px;
  line-height: 1.5;
}

.trigger-kv span {
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.trigger-kv strong {
  color: var(--text);
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.trigger-fire-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.trigger-fire-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--well);
  padding: 8px;
}

.trigger-fire-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
}

.trigger-detail-empty {
  color: var(--muted);
  font-size: 11px;
  padding: 14px;
  text-align: center;
}

.trigger-error-text {
  color: #f87171;
  font-size: 10px;
  line-height: 1.5;
}

.trigger-load-error {
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.08);
  padding: 9px 11px;
  margin-bottom: 12px;
}

@media (max-width: 1023px) {
  .trigger-summary {
    justify-content: flex-start;
    width: 100%;
    order: 3;
  }

  .trigger-layout {
    grid-template-columns: 1fr;
  }

  .trigger-detail-wrap {
    position: static;
    max-height: none;
  }

  .trigger-topbar {
    flex-wrap: wrap;
  }

  .trigger-row {
    grid-template-columns: 1fr;
  }

  .trigger-row-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .trigger-row-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* -- Execution agent roster view -- */
.exec-view {
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 14px clamp(10px, 2vw, 18px) 28px;
}

.exec-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 46px;
  padding: 0 0 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.exec-page-title,
.exec-detail-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-hi);
  margin-bottom: 3px;
}

.exec-page-subtitle,
.exec-detail-subtitle,
.exec-source {
  color: var(--muted);
  font-size: 9px;
}

.exec-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
}

.exec-stat {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  padding: 5px 8px;
}

.exec-stat-value {
  color: var(--text-hi);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

.exec-stat-label {
  color: var(--muted);
  font-size: 7px;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.exec-refresh-btn,
.exec-inspect-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  padding: 6px 9px;
  cursor: pointer;
  box-shadow: var(--shadow-bezel);
}

.exec-refresh-btn:hover,
.exec-inspect-btn:hover {
  border-color: var(--border-hover);
  background: var(--surface3);
}

.exec-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(360px, 410px);
  gap: 12px;
  align-items: start;
}

.exec-list-panel,
.exec-detail-wrap {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-bezel);
  overflow: hidden;
}

.exec-detail-wrap {
  position: sticky;
  top: 10px;
  max-height: calc(100vh - var(--topbar-h) - 22px);
  overflow: auto;
}

.exec-section-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--surface2);
}

.exec-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: rgba(255, 255, 255, 0.018);
}

.exec-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.32fr);
  gap: 14px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
  cursor: pointer;
  font-family: var(--mono);
}

.exec-row:hover {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(255, 255, 255, 0.10);
}

.exec-row-active {
  background: rgba(14, 165, 233, 0.065);
  border-color: rgba(14, 165, 233, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(14, 165, 233, 0.10);
}

.exec-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 5px;
}

.exec-title {
  color: var(--text-hi);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exec-subline,
.exec-task,
.exec-assets,
.exec-row-metrics,
.exec-event-meta {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.exec-subline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--dim);
  margin-bottom: 6px;
}

.exec-task,
.exec-assets {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 5px;
}

.exec-task {
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  padding: 5px 7px;
}

.exec-row-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 5px;
}

.exec-metric {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  background: var(--well);
  padding: 4px 6px;
}

.exec-metric span,
.exec-metric strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exec-metric span {
  color: var(--dim);
  font-size: 7px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.exec-metric strong {
  color: var(--text-hi);
  font-size: 9px;
  font-weight: 700;
  margin-top: 1px;
}

.exec-detail-panel {
  padding: 10px;
}

.exec-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.exec-detail-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.exec-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 10px;
}

.exec-detail-section {
  border-top: 1px solid var(--border);
  padding-top: 9px;
  margin-top: 9px;
}

.exec-section-title {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.exec-detail-text {
  color: var(--text);
  font-size: 10px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.exec-event-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.exec-event-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--well);
  padding: 8px;
}

.exec-event-head,
.exec-event-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.exec-event-head {
  color: var(--text-hi);
  font-size: 10px;
  font-weight: 700;
}

.exec-event-text {
  color: var(--text);
  font-size: 10px;
  line-height: 1.5;
  margin-top: 6px;
}

.exec-empty {
  color: var(--muted);
  font-size: 11px;
  padding: 14px;
  text-align: center;
}

.exec-error {
  color: #f87171;
  font-size: 10px;
  line-height: 1.5;
}

.exec-load-error {
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.08);
  padding: 9px 11px;
  margin-bottom: 12px;
}

.exec-map-panel {
  padding: 10px;
}

.exec-map-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.exec-map-count {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--well);
  color: var(--text);
  font-family: var(--mono);
  font-size: 9px;
  padding: 5px 7px;
}

.exec-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
  color: var(--muted);
  font-size: 9px;
  margin-bottom: 12px;
}

.exec-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.exec-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  display: inline-block;
}

.exec-dot-working { background: #22c55e; }
.exec-dot-idle { background: #f59e0b; }
.exec-dot-completed { background: #64748b; }
.exec-dot-failed { background: #ef4444; }

.exec-map-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exec-map-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.018);
  padding: 9px;
}

.exec-hub {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
}

.exec-hub-node {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(14, 165, 233, 0.45);
  background: rgba(14, 165, 233, 0.12);
  color: var(--text-hi);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.exec-hub-meta {
  min-width: 0;
  font-size: 10px;
  color: var(--text);
  line-height: 1.4;
}

.exec-hub-meta div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exec-hub-meta span {
  color: var(--muted);
  font-size: 9px;
}

.exec-bubble-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.exec-bubble {
  width: var(--bubble-size);
  height: var(--bubble-size);
  min-width: 30px;
  min-height: 30px;
  max-width: 72px;
  max-height: 72px;
  border-radius: 999px;
  border: 1px solid rgba(100, 116, 139, 0.52);
  background: rgba(100, 116, 139, 0.16);
  color: var(--text-hi);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.05;
  padding: 4px;
  display: grid;
  place-items: center;
  text-align: center;
  overflow: hidden;
}

.exec-bubble span {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.exec-bubble:hover {
  transform: translateY(-1px);
  filter: brightness(1.15);
}

.exec-bubble-working {
  border-color: rgba(34, 197, 94, 0.58);
  background: rgba(34, 197, 94, 0.16);
}

.exec-bubble-queued,
.exec-bubble-idle {
  border-color: rgba(245, 158, 11, 0.58);
  background: rgba(245, 158, 11, 0.15);
}

.exec-bubble-failed {
  border-color: rgba(239, 68, 68, 0.62);
  background: rgba(239, 68, 68, 0.16);
}

.exec-bubble-completed {
  border-color: rgba(100, 116, 139, 0.58);
  background: rgba(100, 116, 139, 0.16);
}

.exec-bubble-inactive {
  opacity: 0.58;
}

.exec-bubble-db {
  border-style: dashed;
}

.exec-bubble-live {
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.14);
}

@media (max-width: 1023px) {
  .exec-summary {
    justify-content: flex-start;
    width: 100%;
    order: 3;
  }

  .exec-layout {
    grid-template-columns: 1fr;
  }

  .exec-detail-wrap {
    position: static;
    max-height: none;
  }

  .exec-topbar {
    flex-wrap: wrap;
  }

  .exec-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .exec-row-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* -- Tool presentation manifest view -- */
.tool-view {
  height: auto;
  min-height: 100%;
  overflow: auto;
  padding: 14px clamp(10px, 2vw, 20px) 28px;
}

.tool-bundle-panel .prompt-bundle-summary {
  grid-template-columns: auto minmax(180px, 1fr) minmax(220px, auto);
}

.tool-bundle-panel .prompt-bundle-meta span {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-bundle-panel .prompt-bundle-body {
  padding: 14px;
}

.tool-bundle-panel .prompt-bundle-description {
  max-width: 920px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.tool-section-card {
  padding: 12px;
  border-style: solid;
  border-color: rgba(216, 216, 220, 0.16);
  background: rgba(255, 255, 255, 0.012);
}

.tool-section-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-section-group {
  border: 1px solid rgba(216, 216, 220, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.012);
  overflow: hidden;
}

.tool-section-group-primary {
  border-color: rgba(216, 216, 220, 0.22);
  background: rgba(255, 255, 255, 0.018);
}

.tool-section-group-summary {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(0,0,0,0.08));
}

.tool-section-group-summary::-webkit-details-marker {
  display: none;
}

.tool-section-group-summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--well);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.tool-section-group[open] > .tool-section-group-summary::before {
  content: "-";
  color: var(--accent-text);
}

.tool-section-group-summary:hover {
  background: rgba(255, 255, 255, 0.04);
}

.tool-section-group-title {
  color: var(--text-hi);
  font-size: 11px;
  font-weight: 700;
}

.tool-section-group-meta {
  color: var(--dim);
  font-size: 10px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-section-group-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px;
  align-items: start;
  padding: 10px;
  border-top: 1px solid rgba(216, 216, 220, 0.1);
}

.tool-section-wide {
  grid-column: 1 / -1;
}

.tool-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-section-header span:first-child {
  color: var(--text);
}

.tool-section-header span:last-child {
  color: var(--dim);
  font-size: 9px;
}

.tool-section-card .prompt-section-content {
  max-width: 960px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
}

.tool-section-card-primary {
  grid-column: 1 / -1;
  background: rgba(255, 255, 255, 0.018);
}

.tool-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 0 0 9px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  box-shadow: none;
}

.tool-page-title,
.tool-detail-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-hi);
  margin-bottom: 3px;
}

.tool-page-subtitle,
.tool-detail-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.tool-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-refresh-btn,
.tool-inspect-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  padding: 6px 9px;
  cursor: pointer;
  box-shadow: var(--shadow-bezel);
}

.tool-refresh-btn:hover,
.tool-inspect-btn:hover {
  border-color: var(--border-hover);
  background: var(--surface3);
}

.tool-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  margin-left: auto;
}

.tool-stat {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 3px 6px;
  box-shadow: none;
}

.tool-stat-value {
  color: var(--text-hi);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

.tool-stat-label {
  color: var(--muted);
  font-size: 7px;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(460px, 1fr) 430px;
  gap: 10px;
  align-items: start;
}

.tool-list-panel,
.tool-detail-wrap {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-bezel);
  overflow: hidden;
}

.tool-detail-wrap {
  position: sticky;
  top: 10px;
  max-height: calc(100vh - var(--topbar-h) - 22px);
  overflow: auto;
}

.tool-section-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--surface2);
}

.tool-list {
  display: flex;
  flex-direction: column;
}

.tool-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.28fr);
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 9px;
  cursor: pointer;
  font-family: var(--mono);
}

.tool-row:hover {
  background: rgba(255, 255, 255, 0.025);
}

.tool-row-active {
  background: rgba(139, 92, 246, 0.07);
  border-color: rgba(139, 92, 246, 0.46);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(139, 92, 246, 0.10);
}

.tool-row-main,
.tool-row-metrics {
  min-width: 0;
}

.tool-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tool-title {
  color: var(--text-hi);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-summary,
.tool-meta-line,
.tool-row-metrics {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.tool-summary,
.tool-meta-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 4px;
}

.tool-row-metrics {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.tool-detail-panel {
  padding: 10px;
}

.tool-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.tool-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 10px;
}

.tool-detail-grid .tool-stat {
  background: var(--well);
}

.tool-detail-section {
  border-top: 1px solid var(--border);
  padding-top: 9px;
  margin-top: 9px;
}

.tool-section-title {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.tool-kv {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 6px 10px;
  font-size: 10px;
  line-height: 1.5;
}

.tool-kv span {
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tool-kv strong {
  color: var(--text);
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tool-generated-summary {
  color: var(--text);
  font-size: 11px;
  line-height: 1.5;
}

.tool-description-block {
  margin: 8px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--well);
  color: var(--muted);
  padding: 8px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 10px;
  line-height: 1.5;
}

.tool-bullet-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  font-size: 10px;
  line-height: 1.55;
}

.tool-bullet-list li + li {
  margin-top: 4px;
}

.tool-operation-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.tool-operation {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--well);
  padding: 8px;
}

.tool-operation-title {
  color: var(--text-hi);
  font-size: 11px;
  font-weight: 700;
}

.tool-operation-summary {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  margin-top: 4px;
}

.tool-kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tool-kv-row {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--well);
  padding: 7px;
}

.tool-kv-row span {
  display: block;
  color: var(--dim);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tool-kv-row strong {
  display: block;
  margin-top: 4px;
  color: var(--text-hi);
  font-size: 10px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.tool-chip {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--muted);
  font-size: 9px;
  padding: 2px 5px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-detail-empty {
  color: var(--muted);
  font-size: 11px;
  padding: 14px;
  text-align: center;
}

.tool-detail-empty-compact {
  padding: 2px 0;
  text-align: left;
}

.tool-error-text {
  color: #f87171;
  font-size: 10px;
  line-height: 1.5;
}

.tool-load-error {
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.08);
  padding: 9px 11px;
  margin-bottom: 12px;
}

@media (max-width: 1023px) {
  .tool-summary {
    justify-content: flex-start;
    width: 100%;
    order: 3;
  }

  .tool-layout {
    grid-template-columns: 1fr;
  }

  .tool-detail-wrap {
    position: static;
    max-height: none;
  }

  .tool-topbar {
    flex-wrap: wrap;
  }

  .tool-row {
    grid-template-columns: 1fr;
  }

  .tool-row-metrics {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
  /* dark metallic gradient — 135deg multi-stop chrome */
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.15);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  background: linear-gradient(
    135deg,
    #1a1a1a 5%,
    #2e2e2e 15%,
    #252525 35%,
    #2c2c2c 50%,
    #252525 65%,
    #2e2e2e 85%,
    #1a1a1a 95%
  );
  color: var(--muted);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
  line-height: 1.6;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.pill.urgent {
  border-color: rgba(239, 68, 68, 0.30);
  border-top-color: rgba(239, 68, 68, 0.40);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(
    135deg,
    rgba(239,68,68,0.08) 5%,
    rgba(239,68,68,0.15) 15%,
    rgba(239,68,68,0.10) 35%,
    rgba(239,68,68,0.14) 50%,
    rgba(239,68,68,0.10) 65%,
    rgba(239,68,68,0.15) 85%,
    rgba(239,68,68,0.08) 95%
  );
  color: #f87171;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(239, 68, 68, 0.15),
    inset 0 1px 0 rgba(239, 68, 68, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.pill.medium {
  border-color: rgba(245, 158, 11, 0.30);
  border-top-color: rgba(245, 158, 11, 0.40);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(
    135deg,
    rgba(245,158,11,0.08) 5%,
    rgba(245,158,11,0.15) 15%,
    rgba(245,158,11,0.10) 35%,
    rgba(245,158,11,0.14) 50%,
    rgba(245,158,11,0.10) 65%,
    rgba(245,158,11,0.15) 85%,
    rgba(245,158,11,0.08) 95%
  );
  color: #fbbf24;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(245, 158, 11, 0.12),
    inset 0 1px 0 rgba(245, 158, 11, 0.10),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.pill.low {
  border-color: rgba(139, 92, 246, 0.25);
  border-top-color: rgba(139, 92, 246, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(
    135deg,
    rgba(139,92,246,0.08) 5%,
    rgba(139,92,246,0.15) 15%,
    rgba(139,92,246,0.10) 35%,
    rgba(139,92,246,0.14) 50%,
    rgba(139,92,246,0.10) 65%,
    rgba(139,92,246,0.15) 85%,
    rgba(139,92,246,0.08) 95%
  );
  color: var(--accent-text);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(139, 92, 246, 0.12),
    inset 0 1px 0 rgba(139, 92, 246, 0.10),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* ── Metallic press animation — shared across all metal badges/chips ── */
.pill:active,
.detail-badge:active,
.detail-badge-name:active,
.tf-pipeline-chip:active,
.tf-delta:active,
.ce-delta-row:active,
.treemap-legend-item:active,
.nav:active,
.tf-row:active,
.item:active,
.detail-collapsible-title:active,
.ce-convo-chip:active,
.af-pill:active,
.ce-wf-zoom-chip:active,
.span-badge:active,
.tfe-tool-entry-header:active,
.jt-copy-btn:active {
  transform: translateY(0.5px);
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(0, 0, 0, 0.3),
    0 0.5px 0 rgba(255, 255, 255, 0.04);
  border-top-color: rgba(0, 0, 0, 0.3) !important;
  border-bottom-color: rgba(255, 255, 255, 0.05) !important;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

/* ── Board / Tasks ── */

.board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

@media (min-width: 640px) {
  .board {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .board {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

.col {
  background: var(--bg);
  padding: 10px;
  min-height: 100px;
}

@media (min-width: 640px) {
  .col {
    padding: 12px;
    min-height: 160px;
  }
}

.col-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08),
    0 -1px 0 rgba(0, 0, 0, 0.5);
}

.card {
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.card:hover {
  border-color: var(--border-hover);
}

.card:active {
  background: rgba(255, 255, 255, 0.03);
}

.card:last-child {
  margin-bottom: 0;
}

.card-title {
  font-size: 12px;
  margin-bottom: 4px;
  line-height: 1.45;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.card a {
  color: var(--accent-text);
  text-decoration: none;
  transition: color 0.1s;
}

.card a:hover {
  text-decoration: underline;
}

/* ── Graph / Context ── */

.graph-header {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.graph-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.graph-legend-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.map {
  width: 100%;
  height: calc(100vh - 200px);
  min-height: 300px;
  max-height: 700px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ── Empty state ── */

.empty {
  color: var(--dim);
  font-size: 11px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 40px 20px;
  text-align: center;
  border: 1px solid var(--border);
  border-top-color: rgba(255, 255, 255, 0.06);
  border-bottom-color: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.06);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.2),
    0 1px 0 rgba(255, 255, 255, 0.03);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06),
    0 -1px 0 rgba(0, 0, 0, 0.4);
}

/* ── Treemap ── */

.treemap-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 0;
  padding-bottom: 8px;
}

.treemap-toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 100%;
}

.treemap-select {
  padding: 5px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  flex: 1 1 0;
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  outline: none;
  transition: border-color 0.15s;
}

.treemap-select:focus {
  border-color: var(--accent);
}

.treemap-stats {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.treemap-stat-item {
  font-size: 9px;
  color: var(--muted);
  padding: 2px 5px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.02);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.treemap-stat-item strong {
  color: var(--text);
  font-weight: 500;
}

/* stacked category breakdown bar */
.treemap-breakdown-bar {
  flex: 0 0 100%;
  display: flex;
  height: 3px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  gap: 1px;
}

.treemap-breakdown-seg {
  height: 100%;
  border-radius: 1px;
  transition: flex 0.4s var(--ease), opacity 0.2s;
}

.treemap-breakdown-seg:hover {
  opacity: 0.7;
}

.treemap-summary {
  flex: 0 0 100%;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
  word-break: break-word;
}

/* treemap container: SVG + tooltip + legend */
.treemap-container {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  background: #080808;
  overflow: hidden;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.5);
}

.treemap-svg {
  width: 100%;
  display: block;
}

/* hover tooltip bar */
.treemap-tooltip-bar {
  flex-shrink: 0;
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--dim);
  font-family: var(--mono);
  overflow: hidden;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.treemap-tooltip-bar.active {
  background: var(--surface2);
  color: var(--text);
}

.treemap-tooltip-name {
  font-weight: 600;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.treemap-tooltip-tokens {
  color: var(--accent-text);
  font-weight: 600;
  flex-shrink: 0;
  background: rgba(139, 92, 246, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
}

.treemap-tooltip-pct {
  color: var(--muted);
  flex-shrink: 0;
}

.treemap-tooltip-sep {
  color: var(--dim);
  opacity: 0.3;
}

.treemap-tooltip-path {
  color: var(--dim);
  font-size: 9px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* footer legend */
.treemap-legend {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
  padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.3);
}

.treemap-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  color: var(--muted);
  cursor: default;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  font-family: var(--mono);
  padding: 2px 8px 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.15);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  border-radius: 2px;
  background: linear-gradient(135deg,
    #1a1a1a 5%, #2e2e2e 15%, #252525 35%, #2c2c2c 50%,
    #252525 65%, #2e2e2e 85%, #1a1a1a 95%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.treemap-legend-item:hover {
  color: var(--text);
  border-color: currentColor;
}

.treemap-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  border: none;
}

.treemap-legend-tokens {
  color: var(--dim);
  font-size: 9px;
}

#main.treemap-mode {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

/* context explorer: flush layout, no main padding */
#main:has(.timeline-wrap) {
  padding: 0;
}

#main.treemap-mode .treemap-toolbar {
  flex: 0 0 auto;
}

#main.treemap-mode .treemap-container {
  flex: 0 0 auto;
}

/* SVG cell transitions */
.tm-top-bg,
.tm-leaf-bg {
  transition: fill-opacity 0.2s ease-out, stroke 0.15s ease-out, stroke-width 0.15s ease-out, filter 0.15s ease-out;
}

.tm-header-bar {
  transition: fill-opacity 0.15s ease-out;
}

.tm-leaf-bg:hover {
  fill-opacity: 1;
  filter: brightness(1.3);
}

/* selected cell */
.tm-cell-selected .tm-leaf-bg,
.tm-cell-selected .tm-top-bg {
  stroke-width: 2;
}

/* available context cell */
.tm-available-bg {
  transition: fill-opacity 0.2s ease-out;
}

/* ── Micro-interactions ── */

/* P1: Content entrance */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.list,
.board,
.map,
.treemap-toolbar,
.treemap-container,
.timeline-toolbar,
.timeline-container,
.empty {
  animation: fadeIn 0.12s ease-out;
}

/* P2: Detail crossfade */
#detail-content {
  transition: opacity 0.1s ease-out;
}

/* P3: New activity highlight */
@keyframes accentPulse {
  from {
    border-left: 2px solid var(--accent);
    background: var(--accent-dim);
  }
  to {
    border-left: 2px solid transparent;
    background: transparent;
  }
}

.item-new {
  animation: accentPulse 1.5s ease-out forwards;
}

/* P4: Breakdown bar segment fill */
@keyframes segGrow {
  from {
    flex: 0 0 0%;
  }
}

.treemap-breakdown-seg {
  animation: segGrow 0.5s var(--ease);
}

/* Treemap cell entrance */
@keyframes cellFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* P7: Detail panel inner fade */
#detail-inner {
  transition: opacity 0.15s ease-out;
}

/* P8: Staggered list entrance — items cascade in */
@keyframes itemSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.item,
.card {
  animation: itemSlideIn 0.15s var(--ease) both;
}

/* P9: Active item highlight — selected item left accent */
.item.item-active {
  border-left: 2px solid var(--accent);
  background: rgba(139, 92, 246, 0.04);
}

.card.item-active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.04);
}

/* P10: Search focus — border only, no glow */

/* P11: Card hover — border only, no lift/shadow */
.card {
  transition: border-color 0.15s, background 0.1s;
}

/* P12: WS connection indicator — metallic LED */
#ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
  align-self: center;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  margin-left: 8px;
}

#ws-dot.connected {
  background: var(--ok);
  box-shadow:
    0 0 4px rgba(34, 197, 94, 0.5),
    inset 0 1px 1px rgba(255, 255, 255, 0.3);
  animation: dotPulse 3s ease-in-out infinite;
}

#ws-dot.disconnected {
  background: var(--urgent);
  box-shadow:
    0 0 4px rgba(239, 68, 68, 0.4),
    inset 0 1px 1px rgba(255, 255, 255, 0.2);
  animation: none;
}

@keyframes dotPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* P13: View crossfade on #main */
#main {
  transition: opacity 0.08s ease-out;
}

#main.view-switching {
  opacity: 0;
}

/* P14: Scroll edge shadows */
#main {
  mask-image: linear-gradient(
    to bottom,
    transparent 0px,
    black 8px,
    black calc(100% - 8px),
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0px,
    black 8px,
    black calc(100% - 8px),
    transparent 100%
  );
}

/* treemap mode needs no mask (SVG fills edge) */
#main.treemap-mode {
  mask-image: none;
  -webkit-mask-image: none;
}

/* P15: Treemap cell click flash + scale */
@keyframes cellFlash {
  0% {
    fill-opacity: 1;
  }
  40% {
    fill-opacity: 0.4;
  }
  100% {
    fill-opacity: 1;
  }
}

/* P16: Urgent pill — static border, no glow animation */

/* P17: Collapsible body slide-in */
.detail-collapsible-body {
  animation: fadeIn 0.12s ease-out;
}

/* P18: Empty state subtle float */
@keyframes gentleFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

.empty {
  animation: fadeIn 0.2s ease-out;
}

/* P19: Graph legend dot pulse on hover */
.graph-legend span {
  cursor: default;
  transition: opacity 0.15s;
}

.graph-legend span:hover {
  opacity: 0.7;
}

.graph-legend span:hover .graph-legend-dot {
  animation: dotPulse 1s ease-in-out infinite;
}

/* ── Timeline ── */

/* ── Timeline ── */

.timeline-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  container-type: inline-size;
}

/* toolbar mirrors treemap toolbar */
.timeline-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid var(--border);
}

.timeline-toolbar-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 0 0 100%;
  flex-wrap: wrap;
}

.timeline-select {
  padding: 5px 24px 5px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  outline: none;
  flex: 1 1 0;
  min-width: 0;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 8px 5px;
}

.timeline-select--compact {
  flex: 0 0 auto;
  min-width: 150px;
}

.timeline-select:focus {
  border-color: var(--accent);
}

/* Container queries: when main pane is squeezed by side panels */
@container (max-width: 420px) {
  .timeline-toolbar {
    gap: 3px;
    padding: 4px 8px;
  }

  .tl-range-handle::before {
    width: 3px;
    height: 16px;
    margin-left: -1.5px;
  }

}

@container (min-width: 800px) {
  .timeline-bar {
    min-height: 72px;
  }
}

/* container — flush, no extra visual border */
.timeline-container {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  background: #080808;
  overflow: hidden;
  max-height: 50vh;
}

/* wrapper: holds clip + range overlay */
.timeline-bar-wrap {
  position: relative;
  flex-shrink: 0;
}

/* clip container for zooming the bar */
.timeline-bar-clip {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
}

/* main stacked bar */
.timeline-bar {
  display: flex;
  align-items: stretch;
  min-height: clamp(48px, 8vh, 80px);
  flex-shrink: 0;
  overflow: visible;
  gap: 1px;
  padding: 6px;
  background: transparent;
  transform-origin: left top;
  transition: transform 0.15s ease-out, width 0.15s ease-out;
  will-change: transform, width;
}

.timeline-bar.tl-bar-dragging {
  transition: none;
}

.timeline-seg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 3px;
  border-radius: 2px;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: flex 0.25s var(--ease), filter 0.15s ease-out, opacity 0.15s ease-out, transform 0.15s ease-out;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

.timeline-seg:hover {
  filter: brightness(1.25);
  transform: scaleY(1.04);
  z-index: 1;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    0 0 6px rgba(255, 255, 255, 0.06);
}

.timeline-seg.seg-active {
  outline: 1px solid rgba(255, 255, 255, 0.35);
  outline-offset: 1px;
}

/* ── Cross-highlight (timeline ↔ treemap) ── */
.timeline-seg.cross-hl {
  filter: brightness(1.3);
  transform: scaleY(1.06);
  z-index: 2;
  outline: 1px solid rgba(255, 255, 255, 0.3);
  outline-offset: 0px;
}

.timeline-seg.seg-dimmed {
  opacity: 0.25;
  filter: brightness(0.7) saturate(0.4);
}

.tm-dimmed {
  opacity: 0.25;
  transition: opacity 0.15s ease;
}

.tm-cross-hl {
  opacity: 1;
}

.tm-cross-hl > .tm-top-bg,
.tm-focused > .tm-top-bg {
  stroke-width: 2px !important;
  filter: brightness(1.4);
}

.tm-leaf-focused > .tm-leaf-bg {
  stroke-width: 2px !important;
  filter: brightness(1.4);
}

.timeline-seg-label,
.timeline-seg-name {
  display: none;
  white-space: nowrap;
  padding: 0 4px;
  font-family: var(--mono);
}

.timeline-seg.seg-show-tokens .timeline-seg-label {
  display: block;
  font-size: 9px;
  color: rgba(0, 0, 0, 0.7);
  font-weight: 600;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.15);
}

.timeline-seg.seg-show-name .timeline-seg-name {
  display: block;
  font-size: 8px;
  color: rgba(0, 0, 0, 0.45);
}

.timeline-free {
  min-width: 6px;
  border-radius: 3px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.015);
  transition: flex 0.25s var(--ease);
}

/* hover tooltip bar — matches treemap tooltip */
.timeline-tooltip-bar {
  flex-shrink: 0;
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--dim);
  font-family: var(--mono);
  overflow: hidden;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.timeline-tooltip-bar.active {
  background: var(--surface2);
  color: var(--text);
}

/* ── Range slider (bar zoom — overlaid at bottom of bar clip) ── */

.tl-range {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  z-index: 5;
  user-select: none;
  -webkit-user-select: none;
}

.tl-range-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.04);
}

.tl-range-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--accent);
  opacity: 0.35;
  cursor: grab;
  transition: opacity 0.12s;
}

.tl-range-fill:hover {
  opacity: 0.55;
}

.tl-range-active .tl-range-fill {
  opacity: 0.6;
  cursor: grabbing;
  transition: none;
}

/* edge-mounted tab handles */
.tl-range-handle {
  position: absolute;
  bottom: 0;
  width: 8px;
  height: 100%;
  min-height: 28px;
  margin-left: -4px;
  background: transparent;
  cursor: ew-resize;
  z-index: 6;
  touch-action: none;
}

/* visible tab part */
.tl-range-handle::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 4px;
  height: 20px;
  margin-left: -2px;
  border-radius: 2px 2px 0 0;
  background: rgba(255, 255, 255, 0.25);
  transition: background 0.12s, height 0.12s, box-shadow 0.12s;
}

/* grip dot */
.tl-range-handle::after {
  content: '';
  position: absolute;
  bottom: 7px;
  left: 50%;
  width: 2px;
  height: 2px;
  margin-left: -1px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  transition: bottom 0.12s;
}

.tl-range-handle:hover::before {
  background: var(--accent-text);
  height: 26px;
  box-shadow: 0 -2px 8px rgba(139, 92, 246, 0.4);
}

.tl-range-handle:hover::after {
  bottom: 10px;
}

.tl-range-active .tl-range-handle::before {
  background: var(--accent-text);
  height: 26px;
  box-shadow: 0 -2px 10px rgba(139, 92, 246, 0.5);
  transition: none;
}

/* range footer row (tooltip + reset) */
.tl-range-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
}

.tl-range-footer .timeline-tooltip-bar {
  flex: 1;
  min-height: 0;
  padding: 3px 10px;
}

.tl-range-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--dim);
  border-radius: 3px;
  width: 20px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.2s, width 0.2s;
  flex-shrink: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
  border: none;
}

.tl-range-reset.tl-range-zoomed {
  opacity: 1;
  pointer-events: auto;
  width: 20px;
  border: 1px solid var(--border);
}

.tl-range-reset:hover {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--text);
}

/* legend matches treemap */
.timeline-legend {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
  padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.3);
}

.timeline-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  color: var(--muted);
  cursor: default;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  font-family: var(--mono);
  padding: 2px 8px 2px 6px;
  border: 1px solid transparent;
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.timeline-legend-item:hover {
  color: var(--text);
  border-color: currentColor;
}

.timeline-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.timeline-legend-tokens {
  color: var(--dim);
  font-size: 9px;
}

/* (old dual-handle slider removed — replaced by .tl-range above) */

/* segment entrance animation */
@keyframes segSlideIn {
  from {
    transform: scaleX(0);
    opacity: 0;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

.timeline-seg {
  animation: segSlideIn 0.3s var(--ease) both;
  transform-origin: left center;
}

/* ── Context Explorer: Treemap section ── */

.ce-treemap-section {
  border-top: none;
  padding: 0;
  flex: 1 1 0;
  min-height: 200px;
  overflow: hidden;
  background: #080808;
  display: flex;
  flex-direction: column;
}

.ce-controls {
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ce-controls-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  font-family: var(--mono);
}

.ce-controls-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* ── Options dropdown ── */
.ce-dropdown {
  position: relative;
}

.ce-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.ce-dropdown-btn:hover,
.ce-dropdown-btn.open {
  border-color: var(--accent);
  color: var(--text);
}

.ce-dropdown-icon {
  width: 12px;
  height: 12px;
  opacity: 0.6;
  flex-shrink: 0;
}

.ce-dropdown-caret {
  width: 8px;
  height: 5px;
  opacity: 0.5;
  margin-left: 2px;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.ce-dropdown-btn.open .ce-dropdown-caret {
  transform: rotate(180deg);
}

.ce-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  z-index: 50;
}

.ce-dropdown-menu.open {
  display: block;
}

.ce-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}

.ce-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.ce-dropdown-item input[type="checkbox"] {
  display: none;
}

.ce-check {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--dim);
  background: transparent;
  flex-shrink: 0;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
}

.ce-dropdown-item input[type="checkbox"]:checked + .ce-check {
  background: var(--accent);
  border-color: var(--accent);
}

.ce-dropdown-item input[type="checkbox"]:checked + .ce-check::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 1px;
  width: 5px;
  height: 8px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.ce-treemap-wrap {
  position: relative;
  overflow: hidden;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ce-treemap-wrap .treemap-svg {
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  display: block;
}

.tm-view-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 12;
  max-width: min(460px, calc(100% - 16px));
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-top-color: rgba(255, 255, 255, 0.22);
  border-bottom-color: rgba(0, 0, 0, 0.35);
  background: rgba(10, 12, 18, 0.82);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.tm-view-badge-raw {
  color: #93c5fd;
  border-color: rgba(96, 165, 250, 0.30);
}

.tm-view-badge-derived {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.30);
}

/* ── Floating content tooltip for treemap cells ── */

.tm-float-tooltip {
  --ft-accent: rgba(255, 255, 255, 0.15);
  position: absolute;
  z-index: 20;
  pointer-events: none;
  max-width: 340px;
  min-width: 200px;
  background: #0a0a0a;
  border: 1.5px solid var(--ft-accent);
  border-radius: var(--radius);
  padding: 0;
  font-family: var(--mono);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.1s;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.tm-float-tooltip.tm-ft-visible {
  opacity: 1;
  visibility: visible;
}

.tm-ft-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.tm-ft-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.tm-ft-tokens {
  font-size: 10px;
  color: var(--dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.tm-ft-content {
  padding: 8px 10px;
  font-size: 10px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.55);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, black 75%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 75%, transparent 100%);
}

/* ── Context Explorer: Delta section ── */

.ce-context-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.ce-context-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ce-context-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.ce-context-chip-positive {
  border-color: rgba(34, 197, 94, 0.25);
}

.ce-context-chip-negative {
  border-color: rgba(244, 63, 94, 0.25);
}

.ce-context-chip-warning {
  border-color: rgba(245, 158, 11, 0.25);
}

.ce-context-chip-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
}

.ce-context-chip-value {
  color: var(--text);
  font-weight: 600;
}

.ce-context-runtime,
.ce-context-blocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.ce-context-card {
  appearance: none;
  text-align: left;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.ce-context-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.02);
}

.ce-context-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ce-context-card-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  text-transform: lowercase;
}

.ce-context-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ce-context-status-loaded {
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
}

.ce-context-status-empty {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
}

.ce-context-status-error {
  color: #fda4af;
  background: rgba(244, 63, 94, 0.12);
}

.ce-context-status-skipped,
.ce-context-status-neutral {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.ce-context-card-preview {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.ce-context-card-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
}

.ce-convo-section {
  padding: 2px 4px 0 4px;
  flex: 0 0 auto;
  background: transparent;
  border-top: none;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 48px;
  display: flex;
  flex-direction: column;
}

.ce-convo-resizer {
  flex: 0 0 auto;
  height: 8px;
  cursor: row-resize;
  background: rgba(255, 255, 255, 0.015);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  position: relative;
  touch-action: none;
}

.ce-convo-resizer::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 2px;
  transform: translateX(-50%);
  width: 34px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  opacity: 0.7;
}

.ce-convo-resizer:hover {
  background: rgba(255, 255, 255, 0.03);
}

.ce-convo-resizer.dragging {
  background: rgba(139, 92, 246, 0.10);
  border-top-color: rgba(139, 92, 246, 0.35);
}

.ce-convo-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.ce-wf-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 0;
  min-height: 0;
}

.ce-wf-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.ce-wf-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
  font-family: var(--mono);
  flex-shrink: 0;
}

.ce-wf-headline {
  font-size: 11px;
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 260px;
}

.ce-wf-meta {
  font-size: 9px;
  color: var(--dim);
  font-family: var(--mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.ce-wf-zoom-chip {
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--dim);
  padding: 1px 6px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  background: linear-gradient(135deg,
    #1a1a1a 5%, #2a2a2a 15%, #222 35%, #282828 50%,
    #222 65%, #2a2a2a 85%, #1a1a1a 95%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top-color: rgba(255, 255, 255, 0.12);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.ce-wf-zoom-chip:hover {
  opacity: 0.85;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
}

.ce-wf-zoom-active {
  opacity: 1;
  color: var(--accent);
  border-color: rgba(139, 92, 246, 0.30);
  border-top-color: rgba(139, 92, 246, 0.40);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg,
    rgba(139,92,246,0.08) 5%, rgba(139,92,246,0.16) 15%, rgba(139,92,246,0.10) 35%,
    rgba(139,92,246,0.14) 50%, rgba(139,92,246,0.10) 65%, rgba(139,92,246,0.16) 85%,
    rgba(139,92,246,0.08) 95%);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(139,92,246,0.15),
    inset 0 1px 0 rgba(139,92,246,0.12), inset 0 -1px 0 rgba(0,0,0,0.25);
}

.ce-wf-header-chips {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.ce-wf-chip {
  font-size: 8px;
  font-weight: 600;
  color: var(--dim);
  padding: 1px 6px;
  border-radius: 2px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-top-color: rgba(148, 163, 184, 0.20);
  border-bottom-color: rgba(0, 0, 0, 0.30);
  background: linear-gradient(135deg, #1a1a1a 5%, #2a2a2a 15%, #222 35%, #282828 50%, #222 65%, #2a2a2a 85%, #1a1a1a 95%);
  font-family: var(--mono);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  line-height: 1.5;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 0 0 0.5px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.ce-wf-chip-active {
  color: var(--accent);
  border-color: rgba(139, 92, 246, 0.30);
  background: linear-gradient(135deg, #151020 5%, #1e1530 15%, #181228 35%, #1e1530 50%, #181228 65%, #1e1530 85%, #151020 95%);
}

.ce-wf-chip-warn {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.24);
  background: rgba(251, 191, 36, 0.08);
}

.ce-wf-notice {
  color: rgba(251, 191, 36, 0.76);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.35;
  padding: 2px 4px 4px;
}

.ce-wf-scroll {
  overflow: auto;
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
  flex: 1 1 0;
  min-height: 120px;
}

.ce-wf-svg {
  display: block;
  min-height: 100%;
}

.ce-wf-tick {
  stroke: rgba(255, 255, 255, 0.05);
  stroke-width: 1;
}

.ce-wf-tick-label {
  font-size: 9px;
  font-family: var(--mono);
  fill: var(--dim);
  text-anchor: middle;
}

.ce-wf-cursor {
  stroke: rgba(255, 255, 255, 0.30);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.ce-wf-row-label {
  font-size: 10px;
  font-family: var(--mono);
  fill: var(--muted);
  cursor: pointer;
}

.ce-wf-row-label:hover {
  fill: var(--text);
}

.ce-wf-bar {
  cursor: pointer;
  fill: rgba(255, 255, 255, 0.14);
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
  filter: url(#wf-bar-glow);
  transition: filter 0.15s ease-out, opacity 0.15s ease-out;
}

.ce-wf-bar:hover {
  filter: url(#wf-bar-glow) brightness(1.3);
}

.ce-wf-bar-router {
  fill: rgba(139, 92, 246, 0.72);
  stroke: rgba(139, 92, 246, 0.30);
}

.ce-wf-bar-assistant {
  fill: rgba(59, 130, 246, 0.72);
  stroke: rgba(59, 130, 246, 0.30);
}

.ce-wf-bar-tool {
  fill: rgba(34, 197, 94, 0.72);
  stroke: rgba(34, 197, 94, 0.30);
}

.ce-wf-tool-marker {
  cursor: pointer;
  fill: rgba(34, 197, 94, 0.86);
  stroke: rgba(187, 247, 208, 0.58);
  stroke-width: 1;
}

.ce-wf-tool-marker-active {
  filter: url(#wf-bar-glow) brightness(1.2);
}

.ce-wf-bar-error {
  fill: rgba(244, 63, 94, 0.78);
  stroke: rgba(244, 63, 94, 0.35);
}

.ce-wf-bar-pipeline {
  fill: rgba(107, 114, 128, 0.50);
  stroke: rgba(255, 255, 255, 0.06);
}

.ce-wf-bar-llm {
  fill: rgba(59, 130, 246, 0.60);
  stroke: rgba(59, 130, 246, 0.25);
}

.ce-wf-bar-active {
  stroke: rgba(255, 255, 255, 0.40);
  stroke-width: 1.5;
  filter: url(#wf-bar-glow) brightness(1.15);
}

.ce-wf-time-highlight {
  fill: rgba(139, 92, 246, 0.10);
  pointer-events: none;
}

.ce-wf-row-label-active {
  fill: var(--accent) !important;
  font-weight: 600;
}

.ce-wf-bar-duration {
  font-size: 9px;
  font-family: var(--mono);
  fill: rgba(255, 255, 255, 0.85);
  text-anchor: middle;
  pointer-events: none;
  dominant-baseline: central;
  font-weight: 500;
}

.ce-wf-bar-dimmed { opacity: 0.35; filter: brightness(0.8) saturate(0.5); }
.ce-wf-row-label-dimmed { opacity: 0.35; }

.ce-wf-bar-duration-outside { fill: var(--muted); }

.ce-wf-row-highlight {
  fill: rgba(255, 255, 255, 0.04);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
}
.ce-wf-row-highlight-visible { opacity: 1; }

.ce-wf-label-bg { fill: rgba(0, 0, 0, 0.20); }
.ce-wf-label-sep { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1; }

.ce-wf-tooltip {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 8px 12px;
  max-width: 320px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text);
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.12s ease;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ce-wf-tooltip-title { font-weight: 600; font-size: 11px; }
.ce-wf-tooltip-dur { color: var(--accent-text); font-weight: 600; }
.ce-wf-tooltip-chip { display: inline-block; padding: 1px 5px; border-radius: 3px; font-size: 9px; font-weight: 600; }
.ce-wf-tooltip-chip-router   { background: rgba(139,92,246,0.20); color: #c4b5fd; }
.ce-wf-tooltip-chip-assistant { background: rgba(59,130,246,0.20); color: #93c5fd; }
.ce-wf-tooltip-chip-tool      { background: rgba(34,197,94,0.20); color: #86efac; }
.ce-wf-tooltip-chip-error     { background: rgba(244,63,94,0.20); color: #fda4af; }
.ce-wf-tooltip-chip-pipeline  { background: rgba(255,255,255,0.08); color: var(--muted); }
.ce-wf-tooltip-chip-llm       { background: rgba(59,130,246,0.15); color: #93c5fd; }
.ce-wf-tooltip-row { color: var(--muted); font-size: 9px; }
.ce-wf-tooltip-status { color: var(--dim); }

.ce-convo-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.ce-convo-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 0 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 8px;
}

.ce-convo-flow-wrap {
  min-height: 0;
}

.ce-convo-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
  font-family: var(--mono);
  flex-shrink: 0;
}

.ce-convo-headline {
  font-size: 11px;
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 260px;
}

.ce-convo-meta {
  font-size: 9px;
  color: var(--dim);
  font-family: var(--mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.ce-convo-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.ce-convo-flow::-webkit-scrollbar {
  width: 4px;
}

.ce-convo-node {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-left: 3px solid var(--dim);
  cursor: pointer;
  transition: background 0.1s, border-left-color 0.1s;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.ce-convo-node:hover {
  background: rgba(255, 255, 255, 0.025);
}

.ce-convo-node-active {
  background: rgba(255, 255, 255, 0.04);
  border-left-color: var(--accent);
}

.ce-convo-chips-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
}

.ce-convo-turn {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--dim);
  flex-shrink: 0;
}

.ce-convo-step {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
  text-align: right;
}

/* .ce-convo-node-bottom removed (vertical layout) */

.ce-convo-chip {
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.15);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg,
    #1a1a1a 5%, #2a2a2a 15%, #222 35%, #282828 50%,
    #222 65%, #2a2a2a 85%, #1a1a1a 95%);
  color: var(--dim);
  white-space: nowrap;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 0 0 0.5px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.ce-convo-chip.chip-tools {
  color: rgba(134, 239, 172, 0.92);
  border-color: rgba(34, 197, 94, 0.25);
  border-top-color: rgba(34, 197, 94, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg,
    rgba(34,197,94,0.06) 5%, rgba(34,197,94,0.14) 15%, rgba(34,197,94,0.08) 35%,
    rgba(34,197,94,0.12) 50%, rgba(34,197,94,0.08) 65%, rgba(34,197,94,0.14) 85%,
    rgba(34,197,94,0.06) 95%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(34,197,94,0.12),
    inset 0 1px 0 rgba(34,197,94,0.10), inset 0 -1px 0 rgba(0,0,0,0.25);
}

.ce-convo-chip.chip-tok {
  color: rgba(255, 255, 255, 0.60);
}

.ce-convo-chip.chip-ok {
  color: rgba(134, 239, 172, 0.92);
  border-color: rgba(34, 197, 94, 0.25);
  border-top-color: rgba(34, 197, 94, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg,
    rgba(34,197,94,0.06) 5%, rgba(34,197,94,0.14) 15%, rgba(34,197,94,0.08) 35%,
    rgba(34,197,94,0.12) 50%, rgba(34,197,94,0.08) 65%, rgba(34,197,94,0.14) 85%,
    rgba(34,197,94,0.06) 95%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(34,197,94,0.12),
    inset 0 1px 0 rgba(34,197,94,0.10), inset 0 -1px 0 rgba(0,0,0,0.25);
}

.ce-convo-chip.chip-muted {
  color: var(--dim);
}

.ce-convo-chip.chip-thinking {
  color: rgba(196, 167, 255, 0.9);
  border-color: rgba(139, 92, 246, 0.25);
  border-top-color: rgba(139, 92, 246, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg,
    rgba(139,92,246,0.06) 5%, rgba(139,92,246,0.14) 15%, rgba(139,92,246,0.08) 35%,
    rgba(139,92,246,0.12) 50%, rgba(139,92,246,0.08) 65%, rgba(139,92,246,0.14) 85%,
    rgba(139,92,246,0.06) 95%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(139,92,246,0.12),
    inset 0 1px 0 rgba(139,92,246,0.10), inset 0 -1px 0 rgba(0,0,0,0.25);
}

.ce-convo-chip.chip-preview {
  color: rgba(255, 255, 255, 0.45);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ce-convo-arrow {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.22);
  font-size: 12px;
  user-select: none;
}

.ce-convo-connector {
  display: none; /* vertical layout no longer uses horizontal connectors */
  align-self: stretch;
}

.ce-convo-connector-line {
  position: absolute;
  left: 0;
  right: 5px;
  height: 1.5px;
  background: rgba(255, 255, 255, 0.16);
  top: 50%;
  transform: translateY(-50%);
}

.ce-convo-connector-head {
  position: absolute;
  right: 0;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid rgba(255, 255, 255, 0.24);
  top: 50%;
  transform: translateY(-50%);
}

/* connector hover styles removed (vertical layout) */

.ce-delta-section {
  display: none;
}

/* ── Turn trigger card ── */
.ce-trigger {
  margin-bottom: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

/* hide trigger card when turn flow panel is open (CSS safety net) */
#turnflow.tf-panel-open ~ #tf-resizer ~ #main .ce-trigger {
  display: none;
}

.ce-trigger-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.ce-trigger-label {
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent-text);
  flex-shrink: 0;
  background: rgba(139, 92, 246, 0.08);
  padding: 2px 6px;
  border-radius: 3px;
}

.ce-trigger-meta {
  font-size: 9px;
  font-family: var(--mono);
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ce-trigger-text {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius);
  max-height: 80px;
  overflow: hidden;
}

.ce-response {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.ce-response-label {
  font-size: 9px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #22c55e;
  margin-bottom: 3px;
}

.ce-response-text {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
  opacity: 0.8;
  white-space: pre-wrap;
}

.ce-response-tool {
  color: var(--muted);
  font-style: italic;
  opacity: 0.6;
}

.ce-delta-empty {
  font-size: 11px;
  color: var(--dim);
  font-family: var(--mono);
  font-style: italic;
}

.ce-delta-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 12px;
}

.ce-delta-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  font-family: var(--mono);
}

.ce-delta-summary {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text);
}

.ce-delta-rows {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.ce-delta-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: var(--mono);
  padding: 2px 8px 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.15);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  border-radius: 2px;
  background: linear-gradient(135deg,
    #1a1a1a 5%, #2e2e2e 15%, #252525 35%, #2c2c2c 50%,
    #252525 65%, #2e2e2e 85%, #1a1a1a 95%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.ce-delta-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 3px currentColor;
}

.ce-delta-name {
  color: var(--dim);
}

.ce-delta-val {
  color: var(--text);
}

.ce-delta-up {
  color: #f87171;
}

.ce-delta-down {
  color: #4ade80;
}

/* ── Turn Flow ── */

.ce-turn-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  outline: none;
  background: var(--well);
  position: relative;
}

/* Conversation list (left pane) */
.tf-convo-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  outline: none;
  position: relative;
}

/* ── Two-line turn rows — metallic card style ── */

.tf-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 10px;
  margin: 2px 6px;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-left-color 0.12s, box-shadow 0.12s;
  border-radius: var(--radius-sm);
  user-select: none;
  background: var(--surface);
  min-width: 0;
  max-width: calc(100% - 12px);
  overflow: visible;
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    inset 0 -1px 0 var(--bezel-lo),
    0 1px 2px rgba(0, 0, 0, 0.2);
}

.tf-convo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  margin: 2px 6px;
  border-left: 3px solid var(--dim);
  cursor: pointer;
  transition: background 0.12s, border-left-color 0.12s, box-shadow 0.12s;
  border-bottom: none;
  border-radius: var(--radius-sm);
  user-select: none;
  background: var(--surface);
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    inset 0 -1px 0 var(--bezel-lo),
    0 1px 2px rgba(0, 0, 0, 0.2);
}

.tf-convo-row-static {
  cursor: default;
}

.tf-convo-row-static:hover,
.tf-convo-row-static:active {
  transform: none;
  background: var(--surface3);
}

.tf-row-line1 {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.tf-row-line2 {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 30px;
  min-width: 0;
  overflow: hidden;
}

.tf-run-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 30px;
  padding-top: 4px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.tf-life-flow {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 3px 4px 5px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.2;
}

.tf-agent-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 5px 4px 1px;
  padding: 4px 0 1px;
  border-top: 1px dotted rgba(255, 255, 255, 0.1);
  color: rgba(203, 213, 225, 0.88);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tf-agent-section span:last-child {
  overflow: hidden;
  color: var(--dim);
  font-weight: 500;
  text-align: right;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

/*
 * Round-block layout (Layout 3): each block groups one round
 * (context_build -> model_call -> tools) into a single visual unit
 * with an agent-colored stripe, round number, duration, and badges
 * (spawned by R1, terminal, after execution result, etc.).
 */
.tf-round-block {
  position: relative;
  margin: 6px 0 4px;
  padding: 4px 6px 4px 9px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left-width: 3px;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.18);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.tf-round-block + .tf-round-block { margin-top: 4px; }

.tf-round-interaction {
  border-left-color: rgba(96, 165, 250, 0.78);
  background: rgba(30, 58, 138, 0.10);
}
.tf-round-execution {
  border-left-color: rgba(167, 139, 250, 0.78);
  background: rgba(76, 29, 149, 0.10);
}
.tf-round-unknown {
  border-left-color: rgba(148, 163, 184, 0.55);
}

.tf-round-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  padding: 1px 0;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.3;
  color: var(--text-hi);
}

.tf-round-num {
  color: rgba(248, 250, 252, 0.95);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tf-round-owner {
  display: inline-flex;
  align-items: center;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.55;
  text-transform: uppercase;
}
.tf-round-owner-interaction {
  color: rgba(191, 219, 254, 0.95);
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(96, 165, 250, 0.45);
}
.tf-round-owner-execution {
  color: rgba(221, 214, 254, 0.95);
  background: rgba(139, 92, 246, 0.20);
  border: 1px solid rgba(167, 139, 250, 0.50);
}

.tf-round-dur {
  margin-left: auto;
  color: var(--dim);
  font-size: 8px;
  font-weight: 500;
}

.tf-round-tag {
  display: inline-flex;
  align-items: center;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 600;
  line-height: 1.55;
  color: rgba(252, 211, 77, 0.95);
  background: rgba(146, 64, 14, 0.22);
  border: 1px solid rgba(217, 119, 6, 0.35);
  letter-spacing: 0.02em;
}

.tf-round-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Tighten lifecycle items inside a round so the block reads as one unit. */
.tf-round-body .tf-run-item {
  padding-top: 1px;
  padding-bottom: 1px;
}

.tf-life-step {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 58px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tf-life-step-active {
  color: var(--muted);
}

.tf-life-step-muted {
  color: rgba(148, 163, 184, 0.26);
}

.tf-life-arrow {
  color: rgba(148, 163, 184, 0.28);
}

.tf-life-badge {
  width: 46px;
  flex: 0 0 46px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.45;
  padding: 1px 4px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tf-life-badge-input {
  border-color: rgba(148, 163, 184, 0.22);
  color: rgba(203, 213, 225, 0.86);
}

.tf-life-badge-context {
  border-color: rgba(167, 139, 250, 0.25);
  color: rgba(196, 181, 253, 0.9);
}

.tf-life-badge-model {
  border-color: rgba(96, 165, 250, 0.25);
  color: rgba(147, 197, 253, 0.95);
}

.tf-life-badge-tool {
  border-color: rgba(74, 222, 128, 0.24);
  color: rgba(134, 239, 172, 0.92);
}

.tf-life-badge-response {
  border-color: rgba(148, 163, 184, 0.22);
  color: var(--text);
}

.tf-run-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 3px;
  padding: 4px 4px 1px;
  border-top: 1px dotted rgba(255, 255, 255, 0.08);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tf-run-section-label:first-child {
  margin-top: 0;
  border-top: 0;
}

.tf-run-section-label span:last-child {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-align: right;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

.tf-run-group {
  min-width: 0;
}

.tf-run-group summary {
  list-style: none;
}

.tf-run-group summary::-webkit-details-marker {
  display: none;
}

.tf-run-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  font-size: 9px;
  color: var(--dim);
  padding: 2px 4px;
  border-radius: 4px;
}

.tf-run-item-life {
  padding: 3px 4px;
}

.tf-run-item-clickable {
  cursor: pointer;
  border: 1px solid transparent;
}

.tf-run-item-clickable:hover {
  background: rgba(96, 165, 250, 0.08);
  border-color: rgba(96, 165, 250, 0.24);
}

.tf-run-item-clickable:hover .tf-run-label {
  color: var(--text-hi);
}

.tf-run-item-active {
  background: rgba(96, 165, 250, 0.14);
  border-color: rgba(96, 165, 250, 0.45);
}

.tf-run-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.45);
  flex-shrink: 0;
}

.tf-run-label {
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.tf-run-meta {
  color: var(--dim);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tf-run-action {
  margin-left: auto;
  flex: 0 0 auto;
  max-width: 112px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 3px;
  padding: 1px 4px;
  color: rgba(203, 213, 225, 0.68);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tf-run-action-api_tree {
  border-color: rgba(167, 139, 250, 0.34);
  color: rgba(196, 181, 253, 0.92);
}

.tf-run-action-prompt_input_tree {
  border-color: rgba(96, 165, 250, 0.32);
  color: rgba(147, 197, 253, 0.9);
}

.tf-run-action-details_only {
  border-color: rgba(148, 163, 184, 0.14);
  color: rgba(148, 163, 184, 0.58);
}

.tf-run-child-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 3px 28px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.tf-run-child {
  display: grid;
  grid-template-columns: minmax(72px, 0.5fr) minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.35;
}

.tf-run-child-kind,
.tf-run-child-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tf-run-child-kind {
  color: rgba(147, 197, 253, 0.78);
}

.tf-run-child-message {
  opacity: 0.86;
}

.tf-run-child-message .tf-run-child-kind {
  color: rgba(167, 139, 250, 0.78);
}

.tf-run-child-message .tf-run-child-kind:first-child {
  text-transform: uppercase;
}

.tf-run-child-label {
  color: var(--muted);
}

.tf-run-child-tokens {
  color: var(--dim);
  white-space: nowrap;
}

.tf-run-item-response .tf-run-label {
  color: var(--text);
}

.tf-run-item-llm .tf-run-label {
  color: #60a5fa;
}

.tf-run-item-child .tf-run-label {
  color: #4ade80;
}

.tf-run-item-life .tf-run-label {
  width: 76px;
  flex: 0 0 76px;
  color: var(--muted);
}

.tf-run-item-life .tf-run-meta {
  color: rgba(148, 163, 184, 0.72);
}

.tf-run-item-life.tf-life-model .tf-run-label {
  color: rgba(147, 197, 253, 0.95);
}

.tf-run-item-life.tf-life-tool .tf-run-label {
  color: rgba(134, 239, 172, 0.92);
}

.tf-run-item-life.tf-life-context .tf-run-label {
  color: rgba(196, 181, 253, 0.9);
}

.tf-run-item-life.tf-life-response .tf-run-label {
  color: var(--text);
}

.tf-row-active .tf-run-label {
  color: var(--text-hi);
}

.tf-row-active .tf-run-meta {
  color: var(--muted);
}

.tf-row-pipe-chip {
  font-size: 8px !important;
}

.tf-row-meta-item {
  font-size: 9px;
  font-family: var(--mono);
  color: var(--dim);
  white-space: nowrap;
}

.tf-click-hint {
  margin-left: auto;
  color: rgba(148, 163, 184, 0.62);
}

.tf-row-ts {
  opacity: 0.6;
}

.tf-row:hover,
.tf-convo-row:hover {
  background: var(--surface2);
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    inset 0 -1px 0 var(--bezel-lo),
    0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Active row — raised, brighter */
.tf-row-active,
.tf-convo-row-active {
  background: var(--surface3);
  border-left-width: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 0 var(--bezel-lo),
    0 2px 6px rgba(0, 0, 0, 0.35);
}

.tf-row-active:hover,
.tf-convo-row-active:hover {
  background: var(--surface3);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 var(--bezel-lo),
    0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Press effect — pushed in */
.tf-row:active,
.tf-convo-row:active {
  transform: translateY(0.5px);
  background: var(--well);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(0, 0, 0, 0.2);
}

.tf-row-num {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--dim);
  flex-shrink: 0;
  min-width: 24px;
  letter-spacing: 0.02em;
}

.tf-row-active .tf-row-num,
.tf-convo-row-active .tf-row-num {
  color: var(--text);
}

.tf-row-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--muted);
  min-width: 0;
}

.tf-row-active .tf-row-text,
.tf-convo-row-active .tf-row-text {
  color: var(--text-hi);
}

.tf-row-delta {
  flex-shrink: 0;
}

.tf-convo-count {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--dim);
  padding: 1px 6px;
  border-radius: 2px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-top-color: rgba(148, 163, 184, 0.20);
  border-bottom-color: rgba(0, 0, 0, 0.30);
  background: linear-gradient(135deg, #1a1a1a 5%, #2a2a2a 15%, #222 35%, #282828 50%, #222 65%, #2a2a2a 85%, #1a1a1a 95%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 0 0 0.5px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  line-height: 1.5;
}

/* Only the selected turn gets a status rail. Pipeline type now lives in chips,
   not persistent left borders on every row. */
.tf-row-active {
  border-color: rgba(34, 197, 94, 0.58);
  border-left-color: var(--ok);
}

/* ── Group divider (section header between groups) ── */

/* .tf-group-divider removed (dead code) */

/* ── Status bar — LCD instrument panel ── */

.tf-status-bar {
  /* outer chassis */
  background: var(--surface);
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-lg);
  margin: 6px 8px;
  padding: 3px;
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    0 2px 8px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-shrink: 0;
}

/* inner LCD screen */
.tf-status-bar::before {
  display: none; /* no pseudo needed — children handle it */
}

.tf-status-meta {
  /* the LCD display panel */
  background: linear-gradient(180deg, #c4c8cc 0%, #cdd1d5 40%, #c8ccd0 70%, #c0c4c8 100%);
  border: 2.5px solid rgba(255, 255, 255, 0.75);
  outline: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: #111318;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.10),
    inset 0 -1px 0 rgba(255, 255, 255, 0.6),
    0 1px 0 rgba(0, 0, 0, 0.3);
  letter-spacing: 0.03em;
  line-height: 1.3;
}

.tf-status-sep {
  display: none; /* not used in LCD layout */
}

.tf-status-bar .tf-minibar {
  /* minibar sits below the LCD — in the chassis area */
  flex: none;
  width: calc(100% - 8px);
  margin: 6px auto 2px;
  height: 8px;
  border-radius: 4px;
  background: var(--well);
  border: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    0 1px 0 var(--bezel-hi);
}

/* ── LCD inner layout ── */

.lcd-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

/* Row 1: Turn number + pipeline step label bar */
.lcd-row-primary {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.18);
}

.lcd-value-lg {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: #0a0d12;
  letter-spacing: 0.02em;
  line-height: 1;
}

.lcd-label-right {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  color: #1a1e28;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.10);
  padding: 3px 8px;
  border-radius: 3px;
  border: 1.5px solid rgba(0, 0, 0, 0.18);
}

/* Row 2: Big readout cells — TOKENS | UTIL | TOOLS */
.lcd-row-readout {
  align-items: stretch;
  gap: 0;
  margin: 4px 0 2px;
}

.lcd-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  gap: 2px;
  padding: 2px 6px;
}

.lcd-label {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  color: #1a1e28;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  line-height: 1;
}

.lcd-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: #0a0d12;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.lcd-div {
  width: 2px;
  align-self: stretch;
  background: rgba(0, 0, 0, 0.16);
  margin: 0;
}

/* Row 3: Footer — timestamp, router status */
.lcd-row-footer {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  color: #2a2e38;
  letter-spacing: 0.06em;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 2px solid rgba(0, 0, 0, 0.16);
  gap: 6px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.lcd-dot {
  color: #6b7280;
  margin: 0 2px;
}

.lcd-empty {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #8890a0;
  letter-spacing: 0.1em;
  text-align: center;
  width: 100%;
  display: block;
  padding: 12px 0;
}

.tf-pipeline-chip {
  font-size: 9px;
  font-weight: 600;
  color: var(--text);
  padding: 1px 6px;
  border-radius: 2px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-top-color: rgba(148, 163, 184, 0.25);
  border-bottom-color: rgba(0, 0, 0, 0.35);
  background: linear-gradient(135deg, #1a1a1a 5%, #2a2a2a 15%, #222 35%, #282828 50%, #222 65%, #2a2a2a 85%, #1a1a1a 95%);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  line-height: 1.5;
  white-space: nowrap;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.tf-pipeline-chip.router {
  color: #f97316;
  border-color: rgba(249, 115, 22, 0.25);
  border-top-color: rgba(249, 115, 22, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, rgba(249,115,22,0.06) 5%, rgba(249,115,22,0.14) 15%, rgba(249,115,22,0.08) 35%, rgba(249,115,22,0.12) 50%, rgba(249,115,22,0.08) 65%, rgba(249,115,22,0.14) 85%, rgba(249,115,22,0.06) 95%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(249,115,22,0.12), inset 0 1px 0 rgba(249,115,22,0.10), inset 0 -1px 0 rgba(0,0,0,0.25);
}

.tf-pipeline-chip.tool-result {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.25);
  border-top-color: rgba(245, 158, 11, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, rgba(245,158,11,0.06) 5%, rgba(245,158,11,0.14) 15%, rgba(245,158,11,0.08) 35%, rgba(245,158,11,0.12) 50%, rgba(245,158,11,0.08) 65%, rgba(245,158,11,0.14) 85%, rgba(245,158,11,0.06) 95%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(245,158,11,0.12), inset 0 1px 0 rgba(245,158,11,0.10), inset 0 -1px 0 rgba(0,0,0,0.25);
}

.tf-pipeline-chip.assistant-tools {
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.25);
  border-top-color: rgba(96, 165, 250, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, rgba(96,165,250,0.06) 5%, rgba(96,165,250,0.14) 15%, rgba(96,165,250,0.08) 35%, rgba(96,165,250,0.12) 50%, rgba(96,165,250,0.08) 65%, rgba(96,165,250,0.14) 85%, rgba(96,165,250,0.06) 95%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(96,165,250,0.12), inset 0 1px 0 rgba(96,165,250,0.10), inset 0 -1px 0 rgba(0,0,0,0.25);
}

.tf-pipeline-chip.assistant {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.25);
  border-top-color: rgba(74, 222, 128, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, rgba(74,222,128,0.06) 5%, rgba(74,222,128,0.14) 15%, rgba(74,222,128,0.08) 35%, rgba(74,222,128,0.12) 50%, rgba(74,222,128,0.08) 65%, rgba(74,222,128,0.14) 85%, rgba(74,222,128,0.06) 95%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(74,222,128,0.12), inset 0 1px 0 rgba(74,222,128,0.10), inset 0 -1px 0 rgba(0,0,0,0.25);
}

.tf-pipeline-chip.context-assembly {
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.22);
  border-top-color: rgba(148, 163, 184, 0.30);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, rgba(148,163,184,0.04) 5%, rgba(148,163,184,0.10) 15%, rgba(148,163,184,0.06) 35%, rgba(148,163,184,0.08) 50%, rgba(148,163,184,0.06) 65%, rgba(148,163,184,0.10) 85%, rgba(148,163,184,0.04) 95%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(148,163,184,0.08), inset 0 1px 0 rgba(148,163,184,0.08), inset 0 -1px 0 rgba(0,0,0,0.25);
}

.tf-pipeline-chip.user {
  color: #c4b5fd;
  border-color: rgba(196, 181, 253, 0.25);
  border-top-color: rgba(196, 181, 253, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, rgba(196,181,253,0.06) 5%, rgba(196,181,253,0.14) 15%, rgba(196,181,253,0.08) 35%, rgba(196,181,253,0.12) 50%, rgba(196,181,253,0.08) 65%, rgba(196,181,253,0.14) 85%, rgba(196,181,253,0.06) 95%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(196,181,253,0.12), inset 0 1px 0 rgba(196,181,253,0.10), inset 0 -1px 0 rgba(0,0,0,0.25);
}

.tf-meta {
  font-size: 10px;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.tf-delta {
  font-size: 9px;
  font-weight: 600;
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 2px;
  line-height: 1.5;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.tf-delta-up {
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-top-color: rgba(239, 68, 68, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg,
    rgba(239,68,68,0.06) 5%, rgba(239,68,68,0.14) 15%, rgba(239,68,68,0.08) 35%,
    rgba(239,68,68,0.12) 50%, rgba(239,68,68,0.08) 65%, rgba(239,68,68,0.14) 85%,
    rgba(239,68,68,0.06) 95%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(239, 68, 68, 0.12),
    inset 0 1px 0 rgba(239, 68, 68, 0.10),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

.tf-delta-down {
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-top-color: rgba(34, 197, 94, 0.35);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg,
    rgba(34,197,94,0.06) 5%, rgba(34,197,94,0.14) 15%, rgba(34,197,94,0.08) 35%,
    rgba(34,197,94,0.12) 50%, rgba(34,197,94,0.08) 65%, rgba(34,197,94,0.14) 85%,
    rgba(34,197,94,0.06) 95%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(34, 197, 94, 0.12),
    inset 0 1px 0 rgba(34, 197, 94, 0.10),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

/* context mini-bar */
.tf-minibar {
  flex: 1;
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  min-width: 60px;
  border-top: 1px solid rgba(0, 0, 0, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.04);
}

.tf-bar-seg {
  height: 100%;
  min-width: 1px;
}

/* text blocks inside turn detail pane */
.tfe-text {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text);
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  opacity: 0.9;
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* turn detail pane layout override */
#tf-detail-body .detail-stats {
  flex-shrink: 0;
}

/* context breakdown */
.tfe-breakdown {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tfe-bucket {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-family: var(--mono);
  line-height: 1.6;
}

.tfe-bucket-total {
  border-top: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.04);
  padding-top: 3px;
  margin-top: 3px;
  font-weight: 600;
}

.tfe-bucket-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tfe-bucket-name {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tfe-bucket-tokens {
  color: var(--text);
  opacity: 0.8;
  flex-shrink: 0;
  text-align: right;
  min-width: 48px;
}

.tfe-bucket-pct {
  color: var(--dim);
  flex-shrink: 0;
  text-align: right;
  min-width: 42px;
}

/* expandable bucket detail — drill-down for context breakdown */
.tfe-bucket-detail {
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 2px 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-top-color: rgba(255, 255, 255, 0.08);
  border-bottom-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.tfe-bucket-detail > .tfe-bucket {
  cursor: pointer;
  padding: 2px 0;
  border-radius: var(--radius-sm);
  transition: background 0.1s, box-shadow 0.1s;
}

.tfe-bucket-detail > .tfe-bucket:hover {
  background: rgba(255,255,255,0.04);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.tfe-bucket-detail[open] > .tfe-bucket {
  background: var(--surface);
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    inset 0 -1px 0 var(--bezel-lo);
}

.tfe-bucket-detail > .tfe-bucket::-webkit-details-marker {
  display: none;
}

.tfe-bucket-detail > .tfe-bucket::before {
  content: "\203A";
  font-size: 10px;
  color: var(--dim);
  transition: transform 0.15s var(--ease);
  display: inline-block;
  width: 8px;
  flex-shrink: 0;
}

.tfe-bucket-detail[open] > .tfe-bucket::before {
  transform: rotate(90deg);
}

.tfe-bucket-detail > .detail-collapsible-body {
  padding: 6px 8px 6px 20px;
}

/* tool entry hint */
.tfe-tool-entry-header .dc-hint {
  margin-left: auto;
}

.tfe-tool-entry[open] > .tfe-tool-entry-header .dc-hint {
  display: none;
}

/* tool name badges — elevated metal pills */
.tfe-tool-names {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.tfe-tool-name-badge {
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9px;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: linear-gradient(135deg,
    #1a1a1a 5%, #2e2e2e 15%, #252525 35%, #2c2c2c 50%,
    #252525 65%, #2e2e2e 85%, #1a1a1a 95%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.15);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* ── Tool entry (collapsible per-tool result) ── */

.tfe-tool-entry {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top-color: rgba(255, 255, 255, 0.12);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 4px;
  background: var(--surface);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(0, 0, 0, 0.25);
}

.tfe-tool-entry:last-child {
  margin-bottom: 0;
}

.tfe-tool-entry-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: var(--surface2);
  transition: color 0.15s, background 0.12s, box-shadow 0.12s;
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    inset 0 -1px 0 var(--bezel-lo);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.tfe-tool-entry-header::-webkit-details-marker {
  display: none;
}

.tfe-tool-entry-header:hover {
  color: var(--text);
  background: var(--surface3);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    inset 0 -1px 0 var(--bezel-lo);
}

.tfe-tool-entry[open] > .tfe-tool-entry-header {
  background: var(--surface3);
  color: var(--text);
}

.tfe-tool-entry-arrow {
  flex-shrink: 0;
  width: 10px;
  font-size: 13px;
  color: var(--dim);
  transition: transform 0.15s var(--ease), color 0.15s;
  display: inline-block;
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.5),
    0 -1px 0 rgba(255, 255, 255, 0.04);
}

.tfe-tool-entry-arrow::before {
  content: "\203A";
}

.tfe-tool-entry[open] > .tfe-tool-entry-header .tfe-tool-entry-arrow {
  transform: rotate(90deg);
  color: var(--muted);
}

.tfe-tool-entry-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tfe-tool-entry-body {
  background: var(--well);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.5), var(--shadow-well);
  font-size: 11px;
  color: var(--text);
  line-height: 1.5;
  animation: fadeIn 0.12s ease-out;
}

.tfe-tool-entry-body .jt-viewer {
  border: none;
  border-radius: 0;
  max-height: 400px;
  overflow-y: auto;
  box-shadow: none;
}

.tfe-tool-entry-body pre {
  margin: 0;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 0;
  max-height: 400px;
  overflow: auto;
}

.tfe-tool-entry-body pre code {
  font-size: 11px;
  line-height: 1.5;
  color: #b0b0b0;
  background: none;
  padding: 0;
  border: none;
}

/* ── Turn Detail: Stat Chips (LCD indicator buttons) ── */

.tfd-stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 6px 6px;
}

.tfd-stat-chip {
  font-size: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--muted);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top-color: rgba(255, 255, 255, 0.12);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    inset 0 -1px 0 var(--bezel-lo),
    0 1px 2px rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* ── Turn Detail: Section Dividers ── */

.tfd-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 2px;
  font-size: 8px;
  font-family: var(--mono);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--dim);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06),
    0 -1px 0 rgba(0, 0, 0, 0.6);
}

.tfd-section::before,
.tfd-section::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(255, 255, 255, 0.07) 20%,
    rgba(255, 255, 255, 0.07) 80%,
    transparent);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

/* ── Turn Detail: Section Groups (connected collapsibles) ── */

.tfd-section-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tfd-section-group > .detail-collapsible {
  border-radius: 0;
  margin: 0;
}

.tfd-section-group > .detail-collapsible:first-child {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.tfd-section-group > .detail-collapsible:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.tfd-section-group > .detail-collapsible:only-child {
  border-radius: var(--radius-lg);
}

.tfd-section-group > .detail-collapsible + .detail-collapsible {
  border-top: none;
}

.tfd-section-group > .detail-collapsible + .detail-collapsible > .detail-collapsible-title {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    inset 0 -1px 0 var(--bezel-lo),
    0 -1px 0 rgba(0,0,0,0.35);
}

/* ── Turn Detail: Router sub-blocks inside merged collapsible ── */

.tfd-router-sub {
  padding: 6px 0;
}

.tfd-router-sub + .tfd-router-sub {
  border-top: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

.tfd-router-sub-label {
  font-size: 8px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin-bottom: 4px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* ── Hint chip on collapsed collapsibles ── */

.dc-hint {
  font-size: 9px;
  color: var(--dim);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
  flex-shrink: 1;
  min-width: 0;
}

.detail-collapsible[open] > .detail-collapsible-title .dc-hint {
  display: none;
}

/* ── Nested collapsible depth indicators ── */

/* depth 2 — nested inside a collapsible body */
.detail-collapsible-body .detail-collapsible {
  border-color: rgba(255,255,255,0.05);
  border-top-color: rgba(255,255,255,0.08);
  border-bottom-color: rgba(0,0,0,0.25);
  margin: 4px 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.detail-collapsible-body .detail-collapsible-title {
  font-size: 10px;
  padding: 6px 8px;
}

/* depth 3+ — deeper nesting */
.detail-collapsible-body .detail-collapsible-body .detail-collapsible {
  border-color: rgba(255,255,255,0.04);
  border-top-color: rgba(255,255,255,0.06);
  border-bottom-color: rgba(0,0,0,0.20);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

.detail-collapsible-body .detail-collapsible-body .detail-collapsible-title {
  font-size: 10px;
  padding: 5px 8px;
  color: var(--dim);
}

/* ── Scrollbar ── */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--well);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.06) 100%);
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.04);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.10) 100%);
}

/* touch devices: use native momentum */
@media (hover: none) {
  ::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
}

/* ── Keybinding Overlay ── */

.kb-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.kb-overlay.kb-visible {
  opacity: 1;
  pointer-events: auto;
}

.kb-panel {
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  padding: 20px 28px 16px;
  max-width: 420px;
  width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.kb-panel-title {
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 14px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.kb-section {
  margin-bottom: 12px;
}

.kb-section-title {
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  margin-bottom: 6px;
}

.kb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 0;
}

.kb-row-label {
  font-size: 12px;
  color: var(--text);
  font-family: var(--mono);
}

.kb-keys {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.kb-key {
  display: inline-block;
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
  background: linear-gradient(135deg,
    rgba(255,255,255,0.08) 0%,
    rgba(255,255,255,0.03) 100%);
  border: 1px solid rgba(255,255,255,0.12);
  border-bottom-width: 2px;
  border-bottom-color: rgba(0,0,0,0.3);
  border-radius: 4px;
  padding: 2px 7px;
  min-width: 22px;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 1px 2px rgba(0,0,0,0.3);
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}

.kb-hint {
  font-size: 10px;
  color: var(--dim);
  font-family: var(--mono);
  text-align: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════
   Agent Flow View — Architecture Diagram (af-*)
   ══════════════════════════════════════════════════ */

#main.af-mode {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  mask-image: none;
  -webkit-mask-image: none;
}

#main.cg-mode {
  padding: 0;
  overflow: hidden;
  mask-image: none;
  -webkit-mask-image: none;
}

/* ── Toolbar ── */
.af-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.af-session-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 11px;
  max-width: 300px;
  cursor: pointer;
}
.af-session-select:focus {
  outline: none;
  border-color: var(--accent);
}
.af-meta-chips {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.af-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  background: linear-gradient(135deg,
    #1a1a1a 5%, #2a2a2a 15%, #222 35%, #282828 50%,
    #222 65%, #2a2a2a 85%, #1a1a1a 95%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.15);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 0 0 0.5px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.af-live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--ok);
  font-weight: 600;
}
.af-live-dot-inner {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  animation: af-pulse 1.5s ease-in-out infinite;
}

.af-toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.af-reset-btn {
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 10px;
  font-family: var(--mono);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.af-reset-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}
.af-zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}
.af-zoom-btn {
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--mono);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
}
.af-zoom-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}
.af-zoom-label {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--muted);
  min-width: 36px;
  text-align: center;
}

/* ── Canvas Wrap ── */
.af-canvas-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  display: flex;
  justify-content: center;
  padding: 20px 16px;
  cursor: grab;
}
.af-canvas-panning {
  cursor: grabbing !important;
}

/* ── Architecture Diagram ── */
.af-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  position: relative;
  width: 100%;
  max-width: 640px;
  padding: 24px 0;
  transform-origin: 0 0;
  will-change: transform;
}

/* ── Row layouts ── */
.af-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 100%;
  z-index: 1;
}
.af-row-inputs,
.af-row-outputs {
  gap: 10px;
}
.af-row-agents {
  gap: 10px;
}
.af-row-branches {
  gap: 10px;
}

/* ── Stage Nodes ── */
.af-stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 16px;
  text-align: center;
  transition: all 0.3s var(--ease);
  cursor: grab;
  user-select: none;
  position: relative;
}
.af-stage-dragging {
  cursor: grabbing !important;
  transition: none !important;
  z-index: 10;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.af-stage-sm {
  min-width: 100px;
  padding: 8px 12px;
}
.af-stage-wide {
  width: 80%;
  max-width: 500px;
}
.af-stage-title {
  font-weight: 600;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--muted);
  transition: color 0.3s var(--ease);
}
.af-stage-detail {
  font-size: 10px;
  color: var(--dim);
  margin-top: 2px;
  transition: color 0.3s var(--ease);
}

/* ── Active State ── */
.af-stage-active {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 12px rgba(139,92,246,0.12), 0 0 2px rgba(139,92,246,0.3);
  cursor: pointer;
  animation: af-glow 3s ease-in-out infinite;
}
.af-stage-active .af-stage-title {
  color: var(--accent-text);
}
.af-stage-active .af-stage-detail {
  color: var(--muted);
}
.af-stage-active:hover {
  border-color: var(--accent-text);
  box-shadow: 0 0 18px rgba(139,92,246,0.2), 0 0 4px rgba(139,92,246,0.4);
}

/* ── SVG Edge Layer ── */
.af-edges {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.af-edge {
  fill: none;
  stroke: var(--dim);
  stroke-width: 1;
  opacity: 0.2;
  transition: opacity 0.3s var(--ease), stroke 0.3s var(--ease);
}
.af-edge-active {
  stroke: var(--accent);
  opacity: 0.8;
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  animation: af-dash 15s linear infinite;
}

/* ── Loop Badge ── */
.af-loop-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  border-radius: 10px;
  font-size: 10px;
  padding: 1px 6px;
  font-weight: 700;
  font-family: var(--font-display);
  z-index: 2;
  line-height: 1.4;
  color: var(--text-hi);
  background: linear-gradient(135deg,
    #2a2a30 5%, #3a3a42 15%, #32323a 35%, #38384040 50%,
    #32323a 65%, #3a3a42 85%, #2a2a30 95%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.22);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* ── Tooltip ── */
.af-tooltip {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 8px 12px;
  max-width: 320px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text);
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.15s ease;
  line-height: 1.5;
}
.af-tooltip strong {
  color: var(--accent-text);
  font-size: 11px;
}

/* ── Animations ── */
@keyframes af-dash {
  to { stroke-dashoffset: -200; }
}
@keyframes af-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(139,92,246,0.12), 0 0 2px rgba(139,92,246,0.3); }
  50% { box-shadow: 0 0 16px rgba(139,92,246,0.18), 0 0 4px rgba(139,92,246,0.4); }
}
@keyframes af-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Detail bar ── */
.af-detail-bar {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 14px;
  max-height: 240px;
  overflow-y: auto;
  font-size: 11px;
}
.af-detail-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  font-size: 12px;
}
.af-detail-meta {
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 2px;
  font-family: var(--mono);
}
.af-detail-preview {
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 3px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 80px;
  overflow-y: auto;
}
.af-detail-content {
  margin-top: 4px;
}
.af-detail-content pre {
  font-size: 10px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 6px 8px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 100px;
  overflow-y: auto;
  margin: 0;
}
.af-detail-args {
  font-size: 10px;
  color: var(--dim);
  margin-top: 2px;
}
.af-detail-args code {
  color: var(--muted);
  background: var(--bg);
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 9px;
}
.af-detail-args-label {
  color: var(--accent-text);
  font-weight: 500;
}

/* ── Mobile responsive ── */
@media (max-width: 639px) {
  .af-toolbar {
    padding: 6px 8px;
    gap: 6px;
  }
  .af-session-select {
    max-width: 160px;
    font-size: 10px;
  }
  .af-stage-sm {
    min-width: 70px;
    padding: 6px 8px;
  }
  .af-stage-detail {
    display: none;
  }
  .af-tooltip {
    max-width: 200px;
  }
  .af-detail-bar {
    max-height: 150px;
  }
  .af-diagram {
    gap: 18px;
  }
  .af-row {
    gap: 6px;
  }
  .af-stage-title {
    font-size: 10px;
  }
}

@keyframes ocSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Span badges & turn span list ── */
.span-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 2px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-top-color: rgba(148, 163, 184, 0.25);
  border-bottom-color: rgba(0, 0, 0, 0.35);
  background: linear-gradient(135deg, #1a1a1a 5%, #2a2a2a 15%, #222 35%, #282828 50%, #222 65%, #2a2a2a 85%, #1a1a1a 95%);
  color: var(--muted);
  margin-left: 4px;
  font-family: var(--mono);
  display: inline-flex;
  align-items: center;
  line-height: 1.5;
  white-space: nowrap;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
.span-badge-router_call {
  color: #f97316;
  border-color: rgba(249, 115, 22, 0.25);
  background: linear-gradient(135deg, #1a1508 5%, #2a2010 15%, #221c0c 35%, #282010 50%, #221c0c 65%, #2a2010 85%, #1a1508 95%);
}
.span-badge-llm_call {
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.25);
  background: linear-gradient(135deg, #0f1520 5%, #162030 15%, #121a28 35%, #152030 50%, #121a28 65%, #162030 85%, #0f1520 95%);
}
.span-badge-llm_segment {
  color: #93c5fd;
  border-color: rgba(147, 197, 253, 0.25);
  background: linear-gradient(135deg, #0f1520 5%, #162030 15%, #121a28 35%, #152030 50%, #121a28 65%, #162030 85%, #0f1520 95%);
}
.span-badge-tool_call {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.25);
  background: linear-gradient(135deg, #0f1a10 5%, #162818 15%, #122014 35%, #162818 50%, #122014 65%, #162818 85%, #0f1a10 95%);
}
.span-badge-pipeline_step {
  color: #c4b5fd;
  border-color: rgba(196, 181, 253, 0.25);
  background: linear-gradient(135deg, #151020 5%, #1e1530 15%, #181228 35%, #1e1530 50%, #181228 65%, #1e1530 85%, #151020 95%);
}
.span-badge-runtime_event {
  color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.25);
  background: linear-gradient(135deg, #151020 5%, #201632 15%, #181228 35%, #201632 50%, #181228 65%, #201632 85%, #151020 95%);
}
.tf-span-count {
  font-size: 9px;
  font-weight: 600;
  color: var(--dim);
  margin-left: 4px;
  font-family: var(--mono);
  padding: 1px 6px;
  border-radius: 2px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-top-color: rgba(148, 163, 184, 0.20);
  border-bottom-color: rgba(0, 0, 0, 0.30);
  background: linear-gradient(135deg, #1a1a1a 5%, #2a2a2a 15%, #222 35%, #282828 50%, #222 65%, #2a2a2a 85%, #1a1a1a 95%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 0 0 0.5px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  line-height: 1.5;
  display: inline-flex;
  align-items: center;
  cursor: help;
}
.tfd-span-list { display:flex; flex-direction:column; gap:4px; padding:4px 0; }
.tfd-span-item { display:flex; align-items:center; gap:6px; padding:3px 6px; border-radius:4px; font-size:11px; }
.tfd-span-current { background:var(--surface-2, rgba(255,255,255,0.06)); font-weight:600; }

@media (max-width: 760px) {
  .tool-section-group-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .tool-section-group-summary {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .tool-section-group-meta {
    grid-column: 2;
    text-align: left;
    white-space: normal;
  }

  .tool-kv-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
