/* Agent Trace — standalone skin. Every value maps to a token in DESIGN.md. */

:root {
  /* colors */
  --primary: #ff7100;
  --secondary: #27aae1;
  --tertiary: #3cb93c;
  --background: #090d0f;
  --surface: rgba(18, 24, 27, 0.92);
  --surface-strong: rgba(13, 18, 21, 0.98);
  --surface-raised: rgba(255, 255, 255, 0.04);
  --surface-raised-hover: rgba(255, 255, 255, 0.07);
  --on-surface: #e8e2d8;
  --on-primary: #130c02;
  --muted: #8d8994;
  --line: rgba(255, 255, 255, 0.08);
  --warn: #f5ae6c;
  --error: #cc1225;
  --error-text: #ff6677;
  --ok: #3cb93c;
  --span-model: var(--primary);
  --span-tool: var(--secondary);
  --span-capability: var(--tertiary);
  --span-subagent: var(--warn);
  /* type */
  --font-sans: "Instrument Sans", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
  /* rounded */
  --rounded-sm: 8px;
  --rounded-md: 14px;
  --rounded-lg: 20px;
  --rounded-xl: 28px;
  --rounded-shell: 32px;
  --rounded-full: 9999px;
  /* spacing */
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 14px;
  --space-lg: 18px;
  --space-xl: 22px;
  --space-margin: 28px;
  /* depth */
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --glow-primary: rgba(255, 113, 0, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--on-surface);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 113, 0, 0.2), transparent 20%),
    radial-gradient(circle at 88% 12%, rgba(39, 170, 225, 0.14), transparent 22%),
    radial-gradient(circle at 78% 72%, rgba(245, 174, 108, 0.08), transparent 20%),
    linear-gradient(180deg, #11161a 0%, var(--background) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 92%);
}

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

button {
  cursor: pointer;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- shell + masthead ---------- */

.shell {
  position: relative;
  width: min(1440px, calc(100vw - 32px));
  margin: var(--space-margin) auto;
  padding: var(--space-lg);
  border: 1px solid var(--line);
  border-radius: var(--rounded-shell);
  background: linear-gradient(180deg, rgba(17, 22, 26, 0.78), rgba(9, 13, 15, 0.68));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.masthead {
  position: relative;
  overflow: hidden;
  padding: var(--space-margin);
  border-radius: var(--rounded-xl);
  background:
    radial-gradient(circle at 100% 100%, rgba(255, 113, 0, 0.18), transparent 28%),
    linear-gradient(120deg, var(--surface-strong), rgba(18, 24, 27, 0.96) 56%, rgba(29, 18, 13, 0.94));
  isolation: isolate;
}

.masthead::after {
  content: "";
  position: absolute;
  inset: auto -8% -35% auto;
  z-index: -1;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(255, 113, 0, 0.22), transparent 60%);
  filter: blur(4px);
}

.masthead-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-lg);
}

.eyebrow,
.trace-shell .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: rgba(232, 226, 216, 0.74);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.masthead .eyebrow::before {
  content: "";
  width: 16px;
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
}

h1 {
  font-size: 29px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.masthead-sub {
  max-width: 520px;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.masthead-agents {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--line);
  border-radius: var(--rounded-full);
  background: var(--surface-raised);
  font-weight: 500;
}

.agent-pill span,
.trace-run-agent {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--rounded-full);
  color: var(--on-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.agent-pill.is-solomon span,
.trace-run-agent.is-solomon {
  background: linear-gradient(180deg, #f7b26c, var(--primary));
}

.agent-pill.is-optimus span,
.trace-run-agent.is-optimus {
  background: var(--secondary);
}

.content {
  margin-top: var(--space-lg);
}

/* ---------- trace shell ---------- */

.trace-shell {
  display: grid;
  gap: var(--space-lg);
  --gutter: 280px;
  --meta: 96px;
  --row: 36px;
}

.trace-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.trace-seg {
  display: inline-flex;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--rounded-full);
  background: var(--surface-raised);
}

.trace-seg button {
  padding: 7px 12px;
  border: 0;
  border-radius: var(--rounded-full);
  background: transparent;
  color: rgba(232, 226, 216, 0.72);
  font-size: 13px;
  font-weight: 500;
  transition: color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.trace-seg button:hover {
  color: var(--on-surface);
}

.trace-seg button.is-active {
  color: var(--on-primary);
  background: linear-gradient(180deg, #f7b26c, var(--primary));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 0 0 3px var(--glow-primary);
}

.trace-fresh {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.trace-refresh,
.trace-play {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--rounded-full);
  background: var(--surface-raised);
  color: var(--on-surface);
}

.trace-refresh:hover {
  background: var(--surface-raised-hover);
}

.trace-play {
  border: 0;
  color: var(--on-primary);
  background: linear-gradient(180deg, #f7b26c, var(--primary));
  box-shadow: 0 0 0 3px var(--glow-primary);
}

/* ---------- search + capability filter ---------- */

.trace-search,
.trace-cap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 var(--space-md);
  border: 1px solid var(--line);
  border-radius: var(--rounded-full);
  background: var(--surface-raised);
  color: var(--muted);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

/* Row 1: filter pills. Row 2: search, capability, freshness, refresh. */
.trace-toolbar::after {
  content: "";
  order: 9;
  flex-basis: 100%;
  height: 0;
}

.trace-search { order: 10; }
.trace-cap { order: 11; }
.trace-fresh { order: 12; }
.trace-refresh { order: 13; }

.trace-search {
  flex: 1 1 320px;
  min-width: 160px;
}

.trace-search:focus-within,
.trace-cap:focus-within {
  border-color: rgba(255, 113, 0, 0.45);
  box-shadow: 0 0 0 3px var(--glow-primary);
}

.trace-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--on-surface);
  font-size: 13px;
}

.trace-search input::placeholder {
  color: var(--muted);
}

.trace-cap {
  flex: 0 1 280px;
  min-width: 0;
  padding-right: 6px;
}

.trace-cap select {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--on-surface);
  font-family: var(--font-mono);
  font-size: 12px;
}

.trace-cap select option {
  background: #12181b;
}

/* ---------- KPI row ---------- */

.trace-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-md);
}

.trace-stat {
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 132px;
  padding: var(--space-lg);
  border: 1px solid var(--line);
  border-radius: var(--rounded-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.trace-stat span {
  color: rgba(232, 226, 216, 0.74);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.trace-stat strong {
  margin-top: 10px;
  font-size: clamp(32px, 3.2vw, 48px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.06em;
}

.trace-stat small {
  color: var(--muted);
  font-size: 13px;
}

.trace-stat.is-alert {
  background: linear-gradient(180deg, rgba(204, 18, 37, 0.12), var(--surface));
}

.trace-stat.is-alert strong {
  color: var(--error-text);
}

.trace-pricing-note {
  grid-column: 1 / -1;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.trace-pricing-note i {
  margin-right: 6px;
  color: var(--secondary);
}

/* ---------- work area ---------- */

.trace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: var(--space-lg);
  align-items: start;
}

.trace-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--rounded-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.trace-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xl) var(--space-xl) var(--space-sm);
}

.trace-count {
  padding: 5px 9px;
  border-radius: var(--rounded-full);
  background: var(--surface-raised);
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(232, 226, 216, 0.8);
}

/* ---------- runs ---------- */

.trace-run-list {
  display: grid;
  gap: 6px;
  max-height: min(74vh, 920px);
  overflow-y: auto;
  padding: 4px var(--space-md) var(--space-md);
}

.trace-run {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: var(--space-sm);
  align-items: center;
  width: 100%;
  padding: 12px var(--space-md);
  border: 1px solid transparent;
  border-radius: var(--rounded-lg);
  background: var(--surface-strong);
  color: var(--on-surface);
  text-align: left;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.trace-run:hover {
  background: rgba(22, 28, 32, 0.96);
}

.trace-run.is-selected {
  border-color: rgba(255, 113, 0, 0.35);
  background:
    radial-gradient(circle at 100% 100%, rgba(255, 113, 0, 0.14), transparent 45%),
    rgba(22, 28, 32, 0.98);
  box-shadow: inset 3px 0 0 var(--primary);
}

.trace-run-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.trace-run-label {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-run-meta {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-run-side {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.trace-run-cost {
  font-family: var(--font-mono);
  font-size: 12px;
}

.trace-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(60, 185, 60, 0.14);
}

.trace-status-dot.is-error {
  background: var(--error);
  box-shadow: 0 0 0 4px rgba(204, 18, 37, 0.2);
}

.trace-status-dot.is-unverified {
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(245, 174, 108, 0.18);
}

.trace-status-dot.is-running {
  background: var(--secondary);
}

/* ---------- empty / error ---------- */

.trace-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 40px var(--space-lg);
  color: var(--muted);
  text-align: center;
}

.trace-empty i {
  font-size: 22px;
  color: var(--primary);
}

.trace-empty strong {
  color: var(--on-surface);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.trace-empty.is-detail {
  padding: 96px var(--space-lg);
}

.trace-empty .secondary {
  margin-top: 8px;
  padding: 8px 14px;
  border: 0;
  border-radius: var(--rounded-full);
  color: var(--on-primary);
  background: linear-gradient(180deg, #f7b26c, var(--primary));
  font-weight: 600;
}

.trace-empty a.secondary {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.auth-shell {
  width: min(520px, calc(100vw - 32px));
  margin: clamp(28px, 10vh, 100px) auto;
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: var(--rounded-shell);
  background: linear-gradient(180deg, rgba(17, 22, 26, 0.92), rgba(9, 13, 15, 0.92));
  box-shadow: var(--shadow);
}

.auth-shell h1 {
  margin-top: 8px;
  font-size: clamp(30px, 8vw, 42px);
  letter-spacing: -0.06em;
}

.auth-shell p {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.auth-shell form {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

.auth-email {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--rounded-md);
  color: var(--on-surface);
  background: var(--surface-raised);
  font-family: var(--font-mono);
}

.auth-submit {
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--rounded-full);
  color: var(--on-primary);
  background: linear-gradient(180deg, #f7b26c, var(--primary));
  font-weight: 700;
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.65;
}

.auth-status {
  min-height: 24px;
  color: var(--on-surface) !important;
}

.auth-back {
  display: inline-block;
  margin-top: 12px;
  color: var(--secondary);
  text-decoration: none;
}

/* ---------- run detail ---------- */

.trace-detail {
  overflow: hidden;
}

.trace-run-head {
  position: relative;
  display: grid;
  gap: var(--space-sm);
  padding: var(--space-xl);
  border-bottom: 1px solid var(--line);
}

.trace-run-title {
  font-size: 29px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.05em;
  overflow-wrap: anywhere;
}

.trace-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trace-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--rounded-full);
  background: var(--surface-raised);
  color: rgba(232, 226, 216, 0.8);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.trace-chip i {
  color: var(--muted);
}

.trace-chip.is-ok,
.trace-chip.is-error,
.trace-chip.is-unverified,
.trace-chip.is-warn,
.trace-chip.is-cached {
  gap: 8px;
}

.trace-chip.is-ok::before,
.trace-chip.is-error::before,
.trace-chip.is-unverified::before,
.trace-chip.is-warn::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
}

.trace-chip.is-ok { color: var(--ok); background: rgba(60, 185, 60, 0.14); }
.trace-chip.is-error { color: var(--error-text); background: rgba(204, 18, 37, 0.16); }
.trace-chip.is-unverified,
.trace-chip.is-warn { color: var(--warn); background: rgba(245, 174, 108, 0.16); }
.trace-chip.is-cached { color: var(--muted); border-style: dashed; }

/* ---------- timeline ---------- */

.trace-water {
  padding: var(--space-lg) 0 var(--space-sm);
  border-bottom: 1px solid var(--line);
}

.trace-transport {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: var(--space-sm);
  align-items: center;
  padding: 0 var(--space-xl) var(--space-md);
}

.trace-speed select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--rounded-full);
  background: var(--surface-raised);
  font-family: var(--font-mono);
  font-size: 12px;
}

.trace-speed option {
  background: #12181b;
}

.trace-scrub {
  width: 100%;
  accent-color: var(--primary);
}

.trace-clock {
  min-width: 120px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
}

.trace-ruler {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr) var(--meta);
  height: 24px;
  padding-right: var(--space-md);
}

.trace-ruler-track {
  position: relative;
  border-bottom: 1px solid var(--line);
}

.trace-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--line);
}

.trace-tick span {
  position: absolute;
  top: 2px;
  left: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  white-space: nowrap;
}

.trace-rows {
  position: relative;
  max-height: 480px;
  overflow-y: auto;
  padding: 4px var(--space-md) 4px 0;
}

.trace-playhead {
  --p: 1;
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--gutter) + (100% - var(--gutter) - var(--meta) - var(--space-md)) * var(--p));
  z-index: 2;
  width: 2px;
  margin-left: -1px;
  background: var(--primary);
  box-shadow: 0 0 12px rgba(255, 113, 0, 0.55);
  pointer-events: none;
}

.trace-row {
  --k: var(--muted);
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr) var(--meta);
  align-items: center;
  height: var(--row);
  margin: 0 0 0 var(--space-sm);
  border-radius: var(--rounded-md);
  cursor: pointer;
  outline-offset: -2px;
}

.trace-row:hover {
  background: var(--surface-raised);
}

.trace-row.is-selected {
  background:
    radial-gradient(circle at 0% 50%, rgba(255, 113, 0, 0.16), transparent 30%),
    rgba(255, 255, 255, 0.05);
  box-shadow: inset 2px 0 0 var(--primary);
}

.trace-row.is-kind-model { --k: var(--span-model); }
.trace-row.is-kind-tool { --k: var(--span-tool); }
.trace-row.is-kind-capability { --k: var(--span-capability); }
.trace-row.is-kind-subagent { --k: var(--span-subagent); }
.trace-row.is-kind-marker { --k: var(--primary); }
.trace-row.is-kind-agent { --k: var(--on-surface); }
.trace-row.is-error { --k: var(--error); }
.trace-row.is-unverified { --k: var(--warn); }
.trace-row.is-cached { --k: var(--muted); }

.trace-row-name {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding-left: calc(8px + var(--depth, 0) * 16px);
}

.trace-caret,
.trace-caret-spacer {
  flex: none;
  width: 20px;
  height: 20px;
}

.trace-caret {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--rounded-full);
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.trace-caret:hover {
  background: var(--surface-raised-hover);
  color: var(--on-surface);
}

.trace-kind-icon {
  flex: none;
  width: 16px;
  color: var(--k);
  font-size: 12px;
  text-align: center;
}

.trace-row-label {
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-row.is-kind-model .trace-row-label,
.trace-row.is-kind-capability .trace-row-label,
.trace-row.is-kind-tool .trace-row-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
}

.trace-row.is-kind-agent .trace-row-label,
.trace-row.is-kind-subagent .trace-row-label {
  font-weight: 700;
  letter-spacing: -0.03em;
}

.trace-row.is-queued .trace-row-name,
.trace-row.is-queued .trace-row-meta {
  opacity: 0.4;
}

.trace-mini {
  flex: none;
  padding: 2px 7px;
  border-radius: var(--rounded-full);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.trace-mini.is-warn {
  background: rgba(245, 174, 108, 0.16);
  color: var(--warn);
}

.trace-mini.is-slow {
  background: rgba(255, 113, 0, 0.16);
  color: var(--primary);
}

.trace-row-track {
  position: relative;
  height: 100%;
}

.trace-bar {
  position: absolute;
  top: 50%;
  min-width: 4px;
  height: 8px;
  transform: translateY(-50%);
  border-radius: var(--rounded-full);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.trace-row.is-kind-agent .trace-bar,
.trace-row.is-kind-subagent .trace-bar {
  height: 4px;
}

.trace-bar-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--k);
}

.trace-row.is-unverified .trace-bar-fill {
  background: repeating-linear-gradient(135deg, var(--k) 0 5px, rgba(245, 174, 108, 0.4) 5px 10px);
}

.trace-row.is-cached .trace-bar {
  background: transparent;
  outline: 1px dashed var(--muted);
}

.trace-row.is-running .trace-bar {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08), 0 0 14px var(--k);
}

.trace-row.is-slowest .trace-bar {
  box-shadow: 0 0 0 2px rgba(255, 113, 0, 0.45);
}

.trace-bar.is-marker {
  width: 12px !important;
  height: 12px;
  margin-left: -6px;
  transform: translateY(-50%) rotate(45deg);
  border-radius: 3px;
  background: var(--k);
}

.trace-row-meta {
  overflow: hidden;
  padding-left: var(--space-sm);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- step detail ---------- */

.trace-step {
  display: grid;
  gap: var(--space-md);
  padding: var(--space-xl);
}

.trace-step-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.trace-step-head h3 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}

.trace-step-head .trace-kind-icon.is-kind-model { color: var(--span-model); }
.trace-step-head .trace-kind-icon.is-kind-tool { color: var(--span-tool); }
.trace-step-head .trace-kind-icon.is-kind-capability { color: var(--span-capability); }
.trace-step-head .trace-kind-icon.is-kind-subagent { color: var(--span-subagent); }
.trace-step-head .trace-kind-icon.is-kind-marker { color: var(--primary); }

.trace-step-detail {
  color: var(--muted);
  font-size: 13px;
}

.trace-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 0;
}

.trace-facts div {
  padding: var(--space-sm) 12px;
  border: 1px solid var(--line);
  border-radius: var(--rounded-md);
  background: var(--surface-raised);
}

.trace-facts dt {
  color: rgba(232, 226, 216, 0.6);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.trace-facts dd {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.trace-marker {
  display: grid;
  gap: 8px;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid rgba(255, 113, 0, 0.3);
  border-radius: var(--rounded-lg);
  background:
    radial-gradient(circle at 100% 100%, rgba(255, 113, 0, 0.16), transparent 40%),
    var(--surface-strong);
  line-height: 1.45;
}

.trace-marker span {
  display: inline-block;
  min-width: 82px;
  margin-right: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.trace-excerpt {
  display: grid;
  gap: 6px;
}

.trace-excerpt em {
  color: var(--warn);
  font-style: normal;
}

.trace-excerpt pre {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--line);
  border-radius: var(--rounded-md);
  background: var(--surface-strong);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.trace-attrs {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--rounded-lg);
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface-strong);
}

.trace-attrs th,
.trace-attrs td {
  padding: 10px var(--space-md);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.trace-attrs tr:last-child th,
.trace-attrs tr:last-child td {
  border-bottom: 0;
}

.trace-attrs th {
  width: 34%;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--surface-raised);
}

.trace-attrs td {
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* ---------- lead-up to a failure ---------- */

.trace-leadup {
  display: grid;
  gap: 8px;
  padding: var(--space-md);
  border: 1px solid rgba(245, 174, 108, 0.24);
  border-radius: var(--rounded-lg);
  background:
    radial-gradient(circle at 100% 0%, rgba(245, 174, 108, 0.1), transparent 45%),
    var(--surface-strong);
}

.trace-leadup ol {
  position: relative;
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.trace-leadup ol::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 21px;
  width: 1px;
  background: var(--line);
}

.trace-leadup-step {
  --k: var(--muted);
  position: relative;
  display: grid;
  grid-template-columns: 22px 190px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--rounded-md);
  background: transparent;
  color: var(--on-surface);
  text-align: left;
}

.trace-leadup-step:hover {
  background: var(--surface-raised);
}

.trace-leadup-step.is-kind-model { --k: var(--span-model); }
.trace-leadup-step.is-kind-tool { --k: var(--span-tool); }
.trace-leadup-step.is-kind-capability { --k: var(--span-capability); }
.trace-leadup-step.is-error { --k: var(--error-text); }
.trace-leadup-step.is-unverified { --k: var(--warn); }

.trace-leadup-step i {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--rounded-full);
  background: #12181b;
  color: var(--k);
  font-size: 10px;
  box-shadow: 0 0 0 1px var(--line);
}

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

.trace-leadup-text {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.trace-leadup-step.is-current {
  background: rgba(245, 174, 108, 0.1);
  box-shadow: inset 2px 0 0 var(--k);
}

.trace-leadup-step.is-current .trace-leadup-text {
  color: var(--k);
}

/* ---------- responsive ---------- */

@media (prefers-reduced-motion: reduce) {
  .trace-seg button,
  .trace-run {
    transition: none;
  }
}

@media (max-width: 1180px) {
  .trace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .trace-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .trace-run-list {
    max-height: 360px;
  }
}

@media (max-width: 760px) {
  .shell {
    width: calc(100vw - 16px);
    margin: 8px auto;
    padding: var(--space-sm);
    border-radius: var(--rounded-lg);
  }

  .masthead,
  .trace-card,
  .trace-stat {
    border-radius: var(--rounded-lg);
  }

  .masthead {
    padding: var(--space-lg);
  }

  .trace-shell {
    --gutter: 168px;
    --meta: 64px;
    --row: 40px;
  }

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

  .trace-stat {
    min-height: 0;
  }

  .trace-fresh {
    margin-left: 0;
    flex: 1 1 auto;
  }

  .trace-transport {
    grid-template-columns: auto auto minmax(0, 1fr);
    padding: 0 var(--space-md) var(--space-md);
  }

  .trace-clock {
    grid-column: 1 / -1;
    text-align: left;
  }

  .trace-run-head,
  .trace-step {
    padding: var(--space-lg);
  }

  .trace-run-title {
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  .trace-shell {
    --gutter: 148px;
    --meta: 0px;
  }

  .trace-row-meta,
  .trace-ruler-meta {
    display: none;
  }

  .trace-ruler,
  .trace-row {
    grid-template-columns: var(--gutter) minmax(0, 1fr);
  }

  .trace-seg {
    flex: 1 1 100%;
  }

  .trace-seg button {
    flex: 1 1 0;
    padding: 7px 6px;
  }

  .trace-row-name {
    gap: 4px;
    padding-left: calc(4px + var(--depth, 0) * 10px);
  }

  .trace-mini.is-slow {
    display: none;
  }

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

  .trace-search,
  .trace-cap {
    flex: 1 1 100%;
  }

  .trace-leadup-step {
    grid-template-columns: 22px minmax(0, 1fr) auto;
  }

  .trace-leadup-text {
    grid-column: 2 / -1;
    white-space: normal;
  }
}
