/* ══════════════════════════════════════════════════════════════════════════
   Дизайн-система Mini App: iOS 26 (HIG) + Material 3
   ──────────────────────────────────────────────────────────────────────────
   Тёмная тема — базовая. Светлая включается через [data-theme="light"],
   который ставит app.js по tg.colorScheme.
   Слои: 1) токены  2) сброс  3) каркас  4) компоненты  5) состояния
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 1. Токены ───────────────────────────────────────────────────────────── */
:root {
  /* Нейтральная шкала (единый OKLCH-подобный ряд по светлоте) */
  --n-1000: #05060a;
  --n-950:  #08090f;
  --n-900:  #0b0d14;
  --n-850:  #10131c;
  --n-800:  #161a26;
  --n-750:  #1c2130;
  --n-700:  #232a3d;
  --n-600:  #333d57;
  --n-500:  #4a5675;
  --n-400:  #6b7794;
  --n-300:  #98a3bd;
  --n-200:  #c3cbdd;
  --n-100:  #e6eaf3;
  --n-50:   #f7f9fc;

  /* Системные цвета iOS */
  --ios-blue:   #0a84ff;
  --ios-indigo: #5e5ce6;
  --ios-purple: #bf5af2;
  --ios-green:  #30d158;
  --ios-yellow: #ffd60a;
  --ios-orange: #ff9f0a;
  --ios-red:    #ff453a;

  /* Акцент */
  --a-700: #3730a3;
  --a-600: #4338ca;
  --a-500: #5b52f0;
  --a-400: #6d67f5;
  --a-300: #8f8bfa;
  --a-200: #b4b1fc;
  --a-glow: rgba(109,103,245,0.30);
  --a-soft: rgba(109,103,245,0.14);
  --a-line: rgba(109,103,245,0.34);

  /* Семантика */
  --ok:          var(--ios-green);
  --ok-soft:     rgba(48,209,88,0.15);
  --warn:        var(--ios-orange);
  --warn-soft:   rgba(255,159,10,0.15);
  --danger:      var(--ios-red);
  --danger-soft: rgba(255,69,58,0.15);

  /* Роли поверхностей */
  --bg:          var(--n-900);
  --bg-elev:     var(--n-850);
  --surface:     rgba(22,26,38,0.74);
  --surface-hi:  rgba(35,42,61,0.62);
  --surface-solid: var(--n-800);
  --border:      rgba(255,255,255,0.065);
  --border-hi:   rgba(255,255,255,0.115);

  --text:        var(--n-50);
  --text-2:      var(--n-200);
  --text-muted:  var(--n-300);
  --text-dim:    var(--n-400);

  --accent:      var(--a-400);
  --accent-fg:   #ffffff;
  --accent-grad: linear-gradient(135deg, #8f8bfa 0%, #6d67f5 52%, #5b52f0 100%);

  /* Elevation — Material 3 + iOS-тени */
  --el-0: none;
  --el-1: 0 1px 2px rgba(0,0,0,0.30), 0 1px 3px rgba(0,0,0,0.22);
  --el-2: 0 2px 6px rgba(0,0,0,0.34), 0 4px 14px rgba(0,0,0,0.28);
  --el-3: 0 8px 26px rgba(0,0,0,0.46), 0 2px 8px rgba(0,0,0,0.30);
  --el-4: 0 16px 48px rgba(0,0,0,0.56);
  --el-acc: 0 6px 22px rgba(109,103,245,0.34);

  --ring: 0 0 0 3px var(--a-soft);
  --hairline: inset 0 1px 0 rgba(255,255,255,0.055);

  /* Скругления — iOS 26 крупнее, чем было */
  --r-xs: 9px;
  --r-sm: 13px;
  --r-md: 18px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-2xl: 34px;
  --r-full: 999px;

  /* Ритм */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  --maxw: 470px;
  --nav-h: 64px;
  --bar-h: 52px;

  /* Пружины и кривые */
  --ease-spring: cubic-bezier(0.34,1.56,0.64,1);
  --ease-out:    cubic-bezier(0.16,1,0.3,1);
  --ease-std:    cubic-bezier(0.2,0,0,1);
  --dur-1: 140ms;
  --dur-2: 220ms;
  --dur-3: 340ms;

  /* Тап-таргеты */
  --tap: 44px;

  /* Прозрачность стекла */
  --glass-blur: 26px;
  --glass-sat: 165%;
}

/* Светлая тема */
[data-theme="light"] {
  --bg:          var(--n-50);
  --bg-elev:     #ffffff;
  --surface:     rgba(255,255,255,0.86);
  --surface-hi:  rgba(233,237,246,0.90);
  --surface-solid: #ffffff;
  --border:      rgba(17,24,39,0.055);
  --border-hi:   rgba(17,24,39,0.095);

  --text:        #0d1017;
  --text-2:      #2c3444;
  --text-muted:  var(--n-500);
  --text-dim:    var(--n-400);

  --accent:      var(--a-600);
  --a-soft:      rgba(67,56,202,0.10);
  --a-glow:      rgba(67,56,202,0.18);
  --a-line:      rgba(67,56,202,0.28);

  --ok:          #0f9d58;
  --ok-soft:     rgba(15,157,88,0.12);
  --warn:        #c77700;
  --warn-soft:   rgba(199,119,0,0.12);
  --danger:      #d92c20;
  --danger-soft: rgba(217,44,32,0.11);

  --el-1: 0 1px 2px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.05);
  --el-2: 0 2px 6px rgba(15,23,42,0.08), 0 4px 14px rgba(15,23,42,0.06);
  --el-3: 0 8px 26px rgba(15,23,42,0.12), 0 2px 8px rgba(15,23,42,0.07);
  --el-4: 0 16px 48px rgba(15,23,42,0.16);
  --el-acc: 0 6px 22px rgba(67,56,202,0.22);
  --hairline: inset 0 1px 0 rgba(255,255,255,0.9);
}

/* ── 2. Сброс ────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.011em;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--dur-3) var(--ease-out), color var(--dur-2) var(--ease-out);
}

button, input { font: inherit; color: inherit; }

/* Фоновая канва частиц */
#particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ── 3. Каркас ───────────────────────────────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-2) var(--sp-3) calc(var(--nav-h) + var(--sp-8) + env(safe-area-inset-bottom, 0px));
  min-height: 100dvh;
}

.screen {
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin: 0 auto;
}

.hidden { display: none !important; }

/* ── Анимации ────────────────────────────────────────────────────────────── */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes fadeUp   { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes sheetUp  { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes rippleOut{ to { transform: scale(2.6); opacity: 0; } }
@keyframes pulseRing{
  0%   { transform: scale(0.85); opacity: 0.6; }
  70%  { transform: scale(1.5);  opacity: 0; }
  100% { transform: scale(0.85); opacity: 0; }
}

/* ── Загрузка ────────────────────────────────────────────────────────────── */
#loading { align-items: center; justify-content: center; min-height: 64dvh; }

.loader-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); }

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border-hi);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loader-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ── Карточка (база) ─────────────────────────────────────────────────────── */
.card {
  width: 100%;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border-hi);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  box-shadow: var(--el-1), var(--hairline);
  animation: fadeUp var(--dur-3) var(--ease-out) both;
}

/* ── Компактный хедер при скролле ────────────────────────────────────────── */
.compact-bar {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%) translateY(-100%);
  width: 100%;
  max-width: var(--maxw);
  height: var(--bar-h);
  padding: 0 var(--sp-4);
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  border-bottom: 1px solid var(--border);
  transition: transform var(--dur-3) var(--ease-out);
}
.compact-bar.show { transform: translateX(-50%) translateY(0); }

.compact-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
  background-size: cover; background-position: center;
}

.compact-name {
  font-size: 0.9375rem;
  font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}

.compact-status {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.compact-status.ok     { color: var(--ok); }
.compact-status.warn   { color: var(--warn); }
.compact-status.danger { color: var(--danger); }

/* ── Hero (large title) ──────────────────────────────────────────────────── */
.hero {
  position: relative;
  width: 100%;
  border-radius: var(--r-xl);
  overflow: hidden;
  border: 1px solid var(--border-hi);
  box-shadow: var(--el-3), var(--hairline);
  animation: fadeUp var(--dur-3) var(--ease-out) both;
  min-height: 132px;
  isolation: isolate;
}

.hero-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  transition: transform 0.7s var(--ease-out);
  will-change: transform;
  z-index: 0;
}

.hero-overlay {
  position: absolute; inset: 0;
  z-index: 1;
  background: linear-gradient(
    165deg,
    rgba(5,6,10,0.90) 0%,
    rgba(5,6,10,0.30) 48%,
    rgba(5,6,10,0.84) 100%
  );
}

.hero-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 26px 18px 20px;
}

/* Кнопка смены темы — стеклянная, в правом нижнем углу героя */
.icon-block {
  position: absolute;
  bottom: 14px; right: 14px;
  z-index: 3;
  width: var(--tap); height: var(--tap);
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(5,6,10,0.48);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform var(--dur-1) var(--ease-spring),
              background var(--dur-2) var(--ease-out),
              border-color var(--dur-2) var(--ease-out);
}
.icon-block:hover  { background: rgba(5,6,10,0.66); border-color: rgba(255,255,255,0.3); }
.icon-block:active { transform: scale(0.88); }

.icon-fallback {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  font-size: 18px; line-height: 1;
}

/* Аватар */
.avatar-wrap { position: relative; flex-shrink: 0; }

.avatar, .avatar-fallback {
  width: 54px; height: 54px;
  border-radius: var(--r-md);
  border: 2px solid rgba(255,255,255,0.24);
  display: block;
  box-shadow: var(--el-2);
}
.avatar { object-fit: cover; }

.avatar-fallback {
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.125rem; font-weight: 800; color: #fff;
  letter-spacing: -0.02em;
}

.user-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.user-name {
  font-size: 1.3125rem;
  font-weight: 800;
  line-height: 1.15;
  color: #fff;
  letter-spacing: -0.022em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

.user-username {
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.72);
  font-weight: 500;
  text-shadow: 0 1px 5px rgba(0,0,0,0.5);
}

/* ── Карточка статуса ────────────────────────────────────────────────────── */
.status-card { padding: 15px var(--sp-4); }

/* Status Dot (21st.dev — System Status Block) */
@keyframes statusPulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  50%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1);   opacity: 0; }
}

.status-dot-wrap {
  position: relative;
  width: 10px; height: 10px;
  flex-shrink: 0;
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--ok);
  display: block;
  position: relative;
  z-index: 1;
}
.status-dot.off  { background: var(--danger); }
.status-dot.warn { background: var(--warn); }

.status-dot::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: inherit;
  opacity: 0.7;
  animation: statusPulse 2.2s var(--ease-out) infinite;
}
.status-dot.off::before { animation: none; }

.status-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.status-icon {
  width: 26px; height: 26px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
}
.status-icon[hidden] { display: none; }

.status-text {
  font-size: 0.9375rem;
  font-weight: 680;
  letter-spacing: -0.015em;
}

.status-until {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Прогресс */
.progress {
  width: 100%;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-hi);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: var(--r-full);
  background: var(--accent-grad);
  transition: width 0.7s var(--ease-out), background var(--dur-2) var(--ease-out);
}
.progress-bar.warn   { background: linear-gradient(90deg, var(--warn), #ff7a1a); }
.progress-bar.danger { background: linear-gradient(90deg, var(--danger), #ff7a5c); }

/* ── Чипы статистики ─────────────────────────────────────────────────────── */
.hero-stats {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
  animation: fadeUp var(--dur-3) var(--ease-out) both;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border-hi);
  backdrop-filter: blur(20px) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(20px) saturate(var(--glass-sat));
  box-shadow: var(--el-1), var(--hairline);
  transition: border-color var(--dur-2) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out),
              transform var(--dur-1) var(--ease-spring);
  min-width: 0;
}
.stat-chip:active { transform: scale(0.985); }
.stat-chip.wide { grid-column: 1 / -1; }

.chip-icon {
  width: 34px; height: 34px;
  border-radius: var(--r-xs);
  background: var(--a-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  transition: background var(--dur-2) var(--ease-out);
}
.stat-chip:hover .chip-icon { background: var(--a-glow); }

.chip-meta { display: flex; flex-direction: column; min-width: 0; }

.chip-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 550;
  line-height: 1.2;
  letter-spacing: 0.005em;
}

.chip-value {
  font-size: 0.875rem;
  font-weight: 700;
  margin-top: 2px;
  line-height: 1.2;
  letter-spacing: -0.012em;
  font-family: "JetBrains Mono", "SF Mono", monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

/* ── Карточка трафика ────────────────────────────────────────────────────── */
.traffic-card { padding: 13px var(--sp-4); }

.traffic-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}

.traffic-title {
  font-size: 0.8125rem;
  font-weight: 620;
  color: var(--text-muted);
  letter-spacing: -0.005em;
}

.traffic-nums {
  font-size: 0.875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.012em;
  font-family: "JetBrains Mono", "SF Mono", monospace;
}

/* Partition Bar (21st.dev — Partition Bar) */
.partition-bar {
  width: 100%;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--surface-hi);
  overflow: hidden;
  display: flex;
  gap: 2px;
}
.partition-segment {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.8s var(--ease-out);
}
.partition-segment.used {
  background: linear-gradient(90deg, var(--accent) 0%, #8f8bfa 100%);
}
.partition-segment.used.warn   { background: linear-gradient(90deg, var(--warn), #ffb340); }
.partition-segment.used.danger { background: linear-gradient(90deg, var(--danger), #ff7a5c); }
.partition-segment.free {
  background: var(--border-hi);
  flex: 1;
}

/* ── Кнопки ──────────────────────────────────────────────────────────────── */
.actions-row { display: flex; gap: var(--sp-2); }

.action-btn {
  position: relative;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: 12px var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border-hi);
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(20px) saturate(var(--glass-sat));
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 620;
  letter-spacing: -0.008em;
  cursor: pointer;
  box-shadow: var(--el-1), var(--hairline);
  overflow: hidden;
  isolation: isolate;
  -webkit-user-select: none; user-select: none;
  transition: transform var(--dur-1) var(--ease-spring),
              box-shadow var(--dur-2) var(--ease-out),
              border-color var(--dur-2) var(--ease-out),
              background var(--dur-2) var(--ease-out);
}

/* Material 3: state layer вместо сплошной заливки при наведении */
.action-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-2) var(--ease-std);
  z-index: 1;
}
.action-btn:hover::after  { opacity: 0.06; }
.action-btn:active::after { opacity: 0.12; }

/* Текст и иконки — над ripple и state layer. Сам .ripple исключаем,
   иначе он перекрывал бы подпись (opacity 0.26 подкрашивала бы текст). */
.action-btn > *:not(.ripple) { position: relative; z-index: 2; }

.action-btn:active { transform: scale(0.972); }

.action-btn:disabled {
  opacity: 0.40;
  cursor: not-allowed;
}
.action-btn:disabled:active { transform: none; }
.action-btn:disabled::after { opacity: 0; }

.action-btn.full { width: 100%; }

.action-btn.primary {
  background: var(--accent-grad);
  color: var(--accent-fg);
  border-color: transparent;
  box-shadow: var(--el-acc);
}
.action-btn.primary::after { background: #fff; }
.action-btn.primary:hover  { box-shadow: 0 8px 30px rgba(109,103,245,0.44); }
.action-btn.primary:active { box-shadow: 0 3px 14px rgba(109,103,245,0.30); }

.action-btn.mini {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 9px 14px;
  font-size: 0.8125rem;
  border-radius: var(--r-sm);
}

/* Ripple (Material 3) — волна от точки касания */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.26;
  transform: scale(0);
  pointer-events: none;
  animation: rippleOut 560ms var(--ease-out) forwards;
  z-index: 1;
}
.action-btn.primary .ripple { background: #fff; opacity: 0.34; }

/* Иконка внутри кнопки */
.btn-icon {
  width: 19px; height: 19px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

/* ── Переключатель ───────────────────────────────────────────────────────── */
.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 14px var(--sp-4);
}

.toggle-info { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }

.toggle-title {
  font-size: 0.875rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.toggle-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.switch {
  flex-shrink: 0;
  width: 51px; height: 31px;
  border-radius: var(--r-full);
  border: none;
  background: var(--surface-hi);
  cursor: pointer;
  padding: 2px;
  transition: background var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.switch:hover { box-shadow: var(--ring); }
.switch[aria-checked="true"] {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--a-soft);
}

.switch-knob {
  display: block;
  width: 27px; height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,0.30), 0 1px 2px rgba(0,0,0,0.20);
  transition: transform var(--dur-2) var(--ease-spring);
}
.switch[aria-checked="true"] .switch-knob { transform: translateX(20px); }

/* ── Баланс ──────────────────────────────────────────────────────────────── */
.balance-card { padding: var(--sp-4); }

.balance-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.balance-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.balance-amount {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.032em;
  font-variant-numeric: tabular-nums;
  font-family: "JetBrains Mono", "SF Mono", "Fira Mono", monospace;
}

/* ── Рефералы ────────────────────────────────────────────────────────────── */
.referral-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 14px var(--sp-4);
}
.referral-head { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }

/* ── Списки / Timeline истории (21st.dev — Timeline) ────────────────────── */
.list-card { padding: 15px var(--sp-4); }

.list-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.list-title {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  flex: 1;
  min-width: 0;
}

.list-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
}

.list-refresh {
  width: 34px; height: 34px;
  min-width: 34px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border-hi);
  background: var(--surface-hi);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform var(--dur-2) var(--ease-spring),
              color var(--dur-2) var(--ease-out),
              background var(--dur-2) var(--ease-out);
}
.list-refresh:hover  { color: var(--text); background: var(--a-soft); }
.list-refresh:active { transform: scale(0.88) rotate(-90deg); }
.list-refresh .btn-icon { font-size: 15px; }

/* Timeline items */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px 0;
  position: relative;
}
.list-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 17px;
  top: calc(36px + 4px);
  bottom: calc(-10px);
  width: 2px;
  background: var(--border);
  border-radius: var(--r-full);
}
.list-item:first-child { border-top: none; }

.list-item-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-xs);
  background: var(--surface-hi);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
  position: relative;
  z-index: 1;
  border: 1px solid var(--border);
}

.list-item-body  { min-width: 0; flex: 1; }
.list-item-title {
  font-size: 0.875rem;
  font-weight: 620;
  letter-spacing: -0.008em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-item-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.list-item-amount {
  font-size: 0.875rem;
  font-weight: 700;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.012em;
  font-family: "JetBrains Mono", "SF Mono", monospace;
}
.list-item-amount.plus  { color: var(--ok); }
.list-item-amount.minus { color: var(--danger); }

.list-empty {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  padding: 14px 0;
}

/* ── Промокод ────────────────────────────────────────────────────────────── */
.promo-card { padding: 15px var(--sp-4); }
.promo-row  { display: flex; gap: var(--sp-2); }

.promo-input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-hi);
  background: var(--surface-hi);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 620;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color var(--dur-2) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out),
              background var(--dur-2) var(--ease-out);
}
.promo-input::placeholder {
  color: var(--text-dim);
  text-transform: none;
  font-weight: 400;
  letter-spacing: normal;
}
.promo-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--ring);
}

/* ── Колесо фортуны ──────────────────────────────────────────────────────── */
.wheel-card { padding: var(--sp-4); }

.wheel-wrap {
  position: relative;
  width: 290px; height: 290px;
  margin: var(--sp-3) auto var(--sp-4);
  max-width: 84vw; max-height: 84vw;
}

@keyframes wheelGlow {
  0%   { box-shadow: 0 0 0 6px var(--surface-hi), 0 0 0 8px var(--border-hi), var(--el-3), 0 0 32px var(--a-glow); }
  50%  { box-shadow: 0 0 0 6px var(--surface-hi), 0 0 0 9px var(--a-line),    var(--el-3), 0 0 52px rgba(109,103,245,0.52); }
  100% { box-shadow: 0 0 0 6px var(--surface-hi), 0 0 0 8px var(--border-hi), var(--el-3), 0 0 32px var(--a-glow); }
}

.wheel-canvas {
  width: 100%; height: 100%;
  border-radius: 50%;
  display: block;
  box-shadow:
    0 0 0 6px var(--surface-hi),
    0 0 0 8px var(--border-hi),
    var(--el-3);
  transition: transform 4.5s cubic-bezier(0.17,0.67,0.12,1);
}
.wheel-canvas.spinning {
  animation: wheelGlow 1s ease-in-out infinite;
}

.wheel-pointer {
  position: absolute;
  top: -17px; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 32px;
  z-index: 3;
  filter: drop-shadow(0 3px 8px rgba(109,103,245,0.65));
}
.wheel-pointer svg { width: 100%; height: 100%; }

.wheel-hub {
  position: absolute;
  left: 50%; top: 50%;
  width: 60px; height: 60px;
  transform: translate(-50%,-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--n-700), var(--surface-solid));
  border: 3px solid var(--border-hi);
  z-index: 2;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  pointer-events: none;
  overflow: hidden;
  box-shadow: var(--el-2), var(--hairline), inset 0 1px 0 rgba(255,255,255,0.12);
}
[data-theme="light"] .wheel-hub {
  background: radial-gradient(circle at 35% 35%, #ffffff, #e8edf6);
}

.wheel-status {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  min-height: 1.25em;
  text-align: center;
}

/* ── Лидерборд ───────────────────────────────────────────────────────────── */
.list-item-rank {
  width: 30px;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.9375rem;
  font-weight: 800;
  color: var(--text-muted);
}
.list-item-prize {
  font-size: 0.8125rem;
  color: var(--ok);
  font-weight: 700;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.list-item.me {
  background: var(--a-soft);
  border-radius: var(--r-sm);
  margin: 2px -8px;
  padding-left: 8px;
  padding-right: 8px;
}

.contest-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: var(--sp-3) 0 var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

/* ── Оформление (темы) ───────────────────────────────────────────────────── */
.theme-card { padding: 15px var(--sp-4); }
.theme-btns { display: flex; gap: var(--sp-3); }

.theme-btn {
  width: 56px; height: 56px;
  border-radius: var(--r-sm);
  border: 2px solid transparent;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  background-color: var(--surface-hi);
  position: relative;
  transition: transform var(--dur-1) var(--ease-spring),
              border-color var(--dur-2) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out);
}
.theme-btn:hover  { transform: scale(1.07); }
.theme-btn:active { transform: scale(0.93); }
.theme-btn.active {
  border-color: var(--accent);
  box-shadow: var(--ring), var(--el-2);
}
.theme-btn.active::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: calc(var(--r-sm) - 2px);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.55);
  pointer-events: none;
}

/* ── Строки-ссылки ───────────────────────────────────────────────────────── */
.link-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--tap);
  padding: 14px var(--sp-4);
  text-decoration: none;
  color: var(--text);
  border-radius: inherit;
  cursor: pointer;
  transition: background var(--dur-2) var(--ease-out);
}
.link-row:hover  { background: var(--surface-hi); }
.link-row:active { background: var(--a-soft); }

.link-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-xs);
  background: var(--a-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  font-size: 18px;
}

.link-title {
  font-size: 0.9375rem;
  font-weight: 620;
  letter-spacing: -0.012em;
  flex: 1;
}

.link-arrow {
  color: var(--text-dim);
  display: flex;
  flex-shrink: 0;
  transition: transform var(--dur-2) var(--ease-spring), color var(--dur-2) var(--ease-out);
}
.link-row:hover .link-arrow { transform: translateX(3px); color: var(--text-muted); }

.more-id {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding: var(--sp-2) 0 var(--sp-1);
  font-variant-numeric: tabular-nums;
}

/* ── Семья (drill-in) ────────────────────────────────────────────────────── */
.drill-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 4px 0 10px;
}

.drill-back {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-hi);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: transform var(--dur-1) var(--ease-spring), background var(--dur-2) var(--ease-out);
}
.drill-back:hover  { background: var(--surface-hi); }
.drill-back:active { transform: scale(0.90); }
.drill-back .btn-icon { font-size: 17px; }

.drill-title {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.024em;
}

#family-body { display: flex; flex-direction: column; gap: var(--sp-2); }

/* Блоки, которые рисует app.js для семьи */
.family-bank {
  padding: var(--sp-4);
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--el-acc);
}
.family-bank-label {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.85;
  letter-spacing: 0.01em;
}
.family-bank-amount {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 4px;
  letter-spacing: -0.032em;
  font-variant-numeric: tabular-nums;
  font-family: "JetBrains Mono", "SF Mono", monospace;
}
.family-sub {
  font-size: 0.75rem;
  opacity: 0.82;
  margin-top: var(--sp-2);
}

.fam-form { display: flex; gap: var(--sp-2); }

/* ── Ошибка ──────────────────────────────────────────────────────────────── */
#error { align-items: center; justify-content: center; min-height: 54dvh; }

.error-card {
  background: var(--surface);
  border: 1px solid var(--danger-soft);
  border-radius: var(--r-lg);
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  max-width: 310px;
  text-align: center;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--el-3);
  animation: fadeUp var(--dur-3) var(--ease-out) both;
}

.error-icon-wrap {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  line-height: 1;
  overflow: hidden;
}

#error-msg {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* ── Модальная шторка ────────────────────────────────────────────────────── */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn var(--dur-2) var(--ease-out) both;
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: var(--maxw);
  background: var(--bg-elev);
  border-top-left-radius: var(--r-xl);
  border-top-right-radius: var(--r-xl);
  border: 1px solid var(--border-hi);
  border-bottom: none;
  padding: var(--sp-2) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  animation: sheetUp var(--dur-3) var(--ease-out) both;
  box-shadow: var(--el-4);
}

.sheet-grabber {
  width: 38px; height: 5px;
  border-radius: var(--r-full);
  background: var(--border-hi);
  margin: 0 auto 2px;
  flex-shrink: 0;
}

.sheet-title {
  font-size: 1.0625rem;
  font-weight: 750;
  letter-spacing: -0.018em;
  text-align: center;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  text-align: center;
}

.sheet-body img {
  width: 240px; height: 240px;
  max-width: 72vw; max-height: 72vw;
  border-radius: var(--r-md);
  background: #fff;
  padding: 12px;
  box-shadow: var(--el-2);
}

.sheet-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.sheet-link {
  width: 100%;
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-muted);
  background: var(--surface-hi);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  word-break: break-all;
  line-height: 1.5;
}

/* ── Нижнее меню (liquid glass) ──────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: calc(100% - 20px);
  max-width: var(--maxw);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-2xl);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  box-shadow: var(--el-3), var(--hairline);
  z-index: 100;
  transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-2) var(--ease-out);
}

.nav-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  position: relative;
  border-radius: var(--r-lg);
  padding: 0;
  transition: color var(--dur-2) var(--ease-out);
}
.nav-item > span:last-child {
  font-size: 0.625rem;
  font-weight: 620;
  letter-spacing: 0.005em;
}

/* Активный пилл */
.nav-item::before {
  content: '';
  position: absolute;
  inset: 9px 5px;
  border-radius: var(--r-md);
  background: var(--a-soft);
  opacity: 0;
  transform: scale(0.82);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-spring);
}
.nav-item.active::before { opacity: 1; transform: scale(1); }
.nav-item.active { color: var(--accent); }

.nav-icon {
  width: 25px; height: 25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  position: relative;
  z-index: 1;
  transition: transform var(--dur-2) var(--ease-spring);
}
.nav-item.active .nav-icon { transform: translateY(-1px) scale(1.08); }
.nav-item:active .nav-icon { transform: scale(0.9); }

/* Иконки-эмодзи (фолбэк, когда Lottie недоступен) */
.i-fallback {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  line-height: 1;
}

/* Когда Lottie смонтирован — текст-эмодзи убираем, SVG растягиваем.
   Селектор бьёт по всем контейнерам с data-icon (иконки меню, чипов,
   кнопок, заголовков), не трогая обычный текст внутри карточек. */
.i-live {
  font-size: 0 !important;
  line-height: 0;
}
.i-live > svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Доступность ─────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }

/* ── Медиа-предпочтения ──────────────────────────────────────────────────── */

/* Уменьшенная прозрачность: убираем размытие — иначе текст «плывёт» */
@media (prefers-reduced-transparency: reduce) {
  :root {
    --surface: var(--n-800);
    --surface-hi: var(--n-750);
    --glass-blur: 0px;
    --glass-sat: 100%;
  }
  [data-theme="light"] {
    --surface: #ffffff;
    --surface-hi: #eef1f8;
  }
  .card, .stat-chip, .action-btn, .bottom-nav, .compact-bar,
  .icon-block, .drill-back, .sheet-backdrop {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* Уменьшенная анимация */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .wheel-canvas { transition: none !important; }
  .ripple { display: none; }
}

/* Увеличенный контраст */
@media (prefers-contrast: more) {
  :root {
    --border: rgba(255,255,255,0.20);
    --border-hi: rgba(255,255,255,0.32);
    --text-muted: var(--n-200);
    --text-dim: var(--n-300);
  }
  [data-theme="light"] {
    --border: rgba(0,0,0,0.22);
    --border-hi: rgba(0,0,0,0.34);
    --text-muted: var(--n-600);
    --text-dim: var(--n-500);
  }
}

/* ── Адаптив ─────────────────────────────────────────────────────────────── */

/* Очень узкие экраны (iPhone SE, 320–360px) */
@media (max-width: 360px) {
  :root { --maxw: 100%; --sp-4: 14px; }
  body { font-size: 15px; }
  .balance-amount { font-size: 1.75rem; }
  .user-name { font-size: 1.1875rem; }
  .wheel-wrap { width: 240px; height: 240px; }
  .theme-btn { width: 50px; height: 50px; }
  .stat-chip { padding: 10px 11px; gap: 9px; }
  .chip-icon { width: 30px; height: 30px; }
  .action-btn { font-size: 0.8438rem; }
}

/* Широкие экраны: карточки не растягиваются */
@media (min-width: 520px) {
  #app { padding-top: var(--sp-4); }
}

/* Когда открыта шторка — не даём странице «прыгать» */
body.sheet-open { overflow: hidden; }
