:root {
  --bg: #F7F8FA;
  --card: #FFFFFF;
  --ink: #0E1530;
  --ink-2: #4A5168;
  --muted: #7E8499;
  --line: #ECEEF3;
  --key: #EFF0F4;
  --accent: #5B4DFF;
  --accent-press: #4A3CF0;
  --accent-soft: #EEECFF;
  --accent-line: #DCD8FF;
  --green: #17914E;
  --green-soft: #E2F5E9;
  --amber: #B7791F;
  --amber-soft: #FDF3E1;
  --red: #D13B3B;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(14, 21, 48, .04), 0 6px 20px rgba(14, 21, 48, .05);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.35 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
[hidden] { display: none !important; }

#app { max-width: 480px; margin: 0 auto; }
.screen { padding: calc(var(--safe-top) + 14px) 20px calc(96px + var(--safe-bottom)); min-height: 100dvh; }
.screen.no-tabs { padding-bottom: calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; }
.grow { flex: 1; }

/* ---------- top of home ---------- */
.topbar { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #7B6CFF, #4A3CF0 70%); display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(91, 77, 255, .28);
}
.avatar svg { width: 26px; height: 26px; }
.account { min-width: 0; flex: 1; }
.account-name { display: flex; align-items: center; gap: 6px; font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.account-name svg { width: 16px; height: 16px; stroke: var(--ink); fill: none; stroke-width: 2.2; }
.addr-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; margin-top: 2px; }
.addr-chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.net-pill {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 600;
  padding: 8px 13px; border-radius: 999px;
}
.net-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #21B25F; }

.balance { text-align: center; margin: 34px 0 30px; }
.balance-label { color: var(--muted); font-size: 16px; font-weight: 500; }
.balance-value { font-size: 46px; font-weight: 800; letter-spacing: -1.4px; margin: 6px 0 4px; line-height: 1.05; }
.change { font-size: 16px; font-weight: 600; }
.up { color: var(--green); }
.down { color: var(--red); }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 26px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 9px; font-size: 15px; font-weight: 500; }
.action-circle {
  width: 60px; height: 60px; border-radius: 50%; background: var(--accent); display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(91, 77, 255, .25); transition: transform .12s, background .12s;
}
.action:active .action-circle { transform: scale(.94); background: var(--accent-press); }
.action-circle svg { width: 26px; height: 26px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- cards and lists ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: #F1F2F6; border-radius: 14px; padding: 3px; margin: 14px 14px 4px; }
.seg button { padding: 10px; border-radius: 12px; font-size: 16px; font-weight: 600; color: var(--ink-2); border: 1px solid transparent; }
.seg button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

.rows { list-style: none; margin: 0; padding: 0 16px; }
.row { display: flex; align-items: center; gap: 14px; padding: 15px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.rows > li:first-child > .row { border-top: 0; }
.coin-icon { width: 46px; height: 46px; border-radius: 50%; flex: none; }
.coin-icon.sm { width: 36px; height: 36px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 15px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { text-align: right; flex: none; }
.row-amount { font-size: 16px; font-weight: 700; }
.row-usd { font-size: 15px; color: var(--muted); margin-top: 2px; }
.tx-icon { width: 46px; height: 46px; border-radius: 50%; flex: none; position: relative; }
.tx-icon .badge {
  position: absolute; right: -3px; bottom: -3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff; display: grid; place-items: center;
}
.tx-icon .badge.in { background: var(--green); }
.tx-icon .badge svg { width: 12px; height: 12px; stroke: #fff; stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px 32px; font-size: 15px; }
.day { font-size: 14px; font-weight: 600; color: var(--muted); margin: 22px 4px 8px; text-transform: uppercase; letter-spacing: .4px; }

/* ---------- sub-screen header ---------- */
.header { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; margin: 4px -6px 18px; min-height: 48px; }
.header h1 { margin: 0; text-align: center; font-size: 22px; font-weight: 700; letter-spacing: -.3px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.header h1 img, .header h1 .mark { width: 30px; height: 30px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; }
.icon-btn:active { background: var(--key); }
.icon-btn svg { width: 24px; height: 24px; stroke: var(--ink); fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.page-title { font-size: 30px; font-weight: 800; letter-spacing: -.6px; margin: 10px 2px 18px; }

/* ---------- send ---------- */
.field { padding: 16px 18px; }
.field-label { font-size: 15px; color: var(--muted); font-weight: 500; }
.field-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.field-row input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 19px; font-weight: 500; padding: 6px 0;
}
.field-row input::placeholder { color: #B4B8C6; }
.square-btn { width: 46px; height: 46px; border-radius: 12px; background: #F1F2F6; display: grid; place-items: center; flex: none; }
.square-btn svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 1.9; stroke-linejoin: round; }
.field-error { color: var(--red); font-size: 14px; margin-top: 8px; }
.field-hint { color: var(--muted); font-size: 14px; margin-top: 8px; }
.field-hint.ok { color: var(--green); }

.amount { text-align: center; margin: 26px 0 8px; }
.amount-value { font-size: 52px; font-weight: 800; letter-spacing: -1.6px; line-height: 1.05; word-break: break-all; }
.amount-value .ghost { color: #C3C6D2; }
.amount-usd { font-size: 20px; color: var(--muted); margin-top: 8px; }
.avail { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--ink-2); font-size: 16px; margin: 12px 0 18px; }
.chip { background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; padding: 5px 14px; border-radius: 999px; }
.chip.soft { background: var(--accent-soft); color: var(--accent); }
.fee-row { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border: 1px solid var(--line); background: #fff; border-radius: 16px; font-size: 17px; }
.fee-row svg { width: 26px; height: 26px; stroke: var(--ink-2); fill: none; stroke-width: 1.6; }
.fee-row .val { margin-left: auto; color: var(--muted); font-size: 15px; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.keypad button { height: 58px; border-radius: 14px; background: var(--key); font-size: 26px; font-weight: 600; display: grid; place-items: center; }
.keypad button:active { background: #E2E4EB; }
.keypad svg { width: 30px; height: 24px; stroke: var(--ink); fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }

.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 56px; border-radius: 999px; font-size: 18px; font-weight: 600; }
.btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(91, 77, 255, .25); }
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled { background: #BDB7FF; box-shadow: none; }
.btn-outline { border: 1.5px solid var(--accent); color: var(--accent); background: #fff; }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-danger { background: #FDECEC; color: var(--red); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn.small { height: 50px; font-size: 17px; border-radius: 14px; }

/* ---------- pickers ---------- */
.picker { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 18px 12px 12px; border: 1px solid var(--line); background: #fff; border-radius: 999px; font-size: 18px; font-weight: 500; }
.picker .coin-icon { width: 44px; height: 44px; }
.picker .chev { margin-left: auto; width: 20px; height: 20px; stroke: var(--ink); fill: none; stroke-width: 2.2; }

/* ---------- receive ---------- */
.qr-card { margin-top: 22px; padding: 30px 26px 26px; text-align: center; }
.qr { width: 100%; max-width: 280px; margin: 0 auto; aspect-ratio: 1; position: relative; }
.qr svg { width: 100%; height: 100%; }
.qr .qr-mark { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: 22%; aspect-ratio: 1; background: #fff; border-radius: 22%; display: grid; place-items: center; }
.qr .qr-mark svg { width: 72%; height: 72%; }
.your-addr { color: var(--muted); font-size: 16px; margin-top: 22px; }
.addr-full { font-family: var(--mono); font-size: 17px; line-height: 1.5; margin: 8px auto 22px; word-break: break-all; max-width: 290px; }
.info { display: flex; gap: 12px; align-items: flex-start; background: var(--accent-soft); color: var(--accent); border-radius: 16px; padding: 16px 18px; margin-top: 18px; font-size: 16px; }
.info svg { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ---------- transaction ---------- */
.tx-head { display: flex; gap: 18px; align-items: center; margin: 4px 0 24px; }
.tx-head .tx-icon { width: 76px; height: 76px; }
.tx-head .tx-icon .badge { width: 32px; height: 32px; right: -4px; bottom: -2px; border-width: 3px; }
.tx-head .tx-icon .badge svg { width: 16px; height: 16px; }
.tx-title { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.tx-usd { font-size: 19px; color: var(--muted); margin: 2px 0 8px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; padding: 6px 12px; border-radius: 999px; }
.status svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.status.confirmed { background: var(--green-soft); color: var(--green); }
.status.pending, .status.confirming { background: var(--amber-soft); color: var(--amber); }
.status .spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kv { padding: 8px 20px; }
.kv-row { display: grid; grid-template-columns: 112px 1fr; gap: 12px; padding: 12px 0; font-size: 16px; align-items: center; }
.kv-row .k { color: var(--muted); }
.kv-row .v { display: flex; align-items: center; gap: 10px; min-width: 0; }
.kv-row .v span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-row .v.mono { font-family: var(--mono); font-size: 15px; }
.kv-row .v.wrap span { white-space: normal; word-break: break-all; }
.copy { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; }
.copy svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-2); stroke-width: 1.8; }
.copy:active { background: var(--key); }

.trace { padding: 20px 20px 10px; margin-top: 16px; }
.trace h2 { margin: 0 0 12px; font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: grid; grid-template-columns: 20px 1fr auto; gap: 14px; align-items: center; padding: 11px 0; position: relative; font-size: 16px; }
.step::before { content: ""; position: absolute; left: 9px; top: -11px; height: 22px; width: 2px; background: #D9DCE6; }
.step:first-child::before { display: none; }
.step .dot { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); position: relative; z-index: 1; }
.step.todo .dot { background: #fff; border: 2px solid #D0D3DE; }
.step.todo { color: var(--muted); }
.step.done.last .dot { background: #21A05A; }
.step.now .dot { box-shadow: 0 0 0 5px rgba(91, 77, 255, .16); }
.step .when { color: var(--muted); font-size: 15px; }
.full-trace { margin: 14px 0 6px; }
.full-trace .kv-row { grid-template-columns: 128px 1fr; }

/* ---------- welcome ---------- */
.welcome { text-align: center; justify-content: center; }
.welcome .mark-lg { width: 96px; height: 96px; margin: 0 auto 26px; border-radius: 28px; background: linear-gradient(135deg, #7B6CFF, #4A3CF0 70%); display: grid; place-items: center; box-shadow: 0 16px 36px rgba(91, 77, 255, .3); }
.welcome .mark-lg svg { width: 52px; height: 52px; }
.welcome h1 { font-size: 34px; font-weight: 800; letter-spacing: -.8px; margin: 0 0 10px; }
.welcome p { color: var(--ink-2); font-size: 17px; margin: 0 auto 8px; max-width: 320px; }
.welcome .fine { color: var(--muted); font-size: 14px; margin-top: 16px; }

/* ---------- misc ---------- */
.install { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin: 0 0 18px; }
.install .txt { flex: 1; font-size: 15px; }
.install b { display: block; font-size: 16px; }
.install .x { width: 32px; height: 32px; display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--muted); margin: 26px 4px 10px; text-transform: uppercase; letter-spacing: .4px; }
.settings-row { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-top: 1px solid var(--line); font-size: 16px; width: 100%; text-align: left; }
.settings-row:first-child { border-top: 0; }
.settings-row .end { margin-left: auto; color: var(--muted); font-size: 15px; text-align: right; }
.settings-row .mono { font-family: var(--mono); font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-hero { text-align: center; margin: 4px 0 24px; }
.token-hero .coin-icon { width: 72px; height: 72px; margin: 0 auto 14px; }
.token-hero .big { font-size: 34px; font-weight: 800; letter-spacing: -.8px; }
.token-hero .sub { color: var(--muted); font-size: 18px; margin-top: 4px; }
.price-line { display: flex; justify-content: space-between; padding: 16px 18px; font-size: 16px; }
.price-line + .price-line { border-top: 1px solid var(--line); }
.price-line .k { color: var(--muted); }
.skel { background: linear-gradient(90deg, #ECEEF3 0%, #F5F6F9 50%, #ECEEF3 100%); background-size: 200% 100%; animation: skel 1.2s infinite; border-radius: 10px; color: transparent !important; }
@keyframes skel { to { background-position: -200% 0; } }
.error-box { background: #FDECEC; color: var(--red); border-radius: 14px; padding: 14px 16px; font-size: 15px; margin: 12px 0; }

/* ---------- tab bar ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px max(8px, calc((100vw - 480px) / 2)) calc(8px + var(--safe-bottom));
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #8C92A5; font-size: 13px; font-weight: 500; padding: 4px 0; }
.tabs svg { width: 26px; height: 26px; fill: currentColor; stroke: currentColor; stroke-width: 0; }
.tabs a.on { color: var(--accent); font-weight: 600; }

/* ---------- sheet and toast ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(14, 21, 48, .38); z-index: 20; animation: fade .18s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: #fff; border-radius: 24px 24px 0 0;
  max-width: 480px; margin: 0 auto; max-height: 86dvh; overflow: auto;
  padding: 10px 20px calc(22px + var(--safe-bottom)); animation: up .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: #D9DCE6; margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 14px; font-size: 21px; font-weight: 800; text-align: center; }
.sheet .rows { padding: 0; }
.sheet .kv { padding: 0; margin-bottom: 18px; }
.sheet p { color: var(--ink-2); text-align: center; margin: 0 0 18px; }
.sheet input.text { width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; font-size: 17px; outline: 0; margin-bottom: 14px; }
.sheet input.text:focus { border-color: var(--accent); }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 500;
  box-shadow: 0 10px 30px rgba(14, 21, 48, .25); max-width: calc(100vw - 40px); animation: fade .15s;
}

@media (max-width: 360px) {
  .balance-value { font-size: 40px; }
  .action-circle { width: 54px; height: 54px; }
  .amount-value { font-size: 44px; }
  .keypad button { height: 52px; }
}
