:root {
  --bg: #0b1030;
  --ink: #e9ece8;
  --ink-2: #a7aecb;
  --ink-3: #6f7799;
  --line: rgba(200, 210, 255, 0.11);
  --accent: #7cf5c8;
  --accent-dim: rgba(124, 245, 200, 0.14);
  --font-ui: 'Geist', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-xl: clamp(2rem, 1.4rem + 2.6vw, 3.25rem);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(1100px 700px at 88% -10%, rgba(153, 69, 255, 0.30), transparent 60%),
    radial-gradient(900px 640px at -5% 105%, rgba(20, 241, 149, 0.16), transparent 60%),
    radial-gradient(800px 600px at 50% 55%, rgba(60, 90, 220, 0.18), transparent 70%),
    linear-gradient(180deg, #111640 0%, #0b1030 55%, #0a0d27 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#field {
  position: fixed; inset: 0; width: 100%; height: 100%;
  transition: opacity 1.2s var(--ease), filter 1.2s var(--ease), transform 1.6s var(--ease);
}

/* spider layer */
#web { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }

/* top bar */
.top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: max(20px, env(safe-area-inset-top)) clamp(20px, 4vw, 40px) 0;
  z-index: 3;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: var(--text-sm); letter-spacing: 0.01em; }
.mark { width: 26px; height: 26px; color: var(--accent); }
.live {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-2);
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(7, 8, 10, 0.5); backdrop-filter: blur(8px);
}
.live i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.live.on i { background: var(--accent); box-shadow: 0 0 0 0 var(--accent-dim); animation: ping 2.4s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(124,245,200,.45); } 70%, 100% { box-shadow: 0 0 0 7px rgba(124,245,200,0); } }

/* HUD */
.hud {
  position: fixed; z-index: 2;
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-3);
  transition: opacity 0.8s var(--ease);
  font-variant-numeric: tabular-nums;
}
.hud-tr { top: 84px; right: clamp(20px, 4vw, 40px); text-align: right; }
.hud-bl { bottom: max(28px, env(safe-area-inset-bottom)); left: clamp(20px, 4vw, 40px); width: 240px; }
.hud-label { color: var(--ink-3); margin-bottom: 8px; letter-spacing: 0.04em; }
.hud-label.mt { margin-top: 18px; }
.matrix { display: grid; grid-template-columns: repeat(3, 7ch); gap: 4px 14px; justify-content: end; color: var(--ink-2); }
.matrix span { transition: color 0.4s; }
.matrix span.hot { color: var(--ink); }
.spectrum { display: flex; gap: 3px; justify-content: flex-end; align-items: flex-end; height: 28px; }
.spectrum i { width: 4px; background: var(--ink-3); border-radius: 1px; transition: height 0.6s var(--ease); }
.spectrum i:first-child { background: var(--accent); opacity: 0.8; }
#spark { width: 240px; height: 48px; display: block; margin-bottom: 10px; }
.hud-bl .row { display: flex; justify-content: space-between; padding: 3px 0; border-top: 1px solid var(--line); }
.hud-bl .row b { font-weight: 400; color: var(--ink-2); }

.brand-sub { color: var(--ink-3); font-weight: 400; margin-left: -4px; }
.brand-sub::before { content: '/'; margin-right: 6px; color: var(--ink-3); opacity: .6; }

/* stage + card */
.stage {
  position: fixed; inset: 0; z-index: 4;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 104px 20px 48px;
}
.card {
  width: min(520px, 100%);
  padding: clamp(24px, 4vw, 36px);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(20, 26, 66, 0.78), rgba(12, 16, 44, 0.86));
  border: 1px solid rgba(124, 245, 200, 0.14);
  box-shadow: 0 24px 60px -28px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,0.02) inset, 0 0 80px -40px rgba(124,245,200,.35);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  animation: in 0.9s var(--ease) both;
}
@keyframes in { from { opacity: 0; transform: translateY(20px) scale(0.98); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
.step { display: flex; flex-direction: column; gap: 18px; }
.step[hidden] { display: none; }
.eyebrow { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--accent); letter-spacing: 0.06em; text-transform: uppercase; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.5rem); font-weight: 600; letter-spacing: -0.025em; line-height: 1.08; margin-top: -8px; }
.lede { color: var(--ink-2); font-size: var(--text-sm); line-height: 1.55; margin-top: -6px; }

/* fields */
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: var(--text-xs); color: var(--ink-2); font-weight: 500; letter-spacing: 0.01em; }
.label em { font-style: normal; color: var(--ink-3); font-weight: 400; margin-left: 4px; }
input, select {
  width: 100%; appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,0.035); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; font: 400 var(--text-sm) var(--font-ui);
  transition: border-color .2s, background .2s, box-shadow .2s;
  color-scheme: dark;
}
#ca { font-family: var(--font-mono); font-size: 0.875rem; letter-spacing: -0.01em; }
input::placeholder { color: var(--ink-3); }
input:hover, select:hover { border-color: rgba(233,236,232,0.16); }
input:focus, select:focus { outline: none; border-color: rgba(124,245,200,0.5); background: rgba(124,245,200,0.04); box-shadow: 0 0 0 3px rgba(124,245,200,0.10); }
input.bad { border-color: rgba(255,122,110,0.6); }
.select-wrap { position: relative; }
.select-wrap select { padding-right: 40px; cursor: pointer; font-weight: 500; }
.select-wrap svg { position: absolute; right: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--ink-2); pointer-events: none; }
select option { background: #141a44; color: var(--ink); }
.hint { font-size: var(--text-xs); color: var(--ink-3); }
.err { font-size: var(--text-xs); color: #ff8a7e; }
.coin { display: flex; align-items: center; gap: 10px; font-size: var(--text-xs); color: var(--ink-2); padding: 8px 10px; border-radius: 10px; background: rgba(124,245,200,0.05); border: 1px solid rgba(124,245,200,0.12); }
.coin[hidden] { display: none; }
.coin img { width: 22px; height: 22px; border-radius: 6px; object-fit: cover; flex: none; background: rgba(255,255,255,.05); }
.coin b { color: var(--ink); font-weight: 600; }
.coin.muted { background: rgba(255,255,255,0.03); border-color: var(--line); color: var(--ink-3); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 12px; background: rgba(255,255,255,0.03); border: 1px solid var(--line); }
.seg-btn { border: 0; background: transparent; color: var(--ink-2); font: 500 var(--text-xs) var(--font-ui); padding: 10px 8px; border-radius: 9px; cursor: pointer; transition: background .2s, color .2s; }
.seg-btn:hover { color: var(--ink); }
.seg-btn:disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.seg-btn:disabled:hover { color: var(--ink-2); }
.seg-btn.on { background: rgba(124,245,200,0.12); color: var(--accent); }
.seg-btn:focus-visible, .cta:focus-visible, .ghost:focus-visible, .back:focus-visible, .wallet:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cta {
  margin-top: 6px; border: 0; cursor: pointer;
  padding: 15px 18px; border-radius: 14px;
  background: var(--accent); color: #04130d;
  font: 600 var(--text-sm) var(--font-ui); letter-spacing: 0.005em;
  box-shadow: 0 10px 30px -12px rgba(124,245,200,.55);
  transition: transform .15s var(--ease), box-shadow .2s, opacity .2s;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 14px 34px -12px rgba(124,245,200,.7); }
.cta:active { transform: translateY(0); }
.cta:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.cta.subtle { background: rgba(255,255,255,0.05); color: var(--ink); box-shadow: none; border: 1px solid var(--line); }
.note { font-size: var(--text-xs); color: var(--ink-3); text-align: center; line-height: 1.5; min-height: 1em; }
.note.warn { color: #ffc27a; }

/* pay step */
.back { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--ink-2); font: 500 var(--text-xs) var(--font-ui); cursor: pointer; padding: 4px 6px 4px 0; }
.back svg { width: 16px; height: 16px; }
.back:hover { color: var(--ink); }
.pay-amt { font-size: clamp(2.4rem, 1.6rem + 3vw, 3.4rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1; margin-top: -8px; font-variant-numeric: tabular-nums; }
.pay-amt small { font-size: 0.4em; color: var(--ink-2); font-weight: 500; letter-spacing: 0; }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: var(--text-xs); padding: 14px 16px; border-radius: 12px; background: rgba(255,255,255,0.025); border: 1px solid var(--line); }
.summary dt { color: var(--ink-3); }
.summary dd { color: var(--ink); text-align: right; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 0.8rem; }
.wallets { display: flex; flex-direction: column; gap: 8px; }
.wallet { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 14px 16px; border-radius: 14px; cursor: pointer; background: var(--accent); color: #04130d; border: 0; font: 600 var(--text-sm) var(--font-ui); transition: transform .15s var(--ease), opacity .2s; }
.wallet:hover { transform: translateY(-1px); }
.wallet:disabled { opacity: .5; cursor: wait; transform: none; }
.wallet small { font-weight: 500; opacity: .7; font-size: var(--text-xs); }
.wallet.alt { background: rgba(255,255,255,0.05); color: var(--ink); border: 1px solid var(--line); }
.no-wallet { font-size: var(--text-xs); color: var(--ink-3); line-height: 1.5; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--line); }
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: var(--text-xs); }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.qr-row { display: grid; grid-template-columns: 148px 1fr; gap: 18px; align-items: center; }
.qr { width: 148px; height: 148px; padding: 10px; border-radius: 14px; background: #e9ece8; display: grid; place-items: center; }
.qr svg { width: 100%; height: 100%; display: block; }
.qr-side { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.qr-side p { font-size: var(--text-xs); color: var(--ink-2); line-height: 1.55; }
.ghost { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border-radius: 11px; border: 1px solid rgba(124,245,200,0.3); color: var(--accent); text-decoration: none; font: 500 var(--text-xs) var(--font-ui); transition: background .2s; }
.ghost:hover { background: rgba(124,245,200,0.07); }
.status { display: flex; align-items: center; gap: 10px; font-size: var(--text-xs); color: var(--ink-2); padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,0.025); border: 1px solid var(--line); line-height: 1.45; }
.status.ok { color: var(--accent); border-color: rgba(124,245,200,0.25); }
.status.bad { color: #ff8a7e; border-color: rgba(255,122,110,0.3); }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 1.6px solid rgba(124,245,200,0.2); border-top-color: var(--accent); flex: none; animation: rot .9s linear infinite; }
.status.bad .spin { display: none; }
@keyframes rot { to { transform: rotate(360deg); } }

/* done */
.done-mark { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: rgba(124,245,200,0.12); color: var(--accent); box-shadow: 0 0 0 8px rgba(124,245,200,0.05); }
.done-mark svg { width: 26px; height: 26px; }
.done-title { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); font-weight: 600; letter-spacing: -0.02em; margin-top: -8px; }
#stepDone .ghost { align-self: flex-start; }

@media (max-width: 720px) {
  .hud-tr { display: none; }
  .hud-bl { display: none; }
  .stage { padding: 88px 14px 32px; }
  .qr-row { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .qr { width: 200px; height: 200px; }
  .qr-side { align-items: center; }
}
@media (prefers-reduced-motion: reduce) { .card { animation: none; } .spin { animation-duration: 3s; } }
.manual { font-size: var(--text-xs); color: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: rgba(255,255,255,0.02); }
.manual summary { cursor: pointer; font-weight: 500; color: var(--ink); }
.manual[open] summary { margin-bottom: 10px; }
.manual .hint { margin-bottom: 10px; line-height: 1.5; }
.manual-row { display: flex; gap: 8px; }
.manual-row input { font-family: var(--font-mono); font-size: 0.8rem; padding: 10px 12px; }
.manual-row .ghost { flex: none; cursor: pointer; background: none; }
.amt-hint { margin-top: -10px; line-height: 1.5; }
.promise { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: rgba(124,245,200,0.05); border: 1px solid rgba(124,245,200,0.16); }
.promise svg { width: 18px; height: 18px; flex: none; color: var(--accent); margin-top: 1px; }
.promise p { font-size: var(--text-xs); color: var(--ink-2); line-height: 1.55; }

/* trading HUD */
.hud-label em { font-style: normal; color: var(--accent); margin-left: 6px; }
.hud-label em::before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin-right: 5px; vertical-align: 1px; animation: ping 2.4s infinite; }
.hud-tr { width: 210px; }
.bk-head { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 10px; margin-bottom: 4px; letter-spacing: .03em; }
.book { display: flex; flex-direction: column; gap: 2px; }
.bk { position: relative; display: flex; justify-content: space-between; padding: 2px 6px; font-variant-numeric: tabular-nums; }
.bk i { position: absolute; right: 0; top: 0; bottom: 0; border-radius: 2px; transition: width .6s var(--ease); }
.bk.ask i { background: rgba(255, 107, 138, 0.16); }
.bk.bid i { background: rgba(124, 245, 200, 0.14); }
.bk span, .bk b { position: relative; }
.bk span { color: var(--ink-3); }
.bk b { font-weight: 400; }
.bk.ask b { color: #ff8aa3; }
.bk.bid b { color: var(--accent); }
.bk-mid { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 6px; margin: 2px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.bk-mid span { color: var(--ink-3); font-size: 10px; }
.bk-mid b { font-weight: 500; font-size: 0.95rem; color: var(--ink); }
.bk-mid b.up { color: var(--accent); } .bk-mid b.dn { color: #ff8aa3; }
.tick-head { display: flex; justify-content: space-between; align-items: baseline; }
.pair { color: var(--ink); font-weight: 500; letter-spacing: .02em; }
.pair em { font-style: normal; color: var(--ink-3); }
#solCh.up { color: var(--accent); } #solCh.dn { color: #ff8aa3; }
.tick-px { font-family: var(--font-ui); font-size: 1.6rem; font-weight: 600; color: var(--ink); letter-spacing: -0.02em; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
#spark { display: block; width: 240px; height: 48px; margin-bottom: 8px; }
.hud[hidden] { display: none; }

.card { margin-block: auto; }
.hud-tr, .hud-bl { padding: 14px 16px; border-radius: 14px; background: rgba(12, 16, 46, 0.72); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.hud-tr { width: 252px; }
.hud-bl { width: 272px; }
.hud-label { white-space: nowrap; }
