/* Phantom Wallet — new home UI */

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

:root {
  --bg: #000000;
  --card: #1c1c1e;
  --card-hover: #2a2a2e;
  --text: #ffffff;
  --text-muted: #8e8e93;
  --accent: #b4a5ff;
  --accent-text: #0a0a0a;
  --positive: #4ade80;
  --negative: #f87171;
  --phone-max: 420px;
  --header-h: 56px;
  --ptr-anchor-top: calc(12px + var(--safe-top) + 36px + 12px);
  --footer-h: 72px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius-card: 20px;
  --radius-pill: 999px;
  --splash-bg: #a799ff;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  --icon-spin-c: 62.832;
  --icon-spin-max: 50.266;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: #0d0d0d;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ─── Splash screen ─── */

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--splash-bg);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.splash-screen.is-hiding {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-screen.is-gone {
  display: none;
}

.splash-logo {
  width: 118px;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* ─── Phone frame ─── */

.phone-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--phone-max);
  height: 100%;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

@media (min-width: 421px) {
  .phone-shell {
    height: 100vh;
    max-height: 920px;
    box-shadow: 0 16px 56px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  }
}

/* ─── Sticky header ─── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 300;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + var(--safe-top)) 14px 12px;
  background: var(--bg);
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.top-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.tab-pill {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-pill.active {
  background: var(--accent);
  color: var(--accent-text);
}

.tab-pill:not(.active):active {
  background: var(--card-hover);
}

/* ─── Scrollable main ─── */

.dashboard {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 4px 16px calc(90px + var(--safe-bottom));
  scrollbar-width: none;
}

.dashboard::-webkit-scrollbar {
  display: none;
}

.dashboard.refreshing,
.dashboard.sync-rugpull {
  pointer-events: none;
}

.dashboard.is-pulling {
  user-select: none;
  -webkit-user-select: none;
}

/* ─── Pull-to-Refresh (global top-center slide) ─── */

.pull-to-refresh-container,
.ptr-container {
  position: absolute;
  top: var(--ptr-anchor-top);
  left: 50%;
  z-index: 250;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #ffffff;
  box-shadow:
    0 3px 12px rgba(0, 0, 0, 0.22),
    0 1px 4px rgba(0, 0, 0, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 0);
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.ptr-container.is-visible {
  opacity: 1;
  visibility: visible;
}

.ptr-container.is-snapping {
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}

.ptr-container.is-threshold {
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.28),
    0 2px 6px rgba(0, 0, 0, 0.16);
}

.ptr-svg {
  width: 20px;
  height: 20px;
  display: block;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  will-change: transform;
}

.ptr-circle {
  /* r=9 → circumference 2π×9 ≈ 56.549 */
  --ptr-c: 56.549;
  stroke: #141414;
  stroke-width: 2.5;
  stroke-linecap: round;
  fill: none;
}

.ptr-arrow-rotor {
  transition: none;
  transform-origin: 0 0;
}

#refresh-arrow {
  transition: none;
}

#refresh-arrow.is-vanished {
  display: none !important;
  opacity: 0 !important;
}

.ptr-container.is-spinning .ptr-arrow-rotor,
.ptr-container.is-snapping-lock .ptr-arrow-rotor {
  opacity: 0 !important;
  visibility: hidden;
}

.ptr-container.is-spinning .ptr-svg {
  animation: ptr-rotate 2s linear infinite;
}

.ptr-container.is-spinning .ptr-circle {
  animation: dash 1.5s ease-in-out infinite;
  will-change: stroke-dasharray, stroke-dashoffset;
}

@keyframes ptr-rotate {
  from {
    transform: rotate(-90deg);
  }
  to {
    transform: rotate(270deg);
  }
}

@keyframes dash {
  0% {
    stroke-dasharray: 1, 56.549;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 33.929, 56.549;
    stroke-dashoffset: -13.195;
  }
  100% {
    stroke-dasharray: 33.929, 56.549;
    stroke-dashoffset: -46.747;
  }
}

/* ─── Balance ─── */

.balance-block {
  margin-bottom: var(--space-lg);
}

/* Legacy reload markup — never reserve layout space */
.reload-container,
#reload-container {
  display: none !important;
}

.main-balance {
  font-size: 52px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 0;
}

.balance-change {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: 6px;
}

.delta {
  font-size: 15px;
  font-weight: 500;
}

.delta.positive {
  color: var(--positive);
}

.delta.negative {
  color: var(--negative);
}

.pct-badge {
  font-size: 13px;
  font-weight: 600;
  padding: var(--space-xs) 10px;
  border-radius: var(--radius-pill);
}

.pct-badge.positive {
  color: var(--positive);
  background: rgba(74, 222, 128, 0.14);
}

.pct-badge.negative {
  color: var(--negative);
  background: rgba(248, 113, 113, 0.14);
}

.dashboard.refreshing .main-balance,
.dashboard.sync-rugpull .main-balance {
  animation: balance-pulse 0.5s ease;
}

@keyframes balance-pulse {
  50% {
    opacity: 0.6;
  }
}

/* ─── Account picker ─── */

.account-picker {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

.chevron-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  opacity: 0.7;
}

/* ─── Cash row ─── */

.cash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--space-lg);
  margin-bottom: var(--space-xl);
  background: var(--card);
  border-radius: var(--radius-card);
}

.cash-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cash-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.cash-label {
  font-size: 17px;
  font-weight: 600;
}

.cash-amount {
  font-size: 17px;
  font-weight: 600;
}

/* ─── Tokens ─── */

.tokens-section--landing {
  margin-bottom: 0;
}

.tokens-section--landing .section-heading {
  margin-bottom: 10px;
}

.token-list--landing + .token-list--more {
  margin-top: var(--space-xs);
}

.token-list--landing {
  gap: var(--space-xs);
}

.token-list--more {
  gap: var(--space-xs);
}

.scroll-more {
  margin-top: var(--space-md);
}

.scroll-more > .perps-section:first-child {
  margin-top: var(--space-2xl);
}

.section-heading {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: var(--space-md);
  letter-spacing: -0.02em;
}

.heading-chevron {
  font-weight: 400;
  color: var(--text-muted);
}

.token-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  border-radius: 18px;
}

.token-list--landing .token-row {
  padding: 11px 14px;
  border-radius: 20px;
}

.token-icon-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.token-row .token-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.chain-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--card);
  background: var(--bg);
}

.chain-badge--square {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: contain;
}

.token-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.token-name {
  font-size: 17px;
  font-weight: 600;
}

.verified-badge {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.token-qty {
  font-size: 15px;
  color: var(--text-muted);
}

.token-value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.token-usd {
  font-size: 17px;
  font-weight: 600;
}

.token-usd.dash {
  color: var(--text-muted);
}

.token-change {
  font-size: 15px;
  font-weight: 500;
}

.token-change.positive {
  color: var(--positive);
}

.token-change.negative {
  color: var(--negative);
}

.token-change.neutral {
  color: var(--text-muted);
}

.token-value--single {
  justify-content: center;
}

/* ─── Perps ─── */

.perps-section {
  margin-bottom: var(--space-2xl);
}

.perps-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.perps-scroll::-webkit-scrollbar {
  display: none;
}

.perp-card {
  flex: 0 0 auto;
  width: 132px;
  padding: 14px;
  background: var(--card);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.perp-icon-wrap {
  position: relative;
  width: 40px;
  height: 40px;
}

.perp-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.perp-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 18px;
  height: 18px;
  object-fit: contain;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: var(--card);
}

.perp-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.perp-ticker {
  font-size: 16px;
  font-weight: 600;
}

.perp-leverage {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 2px 7px;
  margin-left: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.perp-change {
  font-size: 15px;
  font-weight: 500;
}

.perp-change.negative {
  color: var(--negative);
}

/* ─── Predictions ─── */

.predictions-section {
  margin-bottom: var(--space-2xl);
}

.predictions-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.predictions-scroll::-webkit-scrollbar {
  display: none;
}

.prediction-card {
  flex: 0 0 auto;
  width: 200px;
  padding: 12px;
  background: var(--card);
  border-radius: var(--radius-card);
  position: relative;
}

.prediction-thumb-wrap {
  position: relative;
  margin-bottom: 10px;
}

.prediction-thumb {
  width: 100%;
  height: 88px;
  border-radius: 14px;
  object-fit: cover;
  display: block;
}

.live-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--negative);
  letter-spacing: 0.02em;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--negative);
}

.prediction-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prediction-sub {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Collectibles ─── */

.collectibles-section {
  margin-bottom: var(--space-2xl);
}

.collectibles-empty {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--card);
  border: none;
  border-radius: var(--radius-card);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.collectibles-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.collectibles-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.collectibles-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collectibles-sub {
  font-size: 14px;
  color: var(--text-muted);
}

/* ─── Following ─── */

.following-section {
  margin-bottom: var(--space-lg);
}

/* ─── Sticky footer (70% transparent — ref overlay) ─── */

.app-footer {
  position: sticky;
  bottom: 0;
  z-index: 300;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px calc(14px + var(--safe-bottom));
  border-radius: 22px 22px 0 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.12) 0%,
    rgba(0, 0, 0, 0.28) 45%,
    rgba(0, 0, 0, 0.3) 100%
  );
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}

.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 48px;
  padding: 0 16px;
  background: #1a1a1c;
  border-radius: var(--radius-pill);
  cursor: text;
}

.search-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  opacity: 0.5;
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  outline: none;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.fab {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 502;
  transition: background 0.2s ease, transform 0.15s ease;
}

.fab-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  position: absolute;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.fab-icon--close {
  opacity: 0;
  transform: scale(0.6);
}

.fab.fab--open {
  background: #2c2c2e;
}

.fab.fab--open .fab-icon--plus {
  opacity: 0;
  transform: scale(0.6);
}

.fab.fab--open .fab-icon--close {
  opacity: 1;
  transform: scale(1);
}

.fab:active {
  transform: scale(0.96);
}

/* ─── FAB action menu overlay ─── */

.fab-backdrop {
  position: absolute;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.phone-shell.fab-menu-open .fab-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.fab-menu {
  position: absolute;
  right: 16px;
  bottom: calc(72px + var(--safe-bottom));
  z-index: 501;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 18px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.28s ease;
}

.phone-shell.fab-menu-open .fab-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.fab-action {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.fab-action-label {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.fab-action-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fab-action-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.fab-action:active .fab-action-icon {
  transform: scale(0.94);
}

.phone-shell.fab-menu-open .dashboard {
  pointer-events: none;
}

/* ─── Demo Injector bottom-sheet drawer ─── */

.demo-injector-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.demo-injector-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.demo-injector-drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  transform: translateY(100%);
  transition: transform 0.3s ease-in-out;
  z-index: 999;
  background: #1a1a1e;
  border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(24px + var(--safe-bottom));
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
}

.demo-injector-drawer.slide-up {
  transform: translateY(0);
}

.demo-injector-drawer-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  margin: 4px auto 16px;
}

.demo-injector-drawer-title {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-align: center;
}

.demo-injector-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.demo-injector-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.demo-injector-select,
.demo-injector-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #121214;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
}

.demo-injector-btn {
  width: 100%;
  padding: 13px 16px;
  margin-top: 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #2a2a30;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.demo-injector-btn--primary {
  background: #ab9ff2;
  border-color: #ab9ff2;
  color: #111;
}

.demo-injector-btn--danger {
  border-color: rgba(255, 77, 77, 0.45);
  color: #ff6b6b;
  background: transparent;
}

.search-bar {
  cursor: pointer;
}

.search-bar input {
  pointer-events: none;
}

.delta.neutral,
.pct-badge.neutral,
.token-change.neutral {
  color: var(--pw-muted, #999999) !important;
}
