:root {
  --bg0: #070b16;
  --bg1: #0b1226;
  --bg2: #0e1630;
  --card: rgba(255, 255, 255, 0.045);
  --card-brd: rgba(255, 255, 255, 0.10);
  --card-hi: rgba(255, 255, 255, 0.16);
  --txt: #eaf0ff;
  --muted: #8ea0c4;
  --accent: #4c8dff;
  --accent2: #6aa8ff;
  --accent-soft: rgba(76, 141, 255, 0.16);
  --radius: 22px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg0);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { overflow-x: hidden; }

/* ── фон ─────────────────────────────────────────────── */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 700px at 50% -10%, #16224a 0%, rgba(22, 34, 74, 0) 60%),
    linear-gradient(180deg, #0a1124 0%, #070b16 60%, #060912 100%);
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  animation: float 18s var(--ease) infinite alternate;
}
.b1 { width: 420px; height: 420px; left: -120px; top: -80px; background: #1c3a86; }
.b2 { width: 360px; height: 360px; right: -120px; top: 20%; background: #2a2f7a; animation-delay: -6s; }
.b3 { width: 500px; height: 500px; left: 20%; bottom: -220px; background: #122a66; animation-delay: -11s; }
@keyframes float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(30px, -30px, 0) scale(1.12); }
}

/* ── каркас ──────────────────────────────────────────── */
.app {
  min-height: 100%;
  padding: calc(var(--safe-top) + 14px) 18px calc(var(--safe-bot) + 22px);
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.brand-ai { color: var(--accent2); }

.balance {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--card-brd);
  background: var(--card);
  color: var(--txt);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}
.balance:active { transform: scale(0.96); background: var(--card-hi); }
.balance-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 10px var(--accent2);
}

/* ── переходы вида ───────────────────────────────────── */
.view { flex: 1; display: flex; flex-direction: column; }
.view-enter { animation: viewIn 0.42s var(--ease) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── home ────────────────────────────────────────────── */
.hero {
  text-align: center;
  margin: 10px 0 26px;
}
.hero h1 {
  font-size: 44px;
  line-height: 1.05;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: 0.2px;
}
.hero h1 .ai {
  background: linear-gradient(120deg, var(--accent2), #9cc4ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p {
  margin: 0 auto;
  max-width: 320px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.tile {
  position: relative;
  border: 1px solid var(--card-brd);
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
  overflow: hidden;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
  opacity: 0;
  transform: translateY(16px);
  animation: tileIn 0.5s var(--ease) forwards;
}
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(130px 90px at 78% 0%, var(--accent-soft), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}
.tile:active { transform: scale(0.97); border-color: var(--card-hi); }
.tile:hover::before { opacity: 1; }
@keyframes tileIn { to { opacity: 1; transform: translateY(0); } }

.tile .ico {
  width: 46px; height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid rgba(76, 141, 255, 0.25);
}
.tile .ico svg { width: 24px; height: 24px; stroke: var(--accent2); fill: none; stroke-width: 1.8; }
.tile .t-name { font-size: 16px; font-weight: 650; }
.tile .t-sub { font-size: 12px; color: var(--muted); margin-top: -8px; }
.tile.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; }
.tile.wide .t-name { font-size: 16px; }

/* ── профиль / карточки ──────────────────────────────── */
.card {
  border: 1px solid var(--card-brd);
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 22px 4px 12px;
}
.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.back {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--card-brd);
  background: var(--card);
  color: var(--txt);
  display: grid; place-items: center;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}
.back:active { transform: scale(0.92); background: var(--card-hi); }
.back svg { width: 20px; height: 20px; stroke: var(--txt); fill: none; stroke-width: 2; }
.page-head h2 { font-size: 22px; font-weight: 750; margin: 0; }

.bal-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.bal-row:last-child { border-bottom: 0; }
.bal-row .l { color: var(--muted); font-size: 14px; }
.bal-row .v { font-size: 18px; font-weight: 700; }

.profile-top { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #24407f, #1a2550);
  border: 1px solid var(--card-brd);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: #cfe0ff;
  background-size: cover; background-position: center;
}
.profile-top .n { font-size: 20px; font-weight: 750; }
.profile-top .u { font-size: 13px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 15px 18px;
  border-radius: 16px;
  border: 0;
  font-size: 15px; font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), #3b74e0);
  box-shadow: 0 10px 26px rgba(42, 92, 200, 0.35);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), filter 0.18s var(--ease);
  cursor: pointer;
}
.btn:active { transform: scale(0.97); filter: brightness(1.05); }
.btn.ghost {
  background: var(--card); color: var(--txt);
  border: 1px solid var(--card-brd); box-shadow: none;
}

.stub {
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}
.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent2);
  font-size: 12px;
  font-weight: 650;
  margin-top: 10px;
}

/* ── загрузка ────────────────────────────────────────── */
.loader {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 60vh;
}
.spin {
  width: 34px; height: 34px;
  border: 3px solid rgba(255,255,255,0.14);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── toast ───────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bot) + 24px);
  transform: translate(-50%, 24px);
  background: rgba(16, 24, 46, 0.96);
  border: 1px solid var(--card-brd);
  color: var(--txt);
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 50;
  max-width: 86%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
