:root {
  color-scheme: light dark;

  /* Trust — light (default) */
  --bg: #fcfcfc;
  --surface: #f2f2f5;
  --surface-2: #ebebed;
  --surface-pressed: #e2e2e7;
  --fg: #0a0d10;
  --muted: #7d7d7d;
  --idle: #b0b2b8;
  --line: #e6e6e9;
  --brand: #0500ff;
  --brand-press: #2b2be0;
  --tron: #ea0027;
  --warn-bg: #f6f0e3;
  --good: #2ebd59;
  --bad: #f04a5c;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Trust — dark */
    --bg: #0e1019;
    --surface: #1c2030;
    --surface-2: #262936;
    --surface-pressed: #2e3243;
    --fg: #fafafa;
    --muted: #767986;
    --idle: #4a4e5c;
    --line: #262936;
    --brand: #0500ff;
    --brand-press: #2b2be0;
    --tron: #ea0027;
    --warn-bg: #2a2418;
    --good: #34d05f;
    --bad: #ff7b7b;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
}

img {
  display: block;
}

main {
  width: 100%;
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* ---- top navigation (Trust in-page nav) ---- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 8px 0;
  position: relative;
}

.nav-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--fg);
}

.nav-back:active {
  background: var(--surface);
}

.nav-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: var(--fg);
  font-size: 17px;
  font-weight: 600;
  line-height: 22px;
  letter-spacing: -0.01em;
}

/* ---- recipient card ---- */
.to {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
}

.to-icon {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 999px;
  object-fit: contain;
}

.to-meta {
  min-width: 0;
}

.to-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.to-addr {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg);
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: -0.01em;
}

/* ---- amount display ---- */
.amount-wrap {
  padding: 30px 4px 12px;
}

.amount {
  display: block;
  max-width: 100%;
  min-height: 66px;
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 56px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--idle);
  transition: color 0.15s ease;
}

.amount.filled {
  color: var(--fg);
}

.amount.long {
  font-size: 40px;
}

.amount:empty::before {
  content: "0";
}

.convert {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 22px;
}

.convert[hidden] {
  display: none;
}

.convert svg {
  flex: none;
}

/* ---- balance row ---- */
.balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 4px 4px 20px;
}

.balance-text {
  min-width: 0;
}

.balance {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg);
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.balance-usd {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}

.max {
  flex: none;
  min-height: 40px;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  line-height: 16px;
  transition: background 0.1s ease;
}

.max:active:enabled {
  background: var(--brand-press);
}

.max:disabled {
  background: var(--surface);
  color: var(--idle);
}

/* ---- keypad ---- */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.keypad button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--fg);
  font-size: 20px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: background 0.1s ease;
}

.keypad button:active {
  background: var(--surface-pressed);
}

/* ---- messages ---- */
.status,
.error,
.success {
  margin: 0;
  padding: 16px 4px 0;
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
}

.status {
  color: var(--muted);
}

.error {
  color: var(--bad);
}

.success {
  color: var(--good);
}

.status[hidden],
.error[hidden],
.success[hidden] {
  display: none;
}

.success a {
  color: inherit;
}

/* ---- primary action ---- */
.send {
  width: 100%;
  height: 52px;
  margin-top: auto;
  border-radius: 14px;
  background: var(--surface);
  color: var(--idle);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background 0.1s ease, color 0.1s ease;
}

.send:enabled {
  background: var(--brand);
  color: #ffffff;
}

.send:active:enabled {
  background: var(--brand-press);
}

/* ---- footnote ---- */
.gas-note {
  margin: 14px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.legal {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
}

.legal a {
  color: inherit;
  text-decoration: none;
}

.legal a:active {
  text-decoration: underline;
}

/* =====================================================
   Receive screen (receive.html)
   ===================================================== */
.receive-main {
  align-items: stretch;
}

.receive-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 24px;
}

.network-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font-size: 13px;
  font-weight: 600;
  line-height: 16px;
}

.network-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--tron);
}

.qr-card {
  position: relative;
  margin-top: 24px;
  padding: 20px;
  border-radius: 20px;
  background: #ffffff;
  width: 280px;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-logo {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 6px #ffffff;
}

.receive-addr {
  margin-top: 22px;
  padding: 0 8px;
  text-align: center;
  color: var(--fg);
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  word-break: break-all;
  letter-spacing: -0.01em;
}

.receive-warn {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--warn-bg);
  color: var(--fg);
  font-size: 13px;
  line-height: 18px;
}

.receive-warn .warn-ic {
  flex: none;
  width: 20px;
  height: 20px;
  color: #b8860b;
}

@media (prefers-color-scheme: dark) {
  .receive-warn .warn-ic {
    color: #e6b34a;
  }
}

.receive-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 24px;
}

.btn-ghost {
  flex: 1;
  min-height: 50px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--fg);
  font-size: 15px;
  font-weight: 600;
}

.btn-ghost:active {
  background: var(--surface-pressed);
}

.receive-binance {
  width: 100%;
  min-height: 50px;
  margin-top: 12px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--fg);
  font-size: 15px;
  font-weight: 600;
}

.receive-binance:active {
  background: var(--surface-pressed);
}

.exchange-sub {
  margin: 8px 0 0;
  text-align: center;
  font-size: 11px;
  line-height: 16px;
  color: var(--muted);
}