:root {
  --bg: #0F141B;
  --surface: #171E28;
  --surface-2: #1E2735;
  --border: #253041;
  --text: #F3F6FA;
  --muted: #8E9CB2;
  --accent: #3375BB;
  --accent-bright: #4B8DF8;
  --tether: #26A17B;
  --green: #16C784;
  --red: #EA3943;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
  overscroll-behavior-y: contain;
}

.hidden { display: none !important; }

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(38, 161, 123, 0.45);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.env-pill {
  font-size: 11px;
  color: var(--tether);
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active { transform: scale(0.95); }
.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* iOS Tip */
.ios-tip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  background: rgba(51, 117, 187, 0.14);
  border: 1px solid rgba(75, 141, 248, 0.35);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 12.5px;
  line-height: 1.4;
  color: #D9E6FA;
}

.ios-tip span {
  color: #FFFFFF;
  font-weight: 600;
}

.ios-tip-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
}

/* Hero Card */
.hero-card {
  background: linear-gradient(155deg, #1B2432 0%, #131A24 100%);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 20px 18px 18px;
  margin-bottom: 16px;
  text-align: center;
}

.hero-label-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.eye-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
}

.hero-balance {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 6px 0 4px;
  word-break: break-word;
}

.hero-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 18px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.action-item {
  background: none;
  border: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
}

.action-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  transition: transform 0.12s ease;
}

.action-circle.primary {
  background: var(--accent);
  border-color: var(--accent-bright);
  color: #FFF;
}

.action-item:active .action-circle { transform: scale(0.93); }

/* Setup Banner */
.setup-banner {
  background: rgba(38, 161, 123, 0.1);
  border: 1px solid rgba(38, 161, 123, 0.35);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

.setup-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 5px;
}

.setup-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 12px;
}

/* Token Section */
.section-block {
  margin-bottom: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 4px 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sync-status {
  font-size: 12px;
  color: var(--tether);
}

.token-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.token-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.token-card:active {
  background: var(--surface-2);
  transform: scale(0.99);
}

.token-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.token-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.token-avatar.large {
  width: 58px;
  height: 58px;
  margin: 0 auto 10px;
}

.token-avatar img.main-logo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: var(--tether);
}

.net-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  color: #FFF;
}

.token-avatar.large .net-badge {
  width: 22px;
  height: 22px;
  font-size: 11px;
}

.net-badge.tron { background: #E02424; }
.net-badge.bsc { background: #F0B90B; color: #111; }
.net-badge.ethereum { background: #627EEA; }

.token-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.token-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.token-symbol {
  font-weight: 700;
  font-size: 15px;
}

.net-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}

.token-price-row {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 6px;
}

.chg-pos { color: var(--green); }
.chg-neg { color: var(--red); }

.token-right {
  text-align: right;
  flex-shrink: 0;
}

.token-bal {
  font-weight: 700;
  font-size: 15px;
}

.token-fiat {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* Buttons & Inputs */
.btn-primary, .btn-success, .btn-secondary {
  border: none;
  border-radius: 13px;
  padding: 13px 16px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}

.btn-primary { background: var(--accent); color: #FFF; }
.btn-success { background: var(--tether); color: #FFF; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.full-width { width: 100%; }

.field-label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin: 12px 0 6px;
}

.field-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.field-input:focus { border-color: var(--accent-bright); }

/* Modals / Bottom Sheets */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 40;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  z-index: 50;
  max-height: 88vh;
  overflow-y: auto;
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 12px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sheet-header h3 { margin: 0; font-size: 17px; }

.sheet-close {
  background: var(--surface-2);
  border: none;
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
}

.sheet-note, .send-mode-note {
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 12px 0;
  line-height: 1.4;
}

.net-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.net-tab {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 10px;
  padding: 9px;
  font-weight: 700;
  cursor: pointer;
}

.net-tab.active {
  background: var(--accent);
  border-color: var(--accent-bright);
  color: #FFF;
}

.qr-box {
  background: #FFF;
  border-radius: 14px;
  width: 196px;
  height: 196px;
  margin: 0 auto 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-img { width: 176px; height: 176px; }

.addr-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  text-align: center;
  margin-bottom: 12px;
}

/* Detail */
.detail-hero { text-align: center; margin-bottom: 14px; }
.detail-bal { font-size: 24px; font-weight: 800; }
.detail-fiat { font-size: 14px; color: var(--muted); margin-top: 2px; }

.detail-rows {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px 12px;
  margin-bottom: 14px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.detail-row:last-child { border-bottom: none; }
.detail-row span { color: var(--muted); }
.detail-row code {
  font-size: 11px;
  color: #7CC4FA;
  word-break: break-all;
  text-align: right;
  max-width: 62%;
}
.detail-row.clickable { cursor: pointer; }

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tx-status {
  margin: 10px 0;
  padding: 10px;
  border-radius: 10px;
  font-size: 12.5px;
  background: rgba(22, 199, 132, 0.12);
  border: 1px solid rgba(22, 199, 132, 0.4);
  word-break: break-all;
}

.tx-status.error {
  background: rgba(234, 57, 67, 0.12);
  border-color: rgba(234, 57, 67, 0.4);
}

/* Footer & Toast */
.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 22px;
  line-height: 1.7;
}

.app-footer a { color: var(--accent-bright); text-decoration: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #232E3E;
  color: #FFF;
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 80;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
