/* ===========================================================================
   Base — reset, typography, app frame, glass utilities
   =========================================================================== */

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

* { margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { display: block; max-width: 100%; }

/* Tabular figures for all monetary / numeric displays */
.num, .amount, .balance, .stat-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
  letter-spacing: -0.01em;
}

/* ---- App frame: phone-first, centered on desktop ---- */
#app {
  position: relative;
  width: 100%;
  max-width: var(--app-max-w);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  overflow: hidden;
}

@media (min-width: 520px) {
  body { background: #050505; }
  #app {
    min-height: 100dvh;
    box-shadow: 0 0 0 1px var(--border-soft), 0 30px 80px rgba(0,0,0,0.6);
  }
}

/* A screen = full-bleed scrollable view inside the app frame */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  animation: screen-in var(--t-base) var(--ease-out);
}
.screen.has-nav { padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--s-4)); }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Scrollbars (desktop) */
.screen::-webkit-scrollbar { width: 0; }

/* ---- Typography helpers ---- */
.t-display { font-size: var(--fs-display); font-weight: var(--fw-black); letter-spacing: -0.03em; line-height: 1.02; }
.t-h1 { font-size: var(--fs-3xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.t-h2 { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.t-h3 { font-size: var(--fs-xl); font-weight: var(--fw-semibold); letter-spacing: -0.01em; }
.t-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.t-body { font-size: var(--fs-md); font-weight: var(--fw-regular); }
.t-sm { font-size: var(--fs-sm); }
.t-xs { font-size: var(--fs-xs); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.center { text-align: center; }
.upper { text-transform: uppercase; letter-spacing: 0.08em; }
.bold { font-weight: var(--fw-bold); }
.semibold { font-weight: var(--fw-semibold); }
.gold { color: var(--plt-gold); }
.success { color: var(--color-success); }
.error { color: var(--color-error); }
.warn { color: var(--color-warning); }

/* ---- Layout helpers ---- */
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.row.gap-1 { gap: var(--s-1); }
.row.gap-2 { gap: var(--s-2); }
.row.gap-3 { gap: var(--s-3); }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; }
.wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

.pad { padding: var(--s-5); }
.pad-x { padding-left: var(--s-5); padding-right: var(--s-5); }
.mt-1 { margin-top: var(--s-1); } .mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }

/* ---- Glass utility ---- */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  box-shadow: var(--glass-shadow);
}
.glass-2 { background: var(--glass-bg-2); }

/* ---- Screen header (sticky top bar) ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-5) var(--s-5) var(--s-4);
  background: linear-gradient(to bottom, var(--bg) 60%, transparent);
}
.topbar .icon-btn { margin-left: -6px; }
.topbar h1 { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; }

/* Visually-hidden but screen-reader accessible */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Skeleton shimmer */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
