:root {
  --bg: var(--tg-theme-bg-color, #0b0d12);
  --fg: var(--tg-theme-text-color, #eef1f7);
  --muted: var(--tg-theme-hint-color, #8b93a7);
  --card: var(--tg-theme-secondary-bg-color, #151922);
  --accent: var(--tg-theme-button-color, #4f7cff);
  --accent-fg: var(--tg-theme-button-text-color, #fff);
  --line: color-mix(in srgb, var(--muted) 16%, transparent);
  --ok: #22c55e; --danger: #ef4444; --warn: #f59e0b;
  --r: 18px; --r-sm: 12px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .45);
  --grad: linear-gradient(135deg, #6d5dfc 0%, #4f7cff 45%, #22d3ee 100%);
  color-scheme: light dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
main { max-width: 560px; margin: 0 auto; padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); }
.page { animation: in .22s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
h1 { font-size: 24px; letter-spacing: -.02em; margin: 6px 0 14px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 24px 4px 10px; font-weight: 600; }
h3 { font-size: 13px; color: var(--muted); margin: 20px 4px 8px; font-weight: 600; }
.top h1 { margin-bottom: 10px; }
.muted { color: var(--muted); }
.center { text-align: center; justify-content: center; }
.hidden { display: none !important; }
.up { color: var(--ok); } .down { color: var(--danger); }

/* icons */
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.xl { width: 38px; height: 38px; }
.ic.dim { opacity: .4; }
[dir="rtl"] .ic.arrow, [dir="rtl"] .row-item .ic:last-child { transform: scaleX(-1); }

/* buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; border-radius: 16px; padding: 15px 16px; margin: 10px 0;
  font: inherit; font-weight: 650; cursor: pointer; transition: transform .08s ease, filter .15s, opacity .15s; text-decoration: none; position: relative; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; }
.btn.loading span::after { content: ''; display: inline-block; width: 14px; height: 14px; margin-inline-start: 8px; vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.primary { background: var(--grad); color: #fff; box-shadow: 0 8px 22px -10px #4f7cff; }
.ghost { background: var(--card); color: var(--fg); }
.success { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; box-shadow: 0 8px 22px -10px #22c55e; }
.danger { background: linear-gradient(135deg, #f43f5e, #dc2626); color: #fff; }
.row2 { display: flex; gap: 10px; } .row2 > * { flex: 1; min-width: 0; }
.icon-btn { border: 0; background: color-mix(in srgb, var(--muted) 14%, transparent); color: inherit; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; }
.icon-btn.glass { background: rgba(255, 255, 255, .18); color: #fff; backdrop-filter: blur(8px); }
.spin .ic { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip .ic { width: 15px; height: 15px; }
.chip.on { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.chip.big { padding: 8px 14px 8px 8px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }

/* cards & lists */
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin: 10px 0; border: 1px solid var(--line); }
.card.list { padding: 4px 0; }
.card.form { padding: 4px 14px 10px; }
.row-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; background: none; border: 0; color: inherit; font: inherit; text-align: start; text-decoration: none; }
.row-item + .row-item { border-top: 1px solid var(--line); }
.row-item.tap { cursor: pointer; transition: background .15s; }
.row-item.tap:active { background: color-mix(in srgb, var(--muted) 10%, transparent); }
.row-item.danger { color: var(--danger); }
.row-item.dim { opacity: .5; }
.row-item b { display: block; font-weight: 620; }
.row-item small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.row-item small .up, .row-item small .down { font-weight: 600; }
.grow { flex: 1; min-width: 0; } .grow b, .grow small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: end; } .right b { font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 18px 10px; margin: 0; }
details summary { color: var(--muted); cursor: pointer; padding: 12px 14px; list-style: none; font-weight: 600; font-size: 13px; }
details summary::before { content: '▸ '; } details[open] summary::before { content: '▾ '; }
.set-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.danger .set-ic { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* coins */
.coin { --a: #7c8aa5; --b: #334155; position: relative; flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(120% 120% at 25% 20%, var(--a), var(--b)); color: #fff; font-weight: 800; font-size: 11px; letter-spacing: -.02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 4px 10px -6px var(--b); text-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.coin.sm { width: 34px; height: 34px; font-size: 9.5px; } .coin.xs { width: 24px; height: 24px; font-size: 7px; } .coin.lg { width: 56px; height: 56px; font-size: 14px; }
.coin .badge { position: absolute; right: -2px; bottom: -2px; width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, var(--a), var(--b)); border: 2px solid var(--card); }
.coin.lg .badge { width: 20px; height: 20px; }
.coins-row { display: flex; justify-content: center; margin: 4px 0 18px; }
.coins-row .coin { margin-inline-start: -8px; border: 2px solid var(--bg); }

/* hero */
.hero { position: relative; overflow: hidden; border-radius: 26px; padding: 20px 18px 18px; color: #fff; background: var(--grad); box-shadow: 0 18px 40px -18px #4f7cff; }
.hero::before, .hero::after { content: ''; position: absolute; border-radius: 50%; filter: blur(30px); opacity: .55; pointer-events: none; }
.hero::before { width: 220px; height: 220px; background: #a78bfa; top: -90px; right: -60px; }
.hero::after { width: 180px; height: 180px; background: #22d3ee; bottom: -100px; left: -40px; }
.hero > * { position: relative; z-index: 1; }
.hero-top { display: flex; justify-content: space-between; align-items: center; } .hero-top small { opacity: .85; font-weight: 600; }
.total { font-size: 38px; font-weight: 800; letter-spacing: -.03em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.delta { display: inline-block; font-size: 13px; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .18); }
.delta.up, .delta.down { color: #fff; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 18px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: 0; color: #fff; font: inherit; cursor: pointer; }
.action small { font-size: 12.5px; font-weight: 600; }
.bubble { width: 50px; height: 50px; border-radius: 17px; display: grid; place-items: center; background: rgba(255, 255, 255, .2); backdrop-filter: blur(10px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); transition: transform .1s; }
.action:active .bubble { transform: scale(.92); }

/* tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(18px) saturate(1.4); border-top: 1px solid var(--line); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; padding: 4px 0; }
.tab.on { color: var(--accent); }
.tab.on .ic { filter: drop-shadow(0 2px 6px color-mix(in srgb, var(--accent) 60%, transparent)); }

/* forms */
.field { display: block; margin: 12px 0; }
.lbl { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; margin-bottom: 7px; }
input, textarea, select { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 60%, var(--card)); color: var(--fg); font: inherit; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize: vertical; font-family: ui-monospace, Menlo, monospace; }
.amount-box { display: flex; align-items: center; gap: 8px; }
.big-input { font-size: 26px; font-weight: 750; padding: 10px 12px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.split { display: flex; justify-content: space-between; gap: 8px; margin-top: -4px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 2px; } .hint.ok { color: var(--ok); word-break: break-all; }
.err { color: var(--danger); min-height: 1.2em; font-size: 13.5px; margin: 6px 2px; font-weight: 600; }
.check { display: flex; gap: 10px; align-items: center; margin: 14px 2px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.meter { display: flex; align-items: center; gap: 10px; margin: -4px 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.meter i { flex: 1; height: 5px; border-radius: 5px; background: var(--line); position: relative; overflow: hidden; }
.meter i::after { content: ''; position: absolute; inset: 0; width: 0; border-radius: 5px; transition: width .25s, background .25s; }
.meter.s1 i::after { width: 33%; background: var(--danger); } .meter.s2 i::after { width: 66%; background: var(--warn); } .meter.s3 i::after { width: 100%; background: var(--ok); }
.asset-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 60%, var(--card)); color: var(--fg); font: inherit; text-align: start; cursor: pointer; }
.asset-btn b { display: block; } .asset-btn small { display: block; color: var(--muted); font-size: 12px; }

/* notes */
.note { display: flex; gap: 10px; align-items: flex-start; border-radius: 14px; padding: 12px 13px; margin: 10px 0; font-size: 13.5px; line-height: 1.45;
  background: color-mix(in srgb, var(--warn) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
.note .ic { width: 18px; height: 18px; margin-top: 1px; color: var(--warn); }
.note.danger { background: color-mix(in srgb, var(--danger) 13%, var(--card)); border-color: color-mix(in srgb, var(--danger) 45%, transparent); font-weight: 650; }
.note.danger .ic { color: var(--danger); }
.note.info { background: color-mix(in srgb, var(--accent) 10%, var(--card)); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.note.info .ic { color: var(--accent); }

/* welcome / onboarding */
.welcome { text-align: center; padding-top: 18px; }
.welcome .note { text-align: start; }
.logo { width: 84px; height: 84px; margin: 10px auto 14px; border-radius: 26px; display: grid; place-items: center; background: var(--grad); color: #fff; box-shadow: 0 16px 36px -14px #4f7cff; }
.words { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0; margin: 14px 0; list-style: none; }
.words li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; font-weight: 650; display: flex; gap: 6px; align-items: baseline; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.words small { color: var(--muted); font-size: 10.5px; min-width: 14px; }

/* addresses / qr */
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.addr-big { display: block; background: color-mix(in srgb, var(--bg) 60%, var(--card)); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 10px 0 2px; font-size: 14px; line-height: 1.5; text-align: center; }
.qr-card { text-align: center; padding: 18px; }
.qr-wrap { position: relative; width: 232px; margin: 0 auto 6px; }
.qr { display: block; width: 232px; height: 232px; background: #fff; border-radius: 18px; padding: 10px; image-rendering: pixelated; }
.coin.qr-logo { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 46px; height: 46px; font-size: 11px; border: 4px solid #fff; }

/* swap */
.swap-card { display: flex; flex-direction: column; }
.swap-card .card { margin: 0; }
.swap-side { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.flip { position: relative; z-index: 2; align-self: center; margin: -14px 0; width: 44px; height: 44px; border-radius: 14px; border: 4px solid var(--bg); background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; cursor: pointer; transition: transform .2s; }
.flip:active { transform: rotate(180deg); }

/* summary */
.summary { padding: 16px; }
.summary-head { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-bottom: 12px; margin-bottom: 6px; border-bottom: 1px dashed var(--line); }
.summary-head.swap { flex-direction: row; justify-content: center; gap: 14px; }
.summary-head .addr-big { width: 100%; font-size: 15px; font-weight: 600; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 14px; } .kv span { color: var(--muted); } .kv b { text-align: end; font-variant-numeric: tabular-nums; }
.kv.strong b { font-size: 16px; }

/* history */
.kind-ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.kind-ic.send { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.kind-ic.receive { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.kind-ic.swap, .kind-ic.bridge { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.status { font-weight: 600; } .status.confirmed { color: var(--ok); } .status.failed { color: var(--danger); } .status.pending { color: var(--warn); }

/* sheet */
.shade { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; animation: fade .2s; }
.shade.out { animation: fade .2s reverse forwards; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { width: 100%; max-width: 560px; margin: 0 auto; max-height: 82vh; display: flex; flex-direction: column; background: var(--bg); border-radius: 24px 24px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .25s cubic-bezier(.2, .8, .2, 1); }
@keyframes up { from { transform: translateY(40%); } to { transform: none; } }
.grab { width: 40px; height: 5px; border-radius: 5px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 17px; }
.sheet-list { overflow-y: auto; margin: 8px -16px 0; }
.search { margin-bottom: 4px; }

/* done */
.done { text-align: center; padding: 30px 0 10px; }
.tick { width: 92px; height: 92px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 16px 40px -14px #22c55e; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* referral */
.ref { text-align: center; padding: 20px; } .big-num { display: block; font-size: 20px; margin-top: 12px; }
.order-box { border-top: 1px dashed var(--line); margin-top: 6px; }

/* skeleton */
.skeleton i { display: block; background: linear-gradient(90deg, var(--line) 25%, color-mix(in srgb, var(--muted) 26%, transparent) 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
.skeleton > i { width: 42px; height: 42px; border-radius: 50%; }
.skeleton .grow i { height: 11px; margin: 5px 0; width: 60%; } .skeleton .grow i + i { width: 35%; }
.skeleton-hero { height: 220px; background: linear-gradient(90deg, var(--card) 25%, var(--line) 50%, var(--card) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; box-shadow: none; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 650; font-size: 13.5px; box-shadow: var(--shadow); animation: in .2s; }
.toast.out { opacity: 0; transition: opacity .4s; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
