/* ══════════════════════════════════════════
   BLABCHAT — Design System v2 (Fully Responsive)
   Mobile-first approach
   Theme: Dark luxury + glassmorphism
   Font: Syne (display) + DM Sans (body) + Space Mono (code/labels)
══════════════════════════════════════════ */

:root {
  --bg-void: #060608;
  --bg-deep: #0d0d10;
  --bg-panel: #111115;
  --bg-surface: #18181e;
  --bg-elevated: #1f1f27;
  --bg-hover: #252530;
  --bg-active: #2a2a38;

  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.12);

  --accent: #7c6af7;
  --accent-bright: #9d8fff;
  --accent-dim: rgba(124, 106, 247, 0.15);
  --accent-glow: rgba(124, 106, 247, 0.4);

  --gold: #f5c842;
  --emerald: #22d3a5;
  --rose: #f06292;

  --text-primary: #f0f0f5;
  --text-secondary: #9090a8;
  --text-muted: #52526a;
  --text-link: var(--accent-bright);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-glow: 0 0 40px rgba(124,106,247,0.2);
  --shadow-card: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-float: 0 24px 64px rgba(0,0,0,0.7);

  /* Layout widths — overridden at breakpoints */
  --sidebar-servers-w: 60px;
  --sidebar-channels-w: 200px;
  --sidebar-members-w: 220px;

  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'Space Mono', monospace;

  /* Touch-friendly min tap target */
  --tap-min: 44px;
}

/* ══ TABLET ══ */
@media (min-width: 600px) {
  :root {
    --sidebar-servers-w: 64px;
    --sidebar-channels-w: 210px;
    --sidebar-members-w: 230px;
  }
}

/* ══ DESKTOP ══ */
@media (min-width: 1024px) {
  :root {
    --sidebar-servers-w: 72px;
    --sidebar-channels-w: 220px;
    --sidebar-members-w: 240px;
  }
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  /* Prevent iOS zoom on input focus */
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  /* On mobile, overflow can be needed; pages handle their own overflow */
  overflow: hidden;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── PAGES ─── */
.page { display: none; height: 100svh; /* svh = safer on mobile */ }
.page.active { display: block; }

/* ══════════════════════════════════════
   DISCOVER PAGE
══════════════════════════════════════ */

/* Background orbs */
.bg-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.25;
  animation: orbFloat 12s ease-in-out infinite;
}
/* Smaller orbs on mobile */
.orb-1 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #7c6af7, transparent 70%);
  top: -100px; left: -80px;
  animation-delay: 0s;
}
.orb-2 {
  width: 260px; height: 260px;
  background: radial-gradient(circle, #22d3a5, transparent 70%);
  bottom: -80px; right: -60px;
  animation-delay: -4s;
}
.orb-3 {
  width: 200px; height: 200px;
  background: radial-gradient(circle, #f06292, transparent 70%);
  top: 40%; left: 50%;
  animation-delay: -8s;
}

@media (min-width: 768px) {
  .orb { opacity: 0.32; filter: blur(80px); }
  .orb-1 { width: 500px; height: 500px; top: -180px; left: -120px; }
  .orb-2 { width: 420px; height: 420px; bottom: -120px; right: -80px; }
  .orb-3 { width: 340px; height: 340px; }
}

@media (min-width: 1200px) {
  .orb { opacity: 0.35; }
  .orb-1 { width: 600px; height: 600px; top: -200px; left: -150px; }
  .orb-2 { width: 500px; height: 500px; bottom: -150px; right: -100px; }
  .orb-3 { width: 400px; height: 400px; }
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 30px) scale(0.97); }
}

/* ── Nav ── */
.top-nav {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: rgba(6,6,8,0.5);
}

@media (min-width: 600px) {
  .top-nav { padding: 16px 32px; }
}
@media (min-width: 1024px) {
  .top-nav { padding: 20px 48px; }
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.5px;
}

@media (min-width: 600px) {
  .logo { font-size: 20px; gap: 10px; }
}
@media (min-width: 1024px) {
  .logo { font-size: 22px; }
}

.logo-icon {
  font-size: 24px;
  background: linear-gradient(135deg, var(--accent), var(--emerald));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@media (min-width: 600px) { .logo-icon { font-size: 26px; } }
@media (min-width: 1024px) { .logo-icon { font-size: 28px; } }

.logo-text { color: var(--text-primary); }

.auth-buttons {
  display: flex;
  gap: 8px;
}

/* ── Buttons ── */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5c4ee8);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px var(--accent-glow);
  position: relative;
  overflow: hidden;
  /* touch-friendly */
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 30px var(--accent-glow); }
.btn-primary:hover::after { opacity: 1; }
.btn-primary:active { transform: translateY(0); }

@media (min-width: 600px) {
  .btn-primary { padding: 10px 20px; font-size: 14px; }
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.2);
}

@media (min-width: 600px) {
  .btn-ghost { padding: 10px 20px; font-size: 14px; }
}

.btn-large { padding: 13px 28px; font-size: 14px; border-radius: var(--radius-lg); }
.btn-full { width: 100%; text-align: center; padding: 13px; font-size: 15px; border-radius: var(--radius-md); }

@media (min-width: 600px) {
  .btn-large { padding: 14px 32px; font-size: 15px; }
  .btn-full { padding: 14px; }
}

/* ── Hero ── */
.hero {
  position: relative;
  z-index: 5;
  max-width: 560px;
  padding: 40px 20px 0;
  animation: heroEntrance 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (min-width: 600px) {
  .hero { padding: 60px 32px 0; }
}
@media (min-width: 1024px) {
  .hero { padding: 80px 48px 0; }
}

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

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-bright);
  background: var(--accent-dim);
  border: 1px solid rgba(124,106,247,0.3);
  padding: 4px 12px;
  border-radius: 100px;
  margin-bottom: 20px;
  animation: heroEntrance 0.8s 0.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (min-width: 600px) {
  .hero-badge { font-size: 11px; padding: 5px 14px; margin-bottom: 28px; }
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 12vw, 88px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -2px;
  color: var(--text-primary);
  margin-bottom: 18px;
  animation: heroEntrance 0.8s 0.15s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (min-width: 600px) {
  .hero-title { letter-spacing: -3px; margin-bottom: 24px; }
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent-bright) 0%, var(--emerald) 50%, var(--rose) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 28px;
  font-weight: 300;
  animation: heroEntrance 0.8s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (min-width: 600px) {
  .hero-sub { font-size: 16px; margin-bottom: 32px; }
}
@media (min-width: 1024px) {
  .hero-sub { font-size: 17px; margin-bottom: 36px; }
}

.hero-cta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 36px;
  animation: heroEntrance 0.8s 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (min-width: 600px) {
  .hero-cta { margin-bottom: 48px; gap: 12px; }
}

.hero-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  animation: heroEntrance 0.8s 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (min-width: 600px) {
  .hero-stats { gap: 20px; }
}

.stat { display: flex; flex-direction: column; }
.stat-num {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -1px;
}

@media (min-width: 600px) {
  .stat-num { font-size: 22px; }
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.stat-sep { color: var(--text-muted); font-size: 20px; }

/* ── Chat Preview ── */
/* Hidden on mobile, shown progressively */
.chat-preview {
  display: none;
}

@media (min-width: 768px) {
  .chat-preview {
    display: flex;
    position: fixed;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    background: rgba(17,17,21,0.8);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    padding: 20px;
    backdrop-filter: blur(24px);
    box-shadow: var(--shadow-float);
    flex-direction: column;
    gap: 12px;
    animation: previewEntrance 0.9s 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    z-index: 5;
  }
}

@media (min-width: 1024px) {
  .chat-preview {
    right: 60px;
    width: 320px;
    padding: 22px;
  }
}

@media (min-width: 1280px) {
  .chat-preview {
    right: 80px;
    width: 340px;
    padding: 24px;
  }
}

@keyframes previewEntrance {
  from { opacity: 0; transform: translateY(-40%) translateX(30px); }
  to { opacity: 1; transform: translateY(-50%) translateX(0); }
}

.preview-msg {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.preview-msg.outgoing { flex-direction: row-reverse; }

.preview-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #5c4ee8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .preview-avatar { width: 36px; height: 36px; font-size: 14px; }
}

.preview-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  color: var(--text-primary);
  max-width: 200px;
  line-height: 1.5;
}

@media (min-width: 1024px) {
  .preview-bubble { padding: 10px 14px; font-size: 14px; max-width: 220px; }
}

.preview-msg.outgoing .preview-bubble {
  background: linear-gradient(135deg, var(--accent), #5c4ee8);
  border-color: transparent;
  border-radius: 16px 16px 4px 16px;
}
.preview-msg.incoming .preview-bubble {
  border-radius: 16px 16px 16px 4px;
}

/* ══════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════ */

.app-layout {
  display: flex;
  height: 100svh;
  background: var(--bg-void);
  position: relative;
  overflow: hidden;
}

/* ── Server sidebar ──
   Mobile: hidden by default (shown via overlay drawer)
   ≥ 600px: always visible */
.sidebar-servers {
  width: var(--sidebar-servers-w);
  background: var(--bg-deep);
  display: none; /* hidden on mobile */
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 6px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}

@media (min-width: 600px) {
  .sidebar-servers {
    display: flex;
    padding: 12px 0;
    gap: 8px;
  }
}

.server-home {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent), #5c4ee8);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  color: #fff;
  transition: border-radius 0.2s, transform 0.2s;
  box-shadow: 0 4px 16px var(--accent-glow);
  -webkit-tap-highlight-color: transparent;
}
.server-home:hover { border-radius: 12px; transform: scale(1.05); }

@media (min-width: 1024px) {
  .server-home { width: 48px; height: 48px; font-size: 22px; border-radius: 16px; }
  .server-home:hover { border-radius: 14px; }
}

.server-divider {
  width: 28px;
  height: 2px;
  background: var(--border-strong);
  border-radius: 1px;
  margin: 2px 0;
}

.server-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}
.server-list::-webkit-scrollbar { display: none; }

.server-icon {
  width: 44px;
  height: 44px;
  background: var(--bg-surface);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border);
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
}
.server-icon:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  border-radius: 12px;
}

@media (min-width: 1024px) {
  .server-icon { width: 48px; height: 48px; font-size: 20px; border-radius: 16px; }
  .server-icon:hover { border-radius: 14px; }
}

.server-add {
  width: 44px;
  height: 44px;
  background: transparent;
  border: 2px dashed var(--border-strong);
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  -webkit-tap-highlight-color: transparent;
}
.server-add:hover {
  border-color: var(--emerald);
  color: var(--emerald);
  border-radius: 12px;
  background: rgba(34,211,165,0.08);
}

@media (min-width: 1024px) {
  .server-add { width: 48px; height: 48px; border-radius: 16px; }
  .server-add:hover { border-radius: 14px; }
}

/* ── Channels sidebar ──
   Mobile: full-width overlay or hidden
   ≥ 600px: always visible narrow column */
.sidebar-channels {
  width: var(--sidebar-channels-w);
  background: var(--bg-panel);
  display: none;
  flex-direction: column;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 15;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* On mobile: channels panel shown as overlay when .open is added by JS */
@media (max-width: 599px) {
  .sidebar-channels {
    display: flex;
    position: absolute;
    top: 0; left: 0;
    width: min(280px, 85vw);
    height: 100%;
    transform: translateX(-100%);
    box-shadow: var(--shadow-float);
  }
  .sidebar-channels.open {
    transform: translateX(0);
  }
  /* Dimmed backdrop when channels open on mobile */
  .sidebar-channels.open + .main-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10;
    pointer-events: auto;
  }
}

@media (min-width: 600px) {
  .sidebar-channels { display: flex; }
}

.channels-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 1024px) {
  .channels-header { padding: 16px 16px 12px; }
}

.channels-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

@media (min-width: 1024px) {
  .channels-title { font-size: 15px; }
}

.channels-settings {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 6px;
  border-radius: 4px;
  transition: color 0.2s;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.channels-settings:hover { color: var(--text-primary); }

.channel-group {
  padding: 10px 6px;
  flex: 1;
  overflow-y: auto;
}

@media (min-width: 1024px) {
  .channel-group { padding: 12px 8px; }
}

.channel-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 4px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all 0.15s;
  margin-bottom: 1px;
  min-height: var(--tap-min);
  -webkit-tap-highlight-color: transparent;
}
.channel-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.channel-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

@media (min-width: 1024px) {
  .channel-item { font-size: 14px; padding: 7px 8px; min-height: auto; }
}

.channel-hash {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 300;
}

/* User bar */
.user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

@media (min-width: 1024px) {
  .user-bar { padding: 10px 12px; }
}

.user-bar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--emerald));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .user-bar-avatar { width: 34px; height: 34px; font-size: 14px; }
}

.user-bar-info {
  flex: 1;
  overflow: hidden;
  min-width: 0;
}
.user-bar-name {
  display: block;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 1024px) {
  .user-bar-name { font-size: 13px; }
}

.user-bar-status {
  display: block;
  font-size: 10px;
  color: var(--emerald);
  font-family: var(--font-mono);
}

.badge-verify {
  background: linear-gradient(135deg, var(--gold), #f97316);
  color: var(--bg-void);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 100px;
  font-family: var(--font-mono);
}

@media (min-width: 1024px) {
  .badge-verify { font-size: 11px; padding: 2px 7px; }
}

.btn-icon-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.btn-icon-logout:hover { color: var(--rose); background: rgba(240,98,146,0.1); }

/* ── Main area ── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  min-width: 0;
  position: relative;
}

/* ── Main header ── */
.main-header {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .main-header { padding: 0 14px; }
}
@media (min-width: 1024px) {
  .main-header { padding: 0 16px; }
}

.main-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

@media (min-width: 600px) {
  .main-header-left { gap: 8px; }
}

/* Hamburger / menu toggle — mobile only */
.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

@media (min-width: 600px) {
  .mobile-menu-btn { display: none; }
}

.header-hash {
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 300;
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .header-hash { font-size: 20px; }
}

.main-header-left h3 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 600px) {
  .main-header-left h3 { font-size: 15px; }
}

.header-desc {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 8px;
  border-left: 1px solid var(--border-strong);
  margin-left: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Hidden on mobile */
  display: none;
}

@media (min-width: 768px) {
  .header-desc { display: block; font-size: 13px; }
}

.main-header-right {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .main-header-right { gap: 4px; }
}

.header-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 15px;
  padding: 6px 7px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.header-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

@media (min-width: 1024px) {
  .header-btn { font-size: 16px; padding: 6px 8px; }
}

/* Fewer header buttons on mobile — hide non-essential ones */
.header-btn.hide-mobile {
  display: none;
}
@media (min-width: 600px) {
  .header-btn.hide-mobile { display: flex; }
}

/* Admin bar */
.admin-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: linear-gradient(90deg, rgba(124,106,247,0.1), rgba(34,211,165,0.05));
  border-bottom: 1px solid rgba(124,106,247,0.2);
  flex-shrink: 0;
  overflow-x: auto;
}

@media (min-width: 600px) {
  .admin-bar { padding: 8px 16px; gap: 8px; }
}

.admin-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-bright);
  letter-spacing: 0.05em;
  margin-right: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .admin-title { font-size: 12px; margin-right: 4px; }
}

.admin-btn {
  background: rgba(124,106,247,0.15);
  border: 1px solid rgba(124,106,247,0.3);
  color: var(--accent-bright);
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.admin-btn:hover { background: rgba(124,106,247,0.3); }

@media (min-width: 600px) {
  .admin-btn { font-size: 12px; padding: 4px 12px; }
}

/* ── Chat messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scroll-behavior: smooth;
  /* Prevent momentum scrolling from bouncing page on iOS */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

@media (min-width: 600px) {
  .chat-messages { padding: 16px 14px; }
}
@media (min-width: 1024px) {
  .chat-messages { padding: 20px 16px; }
}

.chat-messages::-webkit-scrollbar { width: 4px; }
@media (min-width: 768px) {
  .chat-messages::-webkit-scrollbar { width: 6px; }
}
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Message grouping */
.msg-line {
  display: flex;
  gap: 10px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
  position: relative;
}
.msg-line:hover { background: rgba(255,255,255,0.02); }

@media (min-width: 600px) {
  .msg-line { gap: 12px; }
}

.msg-line.first-in-group {
  margin-top: 10px;
  padding-top: 4px;
}

@media (min-width: 600px) {
  .msg-line.first-in-group { margin-top: 12px; }
}

.msg-avatar-col {
  width: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
}

@media (min-width: 600px) {
  .msg-avatar-col { width: 40px; }
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #5c4ee8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .msg-avatar { width: 40px; height: 40px; font-size: 16px; }
}

.msg-avatar.admin-avatar {
  background: linear-gradient(135deg, var(--gold), #f97316);
}

.msg-no-avatar {
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .msg-no-avatar { width: 40px; }
}

.msg-timestamp-small {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  padding-left: 4px;
}
.msg-line:hover .msg-timestamp-small { opacity: 1; }

/* On mobile, touch doesn't trigger hover — always show time on first-in-group */
@media (max-width: 599px) {
  .msg-line.first-in-group .msg-timestamp-small { opacity: 0.6; }
}

.msg-content-col {
  flex: 1;
  min-width: 0;
}

.msg-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}

@media (min-width: 600px) {
  .msg-header { gap: 8px; }
}

.msg-sender {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font-body);
}

@media (min-width: 600px) {
  .msg-sender { font-size: 14px; }
}

.msg-sender.is-admin { color: var(--gold); }
.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

@media (min-width: 600px) {
  .msg-time { font-size: 11px; }
}

.msg-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.55;
  word-break: break-word;
}

@media (min-width: 600px) {
  .msg-text { font-size: 15px; }
}

.msg-line.own-msg .msg-sender { color: var(--accent-bright); }

/* ── Chat input ── */
.chat-input-area {
  padding: 0 10px 14px;
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .chat-input-area { padding: 0 14px 18px; }
}
@media (min-width: 1024px) {
  .chat-input-area { padding: 0 16px 20px; }
}

.chat-input-box {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 4px 4px 4px 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

@media (min-width: 600px) {
  .chat-input-box { padding: 4px 4px 4px 8px; }
}

.input-attach {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px 6px 4px;
  transition: color 0.2s;
  line-height: 1;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.input-attach:hover { color: var(--text-primary); }

@media (min-width: 600px) {
  .input-attach { font-size: 20px; padding: 6px 10px 6px 4px; }
}

#msgInput {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-body);
  outline: none;
  padding: 10px 0;
  /* Prevent zoom on iOS for font-size < 16px */
  font-size: 16px;
}

@media (min-width: 600px) {
  #msgInput { font-size: 15px; }
}

#msgInput::placeholder { color: var(--text-muted); }

.input-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

@media (min-width: 600px) {
  .input-actions { gap: 4px; }
}

.input-emoji {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  opacity: 0.6;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  /* Hide on very small screens to save space */
  display: none;
}

@media (min-width: 400px) {
  .input-emoji { display: flex; }
}

.input-emoji:hover { background: var(--bg-hover); opacity: 1; }

.input-send {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent), #5c4ee8);
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 12px var(--accent-glow);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.input-send:hover { transform: scale(1.05); box-shadow: 0 4px 20px var(--accent-glow); }
.input-send:active { transform: scale(0.97); }

/* ── Members sidebar ──
   Hidden on mobile and small tablets, shown on ≥ 960px */
.sidebar-members {
  display: none;
  width: var(--sidebar-members-w);
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

@media (min-width: 960px) {
  .sidebar-members { display: flex; }
}

.sidebar-members::-webkit-scrollbar { width: 4px; }
.sidebar-members::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 2px; }

.members-section { padding: 14px 10px; flex: 1; }

@media (min-width: 1024px) {
  .members-section { padding: 16px 12px; }
}

.members-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 0 4px;
}

.members-list { display: flex; flex-direction: column; gap: 2px; }

.member-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.member-item:hover { background: var(--bg-hover); }

@media (min-width: 1024px) {
  .member-item { gap: 10px; }
}

.member-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #5c4ee8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

@media (min-width: 1024px) {
  .member-avatar { width: 32px; height: 32px; font-size: 13px; }
}

.member-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 8px;
  height: 8px;
  background: var(--emerald);
  border: 2px solid var(--bg-panel);
  border-radius: 50%;
}

@media (min-width: 1024px) {
  .member-avatar::after { width: 9px; height: 9px; }
}

.member-name {
  font-size: 13px;
  color: var(--text-secondary);
}

@media (min-width: 1024px) {
  .member-name { font-size: 14px; }
}

.add-friend-section {
  padding: 10px;
  border-top: 1px solid var(--border);
}

@media (min-width: 1024px) {
  .add-friend-section { padding: 12px; }
}

.add-friend-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.add-friend-input {
  display: flex;
  gap: 6px;
}

.add-friend-input input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  /* Prevent iOS zoom */
  font-size: 16px;
}
.add-friend-input input:focus { border-color: var(--accent); }
.add-friend-input input::placeholder { color: var(--text-muted); }

@media (min-width: 1024px) {
  .add-friend-input input { font-size: 13px; }
}

.add-friend-input button {
  width: 34px;
  height: 34px;
  background: var(--accent-dim);
  border: 1px solid rgba(124,106,247,0.3);
  border-radius: var(--radius-sm);
  color: var(--accent-bright);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.add-friend-input button:hover { background: var(--accent); color: #fff; }

/* ══════════════════════════════════════
   BOTTOM NAV — Mobile only (≤ 599px)
   Replaces the hidden sidebars
══════════════════════════════════════ */
.mobile-bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 56px;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px); /* notch support */
}

@media (min-width: 600px) {
  .mobile-bottom-nav { display: none; }
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
  flex: 1;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-item.active { color: var(--accent-bright); }
.mobile-nav-item:hover { color: var(--text-primary); }

.mobile-nav-item .nav-icon { font-size: 20px; }
.mobile-nav-item .nav-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ══════════════════════════════════════
   MOBILE OVERLAY BACKDROP
══════════════════════════════════════ */
.mobile-overlay-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 14;
  backdrop-filter: blur(2px);
}
.mobile-overlay-backdrop.visible { display: block; }

@media (min-width: 600px) {
  .mobile-overlay-backdrop { display: none !important; }
}

/* ══════════════════════════════════════
   MODAL
══════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
}
.modal {
  position: relative;
  z-index: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 28px 20px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-float);
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  /* Ensure modal isn't too tall on small screens */
  max-height: calc(100svh - 32px);
  overflow-y: auto;
}

@media (min-width: 600px) {
  .modal { padding: 36px 32px; gap: 16px; }
}
@media (min-width: 768px) {
  .modal { padding: 40px; }
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-logo {
  font-size: 30px;
  text-align: center;
  background: linear-gradient(135deg, var(--accent), var(--emerald));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: -4px;
}

@media (min-width: 600px) {
  .modal-logo { font-size: 36px; }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text-primary);
  text-align: center;
}

@media (min-width: 600px) {
  .modal-title { font-size: 26px; letter-spacing: -1px; }
}

.modal-sub {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: -8px;
}

@media (min-width: 600px) {
  .modal-sub { font-size: 14px; }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

@media (min-width: 600px) {
  .form-group label { font-size: 11px; }
}

.form-group input {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
  /* 16px to prevent iOS zoom */
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-group input::placeholder { color: var(--text-muted); }

@media (min-width: 600px) {
  .form-group input { font-size: 15px; }
}

.auth-error {
  background: rgba(240,98,146,0.1);
  border: 1px solid rgba(240,98,146,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--rose);
  text-align: center;
}

@media (min-width: 600px) {
  .auth-error { font-size: 13px; }
}

/* ══════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════ */

#toast-container {
  position: fixed;
  bottom: 80px; /* above bottom nav on mobile */
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100vw - 32px);
  max-width: 320px;
}

@media (min-width: 600px) {
  #toast-container {
    bottom: 24px;
    right: 24px;
    left: auto;
    transform: none;
    width: auto;
    max-width: 300px;
  }
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: all;
  text-align: center;
}

@media (min-width: 600px) {
  .toast { font-size: 14px; padding: 12px 18px; text-align: left; }
}

.toast.success { border-left: 3px solid var(--emerald); }
.toast.error { border-left: 3px solid var(--rose); }
.toast.info { border-left: 3px solid var(--accent-bright); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ══════════════════════════════════════
   SCROLLBAR — global
══════════════════════════════════════ */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-hover) transparent;
}

/* ══════════════════════════════════════
   SAFE AREA (iPhone notch / home bar)
══════════════════════════════════════ */

.app-layout {
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-top: env(safe-area-inset-top, 0px);
}

/* ══════════════════════════════════════
   DISCOVER PAGE: full-screen layout fix on mobile
══════════════════════════════════════ */

#page-discover {
  height: 100svh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Hero centering on very wide screens */
@media (min-width: 1400px) {
  .hero {
    padding-left: calc((100vw - 1100px) / 2);
    max-width: 700px;
  }
}
