:root {
  --accent: #b49cff;
  --accent-strong: #9b7bff;
  --accent-glow: rgba(155, 123, 255, 0.45);
  --accent-soft: rgba(155, 123, 255, 0.14);
  --accent-muted: rgba(155, 123, 255, 0.08);
  --bg: #0f0d14;
  --bg-elevated: #16131f;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.075);
  --surface-3: rgba(255, 255, 255, 0.11);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f6f3ff;
  --text-muted: rgba(246, 243, 255, 0.52);
  --text-faint: rgba(246, 243, 255, 0.32);
  --danger: #ff7b7b;
  --danger-soft: rgba(255, 123, 123, 0.12);
  --success: #5ee89a;
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.1);
  --gold: #f5c842;
  --radius: 18px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.2);
  --nav-h: 72px;
  --top-h: 56px;
  --tg-content-top: 0px;
  --tg-safe-bottom: 0px;
  --top-extra: 39px;
  --font: 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, sans-serif;
  --touch: 48px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body[data-theme="light"] {
  --bg: #f7f5fc;
  --bg-elevated: #ffffff;
  --surface: rgba(15, 13, 20, 0.04);
  --surface-2: rgba(15, 13, 20, 0.07);
  --surface-3: rgba(15, 13, 20, 0.1);
  --border: rgba(15, 13, 20, 0.08);
  --border-strong: rgba(15, 13, 20, 0.12);
  --text: #14101f;
  --text-muted: rgba(20, 16, 31, 0.55);
  --text-faint: rgba(20, 16, 31, 0.35);
  --shadow: 0 12px 40px rgba(80, 60, 120, 0.12);
  --shadow-soft: 0 4px 16px rgba(80, 60, 120, 0.08);
}

#app {
  display: flex;
  flex-direction: column;
  height: var(--tg-viewport-height, 100dvh);
  max-height: var(--tg-viewport-height, 100dvh);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(ellipse 90% 55% at 50% -15%, rgba(155, 123, 255, 0.22), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 80%, rgba(99, 102, 241, 0.1), transparent),
    var(--bg);
}

#app::before {
  content: '';
  position: fixed;
  inset: 0;
  max-width: 480px;
  margin: 0 auto;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.top-bar,
.main-content,
.bottom-nav {
  position: relative;
  z-index: 1;
}

/* ── Top bar ── */
.top-bar {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
}

.top-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 12px;
  padding-top: calc(var(--tg-content-top) + var(--top-extra));
}

body.tg-fullscreen {
  --top-extra: 45px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-inline-start: auto;
}

.top-bar-center {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-align: start;
}

.top-bar-row:has(.back-btn:not(.hidden)) .top-bar-center {
  text-align: center;
}

.page-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.page-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  max-width: 100%;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s var(--ease), background 0.15s;
}

.icon-btn:active {
  transform: scale(0.94);
  background: var(--surface-2);
}

.coins-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s var(--ease), background 0.15s;
}

.coins-chip:active {
  transform: scale(0.96);
  background: var(--surface-3);
}

.coins-chip-icon {
  font-size: 17px;
  line-height: 1;
}

.coins-chip-val {
  font-variant-numeric: tabular-nums;
  min-width: 1ch;
}

body[data-theme="light"] .coins-chip {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 13, 20, 0.1);
  box-shadow: var(--shadow-soft);
}

.hidden { display: none !important; }

/* ── Main scroll area ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px;
  padding-bottom: calc(var(--nav-h) + 20px + var(--tg-safe-bottom) + env(safe-area-inset-bottom, 0));
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.page-enter {
  animation: pageIn 0.38s var(--ease) both;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-h) + var(--tg-safe-bottom) + env(safe-area-inset-bottom, 0));
  padding: 8px 6px calc(8px + var(--tg-safe-bottom) + env(safe-area-inset-bottom, 0));
  display: flex;
  align-items: stretch;
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
  z-index: 30;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--text-faint);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.25s var(--ease);
  position: relative;
  min-height: var(--touch);
}

.nav-item.active {
  color: var(--accent);
}

.nav-icon-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-svg {
  width: 22px;
  height: 22px;
  transition: transform 0.25s var(--ease);
}

.nav-item.active .nav-svg {
  transform: scale(1.06);
}

.nav-label {
  line-height: 1;
}

.nav-badge {
  position: absolute;
  top: -2px;
  left: -2px;
  min-width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--bg-elevated);
}

.nav-badge.searching {
  background: var(--warning);
  animation: badgePulse 1.5s ease infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.85; }
}

.nav-indicator {
  display: none;
}

/* ── Loader & brand ── */
.loader-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 55vh;
  gap: 18px;
  color: var(--text-muted);
}

.brand-mark {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.02em;
}

.loader-ring {
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--accent-soft);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton */
.skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-card {
  height: 76px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ── Hero ── */
.hero {
  position: relative;
  border-radius: 22px;
  padding: 22px 18px;
  margin-bottom: 22px;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(155, 123, 255, 0.28) 0%, rgba(99, 102, 241, 0.12) 100%);
  border: 1px solid rgba(155, 123, 255, 0.22);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255,255,255,0.06);
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 85% 15%, rgba(255,255,255,0.12), transparent 45%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  position: relative;
}

.hero-avatar {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.hero-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-text { flex: 1; min-width: 0; }

.hero-greeting {
  font-size: 13px;
  color: rgba(255,255,255,0.72);
  margin-bottom: 2px;
}

body[data-theme="light"] .hero-greeting {
  color: var(--text-muted);
}

.hero-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}

.status-dot.live { background: var(--success); box-shadow: 0 0 8px rgba(94, 232, 154, 0.6); }
.status-dot.search { background: var(--warning); animation: badgePulse 1.5s ease infinite; }

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: relative;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

body[data-theme="light"] .stat-pill {
  background: rgba(255,255,255,0.65);
  border-color: rgba(0,0,0,0.06);
}

.stat-pill.vip {
  background: linear-gradient(135deg, rgba(245, 200, 66, 0.28), rgba(245, 158, 11, 0.12));
  border-color: rgba(245, 200, 66, 0.35);
  color: #fde68a;
}

body[data-theme="light"] .stat-pill.vip {
  color: #92400e;
}

/* ── Sections ── */
.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-right: 2px;
  letter-spacing: 0.02em;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* ── Feature grid ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}

.feature-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  min-height: 110px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.18s, border-color 0.18s;
  text-align: right;
  font-family: inherit;
  color: inherit;
  width: 100%;
  box-shadow: var(--shadow-soft);
}

.feature-card:active {
  transform: scale(0.97);
  background: var(--surface-2);
}

.feature-card.primary {
  grid-column: span 2;
  flex-direction: row;
  align-items: center;
  min-height: auto;
  padding: 18px;
  background: linear-gradient(135deg, rgba(155, 123, 255, 0.32), rgba(99, 102, 241, 0.16));
  border-color: rgba(155, 123, 255, 0.3);
}

.feature-icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--accent-muted);
  flex-shrink: 0;
}

.feature-card.primary .feature-icon {
  background: rgba(255,255,255,0.14);
  width: 52px;
  height: 52px;
  font-size: 24px;
}

.feature-label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.feature-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.45;
}

.feature-card.primary .feature-text { flex: 1; }

.feature-arrow {
  font-size: 18px;
  opacity: 0.5;
  margin-right: auto;
}

/* ── User cards ── */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  min-height: 76px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.15s, border-color 0.15s;
  box-shadow: var(--shadow-soft);
}

.user-card:active {
  transform: scale(0.985);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(99,102,241,0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar .online-dot {
  position: absolute;
  bottom: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--bg-elevated);
}

.avatar .online-dot.busy {
  background: var(--warning);
}

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.user-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.user-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-muted);
  color: var(--accent);
}

.user-tag.busy {
  background: var(--warning-soft);
  color: var(--warning);
}

.user-chevron {
  color: var(--text-faint);
  font-size: 18px;
  flex-shrink: 0;
  padding-left: 4px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: transform 0.15s var(--ease), opacity 0.15s, box-shadow 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-strong) 0%, #7c6cf0 50%, #6366f1 100%);
  color: #fff;
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(255, 123, 123, 0.25);
}

.btn-sm {
  min-height: 40px;
  padding: 10px 16px;
  font-size: 13px;
  width: auto;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* ── Chat states ── */
.chat-state-card {
  text-align: center;
  padding: 28px 20px;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}

.chat-state-icon {
  font-size: 52px;
  margin-bottom: 14px;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

.chat-state-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.chat-state-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.65;
}

.chat-state-desc code {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
  direction: ltr;
}

.searching-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0 auto 18px;
}

.searching-ring,
.searching-ring-2 {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
}

.searching-ring {
  border-top-color: var(--accent-strong);
  animation: spin 1s linear infinite;
}

.searching-ring-2 {
  inset: 10px;
  border-bottom-color: var(--accent);
  animation: spin 1.4s linear infinite reverse;
  opacity: 0.6;
}

.searching-core {
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  background: var(--accent-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.tip-box {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--warning-soft);
  border: 1px solid rgba(251, 191, 36, 0.18);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  margin-top: 14px;
}

.tip-box strong { font-weight: 700; }

/* ── Profile ── */
.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 18px;
  margin-bottom: 16px;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 26px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(99,102,241,0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 50px;
  overflow: hidden;
  margin-bottom: 14px;
  border: 3px solid rgba(155, 123, 255, 0.25);
  box-shadow: 0 8px 28px rgba(155, 123, 255, 0.2);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.profile-code {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  font-family: ui-monospace, monospace;
  direction: ltr;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.detail-list {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 14px;
  box-shadow: var(--shadow-soft);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.detail-row:last-child { border-bottom: none; }

.detail-label { color: var(--text-muted); font-weight: 500; }

.detail-value {
  font-weight: 600;
  text-align: left;
  max-width: 58%;
  word-break: break-word;
}

.bio-box {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.bio-box label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.bio-box textarea {
  width: 100%;
  min-height: 88px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.bio-box textarea:focus {
  border-color: var(--accent-strong);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.action-row .btn {
  padding: 12px 10px;
  font-size: 12px;
  min-height: 44px;
}

/* ── Connect ── */
.option-group { margin-bottom: 18px; }

.option-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-right: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--touch);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  width: 100%;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.option-btn:active { transform: scale(0.985); }

.option-btn.selected {
  background: var(--accent-soft);
  border-color: rgba(155, 123, 255, 0.4);
  box-shadow: inset 0 0 0 1px rgba(155, 123, 255, 0.15);
}

.option-btn .opt-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--accent-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.option-btn.selected .opt-icon {
  background: rgba(155, 123, 255, 0.25);
}

/* ── Coins ── */
.coins-hero {
  text-align: center;
  padding: 32px 24px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(245, 200, 66, 0.16), rgba(245, 158, 11, 0.04));
  border: 1px solid rgba(245, 200, 66, 0.22);
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
}

.coins-balance {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fde68a, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.coins-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 500;
}

.package-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  min-height: 68px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  box-shadow: var(--shadow-soft);
}

.package-info {
  font-size: 14px;
  font-weight: 700;
}

.package-stars {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.package-badge {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* ── Settings ── */
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.setting-label {
  font-size: 14px;
  font-weight: 600;
}

.setting-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.toggle {
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-3);
  border: none;
  position: relative;
  cursor: pointer;
  transition: background 0.25s var(--ease);
  flex-shrink: 0;
}

.toggle.on { background: var(--accent-strong); }

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.25s var(--ease);
}

.toggle.on::after { transform: translateX(-20px); }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 16px;
  background: var(--surface);
}

.chip {
  min-height: 38px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:active { transform: scale(0.96); }

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent-strong);
  color: var(--accent);
}

/* ── Search categories ── */
.search-sticky {
  position: sticky;
  top: 0;
  margin: -16px -16px 12px;
  padding: 12px 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 5;
  border-bottom: 1px solid transparent;
}

.category-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.category-scroll::-webkit-scrollbar { display: none; }

.category-chip {
  flex-shrink: 0;
  min-height: 38px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s var(--ease);
}

.category-chip:active { transform: scale(0.96); }

.category-chip.active {
  background: var(--accent-strong);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

/* ── Empty & pagination ── */
.empty-state {
  text-align: center;
  padding: 52px 28px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 52px;
  margin-bottom: 14px;
  opacity: 0.85;
}

.empty-state p {
  font-size: 14px;
  line-height: 1.6;
  max-width: 280px;
  margin: 0 auto;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  padding-bottom: 8px;
}

.pagination span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 64px;
  text-align: center;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px + var(--tg-safe-bottom) + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 13px 22px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-elevated) 95%, transparent);
  border: 1px solid var(--border-strong);
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
  box-shadow: var(--shadow);
  animation: toastIn 0.35s var(--ease);
  backdrop-filter: blur(16px);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ── In-app chat room ── */
body.chat-room-active .bottom-nav { display: none !important; }

.chat-partner-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-partner-info {
  min-width: 0;
  flex: 1;
}

.chat-partner-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.chat-partner-code {
  font-size: 13px;
  font-family: ui-monospace, monospace;
  direction: ltr;
  text-align: right;
  color: var(--accent);
}

.chat-partner-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.chat-partner-actions .icon-btn {
  width: 38px;
  height: 38px;
  font-size: 15px;
}

.main-content.chat-mode {
  padding: 0;
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-room {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  flex: 1;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 8px;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 40px 20px;
  margin: auto;
}

.msg-system {
  text-align: center;
  margin: 10px 0;
}

.msg-system span {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  margin-bottom: 4px;
}

.msg-row.mine {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-row.theirs {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  box-shadow: var(--shadow-soft);
}

.msg-row.mine .msg-bubble {
  background: linear-gradient(135deg, var(--accent-strong), #7c6cf0);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.msg-bubble.msg-media {
  padding: 4px;
  overflow: hidden;
  max-width: min(260px, 72vw);
}

.msg-row.mine .msg-bubble.msg-media {
  background: var(--surface-2);
  color: inherit;
}

.msg-image,
.msg-video {
  display: block;
  width: 100%;
  max-width: 260px;
  border-radius: 14px;
}

.msg-caption {
  padding: 8px 10px 4px;
  font-size: 14px;
  line-height: 1.45;
}

.msg-row.mine .msg-caption {
  color: var(--text);
}

.chat-attach-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.15s, color 0.15s;
}

.chat-attach-btn:active:not(:disabled) {
  transform: scale(0.94);
  background: var(--surface-2);
  color: var(--accent-strong);
}

.chat-attach-btn:disabled {
  opacity: 0.5;
}

.msg-row.theirs .msg-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}

.msg-time {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 3px;
  padding: 0 4px;
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--tg-safe-bottom) + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 94%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.chat-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: inherit;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  outline: none;
}

.chat-composer textarea:focus {
  border-color: var(--accent-strong);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-strong), #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: transform 0.15s var(--ease);
}

.chat-send-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.chat-send-btn:disabled {
  opacity: 0.5;
}

.chat-toolbar-btn.danger {
  color: var(--danger);
}

@media (max-width: 360px) {
  .grid-2 { grid-template-columns: 1fr; }
  .feature-card.primary { grid-column: span 1; }
  .nav-label { font-size: 9px; }
  .hero-title { font-size: 19px; }
}

/* ── Small phones ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Search lookup ── */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.search-box-icon {
  font-size: 16px;
  opacity: 0.6;
  flex-shrink: 0;
}

.search-box-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.search-box-btn {
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-xs);
  padding: 8px 14px;
  background: var(--accent-strong);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ── Referral ── */
.referral-hero {
  text-align: center;
  padding: 28px 20px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--border);
}

.referral-icon { font-size: 48px; margin-bottom: 8px; }
.referral-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.referral-desc { font-size: 14px; color: var(--text-muted); line-height: 1.5; }
.referral-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 20px;
}
.referral-stat span { display: block; font-size: 22px; font-weight: 700; }
.referral-stat small { font-size: 11px; color: var(--text-muted); }

/* ── Help ── */
.help-card {
  padding: 16px 18px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.help-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
}

.help-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}

.help-card code {
  font-size: 12px;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-sm {
  padding: 10px 14px !important;
  font-size: 13px !important;
}

.profile-header-edit {
  position: relative;
}

.avatar-edit-btn {
  position: relative;
  display: inline-block;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.avatar-edit-badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  font-size: 14px;
  border: 2px solid var(--surface);
}

.profile-incomplete-tag {
  margin-top: 8px;
  font-size: 12px;
  color: #ffb74d;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

.profile-readonly {
  margin-top: 8px;
}

.form-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.dm-composer {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.social-proof {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
}

.social-proof-sep { opacity: 0.4; }

.growth-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 16px 0 4px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 183, 77, 0.35);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.12), rgba(255, 87, 34, 0.08));
  color: inherit;
  text-align: right;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.growth-banner:active { transform: scale(0.98); }

.growth-banner-icon { font-size: 32px; flex-shrink: 0; }

.growth-banner-text { flex: 1; min-width: 0; }

.growth-banner-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.growth-banner-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.growth-banner-arrow {
  font-size: 22px;
  opacity: 0.5;
  transform: rotate(180deg);
}

button.package-card.package-buy {
  width: 100%;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

button.package-card.package-buy:active {
  transform: scale(0.98);
  border-color: var(--accent);
}
