:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1b1b1f;
  --muted: #6b6b75;
  --line: #e4e2dc;
  --accent: #2a2a8f;
  --accent-ink: #ffffff;
  --ok: #1d7a46;
  --bad: #b3261e;
  --warn-bg: #fff4d6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141418;
    --card: #1e1e24;
    --ink: #ececf1;
    --muted: #9a9aa6;
    --line: #2e2e36;
    --accent: #8f8fff;
    --accent-ink: #101014;
    --ok: #5ccf8b;
    --bad: #ff8a80;
    --warn-bg: #3a3218;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
}

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

.shell {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
}

nav a {
  margin-left: 16px;
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}

h1 {
  font-size: 22px;
  margin: 0 0 8px;
}

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

.small {
  font-size: 13px;
}

.error {
  color: var(--bad);
}

.banner {
  background: var(--warn-bg);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.wallets {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

button {
  font: inherit;
  cursor: pointer;
}

button.wallet {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
}

button.wallet img {
  width: 24px;
  height: 24px;
}

button.primary {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

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

button.link {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0;
  font-size: 14px;
}

.field {
  display: grid;
  gap: 6px;
  margin: 16px 0 6px;
}

.field span {
  font-size: 14px;
  color: var(--muted);
}

.field input {
  font: inherit;
  font-size: 28px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  width: 100%;
}

.quote {
  margin-top: 18px;
  min-height: 92px;
  display: grid;
  gap: 4px;
}

.quote .big {
  font-size: 20px;
  font-weight: 600;
}

.row {
  margin-bottom: 4px;
}

ol.stages {
  list-style: none;
  padding: 0;
  margin: 18px 0;
  display: grid;
  gap: 12px;
}

ol.stages li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-left: 26px;
  position: relative;
}

ol.stages li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
}

ol.stages li.done::before {
  background: var(--ok);
  border-color: var(--ok);
}

ol.stages li.active::before {
  border-color: var(--accent);
  border-top-color: transparent;
  animation: spin 0.9s linear infinite;
}

ol.stages li.failed::before {
  background: var(--bad);
  border-color: var(--bad);
}

ol.stages li.todo {
  color: var(--muted);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

footer {
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

/* Buy / Sell NIGHT */
.toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.toggle button {
  padding: 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.toggle button.on {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ?embed=1: inside an app's iframe (embed.js). The page keeps its own background: an
   iframe whose color scheme differs from the host's is painted opaque anyway. */
body.embed .shell {
  padding: 12px;
}

body.embed header {
  margin-bottom: 10px;
}

body.embed .card {
  padding: 18px;
}

body.embed footer {
  margin-top: 10px;
  text-align: center;
}

/* /regression */
.shell.wide {
  max-width: 920px;
}

table.regression {
  width: 100%;
  margin-top: 18px;
  border-collapse: collapse;
  font-size: 14px;
}

table.regression th,
table.regression td {
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

table.regression th,
table.regression td.num,
table.regression td.result {
  white-space: nowrap;
  overflow-wrap: normal;
}

table.regression td.num {
  font-variant-numeric: tabular-nums;
}

table.regression td.result {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
}

table.regression tr.pass td.result {
  color: var(--ok);
}

table.regression tr.fail td.result {
  color: var(--bad);
}

table.regression tr.running td.result {
  color: var(--accent);
}

table.regression tr.skip td,
table.regression tr.todo td {
  color: var(--muted);
}

main.doc {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 16px;
}

table.status td {
  padding: 4px 10px 4px 0;
}
