/* Telegram gives its theme as --tg-theme-* variables; these are the fallbacks (and the look in a browser). */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-2: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --card: var(--tg-theme-section-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111111);
  --muted: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-ink: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --line: color-mix(in srgb, var(--muted) 22%, transparent);
  --ok: #1aa260;
  --warn: #d97706;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #17181c; --bg-2: #0f1013; --card: #1f2026; --text: #f3f3f5; --muted: #8b8d98; --link: #6ab3f3; --accent: #3e88f7;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg-2); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 520px; margin: 0 auto; padding: 12px 16px 28px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }

.loading { display: grid; place-items: center; min-height: 70vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Home */
.hero { text-align: center; padding: 18px 0 16px; }
.hero .label { color: var(--muted); font-size: 13px; }
.hero .total { font-size: 38px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.hero .hi { color: var(--muted); font-size: 13px; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 18px; }
.action {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px;
  background: var(--card); border: 0; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500;
}
.action .ic { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.action .ic svg { width: 20px; height: 20px; }
.action:active { transform: scale(.97); }

.section-title { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin: 18px 4px 8px; }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.row + .row { border-top: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.row .amt .sub { font-weight: 400; }
.row.tap { cursor: pointer; }
.coin { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 12px; color: #fff; }
.coin.USDT { background: #26a17b; }
.coin.TRX { background: #eb0029; }
.coin.USDC { background: #2775ca; }
.coin.BNB { background: #f0b90b; color: #1b1a17; }
.coin.POL { background: #8247e5; }
.coin { position: relative; }
/* The network of a coin that exists on several (T = Tron, B = BNB Smart Chain, P = Polygon) */
.coin .net { position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; font-size: 9px; line-height: 17px; text-align: center; color: #fff; border: 2px solid var(--card); }
.coin .net.tron { background: #eb0029; }
.coin .net.bsc { background: #f0b90b; color: #1b1a17; }
.coin .net.polygon { background: #8247e5; }
.coins .coin .net { width: 13px; height: 13px; line-height: 13px; font-size: 7px; right: -4px; bottom: -4px; }
.row.dim { opacity: .55; }
.coin svg { width: 22px; height: 22px; }
.plus { color: var(--ok); }
.pending { color: var(--warn); }
.empty { color: var(--muted); text-align: center; padding: 26px 14px; font-size: 14px; }
.more { display: block; width: 100%; background: none; border: 0; color: var(--link); padding: 12px; cursor: pointer; }

/* Screens */
.top { display: flex; align-items: center; gap: 8px; margin: 2px 0 14px; }
.top h1 { font-size: 20px; margin: 0; flex: 1; }
.back { background: none; border: 0; color: var(--link); cursor: pointer; padding: 6px 0; font-size: 15px; }
.tabs { display: flex; background: var(--card); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 500; color: var(--muted); }
.tabs button.on { background: var(--accent); color: var(--accent-ink); }

.field { margin-bottom: 12px; }
.field label { display: block; color: var(--muted); font-size: 13px; margin: 0 4px 6px; }
.input {
  width: 100%; background: var(--card); border: 1px solid transparent; border-radius: 12px; padding: 12px 14px; outline: none;
}
.input:focus { border-color: var(--accent); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 64px; }
.input-wrap .max { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: var(--bg-2); color: var(--link); border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: 13px; font-weight: 600; }
.chip { border: 1px solid var(--line); background: none; color: var(--link); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; font-weight: 600; }
.chip.danger { color: var(--danger); }
.coins { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.coins button { display: flex; align-items: center; gap: 8px; background: var(--card); border: 2px solid transparent; border-radius: 12px; padding: 8px 10px; cursor: pointer; text-align: left; }
.coins button.on { border-color: var(--accent); }
.coins .coin { width: 28px; height: 28px; font-size: 10px; }
.coins .coin svg { width: 16px; height: 16px; }
.coins small { display: block; color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 4px 0; }
.hint.err { color: var(--danger); }
.hint.ok { color: var(--ok); }
.summary { background: var(--card); border-radius: 12px; padding: 4px 14px; margin: 14px 0; }
.summary div { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; }
.summary div + div { border-top: 1px solid var(--line); }
.summary span:first-child { color: var(--muted); }
.btn {
  display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); margin-top: 8px;
}
.btn.ghost { background: var(--card); color: var(--link); }
.btn.danger { background: none; color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

/* Deposit */
.qr { background: #fff; border-radius: 16px; padding: 14px; width: 236px; margin: 4px auto 14px; }
.qr img { width: 100%; display: block; image-rendering: pixelated; }
.addr { background: var(--card); border-radius: 12px; padding: 12px 14px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; word-break: break-all; text-align: center; }
.note { background: color-mix(in srgb, var(--warn) 14%, var(--card)); border-radius: 12px; padding: 12px 14px; font-size: 13px; margin-top: 12px; }
.note b { color: var(--text); }

/* Result */
.done { text-align: center; padding: 30px 8px 10px; }
.done .big { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.done .big svg { width: 36px; height: 36px; }
.done h2 { margin: 0 0 6px; font-size: 22px; }
.done p { color: var(--muted); margin: 0 0 16px; }
.link-box { background: var(--card); border-radius: 12px; padding: 12px 14px; font-size: 13px; word-break: break-all; margin: 10px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: rgba(20, 20, 24, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.accept-row { flex-wrap: wrap; }
.accept-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.actions.two { grid-template-columns: repeat(2, 1fr); }
.asset-hero .coin { width: 52px; height: 52px; margin: 0 auto 8px; font-size: 14px; }
.asset-hero .total { font-size: 30px; }
.row-title { display: flex; justify-content: space-between; align-items: baseline; }
.link { background: none; border: 0; color: var(--link); cursor: pointer; font-size: 13px; text-transform: none; letter-spacing: 0; padding: 0; }
