:root {
  --bg: #000000;
  --ink: #ffffff;
  --muted: #999999;
  --faint: #666666;
  --line: #333333;
  --line-hi: #666666;
  --hover: #111111;
  --mono: ui-monospace, "SF Mono", "IBM Plex Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--mono);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.top {
  width: 100%;
  max-width: 900px;
  padding: 1.5rem 1rem 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.nav-link:hover { color: var(--ink); }

.wordmark {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}
.wordmark span { color: var(--muted); }

main {
  width: 100%;
  max-width: 900px;
  padding: 1.5rem 1rem;
  margin-block: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1rem;
}

.ticket {
  position: relative;
  border: 1px solid var(--line);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 420px;
  flex-shrink: 0;
}

.results[hidden] { display: none; }

.results {
  border: 1px solid var(--line);
  padding: 1rem;
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.pane {
  border: 1px solid var(--line);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.pane:focus-within { border-color: var(--ink); }

.leg-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.leg-row { display: flex; gap: 0.75rem; align-items: center; }

.rate-toggle { display: flex; border: 1px solid var(--line); }
.rate-opt { flex: 1; cursor: pointer; }
.rate-opt input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.rate-opt span {
  display: block;
  padding: 0.45rem;
  text-align: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.rate-opt:hover span { color: var(--ink); }
.rate-opt:has(input:checked) span { background: var(--ink); color: var(--bg); }
.rate-opt:has(input:focus-visible) span { outline: 1px solid var(--ink); outline-offset: -3px; }

input, select, button {
  background: transparent;
  border: none;
  color: var(--ink);
  padding: 0;
  font: 1rem var(--mono);
}

.pane .amount {
  flex: 1;
  min-width: 0;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}
.pane .amount::placeholder { color: var(--faint); }

.token {
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 0.4rem 0.5rem;
  min-width: 7rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.token:hover { border-color: var(--line-hi); }
.token option { background: var(--bg); color: var(--ink); }

input:focus, select:focus { outline: none; }
.token:focus-visible, .addr-input:focus { border-color: var(--ink); }
button:focus-visible, a:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

.addr-input {
  border: 1px solid var(--line);
  padding: 0.5rem;
  font-size: 0.85rem;
  width: 100%;
}
.addr-input:hover { border-color: var(--line-hi); }

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field .leg-label { font-size: 0.68rem; }

.flip-row { display: flex; justify-content: flex-start; }
.flip {
  border: 1px solid var(--line);
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}
.flip:hover { border-color: var(--ink); color: var(--ink); }

.est {
  display: block;
  flex: 1;
  min-width: 0;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quotes { display: flex; flex-direction: column; }

.quote-row.skeleton { cursor: default; }
.sk-bar {
  height: 0.72rem;
  background: var(--line);
  animation: pulse 1.1s ease-in-out infinite;
}
.sk-name { width: 45%; }
.sk-out { width: 4.5rem; justify-self: end; }
.quote-row.skeleton:nth-child(2) .sk-bar { animation-delay: 0.12s; }
.quote-row.skeleton:nth-child(3) .sk-bar { animation-delay: 0.24s; }
.quote-row.skeleton:nth-child(4) .sk-bar { animation-delay: 0.36s; }

@keyframes pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.7; }
}

.quote-row {
  position: relative;
  display: grid;
  grid-template-columns: 1rem 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.quote-row:last-child { border-bottom: none; }
.quote-row:hover { background: var(--hover); }
.quote-row.err { cursor: default; color: var(--faint); }

.quote-row input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.quote-row:has(input:checked) {
  background: var(--ink);
  color: var(--bg);
}
.quote-row:has(input:checked) .q-meta { color: inherit; opacity: 0.6; }

.q-mark {
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0;
}
.quote-row:hover .q-mark { opacity: 0.4; }
.quote-row:has(input:checked) .q-mark { opacity: 1; }

.quote-row > span { min-width: 0; }
.q-name {
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: 0.9rem;
}
.q-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-meta {
  color: var(--faint);
  font-size: 0.72rem;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.q-out { font-size: 0.95rem; text-align: right; white-space: nowrap; }
.q-err { font-size: 0.78rem; color: var(--faint); text-align: right; max-width: 11rem; }

.best-tag {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid currentColor;
  padding: 0 0.25rem;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

a.quote-row { color: var(--ink); text-decoration: none; }
.q-ext { color: var(--muted); font-size: 0.9rem; }

.quote-row.gated { cursor: default; }
.q-key-mark {
  color: var(--faint);
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.q-key-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
}
.q-key-btn {
  border: 1px solid var(--line-hi);
  color: var(--ink);
  padding: 0.25rem 0.45rem;
  font-size: 0.7rem;
  white-space: nowrap;
  cursor: pointer;
}
.q-key-btn:hover { background: var(--ink); color: var(--bg); }
.q-deeplink {
  color: var(--muted);
  font-size: 0.68rem;
  text-decoration: none;
  white-space: nowrap;
}
.q-deeplink:hover { color: var(--ink); text-decoration: underline; }

button[type="submit"] {
  background: var(--ink);
  color: var(--bg);
  padding: 0.7rem;
  font-size: 0.9rem;
  cursor: pointer;
}
button[type="submit"]:hover { background: var(--muted); }
button[type="submit"]:disabled { cursor: wait; }

.ticket.loading::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--ink);
  animation: sweep 1s linear infinite;
}

@keyframes sweep {
  0% { clip-path: inset(0 100% 0 0); }
  50% { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(0 0 0 100%); }
}

.ticket.loading .pane,
.ticket.loading .field { opacity: 0.45; }

.dots { display: inline-block; margin-left: 0.15em; }
.dots i {
  display: inline-block;
  width: 0.32em;
  height: 0.32em;
  margin-left: 0.22em;
  background: currentColor;
  animation: blink 1.2s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

.error {
  border: 1px solid var(--ink);
  padding: 0.5rem;
  font-size: 0.85rem;
}

.key-dialog {
  width: min(400px, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--line-hi);
  background: var(--bg);
  color: var(--ink);
}
.key-dialog::backdrop { background: rgba(0, 0, 0, 0.8); }
.key-form {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.key-dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.key-dialog h2 {
  margin: 0.2rem 0 0;
  font: 1rem/1.3 var(--mono);
}
.key-close {
  color: var(--muted);
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.key-close:hover { color: var(--ink); }
.key-input { width: 100%; }
.key-note {
  margin: 0;
  color: var(--faint);
  font-size: 0.72rem;
  line-height: 1.5;
}
.key-error {
  border: 1px solid var(--ink);
  padding: 0.45rem;
  font-size: 0.78rem;
}
.key-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}
.key-cancel {
  color: var(--muted);
  padding: 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.key-cancel:hover { color: var(--ink); }
.key-save { padding: 0.5rem 0.8rem !important; font-size: 0.8rem !important; }
.key-save:disabled { opacity: 0.5; cursor: wait; }

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

.status-page { display: flex; flex-direction: column; gap: 1.2rem; max-width: 640px; }

.status-line { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }

.badge {
  display: inline-block;
  font-size: 0.8rem;
  border: 1px solid var(--line-hi);
  padding: 0.2rem 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.badge[data-state="completed"] { background: var(--ink); color: var(--bg); }
.badge[data-state="failed"],
.badge[data-state="expired"],
.badge[data-state="refunded"] { color: var(--faint); }

.deposit {
  border: 1px solid var(--ink);
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 1.2rem;
}

.deposit-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.qr-box {
  flex-shrink: 0;
  background: #fff;
  padding: 0.35rem;
  line-height: 0;
}
.qr { width: 132px; height: 132px; display: block; }

.deposit-amount {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.deposit-addr-row { display: flex; align-items: center; gap: 0.7rem; }

.addr {
  font-size: 0.9rem;
  word-break: break-all;
  flex: 1;
}

.copy {
  background: var(--ink);
  color: var(--bg);
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}
.copy:hover { background: var(--muted); }

dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.2rem;
  margin: 0;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
dt { color: var(--muted); }
dd { margin: 0; word-break: break-all; }

.swaps-page {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  max-width: 680px;
}

.swap-list { border: 1px solid var(--line); }

.swap-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.swap-row:last-child { border-bottom: none; }
.swap-row:hover { background: var(--hover); }

.swap-pair { min-width: 0; font-size: 0.9rem; }
.swap-pair strong { font-weight: 400; }
.swap-meta { display: block; color: var(--faint); font-size: 0.72rem; }
.swap-id {
  color: var(--faint);
  font-size: 0.72rem;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.swap-state { text-align: center; }

.back { color: var(--muted); text-decoration: none; font-size: 0.85rem; }
.back:hover { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .ticket.loading::before { animation: none; clip-path: none; }
  .dots i { animation: none; opacity: 1; }
  .sk-bar { animation: none; opacity: 0.4; }
}

@media (max-width: 900px) {
  main { flex-direction: column; align-items: center; }
  .results { width: 100%; max-width: 420px; }
}

@media (max-width: 480px) {
  .deposit { flex-direction: column; align-items: center; }
  .pane .amount, .est { font-size: 1.2rem; }
  .token { min-width: 6rem; }
  .q-meta { display: none; }
}
