/* Theme palettes (background, text, accent, JSON-highlight colors, etc.)
   live in themes.css and are switched via the data-theme attribute on
   <html>. styles.css only consumes the variables defined there. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  -webkit-user-select: none;
}

/* Toolbar */
.toolbar {
  position: relative;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px 10px 80px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  -webkit-app-region: drag;
}
.toolbar-actions, .brand, .file-info {
  -webkit-app-region: no-drag;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.brand .logo {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 16px;
}
.brand .title { font-size: 14px; letter-spacing: 0.2px; }

.toolbar-actions {
  position: absolute;
  left: 50%;
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  -webkit-app-region: no-drag;
}
.zoom-btn,
.zoom-level {
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: var(--sans);
}
.zoom-btn {
  width: 25px;
  font-size: 16px;
  line-height: 24px;
}
.zoom-level {
  min-width: 46px;
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
}
.zoom-btn:hover,
.zoom-level:hover { background: var(--btn-hover); color: var(--accent); }
.zoom-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.zoom-btn:focus-visible,
.zoom-level:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }

.trace-sources-menu {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: min(780px, calc(100vw - 24px));
  height: fit-content;
  /* One harness at a time, but that list can be long. */
  max-height: calc(100vh - 96px);
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  z-index: 80;
  font-size: 12px;
  -webkit-app-region: no-drag;
}
.trace-sources-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.trace-sources-head > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.trace-sources-head strong { color: var(--text); font-size: 12px; }
.trace-sources-head span { color: var(--text-faint); font-size: 10px; }
.trace-sources-refresh {
  width: 26px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg-soft);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  line-height: 22px;
}
.trace-sources-refresh:hover { color: var(--accent); border-color: var(--accent); }
.trace-source-card {
  padding: 10px 12px 11px;
  border-bottom: 1px solid var(--border);
}
.trace-source-card:last-child { border-bottom: none; }
.trace-source-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-bottom: 7px;
}
.trace-source-name {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.trace-source-name strong { color: var(--text); font-size: 12px; }
/* One tab per agent. The active tab names the source, so the card below it
   only has to show the path. */
.trace-sources-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}
.trace-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12px;
  white-space: nowrap;
}
.trace-tab:hover { color: var(--text); background: var(--row-hover); }
/* The harness-* classes set the colour; the active tab wears it. */
.trace-tab:not(.active) { color: var(--text-faint) !important; }
.trace-tab.active { border-bottom-color: currentColor; font-weight: 600; }
.trace-tab-count {
  padding: 0 5px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 15px;
}
.trace-tab.active .trace-tab-count { border-color: currentColor; color: inherit; }
.trace-source-name code {
  overflow: hidden;
  color: var(--text-faint);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 10px;
}
.trace-source-folder {
  flex: 0 0 auto;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 10px;
}
.trace-source-folder:hover { color: var(--accent); border-color: var(--accent); }
.trace-source-files { display: flex; flex-direction: column; gap: 2px; }
.trace-source-file {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: var(--sans);
}
.trace-source-file:hover { background: var(--btn-hover); border-color: var(--border); }
.trace-source-file-name {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  /* Rollout names are long and the whole name is what tells sessions apart,
     so they wrap rather than truncate. */
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 11px;
}
.trace-source-file-detail {
  width: 100%;
  color: var(--text-faint);
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 9px;
}
.trace-source-count {
  padding: 6px 7px 0;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 9px;
}
.trace-source-loading,
.trace-source-empty,
.trace-source-note {
  padding: 5px 7px;
  color: var(--text-faint);
  font-size: 10px;
  line-height: 1.4;
}
.trace-source-note {
  padding-top: 2px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 9px;
  word-break: break-word;
}

.btn {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--btn-hover); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.hidden-slot { visibility: hidden; }
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.cta-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn.primary {
  background: var(--accent);
  color: var(--primary-fg);
  border-color: var(--accent);
  font-weight: 600;
}
.btn.primary:hover { background: var(--primary-hover); }

/* Theme picker dropdown in the toolbar */
.theme-picker { position: relative; -webkit-app-region: no-drag; }
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 0 10px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.theme-btn:hover { background: var(--btn-hover); color: var(--accent); border-color: var(--accent); }
.theme-btn .theme-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  flex: 0 0 auto;
}
.theme-btn .theme-caret { color: var(--text-faint); font-size: 10px; margin-left: 2px; }
.theme-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  max-height: 380px;
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  padding: 6px;
  z-index: 60;
  font-size: 12px;
  font-family: var(--sans);
}
.theme-menu .theme-section {
  color: var(--text-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 8px 4px;
  -webkit-user-select: none;
}
.theme-menu button.theme-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--sans);
}
.theme-menu button.theme-item:hover { background: var(--btn-hover); color: var(--accent); }
.theme-menu button.theme-item.active { color: var(--accent); }
.theme-menu .theme-item .theme-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, 0.2);
}
.theme-menu .theme-item .theme-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-menu .theme-item .theme-check { color: var(--accent); font-size: 12px; visibility: hidden; }
.theme-menu .theme-item.active .theme-check { visibility: visible; }

.file-info {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(50% - 145px);
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.search-wrap { flex: 1; }
#search {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 12px;
  outline: none;
}
#search:focus { border-color: var(--accent); }

.view-toggle { display: flex; gap: 12px; color: var(--text-dim); font-size: 12px; }
.view-toggle label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

.trace-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.trace-segmented {
  display: inline-flex;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.trace-segmented button {
  background: transparent;
  color: var(--text-faint);
  border: none;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 11px;
  cursor: pointer;
}
.trace-segmented button:hover { color: var(--text); background: var(--btn-hover); }
.trace-segmented button.active {
  color: var(--text);
  background: var(--bg-elev);
  box-shadow: 0 0 0 1px var(--border);
}

.stat {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

/* Workspace: explorer + main column */
.workspace {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: row;
}
.workspace.explorer-hidden .explorer { display: none; }
.explorer-edge-toggle {
  position: absolute;
  top: 50%;
  z-index: 7;
  width: 24px;
  height: 48px;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  background: var(--bg-elev);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  box-shadow: 2px 4px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  font-size: 18px;
}
.explorer-show {
  left: 0;
}
.explorer-hide {
  right: -24px;
}
.workspace.explorer-hidden .explorer-show { display: inline-flex; }
.explorer-hide { display: inline-flex; }
.explorer-edge-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.explorer-edge-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}
.main-col {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Open files — editor-style tab strip */
.file-tabs {
  flex: 0 0 34px;
  min-width: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}
.file-tab {
  position: relative;
  min-width: 110px;
  max-width: 220px;
  height: 34px;
  padding: 0 7px 0 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  color: var(--text-faint);
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11px;
  -webkit-user-select: none;
  user-select: none;
}
.file-tab::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: transparent;
}
.file-tab:hover { color: var(--text); background: var(--btn-hover); }
.file-tab.active {
  color: var(--text);
  background: var(--bg);
}
.file-tab.active::before { background: var(--accent); }
.file-tab-icon {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.file-tab-name {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-tab-dirty {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}
.file-tab-close {
  width: 18px;
  height: 18px;
  padding: 0;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  color: var(--text-faint);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.file-tab:hover .file-tab-close,
.file-tab.active .file-tab-close { visibility: visible; }
.file-tab-close:hover { color: var(--text); background: var(--bg-elev); }
.file-tab:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }

/* Left file explorer */
.explorer {
  position: relative;
  flex: 0 0 248px;
  width: 248px;
  min-width: 160px;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  -webkit-user-select: none;
  z-index: 4;
}
.explorer-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.explorer-title {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.explorer-icon-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--sans);
  height: 22px;
  padding: 0 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.explorer-icon-btn:hover { color: var(--accent); border-color: var(--border); }
.explorer-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.explorer-action-btn {
  min-width: 0;
  height: 28px;
  padding: 0 5px;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--bg-elev);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.explorer-action-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--btn-hover);
}
.explorer-action-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
.explorer-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.explorer-section-head {
  display: flex;
  align-items: center;
  padding-right: 6px;
}
.explorer-section-label {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  /* Never shrink: a section label is a direct child of the column
     .explorer-section, where `flex: 1` would set a 0 basis and let a tall
     list squeeze the label to half its line height. */
  flex: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Inside the head the label shares a row with the icon buttons, so there it
   does fill the free space — that is where `flex: 1` belongs. */
.explorer-section-head .explorer-section-label {
  flex: 1;
  min-width: 0;
}
.explorer-list,
.explorer-tree {
  overflow: auto;
}
/* Trace rows are two lines tall, so a handful of open files could otherwise
   crowd the folder tree out of a short window. The list scrolls instead. */
#explorerOpenList { max-height: 45vh; }
.explorer-tree-section { flex: 1 1 auto; }
.explorer-tree { flex: 1 1 auto; }
.explorer-empty {
  padding: 16px 14px;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.45;
}
.ex-row {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding-right: 8px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12px;
  min-width: 0;
}
.ex-row:hover { background: var(--row-hover); color: var(--text); }
.ex-row.active { background: var(--selected); color: var(--accent); }
.ex-row.opened:not(.active) .ex-name { color: var(--text); }
.ex-caret {
  width: 14px;
  flex: 0 0 auto;
  text-align: center;
  color: var(--text-faint);
  font-size: 10px;
}
.ex-caret-ph { width: 14px; flex: 0 0 auto; }
.ex-label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ex-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--sans);
}
.ex-file .ex-name { font-family: var(--mono); font-size: 11.5px; }
/* A trace row carries a second line, so it drops the fixed single-line
   height and top-aligns its caret, dirty dot and close button. */
.ex-row.ex-has-trace {
  height: auto;
  min-height: 34px;
  align-items: flex-start;
  padding-top: 4px;
  padding-bottom: 4px;
}
.ex-row.ex-has-trace .ex-caret-ph,
.ex-row.ex-has-trace .ex-caret { margin-top: 1px; }
.ex-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
/* The harness reads as a badge of the same weight as MAIN/SUBAGENT, with a
   colour per agent so a folder of traces can be scanned at a glance. */
.ex-harness {
  flex: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
  border: 1px solid var(--text-faint);
  color: var(--text-dim);
  background: var(--bg-elev);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  line-height: 15px;
}
.ex-dirty {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}
.ex-close {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0;
}
.ex-row:hover .ex-close,
.ex-row.active .ex-close { display: inline-flex; }
.ex-close:hover { color: var(--red); background: var(--btn-hover); }
.explorer-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
}
body.explorer-resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }

.empty-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 6px;
}

/* Content */
.content {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: row;
}

.view-pane {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
  min-width: 0;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-faint);
  gap: 8px;
  z-index: 1;
}
.empty-icon {
  font-family: var(--mono);
  font-size: 64px;
  color: var(--bg-elev);
  margin-bottom: 8px;
}
.empty-state h2 { margin: 0; color: var(--text-dim); font-weight: 500; }
.empty-state code {
  background: var(--bg-elev);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  color: var(--accent);
}
.empty-state .hint { font-size: 11px; color: var(--text-faint); }

.drop-overlay {
  position: absolute;
  inset: 0;
  background: var(--drop-overlay-bg);
  border: 3px dashed var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--accent);
  font-weight: 600;
  pointer-events: none;
  z-index: 10;
}

/* Table view */
table.jsonl {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
table.jsonl thead th {
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  font-weight: 600;
  z-index: 2;
}
table.jsonl td {
  border-bottom: 1px solid var(--bg-soft);
  padding: 6px 10px;
  vertical-align: top;
  font-size: 12px;
  word-break: break-word;
  white-space: pre-wrap;
}
table.jsonl tr:hover td { background: var(--row-hover); }
table.jsonl tr.error td .err-badge {
  color: var(--red);
  font-family: var(--mono);
  font-size: 11px;
}

.col-line { width: 60px; color: var(--text-faint); font-family: var(--mono); text-align: right; }
.col-actions { width: 44px; text-align: center; }

.row-expand-btn {
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-faint);
  padding: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.row-expand-btn .chevron {
  display: block;
  transition: transform 0.15s ease;
}
.row-expand-btn.expanded .chevron { transform: rotate(90deg); }
.row-expand-btn:hover { color: var(--accent); background: var(--btn-hover); }

.preview {
  font-family: var(--mono);
  color: var(--text-dim);
  font-size: 11.5px;
  max-height: 200px;
  overflow: auto;
  -webkit-user-select: text;
}
.preview .k, .sidebar-json .k, .detail-panel .k { color: var(--accent); }
.preview .s, .sidebar-json .s, .detail-panel .s { color: var(--green); }
.preview .n, .sidebar-json .n, .detail-panel .n { color: var(--orange); }
.preview .b, .sidebar-json .b, .detail-panel .b { color: var(--accent-2); }
.preview .null, .sidebar-json .null, .detail-panel .null { color: var(--text-faint); }
.preview .punc, .sidebar-json .punc, .detail-panel .punc { color: var(--text-faint); }

.detail-panel {
  background: var(--bg-soft);
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  -webkit-user-select: text;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}
.detail-panel .label {
  color: var(--text-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

/* Raw view */
.raw-view {
  font-family: var(--mono);
  font-size: 12px;
  -webkit-user-select: text;
}
.raw-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  border-bottom: 1px solid var(--bg-soft);
}
.raw-row:hover { background: var(--row-hover); }
.raw-row .ln {
  color: var(--text-faint);
  text-align: right;
  padding: 6px 10px;
  -webkit-user-select: none;
}
.raw-row .txt {
  padding: 6px 10px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
}
.raw-row.error .txt { color: var(--red); }

/* Tree view */
.tree-view {
  font-family: var(--mono);
  font-size: 12px;
  -webkit-user-select: text;
  padding: 4px 0;
}
.tree-node {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 1px 10px;
  white-space: nowrap;
}
.tree-node:hover { background: var(--row-hover); }
.tree-line {
  padding-top: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--bg-soft);
  align-items: center;
}
.tree-line.error { color: var(--red); }
.tree-line .ln {
  color: var(--text-faint);
  width: 50px;
  text-align: right;
  flex: 0 0 auto;
  -webkit-user-select: none;
}
.tree-line .preview {
  margin-left: 8px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-preview {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-caret {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 10px;
  width: 14px;
  flex: 0 0 auto;
  padding: 0;
  text-align: center;
  -webkit-user-select: none;
}
.tree-caret:hover { color: var(--accent); }
.tree-caret-placeholder { width: 14px; flex: 0 0 auto; }

.tree-children {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
}
.tree-line-children {
  padding-left: 64px;
  padding-top: 2px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--bg-soft);
}
.tree-line-children-wrap {
  padding-left: 44px;
  padding-top: 2px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--bg-soft);
  display: flex;
  flex-direction: column;
}
.tree-brace {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 12px;
  -webkit-user-select: none;
}
.tree-key { color: var(--accent); }
.tree-key.idx { color: var(--text-faint); }
.tree-summary { color: var(--text-faint); }
.tree-count { color: var(--text-dim); margin: 0 1px; }
.tree-leaf { color: var(--text-dim); }
.tree-leaf-row { align-items: baseline; }

/* Agent trace view */
.trace-view {
  min-height: 100%;
  padding: 14px 18px 42px;
}
.trace-view.trace-compact .trace-header-card,
.trace-view.trace-compact .trace-timeline {
  max-width: 980px;
  margin-left: auto;
  margin-right: auto;
}
.trace-view.trace-wide .trace-header-card,
.trace-view.trace-wide .trace-timeline { width: 100%; }
.trace-header-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 11px 14px;
  -webkit-user-select: none;
}
.trace-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  min-width: 0;
}
.trace-header-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.trace-agent-glyph { color: var(--accent); font-size: 16px; }
.trace-format-badge,
.trace-type-badge,
.trace-model {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg-elev);
  color: var(--text-dim);
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 10px;
}
/* Fallback for a trace whose format has no colour of its own. */
.trace-format-badge { color: var(--accent); }
/* One colour per harness, shared by the trace header badge, the trace
   picker headings and the explorer rows, so the same agent looks the same
   everywhere it is named. Declared after every badge base rule it overrides,
   which is what lets a single class win. */
.harness-codex,
.trace-source-name strong.harness-codex { color: var(--accent); border-color: var(--accent); }
.harness-claude,
.trace-source-name strong.harness-claude { color: var(--orange); border-color: var(--orange); }
.harness-pi,
.trace-source-name strong.harness-pi { color: var(--yellow); border-color: var(--yellow); }
.harness-hermes,
.trace-source-name strong.harness-hermes { color: var(--red); border-color: var(--red); }
.harness-sts,
.trace-source-name strong.harness-sts { color: var(--text-dim); border-color: var(--text-dim); }
.trace-type-badge { letter-spacing: 0.06em; flex: none; }
.trace-type-main { color: var(--green); border-color: var(--green); }
.trace-type-subagent { color: var(--orange); border-color: var(--orange); }
.ex-trace-type {
  flex: none;
  padding: 0 4px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  line-height: 15px;
}
/* Parent / subagent navigation under the trace header. */
.trace-relations {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.trace-relation-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}
.trace-relation-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}
.trace-relation-count {
  padding: 0 4px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
}
.trace-relation {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  overflow: hidden;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg-elev);
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trace-relation:hover { border-color: var(--accent); color: var(--accent); }
/* The offer shown when a trace with subagents is opened. Tinted so it reads
   as a question rather than another row of metadata, but it stays inline —
   it must never block reading the trace. */
.trace-subagent-ask {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  background: var(--bg-elev);
}
.trace-ask-text {
  margin-right: 4px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
}
.trace-ask-yes { border-color: var(--accent); color: var(--accent); }
.trace-ask-quiet { color: var(--text-faint); }
/* Reads as an action next to the subagents it opens, not as another one of
   them, so it is dashed rather than boxed like the trace links. */
.trace-relation-all {
  border-style: dashed;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}
.trace-relation-prefix { color: var(--green); letter-spacing: 0.06em; }
.trace-relation-missing {
  padding: 2px 7px;
  border: 1px dashed var(--border);
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 10px;
}
/* Reasoning effort on an assistant turn. Colour tracks the level so a
   session that shifts gears is visible while scrolling. */
.trace-effort {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 1px 6px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.effort-minimal, .effort-low { color: var(--text-faint); border-color: var(--text-faint); }
.effort-medium { color: var(--accent); border-color: var(--accent); }
.effort-high, .effort-xhigh, .effort-max { color: var(--orange); border-color: var(--orange); }
.trace-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 7px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 10px;
  overflow: hidden;
}
.trace-header-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trace-timeline {
  position: relative;
  margin-top: 14px;
  padding-left: 18px;
}
.trace-timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 20px;
  border-left: 1px solid var(--border);
  opacity: 0.7;
}
.trace-entry {
  position: relative;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0;
  background: var(--bg);
  overflow: hidden;
}
.trace-entry::before {
  content: '';
  position: absolute;
  left: -18px;
  top: 20px;
  width: 13px;
  border-top: 1px solid var(--border);
  opacity: 0.7;
}
.trace-entry-user { border-left-color: var(--accent); background: rgba(var(--accent-rgb), 0.045); }
.trace-entry-assistant { border-left-color: var(--accent-2); }
.trace-entry-tool { border-left-color: var(--orange); }
.trace-entry-event { border-left-color: var(--text-faint); opacity: 0.9; }
.trace-entry:hover { border-right-color: var(--accent); }
.trace-entry.selected { box-shadow: 0 0 0 1px var(--accent); }
.trace-entry.trace-nav-flash { animation: trace-nav-flash 1s ease-out; }
@keyframes trace-nav-flash {
  0% { box-shadow: 0 0 0 2px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.trace-source-live {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 1px 5px;
  border: 1px solid var(--green);
  color: var(--green);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
}

/* Live streaming — badge on the trace header, follow pill over the pane */
.trace-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border: 1px solid var(--green);
  border-radius: 0;
  background: var(--bg-elev);
  color: var(--green);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.trace-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: trace-live-pulse 1.6s ease-in-out infinite;
}
@keyframes trace-live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}
@media (prefers-reduced-motion: reduce) {
  .trace-live-dot { animation: none; }
}
.trace-follow-pill {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 7;
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}
.trace-follow-pill:hover { background: var(--accent); color: var(--primary-fg); }
/* Newest first puts the arriving entries at the top, so the pill goes there */
.trace-follow-pill.at-top { bottom: auto; top: 14px; }
.content:has(> .sidebar:not([hidden])) .trace-follow-pill { left: calc(50% - 190px); }

/* Trace message navigation — jump between user/assistant turns */
.trace-nav {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  padding: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
  -webkit-user-select: none;
  user-select: none;
}
/* Keep the widget over the message list, left of the row sidebar when open */
.content:has(> .sidebar:not([hidden])) .trace-nav {
  right: calc(380px + 14px);
}
.trace-nav-btn {
  width: 46px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.trace-nav-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}
.trace-nav-btn:active:not(:disabled) { transform: translateY(1px); }
.trace-nav-btn:disabled { opacity: 0.35; cursor: default; }
.trace-nav-pos {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  padding: 2px 0;
  white-space: nowrap;
}
.trace-entry-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-height: 38px;
  padding: 8px 12px 7px;
  border-bottom: 1px solid var(--bg-soft);
  -webkit-user-select: none;
}
.trace-entry-identity {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  color: var(--text);
  font-size: 12px;
}
.trace-entry-identity strong { color: var(--text); }
.trace-entry-model {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg-elev);
  color: var(--text-dim);
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 10px;
}
.trace-entry-time {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 10px;
  white-space: nowrap;
}
.trace-role-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  color: var(--accent);
  font-size: 11px;
}
.trace-entry-assistant .trace-role-glyph { color: var(--accent-2); }
.trace-entry-tool .trace-role-glyph { color: var(--orange); }
.trace-entry-event .trace-role-glyph { color: var(--text-faint); }
.trace-entry-meta {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px 9px;
  margin-left: auto;
  min-width: 0;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 10px;
}
.trace-entry-meta time { white-space: nowrap; }
.trace-usage { white-space: nowrap; }
.trace-entry-body {
  padding: 10px 14px 14px;
  color: var(--text-dim);
  min-width: 0;
}
.trace-text {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  -webkit-user-select: text;
}
.trace-text p { margin: 0 0 8px; }
.trace-text p:last-child { margin-bottom: 0; }
.trace-text h1,
.trace-text h2,
.trace-text h3,
.trace-text h4 {
  color: var(--text);
  margin: 8px 0 6px;
  line-height: 1.3;
}
.trace-text h1 { font-size: 18px; }
.trace-text h2 { font-size: 16px; }
.trace-text h3 { font-size: 14px; }
.trace-text h4 { font-size: 13px; }
.trace-text ul,
.trace-text ol { margin: 5px 0 8px 20px; padding: 0; }
.trace-text li { margin: 3px 0; }
.trace-text code {
  background: var(--bg-elev);
  color: var(--accent-2);
  border-radius: 0;
  padding: 1px 4px;
  font-family: var(--mono);
  font-size: 11px;
}
.trace-text pre,
.trace-code-section pre,
.trace-tool-body > pre {
  margin: 6px 0 0;
  padding: 9px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  -webkit-user-select: text;
}
.trace-text a { color: var(--accent); }
.trace-disclosure {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  text-align: left;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--mono);
}
.trace-disclosure:hover { color: var(--accent); background: var(--btn-hover); }
.trace-disclosure-caret { color: var(--text-faint); width: 10px; }
.trace-tool-status { margin-left: auto; color: var(--green); font-size: 10px; }
.trace-tool-status.error { color: var(--red); }
.trace-thinking-block {
  margin-top: 8px;
  border: 1px solid rgba(var(--accent-rgb), 0.32);
  border-radius: 0;
  background: var(--bg-soft);
  overflow: hidden;
}
.trace-thinking-summary {
  align-items: center;
  padding: 7px 9px;
  color: var(--text);
}
.trace-thinking-badge {
  flex: 0 0 auto;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--sans);
  font-style: normal;
  font-size: 11px;
}
.trace-thinking-preview {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--sans);
  font-size: 12px;
  font-style: italic;
}
.trace-thinking-body {
  padding: 11px 14px 12px;
  border-top: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
  -webkit-user-select: text;
}
.trace-thinking-body p { margin: 0 0 8px; }
.trace-thinking-body p:last-child { margin-bottom: 0; }
.trace-tool-group {
  position: relative;
  margin: 12px 0 2px 6px;
  padding-left: 21px;
}
.trace-tool-group::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 28px;
  bottom: 12px;
  border-left: 1px solid var(--border);
}
.trace-tool-group-standalone { margin-top: 9px; }
.trace-tool-group-standalone::before { top: 28px; }
.trace-tool-group-header {
  align-items: center;
  width: auto;
  padding: 2px 0 6px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
}
.trace-tool-group-header:hover { background: transparent; color: var(--accent); }
.trace-tool-group-header strong { font-weight: 600; }
.trace-tool-list { position: relative; }
.trace-tool-row {
  position: relative;
  margin-top: 6px;
}
.trace-tool-row::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 16px;
  width: 14px;
  border-top: 1px solid var(--border);
}
.trace-tool-summary {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg-soft);
  color: var(--text);
}
.trace-tool-icon {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-size: 12px;
}
.trace-tool-name {
  flex: 0 0 auto;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
}
.trace-tool-input-preview {
  min-width: 0;
  max-width: min(60%, 560px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
}
.trace-tool-result-preview {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  margin: 5px 3px 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.45;
}
.trace-tool-result-preview > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trace-tool-result-preview.error { color: var(--red); }
.trace-result-dot { flex: 0 0 auto; color: var(--green); }
.trace-tool-result-preview.error .trace-result-dot { color: var(--red); }
.trace-tool-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  padding: 7px 0 0;
}
.trace-code-section { min-width: 0; }
.trace-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 18px;
}
.trace-code-label {
  color: var(--text-dim);
  font-size: 9px;
  letter-spacing: 0.55px;
  text-transform: uppercase;
}
.trace-copy-button {
  width: 22px;
  height: 20px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 13px;
  line-height: 18px;
}
.trace-copy-button:hover { border-color: var(--border); color: var(--accent); background: var(--btn-hover); }
.trace-code-section pre { margin: 0; max-height: 260px; }
.trace-code-section pre.error,
.trace-tool-body > pre.error { color: var(--red); }
.trace-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
}
.trace-attachment-icon { color: var(--accent); }
.trace-image {
  display: block;
  max-width: min(100%, 720px);
  max-height: 420px;
  margin-top: 7px;
  border: 1px solid var(--border);
  border-radius: 0;
  object-fit: contain;
  background: var(--bg-soft);
}
.trace-view,
.trace-view * {
  border-radius: 0;
}
.trace-controls .trace-segmented,
.trace-controls .trace-segmented button {
  border-radius: 0;
}
.trace-event-empty,
.trace-no-results {
  color: var(--text-faint);
  font-size: 12px;
}
.trace-no-results {
  padding: 24px;
  text-align: center;
}

/* Sidebar */
.sidebar {
  flex: 0 0 380px;
  width: 380px;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  min-width: 0;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  -webkit-user-select: none;
}
.sidebar-title {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-icon-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 13px;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar-icon-btn:hover { color: var(--accent); border-color: var(--border); }
.sidebar-icon-btn.active { color: var(--accent); border-color: var(--border); background: var(--bg-elev); }
.sidebar-raw-toggle { font-size: 10px; font-family: var(--mono); padding: 0 6px; width: auto; }
.sidebar-body {
  flex: 1;
  overflow: auto;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  -webkit-user-select: text;
}
.sidebar-raw {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.sidebar-label {
  color: var(--text-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  -webkit-user-select: none;
}
.sidebar-raw-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
}
.sidebar-json {
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 2;
  -moz-tab-size: 2;
  color: var(--text-dim);
  font-size: 12px;
}
.sidebar-edit {
  width: 100%;
  min-height: 60vh;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  white-space: pre;
  overflow: auto;
}
.sidebar-edit:focus { border-color: var(--accent); }
.sidebar-edit.invalid { border-color: var(--red); }
.sidebar-empty {
  color: var(--text-faint);
  font-size: 12px;
  font-family: var(--sans);
  text-align: center;
  margin-top: 24px;
}
/* Suppress the dotted focus ring inside the sidebar panel */
.sidebar,
.sidebar-body,
.sidebar *:focus {
  outline: none;
}
.sidebar:focus,
.sidebar-body:focus,
.sidebar-body:focus-within {
  outline: none;
}

.col-picker { position: relative; }
.col-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  max-height: 320px;
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  padding: 8px;
  z-index: 40;
  font-size: 12px;
}
.col-popover .col-actions {
  display: flex;
  gap: 6px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  -webkit-user-select: none;
}
.col-popover .col-actions button {
  flex: 1 1 0;
  min-width: max-content;
  height: 28px;
  line-height: 1;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 5px;
  padding: 0 10px;
  font-size: 11px;
  font-family: var(--sans);
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.col-popover .col-actions button:hover { color: var(--accent); border-color: var(--accent); }
.col-popover .col-actions button:focus { outline: none; }
.col-popover label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px;
  cursor: pointer;
  border-radius: 4px;
  -webkit-user-select: none;
}
.col-popover label:hover { background: var(--btn-hover); }
.col-popover label .col-name {
  font-family: var(--mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-popover input[type="checkbox"] { accent-color: var(--accent); }
.col-popover .recent-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px 4px;
  cursor: pointer;
  border-radius: 4px;
  -webkit-user-select: none;
}
.col-popover .recent-item:hover { background: var(--btn-hover); }
.col-popover .recent-item .recent-path {
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-family: var(--mono);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
  max-width: 60vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error { border-left-color: var(--red); }

/* Right-click context menu */
.ctx-menu {
  position: fixed;
  min-width: 150px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  padding: 4px;
  z-index: 100;
  font-family: var(--sans);
  font-size: 12px;
}
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
}
.ctx-menu button:hover:not(:disabled) { background: var(--btn-hover); color: var(--accent); }
/* Greyed rather than removed, so the menu keeps the same shape whichever tab
   is right-clicked. */
.ctx-menu button:disabled {
  color: var(--text-faint);
  cursor: default;
  opacity: 0.55;
}

/* Selected row highlight */
table.jsonl tr.selected td { background: var(--selected) !important; }
.raw-row.selected { background: var(--selected); }
.tree-line.selected { background: var(--selected); }
table.jsonl tr, .raw-row, .tree-line { cursor: pointer; }

/* Edit mode */
body.edit-mode table.jsonl td.cell-editable { cursor: text; }
body.edit-mode table.jsonl td.cell-editable:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--bg-soft) !important;
}
.cell-editable[contenteditable="true"] { outline: none; }
body.edit-mode .edit-hint { display: inline; }
.edit-hint { display: none; color: var(--text-faint); font-size: 11px; margin-left: 8px; }
#editToggle.active { background: var(--green); color: var(--primary-fg); border-color: var(--green); font-weight: 600; }
.raw-edit {
  width: 100%;
  min-height: 22px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 4px 6px;
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
  outline: none;
}
.raw-edit.invalid { border-color: var(--red); }

/* Column resize handles */
table.jsonl th { position: relative; }
.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  -webkit-user-select: none;
  z-index: 3;
}
.col-resizer::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  right: 3px;
  width: 1px;
  background: transparent;
}
.col-resizer:hover::after,
.col-resizer.dragging::after { background: var(--accent); }
body.col-resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg-elev); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

@media (max-width: 1050px) {
  .controls { gap: 8px; flex-wrap: wrap; }
  .search-wrap { flex: 1 1 100%; order: 0; }
  .view-toggle { order: 1; }
  .trace-controls { order: 2; }
  .controls > .col-picker,
  .controls > #treeExpandAll,
  .controls > #treeCollapseAll,
  .controls > #editToggle,
  .controls > #saveBtn { order: 3; }
  .stat { order: 4; margin-left: auto; }
}

@media (max-width: 700px) {
  .trace-view { padding-left: 10px; padding-right: 10px; }
  .trace-entry-header { align-items: flex-start; flex-direction: column; gap: 5px; }
  .trace-entry-meta { justify-content: flex-start; margin-left: 22px; }
  .trace-tool-body { grid-template-columns: 1fr; }
  .trace-format-badge { max-width: 180px; }
}
