@font-face {
  font-family: Inter;
  src: url("./fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("./fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Departure Mono";
  src: url("./fonts/departure-mono.woff2") format("woff2");
  font-display: swap;
}

:root {
  --bg: #fdfdfb;
  --subtle: #f5f5f0;
  --surface: #ffffff;
  --border: #dfdfd7;
  --strong: #c2c3b8;
  --ink: #1c1d1a;
  --secondary: #52554d;
  --muted: #767970;
  --accent: #2c4cde;
  --accent-soft: #ebefff;
  --purple: #6d28d9;
  --purple-soft: #f3ecff;
  --teal: #0f766e;
  --teal-soft: #e6faf6;
  --amber: #c26d0a;
  --amber-soft: #fef4e2;
  --red: #c53030;
  --red-soft: #fde8e8;
  --yellow: #f5ef61;
  --yellow-soft: rgba(245, 239, 97, 0.28);
  --shadow: #1c1d1a;
  --grid: rgba(91, 109, 129, 0.062);
  --grid-svg: rgba(91, 109, 129, 0.1);
  --header-bg: rgba(253, 253, 251, 0.92);
  --row-hover: #f7f7f2;
  --row-active: #eef2ff;
  --brush-mask: rgba(28, 29, 26, 0.12);
  --font-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-sans: Inter, system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-pixel: "Departure Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101216;
  --subtle: #161920;
  --surface: #1a1e27;
  --border: #262c38;
  --strong: #3b4456;
  --ink: #f2f4f7;
  --secondary: #a4acb9;
  --muted: #7b8494;
  --accent: #7c93ff;
  --accent-soft: rgba(124, 147, 255, 0.18);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.18);
  --teal: #2dd4bf;
  --teal-soft: rgba(45, 212, 191, 0.16);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.18);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.18);
  --yellow: #e8df56;
  --yellow-soft: rgba(245, 239, 97, 0.18);
  --shadow: #050608;
  --grid: rgba(148, 163, 184, 0.055);
  --grid-svg: rgba(148, 163, 184, 0.085);
  --header-bg: rgba(16, 18, 22, 0.92);
  --row-hover: #1f2430;
  --row-active: rgba(124, 147, 255, 0.15);
  --brush-mask: rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

a {
  color: var(--accent);
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
}

::selection {
  background: var(--yellow);
  color: #1c1d1a;
}

.muted {
  color: var(--muted);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 12px;
}

.header-left,
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}

.brand-word {
  font-family: var(--font-pixel);
  font-size: 15px;
  letter-spacing: 0.04em;
}

.brand-sep {
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--strong);
}

.pixel-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: 0.05em;
  padding: 2.5px 7px;
  border-radius: 3px;
  background: var(--ink);
  color: var(--bg);
  white-space: nowrap;
}

.read-only {
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--secondary);
  padding: 0;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.icon-button:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.icon-button-sm {
  width: 26px;
  height: 26px;
}

/* Workspace Layout */
.workspace {
  display: flex;
  min-height: calc(100vh - 52px);
}

.run-sidebar {
  flex: 0 0 244px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 10px;
}

.sidebar-heading h2 {
  font-family: var(--font-pixel);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 400;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 9px;
  background: var(--surface);
  color: var(--muted);
  margin-bottom: 10px;
}

.search-box-compact {
  margin-bottom: 0;
  padding: 4px 8px;
  width: 215px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: 0;
  font-size: 12px;
  color: var(--ink);
}

.search-box:focus-within {
  border-color: var(--accent);
}

#runs {
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.run-root-info {
  display: grid;
  gap: 5px;
  margin: 0 4px 12px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

#run-root {
  overflow-wrap: anywhere;
  max-height: 5em;
  overflow: auto;
  user-select: text;
}

#run-list-error {
  color: var(--red);
}

.run-card {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 7px;
  padding: 9px 10px;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.run-card:hover {
  background: var(--subtle);
  border-color: var(--strong);
}

.run-card.selected {
  background: var(--surface);
  border-color: var(--ink);
  box-shadow: 2.5px 2.5px 0 var(--shadow);
}

.run-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.run-card-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.run-card-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.status-dot.active {
  background: var(--accent);
}

.status-dot.good {
  background: var(--teal);
}

.status-dot.bad {
  background: var(--red);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-footer .muted {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
}

/* Main Drafting Paper Canvas */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 20px 24px 36px;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

.run-container {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.welcome {
  max-width: 520px;
  margin: 16vh auto;
  padding: 0 20px;
}

.eyebrow {
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.welcome h1 {
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -1.5px;
  margin: 14px 0;
}

.welcome p {
  color: var(--secondary);
  font-size: 14px;
  margin-bottom: 12px;
}

/* Run Heading & Compact Status Strip */
.run-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.run-heading-meta {
  min-width: 0;
}

.run-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.run-title-row h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.harness-pill {
  font-family: var(--font-pixel);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  text-transform: uppercase;
}

.run-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.run-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.live-state {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
}

.live-state.connected {
  color: var(--teal);
}

.live-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.status-cell {
  padding: 9px 14px;
  min-width: 0;
}

.status-cell + .status-cell {
  border-left: 1px solid var(--border);
}

.status-label {
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.status-value {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.status-value.good {
  color: var(--teal);
}

.status-value.warning {
  color: var(--amber);
}

.status-value.bad {
  color: var(--red);
}

.gaps:empty {
  display: none;
}

.gaps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gap {
  padding: 7px 12px;
  border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent);
  background: var(--amber-soft);
  border-radius: 6px;
  color: var(--amber);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

/* Tabs */
.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: flex;
  gap: 22px;
  overflow-x: auto;
}

.tabs button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 2px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tabs button:hover {
  color: var(--ink);
}

.tabs button[aria-selected="true"] {
  color: var(--ink);
  border-color: var(--accent);
}

.tabs button span {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--subtle);
  color: var(--muted);
}

.cursor-readout {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* Blueprint Frames & Segmented Controls */
.blueprint-frame {
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: 9px;
  box-shadow: 3.5px 3.5px 0 var(--shadow);
  overflow: hidden;
}

.segmented {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  gap: 2px;
}

.seg-button {
  padding: 3.5px 9px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--secondary);
  background: transparent;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.seg-button:hover {
  color: var(--ink);
}

.seg-button.active {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--strong);
  font-weight: 600;
}

.button {
  background: var(--surface);
  border: 1px solid var(--strong);
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.button:hover:not(:disabled) {
  border-color: var(--ink);
  background: var(--subtle);
}

.button-primary {
  background: var(--yellow);
  color: #1c1d1a;
  border: 1.5px solid var(--ink);
  font-weight: 600;
  box-shadow: 2px 2px 0 var(--shadow);
}

.button-primary:hover:not(:disabled) {
  background: var(--yellow);
  transform: translate(-0.5px, -0.5px);
}

/* Timeline Toolbar & Overview Minimap Navigator */
.timeline-toolbar {
  padding: 8px 14px;
  background: var(--subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.zoom-readout {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--secondary);
  min-width: 42px;
  text-align: center;
  user-select: none;
}

.spawn-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--secondary);
  cursor: pointer;
  user-select: none;
  padding: 0 4px;
}

.minimap-section {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.minimap-bar {
  padding: 4px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.minimap-hint {
  font-family: var(--font-pixel);
  font-size: 9.5px;
  color: var(--muted);
}

.minimap-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--secondary);
}

.overlap-badge {
  font-family: var(--font-pixel);
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--teal-soft);
  color: var(--teal);
}

.minimap-wrap {
  height: 46px;
  user-select: none;
  touch-action: none;
  position: relative;
}

/* Swimlane SVG Host */
.swimlane-scroll {
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1.5px solid var(--strong);
  touch-action: pan-y;
}

.timeline-svg-host svg {
  display: block;
}

.sl-block {
  cursor: pointer;
}

.sl-block:hover .sl-rect {
  filter: brightness(0.9);
  stroke: var(--ink);
  stroke-width: 1.5;
}

:root[data-theme="dark"] .sl-block:hover .sl-rect {
  filter: brightness(1.2);
}

.sl-block.active .sl-rect,
.sl-block.hovered .sl-rect {
  stroke: var(--ink);
  stroke-width: 2;
}

/* Trajectory Stream & Event Ledger */
.trajectory-bar {
  padding: 8px 14px;
  background: var(--subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.track-filter-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.traj-summary {
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.traj-more-wrap {
  padding: 10px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--subtle);
}

.timeline-note {
  font-size: 10.5px;
  color: var(--muted);
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.event-row {
  width: 100%;
  display: grid;
  grid-template-columns: 74px 132px 74px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  padding: 7.5px 14px;
  text-align: left;
  transition: background 0.08s ease;
}

.event-row:last-child {
  border-bottom: 0;
}

.event-row:hover,
.event-row.hovered {
  background: var(--row-hover);
}

.event-row.selected {
  background: var(--row-active);
}

.event-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.event-agent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--secondary);
  min-width: 0;
}

.event-agent-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.event-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-label strong {
  font-weight: 600;
  color: var(--ink);
}

.event-detail {
  color: var(--muted);
}

.event-dur {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-pixel);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--subtle);
  color: var(--secondary);
}

.pill-badge.input {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-badge.model {
  background: var(--purple-soft);
  color: var(--purple);
}

.pill-badge.tool {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill-badge.service {
  background: var(--teal-soft);
  color: var(--teal);
}

.pill-badge.error {
  background: var(--red-soft);
  color: var(--red);
}

/* Events Panel Filters & Pagination */
.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--subtle);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.filter-label select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11.5px;
  color: var(--ink);
  max-width: 170px;
}

.page-info {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--subtle);
  border-top: 1px solid var(--border);
}

/* Collaboration & Files Panels */
.relations-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.relation-card {
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: 9px;
  box-shadow: 3px 3px 0 var(--shadow);
  padding: 14px 16px;
}

.relation-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.relation-route {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  flex-wrap: wrap;
}

.relation-arrow {
  color: var(--purple);
  font-weight: 700;
}

.evidence-links {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.outcome-frame {
  margin-bottom: 14px;
}

.panel-heading {
  padding: 11px 16px;
  background: var(--subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-heading h2 {
  font-size: 13px;
  font-weight: 700;
}

.outcome-body {
  padding: 14px 16px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--secondary);
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  padding: 10px 16px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row:hover {
  background: var(--row-hover);
  color: var(--accent);
}

.empty-state {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* Floating Tooltip */
.hover-tip {
  position: fixed;
  z-index: 70;
  pointer-events: none;
  width: 320px;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: 7px;
  box-shadow: 3px 3px 0 var(--shadow);
  padding: 9px 11px;
  opacity: 0;
  transition: opacity 0.08s ease;
}

.hover-tip.visible {
  opacity: 1;
}

.tip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.tip-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 3px;
  overflow-wrap: anywhere;
}

.tip-detail {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--secondary);
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.tip-foot {
  border-top: 1px solid var(--border);
  padding-top: 5px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}

.tip-action {
  border-top: 1px solid var(--border);
  padding-top: 5px;
  font-family: var(--font-pixel);
  font-size: 9.5px;
  color: var(--accent);
}

/* Slide-Over Evidence Inspector */
.inspector {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  z-index: 45;
  background: var(--surface);
  border-left: 1.5px solid var(--ink);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
}

.inspector-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--subtle);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.inspector-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.inspector-body {
  flex: 1;
  overflow: auto;
}

.inspector-title {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.inspector-title h3 {
  font-size: 16px;
  line-height: 1.35;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.inspector-title .muted {
  font-family: var(--font-mono);
  font-size: 10.5px;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.inspector-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.inspector-section h4 {
  font-family: var(--font-pixel);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

.inspector-data {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 7px 10px;
  font-size: 11.5px;
  margin: 0;
}

.inspector-data dt {
  color: var(--muted);
}

.inspector-data dd {
  margin: 0;
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.inspector-section pre {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--subtle);
  border: 1px solid var(--border);
  color: var(--ink);
  tab-size: 2;
}

.raw-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.raw-toolbar h4 {
  margin: 0;
}

.msg-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-card {
  border-radius: 6px;
  padding: 9px 11px;
  background: var(--subtle);
  border: 1px solid var(--border);
}

.msg-card.highlight {
  background: var(--yellow-soft);
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 var(--shadow);
}

.msg-role {
  font-family: var(--font-pixel);
  font-size: 9.5px;
  color: var(--accent);
  margin-bottom: 4px;
}

.msg-card.highlight .msg-role {
  color: var(--ink);
}

.msg-text {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-banner {
  background: var(--red-soft);
  border: 1px solid var(--red);
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--red);
  margin: 12px 0;
  font-size: 12px;
}

.inspect-loading {
  padding: 20px 18px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .workspace {
    flex-direction: column;
  }
  .run-sidebar {
    position: static;
    height: auto;
    flex: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  #runs {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .run-card {
    min-width: 190px;
    max-width: 230px;
    border-color: var(--border);
  }
  .sidebar-footer {
    display: none;
  }
  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .status-cell + .status-cell {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  .event-row {
    grid-template-columns: 60px 88px 66px minmax(0, 1fr);
  }
  .event-dur {
    display: none;
  }
  .cursor-readout {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
.run-search-results {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.run-search-results .event-list {
  max-height: 320px;
  overflow-y: auto;
}

.run-search-results > p {
  margin: 0 0 10px;
}
#service-states .relation-evidence {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-block: 8px;
}
.service-state-table {
  width: 100%;
  border-collapse: collapse;
  margin-block: 12px;
  font-size: 12px;
}
.service-state-table th,
.service-state-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  overflow-wrap: anywhere;
}
.service-state-table th {
  white-space: nowrap;
}


/* Focused zero-scroll embed mode: keeps ONLY core interactive swimlane + active view */
html.embed-mode,
html.embed-mode body {
  height: auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
  background: var(--surface, var(--bg)) !important;
}
html.embed-mode .app-header,
html.embed-mode .run-sidebar,
html.embed-mode .run-heading,
html.embed-mode .status-strip,
html.embed-mode .gaps,
html.embed-mode .view-toolbar,
html.embed-mode .trajectory-bar,
html.embed-mode #timeline-events,
html.embed-mode #traj-more-wrap,
html.embed-mode #timeline-note {
  display: none !important;
}
html.embed-mode .workspace {
  display: block !important;
  height: auto !important;
  min-height: 0 !important;
}
html.embed-mode .main-content {
  padding: 0 !important;
  height: auto !important;
  overflow: visible !important;
}
html.embed-mode .run-container {
  gap: 0 !important;
}
html.embed-mode .view-panel.blueprint-frame {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
html.embed-mode .timeline-toolbar {
  padding: 8px 12px !important;
}
html.embed-mode .minimap-section {
  padding: 6px 12px 8px !important;
}
html.embed-mode #events {
  max-height: min(55vh, 480px);
  overflow-y: auto;
}
html.embed-mode .relations-grid {
  padding: 12px !important;
}
html.embed-mode #artifacts-panel {
  padding: 12px !important;
  gap: 12px !important;
}
html.embed-mode .inspector {
  top: 0 !important;
  height: 100% !important;
  max-height: 100% !important;
}

#replay-bookmarks:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
}

.gallery-link {
  color: var(--secondary);
  font-weight: 650;
  text-decoration: none;
}

.gallery-link:hover,
.run-diagnostics summary:hover,
.technical-details summary:hover {
  color: var(--accent);
}

.welcome {
  max-width: 980px;
  margin: clamp(36px, 9vh, 100px) auto;
}

.welcome h1 {
  font-size: clamp(34px, 6vw, 62px);
  margin: 0 0 12px;
  letter-spacing: -0.045em;
}

.welcome > p {
  max-width: 52ch;
  font-size: 16px;
}

.featured-replays {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 36px;
}

.featured-replay {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  padding: clamp(18px, 3vw, 30px);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 12px;
}

.featured-replay:nth-child(2) {
  border-top-color: var(--teal);
}

.featured-replay:hover,
.featured-replay:focus-visible {
  background: var(--row-hover);
  border-color: var(--accent);
}

.replay-category,
.run-card-top {
  color: var(--accent);
  font: 600 11px/1.35 var(--font-sans);
}

.featured-title {
  font: 700 clamp(20px, 3vw, 29px)/1.12 var(--font-display);
  letter-spacing: -0.03em;
}

.featured-description {
  flex: 1;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.65;
}

.replay-facts {
  padding-top: 8px;
  color: var(--secondary);
  font-weight: 600;
}

.replay-action {
  color: var(--accent);
  font-weight: 700;
}

.run-card {
  padding: 12px;
  border-radius: 8px;
}

.run-card.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: none;
}

.run-card-title {
  display: block;
  font-size: 14px;
}

.run-card-meta {
  font-family: var(--font-sans);
  font-size: 11px;
}

.run-title-row h1 {
  font-size: clamp(25px, 3.25vw, 38px);
  letter-spacing: -0.04em;
}

.run-subtitle {
  max-width: 80ch;
  color: var(--secondary);
  font: 14px/1.55 var(--font-sans);
  margin-top: 8px;
}

.run-heading {
  position: relative;
  align-items: flex-start;
}

.status-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.status-label {
  color: var(--secondary);
  font: 550 11px/1.3 var(--font-sans);
  letter-spacing: normal;
  text-transform: none;
}

.status-value {
  font-size: clamp(15px, 2vw, 20px);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.status-cell {
  padding: 10px 14px;
}

.run-diagnostics,
.technical-details {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--secondary);
  background: var(--surface);
}

.run-diagnostics summary,
.technical-details summary {
  cursor: pointer;
  font-weight: 650;
}

.technical-details[open] > summary,
.run-diagnostics[open] > summary {
  margin-bottom: 12px;
}

.result-description {
  color: var(--secondary);
  padding: 12px 16px;
}

.review-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.65;
}

html.embed-mode .run-diagnostics {
  display: none;
}

@media (max-width: 660px) {
  .featured-replays {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    margin-top: 22px;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .run-actions,
  .header-actions > .read-only {
    display: none;
  }

  .run-title-row {
    align-items: flex-start;
  }
}

.replay-evidence-card {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 18px;
}

.replay-evidence-card p {
  color: var(--secondary);
  max-width: 60ch;
}

.handoff-report {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.handoff-report h4,
.handoff-report h5 {
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.25;
  margin: 20px 0 8px;
}

.handoff-report h5 {
  font-size: 14px;
}

.handoff-report p,
.handoff-report ul {
  margin: 0 0 10px;
}

.handoff-report ul {
  padding-left: 20px;
}

.handoff-report code {
  background: var(--subtle);
  border-radius: 3px;
  padding: 1px 3px;
}

.report-table {
  max-width: 100%;
  overflow-x: auto;
  margin: 8px 0 14px;
}

.report-table table {
  width: 100%;
  border-collapse: collapse;
}

.report-table :is(th, td) {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

@media (max-width: 660px) {
  .tabs {
    flex-wrap: wrap;
    gap: 0;
    overflow: visible;
  }

  .tabs button {
    gap: 4px;
    padding: 8px 6px;
    font-size: 12px;
  }

  .tabs button > :is(#event-total-count, #relation-count) {
    display: none;
  }
}

/* Universal Services Sankey & Agent Config Grid */
.sankey-card,
.agent-config-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sankey-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.sankey-head h2 {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
}

.sankey-head p {
  margin: 0;
  font-size: 0.82rem;
}

.sankey-readout {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.4;
  min-height: 28px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--subtle);
  border: 1px solid var(--border);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

.sankey-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  padding: 12px 8px;
}

.sankey-svg {
  display: block;
  min-width: 680px;
  height: auto;
}

.agent-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.agent-config-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.agent-config-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.agent-config-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.cap-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cap-label {
  font-family: var(--font-pixel);
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.cap-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.cap-preview {
  margin: 0;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  word-break: break-word;
}
