/* ─── Direction artistique : noir profond & or ─────────────────────────── */
:root {
  --bg: #070707;
  --bg-raise: #0e0e0e;
  --surface: #131313;
  --line: rgba(214, 178, 94, 0.14);
  --line-soft: rgba(214, 178, 94, 0.08);
  --line-strong: rgba(214, 178, 94, 0.36);
  --gold: #d6b25e;
  --gold-hi: #f1dea3;
  --gold-lo: #9a7532;
  --gold-grad: linear-gradient(135deg, #f5e4ab 0%, #d6b25e 45%, #a17a2e 100%);
  --ink: #171006;
  --text: #f3eee4;
  --muted: #8d877b;
  --faint: #57524a;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 18px;
  --tabbar-h: 64px;
  --tabbar-gap: 12px;
  --safe-top: max(env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* Halo doré discret + grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(110% 55% at 50% -12%, rgba(214, 178, 94, 0.13), transparent 62%),
    radial-gradient(80% 40% at 50% 112%, rgba(214, 178, 94, 0.05), transparent 70%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon--sm { width: 18px; height: 18px; }

.eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ─── Boutons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 54px;
  padding: 0 24px;
  border: 0;
  border-radius: 14px;
  font: 700 15px/1 var(--font);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn small {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.65;
}
.btn--gold {
  color: var(--ink);
  background: var(--gold-grad);
  box-shadow: 0 12px 32px -14px rgba(214, 178, 94, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn--line {
  color: var(--gold-hi);
  background: rgba(214, 178, 94, 0.04);
  border: 1px solid var(--line-strong);
}

/* ─── Écran d'accès ────────────────────────────────────────────────────── */
.gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(28px + var(--safe-top)) 28px calc(24px + var(--safe-bottom));
  text-align: center;
}

.brand {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}

.gate__view {
  flex: 1;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: rise 0.55s ease both;
}

.crest {
  position: relative;
  width: 88px;
  height: 88px;
  margin-bottom: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--gold-hi);
  background: radial-gradient(circle at 50% 30%, rgba(214, 178, 94, 0.18), rgba(214, 178, 94, 0.02) 72%);
}
.crest::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, rgba(214, 178, 94, 0.06), var(--gold-hi) 18%, rgba(214, 178, 94, 0.06) 42%, var(--gold) 68%, rgba(214, 178, 94, 0.06));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.crest::after {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
}
.crest .icon { width: 32px; height: 32px; stroke-width: 1.6; }
.crest--loading { background: none; }
.crest--loading::before {
  background: conic-gradient(from 0deg, transparent 0 55%, var(--gold) 85%, var(--gold-hi));
  animation: spin 1.3s linear infinite;
}

.gate__caption {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.gate__title {
  margin: 0 0 12px;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.gate__text {
  margin: 0 0 32px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  text-wrap: balance;
}
.gate__actions { width: 100%; display: grid; gap: 12px; }
.gate__hint { margin: 18px 0 0; font-size: 13px; line-height: 1.5; color: var(--gold); text-wrap: balance; }
.gate__foot {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

/* Saisie du mot de passe d'accès */
.code-field {
  width: 100%;
  height: 58px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  outline: 0;
  background: var(--surface);
  color: var(--gold-hi);
  font: 700 17px/1 var(--font);
  letter-spacing: 0.1em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.code-field::placeholder { color: var(--faint); }
.code-field:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(214, 178, 94, 0.08); }
.code-field.is-error { border-color: #b35a4c; animation: shake 0.4s ease; }
.gate__error { margin: 16px 0 0; font-size: 13px; line-height: 1.5; color: #dd8f80; text-wrap: balance; }

/* ─── Pages ────────────────────────────────────────────────────────────── */
.pages {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(22px + var(--safe-top)) 20px calc(var(--tabbar-h) + var(--tabbar-gap) + var(--safe-bottom) + 28px);
}
.page { animation: rise 0.35s ease both; }
.page__head { margin: 6px 0 24px; }
.page__head .eyebrow { margin-bottom: 6px; }
.page__title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.section-title {
  margin: 32px 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 52px 24px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(214, 178, 94, 0.05), rgba(214, 178, 94, 0) 65%);
}
.empty__icon {
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--gold);
}
.empty h2 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.empty p { margin: 0; max-width: 280px; font-size: 14px; line-height: 1.6; color: var(--muted); text-wrap: balance; }
.empty .btn { width: auto; margin-top: 24px; }
.empty--compact { padding: 26px 20px; }

/* Recherche */
.search {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 54px;
  margin-bottom: 18px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;
}
.search:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(214, 178, 94, 0.07);
  color: var(--gold);
}
.search .icon { width: 20px; height: 20px; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: 600 16px var(--font);
}
.search input::placeholder { color: var(--faint); font-weight: 500; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* Wallet */
.balance {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  aspect-ratio: 1.66;
  max-height: 260px;
  margin-bottom: 16px;
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(214, 178, 94, 0.24), transparent 55%),
    linear-gradient(160deg, #18140c, #0a0a0a 62%);
  box-shadow: 0 24px 48px -28px rgba(214, 178, 94, 0.35);
}
.balance::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 34%, rgba(255, 240, 200, 0.07) 47%, transparent 60%);
}
.balance__label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
.balance__amount {
  margin: auto 0 0;
  font-size: 46px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.balance__amount span { font-size: 26px; letter-spacing: 0; }
.balance__foot {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.balance__brand { font-weight: 800; letter-spacing: 0.26em; color: var(--gold); }

/* Compte */
.profile {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raise);
}
.avatar {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold-grad);
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.profile__info { min-width: 0; }
.profile__name { margin: 0 0 2px; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile__handle { margin: 0; font-size: 14px; color: var(--muted); }

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raise);
}
.list li { display: flex; align-items: center; gap: 14px; padding: 17px 18px; font-size: 14px; }
.list li + li { border-top: 1px solid var(--line-soft); }
.list .icon { width: 20px; height: 20px; color: var(--gold); }
.list span { flex: 1; color: var(--muted); }
.list strong { font-weight: 700; text-align: right; }
.list .is-gold { color: var(--gold-hi); }

/* ─── Barre de navigation : pilule flottante, floutée, sans bordure ────── */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-gap) + var(--safe-bottom));
  z-index: 10;
  width: calc(100% - 32px);
  max-width: 420px;
  height: var(--tabbar-h);
  padding: 0 8px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  border-radius: 32px;
  background: rgba(24, 24, 24, 0.6);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  box-shadow: 0 14px 36px -10px rgba(0, 0, 0, 0.8);
  transform: translateX(-50%);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tabbar { background: rgba(24, 24, 24, 0.96); }
}
.tab {
  position: relative;
  height: 48px;
  margin: 0 2px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: rgba(243, 238, 228, 0.55);
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.25s ease;
}
.tab .icon { width: 25px; height: 25px; transition: transform 0.2s ease; }
.tab:active .icon { transform: scale(0.86); }
.tab.is-active { color: var(--gold-hi); background: rgba(214, 178, 94, 0.14); }
.tab.is-active .icon { stroke-width: 2.1; }
.tab__badge {
  position: absolute;
  top: 6px;
  left: calc(50% + 6px);
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--gold);
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
}

/* Notification */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + var(--safe-bottom) + 14px);
  z-index: 20;
  width: max-content;
  max-width: calc(100% - 40px);
  padding: 13px 18px;
  border-radius: 14px;
  background: rgba(28, 25, 18, 0.92);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
