/* ============================================================
   AIRIS CHAT-MANAGER — style.css
   Светлая тема с размытым фоном bg.jpg
   ============================================================ */

/* ---------- VARIABLES ---------- */
:root {
  --bg:        #f4f6fb;
  --bg2:       #ffffff;
  --bg3:       #eef1f8;
  --border:    #dde2f0;
  --accent:    #4f6ef7;
  --accent2:   #7c3aed;
  --text1:     #0f1629;
  --text2:     #4a5578;
  --text3:     #8e9bbf;
  --green:     #16a34a;
  --red:       #dc2626;
  --gold:      #d97706;
  --radius:    14px;
  --gap:       24px;
  --shadow:    0 2px 12px rgba(79,110,247,.08);
  --shadow-lg: 0 8px 32px rgba(79,110,247,.13);
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ---------- GLOBAL BACKGROUND (bg.jpg) ---------- */
body {
  font-family: 'Mulish', sans-serif;
  color: var(--text1);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  background-image: url('/bg.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(244, 246, 251, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: -1;
  pointer-events: none;
}

/* Контент поверх фона */
.container, .nav, .hero, .section, .stats-bar, .footer {
  position: relative;
  z-index: 1;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
svg { display: block; flex-shrink: 0; fill: none; stroke: currentColor;
      stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
code { font-family: monospace; background: var(--bg3); padding: 2px 6px; border-radius: 4px; font-size: .88em; }

/* ---------- LAYOUT ---------- */
.container { max-width: 1140px; margin: 0 auto; padding: 0 var(--gap); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr 1fr; } .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 580px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- REVEAL ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .5s ease, transform .5s ease; }
.reveal.active { opacity: 1; transform: none; }

/* ============================================================
   NAV
   ============================================================ */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(244, 246, 251, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; gap: 28px; height: 60px; }
.logo {
  font-family: 'Unbounded', sans-serif;
  font-weight: 900; font-size: 1.05rem;
  color: var(--text1); letter-spacing: -.3px;
  white-space: nowrap; flex-shrink: 0;
}
.logo span { color: var(--accent); }
.nav-links { display: flex; gap: 2px; }
.nav-links a {
  color: var(--text2); font-size: .84rem; font-weight: 600;
  padding: 6px 12px; border-radius: 8px;
  transition: background .18s, color .18s;
}
.nav-links a:hover { background: var(--bg3); color: var(--text1); text-decoration: none; }
.nav-cta {
  margin-left: auto;
  background: var(--accent); color: #fff !important;
  border-radius: 10px; padding: 8px 18px;
  font-size: .83rem; font-weight: 700;
  transition: opacity .18s; flex-shrink: 0;
}
.nav-cta:hover { opacity: .85; text-decoration: none !important; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff;
  border-radius: var(--radius); padding: 13px 26px;
  font-size: .93rem; font-weight: 700;
  transition: opacity .18s, transform .18s;
}
.btn-primary:hover { opacity: .87; transform: translateY(-1px); text-decoration: none; color: #fff; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; color: var(--text2);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 12px 22px; font-size: .93rem; font-weight: 600;
  transition: border-color .18s, color .18s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text1); text-decoration: none; }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative; text-align: center;
  padding: 100px 0 80px; overflow: hidden;
}
.hero-blur {
  position: absolute; border-radius: 50%; pointer-events: none;
}
.hero-blur.b1 {
  width: 600px; height: 600px;
  top: -200px; left: 50%; transform: translateX(-50%);
  background: radial-gradient(circle, rgba(79,110,247,.1) 0%, transparent 65%);
}
.hero-blur.b2 {
  width: 360px; height: 360px;
  bottom: -80px; right: 8%;
  background: radial-gradient(circle, rgba(124,58,237,.07) 0%, transparent 65%);
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(79,110,247,.08);
  border: 1px solid rgba(79,110,247,.2);
  border-radius: 999px; padding: 6px 16px;
  font-size: .75rem; font-weight: 700; color: var(--accent);
  letter-spacing: .06em; text-transform: uppercase;
  margin-bottom: 28px;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.35; } }
.hero h1 {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(2.2rem, 5.5vw, 4rem);
  font-weight: 900; line-height: 1.08;
  letter-spacing: -1.5px; margin-bottom: 22px;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--text2); font-size: 1.05rem; max-width: 540px; margin: 0 auto 38px; }
.hero-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ============================================================
   STATS BAR
   ============================================================ */
.stats-bar {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 24px 0;
}
.stats-bar-inner { display: flex; justify-content: center; flex-wrap: wrap; }
.stat-item { text-align: center; padding: 8px 40px; border-right: 1px solid var(--border); }
.stat-item:last-child { border-right: none; }
.stat-item .val {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.9rem; font-weight: 900; color: var(--text1); line-height: 1;
}
.stat-item .lbl { font-size: .73rem; color: var(--text3); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-top: 5px; }
@media (max-width: 580px) { .stat-item { padding: 10px 18px; border-right: none; border-bottom: 1px solid var(--border); }
  .stat-item:last-child { border-bottom: none; } }

/* ============================================================
   SECTIONS
   ============================================================ */
.section { position: relative; padding: 56px 0; }
.section-alt { background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(4px); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-label { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.section-title {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 900; line-height: 1.1;
  letter-spacing: -.4px; margin-bottom: 14px;
}
.section-sub { color: var(--text2); max-width: 520px; }

/* ============================================================
   FEATURE CARDS
   ============================================================ */
.feature-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px 20px;
  transition: border-color .22s, box-shadow .22s, transform .22s;
}
.feature-card:hover { border-color: rgba(79,110,247,.3); box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.feature-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; color: #fff;
}
.fi-blue   { background: #4f6ef7; }
.fi-purple { background: #7c3aed; }
.fi-gold   { background: #d97706; }
.fi-green  { background: #16a34a; }
.fi-orange { background: #ea580c; }
.fi-red    { background: #dc2626; }
.feature-card h3 { font-weight: 700; font-size: .9rem; margin-bottom: 5px; }
.feature-card p  { color: var(--text2); font-size: .82rem; line-height: 1.55; }

/* ============================================================
   ECONOMY CARDS
   ============================================================ */
.econ-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 18px; padding: 22px; text-align: center;
  transition: border-color .2s, transform .2s;
}
.econ-card:hover { border-color: rgba(79,110,247,.25); transform: translateY(-2px); }
.econ-icon { font-size: 2rem; margin-bottom: 10px; }
.econ-name { font-weight: 700; font-size: .95rem; margin-bottom: 6px; }
.econ-desc { color: var(--text2); font-size: .82rem; line-height: 1.55; }

/* ============================================================
   PRICING — тарифы на покупку айрисок
   ============================================================ */
.pricing-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 18px; padding: 26px 20px; text-align: center;
  box-shadow: var(--shadow); position: relative;
  transition: border-color .2s, transform .2s;
}
.pricing-card:hover { border-color: rgba(79,110,247,.3); transform: translateY(-2px); }
.pricing-card.featured { border-color: var(--accent); }
.pricing-badge {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; font-size: .68rem; font-weight: 700;
  padding: 3px 12px; border-radius: 999px; letter-spacing: .03em;
}
.pricing-amount { font-family: 'Unbounded', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--text1); margin: 6px 0 2px; }
.pricing-amount .u { font-size: .95rem; font-weight: 600; color: var(--text3); }
.pricing-price { color: var(--text2); font-size: .92rem; margin-bottom: 18px; }
.pricing-price b { color: var(--text1); font-size: 1.05rem; }
.pricing-btn {
  display: block; width: 100%; padding: 11px; border-radius: 10px;
  border: none; background: var(--accent); color: #fff;
  font-weight: 700; font-size: .85rem; cursor: pointer;
  transition: opacity .18s, transform .18s;
}
.pricing-btn:hover { opacity: .85; transform: translateY(-1px); }
.pricing-note { text-align: center; color: var(--text3); font-size: .78rem; margin-top: 18px; }

/* ============================================================
   TELEGRAM LOGIN — кнопка входа и меню аккаунта в шапке
   ============================================================ */
.tg-login-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text1); font-weight: 700; font-size: .85rem;
  padding: 9px 16px; border-radius: 10px; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.tg-login-btn:hover { border-color: var(--accent); background: #fff; }
.tg-login-btn svg { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }
.tg-account { position: relative; }
.tg-account-avatar {
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--border); object-fit: cover; display: block;
  transition: border-color .2s;
}
.tg-account-avatar:hover { border-color: var(--accent); }
.tg-account-menu {
  position: absolute; top: calc(100% + 10px); right: 0;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); min-width: 160px; padding: 8px;
  display: none; z-index: 50;
}
.tg-account-menu.open { display: block; }
.tg-account-name {
  font-size: .8rem; font-weight: 700; color: var(--text1);
  padding: 8px 10px 6px; border-bottom: 1px solid var(--bg3); margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tg-account-logout {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--red); font-weight: 600; font-size: .85rem; padding: 8px 10px;
  border-radius: 8px; cursor: pointer;
}
.tg-account-logout:hover { background: var(--bg3); }

/* ============================================================
   CATALOG — cards
   ============================================================ */
.sort-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.sort-btn {
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text2); border-radius: 10px;
  padding: 7px 18px; font-size: .82rem; font-weight: 600;
  transition: all .18s;
}
.sort-btn:hover { border-color: var(--accent); color: var(--text1); }
.sort-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 18px; }
.chat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.chat-card:hover { border-color: rgba(79,110,247,.35); box-shadow: var(--shadow-lg); transform: translateY(-4px); }

.chat-card-header { display: flex; align-items: center; gap: 10px; }
.chat-avatar {
  width: 44px; height: 44px; border-radius: 11px;
  background: var(--bg3); overflow: hidden; flex-shrink: 0;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-avatar-letter {
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.2rem; color: var(--accent);
}
.chat-card-info { flex: 1; min-width: 0; }
.chat-title { font-weight: 700; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-uname { font-size: .73rem; color: var(--text3); }
.chat-rank-badge {
  font-family: 'Unbounded', sans-serif; font-size: .68rem; font-weight: 900;
  padding: 3px 8px; background: rgba(217,119,6,.12);
  border: 1px solid rgba(217,119,6,.25); color: var(--gold); border-radius: 6px; flex-shrink: 0;
}

.chat-stats-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-stat {
  display: flex; align-items: center; gap: 4px;
  font-size: .76rem; color: var(--text2);
  background: var(--bg3); border-radius: 7px; padding: 3px 9px;
}
.chat-stat strong { color: var(--text1); font-weight: 700; }
.dot-online { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }

.chat-desc { font-size: .81rem; color: var(--text2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.chat-mini-analytics {
  background: var(--bg3); border-radius: 11px; padding: 12px;
}
.mini-chart-label { font-size: .69rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text3); margin-bottom: 8px; }
.hourly-chart { display: flex; align-items: flex-end; gap: 2px; height: 44px; }
.hourly-bar {
  flex: 1; min-width: 3px; border-radius: 2px 2px 0 0;
  background: var(--accent); opacity: .55;
  transition: opacity .15s;
}
.hourly-bar:hover { opacity: 1; }

.top-user { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: .78rem; border-top: 1px solid var(--border); }
.top-user:first-child { border-top: none; }
.top-pos { color: var(--text3); font-weight: 700; width: 16px; flex-shrink: 0; }
.top-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-name a { color: var(--text1); }
.top-name a:hover { color: var(--accent); }
.top-cnt { color: var(--text3); font-size: .73rem; font-weight: 700; }

.chat-open-btn {
  margin-top: auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  border-radius: 10px; padding: 9px 14px;
  font-size: .82rem; font-weight: 700;
  transition: opacity .18s;
}
.chat-open-btn:hover { opacity: .85; text-decoration: none; color: #fff; }

.loading { text-align: center; color: var(--text3); padding: 48px; font-size: .9rem; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer { background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(8px); border-top: 1px solid var(--border); padding: 40px 0 28px; }
.footer-inner { display: flex; gap: 48px; flex-wrap: wrap; }
.footer-brand { flex: 1; min-width: 180px; }
.footer-logo { font-size: .95rem; margin-bottom: 10px; display: block; }
.footer-brand p { font-size: .8rem; color: var(--text3); line-height: 1.6; max-width: 240px; }
.footer-col h4 { font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text3); margin-bottom: 12px; }
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.footer-col ul li a { font-size: .82rem; color: var(--text2); transition: color .18s; }
.footer-col ul li a:hover { color: var(--accent); text-decoration: none; }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 30px; font-size: .75rem; color: var(--text3); }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ============================================================
   CHAT PAGE  — /chats/{slug}/
   ============================================================ */
.chat-page-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; padding: 120px 0;
  color: var(--text3);
}
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Hero шапка страницы чата */
.cp-hero {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 40px 0 32px;
}
.cp-header {
  display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap;
  margin-bottom: 28px;
}
.cp-avatar {
  width: 72px; height: 72px; border-radius: 18px;
  background: var(--bg3); flex-shrink: 0; overflow: hidden;
}
.cp-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.cp-avatar-letter {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.8rem; color: var(--accent);
}
.cp-header-info { flex: 1; min-width: 0; }
.cp-title { font-family: 'Unbounded', sans-serif; font-weight: 900; font-size: 1.5rem; line-height: 1.15; margin-bottom: 4px; }
.cp-username { font-size: .82rem; color: var(--text3); margin-bottom: 8px; }
.cp-username a { color: var(--accent); }
.cp-desc { font-size: .87rem; color: var(--text2); line-height: 1.6; max-width: 520px; }
.cp-join { flex-shrink: 0; align-self: flex-start; }

/* Статы чата — горизонтальный ряд */
.cp-stats-row {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.cp-stat-card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 20px; text-align: center;
  flex: 1; min-width: 100px;
}
.cp-stat-val { font-family: 'Unbounded', sans-serif; font-weight: 900; font-size: 1.35rem; line-height: 1; }
.cp-stat-lbl { font-size: .68rem; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-top: 5px; }

/* Основная сетка страницы */
.cp-body { padding: 36px var(--gap); }
.cp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 720px) { .cp-grid { grid-template-columns: 1fr; } }

.cp-section {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 24px;
}
.cp-section-full { grid-column: 1 / -1; }
.cp-section-title {
  font-weight: 700; font-size: .93rem;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 18px; color: var(--text1);
}
.cp-section-title svg { color: var(--accent); }

/* График */
.cp-chart-wrap { border-radius: 10px; overflow: hidden; background: var(--bg3); }
.cp-chart-img { width: 100%; display: block; border-radius: 10px; }

/* Топ участников */
.cp-top-list { display: flex; flex-direction: column; gap: 6px; }
.cp-top-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--bg3); border-radius: 10px;
  font-size: .83rem;
}
.cp-top-pos { font-weight: 900; color: var(--text3); width: 22px; flex-shrink: 0; }
.cp-top-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-top-name a { color: var(--text1); font-weight: 600; }
.cp-top-name a:hover { color: var(--accent); text-decoration: none; }
.cp-top-msgs { font-size: .75rem; color: var(--text3); font-weight: 700; flex-shrink: 0; }

/* Администрация */
.staff-group { margin-bottom: 20px; }
.staff-group:last-child { margin-bottom: 0; }
.staff-rank-label {
  font-size: .8rem; color: var(--text2);
  padding: 6px 0 8px; border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.staff-rank-label strong { color: var(--text1); }
.staff-members { display: flex; flex-direction: column; gap: 2px; }
.staff-member {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 8px;
  font-size: .84rem;
  transition: background .15s;
}
.staff-member:hover { background: var(--bg3); }
.staff-status { font-size: 1rem; flex-shrink: 0; width: 22px; text-align: center; }
.staff-name { flex: 1; }
.staff-name a { color: var(--text1); font-weight: 600; }
.staff-name a:hover { color: var(--accent); text-decoration: none; }

.cp-empty { color: var(--text3); font-size: .85rem; padding: 12px 0; }

/* ============================================================
   MOBILE — п.7 (доп. задание): раньше почти не было медиа-запросов
   под телефоны (только grid-колонки), из-за чего паддинги/шрифты/
   навигация оставались десктопного размера и либо переполняли экран,
   либо выглядели непропорционально огромными на узких экранах.
   ============================================================ */
@media (max-width: 640px) {
  :root { --gap: 16px; }

  /* Навигация: на десктопе всё в одну строку, на телефоне лого — отдельной
     строкой сверху, ссылки + вход/CTA — компактной строкой под ним (не прячем
     ссылки совсем, чтобы не терять переходы на /payments и т.д.). */
  .nav-inner { height: auto; padding: 10px 0; flex-wrap: wrap; gap: 8px 0; }
  .logo { font-size: .92rem; flex-basis: 100%; }
  .nav-links { gap: 0; flex-wrap: wrap; }
  .nav-links a { font-size: .76rem; padding: 5px 8px; }
  .nav-cta { margin-left: auto; padding: 7px 12px; font-size: .78rem; }

  .hero { padding: 48px 0 40px; }
  .hero p { font-size: .92rem; padding: 0 4px; }
  .hero-buttons { width: 100%; }
  .hero-buttons .btn-primary, .hero-buttons .btn-ghost { width: 100%; justify-content: center; }

  .stats-bar-inner { gap: 0; }
  .stat-item { padding: 10px 14px; }
  .stat-item .val { font-size: 1.5rem; }

  .section { padding: 36px 0; }
  .section-sub { max-width: 100%; }

  .feature-card, .econ-card, .pricing-card { padding: 16px; }

  /* Каталог: карточки чатов на всю ширину вместо auto-fill(310px), которое
     на экранах <350px давало горизонтальный скролл/обрезание карточки. */
  .chats-grid { grid-template-columns: 1fr; gap: 14px; }
  .chat-card { padding: 16px; }
  .sort-bar { gap: 6px; }
  .sort-btn { padding: 6px 14px; font-size: .78rem; }

  /* Страница чата: аватар и текст в колонку, кнопка "вступить" на всю ширину */
  .cp-hero { padding: 24px 0 24px; }
  .cp-header { flex-direction: column; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
  .cp-avatar { width: 60px; height: 60px; border-radius: 15px; }
  .cp-title { font-size: 1.2rem; }
  .cp-join { align-self: stretch; }
  .cp-join .btn-primary { width: 100%; justify-content: center; }

  .cp-stats-row { gap: 8px; }
  .cp-stat-card { min-width: 0; padding: 10px 8px; flex-basis: calc(50% - 4px); }
  .cp-stat-val { font-size: 1.1rem; }

  .cp-body { padding: 24px var(--gap); }
  .cp-section { padding: 16px; border-radius: 16px; }

  .tg-account-menu { right: -8px; min-width: 150px; }

  .footer-inner { gap: 28px; }
  .footer-brand p { max-width: 100%; }
}

@media (max-width: 400px) {
  .hero h1 { letter-spacing: -1px; }
  .cp-stat-card { flex-basis: 100%; }
  .chat-stats-row { gap: 6px; }
}

/* ============================================================
   ICON-SVG — одноцветные иконки из assets/ подключаются через
   mask, чтобы наследовать currentColor (как раньше со встроенным
   <svg fill="currentColor">), а не тащить фиксированный белый цвет
   из файла.
   ============================================================ */
.icon-svg {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  flex-shrink: 0;
}
.icon-arrow-left  { -webkit-mask-image: url("/assets/arrow-left.svg");  mask-image: url("/assets/arrow-left.svg"); }
.icon-clock       { -webkit-mask-image: url("/assets/clock.svg");       mask-image: url("/assets/clock.svg"); }
.icon-import-arrow2 { -webkit-mask-image: url("/assets/import-arrow2.svg"); mask-image: url("/assets/import-arrow2.svg"); }
.icon-arrow-down4 { -webkit-mask-image: url("/assets/arrow-down4.svg"); mask-image: url("/assets/arrow-down4.svg"); }

/* ============================================================
   SCROLL-TO-BOTTOM / SCROLL-TO-TOP — плавающая кнопка внизу справа
   ============================================================ */
.scroll-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(79,110,247,.35);
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity .25s ease, transform .25s ease, visibility .25s, background .18s;
}
.scroll-fab.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.scroll-fab:hover { background: var(--accent2); }
.scroll-fab .icon-svg {
  width: 20px;
  height: 20px;
  transition: transform .4s cubic-bezier(.4,0,.2,1);
  transform: rotate(0deg);
}
.scroll-fab.at-bottom .icon-svg {
  transform: rotate(180deg);
}

@media (max-width: 640px) {
  .scroll-fab { right: 14px; bottom: 14px; width: 44px; height: 44px; }
}