:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #151922;
  --border: #262c38;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --accent: #2f8af5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header,
nav,
main {
  max-width: 1080px;
  margin: 0 auto;
}

header {
  padding: 32px 24px 8px;
}

header h1 {
  margin: 0 0 4px;
  font-size: 26px;
}

header p,
.note {
  margin: 0;
  color: var(--muted);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 24px 0;
}

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

nav a[aria-current="page"] {
  color: var(--text);
}

main {
  padding: 24px;
}

main.embed {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px;
}

main.stack {
  display: grid;
  gap: 24px;
}

.compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

#status-note,
#rate-limit {
  border: 1px solid var(--border);
  padding: 12px 16px;
  margin: 0 0 16px;
}

main.headless-layout,
main.bridge-layout {
  display: grid;
  gap: 24px;
  max-width: 1200px;
  min-width: 0;
}

.headless-notes,
.bridge-notes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.galaxy-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 280px);
  gap: 16px;
  align-items: stretch;
  min-width: 0;
  width: 100%;
}

@media (min-width: 960px) {
  .galaxy-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

@media (max-width: 900px) {
  main.embed,
  .compare,
  .headless-notes,
  .bridge-notes,
  .galaxy-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 20px;
  min-width: 0;
  max-width: 100%;
}

.panel + .panel {
  margin-top: 24px;
}

.panel h2,
.panel h3 {
  margin: 16px 0 8px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.panel h2:first-child,
.panel > h2:first-child {
  margin-top: 0;
}

.panel h3 {
  font-size: 13px;
}

#swap {
  min-height: 480px;
}

.meta,
.panel p {
  font-size: 14px;
}

.meta {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
}

.meta code,
.panel code {
  color: var(--text);
  background: #0b0d12;
  padding: 2px 6px;
}

label {
  display: block;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}

input,
select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  background: #0b0d12;
  color: var(--text);
  font: inherit;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

pre {
  background: #0b0d12;
  border: 1px solid var(--border);
  padding: 14px;
  overflow: auto;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 12.5px;
  color: #cbd3e1;
}

ul.pros {
  margin: 0;
  padding-left: 18px;
}

ul.pros li {
  margin: 0 0 8px;
}

ul#event-log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow: auto;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

ul#event-log li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.galaxy-stage {
  position: relative;
  min-width: 0;
  max-width: 100%;
  min-height: 640px;
  height: 640px;
  background: #05070b;
  overflow: hidden;
  border: 1px solid #143044;
}

.galaxy-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.galaxy-fallback canvas {
  display: none;
}

.route-plane {
  position: static;
  max-height: 220px;
  overflow: auto;
  overflow-x: hidden;
  margin-top: 8px;
  padding: 8px;
  background: #f4f6f8;
  border: 1px solid #d5dbe3;
  color: #1c2430;
  pointer-events: auto;
}

.route-star {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.route-star-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #f4efe6;
  font-size: 10px;
}

.route-star-icon svg {
  position: absolute;
  inset: 0;
  width: 28px;
  height: 28px;
}

.route-star-icon img,
.route-star-icon span {
  position: relative;
  z-index: 1;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.route-star-symbol {
  margin-top: 2px;
  color: #f7f1e6;
  font-size: 11px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.lane {
  position: relative;
  margin: 0 0 8px;
  padding: 6px 8px 8px;
}

.lane-title,
.galaxy-illustration {
  margin: 8px 0 0;
  color: #c8bfae;
  font-size: 12px;
}

.token-unverified {
  display: block;
  margin-top: 4px;
  color: #e4d3a4;
  font-size: 12px;
}

.galaxy-ship-legend,
.route-tip {
  margin: 0;
  color: #1c2430;
  font-size: 12px;
}

.lane-fusion {
  border: 1px solid rgba(126, 182, 255, 0.28);
}

.ship-row {
  min-height: 12px;
  margin: 4px 0;
}

.ship {
  display: inline-block;
  width: 28px;
  height: 14px;
  margin: 0 4px 0 0;
  vertical-align: middle;
}

.ship svg {
  display: block;
  width: 28px;
  height: 14px;
}

.route-arcs {
  display: block;
  width: 100%;
  height: 168px;
}

.route-token-disc {
  fill: #e7edf3;
  stroke: #243040;
  stroke-width: 1;
}

.route-symbol,
.route-monogram {
  fill: #1c2430;
  font-size: 11px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

.route-monogram {
  font-size: 9px;
}

.route-arc {
  pointer-events: stroke;
}

.route-arc-hit {
  pointer-events: stroke;
}

.lane-classic .route-arc:not(.route-arc-hit) {
  stroke: #e7b56a;
}

.lane-fusion .route-arc:not(.route-arc-hit) {
  stroke: #9eb4c8;
}

.route-arc-hit {
  stroke: transparent;
}

.route-details {
  pointer-events: auto;
  margin-top: 6px;
  color: #e4d3a4;
  font-size: 12px;
}

.route-details[open] {
  max-height: 210px;
  overflow: auto;
}

.route-details summary {
  cursor: pointer;
}

.route-tip {
  min-height: 1.2em;
}

@media (prefers-reduced-motion: no-preference) {
  .lane-classic .ship-pirate[data-role="pirate"] {
    animation: pirate-drift 8s linear infinite;
  }
}

@keyframes pirate-drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(10px);
  }
}

.galaxy-legend {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 6;
  max-width: calc(100% - 24px);
  overflow: visible;
  pointer-events: auto;
}

.galaxy-readout-panel {
  max-width: 100%;
  padding: 12px 14px;
  background: rgba(16, 24, 32, 0.88);
  border: 1px solid rgba(180, 198, 214, 0.18);
}

.galaxy-icons,
.galaxy-labels {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.galaxy-icons {
  z-index: 2;
}

.galaxy-labels {
  z-index: 4;
}

.galaxy-icon {
  position: absolute;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  opacity: 0.2;
  background: transparent;
}

.galaxy-icon.is-shown {
  opacity: 1;
}

.galaxy-icon img {
  display: block;
  width: 22px;
  height: 22px;
  opacity: 0.9;
}

.galaxy-monogram {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  background: rgba(8, 12, 18, 0.28);
  color: #7e90a4;
  font-size: 8px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  opacity: 0.58;
}

.galaxy-label {
  color: #e7eef4;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: auto;
  background: transparent;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.galaxy-label-chain {
  z-index: 5;
  font-size: 13px;
  color: #f7f4ea;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
}

.galaxy-label-dex {
  color: #e4d3a4;
}

.galaxy-tooltip {
  position: absolute;
  z-index: 4;
  max-width: 220px;
  padding: 8px 10px;
  background: rgba(16, 24, 32, 0.94);
  border: 1px solid rgba(180, 198, 214, 0.22);
  color: #e7eef4;
  pointer-events: none;
}

.galaxy-tooltip p {
  margin: 0;
  font-size: 12px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

.galaxy-tooltip-symbol {
  font-size: 13px;
}

.galaxy-hud {
  padding: 12px;
  border: 1px solid #1c6a7a;
  background: rgba(4, 12, 18, 0.94);
  box-shadow: inset 0 0 24px rgba(126, 249, 255, 0.08);
}

.galaxy-hud label {
  margin-bottom: 8px;
}

.token-field {
  position: relative;
}

.token-suggest {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  max-height: 240px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  background: #0b0d12;
  border: 1px solid var(--border);
  color: var(--text);
}

.token-suggest li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  cursor: pointer;
}

.token-suggest li[aria-selected="true"] {
  background: #14202a;
}

.token-suggest img,
.token-suggest .token-mark {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  object-fit: contain;
}

.token-suggest .token-mark {
  display: grid;
  place-items: center;
  background: #14202a;
  color: #e7eef4;
  font-size: 10px;
}

.token-suggest .token-symbol {
  color: var(--text);
}

.token-suggest .token-name,
.token-suggest .token-address {
  color: var(--muted);
  font-size: 12px;
}

.galaxy-status,
.galaxy-readout,
#route-hops {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

.galaxy-status {
  margin: 0 0 6px;
  color: #d7e4f0;
  font-size: 13px;
  letter-spacing: 0.04em;
  background: transparent;
}

.galaxy-readout {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 6px;
  color: #e7eef4;
  font-size: 18px;
  background: transparent;
}

.galaxy-readout span,
#dst-count,
#route-hops,
.galaxy-status {
  background: transparent;
}

.quote-headline,
#dst-count,
#fusion-count {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.2;
  color: #f5f8fb;
}

#route-hops {
  min-height: 1.2em;
  max-width: 100%;
  margin: 0;
  color: #e4d3a4;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.galaxy-stage[data-phase="fetching"] {
  box-shadow: inset 0 0 48px rgba(120, 150, 170, 0.16);
}

.galaxy-stage[data-phase="success"] {
  box-shadow: inset 0 0 40px rgba(140, 170, 190, 0.14);
}

.galaxy-stage[data-phase="success"] #dst-count {
  color: #f5f8fb;
}

.galaxy-stage[data-phase="error"] {
  box-shadow: inset 0 0 48px rgba(120, 48, 58, 0.28);
}

.galaxy-stage[data-phase="error"] .galaxy-status,
.galaxy-stage[data-phase="error"] #dst-count {
  color: #ffc1c8;
}

.galaxy-stage[data-phase="unavailable"] {
  box-shadow: inset 0 0 48px rgba(160, 110, 40, 0.24);
}

.galaxy-stage[data-phase="unavailable"] .galaxy-status {
  color: #ffe0ad;
  font-size: 18px;
}

.galaxy-stage[data-phase="fence"] {
  box-shadow: inset 0 0 0 2px #d7e4f0;
}

.galaxy-stage[data-phase="fence"] .galaxy-status {
  color: #f5f8fb;
  font-size: 18px;
}

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

@media (prefers-reduced-motion: reduce) {
  .galaxy-icon {
    opacity: 1;
  }
}

.skin-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.skin-output {
  min-height: 4.5em;
  margin: 0 0 16px;
}

.skin-line {
  white-space: pre-wrap;
}

.skin-line.is-pending {
  opacity: 0;
}

.skin-history,
.till-head,
.hud-brackets {
  display: none;
}

#bridge-stage[data-skin="terminal"] {
  background: #000000;
  color: #39ff6a;
  border-color: #0c3d1c;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  box-shadow: inset 0 0 90px rgba(57, 255, 106, 0.12);
}

#bridge-stage[data-skin="terminal"] .meta,
#bridge-stage[data-skin="terminal"] label,
#bridge-stage[data-skin="terminal"] h2 {
  color: #1f8a45;
}

#bridge-stage[data-skin="terminal"] input,
#bridge-stage[data-skin="terminal"] pre,
#bridge-stage[data-skin="terminal"] code {
  background: #000000;
  color: #39ff6a;
  border-color: #1d5c32;
  font-family: inherit;
}

#bridge-stage[data-skin="terminal"] button {
  background: #03150a;
  color: #39ff6a;
  border: 1px solid #39ff6a;
  box-shadow: 0 0 10px rgba(57, 255, 106, 0.35);
}

#bridge-stage[data-skin="terminal"] .skin-history {
  display: block;
  margin: 0 0 8px;
  color: #146b32;
  font-size: 13px;
  min-height: 2.4em;
}

#bridge-stage[data-skin="terminal"] #skin-output {
  min-height: 7rem;
  padding: 12px;
  background: #000000;
  color: #39ff6a;
  border: 1px solid #145c2c;
  text-shadow: 0 0 8px #39ff6a;
  box-shadow: inset 0 0 24px rgba(57, 255, 106, 0.08);
}

#bridge-stage[data-skin="terminal"] .skin-line {
  overflow: hidden;
  animation: terminal-type 0.75s steps(24, end);
}

#bridge-stage[data-skin="terminal"] #skin-output::after {
  content: "▋";
  margin-left: 4px;
  color: #39ff6a;
  text-shadow: 0 0 8px #39ff6a;
  animation: phosphor-cursor 1.05s steps(1, end) infinite;
}

#bridge-stage[data-skin="hud"] {
  position: relative;
  background: #070014;
  color: #7ef9ff;
  border: 1px solid transparent;
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
  letter-spacing: 0.14em;
  box-shadow:
    0 0 28px rgba(126, 249, 255, 0.45),
    inset 0 0 48px rgba(255, 79, 216, 0.22);
}

#bridge-stage[data-skin="hud"]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.22),
    rgba(0, 0, 0, 0.22) 1px,
    transparent 1px,
    transparent 3px
  );
}

#bridge-stage[data-skin="hud"] .hud-brackets {
  display: block;
  position: absolute;
  inset: 10px;
  z-index: 4;
  pointer-events: none;
}

#bridge-stage[data-skin="hud"] .hud-brackets span {
  position: absolute;
  width: 36px;
  height: 36px;
  border: 2px solid #7ef9ff;
  box-shadow: 0 0 12px #7ef9ff;
}

#bridge-stage[data-skin="hud"] .hud-brackets span:nth-child(1) {
  top: 0;
  left: 0;
  border-right: 0;
  border-bottom: 0;
}

#bridge-stage[data-skin="hud"] .hud-brackets span:nth-child(2) {
  top: 0;
  right: 0;
  border-left: 0;
  border-bottom: 0;
  box-shadow: 0 0 12px #ff4fd8;
  border-color: #ff4fd8;
}

#bridge-stage[data-skin="hud"] .hud-brackets span:nth-child(3) {
  bottom: 0;
  left: 0;
  border-right: 0;
  border-top: 0;
  box-shadow: 0 0 12px #ff4fd8;
  border-color: #ff4fd8;
}

#bridge-stage[data-skin="hud"] .hud-brackets span:nth-child(4) {
  right: 0;
  bottom: 0;
  border-left: 0;
  border-top: 0;
}

#bridge-stage[data-skin="hud"] .meta,
#bridge-stage[data-skin="hud"] label,
#bridge-stage[data-skin="hud"] h2 {
  color: #ff4fd8;
  text-shadow: 0 0 10px rgba(255, 79, 216, 0.8);
}

#bridge-stage[data-skin="hud"] input,
#bridge-stage[data-skin="hud"] pre,
#bridge-stage[data-skin="hud"] code {
  background: rgba(8, 0, 20, 0.88);
  color: #e8ffff;
  border-color: #7ef9ff;
  font-family: inherit;
  box-shadow: 0 0 12px rgba(126, 249, 255, 0.35);
}

#bridge-stage[data-skin="hud"] button {
  background: transparent;
  color: #7ef9ff;
  border: 1px solid #7ef9ff;
  box-shadow: 0 0 14px rgba(126, 249, 255, 0.7);
  text-shadow: 0 0 8px #7ef9ff;
}

#bridge-stage[data-skin="hud"] h2,
#bridge-stage[data-skin="hud"] #skin-output {
  text-transform: uppercase;
}

#bridge-stage[data-skin="hud"] #skin-output {
  position: relative;
  z-index: 1;
  min-height: 7rem;
  padding: 18px 8px;
  font-size: 42px;
  line-height: 1.15;
  color: #ff4fd8;
  text-shadow:
    0 0 12px #ff4fd8,
    0 0 28px #7ef9ff;
}

#bridge-stage[data-skin="receipt"] {
  background-color: #f4ecdc;
  background-image:
    radial-gradient(rgba(90, 70, 40, 0.16) 0.6px, transparent 0.7px),
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(90, 70, 40, 0.04) 4px),
    linear-gradient(#f7f1e6, #efe4d2);
  background-size:
    5px 5px,
    auto,
    auto;
  color: #1a120c;
  border: 0;
  border-top: 2px dashed #1a120c;
  border-bottom: 2px dashed #1a120c;
  font-family: "Courier New", Courier, ui-monospace, monospace;
  box-shadow: 0 14px 0 #e4d7c2;
}

#bridge-stage[data-skin="receipt"] .till-head {
  display: block;
  margin: 8px 0 12px;
  padding: 8px 0;
  text-align: center;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  border-top: 2px dashed #1a120c;
  border-bottom: 2px dashed #1a120c;
}

#bridge-stage[data-skin="receipt"] .meta,
#bridge-stage[data-skin="receipt"] label,
#bridge-stage[data-skin="receipt"] h2 {
  color: #5c5146;
}

#bridge-stage[data-skin="receipt"] input,
#bridge-stage[data-skin="receipt"] pre,
#bridge-stage[data-skin="receipt"] code {
  background: #fffaf2;
  color: #1a120c;
  border-color: #c9bfae;
  font-family: "Courier New", Courier, ui-monospace, monospace;
}

#bridge-stage[data-skin="receipt"] button {
  background: #1c140c;
  color: #f4efe4;
}

#bridge-stage[data-skin="receipt"] #skin-output {
  min-height: 5rem;
  padding: 8px 0 12px;
  font-size: 22px;
  letter-spacing: 0.04em;
  border-bottom: 2px dashed #1a120c;
}

@keyframes terminal-type {
  from {
    clip-path: inset(0 100% 0 0);
  }

  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes phosphor-cursor {
  50% {
    opacity: 0;
  }
}

@keyframes receipt-print {
  from {
    max-height: 0;
  }

  to {
    max-height: 16rem;
  }
}

#bridge-stage[data-skin="receipt"] #skin-output.is-printing {
  overflow: hidden;
  animation: receipt-print 1.2s steps(16, end);
}

@media (prefers-reduced-motion: reduce) {
  #bridge-stage[data-skin="receipt"] #skin-output.is-printing {
    animation: none;
    max-height: none;
  }

  .skin-line.is-pending {
    opacity: 1;
  }

  #bridge-stage[data-skin="terminal"] .skin-line,
  #bridge-stage[data-skin="terminal"] #skin-output::after {
    animation: none;
  }
}
