:root {
  --bg: #0A0A0A;
  --bg-panel: #141414;
  --bg-panel-2: #191919;
  --border: rgba(255, 255, 255, 0.09);
  --ket-red: #C10F0D;
  --ket-red-bright: #E5211E;
  --gold: #C10F0D;      /* legacy alias, kept so existing rules still resolve */
  --violet: #C10F0D;    /* legacy alias */
  --green: #33D17A;
  --red: #E5211E;
  --text: #F5F5F5;
  --text-dim: #9A9A9A;
  --text-faint: #666666;
  --radius: 18px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(120% 100% at 50% 0%, #1F0605 0%, #0A0A0A 55%);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
  overscroll-behavior-y: none;
  touch-action: manipulation;
}

body {
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  padding-top: env(safe-area-inset-top);
}

::selection { background: var(--ket-red); color: #ffffff; }

button { font-family: inherit; }

.hidden { display: none !important; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 8px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(11,10,16,0.95), rgba(11,10,16,0.75) 70%, transparent);
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 0 0 1px var(--border); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }
.brand-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-dim);
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease, color 0.15s ease;
}
.icon-btn:active { transform: scale(0.92) rotate(90deg); color: var(--ket-red-bright); }

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

.install-header-btn {
  border: 1px solid rgba(229, 33, 30, 0.55);
  background: linear-gradient(180deg, rgba(229, 33, 30, 0.22), rgba(193, 15, 13, 0.12));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 8px 12px;
  border-radius: 12px;
  animation: install-pulse 2.4s ease-in-out infinite;
}
.install-header-btn:active { transform: scale(0.96); }

@keyframes install-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 33, 30, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(229, 33, 30, 0); }
}

/* iOS sticky banner */
.ios-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, var(--ket-red), #8A0B0A);
  color: #fff;
  font-size: 12.5px;
  padding: 9px 14px;
  padding-top: calc(9px + env(safe-area-inset-top));
}
.ios-banner-text { flex: 1; line-height: 1.35; }
.ios-banner-cta {
  flex-shrink: 0;
  border: none;
  background: #fff;
  color: var(--ket-red);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  padding: 7px 11px;
  border-radius: 999px;
}
.ios-banner button#ios-banner-close {
  background: rgba(255,255,255,0.18);
  border: none;
  color: #fff;
  border-radius: 8px;
  width: 22px; height: 22px;
  flex-shrink: 0;
}

/* Install modal */
.install-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.install-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}
.install-modal-card {
  position: relative;
  width: min(100%, 420px);
  background: linear-gradient(165deg, #1a1a1a, #111);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px 20px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  animation: install-slide-up 0.28s ease-out;
}
@keyframes install-slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.install-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  color: var(--text-dim);
}
.install-modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--border);
  margin-bottom: 12px;
}
.install-modal-card h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 22px;
}
.install-modal-sub {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.45;
}
.install-panel-lead {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.install-steps {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.install-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  line-height: 1.35;
}
.step-num {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(229, 33, 30, 0.18);
  color: #ff8a88;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.install-action-btn {
  width: 100%;
  margin-top: 4px;
  font-size: 15px;
  padding: 14px 16px;
}
.install-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.4;
  text-align: center;
}
.share-glyph { font-size: 14px; }

@media (min-width: 600px) {
  .install-modal { align-items: center; }
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: linear-gradient(165deg, var(--bg-panel), var(--bg-panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

/* Portfolio hero */
.portfolio-top { margin-bottom: 2px; }
.portfolio-usd {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 42px;
  letter-spacing: -0.02em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.portfolio-sub {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 6px;
}

.price-strip {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}
.price-strip-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 18px;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.hero-change {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
}
.hero-change .change-label {
  font-size: 10px;
  color: var(--text-faint);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.hero-change.up #change-24h { color: var(--green); }
.hero-change.down #change-24h { color: var(--red); }

.metrics-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.metric {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric-label {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}
.metric-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* Chart */
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.tf-switch {
  display: flex;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  overflow-x: auto;
  flex-shrink: 1;
  max-width: 100%;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tf-switch::-webkit-scrollbar { display: none; }
.tf-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 5px 7px;
  border-radius: 7px;
  flex-shrink: 0;
  white-space: nowrap;
}
.tf-btn.active { background: var(--gold); color: #ffffff; font-weight: 600; }

.chart-wrap {
  position: relative;
  height: 280px;
  border-radius: 12px;
  overflow: hidden;
  background: #0D0C13;
}
#chart { width: 100%; height: 100%; }
.rider-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}
.rider {
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  pointer-events: none;
  will-change: transform, opacity;
  transform: translate(-50%, -100%) rotate(0deg);
  transition: opacity 0.2s ease;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.55));
  opacity: 0;
}
.rider.visible { opacity: 1; }

.chart-loading, .chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-faint);
  background: #0D0C13;
}

/* Wallets */
.add-wallet-form {
  display: flex;
  gap: 8px;
}
#wallet-input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  min-width: 0;
}
#wallet-input::placeholder { color: var(--text-faint); font-family: var(--font-body); }
#wallet-input:focus { outline: none; border-color: var(--gold); }

.btn-primary {
  background: var(--gold);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 0 18px;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.btn-primary:active { transform: scale(0.96); }

.field-error {
  color: var(--red);
  font-size: 12px;
  font-family: var(--font-mono);
  margin: 8px 2px 0;
}

.wallet-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wallet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  gap: 10px;
}
.wallet-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wallet-addr {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wallet-balance {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
}
.wallet-balance-usd { font-size: 11px; color: var(--text-faint); }
.wallet-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.wallet-remove {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 16px;
  width: 26px; height: 26px;
  border-radius: 8px;
}
.wallet-remove:active { color: var(--red); background: rgba(255,77,106,0.1); }
.wallet-spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-hint {
  color: var(--text-faint);
  font-size: 12.5px;
  text-align: center;
  margin: 14px 0 2px;
}

/* Pools */
.pools-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.pool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  gap: 10px;
}
.pool-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pool-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pool-dex { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }
.pool-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.pool-liq { font-family: var(--font-mono); font-weight: 600; font-size: 13.5px; }
.pool-vol { font-size: 10.5px; color: var(--text-faint); font-family: var(--font-mono); }

/* Footer */
.app-footer {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  padding: 6px 4px 0;
}

@media (min-width: 600px) {
  .hero-price { font-size: 40px; }
  .chart-wrap { height: 340px; }
}
