:root {
  --bg: #060912;
  --bg-grad: #0f1a2e;
  --surface: #0d1426;
  --surface-elev: #131c33;
  --border: #1f2a47;
  --text: #eaf1ff;
  --text-secondary: #9aa7c4;
  --text-muted: #6b7794;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(ellipse at top, var(--bg-grad), var(--bg));
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#root {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 0 40px;
}

.screen.center {
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 60vh;
}

.boot {
  min-height: 100vh;
}

.welcome {
  flex: 1;
  justify-content: space-between;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 48px 16px;
}

.logo-mark {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 32px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}

h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0;
}

h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
}

h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
}

.sub {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

.sub.small {
  font-size: 13px;
  margin: 4px 0 12px;
}

.disclaimer {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  margin: 16px 0 0;
}

.note {
  color: var(--warn);
  font-size: 13px;
  line-height: 1.5;
  min-height: 20px;
}

.warn {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--warn);
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.helper-text {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

.btn.primary:not(:disabled):hover {
  background: var(--primary-hover);
}

.btn.secondary {
  background: var(--surface-elev);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:not(:disabled):hover {
  background: var(--surface);
}

.btn.ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn.ghost:not(:disabled):hover {
  background: var(--surface);
  color: var(--text);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn.danger:not(:disabled):hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn.small {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 8px;
}

.btn.back {
  align-self: flex-start;
}

.phrase {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  min-height: 140px;
}

.phrase.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
}

.word {
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.word em {
  color: var(--text-muted);
  font-style: normal;
  font-size: 11px;
  min-width: 14px;
}

.phrase-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
}

.phrase-input:focus {
  outline: none;
  border-color: var(--primary);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wallet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 16px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chain-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.card-head strong {
  flex: 1;
  font-size: 15px;
}

.balance {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}

.address {
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
  color: var(--text-secondary);
  line-height: 1.4;
}

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

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  background: var(--surface-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  max-width: 320px;
  width: 100%;
}

.modal-card img {
  border-radius: 8px;
}

.modal-address {
  width: 100%;
  text-align: center;
}

.version {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 16px;
}

/* ── Wallet shell + tab bar ── */
.wallet-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 72px; /* room for tab bar */
}

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
  z-index: 50;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  color: var(--text-muted);
  font-family: inherit;
  transition: color 0.15s;
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn:not(.active):hover {
  color: var(--text-secondary);
}

.tab-icon {
  font-size: 18px;
  line-height: 1;
}

.tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.logo-mark.small {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 18px;
}

/* ── Send screen ── */
.send-screen {
  gap: 12px;
  padding-top: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-field {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
}

select.input-field {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa7c4' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.fee-estimate {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 10px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  min-height: 32px;
}

.send-status {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.5;
  min-height: 20px;
}

.send-status.error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: var(--danger);
}

.send-status.success {
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.25);
  color: var(--accent);
}

.tx-link {
  color: var(--accent);
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

/* ── Receive screen ── */
.receive-screen {
  align-items: center;
  gap: 16px;
  padding-top: 16px;
}

.chain-pills {
  display: flex;
  gap: 8px;
}

.chain-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 20px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.chain-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.qr-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-img {
  border-radius: 8px;
  display: block;
}

.receive-address {
  width: 100%;
  text-align: center;
  font-size: 11px;
}

/* ── Assets tab card updates ── */
.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.wallet-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 16px;
}

.wallet-header h2 {
  flex: 1;
}

/* ── Multi-chain list ── */
.card-section-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.address-mini {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--text-muted);
  word-break: break-all;
}

.chain-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chain-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: 8px;
  transition: background 0.1s;
}

.chain-row:hover {
  background: rgba(255,255,255,0.03);
}

.chain-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
}

.chain-bal {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 80px;
  text-align: right;
}

/* ── TX success modal ── */
.tx-modal {
  gap: 12px;
}

.tx-success-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(16,185,129,0.15);
  border: 2px solid rgba(16,185,129,0.4);
  color: var(--accent);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.tx-hash-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  word-break: break-all;
  width: 100%;
}

/* ── Import tabs ── */
.import-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.import-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.import-tab.active {
  background: var(--surface-elev);
  color: var(--text);
}

/* ── Wallet list in settings ── */
.wallet-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wallet-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background 0.1s;
}

.wallet-row-active {
  background: rgba(37,99,235,0.08);
  border-color: rgba(37,99,235,0.2);
}

.wallet-row-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wallet-row-name {
  font-size: 13px;
  font-weight: 600;
}

.wallet-row-addr {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.wallet-row-actions {
  display: flex;
  gap: 6px;
}

.active-wallet-badge {
  color: var(--primary) !important;
  border-color: rgba(37,99,235,0.3) !important;
  cursor: default;
}

.danger-text {
  color: var(--danger) !important;
}

/* ── Local data table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 12px;
}

.data-key {
  color: var(--text-muted);
  padding: 4px 8px 4px 0;
  white-space: nowrap;
  vertical-align: top;
  width: 40%;
}

.data-val {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  color: var(--text-secondary);
  word-break: break-all;
  padding: 4px 0;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Inline rename ───────────────────────────────────────────────────────────── */
.inline-rename {
  height: 28px;
  padding: 2px 8px;
  font-size: 13px;
}

/* ── Settings actions ────────────────────────────────────────────────────────── */
.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

/* ── Receive actions row ─────────────────────────────────────────────────────── */
.receive-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

/* ── Collapsible token groups ────────────────────────────────────────────────── */
.token-group-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 0;
  cursor: pointer;
  text-align: left;
}
.token-group-toggle:first-child { border-top: none; }
.token-group-toggle:hover { color: var(--text); }
.toggle-arrow { margin-left: auto; font-size: 11px; }

.token-group-rows .chain-row {
  padding-left: 12px;
}

.token-sym-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-elev);
  border-radius: 4px;
  padding: 2px 6px;
  min-width: 44px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Token UI ───────────────────────────────────────────────────────────────── */
.token-chain-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.2;
}

.chain-name {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.token-info-box {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 6px;
  min-height: 0;
}
.token-info-box.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.token-info-box.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.balance-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.danger-text {
  color: var(--danger) !important;
}

/* Tighten chain-row when name has sub-label */
.chain-row .chain-name span:first-child {
  font-size: 14px;
  font-weight: 500;
}

/* Full-width send button */
.btn.primary.full-width {
  width: 100%;
}

/* Token section in assets */
.card-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.card-section-head strong {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (max-width: 380px) {
  .phrase {
    grid-template-columns: repeat(2, 1fr);
  }
  h1 {
    font-size: 30px;
  }
}
