:root {
  --bg: #1a1b1e;
  --bg-card: #25262b;
  --bg-hover: #2c2e33;
  --bg-input: #1a1b1e;
  --border: #373a40;
  --text: #c1c2c5;
  --text-dim: #909296;
  --text-bright: #e9ecef;
  --accent: #7950f2;
  --accent-dim: #5f3dc4;

  --plan: #4dabf7;
  --code: #51cf66;
  --review: #ff922b;
  --memory: #cc5de8;
  --research: #20c997;
  --document: #868e96;
  --consistency: #f06595;

  --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --radius: 6px;
  --transition: 150ms ease;
}

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

html { font-size: 13px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100vh;
}

/* -- Header -- */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.header h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
  font-family: var(--mono);
  letter-spacing: -0.3px;
}
.header h1 span { color: var(--accent); }

/* -- Tabs -- */
.tabs {
  display: flex;
  gap: 2px;
  margin-left: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text); }
.tab-btn.active { background: var(--accent-dim); color: #fff; }

/* -- Main -- */
.main { padding: 16px 20px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* -- Controls bar -- */
.controls {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.ctrl-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.ctrl-btn:hover { background: var(--bg-hover); color: var(--text); }
.controls .status {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.controls .status .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--code);
  margin-right: 4px;
  vertical-align: middle;
}

/* -- Session cards -- */
.session-list { display: flex; flex-direction: column; gap: 6px; }

.session-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}
.session-card:hover { border-color: var(--accent-dim); }

.session-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  gap: 12px;
  user-select: none;
}
.session-head:hover { background: var(--bg-hover); }

.session-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-bright);
  font-weight: 600;
}
.session-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.session-stats {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.stat {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}
.stat b {
  color: var(--text);
  font-weight: 600;
}

.session-flow {
  display: flex;
  gap: 3px;
  align-items: center;
  margin-top: 4px;
}
.flow-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.flow-arrow {
  color: var(--text-dim);
  font-size: 9px;
}

.session-body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 0;
  background: var(--bg);
  position: relative;
}
.session-card.expanded .session-body { display: block; }

.session-body-inner {
  padding: 12px 14px;
}

.tree-loading {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
  padding: 12px 14px;
}

/* -- View toggle -- */
.view-toggle {
  display: flex;
  gap: 2px;
  margin-bottom: 10px;
}
.view-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.view-btn:hover { background: var(--bg-hover); color: var(--text); }
.view-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* -- Graph container -- */
.graph-container {
  width: 100%;
  min-height: 350px;
  height: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
}

/* -- Detail panel (slide-in) -- */
.detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 100%;
  height: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 10;
  overflow-y: auto;
  padding: 14px;
  display: none;
  box-shadow: -4px 0 12px rgba(0,0,0,0.3);
}
.detail-panel.open { display: block; }
.detail-panel-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.detail-panel-close:hover { color: var(--text-bright); }
.detail-panel h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 10px;
  padding-right: 24px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 3px 0;
  border-bottom: 1px solid var(--bg);
}
.detail-row .dl { color: var(--text-dim); }
.detail-row .dv { color: var(--text-bright); font-family: var(--mono); }

/* -- Tool breakdown bar -- */
.tool-bar-container {
  margin: 10px 0;
}
.tool-stacked-bar {
  display: flex;
  height: 20px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg);
}
.tool-stacked-segment {
  height: 100%;
  min-width: 2px;
  transition: width 300ms ease;
}
.tool-table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
}
.tool-table th {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
}
.tool-table td {
  font-size: 11px;
  font-family: var(--mono);
  padding: 3px 6px;
  border-bottom: 1px solid var(--bg);
}
.tool-table .tool-color-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

/* -- Waterfall/Gantt -- */
.waterfall-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
}
.waterfall-row {
  display: flex;
  align-items: center;
  height: 28px;
  margin-bottom: 2px;
}
.waterfall-label {
  min-width: 120px;
  max-width: 160px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
  flex-shrink: 0;
}
.waterfall-label.indent-1 { padding-left: 16px; }
.waterfall-label.indent-2 { padding-left: 32px; }
.waterfall-label.indent-3 { padding-left: 48px; }
.waterfall-track {
  flex: 1;
  height: 20px;
  background: var(--bg);
  border-radius: 3px;
  position: relative;
  min-width: 200px;
}
.waterfall-bar {
  position: absolute;
  height: 100%;
  border-radius: 3px;
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-size: 9px;
  font-family: var(--mono);
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 4px;
}

/* -- Trace timeline (D3) -- */
.trace-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
  min-height: 200px;
}
.trace-container.compact {
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
}
.trace-container svg {
  display: block;
}
.trace-container .span-bar {
  rx: 3;
  ry: 3;
  cursor: pointer;
  transition: opacity 0.15s;
}
.trace-container .span-bar:hover {
  opacity: 0.85;
}
.trace-container .span-bar.resume {
  stroke-dasharray: 6 3;
  stroke-width: 1.5;
  stroke: rgba(255,255,255,0.4);
}
.trace-container .span-label {
  font-family: var(--mono);
  font-size: 11px;
  fill: #fff;
  dominant-baseline: middle;
  pointer-events: none;
}
.trace-container .span-duration {
  font-family: var(--mono);
  font-size: 9px;
  fill: var(--text-dim);
  dominant-baseline: middle;
  pointer-events: none;
}
.trace-container .arrow-line {
  stroke: rgba(255,255,255,0.2);
  stroke-width: 1;
  fill: none;
}
.trace-container .axis-line {
  stroke: var(--border);
  stroke-width: 1;
}
.trace-container .axis-text {
  font-family: var(--mono);
  font-size: 9px;
  fill: var(--text-dim);
}
.trace-container .row-label {
  font-family: var(--mono);
  font-size: 11px;
  fill: var(--text);
  dominant-baseline: middle;
}
.trace-tooltip {
  position: absolute;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text);
  pointer-events: none;
  z-index: 100;
  white-space: pre-line;
  max-width: 420px;
  word-break: break-all;
}

/* -- Tree nodes (improved) -- */
.tree details {
  margin-left: 16px;
}
.tree > details { margin-left: 0; }

.tree summary {
  cursor: pointer;
  list-style: none;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--mono);
  transition: background var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before {
  content: '\25B6';
  font-size: 8px;
  color: var(--text-dim);
  transition: transform var(--transition);
  display: inline-block;
  width: 12px;
  flex-shrink: 0;
}
.tree details[open] > summary::before {
  transform: rotate(90deg);
}
.tree summary:hover { background: var(--bg-hover); }

.tree .node-icon {
  font-size: 11px;
  flex-shrink: 0;
}
.tree .node-label {
  color: var(--text-bright);
  font-weight: 500;
}
.tree .node-meta {
  color: var(--text-dim);
  font-size: 11px;
  margin-left: auto;
}
.tree .node-tools-inline {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: 6px;
}

.tree .badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* -- Badge colors -- */
.badge-plan { background: var(--plan); }
.badge-code { background: var(--code); color: #1a1b1e; }
.badge-review { background: var(--review); color: #1a1b1e; }
.badge-memory { background: var(--memory); }
.badge-research { background: var(--research); color: #1a1b1e; }
.badge-document { background: var(--document); }
.badge-consistency { background: var(--consistency); }
.badge-session { background: var(--accent); }
.badge-worker { background: #495057; }

.dot-plan { background: var(--plan); }
.dot-code { background: var(--code); }
.dot-review { background: var(--review); }
.dot-memory { background: var(--memory); }
.dot-research { background: var(--research); }
.dot-document { background: var(--document); }
.dot-consistency { background: var(--consistency); }

/* -- Stats tab -- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
}
.stat-card .value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-bright);
}
.stat-card .label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.stats-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.stats-section h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-bright);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* -- Bar chart (CSS) -- */
.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.bar-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  min-width: 90px;
  text-align: right;
}
.bar-track {
  flex: 1;
  height: 18px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 400ms ease;
  min-width: 2px;
}
.bar-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  min-width: 40px;
}

/* -- Path frequencies -- */
.path-list { list-style: none; }
.path-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-family: var(--mono);
  font-size: 11px;
  border-bottom: 1px solid var(--bg);
}
.path-flow {
  flex: 1;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.path-flow .arrow { color: var(--text-dim); }
.path-count {
  color: var(--text-dim);
  min-width: 30px;
  text-align: right;
}

/* -- Timeline -- */
.timeline-controls {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.timeline-granularity,
.timeline-period {
  display: flex;
  gap: 2px;
}
.tl-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.tl-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.tl-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.timeline-scroll {
  overflow-x: auto;
  position: relative;
}
.timeline-chart {
  display: flex;
  min-width: fit-content;
  gap: 1px;
}
.timeline-bar-wrap {
  flex: 1 0 32px;
  max-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.timeline-bar-area {
  height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  border-bottom: 1px solid var(--border);
}
.timeline-bar {
  width: 24px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  transition: height 400ms ease;
  min-height: 2px;
  cursor: pointer;
}
.timeline-bar:hover {
  opacity: 0.8;
}
.timeline-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-dim);
  padding-top: 4px;
  white-space: nowrap;
  text-align: center;
  line-height: 1.3;
}
.timeline-count {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.timeline-tooltip {
  position: fixed;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text);
  pointer-events: none;
  z-index: 1000;
  white-space: pre-line;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: none;
}
.timeline-tooltip.visible {
  display: block;
}
.timeline-nav {
  display: flex;
  gap: 4px;
}
.tl-nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.tl-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.tl-nav-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* -- Averages -- */
.avg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}
.avg-item {
  text-align: center;
  padding: 8px;
}
.avg-item .value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
}
.avg-item .label {
  font-size: 11px;
  color: var(--text-dim);
}

/* -- Tool usage stats section -- */
.tool-usage-bar {
  display: flex;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg);
  margin-bottom: 12px;
}
.tool-usage-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-family: var(--mono);
  color: #fff;
  min-width: 2px;
  overflow: hidden;
  white-space: nowrap;
  transition: width 400ms ease;
}
.tool-stats-table {
  width: 100%;
  border-collapse: collapse;
}
.tool-stats-table th {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.tool-stats-table th:last-child,
.tool-stats-table td:last-child { text-align: right; }
.tool-stats-table td {
  font-size: 11px;
  font-family: var(--mono);
  padding: 4px 8px;
  border-bottom: 1px solid var(--bg);
  color: var(--text);
}

/* -- Browse tab -- */
.browse-tree details {
  margin-left: 16px;
}
.browse-tree > details { margin-left: 0; }

.browse-tree summary {
  cursor: pointer;
  list-style: none;
  padding: 3px 6px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
}
.browse-tree summary::-webkit-details-marker { display: none; }
.browse-tree summary::before {
  content: '\25B6';
  font-size: 8px;
  color: var(--text-dim);
  transition: transform var(--transition);
  display: inline-block;
  width: 12px;
  flex-shrink: 0;
}
.browse-tree details[open] > summary::before {
  transform: rotate(90deg);
}
.browse-tree summary:hover { background: var(--bg-hover); }

.browse-tree .file-entry {
  padding: 3px 6px 3px 24px;
  font-family: var(--mono);
  font-size: 12px;
  display: flex;
  gap: 8px;
}
.browse-tree .file-name { color: var(--text); }
.browse-tree .file-meta { color: var(--text-dim); font-size: 11px; }
.browse-tree .dir-icon { color: var(--plan); }
.browse-tree .file-icon { color: var(--text-dim); }

.browse-tree .task-badge {
  display: inline-block;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  margin-left: 4px;
}

/* -- Session name + rename -- */
.session-name {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-bright);
  font-weight: 600;
  cursor: text;
  padding: 1px 2px;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: border-color var(--transition), background var(--transition);
}
.session-name:hover { border-color: var(--border); background: var(--bg-input); }
.session-name-input {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-bright);
  font-weight: 600;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 1px 4px;
  outline: none;
  width: 300px;
  max-width: 100%;
}
.token-badges {
  display: flex;
  gap: 6px;
  margin-top: 3px;
  flex-wrap: wrap;
}
.token-badge {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg);
  border-radius: 3px;
  padding: 1px 5px;
}
.token-badge b { color: var(--text); font-weight: 600; }

/* -- Agent detail expand panel (stats tab) -- */
.agent-detail-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 4px 0 8px 0;
  animation: slideDown 200ms ease;
}
@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 500px; }
}
.agent-detail-panel h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 8px;
}
.agent-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 2px 0;
}
.agent-detail-row .dl { color: var(--text-dim); }
.agent-detail-row .dv { color: var(--text-bright); font-family: var(--mono); }
.bar-row { cursor: pointer; }
.bar-row:hover .bar-label { color: var(--text-bright); }

/* -- Toggle button for stats -- */
.stats-toggle {
  display: inline-flex;
  gap: 2px;
  margin-bottom: 10px;
}
.stats-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.stats-toggle-btn:hover { background: var(--bg-hover); color: var(--text); }
.stats-toggle-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* -- Per-agent tool heatmap -- */
.agent-tool-grid {
  display: grid;
  gap: 2px;
  margin-top: 12px;
}
.agent-tool-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.agent-tool-row-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  min-width: 80px;
  text-align: right;
}
.agent-tool-row-bar {
  flex: 1;
  display: flex;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg);
}
.agent-tool-row-segment {
  height: 100%;
  min-width: 1px;
  transition: width 400ms ease;
}

/* -- Task content overlay -- */
.task-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.task-overlay-inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  position: relative;
}
.task-overlay-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.task-overlay-close:hover { color: var(--text-bright); }
.task-overlay-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
}
.task-overlay-tab {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.task-overlay-tab:hover { background: var(--bg-hover); color: var(--text); }
.task-overlay-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.task-overlay-content {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 14px;
  max-height: 60vh;
  overflow-y: auto;
}
.task-overlay-content h1, .task-overlay-content h2, .task-overlay-content h3 {
  color: var(--text-bright);
  margin-top: 16px;
  margin-bottom: 8px;
}
.task-overlay-content h1 { font-size: 18px; }
.task-overlay-content h2 { font-size: 15px; }
.task-overlay-content h3 { font-size: 13px; }
.task-overlay-content pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
}
.task-overlay-content code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-card);
  padding: 1px 4px;
  border-radius: 3px;
}
.task-overlay-content pre code {
  background: none;
  padding: 0;
}
.task-overlay-content ul, .task-overlay-content ol {
  padding-left: 20px;
}
.task-overlay-content a {
  color: var(--accent);
}
.detail-panel .view-task-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 11px;
  cursor: pointer;
  transition: background var(--transition);
}
.detail-panel .view-task-btn:hover { background: var(--accent-dim); }

/* -- Supercharge highlight -- */
.supercharge-highlight {
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  color: #fff;
  font-weight: 600;
  border-radius: 3px;
  padding: 0 4px;
}

/* -- Empty state -- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 13px;
}

/* -- Global unit selector -- */
.unit-selector {
  display: flex;
  gap: 2px;
}
.unit-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.unit-btn:hover { background: var(--bg-hover); color: var(--text); }
.unit-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* -- Decomposition bar view -- */
.decomp-container {
  position: relative;
}
.decomp-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
.decomp-breadcrumb-item {
  cursor: pointer;
  color: var(--accent);
  transition: color var(--transition);
}
.decomp-breadcrumb-item:hover { color: var(--text-bright); }
.decomp-breadcrumb-sep { color: var(--text-dim); }
.decomp-breadcrumb-current { color: var(--text-bright); font-weight: 600; }
.decomp-back-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 10px;
}
.decomp-back-btn:hover { background: var(--bg-hover); color: var(--text); }
.decomp-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.decomp-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 3px 0;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.decomp-bar-row:hover { background: var(--bg-hover); }
.decomp-bar-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.decomp-children .decomp-bar-label {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
}
.decomp-view-btn {
  cursor: pointer;
  opacity: 0.5;
  font-size: 12px;
  transition: opacity var(--transition);
}
.decomp-view-btn:hover {
  opacity: 1;
}
.decomp-children .decomp-children .decomp-bar-label {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
}
.decomp-bar-track {
  flex: 1;
  height: 28px;
  background: var(--bg);
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
}
.decomp-bar-fill {
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: width 400ms ease;
  box-sizing: border-box;
}
.decomp-bar-fill.decomp-bar-zero {
  min-width: 3px;
  max-width: 3px;
  padding: 0;
}
.decomp-bar-text-outside {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  padding-left: 8px;
  pointer-events: none;
}
.decomp-bar-value {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  min-width: 70px;
  text-align: right;
  flex-shrink: 0;
}
.decomp-total-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.decomp-total-label b { color: var(--text-bright); font-weight: 600; }

/* -- Project grouping -- */
.project-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
  cursor: pointer;
  transition: border-color var(--transition);
}
.project-header:hover { border-color: var(--accent-dim); }
.project-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
}
.project-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}
.project-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.project-badge {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg);
  border-radius: 3px;
  padding: 1px 6px;
}
.decomp-zoom-btn {
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
  transition: opacity var(--transition);
  flex-shrink: 0;
  padding: 0 4px;
}
.decomp-zoom-btn:hover { opacity: 1; }
.project-time-children {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: slideDown 200ms ease;
}

/* -- Browse sub-tabs -- */
.browse-subtabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
}
.browse-subtab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.browse-subtab-btn:hover { background: var(--bg-hover); color: var(--text); }
.browse-subtab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.browse-subpanel { display: none; }
.browse-subpanel.active { display: block; }

/* -- Memory cards -- */
.memory-category {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 0 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.memory-category:first-child { padding-top: 0; }

.memory-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.memory-card:hover { border-color: var(--accent-dim); }
.memory-card.expanded { border-color: var(--accent); }

.memory-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.memory-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
}
.memory-date {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.memory-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.memory-tag {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
}

.memory-preview {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.memory-expand {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* -- Task cards -- */
.task-group { margin-bottom: 16px; }
.task-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.task-group-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
  cursor: pointer;
  transition: border-color var(--transition);
}
.task-card:hover { border-color: var(--accent-dim); }
.task-card.expanded { border-color: var(--accent); }
.task-card-archived { opacity: 0.6; }
.task-card-archived:hover { opacity: 0.8; }

.task-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.status-completed { background: var(--code); }
.status-dot.status-pending { background: #fcc419; }

.task-card-uuid {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.task-card-title {
  font-size: 12px;
  color: var(--text-bright);
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-card-date {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.task-expand {
  border-top: 1px solid var(--border);
  padding: 12px;
  background: var(--bg);
}
.task-expand-section { margin-bottom: 12px; }
.task-expand-section:last-child { margin-bottom: 0; }
.task-expand-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

/* -- Task archive section -- */
.task-archive-section {
  margin-top: 16px;
}
.task-archive-header {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
}
.task-archive-header::-webkit-details-marker { display: none; }
.task-archive-header::before {
  content: '\25B6';
  font-size: 8px;
  color: var(--text-dim);
  transition: transform var(--transition);
  display: inline-block;
}
.task-archive-section[open] > .task-archive-header::before {
  transform: rotate(90deg);
}
.task-archive-header:hover { background: var(--bg-hover); }
.task-archive-list { padding-top: 6px; }

/* -- Scrollbar -- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
