/*
 * BlackVault Mini App styling — Onyx.
 *
 * The background imitates the polished black stone of a Telegram gift: a near-black base, a few
 * soft light pools, a faint grain, and a thin highlight along the top edge of every card. All
 * colour that carries meaning (text, buttons) still comes from the Telegram theme so the app
 * stays readable in both light and dark clients.
 */

:root {
  --onyx-0: #04050a;
  --onyx-1: #0a0c14;
  --onyx-2: #11141f;
  --text: var(--tg-theme-text-color, #f2f4f8);
  --hint: var(--tg-theme-hint-color, #8f97a8);
  --link: var(--tg-theme-link-color, #7cc4ff);
  --button: var(--tg-theme-button-color, #3b82f6);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #ff6b64;
  --ok: #4ade80;
  --warn: #fbbf24;
  --radius: 18px;
  --tab-height: 66px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
  font-size: 15px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  background-color: var(--onyx-0);
  /* Onyx: cold light pools over black stone. */
  background-image:
    radial-gradient(120% 70% at 15% -10%, rgba(96, 132, 220, 0.20), transparent 60%),
    radial-gradient(120% 60% at 100% 0%, rgba(150, 110, 220, 0.16), transparent 55%),
    radial-gradient(90% 50% at 50% 110%, rgba(60, 90, 160, 0.14), transparent 60%),
    linear-gradient(180deg, var(--onyx-1) 0%, var(--onyx-0) 45%, #020307 100%);
  background-attachment: fixed;
}

/* Faint grain, the way real onyx shows under direct light. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='120' height='120' filter='url(%23n)' opacity='0.6'/></svg>");
}

/* ---------- top bar ---------- */

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
}

.brand {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.3px;
  background: linear-gradient(180deg, #ffffff 0%, #b9c6e0 60%, #7f8aa3 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.who { color: var(--hint); font-size: 12.5px; margin-top: 3px; }

.icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.02));
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 17px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.12);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.icon-btn:active { transform: scale(0.92); opacity: 0.75; }
.icon-btn svg { display: block; margin: 0 auto; transform-origin: 50% 50%; }
/* The glyph used to be a character, so it orbited its own text baseline. An SVG rotates around
   its true centre, which is what makes the spin look straight. */
.icon-btn.is-spinning svg { animation: spin 0.8s linear infinite; }

/* ---------- screens ---------- */

#screens { flex: 1; position: relative; overflow: hidden; z-index: 1; }

.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(var(--tab-height) + 34px);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.screen.is-active { opacity: 1; transform: none; pointer-events: auto; }

h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--hint);
  margin: 16px 0 10px;
}
h2.spaced { margin-top: 26px; }

.hint { color: var(--hint); font-size: 12.5px; line-height: 1.5; margin: 10px 0; }
.hidden { display: none !important; }

/* ---------- glossy surfaces ---------- */

.card, .row, .coin-card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.075) 0%, rgba(255,255,255,0.025) 40%, rgba(0,0,0,0.20) 100%);
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: var(--radius);
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
}

/* The polished top edge: a one-pixel light line that fades at the corners. */
.card::after, .row::after, .coin-card::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  pointer-events: none;
}

.list { display: flex; flex-direction: column; gap: 10px; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
}
.row.tappable { transition: transform 0.14s ease, opacity 0.14s ease; }
.row.tappable:active { transform: scale(0.985); opacity: 0.88; }

.row-main { min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; }
.row-sub { color: var(--hint); font-size: 12.5px; margin-top: 3px; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.amount-sub { color: var(--hint); font-size: 12px; text-align: right; margin-top: 3px; }

.card { padding: 16px; }
.label { color: var(--hint); font-size: 12.5px; margin-bottom: 8px; }

.address {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-all;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 13px;
  margin-bottom: 12px;
}

.skeleton {
  height: 64px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

/* ---------- portfolio total with odometer ---------- */

.portfolio { padding: 18px 18px 14px; text-align: center; }
.portfolio .caption { color: var(--hint); font-size: 12px; letter-spacing: 0.6px; text-transform: uppercase; }

/*
 * A solid fill, not background-clip: text.
 *
 * The digits live in absolutely positioned children, and a gradient clipped on the parent does
 * not paint them — only the separators, which set their own fill, stayed visible. That is how the
 * total once rendered as a lone comma.
 */
.odometer {
  display: flex;
  justify-content: center;
  /* Center, not flex-end: every child is the same height, so their glyphs share one optical
     line. With flex-end the currency sign sat on the baseline of a taller box than the digits. */
  align-items: center;
  gap: 1px;
  font-size: 38px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  margin-top: 6px;
  color: #f4f7ff;
  /*
   * No text-shadow here. Each digit sits in its own overflow:hidden box for the roll animation,
   * and the glow was being clipped at every box edge — that painted the faint rectangles around
   * the numbers that made them look highlighted.
   */
}

/* A separator occupies exactly the same box as a digit, so the "$" and the numbers line up. */
.odometer .sep,
.odometer .cur {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.06em;
  line-height: 1.06em;
  color: rgba(236, 242, 255, 0.72);
}

/* One digit: a window showing the current glyph; the previous one falls out below. */
.digit {
  position: relative;
  display: inline-block;
  width: 0.62em;
  height: 1.06em;
  overflow: hidden;
  vertical-align: bottom;
}
.digit > span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.42s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.42s ease;
}
.digit > .out { transform: translateY(100%); opacity: 0; }
.digit > .in { transform: translateY(0); opacity: 1; }
.digit > .above { transform: translateY(-100%); opacity: 0; }

/* ---------- coin carousel ---------- */

.carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 2px 12px;
  scroll-behavior: smooth;
}
.carousel::-webkit-scrollbar { display: none; }

.coin-card {
  flex: 0 0 78%;
  scroll-snap-align: center;
  padding: 16px;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.coin-top { display: flex; align-items: center; justify-content: space-between; }
.coin-symbol { font-size: 15px; font-weight: 700; }
.coin-network { color: var(--hint); font-size: 12px; margin-top: 2px; }
.coin-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
  color: var(--hint);
}
.coin-balance { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 12px; }
.coin-usd { color: var(--hint); font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }

.coin-dots { display: flex; justify-content: center; gap: 6px; margin-top: 2px; }
.coin-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.22);
  transition: background 0.2s ease, transform 0.2s ease;
}
.coin-dots i.is-active { background: rgba(255,255,255,0.85); transform: scale(1.25); }

/* ---------- warning banner ---------- */

.warning {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-radius: 14px;
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #ffd9a8;
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.16), rgba(251, 191, 36, 0.05));
  border: 1px solid rgba(251, 191, 36, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
.warning strong { color: #ffc978; }
.warning .icon { font-size: 15px; line-height: 1.3; }

/* ---------- chips ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.chip {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
  color: var(--text);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 13.5px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.10);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.14s ease;
}
.chip:active { transform: scale(0.96); }
.chip.is-active {
  background: linear-gradient(180deg, #4b8ef7, #2f6fd6);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.45), inset 0 1px 0 rgba(255,255,255,0.35);
}

/* ---------- form ---------- */

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; color: var(--hint); font-size: 12.5px; margin-bottom: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input {
  width: 100%;
  padding: 14px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
input:focus { outline: none; border-color: rgba(96, 165, 250, 0.75); background: rgba(0, 0, 0, 0.5); }
input::placeholder { color: rgba(255,255,255,0.28); }

.primary {
  width: 100%;
  margin-top: 10px;
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background: linear-gradient(180deg, #4b8ef7, #2f6fd6);
  color: #fff;
  font-size: 15.5px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.35), inset 0 1px 0 rgba(255,255,255,0.35);
  transition: transform 0.14s ease, opacity 0.14s ease;
}
.primary:active { transform: scale(0.985); opacity: 0.92; }
.primary[disabled] { opacity: 0.45; }

.secondary {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}
.secondary:active { transform: scale(0.985); opacity: 0.88; }

.link { border: 0; background: transparent; color: var(--link); font-size: 15px; padding: 4px 0 10px; }

.ok { color: var(--ok); }
.danger { color: var(--danger); }
.warn { color: var(--warn); }

/* ---------- bottom tabs: wide, swipeable, cyclic ---------- */

.tabbar {
  position: relative;
  z-index: 3;
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, rgba(8, 10, 16, 0.55), rgba(2, 3, 7, 0.92));
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(18px);
}

.tabbar::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 0 auto;
  min-width: 92px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.015));
  color: var(--hint);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 9px 10px 8px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.10);
  transition: color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}
.tab > span { font-size: 18px; line-height: 1; }
.tab.is-active {
  color: #fff;
  background: linear-gradient(180deg, rgba(75, 142, 247, 0.95), rgba(47, 111, 214, 0.95));
  border-color: rgba(255, 255, 255, 0.30);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.40), inset 0 1px 0 rgba(255,255,255,0.35);
  transform: translateY(-1px);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-height) + 26px);
  transform: translate(-50%, 12px);
  background: rgba(12, 14, 20, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.4;
  padding: 12px 16px;
  border-radius: 14px;
  max-width: calc(100% - 40px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255,255,255,0.08);
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- animations ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
/* ---------- asset badges ---------- */

.coin-heading { display: flex; align-items: center; gap: 10px; }
.row-with-icon { display: flex; align-items: center; gap: 12px; }

.coin-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background:
    radial-gradient(120% 120% at 30% 20%, color-mix(in srgb, var(--tint) 78%, #ffffff) 0%, var(--tint) 45%, color-mix(in srgb, var(--tint) 62%, #000000) 100%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--tint) 45%, transparent), inset 0 1px 0 rgba(255,255,255,0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
/* A coin badge inside a chip: smaller, and it must not push the label off-centre. */
.chip { display: inline-flex; align-items: center; gap: 7px; }
.chip .coin-icon { width: 20px; height: 20px; font-size: 11px; box-shadow: none; }

/* Badges that sit inline with a title (ads, trades, history) stay compact. */
.row-title .coin-icon, h2 .coin-icon { width: 22px; height: 22px; font-size: 12px; box-shadow: none; }
.row-with-icon { display: flex; align-items: center; gap: 9px; }
/* ---------- entrance: the "landing from above" motion ---------- */

/*
 * Elements drop into place instead of appearing. Each one starts slightly above its final spot,
 * a touch smaller and fully transparent, then settles. The delay is per element and comes from
 * --i, which the script sets, so a list reads as a wave rather than a single jump.
 */
@keyframes drop-in {
  0% {
    opacity: 0;
    transform: translate3d(0, -22px, 0) scale(0.99);
  }
  55% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/*
 * A soft variant for the scroll-back replay: a short settle from above with NO opacity change.
 *
 * Fading the screen out and back in is what made the return look like a reload — the page went
 * blank for a moment. Moving only the position keeps the content painted the whole time, so it
 * reads as the buttons settling rather than the screen redrawing.
 */
@keyframes drop-in-soft {
  from { transform: translate3d(0, -10px, 0); }
  to { transform: translate3d(0, 0, 0); }
}

/* Only elements the script marked take part, and only while their container is entering. */
.is-entering .drop-in {
  /* 650 ms with a long settle: the earlier 420 ms read as a snap rather than a landing. */
  animation: drop-in 650ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

.is-entering-soft .drop-in {
  animation: drop-in-soft 460ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 30ms);
}

/* The tab strip lands with a slightly longer wave so the eye notices the screen changed. */
.tabbar.is-entering .tab {
  animation: drop-in 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
