:root {
  --bg-page: #1c1f24;
  --bg-card: #24282e;
  --bg-card-raised: #2b2f36;
  --accent-purple: #9945ff;
  --accent-green: #14f195;
  --text-primary: #f5f5f7;
  --text-secondary: #8a8f98;
  --text-muted: #5f636b;
  --border: #33373e;
  --step-request: #8a8f98;
  --step-challenge: #f2b84a;
  --step-verify: #9945ff;
  --step-reputation: #14f195;
  --step-deliver: #4ac1f2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
}

/* --- Header --- */

#site-header {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 0.5rem;
}

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-shrink: 0;
}

.logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

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

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

.logo-name {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.logo-tagline {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

h2 {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}

.section-caption {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0.25rem 0 0.75rem;
}

/* --- Solscan links --- */

.solscan-link {
  color: var(--accent-green);
  text-decoration: none;
  font-size: inherit;
  white-space: nowrap;
}

.solscan-link:hover {
  text-decoration: underline;
}

/* --- Controls --- */

#controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}

#controls .section-caption {
  margin-bottom: 0;
}

#run-purchase {
  background: var(--accent-purple);
  color: #1c1f24;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

#run-purchase:hover {
  opacity: 0.85;
}

#run-purchase:disabled {
  opacity: 0.5;
  cursor: default;
}

#run-purchase.state-success {
  background: var(--accent-green);
}

#run-purchase.state-error {
  background: #f25c4a;
}

/* --- Highway --- */

#highway {
  position: relative;
  height: 150px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

#highway::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-green));
  opacity: 0.25;
}

.agent-node {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 96px;
  height: 100px;
  border-radius: 14px;
  background: var(--bg-card-raised);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.agent-node:hover {
  border-color: var(--accent-purple);
}

.agent-node .badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-purple);
  color: #1c1f24;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-node .name {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  padding: 0 4px;
}

.agent-node .node-tier {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tx-packet {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  transform: translateY(-50%);
  animation: travel 1.4s linear forwards;
}

@keyframes travel {
  from {
    left: 15%;
    opacity: 1;
  }
  to {
    left: 85%;
    opacity: 0;
  }
}

/* --- Activity feed --- */

#activity-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 320px;
  overflow-y: auto;
}

.activity-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.65rem 1.1rem;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  animation: fadeIn 0.3s ease;
}

.activity-row:last-child {
  border-bottom: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.activity-time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  width: 68px;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-step {
  flex-shrink: 0;
  width: 130px;
  font-weight: 500;
}

.activity-message {
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}

.activity-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

/* --- Leaderboard --- */

#leaderboard-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.lb-row:last-child {
  border-bottom: none;
}

.lb-row:hover {
  background: var(--bg-card-raised);
}

.lb-rank {
  width: 24px;
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
}

.lb-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.lb-tier {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 6px;
}

.lb-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.lb-score {
  text-align: right;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent-green);
}

.lb-score-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* --- Expanded view --- */

#expanded {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

#close-expanded {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 1rem;
}

.stat-card {
  background: var(--bg-card-raised);
  border-radius: 10px;
  padding: 0.75rem;
}

.stat-card .label {
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-card .value {
  font-size: 20px;
  font-weight: 500;
  margin-top: 4px;
  color: var(--accent-purple);
}

.pipeline-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 1.25rem 0 0.5rem;
}

.pipeline {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.pipeline-step {
  background: var(--bg-card-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 13px;
  color: var(--text-secondary);
}
