:root {
  /* Ref. Wallet.png — fond #101010, indigo #4E44E7, vert #22C55E, cartes #1C1C1C */
  --bg: #101010;
  --bg-top-green: rgba(22, 48, 38, 0.65);
  --bg-card: #1c1c1c;
  --bg-card-hover: #252525;
  --border: rgba(255, 255, 255, 0.06);
  --text: #ffffff;
  --text-muted: #9ca3af;
  --accent: #4e44e7;
  --accent-soft: rgba(78, 68, 231, 0.22);
  --pill-primary: #4e44e7;
  --pill-text: #ffffff;
  --positive: #22c55e;
  --negative: #ef4444;
  --overlay-send: #38bdf8;
  --overlay-receive: #a78bfa;
  --action-tile-icon: #b8a5f5;
  --radius-lg: 16px;
  --radius-md: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  /* iPhone : SF Pro en premier (lisibilité & alignement système) */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", system-ui, sans-serif;
  --nav-h: 56px;
  /* Réserve sous le contenu scrollable (barre fixe + indicateur d’accueil + marge) */
  --bottom-nav-reserve: calc(var(--nav-h) + var(--safe-bottom) + 24px);
}

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

html {
  height: 100%;
  height: -webkit-fill-available;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  font-family: var(--font);
  font-size: 16px;
  font-size: max(16px, 1rem);
  color: var(--text);
  background: var(--bg);
}

.app {
  /* iPhone 16 Pro ≈ 402px CSS — pleine largeur utile */
  max-width: min(440px, 100%);
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--bottom-nav-reserve);
  background-color: var(--bg);
  background-image: linear-gradient(180deg, var(--bg-top-green) 0%, transparent 32%);
  background-repeat: no-repeat;
  background-size: 100% 420px;
}

.is-hidden {
  display: none !important;
}

/* ——— Headers ——— */
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
  padding: max(12px, calc(var(--safe-top) + 4px)) 14px 10px;
}

.sheet-header--activity .sheet-title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

.sheet-header-spacer {
  width: 44px;
  flex-shrink: 0;
}

.profile-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-avatar {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.profile-avatar svg {
  display: block;
  width: 100%;
  height: 100%;
}

.avatar-chip {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.account-trigger {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
  min-width: 0;
}

.account-emoji {
  font-size: 18px;
  line-height: 1;
}

.account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-touch-callout: none;
}

.icon-btn--ghost {
  background: transparent;
}

/* ——— Main & views ——— */
.main {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: auto;
  touch-action: pan-y;
  padding: 0 18px;
  /* Marge sous le dernier bloc ; la zone sous la barre est déjà réservée par .app */
  padding-bottom: max(20px, calc(var(--safe-bottom) + 8px));
  scroll-padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
}

.view[hidden] {
  display: none !important;
}

.view--active:not([hidden]) {
  display: block;
}

.balance-block {
  text-align: center;
  padding: 4px 0 20px;
}

.balance-fiat {
  margin: 0;
  font-size: clamp(2rem, 11vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.balance-change-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.balance-delta-line {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

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

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

.balance-delta-line--flat {
  color: var(--text-muted);
}

.balance-pct-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.balance-pct-pill--up {
  color: var(--positive);
  background: rgba(34, 197, 94, 0.18);
}

.balance-pct-pill--down {
  color: var(--negative);
  background: rgba(239, 68, 68, 0.16);
}

.balance-pct-pill--flat {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
}

.balance-pill {
  display: inline-block;
  margin: 12px auto 0;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.balance-pill--down {
  color: var(--negative);
  background: rgba(239, 68, 68, 0.16);
}

.balance-pill--up {
  color: var(--positive);
  background: rgba(34, 197, 94, 0.18);
}

.balance-pill--flat {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
}

.balance-sub {
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 24px;
}

/* Actions rapides — icône dans carré arrondi + libellé (style wallet type Phantom) */
.actions--tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 4px 2px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.action-tile__squircle {
  width: 100%;
  max-width: 76px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 18px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--action-tile-icon);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s ease, background 0.12s ease;
}

.action-tile__squircle svg {
  display: block;
  flex-shrink: 0;
}

.action-tile__label {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-align: center;
}

.action-tile:active .action-tile__squircle {
  background: var(--bg-card-hover);
  transform: scale(0.96);
}

.action-btn {
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px;
}

.action-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--text);
}

/* ——— Token list (home) ——— */
.manage-tokens {
  width: 100%;
  margin-top: 18px;
  padding: 16px 18px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-card);
  cursor: pointer;
}

.manage-tokens:active {
  background: var(--bg-card-hover);
}

.manage-tokens svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.token-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.token-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  min-height: 72px;
  background: var(--bg-card);
  border-radius: calc(var(--radius-lg) + 2px);
  border: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.15s ease;
}

.token-row:active {
  background: var(--bg-card-hover);
}

.token-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  background: #0a0a0a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.token-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.token-icon--fallback {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.token-meta {
  flex: 1;
  min-width: 0;
}

.token-name {
  font-weight: 600;
  font-size: 1.0625rem;
  margin: 0 0 3px;
  letter-spacing: -0.02em;
}

.token-sub {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.token-values {
  text-align: right;
}

.token-fiat {
  margin: 0 0 3px;
  font-weight: 600;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.token-pct {
  font-size: 13px;
  font-weight: 500;
  margin: 0;
  color: var(--text-muted);
}

.token-delta {
  font-size: 14px;
  font-weight: 500;
  margin: 2px 0 0;
}

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

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

.token-delta--flat {
  color: var(--text-muted);
}

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

.token-pct.down {
  color: #ff453a;
}

/* ——— Activity feed (Phantom-style) ——— */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 4px;
}

.activity-day {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.activity-day-title {
  margin: 0;
  padding: 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  min-height: 72px;
}

.activity-row--failed {
  opacity: 0.75;
}

.activity-visual {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.activity-visual--pair .activity-token--back {
  position: absolute;
  left: 0;
  top: 2px;
  width: 36px;
  height: 36px;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.activity-visual--pair .activity-token--front {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 36px;
  height: 36px;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.activity-token {
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}

.activity-token img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.activity-visual--single .activity-token {
  width: 48px;
  height: 48px;
  font-size: 13px;
}

.activity-overlay {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  border: 2px solid var(--bg-card);
}

.activity-overlay--send {
  background: var(--overlay-send);
  color: #000;
}

.activity-overlay--receive {
  background: var(--overlay-receive);
  color: #fff;
}

.activity-body {
  flex: 1;
  min-width: 0;
}

.activity-title {
  margin: 0 0 4px;
  font-weight: 600;
  font-size: 17px;
}

.activity-detail {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.3;
}

.activity-amounts {
  text-align: right;
  flex-shrink: 0;
  max-width: 48%;
}

.activity-line {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.activity-line--in {
  color: var(--positive);
}

.activity-line--out {
  color: var(--text);
}

.activity-line--muted {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  margin-top: 2px;
}

.activity-pending-tag {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #ff9f0a;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ——— Placeholders ——— */
.panel-empty {
  text-align: center;
  padding: 48px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
}

.panel-empty--flat {
  background: transparent;
}

.panel-empty-title {
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 17px;
}

.panel-empty-sub {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.view-placeholder {
  text-align: center;
  padding: 64px 24px;
}

.view-placeholder-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
}

.view-placeholder-sub {
  margin: 0;
  font-size: 15px;
  color: var(--text-muted);
}

/* ——— Discover ——— */
.discover-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: 14px;
  margin-bottom: 24px;
}

.discover-search-icon {
  color: var(--text-muted);
  display: flex;
}

.discover-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 16px;
  outline: none;
}

.discover-tabs-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.discover-section {
  margin-bottom: 28px;
}

.discover-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.discover-section-title {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 700;
}

.discover-section-head .discover-section-title {
  margin: 0;
}

.discover-link {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.discover-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.discover-chip {
  padding: 10px 16px;
  background: var(--bg-card);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
}

.discover-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.discover-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
  color: var(--text-muted);
}

.discover-row-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.discover-row-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.discover-row-name {
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
}

.discover-row-cat {
  font-size: 13px;
}

/* ——— Bottom nav (5) ——— */
/* Enfant direct de body (voir index.html) : bottom:0 = bas réel de l’écran / PWA iOS */
.bottom-nav {
  position: fixed;
  z-index: 100;
  bottom: 0;
  left: 0;
  right: 0;
  margin-inline: auto;
  width: 100%;
  max-width: min(440px, 100%);
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 6px max(6px, var(--safe-left)) constant(safe-area-inset-bottom) max(6px, var(--safe-right));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(16, 16, 16, 0.97);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
}

.nav-item {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.625rem;
  font-size: max(10px, 0.625rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  padding: 2px 2px 0;
  min-height: 0;
  cursor: pointer;
  line-height: 1.15;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item svg {
  opacity: 0.88;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-item::after {
  content: "";
  display: block;
  width: 28px;
  height: 3px;
  margin-top: 2px;
  border-radius: 2px;
  background: transparent;
}

.nav-item.active::after {
  background: var(--accent);
}

/* ——— Modal portefeuille (@kenzi appui long) ——— */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-overlay.is-open {
  display: flex;
}

.modal-sheet {
  width: 100%;
  max-width: 400px;
  max-height: min(90vh, 560px);
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: 20px 20px 16px 16px;
  padding: 20px 20px 24px;
  border: 1px solid var(--border);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modal-hint {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.modal-select,
.modal-input {
  width: 100%;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0a0a0a;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
}

.modal-select {
  cursor: pointer;
}

.modal-input:focus,
.modal-select:focus {
  outline: none;
  border-color: rgba(78, 68, 231, 0.55);
  box-shadow: 0 0 0 3px rgba(78, 68, 231, 0.15);
}

.modal-footnote {
  margin: -8px 0 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  padding: 14px 16px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.modal-btn--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.modal-btn--primary {
  background: var(--pill-primary, #4e44e7);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .action-tile:active .action-tile__squircle,
  .token-row,
  .manage-tokens {
    transition: none;
  }

  .action-tile:active .action-tile__squircle {
    transform: none;
  }
}
