/* Wizard Exchange — design system
   Identity: deep-space navy, arcane violet→cyan gradient, Space Grotesk numerals. */

:root {
  --bg0: #0B0E1A;
  --bg1: #131829;
  --bg2: #1B2138;
  --stroke: rgba(148, 163, 255, 0.13);
  --stroke-strong: rgba(148, 163, 255, 0.28);
  --text: #F2F4FF;
  --muted: #8A91B4;
  --brand-a: #7C5CFF;
  --brand-b: #4CC2FF;
  --grad: linear-gradient(135deg, #7C5CFF 0%, #4CC2FF 100%);
  --good: #3DDC97;
  --warn: #FFC24B;
  --bad: #FF6B81;
  --radius: 18px;
  --font-display: "Space Grotesk", -apple-system, sans-serif;
  --font-body: "Inter", -apple-system, sans-serif;
}

body.light {
  --bg0: #F3F5FC;
  --bg1: #FFFFFF;
  --bg2: #EDF0FA;
  --stroke: rgba(60, 70, 140, 0.10);
  --stroke-strong: rgba(60, 70, 140, 0.22);
  --text: #171B30;
  --muted: #6A7194;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* Author `display` rules outrank the UA stylesheet's [hidden], which silently
   revealed elements we meant to hide (e.g. the empty QR box). */
[hidden] { display: none !important; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(124, 92, 255, 0.16), transparent 60%),
    radial-gradient(700px 420px at -10% 8%, rgba(76, 194, 255, 0.10), transparent 55%),
    var(--bg0);
  background-attachment: fixed;
  color: var(--text);
  padding-bottom: 84px;
  font-size: 15px;
}

#app { max-width: 480px; margin: 0 auto; padding: 18px 16px; }

svg { width: 22px; height: 22px; }

.view { display: none; animation: rise .22s cubic-bezier(.2,.7,.3,1); }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* --- brand header --- */

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand .logo { width: 40px; height: 40px; }
.brand-name {
  font-family: var(--font-display);
  font-size: 21px; font-weight: 700; letter-spacing: .2px;
}
.brand-name span {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-left: 5px;
}
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

h1 { font-family: var(--font-display); font-size: 22px; margin: 4px 0 16px; letter-spacing: .2px; }
h2 {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; margin: 22px 0 10px;
  color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.2px;
}
.h-icon { width: 15px; height: 15px; }
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14.5px; margin-bottom: 10px; }
.card-title .h-icon { width: 17px; height: 17px; color: var(--brand-b); }

/* --- cards & fields --- */

.card {
  background: var(--bg1);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 10px;
}
.stack > * + * { margin-top: 10px; }

.swap-stack { position: relative; }
.field-head {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 10px;
}
.net-tag { color: var(--brand-b); font-weight: 600; }

.row { display: flex; gap: 10px; align-items: center; }
.row.center { justify-content: flex-start; }
.inline-arrow { width: 16px; height: 16px; color: var(--muted); flex: none; }

.chip {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: var(--font-display);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s;
}
.chip:active { border-color: var(--stroke-strong); }

.amount-input, .amount-out {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 26px; font-weight: 600;
  text-align: right;
}
.amount-input::placeholder { color: var(--muted); opacity: .5; }
.amount-out {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.unit-chip {
  flex: none;
  background: var(--bg2);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  color: var(--brand-b);
  font-family: var(--font-display);
  font-size: 12.5px; font-weight: 700;
  letter-spacing: .3px;
  padding: 7px 10px;
  cursor: pointer;
}
.unit-chip:active { border-color: var(--stroke-strong); }
.amount-hint {
  min-height: 15px;
  margin-top: 8px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}
.amount-hint b { color: var(--text); font-family: var(--font-display); }

.flip {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  margin: -16px auto;
  width: 40px; height: 40px;
  background: var(--bg2);
  border: 1px solid var(--stroke-strong);
  border-radius: 50%;
  color: var(--brand-b);
  cursor: pointer;
  transition: transform .2s;
}
.flip:active { transform: rotate(180deg); }
.flip svg { width: 18px; height: 18px; }

.text-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  padding: 12px;
  outline: none;
  transition: border-color .15s;
}
.text-input:focus { border-color: var(--brand-a); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }

/* --- segmented --- */

.segmented {
  display: flex;
  background: var(--bg1);
  border: 1px solid var(--stroke);
  border-radius: 13px;
  padding: 4px;
  margin: 12px 0;
}
.segmented button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: none; border-radius: 10px;
  padding: 10px 0;
  font-family: var(--font-body);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: color .15s;
}
.segmented button em { font-style: normal; opacity: .65; font-weight: 500; }
.segmented button.active { background: var(--grad); color: #fff; }

/* --- quotes --- */

.quotes { margin: 6px 0; }
.quote-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg1);
  border: 1px solid var(--stroke);
  border-radius: 13px;
  padding: 12px 14px;
  margin-bottom: 7px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s;
}
.quote-row .provider { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.quote-row .amt { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.quote-row.best { border-color: transparent; background:
  linear-gradient(var(--bg1), var(--bg1)) padding-box,
  var(--grad) border-box; }
.best-pill {
  font-size: 9.5px; font-weight: 700; letter-spacing: 1px;
  background: var(--grad); color: #fff;
  border-radius: 6px; padding: 3px 7px;
}
.quote-row.chosen .amt { color: var(--brand-b); -webkit-text-fill-color: currentColor; }
.quote-row.err { color: var(--muted); font-size: 12.5px; cursor: default; }

/* --- buttons --- */

.primary-btn {
  width: 100%;
  background: var(--grad);
  color: #fff;
  border: none; border-radius: 15px;
  padding: 16px;
  font-family: var(--font-display);
  font-size: 16px; font-weight: 700; letter-spacing: .3px;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 10px 28px -10px rgba(124, 92, 255, .55);
  transition: opacity .15s, transform .1s;
}
.primary-btn:disabled { opacity: .35; box-shadow: none; }
.primary-btn:not(:disabled):active { transform: scale(.985); }
.primary-btn.small { padding: 12px; font-size: 14px; }

.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--bg1);
  color: var(--text);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.ghost-btn svg { width: 16px; height: 16px; color: var(--brand-b); }
.ghost-btn.wide { width: 100%; }

.fineprint { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 12px; line-height: 1.5; }

/* --- lists --- */

.list .item, .picker-list .item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg1);
  border: 1px solid var(--stroke);
  border-radius: 13px;
  padding: 13px 14px;
  margin-bottom: 7px;
  font-size: 14px;
  cursor: pointer;
}
.list .item .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.item .chev { width: 16px; height: 16px; color: var(--muted); flex: none; }
.item-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.item-actions .icon-btn svg { color: var(--brand-b); }
.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 4px;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:active { color: var(--bad); }
.empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }

.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 7px; vertical-align: 1px;
  background: var(--muted);
}
.status-dot.active { background: var(--brand-b); box-shadow: 0 0 8px var(--brand-b); }
.status-dot.good { background: var(--good); }
.status-dot.warn { background: var(--warn); }
.status-dot.bad { background: var(--bad); }

.saved-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.saved-chips .chip { font-size: 12px; padding: 7px 11px; font-family: var(--font-body); }

/* --- modal --- */

.modal {
  position: fixed; inset: 0;
  background: rgba(5, 7, 15, .6);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-body {
  background: var(--bg0);
  border-top: 1px solid var(--stroke-strong);
  width: 100%; max-width: 480px;
  max-height: 84vh; overflow-y: auto;
  border-radius: 22px 22px 0 0;
  padding: 14px 16px 22px;
  animation: slideup .24s cubic-bezier(.2,.7,.3,1);
}
@keyframes slideup { from { transform: translateY(48px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-grip {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--stroke-strong);
  margin: 0 auto 12px;
}

.picker-list { margin: 10px 0; max-height: 56vh; overflow-y: auto; }
.picker-list .item { justify-content: flex-start; gap: 10px; }
.picker-list .code { font-family: var(--font-display); font-weight: 600; }
.picker-list .net {
  color: var(--brand-b); font-size: 10.5px; font-weight: 600;
  background: var(--bg2); border-radius: 6px; padding: 2px 7px;
}
.picker-list .name { color: var(--muted); font-size: 12px; margin-left: auto; }

/* --- deposit --- */

.deposit-title { font-family: var(--font-display); font-size: 20px; margin-bottom: 6px; }
.deposit-sub { font-size: 14px; color: var(--muted); }
.deposit-sub b { color: var(--text); }
.deposit-qr {
  display: block; margin: 16px auto;
  border-radius: 16px; background: #fff; padding: 10px;
  width: 186px; height: 186px;
  box-shadow: 0 14px 40px -14px rgba(124, 92, 255, .5);
}
.deposit-address {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px; word-break: break-all;
  background: var(--bg1);
  border: 1px dashed var(--stroke-strong);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
}
.tag-warn { font-size: 12.5px; color: var(--warn); margin-top: 8px; }

.progress-track { display: flex; gap: 5px; margin: 16px 0 8px; }
.progress-track i {
  flex: 1; height: 5px; border-radius: 3px;
  background: var(--bg2);
}
.progress-track i.on { background: var(--grad); }
.status-line { display: flex; align-items: center; font-size: 13.5px; margin-bottom: 6px; }

/* --- referral / misc --- */

.ref-stats { font-size: 13.5px; color: var(--muted); margin-bottom: 8px; }
.ref-stats b { color: var(--text); font-family: var(--font-display); }
.ref-link {
  word-break: break-all;
  background: var(--bg2);
  border-radius: 10px;
  padding: 10px;
  margin: 8px 0;
  color: var(--brand-b);
}
.aml-result { font-size: 13.5px; margin-top: 10px; }
.aml-result.good { color: var(--good); }
.aml-result.bad { color: var(--bad); }

details.card summary { cursor: pointer; font-weight: 600; font-size: 14px; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card p { margin-top: 10px; font-size: 13.5px; color: var(--muted); line-height: 1.55; }

/* --- wallet --- */

.wallet-copy { font-size: 13px; color: var(--muted); line-height: 1.55; margin-bottom: 12px; }
.wallet-copy b { color: var(--text); }
.wallet-copy.danger {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent);
  border-radius: 12px;
  padding: 11px 12px;
}
.wallet-copy.danger b { color: var(--warn); }

.seed-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 12px 0;
}
.seed-grid span {
  background: var(--bg2);
  border: 1px solid var(--stroke);
  border-radius: 9px;
  padding: 8px 6px;
  font-size: 12.5px;
  font-family: ui-monospace, Menlo, monospace;
  text-align: center;
}
.seed-grid span i {
  font-style: normal;
  color: var(--muted);
  font-size: 10px;
  margin-right: 4px;
}

.net-ok {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--stroke);
}
.net-ok .title {
  font-size: 11.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 9px;
}
.net-ok .nets { display: flex; flex-wrap: wrap; gap: 6px; }
.net-ok .net {
  display: inline-flex; align-items: center; gap: 5px;
  background: color-mix(in srgb, var(--good) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--good) 32%, transparent);
  color: var(--good);
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 12px; font-weight: 600;
}
.net-ok .net::before { content: "✓"; font-size: 11px; }

.net-warn {
  margin-top: 11px;
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 34%, transparent);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 12.5px;
  color: var(--bad);
  line-height: 1.5;
}
.net-warn b { color: var(--bad); }

.confirm-box {
  background: var(--bg2);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 13px;
  font-size: 13.5px;
}
.confirm-box .line {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0;
}
.confirm-box .line + .line { border-top: 1px solid var(--stroke); }
.confirm-box .k { color: var(--muted); flex: none; }
.confirm-box .v { text-align: right; word-break: break-all; font-weight: 600; }
.confirm-box .v.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; font-weight: 400; }

.saved-chips .chip.active {
  border-color: var(--brand-a);
  color: var(--brand-b);
}

.balance-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg1);
  border: 1px solid var(--stroke);
  border-radius: 13px;
  padding: 13px 14px;
  margin-bottom: 7px;
}
.balance-row .chain { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.balance-row .bal { font-family: var(--font-display); font-weight: 600; }

/* --- loading primitives --- */

@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skeleton {
  border-radius: 13px;
  background: linear-gradient(90deg, var(--bg1) 25%, var(--bg2) 50%, var(--bg1) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.3s linear infinite;
}
.skeleton-row { height: 46px; margin-bottom: 7px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 18px; height: 18px; flex: none;
  border: 2px solid var(--stroke-strong);
  border-top-color: var(--brand-b);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  vertical-align: -3px;
}
.loading-row {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 13.5px;
  padding: 13px 4px;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
  padding: 26px 16px;
  color: var(--muted);
}
.empty-state svg { width: 30px; height: 30px; opacity: .55; }
.empty-state .sub { font-size: 12.5px; }

.text-input.invalid { border-color: var(--bad); }
.input-hint { font-size: 11.5px; color: var(--bad); margin-top: 5px; min-height: 14px; }

/* --- toast --- */

#toast {
  position: fixed;
  left: 50%; bottom: 92px;
  transform: translate(-50%, 20px);
  z-index: 60;
  max-width: 88%;
  background: var(--bg2);
  border: 1px solid var(--stroke-strong);
  color: var(--text);
  border-radius: 13px;
  padding: 12px 18px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: 0 14px 40px -12px rgba(0,0,0,.6);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.good { border-color: var(--good); }
#toast.bad { border-color: var(--bad); }

/* --- tabbar --- */

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: color-mix(in srgb, var(--bg0) 88%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--stroke);
  padding: 8px 0 max(12px, env(safe-area-inset-bottom));
  z-index: 40;
}
.tabbar button {
  flex: 1;
  background: none; border: none;
  color: var(--muted);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: color .15s;
}
.tabbar button svg { width: 21px; height: 21px; }
.tabbar button span { font-size: 10px; font-weight: 600; letter-spacing: .3px; }
.tabbar button.active { color: var(--text); }
.tabbar button.active svg { color: var(--brand-b); }
