/*
 * Stars Cash Flow — premium dark UI kit (Libermall-Card system)
 *
 * Same shadcn-ui dark palette + gold primary as card.libermall.com.
 * iOS HIG-grade mechanics are kept: SF Pro typography ladder, 44pt touch
 * targets, spring easing, glass materials. Only colours move from iOS
 * systemBlue to the "premium fintech" set (gold on near-black).
 *
 * Class names match what's already used in docs/miniapp.html and
 * docs/bot-miniapp.html — .hero / .card / .btn / .seg / .tab / .pill /
 * .kpi-card / .row / .mono / .muted / .link / .badge — so the markup
 * stays untouched.
 */

:root {
  color-scheme: dark;

  /* Surface — near-black with a very slight cool tint */
  --bg: #0a0a0c;
  --bg-grouped: #0a0a0c;
  --bg-card: #0e0e11;
  --bg-card-soft: #14141a;
  --bg-elevated: #16161c;

  /* Labels */
  --label: #fafafa;
  --label-secondary: #a1a1aa;            /* zinc-400 */
  --label-tertiary: #71717a;             /* zinc-500 */
  --label-quaternary: rgba(161, 161, 170, 0.22);
  --label-on-tint: #0a0a0c;

  /* Separators */
  --separator: rgba(255, 255, 255, 0.08);
  --separator-opaque: #27272a;

  /* Brand — Libermall Card gold (hsl 47 92% 49%) + accents */
  --tint: #f3b505;                       /* gold primary */
  --tint-soft: rgba(243, 181, 5, 0.14);
  --tint-2: #fbbf24;                     /* amber lighter */
  --tint-glow: rgba(243, 181, 5, 0.32);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;

  /* Material — glass effects on dark */
  --material-thin: rgba(14, 14, 17, 0.72);
  --material-regular: rgba(14, 14, 17, 0.86);
  --material-ultra: rgba(14, 14, 17, 0.96);

  /* Typography (Apple Dynamic Type ladder, base 17pt body) */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "Helvetica Neue", "Segoe UI", Roboto, Inter, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Radii (iOS standards) */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* Shadows — soft material depth */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 18px 36px rgba(0, 0, 0, 0.12), 0 6px 14px rgba(0, 0, 0, 0.06);

  /* Spring easing — iOS-like */
  --ease-spring: cubic-bezier(0.34, 1.36, 0.64, 1);
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-in: cubic-bezier(0.5, 0, 0.95, 0.45);

  /* Safe-area insets */
  --tg-safe-top: env(safe-area-inset-top, 0px);
  --tg-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tg-safe-left: env(safe-area-inset-left, 0px);
  --tg-safe-right: env(safe-area-inset-right, 0px);

  /* Legacy alias compatibility (no consumer should break) */
  --bg-soft: var(--bg-card-soft);
  --card: var(--bg-card);
  --text: var(--label);
  --muted: var(--label-secondary);
  --stroke: var(--separator);
  --accent: var(--tint);
  --accent-2: var(--tint-2);
  --accent-soft: var(--tint-soft);
  --hero-shadow: var(--shadow-lg);
  --card-shadow: var(--shadow-sm);
  --bg-grad: none;
  --table-head-bg: var(--bg-card-soft);
  --table-head-text: var(--label-secondary);
  --input-bg: var(--bg-card);
  --link-bg: var(--tint-soft);
  --link-stroke: transparent;
  --link-text: var(--tint);
  --service-bg: var(--bg-card-soft);
  --code-bg: var(--bg-card-soft);
  --code-border: var(--separator);
  --pre-bg: #1c1c1e;
  --pre-text: #f2f2f7;
  --pre-border: #2c2c2e;
  --ok: var(--success);
}

/* Forced-dark by default (matches card.libermall.com).
   A light fallback is provided so a user in Telegram light mode still
   sees a coherent premium screen, but the dark surface is canonical. */

:root[data-theme="dark"] { color-scheme: dark; }

:root[data-theme="light"], :root.light {
  color-scheme: light;
  --bg: #fafaf7;
  --bg-grouped: #fafaf7;
  --bg-card: #ffffff;
  --bg-card-soft: #f5f4ef;
  --bg-elevated: #ffffff;
  --label: #0a0a0c;
  --label-secondary: #52525b;
  --label-tertiary: #71717a;
  --label-quaternary: rgba(82, 82, 91, 0.16);
  --label-on-tint: #0a0a0c;
  --separator: rgba(0, 0, 0, 0.08);
  --separator-opaque: #e4e4e7;
  --tint: #ca9a04;                       /* gold a touch darker on light */
  --tint-soft: rgba(202, 154, 4, 0.14);
  --tint-glow: rgba(202, 154, 4, 0.25);
  --material-thin: rgba(255, 255, 255, 0.7);
  --material-regular: rgba(255, 255, 255, 0.84);
  --material-ultra: rgba(255, 255, 255, 0.96);
  --pre-bg: #0a0a0c;
  --pre-text: #f4f4f5;
  --pre-border: #18181b;
}

/* Honour OS preference for users who haven't been put on data-theme yet */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not(.dark) {
    color-scheme: light;
    --bg: #fafaf7;
    --bg-grouped: #fafaf7;
    --bg-card: #ffffff;
    --bg-card-soft: #f5f4ef;
    --bg-elevated: #ffffff;
    --label: #0a0a0c;
    --label-secondary: #52525b;
    --label-tertiary: #71717a;
    --label-quaternary: rgba(82, 82, 91, 0.16);
    --label-on-tint: #0a0a0c;
    --separator: rgba(0, 0, 0, 0.08);
    --separator-opaque: #e4e4e7;
    --tint: #ca9a04;
    --tint-soft: rgba(202, 154, 4, 0.14);
    --tint-glow: rgba(202, 154, 4, 0.25);
    --material-thin: rgba(255, 255, 255, 0.7);
    --material-regular: rgba(255, 255, 255, 0.84);
    --material-ultra: rgba(255, 255, 255, 0.96);
    --pre-bg: #0a0a0c;
    --pre-text: #f4f4f5;
    --pre-border: #18181b;
  }
}

/* ── Reset ──────────────────────────────────────────────────────────────── */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.41;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  padding-top: max(14px, var(--tg-safe-top));
  padding-bottom: max(22px, var(--tg-safe-bottom));
  padding-left: max(14px, var(--tg-safe-left));
  padding-right: max(14px, var(--tg-safe-right));
}

a { color: var(--tint); text-decoration: none; }
a:active { opacity: 0.72; }

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4, p { margin: 0; }

/* ── Container ──────────────────────────────────────────────────────────── */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0;
}

/* ── Hero (large-title pattern, иногда с градиентом) ────────────────────── */

.hero {
  position: relative;
  border-radius: var(--r-xl);
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(243, 181, 5, 0.18), transparent 55%),
    linear-gradient(180deg, #18181b, #0e0e11);
  color: var(--label);
  padding: 22px 20px;
  margin-bottom: 14px;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.45),
    0 0 0 0.5px rgba(243, 181, 5, 0.12) inset;
  overflow: hidden;
  isolation: isolate;
}
.hero::before {
  content: '';
  position: absolute;
  inset: auto -20% -60% auto;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(243, 181, 5, 0.28), transparent 60%);
  filter: blur(6px);
  z-index: -1;
  pointer-events: none;
}
.hero h1 {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.024em;
  margin: 0 0 6px;
  color: var(--label);
}
.hero p {
  color: var(--label-secondary);
  font-size: 15px;
  line-height: 1.4;
}
/* Light theme variant: paper-white card with gold edge */
:root[data-theme="light"] .hero, :root.light .hero {
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(202, 154, 4, 0.14), transparent 55%),
    linear-gradient(180deg, #ffffff, #f8f6ef);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.06),
    0 0 0 0.5px rgba(202, 154, 4, 0.2) inset;
}

.app-header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.app-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.3);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.app-brand .title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-brand .subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--label-secondary);
  line-height: 1.3;
  font-weight: 500;
}

/* ── Cards (iOS grouped list — solid bg, soft shadow, sharp inner separators) */

.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 0;
  margin: 12px 0;
  transition: background .15s var(--ease-out);
}
.card.narrow { max-width: 480px; }
.card .title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--label);
}
.card h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}

/* Row inside a card — used as flex container */
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

/* ── KPI cards (big numerals, balance grid) ─────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
.kpi-card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 96px;
  position: relative;
}
.kpi-card .kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--label-secondary);
  letter-spacing: -0.01em;
  text-transform: none;
}
.kpi-card .kpi-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.026em;
  line-height: 1.1;
  color: var(--label);
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.kpi-card .kpi-meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--label-secondary);
  line-height: 1.3;
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ── Buttons (iOS-grade, three weights) ─────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--tint);
  color: var(--label-on-tint);
  border: none;
  border-radius: var(--r-md);
  padding: 13px 18px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  font-family: var(--font-sans);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform .12s var(--ease-out),
    background .15s var(--ease-out),
    filter .15s var(--ease-out),
    box-shadow .15s var(--ease-out),
    opacity .15s;
  min-height: 44px;             /* HIG touch target */
  text-decoration: none;
  user-select: none;
}
.btn:active { transform: scale(0.97); filter: brightness(0.92); }
.btn.secondary {
  background: var(--bg-card);
  color: var(--tint);
  box-shadow: inset 0 0 0 0.5px var(--separator);
}
.btn.secondary:active { background: var(--bg-card-soft); }
.btn.ghost {
  background: var(--tint-soft);
  color: var(--tint);
}
.btn.full { width: 100%; }
.btn[disabled], .btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

button { font-family: var(--font-sans); }

/* ── Segmented control (iOS UISegmentedControl) ─────────────────────────── */

.segmented {
  display: inline-flex;
  background: var(--label-quaternary);
  padding: 2px;
  border-radius: 10px;
  gap: 0;
}
.segmented.dark { background: rgba(0, 0, 0, 0.18); }
.seg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--label);
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-family: var(--font-sans);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .18s var(--ease-out), color .15s, transform .12s var(--ease-out);
  min-height: 32px;
  user-select: none;
}
.seg:active { transform: scale(0.96); }
.seg.active, .seg.is-active {
  background: var(--tint);
  color: var(--label-on-tint);
  box-shadow: 0 1px 6px var(--tint-glow);
}
.segmented.dark .seg { color: rgba(255, 255, 255, 0.78); }
.segmented.dark .seg.active, .segmented.dark .seg.is-active {
  background: var(--tint);
  color: var(--label-on-tint);
  box-shadow: 0 1px 6px var(--tint-glow);
}
.hero .segmented { background: rgba(255, 255, 255, 0.06); }
.hero .seg { color: var(--label-secondary); }
.hero .seg.active, .hero .seg.is-active { background: var(--tint); color: var(--label-on-tint); box-shadow: 0 1px 6px var(--tint-glow); }

/* ── Tabs (pill row inside hero) ────────────────────────────────────────── */

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tab {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--bg-card-soft);
  color: var(--label);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: background .15s var(--ease-out), transform .12s var(--ease-out);
  border: 0.5px solid var(--separator);
  -webkit-tap-highlight-color: transparent;
}
.tab:hover { background: var(--bg-elevated); }
.tab:active { transform: scale(0.97); }
.hero .tab { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.12); }
.hero .tab:hover { background: rgba(255, 255, 255, 0.12); }

/* ── Pills / Badges ─────────────────────────────────────────────────────── */

.pill, .badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--label-quaternary);
  color: var(--label-secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.3;
}
.pill.accent, .badge.accent { background: var(--tint-soft); color: var(--tint); }
.pill.ok, .badge.ok { background: rgba(48, 209, 88, 0.16); color: var(--success); }
.pill.danger, .badge.danger { background: rgba(255, 69, 58, 0.14); color: var(--danger); }
.pill.warning, .badge.warning { background: rgba(255, 159, 10, 0.14); color: var(--warning); }
.hero .pill, .hero .badge { background: var(--tint-soft); color: var(--tint); }

/* ── Links list (deep-links style) ──────────────────────────────────────── */

.links { display: flex; flex-direction: column; gap: 0; }
.link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--bg-card-soft);
  color: var(--label);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.012em;
  transition: background .15s var(--ease-out), transform .12s var(--ease-out);
}
.link:active { transform: scale(0.98); background: var(--label-quaternary); }
.link::after {
  content: '›';
  color: var(--label-tertiary);
  font-size: 20px;
  font-weight: 400;
}

/* ── Inputs ─────────────────────────────────────────────────────────────── */

input[type="text"], input[type="number"], input[type="search"], input[type="password"],
input[type="email"], input[type="url"], textarea, select {
  background: var(--bg-card);
  color: var(--label);
  border: 0;
  box-shadow: inset 0 0 0 0.5px var(--separator);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 16px;                /* prevents iOS auto-zoom */
  font-family: var(--font-sans);
  letter-spacing: -0.012em;
  width: 100%;
  min-height: 44px;
  outline: none;
  transition: box-shadow .15s var(--ease-out);
}
input:focus, textarea:focus, select:focus {
  box-shadow: inset 0 0 0 1.5px var(--tint);
}
::placeholder { color: var(--label-tertiary); }

label { font-size: 14px; font-weight: 600; color: var(--label-secondary); display: block; margin-bottom: 6px; }

/* ── Typography utilities ───────────────────────────────────────────────── */

.muted { color: var(--label-secondary); font-size: 14px; line-height: 1.4; }
.mono { font-family: var(--font-mono); font-size: 14px; letter-spacing: 0; }

/* iOS body / footnote / caption helpers */
.text-footnote { font-size: 13px; color: var(--label-secondary); }
.text-caption  { font-size: 12px; color: var(--label-secondary); }

/* ── Tables ─────────────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--r-md);
  overflow: hidden;
  margin: 10px 0;
}
th, td {
  padding: 12px 14px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.012em;
  border-bottom: 0.5px solid var(--separator);
  color: var(--label);
}
th {
  background: var(--bg-card-soft);
  color: var(--label-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tr:last-child td { border-bottom: none; }

/* ── Code / pre ─────────────────────────────────────────────────────────── */

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-card-soft);
  color: var(--label);
  padding: 2px 6px;
  border-radius: 6px;
}
pre {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--pre-bg);
  color: var(--pre-text);
  border-radius: var(--r-md);
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
  line-height: 1.55;
}

/* ── Status helpers ─────────────────────────────────────────────────────── */

.status-ok   { color: var(--success); }
.status-bad  { color: var(--danger); }
.status-warn { color: var(--warning); }

/* ── Service rows (list inside cards) ───────────────────────────────────── */

.service {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--separator);
}
.service:last-child { border-bottom: none; }
.service .name { font-weight: 600; font-size: 15px; }
.service .meta { font-size: 13px; color: var(--label-secondary); }

/* ── Sheet (iOS bottom sheet) ───────────────────────────────────────────── */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0; pointer-events: none;
  transition: opacity .26s var(--ease-out);
  backdrop-filter: saturate(140%) blur(6px);
  -webkit-backdrop-filter: saturate(140%) blur(6px);
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9001;
  background: var(--bg-card);
  border-top-left-radius: var(--r-xl);
  border-top-right-radius: var(--r-xl);
  padding: 8px 18px calc(20px + var(--tg-safe-bottom));
  transform: translateY(110%);
  transition: transform .38s var(--ease-spring);
  box-shadow: 0 -22px 60px rgba(0, 0, 0, 0.28);
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet.open { transform: translateY(0); }
.sheet-handle, .sheet::before {
  content: '';
  display: block;
  width: 38px; height: 5px;
  border-radius: 999px;
  background: var(--label-quaternary);
  margin: 6px auto 16px;
}
.sheet .sheet-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.024em;
  margin-bottom: 4px;
}

/* ── Skeleton loader ────────────────────────────────────────────────────── */

.skel-list { display: flex; flex-direction: column; gap: 10px; }
.skel-row {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--label-quaternary) 0%, var(--bg-card-soft) 50%, var(--label-quaternary) 100%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.3s infinite linear;
}
.skel-row:nth-child(2) { width: 78%; }
.skel-row:nth-child(3) { width: 62%; }
.skel-row:nth-child(4) { width: 88%; }
.skel-row:nth-child(5) { width: 70%; }
@keyframes skel-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Toast (slide-down from notch) ──────────────────────────────────────── */

.tg-toast {
  position: fixed;
  top: calc(10px + var(--tg-safe-top));
  left: 50%;
  transform: translate(-50%, -160%);
  z-index: 9999;
  padding: 11px 18px;
  border-radius: var(--r-pill);
  background: var(--material-ultra);
  color: var(--label);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100vw - 32px);
  opacity: 0;
  transition: transform .34s var(--ease-spring), opacity .22s;
  pointer-events: none;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}
.tg-toast.show { transform: translate(-50%, 0); opacity: 1; }
.tg-toast[data-kind="success"] { color: var(--success); }
.tg-toast[data-kind="error"]   { color: var(--danger); }

/* ── Sticky action bar (iOS docked button) ──────────────────────────────── */

.tg-stickybar {
  position: sticky;
  bottom: 0;
  margin: 14px -14px -22px;
  padding: 10px 14px calc(10px + var(--tg-safe-bottom));
  background: linear-gradient(to top, var(--bg) 72%, transparent);
  display: flex;
  gap: 10px;
  z-index: 50;
}
.tg-stickybar .btn { flex: 1; margin: 0; }

/* ── Onboarding overlay ─────────────────────────────────────────────────── */

.tg-onb {
  position: fixed; inset: 0; z-index: 9500;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 14px calc(18px + var(--tg-safe-bottom));
  opacity: 0;
  transition: opacity .26s var(--ease-out);
}
.tg-onb.is-shown { opacity: 1; }
.tg-onb.is-leaving { opacity: 0; }
.tg-onb-card {
  position: relative;
  width: 100%; max-width: 460px;
  background: var(--bg-card);
  border-radius: var(--r-xl);
  padding: 24px 22px 18px;
  box-shadow: var(--shadow-lg);
  transform: translateY(24px);
  animation: onb-pop .42s var(--ease-spring) forwards;
}
@keyframes onb-pop { to { transform: translateY(0); } }
.tg-onb-skip {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; color: var(--label-secondary);
  font-size: 14px; font-weight: 600; cursor: pointer; padding: 6px;
  font-family: var(--font-sans);
}
.tg-onb-emoji { font-size: 52px; line-height: 1; margin-bottom: 14px; }
.tg-onb-title { font-size: 24px; font-weight: 800; letter-spacing: -0.026em; margin: 0 0 8px; color: var(--label); }
.tg-onb-text { margin: 0 0 20px; color: var(--label-secondary); font-size: 16px; line-height: 1.45; }
.tg-onb-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.tg-onb-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--label-quaternary); transition: width .25s var(--ease-spring), background .2s; }
.tg-onb-dot.is-active { width: 22px; background: var(--tint); }
.tg-onb-next { width: 100%; margin: 0; }

/* ── Pull-to-refresh ────────────────────────────────────────────────────── */

.tg-ptr {
  position: fixed;
  top: calc(8px + var(--tg-safe-top));
  left: 50%;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--material-ultra);
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  z-index: 8000;
  transition: transform .26s var(--ease-out);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}
.tg-ptr-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--label-quaternary);
  border-top-color: var(--tint);
  border-radius: 50%;
}
.tg-ptr.is-ready .tg-ptr-spinner { border-top-color: var(--success); }
.tg-ptr.is-loading .tg-ptr-spinner { animation: ptr-spin .85s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ── Tab panels animation ──────────────────────────────────────────────── */

[data-tabpanel] { transition: opacity .2s var(--ease-out), transform .26s var(--ease-out); }
[data-tabpanel].is-hidden { display: none; }
[data-tabpanel].is-leaving { opacity: 0; transform: translateY(4px); }
[data-tabpanel].is-entering { opacity: 0; transform: translateY(6px); }
[data-tabpanel].is-visible { opacity: 1; transform: translateY(0); }

/* ── Reduced motion ─────────────────────────────────────────────────────── */

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

/* ── Press feedback for touch-only devices ─────────────────────────────── */

@media (hover: none) {
  .btn:active, button:active, .seg:active, .tab:active, .pill:active, .link:active {
    transform: scale(0.97);
    transition: transform .08s var(--ease-out);
  }
}
.btn, button, .seg, .tab, .pill, .link, a {
  -webkit-tap-highlight-color: transparent;
}

/* ── Staking sheet helpers (legacy compat) ─────────────────────────────── */

.staking-tier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.staking-tier-btn { padding: 10px 12px; border-radius: var(--r-md); font-weight: 600; }
.staking-tier-btn.st-selected {
  outline: 2px solid var(--tint);
  outline-offset: 1px;
}
.staking-dep {
  margin-top: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--bg-card-soft);
}

/* ── Shared site chrome (public pages: /, /docs, /faq, /market, /app) ────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 10, 12, 0.78);
  border-bottom: 1px solid var(--separator);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  margin: calc(-1 * max(14px, var(--tg-safe-top))) calc(-1 * max(14px, var(--tg-safe-right))) 0 calc(-1 * max(14px, var(--tg-safe-left)));
  padding: 12px max(14px, var(--tg-safe-right)) 12px max(14px, var(--tg-safe-left));
}
.site-header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1080px;
  margin: 0 auto;
}
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--label);
  text-decoration: none;
  flex: 0 0 auto;
}
.site-brand .brand-spark { font-size: 18px; }
.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--label-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  text-decoration: none;
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
  letter-spacing: -0.01em;
}
.site-nav a:hover { color: var(--label); background: rgba(255,255,255,.06); }
.site-nav a.is-active { color: var(--tint); background: var(--tint-soft); }
.site-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.site-actions .lang-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--separator);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--label-secondary);
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.site-actions .lang-pill:hover { background: rgba(255,255,255,.06); color: var(--label); }
.site-actions .btn-small {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-md);
  background: var(--tint);
  color: var(--label-on-tint);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.012em;
  box-shadow: 0 4px 18px var(--tint-glow);
  transition: transform .12s var(--ease-out), filter .15s;
}
.site-actions .btn-small:hover { filter: brightness(1.04); }
.site-actions .btn-small:active { transform: scale(0.96); }

@media (max-width: 900px) {
  .site-nav { display: none; }
  .site-actions { margin-left: auto; }
}

.site-mobile-nav {
  display: none;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 0 2px;
  margin: 0 auto;
  max-width: 1080px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.site-mobile-nav::-webkit-scrollbar { display: none; }
.site-mobile-nav a {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-card-soft);
  color: var(--label-secondary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 0.5px solid var(--separator);
}
.site-mobile-nav a.is-active { background: var(--tint-soft); color: var(--tint); border-color: transparent; }
@media (max-width: 900px) {
  .site-mobile-nav { display: flex; }
}

.site-footer {
  margin-top: 32px;
  padding: 24px 0 8px;
  border-top: 1px solid var(--separator);
  color: var(--label-secondary);
}
.site-footer-inner {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  max-width: 1080px;
  margin: 0 auto;
  font-size: 13px;
}
.site-footer a {
  color: var(--label-secondary);
  text-decoration: none;
  transition: color .15s;
}
.site-footer a:hover { color: var(--label); }
.site-footer .site-footer-links { display: flex; gap: 14px; flex-wrap: wrap; }
