:root {
  --bg: #07110f;
  --bg-deep: #040a09;
  --panel: rgba(14, 29, 26, 0.86);
  --panel-solid: #0e1d1a;
  --panel-lift: #132622;
  --line: rgba(205, 235, 222, 0.12);
  --line-strong: rgba(205, 235, 222, 0.21);
  --ink: #f0f6f1;
  --muted: #91a39c;
  --muted-2: #657970;
  --lime: #c7ff6b;
  --teal: #65e8d2;
  --blue: #8fb6ff;
  --amber: #ffbf69;
  --purple: #cf9cff;
  --rose: #ff7885;
  --danger: #ff6675;
  --radius: 18px;
  --sidebar: 226px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Segoe UI Variable", "Segoe UI", Inter, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

body {
  overflow: hidden;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 42px 42px;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.flow-node:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

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

.ambient {
  position: fixed;
  z-index: 0;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
  opacity: 0.08;
}

.ambient-a {
  top: -240px;
  right: 10%;
  background: var(--teal);
}

.ambient-b {
  bottom: -320px;
  left: 35%;
  background: var(--lime);
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 26px 18px 18px;
  background: rgba(5, 14, 12, 0.9);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  padding: 0 8px 27px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(199, 255, 107, 0.3);
  border-radius: 13px;
  background: rgba(199, 255, 107, 0.08);
  box-shadow: inset 0 0 20px rgba(199, 255, 107, 0.05);
}

.brand-mark svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--lime);
  stroke-width: 2.2;
  stroke-linejoin: round;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-copy strong {
  font-size: 16px;
  letter-spacing: 0.22em;
}

.brand-copy small,
.sidebar-foot,
.panel-kicker,
.section-kicker,
.eyebrow,
.rule-kicker,
.dialog-kicker,
.inspector-eyebrow,
.inspector-index {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.primary-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 26px;
}

.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 25px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: 160ms ease;
}

.nav-item:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.025);
}

.nav-item.is-active {
  color: var(--ink);
  border-color: rgba(199, 255, 107, 0.16);
  background: linear-gradient(90deg, rgba(199, 255, 107, 0.11), rgba(199, 255, 107, 0.025));
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -19px;
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--lime);
  box-shadow: 0 0 14px rgba(199, 255, 107, 0.5);
}

.nav-icon {
  font-family: var(--mono);
  color: var(--muted-2);
  font-size: 18px;
}

.nav-item.is-active .nav-icon {
  color: var(--lime);
}

.nav-count {
  min-width: 25px;
  padding: 3px 6px;
  border-radius: 7px;
  color: var(--lime);
  background: rgba(199, 255, 107, 0.08);
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
}

.nav-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 10px var(--teal);
}

.sidebar-spacer {
  flex: 1;
}

.runtime-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.runtime-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 650;
}

.status-orb {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 12px rgba(255, 191, 105, 0.8);
}

.status-orb.live {
  background: var(--lime);
  box-shadow: 0 0 12px rgba(199, 255, 107, 0.8);
}

.status-orb.demo {
  background: var(--purple);
  box-shadow: 0 0 12px rgba(207, 156, 255, 0.8);
}

.runtime-card p {
  min-height: 32px;
  margin: 9px 0 13px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.runtime-meta {
  display: flex;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  color: var(--muted-2);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.sidebar-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  padding: 0 3px;
  letter-spacing: 0.06em;
}

.sidebar-foot strong {
  color: var(--teal);
  font-weight: 500;
}

.main-stage {
  display: grid;
  grid-template-rows: 76px minmax(0, 1fr);
  min-width: 0;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 15, 0.6);
  backdrop-filter: blur(16px);
}

.topbar-title,
.topbar-actions,
.detail-id-row,
.detail-meta,
.map-actions,
.timeline-scale,
.map-legend {
  display: flex;
  align-items: center;
}

.topbar-title {
  gap: 13px;
  min-width: 0;
}

.topbar-title h1 {
  margin: 3px 0 0;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 630;
  letter-spacing: -0.02em;
}

.eyebrow {
  color: var(--teal);
}

.mobile-menu {
  display: none;
  border: 0;
  background: transparent;
  font-size: 20px;
}

.topbar-actions {
  gap: 10px;
}

.sync-stamp {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.sync-dot,
.lock-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 9px rgba(101, 232, 210, 0.7);
}

.icon-button,
.ghost-button,
.tool-button {
  display: inline-grid;
  place-items: center;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: 150ms ease;
}

.icon-button {
  width: 36px;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:hover,
.ghost-button:hover,
.tool-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
}

.icon-button.is-spinning svg {
  animation: spin 0.8s linear infinite;
}

.ghost-button {
  display: flex;
  grid-auto-flow: column;
  gap: 8px;
  padding: 0 13px;
  color: var(--muted);
  font-size: 11px;
}

.view {
  min-height: 0;
  padding: 28px 32px 40px;
  overflow: auto;
  scrollbar-color: rgba(145, 163, 156, 0.25) transparent;
}

.hero-strip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 155px;
  padding: 25px 32px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(105deg, rgba(20, 46, 39, 0.8), rgba(10, 25, 22, 0.9) 60%, rgba(11, 35, 30, 0.75)),
    radial-gradient(circle at 90% 50%, rgba(101, 232, 210, 0.14), transparent 35%);
  box-shadow: var(--shadow);
}

.hero-strip::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 80px, rgba(255, 255, 255, 0.015) 81px 82px);
}

.hero-copy {
  position: relative;
  z-index: 1;
  width: min(720px, 75%);
}

.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--lime);
}

.section-kicker i {
  width: 18px;
  height: 1px;
  background: currentColor;
}

.hero-copy h2,
.rules-hero h2 {
  margin: 10px 0 7px;
  font-size: clamp(24px, 2.2vw, 36px);
  line-height: 1.12;
  letter-spacing: -0.04em;
  font-weight: 620;
}

.hero-copy p,
.rules-hero p {
  margin: 0;
  max-width: 710px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.hero-signal {
  position: relative;
  z-index: 1;
  width: 180px;
  height: 110px;
  flex: 0 0 180px;
}

.signal-ring,
.signal-core {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.signal-ring {
  border: 1px solid rgba(101, 232, 210, 0.26);
  animation: signal 3s ease-in-out infinite;
}

.ring-one { width: 54px; height: 54px; }
.ring-two { width: 88px; height: 88px; animation-delay: -1s; }
.ring-three { width: 124px; height: 124px; animation-delay: -2s; }

.signal-core {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(199, 255, 107, 0.6);
  background: var(--bg);
  color: var(--lime);
  font-family: var(--mono);
  font-size: 11px;
  box-shadow: 0 0 28px rgba(199, 255, 107, 0.16);
}

.signal-beam {
  position: absolute;
  top: 50%;
  right: -30px;
  width: 90px;
  height: 1px;
  background: linear-gradient(90deg, var(--teal), transparent);
}

.demo-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 12px 15px;
  border: 1px solid rgba(207, 156, 255, 0.24);
  border-radius: 12px;
  background: rgba(207, 156, 255, 0.06);
}

.demo-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(207, 156, 255, 0.14);
  color: var(--purple);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.09em;
}

.demo-banner p {
  flex: 1;
  margin: 0;
  color: #b6aac3;
  font-size: 11px;
}

.demo-banner button {
  border: 0;
  background: transparent;
  color: var(--purple);
  cursor: pointer;
  font-size: 11px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.metric-card {
  position: relative;
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  min-height: 92px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(13, 27, 24, 0.72);
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -28px;
  bottom: -40px;
  width: 95px;
  height: 95px;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: 0.06;
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 1px solid currentColor;
  border-radius: 9px;
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0.85;
}

.metric-card div:nth-child(2) {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.metric-card span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.metric-card strong {
  font-size: 25px;
  font-weight: 580;
  letter-spacing: -0.04em;
}

.metric-card small {
  grid-column: 2;
  margin-top: -11px;
  color: var(--muted-2);
  font-size: 10px;
}

.metric-total { color: var(--teal); }
.metric-success { color: var(--lime); }
.metric-attention { color: var(--amber); }
.metric-failed { color: var(--rose); }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.trace-workbench {
  display: grid;
  grid-template-columns: minmax(310px, 0.75fr) minmax(520px, 1.65fr);
  gap: 14px;
  min-height: 620px;
}

.trace-index-panel,
.trace-detail-panel {
  min-height: 620px;
  overflow: hidden;
}

.trace-index-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 17px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3,
.timeline-head h4 {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 600;
}

.result-count {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.trace-filters {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.search-field {
  display: flex;
  align-items: center;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.14);
  color: var(--muted-2);
}

.search-field input {
  width: 100%;
  min-width: 0;
  margin-left: 8px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
}

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

.select-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.select-row select {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  background: #0b1916;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
}

.trace-list {
  min-height: 0;
  overflow: auto;
}

.trace-list-empty {
  display: grid;
  place-items: center;
  min-height: 230px;
  padding: 25px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.trace-item {
  position: relative;
  display: grid;
  grid-template-columns: 11px minmax(0, 1fr) auto;
  gap: 11px;
  width: 100%;
  padding: 15px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: 140ms ease;
}

.trace-item:hover {
  background: rgba(255, 255, 255, 0.025);
}

.trace-item.is-active {
  background: linear-gradient(90deg, rgba(101, 232, 210, 0.08), rgba(101, 232, 210, 0.015));
}

.trace-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 2px;
  border-radius: 0 3px 3px 0;
  background: var(--teal);
}

.trace-status-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border: 2px solid var(--panel-solid);
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 1px currentColor;
}

.trace-status-dot.processed { color: var(--lime); background: var(--lime); }
.trace-status-dot.needs_review,
.trace-status-dot.needs_user_choice { color: var(--amber); background: var(--amber); }
.trace-status-dot.failed { color: var(--danger); background: var(--danger); }
.trace-status-dot.processing,
.trace-status-dot.received { color: var(--teal); background: var(--teal); animation: pulse 1.4s infinite; }
.trace-status-dot.ignored,
.trace-status-dot.skipped { color: var(--muted-2); background: var(--muted-2); }

.trace-item-copy {
  min-width: 0;
}

.trace-item-top,
.trace-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.trace-item-top strong {
  color: #c8d6d0;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.trace-item-top time,
.trace-item-foot {
  color: var(--muted-2);
  font-size: 9px;
}

.trace-item-caption {
  display: -webkit-box;
  min-height: 34px;
  margin: 7px 0 9px;
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.5;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.workflow-label {
  color: var(--teal);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.trace-event-count {
  align-self: center;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 9px;
}

.trace-detail-panel {
  position: relative;
  padding: 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 620px;
  padding: 40px;
  text-align: center;
}

.empty-state h3 {
  margin: 12px 0 5px;
  font-size: 20px;
  font-weight: 600;
}

.empty-state p {
  max-width: 390px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.empty-glyph {
  position: relative;
  width: 110px;
  height: 70px;
  margin-bottom: 24px;
}

.empty-glyph::before {
  content: "";
  position: absolute;
  top: 34px;
  left: 14px;
  right: 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--teal), transparent);
}

.empty-glyph span,
.empty-glyph i,
.empty-glyph b {
  position: absolute;
  top: 25px;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel-solid);
  transform: rotate(45deg);
}

.empty-glyph span { left: 8px; }
.empty-glyph i { left: 46px; border-color: rgba(101, 232, 210, 0.45); box-shadow: 0 0 20px rgba(101, 232, 210, 0.12); }
.empty-glyph b { right: 8px; }

.trace-detail {
  min-height: 620px;
  padding: 24px 26px 32px;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
}

.detail-title-block {
  min-width: 0;
}

.detail-id-row {
  gap: 8px;
}

.mono {
  font-family: var(--mono);
}

.status-pill,
.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid currentColor;
  border-radius: 20px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-pill.processed { color: var(--lime); background: rgba(199, 255, 107, 0.07); }
.status-pill.needs_review,
.status-pill.needs_user_choice { color: var(--amber); background: rgba(255, 191, 105, 0.07); }
.status-pill.failed { color: var(--danger); background: rgba(255, 102, 117, 0.07); }
.status-pill.ignored,
.status-pill.skipped { color: var(--muted); background: rgba(145, 163, 156, 0.06); }
.status-pill.processing,
.status-pill.received { color: var(--teal); background: rgba(101, 232, 210, 0.07); }

.detail-id-row > .mono {
  color: var(--muted);
  font-size: 10px;
}

.source-pill {
  border-color: var(--line);
  color: var(--muted-2);
}

.detail-head h3 {
  max-width: 760px;
  margin: 13px 0 10px;
  font-size: 20px;
  font-weight: 570;
  line-height: 1.45;
}

.detail-meta {
  flex-wrap: wrap;
  gap: 7px 15px;
  color: var(--muted);
  font-size: 10px;
}

.detail-meta span::before {
  content: "•";
  margin-right: 6px;
  color: var(--muted-2);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 39px;
  padding: 0 14px;
  border: 1px solid rgba(199, 255, 107, 0.3);
  border-radius: 10px;
  background: var(--lime);
  color: #0a120e;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  transition: 150ms ease;
  white-space: nowrap;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(199, 255, 107, 0.12);
}

.primary-button b {
  font-family: var(--mono);
  font-weight: 500;
}

.outcome-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 8px;
  margin: 22px 0 26px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.12);
}

.outcome-cell {
  min-height: 48px;
  padding: 7px 10px;
  border-left: 1px solid var(--line);
}

.outcome-cell:first-child {
  border-left: 0;
}

.outcome-cell span {
  display: block;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.outcome-cell strong {
  display: block;
  margin-top: 5px;
  color: #dce8e2;
  font-size: 12px;
  font-weight: 580;
}

.timeline-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.timeline-scale {
  gap: 8px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.timeline-scale i {
  width: 55px;
  height: 1px;
  background: linear-gradient(90deg, var(--teal), var(--line));
}

.event-timeline {
  margin: 0;
  padding: 7px 0 0;
  list-style: none;
}

.event-item {
  position: relative;
  display: grid;
  grid-template-columns: 66px 24px minmax(0, 1fr) auto;
  gap: 11px;
  min-height: 75px;
  padding: 10px 0;
}

.event-item::before {
  content: "";
  position: absolute;
  top: 35px;
  bottom: -11px;
  left: 88px;
  width: 1px;
  background: var(--line);
}

.event-item:last-child::before {
  display: none;
}

.event-time {
  padding-top: 7px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 9px;
  text-align: right;
}

.event-marker {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel-solid);
  color: var(--teal);
  font-family: var(--mono);
  font-size: 8px;
}

.event-item.completed .event-marker { border-color: rgba(199, 255, 107, 0.45); color: var(--lime); }
.event-item.active .event-marker { border-color: var(--teal); box-shadow: 0 0 14px rgba(101, 232, 210, 0.15); }
.event-item.blocked .event-marker,
.event-item.choice .event-marker { border-color: rgba(255, 191, 105, 0.55); color: var(--amber); }
.event-item.failed .event-marker { border-color: rgba(255, 102, 117, 0.6); color: var(--danger); }
.event-item.skipped .event-marker { color: var(--muted-2); }

.event-copy {
  min-width: 0;
}

.event-copy strong {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 590;
}

.event-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.event-detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.event-detail-chips span {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #9fb2aa;
  background: rgba(255, 255, 255, 0.018);
  font-family: var(--mono);
  font-size: 8px;
}

.event-node-id {
  padding-top: 6px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
}

/* Flow map */
.map-view {
  display: grid;
  grid-template-rows: auto minmax(520px, 1fr) auto;
  gap: 12px;
  height: 100%;
  padding-bottom: 18px;
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.scenario-picker {
  min-width: 0;
}

.scenario-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.scenario-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  transition: 140ms ease;
}

.scenario-button:hover,
.scenario-button.is-active {
  color: var(--ink);
  border-color: rgba(101, 232, 210, 0.32);
  background: rgba(101, 232, 210, 0.07);
}

.map-actions {
  flex: 0 0 auto;
  gap: 6px;
}

.tool-button {
  width: 34px;
  font-family: var(--mono);
}

.fit-button {
  width: auto;
  padding: 0 10px;
  color: var(--muted);
  font-size: 10px;
}

.zoom-readout {
  min-width: 49px;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.replay-button {
  margin-left: 5px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(5, 14, 12, 0.82);
  box-shadow: var(--shadow);
}

.flow-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  background-image:
    radial-gradient(circle at 20% 25%, rgba(101, 232, 210, 0.04), transparent 24%),
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: auto, 32px 32px, 32px 32px;
}

.flow-viewport.is-dragging {
  cursor: grabbing;
}

.flow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 3720px;
  height: 1240px;
  transform-origin: 0 0;
  will-change: transform;
}

.edge-layer,
.lane-layer,
.node-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.edge-path {
  fill: none;
  stroke: rgba(153, 184, 171, 0.22);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  transition: stroke 180ms ease, opacity 180ms ease;
}

.edge-path.success { stroke: rgba(199, 255, 107, 0.28); }
.edge-path.warning { stroke: rgba(255, 191, 105, 0.28); stroke-dasharray: 5 5; }
.edge-path.danger { stroke: rgba(255, 102, 117, 0.25); stroke-dasharray: 4 6; }
.edge-path.is-muted { opacity: 0.1; }
.edge-path.is-visited { stroke: var(--teal); opacity: 0.9; stroke-width: 2.2; filter: drop-shadow(0 0 4px rgba(101, 232, 210, 0.55)); }
.edge-path.is-current { stroke: var(--lime); stroke-width: 3; stroke-dasharray: 8 7; animation: dash 0.7s linear infinite; }

.edge-label {
  fill: #6f857b;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  paint-order: stroke;
  stroke: var(--bg-deep);
  stroke-width: 5px;
  stroke-linejoin: round;
}

.lane-band {
  position: absolute;
  left: 35px;
  width: 3630px;
  height: 160px;
  border-top: 1px solid rgba(255, 255, 255, 0.035);
  pointer-events: none;
}

.lane-band::before {
  content: "";
  position: absolute;
  left: 0;
  top: 25px;
  width: 22px;
  height: 1px;
  background: var(--lane-color);
}

.lane-band span,
.lane-band strong {
  position: absolute;
  left: 31px;
  font-family: var(--mono);
}

.lane-band span {
  top: 17px;
  color: var(--lane-color);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.lane-band strong {
  top: 34px;
  color: rgba(220, 235, 228, 0.38);
  font-size: 11px;
  font-weight: 500;
}

.flow-node {
  --node-color: var(--teal);
  position: absolute;
  width: 214px;
  min-height: 104px;
  padding: 13px 14px 12px;
  border: 1px solid rgba(185, 216, 203, 0.16);
  border-radius: 12px;
  background: linear-gradient(140deg, rgba(18, 38, 33, 0.98), rgba(9, 23, 20, 0.98));
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  transition: border-color 180ms ease, opacity 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.flow-node::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 13px;
  width: 28px;
  height: 2px;
  border-radius: 0 0 3px 3px;
  background: var(--node-color);
  opacity: 0.7;
}

.flow-node:hover,
.flow-node.is-selected {
  z-index: 3;
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--node-color), transparent 45%);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.33), 0 0 24px color-mix(in srgb, var(--node-color), transparent 88%);
}

.flow-node.is-muted {
  opacity: 0.18;
}

.flow-node.is-visited {
  border-color: rgba(101, 232, 210, 0.5);
  box-shadow: 0 0 22px rgba(101, 232, 210, 0.09);
}

.flow-node.is-current {
  z-index: 4;
  border-color: var(--lime);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 0 0 1px rgba(199, 255, 107, 0.16), 0 0 35px rgba(199, 255, 107, 0.18);
}

.flow-node[data-kind="entry"] { --node-color: var(--teal); }
.flow-node[data-kind="process"] { --node-color: var(--blue); }
.flow-node[data-kind="decision"] { --node-color: var(--amber); }
.flow-node[data-kind="write"] { --node-color: var(--lime); }
.flow-node[data-kind="human"] { --node-color: var(--purple); }
.flow-node[data-kind="terminal"] { --node-color: var(--rose); }

.node-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.node-index,
.node-eyebrow {
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.07em;
}

.node-index { color: var(--node-color); }
.node-eyebrow { max-width: 135px; overflow: hidden; color: var(--muted-2); text-overflow: ellipsis; white-space: nowrap; }

.flow-node strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 620;
}

.flow-node p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.45;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.node-port {
  position: absolute;
  top: 50%;
  width: 5px;
  height: 5px;
  border: 1px solid var(--node-color);
  border-radius: 50%;
  background: var(--panel-solid);
  transform: translateY(-50%);
}

.node-port.in { left: -3px; }
.node-port.out { right: -3px; }

.map-coordinate,
.map-hint {
  position: absolute;
  z-index: 6;
  color: var(--muted-2);
  background: rgba(4, 10, 9, 0.65);
  backdrop-filter: blur(8px);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  pointer-events: none;
}

.map-coordinate {
  top: 12px;
  left: 12px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.map-hint {
  bottom: 12px;
  left: 50%;
  padding: 7px 10px;
  border-radius: 7px;
  transform: translateX(-50%);
}

.map-hint span {
  color: var(--teal);
}

.node-inspector {
  position: relative;
  padding: 24px 20px;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 37, 32, 0.94), rgba(8, 20, 17, 0.95));
}

.inspector-index {
  position: absolute;
  top: 21px;
  right: 18px;
  color: var(--muted-2);
}

.inspector-eyebrow {
  display: block;
  max-width: 155px;
  color: var(--teal);
}

.node-inspector h3 {
  margin: 13px 0 10px;
  font-size: 20px;
  font-weight: 590;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.node-inspector > p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.inspector-safety,
.inspector-source,
.inspector-path {
  margin-top: 22px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.inspector-safety span,
.inspector-source span,
.inspector-path > span {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.inspector-safety p {
  margin: 8px 0 0;
  padding: 10px;
  border-left: 2px solid var(--amber);
  background: rgba(255, 191, 105, 0.05);
  color: #d6c29f;
  font-size: 10px;
  line-height: 1.55;
}

.inspector-source code {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  color: #a9bcb4;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.5;
}

.inspector-path {
  position: absolute;
  right: 20px;
  bottom: 22px;
  left: 20px;
}

.inspector-path strong {
  display: block;
  margin: 8px 0 10px;
  font-size: 11px;
  font-weight: 580;
}

.route-progress {
  height: 3px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
}

.route-progress i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--lime));
  transition: width 220ms ease;
}

.inspector-path small {
  display: block;
  margin-top: 7px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
}

.map-legend {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  min-height: 24px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
}

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

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

.legend-dot.entry { background: var(--teal); }
.legend-dot.process { background: var(--blue); }
.legend-dot.decision { background: var(--amber); }
.legend-dot.write { background: var(--lime); }
.legend-dot.human { background: var(--purple); }
.legend-dot.terminal { background: var(--rose); }

/* Rules */
.rules-view {
  padding-bottom: 60px;
}

.rules-hero {
  max-width: 840px;
  padding: 15px 0 28px;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.rule-card {
  position: relative;
  min-height: 260px;
  padding: 23px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(18, 37, 32, 0.82), rgba(9, 23, 20, 0.88));
}

.rule-card::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -60px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 50%;
}

.rule-featured {
  border-color: rgba(199, 255, 107, 0.22);
  background: linear-gradient(145deg, rgba(34, 59, 39, 0.8), rgba(11, 28, 23, 0.9));
}

.rule-number {
  position: absolute;
  top: 20px;
  right: 20px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 9px;
}

.rule-symbol {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 21px;
  border: 1px solid rgba(101, 232, 210, 0.28);
  border-radius: 14px;
  color: var(--teal);
  background: rgba(101, 232, 210, 0.05);
  font-family: var(--mono);
  font-size: 13px;
}

.rule-featured .rule-symbol {
  color: var(--lime);
  border-color: rgba(199, 255, 107, 0.34);
  background: rgba(199, 255, 107, 0.06);
}

.rule-kicker {
  color: var(--muted-2);
}

.rule-card h3 {
  margin: 8px 0 8px;
  font-size: 17px;
  font-weight: 590;
}

.rule-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.rule-code,
.rule-tags,
.threshold-viz {
  position: absolute;
  right: 23px;
  bottom: 21px;
  left: 23px;
}

.rule-code {
  padding: 8px 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.13);
  color: #92aaa0;
  font-family: var(--mono);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-tags {
  display: flex;
  gap: 6px;
}

.rule-tags span {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 8px;
}

.threshold-viz {
  display: grid;
  grid-template-columns: 35px 1fr auto;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
}

.threshold-viz b {
  color: var(--lime);
  font-size: 10px;
}

.threshold-viz i {
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
}

.threshold-viz i span {
  display: block;
  width: 70%;
  height: 100%;
  background: var(--lime);
}

.threshold-viz small {
  color: var(--muted-2);
  font-size: 8px;
}

.write-matrix {
  margin-top: 14px;
  overflow: hidden;
}

.matrix-note {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
}

.matrix-table {
  padding: 0 22px 18px;
}

.matrix-row {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  min-height: 47px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

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

.matrix-header {
  min-height: 37px;
  color: var(--muted-2);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.matrix-row strong {
  color: var(--ink);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 580;
}

.matrix-row .yes { color: var(--teal); }
.matrix-row .no { color: var(--muted-2); }
.matrix-row .exclusive { color: var(--lime); }

/* Dialog */
.access-dialog {
  width: min(440px, calc(100vw - 34px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #0d1d19;
  color: var(--ink);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.65);
}

.access-dialog::backdrop {
  background: rgba(2, 7, 6, 0.78);
  backdrop-filter: blur(8px);
}

.access-dialog form {
  position: relative;
  padding: 30px;
}

.dialog-close {
  position: absolute;
  top: 13px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 21px;
}

.dialog-kicker {
  color: var(--teal);
}

.access-dialog h2 {
  margin: 10px 0 8px;
  font-size: 25px;
  font-weight: 620;
  letter-spacing: -0.035em;
}

.access-dialog p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.access-dialog label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
}

.access-dialog input {
  width: 100%;
  height: 43px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: 0;
  background: rgba(0, 0, 0, 0.18);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
}

.dialog-error {
  margin-top: 9px;
  color: var(--danger);
  font-size: 10px;
}

.dialog-submit {
  width: 100%;
  margin-top: 14px;
}

.access-dialog small {
  display: block;
  margin-top: 13px;
  color: var(--muted-2);
  font-size: 9px;
  text-align: center;
}

.access-dialog code {
  font-family: var(--mono);
}

.toast {
  position: fixed;
  z-index: 30;
  right: 24px;
  bottom: 24px;
  max-width: 320px;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #12251f;
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes signal { 50% { opacity: 0.35; transform: translate(-50%, -50%) scale(1.05); } }
@keyframes dash { to { stroke-dashoffset: -15; } }

@media (max-width: 1180px) {
  :root { --sidebar: 188px; }
  .sidebar { padding-inline: 12px; }
  .nav-item.is-active::before { left: -13px; }
  .view { padding-inline: 22px; }
  .topbar { padding-inline: 22px; }
  .trace-workbench { grid-template-columns: 310px minmax(470px, 1fr); }
  .rule-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-layout { grid-template-columns: minmax(0, 1fr) 230px; }
}

@media (max-width: 920px) {
  :root { --sidebar: 0px; }
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    z-index: 20;
    top: 0;
    bottom: 0;
    left: 0;
    width: 226px;
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 20px 0 60px rgba(0, 0, 0, 0.45); }
  .mobile-menu { display: block; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trace-workbench { grid-template-columns: 280px minmax(470px, 1fr); overflow-x: auto; }
  .hero-signal { display: none; }
  .hero-copy { width: 100%; }
  .map-layout { grid-template-columns: 1fr; }
  .node-inspector { display: none; }
}

@media (max-width: 680px) {
  .main-stage { grid-template-rows: 66px minmax(0, 1fr); }
  .topbar { padding-inline: 14px; }
  .topbar-title h1 { font-size: 15px; }
  .eyebrow, .sync-stamp, .ghost-button span:not(.lock-dot) { display: none; }
  .ghost-button { width: 36px; padding: 0; }
  .view { padding: 14px 13px 30px; }
  .hero-strip { min-height: 180px; padding: 22px; }
  .hero-copy h2 { font-size: 25px; }
  .metric-grid { gap: 8px; }
  .metric-card { min-height: 80px; padding: 12px; }
  .metric-card div:nth-child(2) { align-items: flex-start; flex-direction: column; gap: 4px; }
  .metric-card small { margin-top: 0; }
  .trace-workbench { display: block; min-height: 0; overflow: visible; }
  .trace-index-panel { min-height: 430px; height: 55vh; margin-bottom: 12px; }
  .trace-detail-panel, .empty-state, .trace-detail { min-height: 500px; }
  .detail-head { flex-direction: column; }
  .event-item { grid-template-columns: 49px 22px minmax(0, 1fr); }
  .event-item::before { left: 69px; }
  .event-node-id { display: none; }
  .map-view { display: block; overflow: auto; }
  .map-toolbar { align-items: flex-start; flex-direction: column; }
  .map-actions { width: 100%; }
  .replay-button { margin-left: auto; }
  .map-layout { height: 66vh; margin-top: 12px; }
  .map-legend { justify-content: flex-start; margin-top: 12px; }
  .rule-grid { grid-template-columns: 1fr; }
  .matrix-table { overflow-x: auto; }
  .matrix-row { min-width: 650px; }
  .demo-banner { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
