/* ── Reset & Tokens ─────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #07090e;
  --bg2: #0c0f16;
  --surface: #161b27;
  --surface2: #222838;
  --surface3: #2e3447;
  --border: #2a3146;
  --border2: #3a4159;
  --accent: #f97316;
  --accent2: #fb923c;
  --accent3: #fdba74;
  --accent-grad: linear-gradient(135deg, #fb923c 0%, #f97316 55%, #ea580c 100%);
  --accent-glow: rgba(249, 115, 22, 0.18);
  --accent-glow-strong: rgba(249, 115, 22, 0.35);
  --text: #f1f3f7;
  --text2: #a3aabb;
  --text3: #6b7286;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 8px 28px -6px rgba(249, 115, 22, 0.35);

  /* Safe-area insets for notched phones */
  --sa-top: env(safe-area-inset-top, 0);
  --sa-bot: env(safe-area-inset-bottom, 0);
}

body {
  background:
    radial-gradient(80% 50% at 50% 0%, rgba(249,115,22,0.06), transparent 60%),
    radial-gradient(60% 40% at 100% 100%, rgba(98,126,234,0.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;          /* iOS PWA: 100vh includes home-indicator strip → content gets cut off; 100dvh hugs the real visible area */
  overflow: hidden;        /* page itself never scrolls — only inner lists */
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;   /* prevent iOS rotation auto-zoom */
  position: fixed;         /* locks body from rubber-band bounce in iOS standalone PWA */
  inset: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── App shell — full viewport flex container ────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;                                /* dynamic viewport — same iOS fix as above */
  padding-bottom: calc(54px + var(--sa-bot));   /* room for bottom nav */
  box-sizing: border-box;
}

.view {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;            /* lets children scroll instead of overflowing */
}
.view.active { display: flex; animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Sticky areas inside views */
.view .topbar,
.view .balance-hero,
.view .qa-row,
.view .section-h,
.view #wallet-display,
.view #content {
  flex-shrink: 0;
}

/* Scrollable list areas inside views */
.view .scroll-area,
#asset-list,
#wallet-asset-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Top bar ────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + var(--sa-top)) 12px 8px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.topbar .icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 18px;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.topbar .icon-btn:active { transform: scale(0.92); background: var(--surface2); }

/* Spinner state for the refresh button — keeps the icon size compact
   while loading instead of expanding to fit "↻ Loading…" text. */
.icon-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}
.icon-btn.loading > * ,
.icon-btn.loading {
  animation: icon-spin 0.9s linear infinite;
}
@keyframes icon-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.topbar .topbar-title {
  display: flex; align-items: center; gap: 10px;
}
.topbar .topbar-title svg { width: 28px; height: 28px; }

/* ── Home: total balance card ───────────────────────────────── */
.balance-hero {
  margin: 4px 12px 14px;
  padding: 20px 20px 22px;
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(249,115,22,0.22), transparent 55%),
    radial-gradient(120% 100% at 100% 100%, rgba(251,146,60,0.12), transparent 55%),
    linear-gradient(180deg, #1a1f2d, #131724);
  border: 1px solid var(--border);
  border-radius: 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 22px -8px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.04);
}
.balance-hero::before {
  content: '';
  position: absolute; inset: -1px;
  border-radius: 21px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(249,115,22,0.55), transparent 35%, transparent 65%, rgba(251,146,60,0.35));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.balance-hero::after {
  content: '';
  position: absolute;
  top: -40%; right: -10%;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(249,115,22,0.18), transparent 70%);
  pointer-events: none;
}

.balance-hero .label {
  font-size: 11px;
  color: var(--text2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}
.balance-hero .total {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  margin: 4px 0 2px;
  background: linear-gradient(180deg, #fff, var(--text2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.balance-hero .change {
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
  min-height: 14px;
}

/* ── Quick actions row ──────────────────────────────────────── */
.qa-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 12px 14px;
}
.qa-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
  color: var(--text);
}
.qa-btn:active { transform: scale(0.96); background: var(--surface2); }
.qa-btn .qa-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.qa-btn .qa-label { font-size: 12px; font-weight: 600; }
.qa-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Section header ─────────────────────────────────────────── */
.section-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 16px 6px;
}
.section-h h2 { font-size: 14px; font-weight: 700; letter-spacing: -0.1px; }
.section-h a, .section-h .link-btn {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 8px;
  font-weight: 600;
  font-family: inherit;
}
.section-h .link-btn:active { opacity: 0.6; }

/* ── Network groups ─────────────────────────────────────────── */
.network-group { margin: 0 12px 14px; }
.network-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text2);
  padding: 6px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.network-header .reorder-controls {
  flex-direction: row;
  gap: 6px;
}
.network-card {
  background: linear-gradient(180deg, var(--surface), #141826);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.network-card .asset-item {
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}
.network-card .asset-item:last-child { border-bottom: none; }
.network-card .asset-item.selected {
  background: linear-gradient(90deg, var(--accent-glow), transparent 70%);
  border-left: 3px solid var(--accent);
  padding-left: 7px;
  box-shadow: inset 0 0 0 1px rgba(249,115,22,0.10);
}

/* Reorder controls (shown in home Edit mode) */
.reorder-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.reorder-btn {
  width: 32px; height: 26px;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: background 0.1s, transform 0.1s;
}
.reorder-btn:active:not(:disabled) {
  transform: scale(0.92);
  background: var(--accent);
}
.reorder-btn:disabled { opacity: 0.3; cursor: default; }

/* ── Wallet view: card with QR per coin ─────────────────────── */
.wallet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
}
.wallet-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.wallet-card-head .asset-icon { width: 38px; height: 38px; }
.wallet-card-meta { flex: 1; min-width: 0; }
.wallet-card-body {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.wallet-qr {
  display: flex;
  align-items: center;
  justify-content: center;
}
.wallet-qr canvas, .wallet-qr img {
  background: #fff;
  padding: 6px;
  border-radius: 8px;
}
.wallet-card-addr {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--surface2);
  border-radius: 10px;
  padding: 8px 12px;
}
.wallet-card-addr code {
  flex: 1;
  font-size: 11px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: var(--text2);
  word-break: break-all;
}
.wallet-card-body .btn {
  width: 100%;
  padding: 11px;
}

/* ── Asset list (home) ──────────────────────────────────────── */
.asset-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.asset-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 12px;
  transition: background 0.12s;
}
/* Make clickable contexts (wallet picker) explicit */
.network-card .asset-item { cursor: pointer; }
.network-card .asset-item:active { background: var(--surface); }
#asset-list .asset-item { cursor: default; }

.asset-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.asset-icon img { width: 32px; height: 32px; object-fit: contain; }

.asset-meta { flex: 1; min-width: 0; }
.asset-name {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600;
  margin-bottom: 1px;
}
.asset-symbol {
  font-size: 12px; color: var(--text2);
  font-variant-numeric: tabular-nums;
}

/* ── Tx progress pills (incoming / outgoing confirmation status) ── */
.tx-progress-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.tx-progress {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px 5px;
  min-width: 110px;
  max-width: 100%;
}
.tx-prog-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.tx-prog-bar {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.tx-prog-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}
.tx-prog-out .tx-prog-label { color: var(--accent2); }
.tx-prog-out .tx-prog-fill {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 6px rgba(249,115,22,0.45);
}
.tx-prog-in .tx-prog-label { color: var(--green); }
.tx-prog-in .tx-prog-fill {
  background: linear-gradient(90deg, #16a34a, #22c55e);
  box-shadow: 0 0 6px rgba(34,197,94,0.45);
}
/* Indeterminate scanning shimmer when confs == 0 */
.tx-prog-fill[style*="width:0%"],
.tx-prog-fill[style*="width: 0%"] {
  width: 30% !important;
  animation: tx-prog-shimmer 1.4s linear infinite;
}
@keyframes tx-prog-shimmer {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}

.asset-right { text-align: right; flex-shrink: 0; }
.asset-bal { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.asset-usd { font-size: 11px; color: var(--text2); margin-top: 1px; font-variant-numeric: tabular-nums; }

/* ── Coin detail view ──────────────────────────────────────── */
/* #main is a .view — the .view rules below control its display. Don't override here. */
#main { flex-direction: column; }
#main.active { display: flex; }
#sidebar { display: none; }   /* hide old sidebar, replaced by bottom nav */

/* #content scrolls within the coin detail view (so topbar stays sticky) */
#content {
  padding: 0 12px 12px;
  display: flex; flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.balance-card {
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(249,115,22,0.20), transparent 60%),
    radial-gradient(120% 100% at 100% 100%, rgba(98,126,234,0.06), transparent 60%),
    linear-gradient(180deg, #1a1f2d, #131724);
  text-align: center;
  padding: 8px 14px 8px;         /* further trimmed — was 12/14/10 — to give the asset list below more vertical room on iOS */
  border-radius: 20px;
  position: relative;
  box-shadow: 0 6px 22px -8px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.04);
  overflow: hidden;
}
.balance-card::before {
  content: '';
  position: absolute; inset: -1px;
  border-radius: 21px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(249,115,22,0.45), transparent 40%, transparent 60%, rgba(251,146,60,0.25));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.balance-card > * { position: relative; }
.balance-card .coin-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface2); border-radius: 100px;
  padding: 2px 10px; margin-bottom: 4px;
  font-size: 11px; font-weight: 600;
}
.balance-card .amount {
  font-size: 20px; font-weight: 800;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.balance-card .amount-usd {
  font-size: 12px; color: var(--text2); margin-top: 0;
  min-height: 0 !important;        /* the inline 18px reservation pushed content down */
}
/* QR shown inside balance card — compact size to fit one screen */
.balance-card .qr-container {
  margin: 8px 0 6px;               /* further trimmed */
}
.balance-card #qr-output canvas,
.balance-card #qr-output img,
.balance-card #qr-canvas,
.balance-card #wd-qr canvas,
.balance-card #wd-qr img {
  width: 100px !important;           /* 100×100 — small enough that any phone camera at arm's length can still scan, big enough to read */
  height: 100px !important;
  display: block;
  background: transparent;
  padding: 0;
  border-radius: 6px;
}
.balance-card .address-box {
  margin-top: 0;
  padding: 10px 12px;
  font-size: 11px;
}
.balance-card .address-box code { font-size: 11px; }
.balance-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}
.balance-actions.has-stake { grid-template-columns: 1fr 1fr 1fr; }
.balance-actions.has-earn { grid-template-columns: 1fr 1fr 1fr; }
.balance-actions.has-stake.has-earn { grid-template-columns: 1fr 1fr 1fr 1fr; }
.balance-actions .btn { padding: 8px 10px; font-size: 13px; border-radius: 10px; }
.balance-actions.has-stake.has-earn .btn { padding: 8px 4px; font-size: 12px; }
.balance-actions .btn-with-icon { gap: 6px; }
.balance-actions .btn-with-icon svg { width: 13px; height: 13px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  padding: 12px 18px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
  -webkit-appearance: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 14px -4px rgba(249,115,22,0.55), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn-primary:active:not(:disabled) {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  box-shadow: 0 2px 8px -2px rgba(249,115,22,0.45);
}
.btn-outline {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:active:not(:disabled) { background: var(--surface3); border-color: var(--border2); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn-danger { background: var(--red); color: #fff; }

/* Buttons that pair an SVG icon with a text label (Send / History) */
.btn-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-with-icon svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--surface2);
  border-radius: 12px;
  padding: 4px;
}
.tab {
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  transition: all 0.15s;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-group input, .form-group select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--text);
  font-size: 16px;          /* 16px+ stops iOS Safari from auto-zooming on focus */
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.18);
}
.form-group input::placeholder { color: var(--text3); }

/* Segmented control — replaces native <select> for dark-theme consistency.
   Native pickers on iOS ignore CSS, so we render selects as button rows. */
.seg-control {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}
.seg-btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
  text-align: center;
}
.seg-btn:not(.active):active {
  background: var(--surface3);
  transform: scale(0.97);
}
.seg-btn.active {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 2px 8px -3px rgba(249,115,22,0.55);
}

/* ── Receive / Address ──────────────────────────────────────── */
.qr-container {
  display: flex;
  justify-content: center;
  margin: 14px 0 16px;
  position: relative;
}

/* QR frame — white card with gradient ring, soft accent glow,
   and viewfinder corner brackets at NW + SE for a scanner look.
   Shared by the receive QRs (#qr-output / #wd-qr) and the 2FA setup
   QR (#ta-qr) so all scannable QRs in the wallet match. */
#qr-output, #wd-qr, #ta-qr {
  position: relative;
  display: inline-block;
  padding: 12px;
  background: #fff;
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(249,115,22,0.45),
    0 0 0 4px rgba(249,115,22,0.10),
    0 10px 28px -6px rgba(249,115,22,0.30),
    0 6px 16px rgba(0,0,0,0.45);
}
#qr-output::before, #qr-output::after,
#wd-qr::before, #wd-qr::after,
#ta-qr::before, #ta-qr::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2.5px solid var(--accent);
  pointer-events: none;
}
#qr-output::before, #wd-qr::before, #ta-qr::before {
  top: -5px; left: -5px;
  border-right: 0; border-bottom: 0;
  border-top-left-radius: 6px;
}
#qr-output::after, #wd-qr::after, #ta-qr::after {
  bottom: -5px; right: -5px;
  border-left: 0; border-top: 0;
  border-bottom-right-radius: 6px;
}

#qr-canvas, #qr-output canvas, #qr-output img,
#wd-qr canvas, #wd-qr img,
#ta-qr canvas, #ta-qr img {
  display: block;
  border-radius: 6px;
  background: #fff;
  padding: 0;
}

.address-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  transition: border-color 0.15s, background 0.15s;
}
.address-box:hover { border-color: var(--border2); }
.address-box code {
  flex: 1;
  font-size: 12px;
  word-break: break-all;
  color: var(--text2);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  line-height: 1.4;
}

/* ── History list ───────────────────────────────────────────── */
.history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2);
  font-size: 16px;
  flex-shrink: 0;
}
.history-icon.send { color: var(--red); }
.history-icon.recv { color: var(--green); }
.history-meta { flex: 1; min-width: 0; }
.history-type { font-size: 14px; font-weight: 600; }
.history-time { font-size: 12px; color: var(--text2); margin-top: 2px; }
.history-amt { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Bottom nav ─────────────────────────────────────────────── */
/* Number of nav columns is keyed off the class on the <nav> element
   (.nav-3 for the current Home / Wallet / Settings layout) so adding
   or removing a tab doesn't require touching this file. Default to 3
   if no count class is set. */
#bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(10, 13, 20, 0.88);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  backdrop-filter: blur(24px) saturate(140%);
  border-top: 1px solid var(--border);
  padding-bottom: var(--sa-bot);
  z-index: 50;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  cursor: pointer;
  color: var(--text3);
  transition: color 0.15s, transform 0.1s;
  font-size: 10px;
  font-weight: 500;
  background: none;
  border: none;
  font-family: inherit;
  position: relative;
}
.nav-item.active { color: var(--accent); }
.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 2px;
  background: var(--accent-grad);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 0 12px rgba(249,115,22,0.6);
}
.nav-item:active { transform: scale(0.94); }
.nav-item svg { width: 20px; height: 20px; }

/* ── Setup screen ───────────────────────────────────────────── */
#setup-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
  padding-top: calc(16px + var(--sa-top));
  padding-bottom: calc(16px + var(--sa-bot));
  overflow-y: auto;
}
.setup-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}
.setup-box h1 { font-size: 24px; margin-bottom: 6px; letter-spacing: -0.4px; }
.setup-box p { color: var(--text2); margin-bottom: 22px; font-size: 14px; line-height: 1.5; }

.seed-display {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin: 14px 0;
}
.seed-word {
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 6px;
  font-size: 13px; text-align: center;
  font-weight: 500;
}
.seed-word span { color: var(--text3); font-size: 10px; display: block; margin-bottom: 2px; }

.warning-box {
  background: rgba(249, 115, 22, 0.08);
  border: 1px solid rgba(249, 115, 22, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--accent2);
  line-height: 1.45;
  margin-bottom: 16px;
}

/* ── Toast ──────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(80px + var(--sa-bot));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: 92%;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* Tappable toast (has an action link) must accept clicks. */
#toast.has-action { pointer-events: auto; }
#toast .toast-msg { color: var(--text); }
#toast .toast-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(16,185,129,0.18);
  color: #34d399;
}
#toast .toast-action {
  margin-left: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  background: rgba(249,115,22,0.12);
  flex-shrink: 0;
  white-space: nowrap;
}
#toast .toast-action:active { background: rgba(249,115,22,0.22); }
#toast.toast-success {
  border-color: rgba(16,185,129,0.4);
}

/* ── Network badge ──────────────────────────────────────────── */
.network-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 100px;
  font-weight: 600;
  display: inline-block;
  letter-spacing: 0.02em;
}
.network-erc20 { background: rgba(98, 126, 234, 0.18);  color: #93b0ff; }
.network-trc20 { background: rgba(239, 68, 68, 0.18);   color: #ff8a8a; }
.network-btc   { background: rgba(247, 147, 26, 0.18);  color: #ffb15a; }
.network-xmr   { background: rgba(255, 102, 0, 0.18);   color: #ff8c3a; }
.network-bsc   { background: rgba(243, 186, 47, 0.18);  color: #ffd86b; }
.network-poly  { background: rgba(130, 71, 229, 0.20);  color: #b896ff; }
.network-avax  { background: rgba(232, 65, 66, 0.18);   color: #ff8b8c; }
.network-arb   { background: rgba(40, 160, 240, 0.18);  color: #6cc4ff; }
.network-opt   { background: rgba(255, 4, 32, 0.18);    color: #ff6680; }
.network-base  { background: rgba(0, 82, 255, 0.20);    color: #6b91ff; }
.network-ltc   { background: rgba(190, 190, 190, 0.16); color: #d6d6d6; }
.network-doge  { background: rgba(194, 166, 51, 0.20);  color: #e0c45e; }
.network-sol   { background: rgba(153, 69, 255, 0.20);  color: #c79bff; }

/* Live Aave supply APY badge — appears next to the asset name on
   stablecoins that can be deposited via the Earn modal. */
.apy-badge {
  display: inline-block;
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  vertical-align: middle;
}
.apy-badge::before {
  content: '↑ ';
  opacity: 0.7;
}

/* ── Inbox bell + view ──────────────────────────────────────────── */
.inbox-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 6px rgba(249,115,22,0.6);
}
.inbox-section-label {
  font-size: 13px;
  color: var(--text2);
  font-weight: 600;
  padding: 14px 4px 8px;
  letter-spacing: 0.02em;
}
.inbox-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}
.inbox-item:last-child { border-bottom: none; }
.inbox-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  flex-shrink: 0;
}
.inbox-icon svg { width: 18px; height: 18px; }
.inbox-text { flex: 1; min-width: 0; padding-top: 2px; }
.inbox-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
  word-break: break-word;
}
.inbox-subtitle {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
  word-break: break-word;
}
.inbox-date {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  padding-top: 2px;
  text-align: right;
}
.inbox-date-day {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
}
.inbox-date-time {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* Small inline pill on the title row showing which chain the entry
   came from — Polygon / Ethereum / TRON etc. */
.inbox-network {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 100px;
  background: rgba(249, 115, 22, 0.15);
  color: var(--accent2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

/* ── Custom confirm dialog (replaces browser confirm) ──────────── */
.confirm-rows {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 14px;
  margin: 14px 0 18px;
}
.confirm-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 11px 0;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.confirm-row:last-child { border-bottom: none; }
.confirm-label {
  color: var(--text2);
  flex-shrink: 0;
  padding-top: 1px;
}
.confirm-value {
  color: var(--text);
  font-weight: 600;
  text-align: right;
  word-break: break-all;
  min-width: 0;
}
.confirm-value-code {
  /* Match the other rows exactly — same size, weight and color.
     We drop the monospace + smaller text so the address row reads as
     one consistent value with Amount / Network fee rather than as a
     separate 'code' style. word-break in .confirm-value handles wrap. */
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  letter-spacing: 0;
}

/* ── Send-form recipient address input + Paste / Scan icon buttons ── */
.addr-input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.addr-input-group input,
.addr-input-group textarea {
  /* Leave room on the right for the two 38px icon buttons + gaps */
  padding-right: 88px !important;
}
.addr-input-group textarea {
  /* Long addresses (SOL 44 chars, XMR 95 chars) used to vanish to the
     right of a one-line input. Wrapping inside the field lets users see
     the full string without having to drag-scroll inside the box. */
  display: block;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.45;
  resize: none;
  outline: none;
  word-break: break-all;
  overflow-wrap: anywhere;
  min-height: 60px;
  transition: border-color 0.15s, background 0.15s;
}
.addr-input-group textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
}
.addr-icon-btn {
  position: absolute;
  top: 9px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s, color 0.15s;
}
.addr-icon-btn svg { width: 18px; height: 18px; }
.addr-icon-btn:active {
  transform: scale(0.92);
  background: var(--surface3);
  color: var(--accent2);
}
.addr-icon-btn:nth-of-type(1) { right: 46px; }
.addr-icon-btn:nth-of-type(2) { right: 6px; }

/* ── QR camera scanner overlay ─────────────────────────────────── */
.qr-scanner-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-scanner-overlay video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.qrs-frame {
  position: absolute;
  width: 260px;
  height: 260px;
  pointer-events: none;
}
/* Four corner brackets — scanner-style viewfinder. */
.qrs-corner {
  position: absolute;
  width: 36px;
  height: 36px;
  border: 4px solid var(--accent);
  box-shadow: 0 0 16px rgba(249,115,22,0.6);
}
.qrs-tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 12px; }
.qrs-tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 12px; }
.qrs-bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 12px; }
.qrs-br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 12px; }
.qrs-hint {
  position: absolute;
  bottom: calc(100px + var(--sa-bot));
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  padding: 0 20px;
}
.qrs-cancel {
  position: absolute;
  bottom: calc(40px + var(--sa-bot));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.95);
  color: #000;
  border: none;
  font-weight: 600;
  padding: 10px 28px;
}

/* ── QR camera scanner overlay ─────────────────────────────────── */
.qr-scanner-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-scanner-overlay video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.qrs-frame {
  position: absolute;
  width: 260px;
  height: 260px;
  pointer-events: none;
}
/* Four corner brackets — scanner-style viewfinder. */
.qrs-corner {
  position: absolute;
  width: 36px;
  height: 36px;
  border: 4px solid var(--accent);
  box-shadow: 0 0 16px rgba(249,115,22,0.6);
}
.qrs-tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 12px; }
.qrs-tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 12px; }
.qrs-bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 12px; }
.qrs-br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 12px; }
.qrs-hint {
  position: absolute;
  bottom: calc(100px + var(--sa-bot));
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  padding: 0 20px;
}
.qrs-cancel {
  position: absolute;
  bottom: calc(40px + var(--sa-bot));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.95);
  color: #000;
  border: none;
  font-weight: 600;
  padding: 10px 28px;
}

/* ── Settings page hero (iOS Settings pattern) ─────────────── */
.settings-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 12px 8px;
  gap: 6px;
}
.settings-hero-icon {
  width: 88px;
  height: 88px;
  /* iOS squircle — same rounding as the home topbar icon and the
     Android/iOS app icon mask. Keep object-fit:cover so a non-square
     source image still fills cleanly. */
  border-radius: 22%;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(249, 115, 22, 0.18),
              0 2px 8px rgba(0, 0, 0, 0.4);
  margin-bottom: 4px;
}
.settings-hero-name {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
}
.settings-hero-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text2);
}
.settings-hero-version {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
}

/* Small uppercase section header above each settings card cluster.
   Matches iOS Settings (and Apple HIG list-group headers). */
.settings-section-label {
  margin: 16px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text3);
}

/* ── Settings menu items ────────────────────────────────────── */
.settings-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  transition: background 0.15s;
}
.settings-menu-item:last-child { border-bottom: none; }
.settings-menu-item:active { background: var(--surface2); }
.settings-menu-item .menu-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(249,115,22,0.18), rgba(249,115,22,0.06));
  border: 1px solid rgba(249,115,22,0.20);
  color: var(--accent2);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.settings-menu-item .menu-icon svg {
  width: 18px;
  height: 18px;
}
.settings-menu-item .menu-label { flex: 1; }
.settings-menu-item .menu-arrow {
  color: var(--text3);
  font-size: 20px;
  font-weight: 300;
}

/* ── Modal dialogs ──────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(11,13,18,0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { font-size: 19px; margin-bottom: 6px; letter-spacing: -0.2px; }
.modal p { color: var(--text2); font-size: 14px; margin-bottom: 16px; line-height: 1.5; }
.modal .modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

/* ── Settings overlay ───────────────────────────────────────── */
#settings-overlay {
  position: fixed; inset: 0;
  background: rgba(11, 13, 18, 0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 150;
  display: none;
  align-items: flex-end;
}
#settings-overlay.show { display: flex; }
#settings-overlay > div {
  background: var(--surface);
  width: 100%;
  max-height: 90vh;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(24px + var(--sa-bot));
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }

.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.settings-row:last-child { border-bottom: none; }

/* Drag-to-reorder affordances for Manage Assets */
.settings-row .drag-handle {
  opacity: 0.55;
  transition: opacity 0.15s;
}
.settings-row .drag-handle:active { cursor: grabbing; opacity: 1; }
.settings-row-ghost {
  opacity: 0.4;
  background: var(--surface2);
  border-radius: 8px;
}

/* ── Toggle switch ──────────────────────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px; height: 28px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--surface3);
  border-radius: 100px;
  transition: background 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-track::after {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.toggle-switch input:checked + .toggle-track::after { transform: translateX(18px); }

/* ── Misc utilities ─────────────────────────────────────────── */
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text2); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-accent { color: var(--accent); }

::-webkit-scrollbar { width: 0; }    /* no scrollbars on mobile */

#loading { text-align: center; color: var(--text2); padding: 24px; font-size: 14px; }

/* ── Sync overlay (Monero) ──────────────────────────────────── */
#sync-overlay {
  background: rgba(11, 13, 18, 0.95);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* ── Desktop tweaks ─────────────────────────────────────────── */
@media (min-width: 768px) {
  #app { max-width: 480px; margin: 0 auto; box-shadow: 0 0 60px rgba(0,0,0,0.4); }
  #bottom-nav { left: 50%; transform: translateX(-50%); max-width: 480px; border-radius: 0; }
}

/* ── iOS PWA polish ────────────────────────────────────────────
   These rules target Apple WebKit only via the -webkit-touch-callout
   support query (the cleanest way to detect iOS Safari / iOS standalone
   PWA without UA sniffing). Goals: kill 300ms tap delay, prevent
   text-size auto-zoom on input focus, and stop iOS image long-press
   share sheet from breaking the QR / poster long-press flow. */
@supports (-webkit-touch-callout: none) {
  /* Kill 300ms tap-delay on every interactive element */
  button, .nav-item, .icon-btn, .seg-control > *, .filter-tab, a,
  [onclick], [role="button"] {
    touch-action: manipulation;
    -webkit-touch-callout: none;
  }

  /* iOS Safari auto-zooms any <input>/<textarea>/<select> whose
     font-size is < 16px on focus, leaving the layout zoomed even after
     blur. Bump everything to 16px on iOS only (visual style is preserved
     for non-iOS via the rules above, where the address textarea stays
     12.5px monospace by design). */
  input, textarea, select {
    font-size: 16px !important;
  }

  /* Disable image long-press save / iOS context menu on the QR canvas
     and asset posters so a long touch doesn't pop the share sheet. */
  canvas, img.poster, .qr-wrap canvas {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}
