/* ========== DESIGN TOKENS (dark only) ========== */
:root {
  color-scheme: dark;

  --bg: hsl(230, 18%, 7%);
  --surface: hsl(230, 16%, 10%);
  --surface-2: hsl(230, 14%, 13%);
  --surface-3: hsl(230, 12%, 17%);
  --border: hsl(230, 10%, 19%);
  --border-strong: hsl(230, 10%, 27%);

  --text: hsl(230, 20%, 96%);
  --text-2: hsl(230, 10%, 72%);
  --text-3: hsl(230, 8%, 52%);

  --primary: hsl(245, 85%, 70%);
  --primary-hover: hsl(245, 85%, 76%);
  --primary-soft: hsla(245, 85%, 65%, .15);
  --success: hsl(155, 60%, 55%);
  --success-soft: hsla(155, 60%, 55%, .12);
  --danger: hsl(0, 75%, 65%);
  --danger-soft: hsla(0, 75%, 60%, .12);
  --warning: hsl(38, 90%, 62%);
  --warning-soft: hsla(38, 90%, 55%, .12);
  --aave: hsl(315, 60%, 68%);
  --aave-soft: hsla(315, 60%, 60%, .15);

  --r-sm: 6px;
  --r: 10px;
  --r-md: 12px;
  --r-lg: 16px;

  --f-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --f-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

/* ========== RESET ========== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html, body {
  font-family: var(--f-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--primary-soft); color: var(--text); }

/* ========== LAYOUT ========== */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px calc(40px + env(safe-area-inset-bottom));
}

/* ========== HEADER ========== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.logo-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), hsl(280, 75%, 62%));
  display: grid; place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  flex-shrink: 0;
}
.logo-text { font-weight: 600; font-size: 15px; letter-spacing: -.01em; line-height: 1.1; }
.logo-sub { font-size: 11px; color: var(--text-3); font-weight: 400; margin-top: 1px; }

.header-actions { display: flex; gap: 8px; align-items: center; }

/* Currency dropdown */
.currency { position: relative; }
.currency-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
.currency-btn:hover { background: var(--surface-3); }
.currency-btn .currency-sym { color: var(--text-2); font-weight: 700; }
.currency-btn .currency-code { letter-spacing: .02em; }
.currency-btn svg { width: 12px; height: 12px; color: var(--text-3); transition: transform .2s; }
.currency-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.currency-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.currency-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-align: left;
  transition: background .12s, color .12s;
}
.currency-opt:hover { background: var(--surface-2); color: var(--text); }
.currency-opt.on { background: var(--surface-2); color: var(--text); }
.currency-opt .currency-sym { width: 18px; color: var(--text-3); font-weight: 700; text-align: center; }
.currency-opt.on .currency-sym { color: var(--primary); }
.currency-opt .currency-code { font-weight: 600; letter-spacing: .02em; }

.hbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  width: 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.hbtn:hover { background: var(--surface-3); color: var(--text); }
.hbtn svg { width: 14px; height: 14px; }

/* Icon button */
.ib {
  width: 32px; height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  display: grid; place-items: center;
  transition: all .15s;
  flex-shrink: 0;
}
.ib:hover { color: var(--primary); border-color: var(--border-strong); background: var(--surface); }
.ib:disabled { opacity: .5; cursor: default; }
.ib svg { width: 15px; height: 15px; }

/* ========== HERO ========== */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 20px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), hsl(280, 75%, 62%), hsl(195, 85%, 60%));
}

.hero-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 600;
  margin-bottom: 6px;
}
.hero-value {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  min-width: 0;
}
.hero-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  font-variant-numeric: tabular-nums;
}
.delta.up { background: var(--success-soft); color: var(--success); }
.delta.dn { background: var(--danger-soft); color: var(--danger); }
.delta svg { width: 12px; height: 12px; }
.hero-ago { font-size: 12px; color: var(--text-3); }

/* Distribution */
.dist {
  padding-top: 16px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
}
.dist-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}
.dist-head .dist-count { font-variant-numeric: tabular-nums; color: var(--text-2); }
.dist-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-3);
}
.dist-bar > span {
  height: 100%;
  transition: opacity .15s;
}
.dist-bar > span:hover { opacity: .75; }
.dist-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
  font-size: 12px;
}
.dist-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
}
.dist-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dist-item .pct { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.dist-item .nm { font-weight: 500; }

/* ========== SECTION ========== */
.section { margin-bottom: 18px; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 4px;
}
.section-title h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-3);
  display: flex; align-items: center; gap: 8px;
}
.section-title .count {
  background: var(--surface-3);
  color: var(--text-2);
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ========== WALLET CARD ========== */
.wallet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color .2s;
}
.wallet:hover { border-color: var(--border-strong); }

.w-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 16px 12px;
}
.w-id { flex: 1; min-width: 0; }
.w-label {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -.01em;
  display: flex; align-items: center; gap: 6px;
}
.w-addr {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-3);
  margin-top: 3px;
}

.w-total { text-align: right; flex-shrink: 0; }
.w-total-v {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  line-height: 1.2;
}
.w-total-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
}
.w-ago { font-size: 11px; color: var(--text-3); margin-right: 4px; }
.w-ibtn {
  width: 24px; height: 24px;
  border-radius: 7px;
  color: var(--text-3);
  display: grid; place-items: center;
  transition: all .15s;
}
.w-ibtn:hover { color: var(--text); background: var(--surface-2); }
.w-ibtn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.w-ibtn svg { width: 13px; height: 13px; }

/* Chain pills */
.pills { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 16px 12px; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; }
.pill.aave {
  background: var(--aave-soft);
  color: var(--aave);
  border-color: hsla(315, 40%, 52%, .25);
  gap: 4px;
}

/* ========== AAVE ========== */
.aave-card {
  margin: 8px 16px 14px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: 14px;
  border: 1px solid var(--border);
  position: relative;
}
.aave-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}
.aave-title {
  color: var(--aave);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.005em;
}
.hf {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 500;
}
.hf strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.hf svg { width: 12px; height: 12px; }

.aave-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.metric {
  padding: 10px 4px;
  background: var(--surface);
  border-radius: 10px;
  text-align: center;
  border: 1px solid var(--border);
  overflow: hidden;
}
.metric-l {
  font-size: 9px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 4px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.metric-v {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.metric-v.pos { color: var(--success); }
.metric-v.neg { color: var(--danger); }

.aave-group { margin-top: 10px; }
.aave-group + .aave-group { margin-top: 12px; }
.aave-group-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  margin-bottom: 4px;
}
.aave-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.aave-sym { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.aave-amount { text-align: right; }
.aave-v {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.aave-qty {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}

/* ========== TOKENS ========== */
.toggle {
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  border-top: 1px solid var(--border);
  width: 100%;
  text-align: left;
  display: flex; align-items: center; justify-content: space-between;
  transition: background .15s;
}
.toggle:hover { background: var(--surface-2); color: var(--text); }
.toggle svg { width: 14px; height: 14px; transition: transform .25s; }
.toggle.open svg { transform: rotate(180deg); }

.aave-toggle {
  width: calc(100% + 28px);
  margin: 12px -14px -14px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 13px 13px;
  background: transparent;
}
.aave-toggle:hover { background: transparent; color: var(--text); }
.aave-toggle.open {
  margin-bottom: 0;
  border-radius: 0;
}
.toggle-info { display: flex; align-items: center; gap: 6px; }
.toggle-badge {
  background: var(--surface-3);
  color: var(--text-2);
  padding: 0 6px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tokens { padding: 4px 12px 12px; }

.token {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  padding: 10px 4px;
  align-items: center;
  border-top: 1px solid var(--border);
  transition: background .12s;
  border-radius: 6px;
  margin: 0 -4px;
  padding-left: 8px;
  padding-right: 8px;
}
.token:first-of-type { border-top: none; }
.token:hover { background: var(--surface-2); }

.token-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 10px;
  font-family: var(--f-mono);
  letter-spacing: -.03em;
}
.token-icon-wrap {
  position: relative;
  width: 28px; height: 28px;
  flex-shrink: 0;
}
.token-icon-wrap > .token-icon {
  position: absolute;
  inset: 0;
}
.token-icon-img {
  object-fit: cover;
  z-index: 1;
  background: var(--surface-2);
}
.chain-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
  z-index: 2;
  overflow: hidden;
}
.chain-badge::before {
  content: '';
  position: absolute;
  inset: 2px;
  background: #fff;
  mask-image: var(--logo);
  -webkit-mask-image: var(--logo);
  mask-size: contain;
  -webkit-mask-size: contain;
  mask-position: center;
  -webkit-mask-position: center;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
}

.token-info { min-width: 0; }
.token-sym {
  font-weight: 600;
  font-size: 13.5px;
  display: flex; align-items: center; gap: 6px;
  letter-spacing: -.01em;
}
.token-name {
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-value { text-align: right; flex-shrink: 0; }
.token-v {
  font-weight: 600;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.token-b {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

.tokens-empty {
  padding: 24px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
}

/* ========== ADD WALLET CTA ========== */
.add-wallet {
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--r);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  margin-top: 4px;
  transition: background .15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  letter-spacing: -.01em;
}
.add-wallet svg { width: 16px; height: 16px; }
.add-wallet:hover { background: var(--primary-hover); }

/* ========== MODAL ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: hsla(230, 30%, 5%, .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .18s ease;
}
.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  padding: 22px;
  animation: slideUp .3s cubic-bezier(.2, .8, .2, 1);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.modal-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -.015em; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  display: grid; place-items: center;
  transition: all .15s;
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-close svg { width: 14px; height: 14px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 14px;
  outline: none;
  transition: all .15s;
}
.field input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field input.mono { font-family: var(--f-mono); font-size: 12.5px; }

.hint {
  font-size: 11px;
  margin-top: 6px;
  min-height: 15px;
  color: var(--text-3);
  display: flex; align-items: center; gap: 4px;
}
.hint.ok { color: var(--success); }
.hint.er { color: var(--danger); }

.chain-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.chain-btn {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s;
}
.chain-btn:hover { border-color: var(--border-strong); }
.chain-btn.on { font-weight: 600; border-width: 2px; padding: 6px 11px; }
.chain-btn .pill-dot { width: 7px; height: 7px; }

.modal-body {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 4px;
}
.modal-body strong { color: var(--text); font-weight: 600; }
.modal-body .addr-chip {
  display: block;
  width: fit-content;
  margin-top: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}
.btn-secondary {
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  transition: all .15s;
}
.btn-secondary:hover { background: var(--surface-3); }
.btn-primary {
  padding: 10px 22px;
  border-radius: var(--r);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  transition: background .15s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger {
  padding: 10px 22px;
  border-radius: var(--r);
  background: var(--danger);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  transition: opacity .15s;
}
.btn-danger:hover { opacity: .9; }
.btn-secondary {
  border-radius: var(--r);
}

/* ========== EMPTY STATE ========== */
.empty {
  text-align: center;
  padding: 48px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
}
.empty-icon {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), hsl(280, 75%, 62%));
  display: grid; place-items: center;
  color: #fff;
  font-size: 28px;
}
.empty h2 { font-size: 18px; font-weight: 600; margin-bottom: 6px; letter-spacing: -.015em; }
.empty p { color: var(--text-2); font-size: 13px; max-width: 360px; margin: 0 auto 20px; }

/* ========== UTILITIES ========== */
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ========== RESPONSIVE ========== */
@media (min-width: 640px) {
  .app { padding: 28px 20px 60px; }
  .hero { padding: 28px; }
  .hero-value { font-size: 42px; }
  .w-header { padding: 18px 20px 12px; }
  .pills { padding: 0 20px 12px; }
  .aave-card { margin: 8px 20px 16px; }
  .tokens { padding: 4px 16px 12px; }
  .toggle { padding: 12px 20px; }
  .footer { padding: 16px 20px; }
}

@media (max-width: 480px) {
  .hero-value { font-size: 30px; }
  .metric-v { font-size: 14px; }
  .w-total-v { font-size: 17px; }
  .logo-sub { display: none; }
}
