/* XCHANGE. Monochrome swap box, sized for X's 480x480 player:
   1rem = 1/30 of the square stage, so 16px inside the card.
   Token logos are the only colour on the page. */
:root {
  --bg: #000;
  --panel: #0e0e0e;
  --panel-2: #161616;
  --line: #262626;
  --line-2: #3a3a3a;
  --mute: #8a8a8a;
  --dim: #5c5c5c;
  --fg: #fff;
  --side: min(100vw, 100vh, 640px);
  font-size: calc(var(--side) / 30);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body {
  display: flex; align-items: center; justify-content: center;
  font-family: 'Geist', system-ui, sans-serif; color: var(--fg);
  font-size: 0.875rem; line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1;
}
button, input, output { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 1.5px solid var(--fg); outline-offset: 2px; }
::selection { background: var(--fg); color: var(--bg); }

#stage { width: var(--side); height: var(--side); padding: 0.6rem; display: flex; }

.box {
  position: relative; flex: 1; display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--line); border-radius: 1.1rem;
  padding: 0.9rem 0.9rem 0.9rem;
  overflow: hidden;
}

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; height: 1.5rem; padding: 0 0.2rem; margin-bottom: 0.65rem; }
.mark { display: flex; align-items: center; gap: 0.5rem; color: var(--fg); text-decoration: none; }
.mark svg { width: 0.95rem; height: 0.95rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: square; }
.mark span { font-weight: 700; font-size: 0.95rem; letter-spacing: 0.14em; }
.route-id { font-size: 0.72rem; color: var(--mute); }

/* Plan */
#plan { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.panels { position: relative; display: flex; flex-direction: column; gap: 0.25rem; }
.leg {
  background: var(--panel); border: 1px solid var(--line); border-radius: 0.8rem;
  padding: 0.6rem 0.75rem 0.7rem;
  transition: border-color .15s;
}
.leg:focus-within { border-color: var(--line-2); }
.leg-head { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--mute); }
.usd { color: var(--dim); }
.leg-row { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.25rem; }
.amt {
  flex: 1; min-width: 0; width: 100%;
  font-weight: 500; font-size: 1.95rem; line-height: 1.15; letter-spacing: -0.035em;
  background: none; border: 0; padding: 0; outline: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.amt::placeholder { color: var(--dim); }
.amt.est { color: var(--fg); }
.amt.loading { color: var(--dim); }

.pick {
  flex: none; display: flex; align-items: center; gap: 0.45rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 2rem;
  padding: 0.28rem 0.6rem 0.28rem 0.28rem; text-align: left;
  transition: border-color .15s, background .15s;
}
.pick:hover { border-color: var(--line-2); background: #1c1c1c; }
.pick img { width: 1.55rem; height: 1.55rem; border-radius: 50%; background: var(--line); flex: none; }
.pick img:not([src]) { visibility: hidden; }
.pick-txt { display: flex; flex-direction: column; }
.pick-sym { font-weight: 600; font-size: 0.88rem; line-height: 1.1; }
.pick-chain { font-size: 0.66rem; color: var(--mute); line-height: 1.15; }
.chev { width: 0.75rem; height: 0.75rem; fill: none; stroke: var(--mute); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; margin-left: 0.1rem; }

.flip {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1;
  width: 2rem; height: 2rem; border-radius: 0.6rem;
  background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center;
  transition: border-color .15s, transform .25s;
}
.flip svg { width: 0.9rem; height: 0.9rem; fill: none; stroke: var(--fg); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.flip:hover { border-color: var(--line-2); }
.flip:active { transform: translate(-50%, -50%) rotate(180deg); }

.addr {
  display: flex; align-items: center; gap: 0.6rem; margin-top: 0.45rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 0.8rem;
  padding: 0.55rem 0.75rem;
}
.addr[hidden] { display: none; }
.addr span { flex: none; width: 4.4rem; font-size: 0.72rem; color: var(--mute); }
.addr input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 0; font-size: 0.8rem; }
.addr input::placeholder { color: var(--dim); }
.addr:focus-within { border-color: var(--line-2); }
.addr.bad { border-color: var(--fg); }

.act { margin-top: auto; padding-top: 0.6rem; }
.meta-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.55rem; padding: 0 0.2rem; }
.meta { margin: 0; font-size: 0.72rem; color: var(--mute); min-height: 1.1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta b { color: var(--fg); font-weight: 500; }
.ghost { flex: none; background: none; border: 0; padding: 0; font-size: 0.72rem; color: var(--mute); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 0.2em; }
.ghost:hover { color: var(--fg); text-decoration-color: var(--fg); }
.go {
  width: 100%; background: var(--fg); color: var(--bg); border: 0; border-radius: 0.8rem;
  padding: 0.85rem 1rem; font-weight: 600; font-size: 0.95rem; letter-spacing: -0.01em;
  transition: opacity .15s;
}
.go:hover:not(:disabled) { opacity: .88; }
.go:disabled { background: var(--panel-2); color: var(--dim); cursor: default; }
.go.busy { opacity: .6; }

/* Deposit screen */
#pass { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#pass[hidden], #plan[hidden] { display: none; }
.pass-top { display: flex; gap: 0.9rem; }
.qr-wrap { flex: none; width: 8.6rem; height: 8.6rem; background: #fff; border-radius: 0.8rem; padding: 0.55rem; }
.qr { display: block; width: 100%; height: 100%; }
.pass-send { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lbl { font-size: 0.72rem; color: var(--mute); }
.pass-amt { margin: 0.1rem 0 0; font-size: 1.9rem; line-height: 1.05; letter-spacing: -0.035em; overflow-wrap: anywhere; }
.pass-amt b { font-weight: 600; }
.pass-amt span { font-weight: 500; font-size: 1.1rem; letter-spacing: 0; color: var(--mute); }
.pass-chain { margin: 0.15rem 0 0; font-size: 0.78rem; color: var(--mute); }
.pass-chain span { color: var(--fg); font-weight: 500; }
.dep {
  margin-top: auto; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 0.6rem;
  padding: 0.45rem 0.55rem; font-size: 0.7rem; line-height: 1.35; word-break: break-all;
  transition: border-color .15s;
}
.dep:hover { border-color: var(--line-2); }
.copied { font-size: 0.68rem; color: var(--mute); min-height: 1.1em; margin-top: 0.25rem; }

.pass-note { margin: 0.75rem 0.2rem 0; font-size: 0.74rem; color: var(--mute); }

.voyage {
  list-style: none; margin: auto 0 0; padding: 0.75rem 0.75rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 0.8rem;
  display: grid; gap: 0.6rem; position: relative;
}
.voyage li { position: relative; display: grid; grid-template-columns: 0.75rem 1fr auto; align-items: center; gap: 0.65rem; color: var(--dim); font-size: 0.82rem; }
.voyage li + li::before {
  content: ''; position: absolute; left: calc(0.375rem - 0.5px); top: -0.6rem; height: 0.6rem; width: 1px; background: var(--line-2);
}
.voyage .dot { width: 0.75rem; height: 0.75rem; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--panel); }
.voyage li.now { color: var(--fg); font-weight: 500; }
.voyage li.now .dot { border-color: var(--fg); box-shadow: inset 0 0 0 2px var(--panel), inset 0 0 0 6px var(--fg); animation: pulse 1.8s ease-in-out infinite; }
.voyage li.done { color: var(--mute); }
.voyage li.done .dot { border-color: var(--fg); background: var(--fg); }
.voyage li.bad { color: var(--fg); font-weight: 500; }
.voyage li.bad .dot { border-color: var(--fg); background: repeating-linear-gradient(45deg, var(--fg) 0 1.5px, transparent 1.5px 3.5px); }
.v-l { font-size: 0.7rem; color: var(--mute); }
.v-l:hover { color: var(--fg); }
.v-l:not([href]) { display: none; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .voyage li.now .dot { animation: none; } .flip:active { transform: translate(-50%, -50%); } }

.pass-foot { margin: 0.6rem 0.2rem 0; display: flex; align-items: baseline; gap: 0.9rem; font-size: 0.7rem; color: var(--mute); }
.pass-foot span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pass-foot a { color: var(--mute); }
.pass-foot a:hover { color: var(--fg); }

/* Token picker */
.sheet { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; padding: 0.9rem 0.9rem 0; z-index: 5; }
.sheet[hidden] { display: none; }
.sheet-head { display: flex; gap: 0.8rem; align-items: center; }
.sheet-head input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--panel); border-radius: 0.7rem; padding: 0.6rem 0.75rem; font-size: 0.85rem; outline: none; }
.sheet-head input::placeholder { color: var(--dim); }
.sheet-head input:focus { border-color: var(--line-2); }
.sheet-body { flex: 1; min-height: 0; display: flex; gap: 0.6rem; margin-top: 0.7rem; }
.sheet ul { list-style: none; margin: 0; padding: 0 0 0.8rem; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.chains { flex: none; width: 8.2rem; border-right: 1px solid var(--line); padding-right: 0.6rem !important; }
.chains button, .tokens button { width: 100%; text-align: left; background: none; border: 0; border-radius: 0.55rem; padding: 0.45rem 0.55rem; }
.chains button { font-size: 0.8rem; color: var(--mute); }
.chains button[aria-pressed="true"] { background: var(--fg); color: var(--bg); font-weight: 500; }
.chains button:hover:not([aria-pressed="true"]) { background: var(--panel-2); color: var(--fg); }
.tokens { flex: 1; min-width: 0; }
.tokens button { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr) auto; gap: 0.6rem; align-items: center; }
.tokens button:hover { background: var(--panel-2); }
.tokens img { width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--line); }
.tokens b { font-weight: 600; font-size: 0.85rem; display: block; }
.tokens small { color: var(--mute); font-size: 0.68rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tokens .px { font-size: 0.7rem; color: var(--mute); }
.tokens .empty { color: var(--mute); font-size: 0.8rem; padding: 0.55rem; }

.toast {
  position: absolute; left: 0.9rem; right: 0.9rem; bottom: 4.4rem; margin: 0;
  background: var(--fg); color: var(--bg); border-radius: 0.7rem; padding: 0.6rem 0.8rem; font-size: 0.78rem; font-weight: 500; z-index: 6;
}
.toast[hidden] { display: none; }

.quote { margin: 0.7rem 0.2rem 0; display: grid; gap: 0.32rem; font-size: 0.74rem; }
.quote[hidden] { display: none; }
.quote div { display: flex; justify-content: space-between; gap: 1rem; }
.quote dt { color: var(--mute); }
.quote dd { margin: 0; color: var(--fg); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
