:root {
  color-scheme: dark;
  --bg: #0b1020;
  --card: #141b2e;
  --card2: #0c1226;
  --fg: #e7ecf5;
  --muted: #8b97ad;
  --line: #24304d;
  --accent: #f6821f;
  --win: #57b6ff;
  --ok: #7ee0a2;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 700px at 50% -10%, #1b2340, var(--bg));
  color: var(--fg);
}

/* topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.brand .sep {
  color: var(--line);
}

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

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.modes {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.mode {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}

.mode.is-on {
  background: var(--card);
  color: var(--fg);
}

.btn {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 16px;
  font: inherit;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #201200;
  font-weight: 600;
}

.tagline {
  margin: 0;
  padding: 14px 22px 0;
  color: var(--muted);
  max-width: 90ch;
}

/* stage */
.stage {
  flex: 1;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* journey row */
.journey {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 2px 14px;
}

.hop {
  position: relative;
  flex: 1 1 0;
  min-width: 150px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 14px 14px;
  color: var(--fg);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.hop:hover {
  border-color: var(--fg);
}

.hop.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.hop.visited {
  border-color: var(--ok);
}

/* The Magic routing table is the "glue" people miss — call it out. */
.hop.is-route {
  background: linear-gradient(180deg, #1c2136, var(--card));
  border-color: #3a4a74;
}

.hop.is-route .hop-title::after {
  content: "magic routing table";
  display: block;
  margin-top: 2px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-transform: uppercase;
}

.hop-num {
  position: absolute;
  top: -10px;
  left: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #201200;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.hop-icon {
  font-size: 26px;
}

.hop-title {
  font-weight: 700;
}

.hop-sub {
  color: var(--muted);
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* connectors */
.link {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--accent);
  flex: 0 0 26px;
}

.link-line {
  display: block;
  width: 18px;
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    var(--accent) 0 4px,
    transparent 4px 7px
  );
}

.link-arrow {
  font-size: 18px;
  line-height: 1;
}

/* moving packet */
.packet {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 5;
}

.packet.done {
  background: var(--ok);
  box-shadow: 0 0 16px var(--ok);
}

/* lower area */
.lower {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

.inspector,
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.inspector h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.ins-stage {
  margin: 0 0 10px;
}

.ins-wire {
  display: block;
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--accent);
  font-size: 0.85rem;
  min-height: 20px;
  word-break: break-word;
}

.panel-hint {
  color: var(--muted);
  margin: 4px 0;
}

.panel-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.panel-icon {
  font-size: 30px;
}

.panel-card h2 {
  margin: 0;
  font-size: 1.15rem;
}

.panel-sub {
  margin: 2px 0 0;
  color: var(--win);
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.panel .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}

.panel .row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.panel .row code {
  color: var(--fg);
  font-size: 0.82rem;
  text-align: right;
}

.panel-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.dash-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card2);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.dash-link:hover {
  border-color: var(--accent);
  background: #1a2136;
}

.dash-where {
  color: var(--muted);
  font-size: 0.76rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.dash-cta {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.86rem;
}

.foot {
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}

@media (max-width: 820px) {
  .lower {
    grid-template-columns: 1fr;
  }
  .journey {
    flex-direction: column;
  }
  .journey .link {
    transform: rotate(90deg);
  }
  .packet {
    display: none;
  }
}
