/* ===========================
   CSS Design System & Reset
   =========================== */
:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #EFF6FF;
  --primary-hover: #3B82F6;
  --success: #10B981;
  --danger: #EF4444;
  --danger-dark: #DC2626;
  --warning: #F59E0B;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface2: #F1F5F9;
  --surface3: #E2E8F0;
  --border: #E2E8F0;
  --border-dark: #CBD5E1;
  --text: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --msg-own: #2563EB;
  --msg-other: #F1F5F9;
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07);
  --shadow: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

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

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; }
ul { list-style: none; }
.hidden { display: none !important; }

/* ===========================
   Utility Classes
   =========================== */
.w-full { width: 100%; }
.mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.text-center { text-align: center; }

/* ===========================
   Buttons
   =========================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
  border: none;
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.btn-primary:active { transform: scale(0.97); }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
}
.btn-outline:hover { background: var(--primary-light); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--danger);
  color: white;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--transition);
  cursor: pointer;
  border: none;
}
.btn-danger:hover { background: var(--danger-dark); }

.btn-danger-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: transparent;
  color: var(--danger);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  border: 1.5px solid var(--danger);
  width: 100%;
}
.btn-danger-outline:hover { background: #FEF2F2; }
.btn-danger { width: 100%; }

.btn-small {
  padding: 6px 14px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition);
  cursor: pointer;
  border: none;
  white-space: nowrap;
}
.btn-small:hover { background: var(--primary-dark); }

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
  transition: background var(--transition), color var(--transition);
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }


/* ===========================
   Landing Page
   =========================== */
.landing-body { background: var(--bg); }

/* Nav */
.landing-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  color: var(--primary);
}
.nav-logo { font-size: 24px; }
.nav-links {
  display: flex;
  gap: 28px;
  flex: 1;
}
.nav-links a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: color var(--transition);
}
.nav-links a:hover { color: var(--primary); }
.btn-nav-secondary {
  padding: 8px 18px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-nav-secondary:hover { background: #DBEAFE; }

/* Hero */
.hero {
  background: linear-gradient(135deg, #F0F7FF 0%, #EFF6FF 50%, #F5F3FF 100%);
  padding: 80px 0 100px;
  overflow: hidden;
}
.hero-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.hero-title {
  font-size: 52px;
  font-weight: 900;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 20px;
}
.hero-title-accent { color: var(--primary); }
.hero-description {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 480px;
  margin-bottom: 32px;
}
.hero-buttons { display: flex; gap: 14px; margin-bottom: 40px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 32px; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-size: 22px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-secondary); }

/* PC Mockup */
.hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
}
.hero-pc-mockup { perspective: 800px; }
.pc-case {
  width: 260px;
  height: 340px;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 0 0 2px rgba(255,255,255,0.05);
  transform: rotateY(-10deg) rotateX(5deg);
  transition: transform 0.3s ease;
}
.pc-case:hover { transform: rotateY(-5deg) rotateX(2deg); }
.pc-window {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.pc-rgb {
  position: absolute;
  border-radius: 50%;
  filter: blur(20px);
  opacity: 0.5;
  animation: rgbPulse 3s ease-in-out infinite;
}
.rgb-1 { width: 60px; height: 60px; background: #2563EB; top: -10px; left: 20px; animation-delay: 0s; }
.rgb-2 { width: 50px; height: 50px; background: #7C3AED; bottom: 30px; right: -10px; animation-delay: 1s; }
.rgb-3 { width: 40px; height: 40px; background: #059669; bottom: -5px; left: 50px; animation-delay: 2s; }

@keyframes rgbPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.pc-component {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  letter-spacing: 1px;
  position: relative;
  z-index: 1;
}
.cpu { border-left: 3px solid #2563EB; }
.ram { border-left: 3px solid #7C3AED; }
.gpu { border-left: 3px solid #059669; height: 40px; }

/* Categories */
.categories { padding: 64px 0; }
.section-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}
.section-header {
  text-align: center;
  margin-bottom: 40px;
}
.section-tag {
  display: inline-block;
  padding: 4px 14px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.section-header h2 {
  font-size: 34px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.section-header p { color: var(--text-secondary); font-size: 16px; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.category-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid var(--border);
}
.category-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.cat-cpu { background: linear-gradient(135deg, #EFF6FF, #DBEAFE); }
.cat-gpu { background: linear-gradient(135deg, #F5F3FF, #EDE9FE); }
.cat-ram { background: linear-gradient(135deg, #F0FDF4, #DCFCE7); }
.cat-cool { background: linear-gradient(135deg, #F0F9FF, #E0F2FE); }
.cat-icon { font-size: 28px; }
.cat-info h3 { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.cat-info p { font-size: 12px; color: var(--text-secondary); }

/* Articles */
.articles { padding: 64px 0; background: var(--surface); }
.article-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
.article-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.article-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.article-card.featured { grid-column: span 3; display: grid; grid-template-columns: 1.2fr 1fr; }

.article-image {
  height: 200px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.article-card.featured .article-image { height: auto; min-height: 280px; }

.img-cpu { background: linear-gradient(135deg, #1e3a8a, #2563EB, #60A5FA); }
.img-ram { background: linear-gradient(135deg, #5B21B6, #7C3AED, #A78BFA); }
.img-gpu { background: linear-gradient(135deg, #064E3B, #059669, #34D399); }
.img-cable { background: linear-gradient(135deg, #7C2D12, #EA580C, #FB923C); }
.img-cool { background: linear-gradient(135deg, #0C4A6E, #0284C7, #38BDF8); }
.img-mobo { background: linear-gradient(135deg, #1F2937, #374151, #6B7280); }

.img-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
}
.article-category-badge {
  padding: 4px 10px;
  background: rgba(255,255,255,0.25);
  backdrop-filter: blur(8px);
  color: white;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.3);
}
.img-icon {
  font-size: 56px;
  opacity: 0.85;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.article-content { padding: 24px; display: flex; flex-direction: column; justify-content: space-between; }
.article-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }
.meta-dot { color: var(--border-dark); }
.article-title { font-size: 18px; font-weight: 700; line-height: 1.4; color: var(--text); margin-bottom: 12px; }
.article-card.featured .article-title { font-size: 24px; }
.article-excerpt { font-size: 14px; color: var(--text-secondary); line-height: 1.7; flex: 1; margin-bottom: 20px; }

.article-footer { display: flex; align-items: center; justify-content: space-between; }
.author { display: flex; align-items: center; gap: 10px; }
.author-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.av-1 { background: #2563EB; }
.av-2 { background: #7C3AED; }
.av-3 { background: #059669; }
.av-4 { background: #EA580C; }
.author-name { font-size: 13px; font-weight: 600; color: var(--text); display: block; }
.author-role { font-size: 11px; color: var(--text-secondary); }
.read-more { font-size: 13px; font-weight: 600; color: var(--primary); transition: gap var(--transition); }
.read-more:hover { text-decoration: underline; }

.load-more-wrapper { text-align: center; margin-top: 40px; }
.btn-load-more {
  padding: 12px 32px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-load-more:hover { border-color: var(--primary); color: var(--primary); }

/* Newsletter */
.newsletter { padding: 64px 0; }
.newsletter-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-lg);
  padding: 56px;
  position: relative;
  overflow: hidden;
  color: white;
}
.newsletter-content { position: relative; z-index: 1; max-width: 520px; }
.newsletter-card h2 { font-size: 32px; font-weight: 800; margin-bottom: 12px; }
.newsletter-card p { font-size: 16px; opacity: 0.85; margin-bottom: 28px; }
.newsletter-form { display: flex; gap: 12px; }
.newsletter-input {
  flex: 1;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: none;
  font-size: 15px;
  background: rgba(255,255,255,0.15);
  color: white;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.2);
  outline: none;
}
.newsletter-input::placeholder { color: rgba(255,255,255,0.6); }
.newsletter-input:focus { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.5); }
.newsletter-disclaimer { font-size: 12px; opacity: 0.6; margin-top: 12px; }

.newsletter-decoration { position: absolute; right: 40px; top: 50%; transform: translateY(-50%); }
.deco-circle {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
}
.c1 { width: 180px; height: 180px; top: -90px; right: -90px; }
.c2 { width: 280px; height: 280px; top: -140px; right: -140px; }
.c3 { width: 380px; height: 380px; top: -190px; right: -190px; }

/* Footer */
.landing-footer {
  background: var(--text);
  color: rgba(255,255,255,0.8);
  padding: 64px 0 32px;
}
.footer-container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.footer-main { display: grid; grid-template-columns: 280px 1fr; gap: 60px; margin-bottom: 48px; }
.footer-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  color: white;
  margin-bottom: 16px;
}
.footer-tagline { font-size: 14px; line-height: 1.7; margin-bottom: 24px; }
.footer-social { display: flex; gap: 12px; }
.social-link {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: background var(--transition);
}
.social-link:hover { background: rgba(255,255,255,0.15); }
.footer-links-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.footer-col h4 { color: white; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }
.footer-col li { margin-bottom: 10px; }
.footer-col a { font-size: 14px; opacity: 0.7; transition: opacity var(--transition); }
.footer-col a:hover { opacity: 1; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  opacity: 0.5;
  flex-wrap: wrap;
  gap: 8px;
}

/* Login Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.ctc-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: slideUp 0.25s ease;
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text-secondary);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--surface3); color: var(--text); }

.ctc-card-header { text-align: center; margin-bottom: 28px; }
.ctc-icon { font-size: 40px; margin-bottom: 12px; }
.ctc-card-header h2 { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.ctc-card-header p { font-size: 14px; color: var(--text-secondary); }

.ctc-form { display: flex; flex-direction: column; gap: 16px; }
.code-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.code-input {
  width: 100%;
  padding: 14px 48px 14px 18px;
  font-size: 15px;
  letter-spacing: 8px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition);
  background: var(--surface2);
}
.code-input:focus { border-color: var(--primary); background: white; }
/* Mask input text like a password field without triggering browser save-password */
/* -webkit-text-security works on Chrome/Safari/Edge; Firefox shows plain text (still safe — no save-password popup) */
.code-input-masked { -webkit-text-security: disc; }

.toggle-visibility {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
  padding: 4px;
}

.ctc-alert {
  padding: 10px 14px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}
.btn-ctc {
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-ctc:hover { background: var(--primary-dark); }

.btn-loader {
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

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


/* ===========================
   Chat App Layout
   =========================== */
.chat-body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.chat-app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 300px 1fr auto;
  grid-template-rows: 1fr;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: white;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  transition: transform 0.3s ease;
  z-index: 50;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-info { min-width: 0; flex: 1; }
.user-name { font-size: 14px; font-weight: 700; color: var(--text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-status { font-size: 11px; color: var(--success); }
.sidebar-actions { display: flex; gap: 4px; }

/* Search */
.sidebar-search { padding: 12px 12px 8px; flex-shrink: 0; position: relative; }
.search-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 8px 12px;
  border: 1px solid var(--border);
  transition: border-color var(--transition);
}
.search-container:focus-within { border-color: var(--primary); background: white; }
.search-icon { font-size: 14px; color: var(--text-secondary); flex-shrink: 0; }
.search-input { border: none; background: none; font-size: 13px; color: var(--text); flex: 1; outline: none; min-width: 0; }
.search-input::placeholder { color: var(--text-muted); }

.search-results {
  position: absolute;
  top: calc(100% - 8px);
  left: 12px;
  right: 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  overflow: hidden;
  max-height: 240px;
  overflow-y: auto;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--surface2); }
.search-result-name { font-size: 13px; font-weight: 600; color: var(--text); }
.search-result-code { font-size: 11px; color: var(--text-secondary); font-family: monospace; }
.search-no-result { padding: 16px; text-align: center; font-size: 13px; color: var(--text-secondary); }

/* Conversations */
.sidebar-conversations { flex: 1; overflow-y: auto; padding: 0 0 16px; }
.sidebar-conversations::-webkit-scrollbar { width: 4px; }
.sidebar-conversations::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.conv-section { margin-top: 16px; }
.conv-section-header {
  padding: 0 16px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.conv-list {}
.conv-empty { padding: 12px 16px; font-size: 13px; color: var(--text-muted); font-style: italic; }
.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-radius: 0;
  position: relative;
}
.conv-item:hover { background: var(--surface2); }
.conv-item.active { background: var(--primary-light); }
.conv-item.active .conv-name { color: var(--primary); }
.conv-item[draggable="true"] { cursor: grab; }
.conv-item.dragging { opacity: 0.4; cursor: grabbing; }
.conv-item.drag-over-group { border-top: 2px solid var(--primary); }
.conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #64748B, #475569);
  color: white;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.conv-avatar.group-av { background: linear-gradient(135deg, #7C3AED, #5B21B6); }
.conv-details { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.conv-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.conv-bottom { display: flex; justify-content: space-between; align-items: center; }
.conv-preview { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-unread {
  min-width: 18px;
  height: 18px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

/* Main Chat */
.chat-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  text-align: center;
}
.empty-icon { font-size: 56px; opacity: 0.4; }
.chat-empty h2 { font-size: 22px; font-weight: 800; color: var(--text); }
.chat-empty p { font-size: 15px; color: var(--text-secondary); max-width: 360px; }
.empty-hint { margin-top: 8px; display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-muted); }
.empty-hint kbd {
  padding: 3px 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
}

.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Chat Header */
.chat-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.mobile-back { display: none; }
.chat-header-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), #60A5FA);
  color: white;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-header-name { font-size: 16px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-sub { font-size: 12px; color: var(--text-secondary); }
.chat-header-actions { display: flex; gap: 4px; }

/* Messages */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
}
.messages-area::-webkit-scrollbar { width: 4px; }
.messages-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.messages-loader {
  display: flex;
  justify-content: center;
  padding: 20px;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.messages-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  justify-content: flex-end;
}

/* Message bubble */
.message-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 68%;
  animation: msgIn 0.2s ease;
  margin-bottom: 2px;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message-wrapper.own { align-self: flex-end; align-items: flex-end; }
.message-wrapper.other { align-self: flex-start; align-items: flex-start; }

.message-sender-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 3px;
  padding: 0 4px;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  position: relative;
  word-break: break-word;
  max-width: 100%;
}
.message-wrapper.own .message-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}
.message-wrapper.other .message-bubble {
  background: var(--msg-other);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.message-text { font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.message-text a { text-decoration: underline; }
.message-wrapper.own .message-text a { color: #93C5FD; }

.message-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  justify-content: flex-end;
}
.message-wrapper.other .message-meta { color: var(--text-muted); }
.message-time {}
.message-read { font-size: 13px; }

/* Auto-delete timer */
.message-delete-timer {
  font-size: 10px;
  opacity: 0.65;
  margin-top: 2px;
  text-align: right;
  letter-spacing: 0.01em;
}
.message-wrapper.other .message-delete-timer {
  text-align: left;
}

/* Message with image */
.message-media img {
  max-width: 240px;
  max-height: 200px;
  border-radius: 10px;
  cursor: pointer;
  display: block;
  object-fit: cover;
}
.message-media video {
  max-width: 240px;
  max-height: 200px;
  border-radius: 10px;
  display: block;
}

/* File download link in message */
.file-download-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.06);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  max-width: 240px;
}
.file-download-link:hover { background: rgba(0,0,0,0.12); }
.file-icon { font-size: 20px; flex-shrink: 0; }
.file-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

/* Drag-and-drop highlight */
.chat-view.drag-over::after {
  content: 'Drop file to attach';
  position: absolute;
  inset: 0;
  background: rgba(37, 99, 235, 0.08);
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  pointer-events: none;
  z-index: 50;
}
.chat-view { position: relative; }

/* Message actions */
.message-actions {
  position: absolute;
  top: -28px;
  right: 0;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.message-wrapper:hover .message-actions { opacity: 1; pointer-events: all; }
.message-wrapper.other .message-actions { right: auto; left: 0; }
.msg-action-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.msg-action-btn:hover { background: var(--surface2); }
.msg-action-btn.msg-delete-red { color: var(--danger); }
.msg-action-btn.msg-delete-red:hover { background: #FEE2E2; color: var(--danger); }

/* Reaction inline buttons inside actions bar */
.msg-action-btn.react-inline {
  font-size: 16px;
}

/* Reactions row below bubble */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.reaction-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  line-height: 1.4;
}
.reaction-chip:hover { background: var(--surface3); }
.reaction-chip-mine {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.reaction-chip-mine:hover { background: #DBEAFE; }
/* Country flag (admin-only) */
.country-flag {
  font-style: normal;
  font-size: 2em;
  line-height: 1;
  vertical-align: middle;
  margin-left: 2px;
}

/* Tutorial modal */
.tutorial-modal { max-width: 440px; width: 90%; }
.tutorial-body { display: flex; flex-direction: column; gap: 20px; }
.tutorial-section {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  background: var(--surface2);
  border-radius: var(--radius);
}
.tutorial-icon { font-size: 26px; flex-shrink: 0; }
.tutorial-text { font-size: 14px; color: var(--text); line-height: 1.6; }
.tutorial-text strong { display: block; margin-bottom: 4px; font-size: 15px; }
.tutorial-text p { margin: 0 0 6px 0; }
.tutorial-list { margin: 4px 0 0 0; padding-left: 18px; }
.tutorial-list li { margin-bottom: 4px; }
kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}
.tutorial-footer { padding: 16px 20px; display: flex; justify-content: flex-end; border-top: 1px solid var(--border); }

.reaction-viewer-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.reaction-viewer-row:last-child { border-bottom: none; }
.reaction-viewer-emoji { font-size: 20px; min-width: 48px; }
.reaction-viewer-names { font-size: 14px; color: var(--text); line-height: 1.5; }

/* TG message delete button */
.tg-msg-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--text-muted);
}
.tg-msg-delete:hover { background: var(--surface3); color: var(--danger, #ef4444); }
.message-wrapper:hover .tg-msg-delete { opacity: 1; }

/* Big emoji messages — larger font only, background + time always visible */
.message-text.big-emoji {
  font-size: 4.8em;
  line-height: 1.1;
}

/* Emoji picker (input area) */
.emoji-trigger-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}
.emoji-trigger-btn:hover { background: var(--surface2); }

.emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 320px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
.emoji-item {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform 0.1s;
}
.emoji-item:hover { background: var(--surface2); transform: scale(1.2); }

@media (max-width: 480px) {
  .emoji-picker { width: 260px; max-height: 200px; }
}

/* Reply bar — shown above input when replying */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  flex-shrink: 0;
}
.reply-bar-indicator { display: none; }
.reply-bar-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.reply-bar-sender { font-size: 12px; font-weight: 700; color: var(--primary); }
.reply-bar-preview { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar-cancel {
  width: 24px; height: 24px; border: none; background: none; cursor: pointer;
  color: var(--text-secondary); font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; flex-shrink: 0; transition: background var(--transition);
}
.reply-bar-cancel:hover { background: var(--border); }

/* Reply preview inside message bubble */
.reply-preview {
  background: rgba(0,0,0,0.12);
  border-left: 3px solid rgba(255,255,255,0.55);
  border-radius: 4px;
  padding: 5px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  overflow: hidden;
  transition: filter var(--transition);
}
.reply-preview:hover { filter: brightness(1.12); }
.message-wrapper.other .reply-preview {
  background: rgba(0,0,0,0.05);
  border-left-color: var(--primary);
}
.reply-preview-sender {
  font-size: 11px; font-weight: 700;
  color: rgba(255,255,255,0.9);
  display: block; margin-bottom: 2px;
}
.message-wrapper.other .reply-preview-sender { color: var(--primary); }
.reply-preview-text {
  font-size: 12px; color: rgba(255,255,255,0.72);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.message-wrapper.other .reply-preview-text { color: var(--text-secondary); }

/* Highlight animation when scrolling to replied message */
@keyframes replyHighlight {
  0%,100% { box-shadow: none; }
  20%,60% { box-shadow: 0 0 0 3px var(--primary); }
}
.message-bubble.reply-highlight { animation: replyHighlight 1.8s ease; border-radius: var(--radius-lg); }

/* Date separator */
.date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 8px;
}
.date-separator::before,
.date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.date-separator span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 3px 10px;
  background: var(--bg);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 4px;
  font-size: 12px;
  color: var(--text-secondary);
}
.typing-dots { display: flex; gap: 4px; }
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* Chat Input */
.chat-input-area {
  background: white;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  flex-shrink: 0;
}
.input-container {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 12px;
  transition: border-color var(--transition);
}
.input-container:focus-within { border-color: var(--primary); background: white; }
.attach-btn {
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  color: var(--text-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: color var(--transition);
  margin-bottom: 2px;
}
.attach-btn:hover { color: var(--primary); }
/* Mention dropdown */
.mention-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  max-height: 200px;
  overflow-y: auto;
  z-index: 200;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.12s;
  font-size: 14px;
}
.mention-item:hover,
.mention-item.mention-active {
  background: var(--primary-light, #EFF6FF);
}
.mention-item:first-child { border-radius: 10px 10px 0 0; }
.mention-item:last-child  { border-radius: 0 0 10px 10px; }
.mention-item:only-child  { border-radius: 10px; }
.mention-avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.mention-name { font-weight: 500; color: var(--text); }

/* @mention tag in rendered messages */
.mention-tag {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-light, #EFF6FF);
  border-radius: 4px;
  padding: 0 3px;
}

.input-wrapper { flex: 1; min-width: 0; position: relative; }
.message-input {
  width: 100%;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text);
  outline: none;
  resize: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}
.message-input::placeholder { color: var(--text-muted); }
.char-count { position: absolute; bottom: -2px; right: 0; font-size: 10px; color: var(--text-muted); }
.send-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
  font-size: 16px;
}
.send-btn:hover:not(:disabled) { background: var(--primary-dark); }
.send-btn:active:not(:disabled) { transform: scale(0.93); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }

.media-preview {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 8px 12px;
  border: 1px solid var(--border);
}
.preview-content { flex: 1; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); }
.preview-content img { height: 48px; width: 48px; object-fit: cover; border-radius: 6px; }
.preview-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background var(--transition);
}
.preview-remove:hover { background: var(--surface3); color: var(--danger); }

/* Info Panel */
.info-panel {
  width: 260px;
  background: white;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
}
.info-panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.info-panel-header h3 { font-size: 15px; font-weight: 700; color: var(--text); }
.info-panel-content { flex: 1; overflow-y: auto; padding: 12px; }

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: default;
  transition: background var(--transition);
}
.member-item:hover { background: var(--surface2); }
.member-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), #60A5FA);
  color: white;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-share { font-size: 11px; color: var(--text-secondary); font-family: monospace; }
.member-dm-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: background var(--transition);
}
.member-dm-btn:hover { background: #DBEAFE; }

/* Modals */
.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}
.small-modal { max-width: 400px; }
.admin-modal { max-width: 680px; }
.notes-modal { max-width: 820px; height: 96vh; max-height: 96vh; }
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

/* Modal Tabs */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); background: white; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Admin lists */
.admin-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.admin-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.admin-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), #60A5FA);
  color: white;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.admin-item-info { flex: 1; min-width: 0; }
.admin-item-name { font-size: 14px; font-weight: 600; color: var(--text); }
.admin-item-sub { font-size: 12px; color: var(--text-secondary); }
.role-badge {
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.role-admin { background: #FEF3C7; color: #92400E; }
.role-user { background: var(--surface3); color: var(--text-secondary); }

.admin-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.btn-xs {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}
.btn-xs-primary { background: var(--primary-light); color: var(--primary); }
.btn-xs-primary:hover { background: #DBEAFE; }
.btn-xs-warning { background: #FEF3C7; color: #92400E; }
.btn-xs-warning:hover { background: #FDE68A; }
.btn-xs-danger { background: #FEE2E2; color: var(--danger); }
.btn-xs-danger:hover { background: #FECACA; }
.pending-admin-label {
  font-size: 11px;
  font-weight: 600;
  color: #92400E;
  background: #FEF3C7;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* Settings modal */
.settings-section { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.settings-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.settings-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
  min-width: 0;
  background: white;
}
.settings-input:focus { border-color: var(--primary); }
.settings-name-row { display: flex; gap: 8px; align-items: center; }
.settings-code-row { display: flex; align-items: center; gap: 8px; }
.settings-code, .settings-sharecode {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 20px;
  letter-spacing: 4px;
  color: var(--text);
  background: var(--surface2);
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  flex: 1;
}
.settings-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.copy-btn { font-size: 18px; }

/* Toggle switch */
.settings-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Form elements */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
  background: white;
}
.form-input:focus { border-color: var(--primary); }
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  background: white;
  cursor: pointer;
  transition: border-color var(--transition);
}
.form-select:focus { border-color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.tab-actions { margin-bottom: 12px; }

/* Group members list */
.group-members-list { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.group-member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.group-member-row .member-avatar { width: 32px; height: 32px; font-size: 11px; }
.group-member-name { flex: 1; font-size: 13px; font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auto-delete-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: white;
  cursor: pointer;
}
.remove-member-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--danger);
  font-size: 16px;
  padding: 2px 5px;
  border-radius: 4px;
  transition: background var(--transition);
}
.remove-member-btn:hover { background: #FEE2E2; }

/* Selected members */
.selected-members { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; min-height: 32px; }
.selected-member-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}
.selected-member-tag button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: 0.7;
}
.selected-member-tag button:hover { opacity: 1; }

/* Member search container */
.member-search-container { position: relative; }

/* Result box */
.result-box {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.result-box p { font-size: 14px; font-weight: 600; color: var(--success); margin-bottom: 12px; }
.result-field { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.result-field label { font-weight: 600; color: var(--text-secondary); min-width: 80px; }
.code-display { font-size: 18px; letter-spacing: 4px; color: var(--text); }
.result-warning { font-size: 12px; color: var(--warning); font-weight: 600; margin-top: 8px; }

/* Mobile hamburger */
.hamburger {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 48px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 20px;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  align-items: center;
  justify-content: flex-start;
  padding: 0 16px;
  gap: 10px;
  transition: background var(--transition);
}
.hamburger::after {
  content: ' ';
  font-size: 15px;
  font-weight: 600;
}
.hamburger:hover { background: var(--bg-hover); }

.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}

/* Notification sound visual feedback */
.sound-pulse {
  animation: soundPulse 0.3s ease;
}
@keyframes soundPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Image lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: background var(--transition);
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }

/* Toast notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  background: var(--text);
  color: white;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  max-width: 300px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: #3B82F6; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(10px); } }

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 1100px) {
  .chat-app { grid-template-columns: 260px 1fr; }
  .sidebar { width: 260px; }
}

@media (max-width: 768px) {
  /* Landing */
  .hero-container { grid-template-columns: 1fr; gap: 40px; }
  .hero-title { font-size: 36px; }
  .hero-visual { display: none; }
  .nav-links { display: none; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .article-grid { grid-template-columns: 1fr; }
  .article-card.featured { grid-column: 1; display: flex; flex-direction: column; }
  .article-card.featured .article-image { height: 200px; }
  .footer-main { grid-template-columns: 1fr; gap: 32px; }
  .footer-links-grid { grid-template-columns: repeat(2, 1fr); }
  .newsletter-form { flex-direction: column; }
  .newsletter-card { padding: 32px 24px; }
  .hero-stats { gap: 20px; }

  /* Chat */
  .chat-app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    z-index: 50;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .chat-main { grid-column: 1; }

  .hamburger { display: flex; }

  .chat-input-area {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  /* Prevent iOS auto-zoom on input focus (requires font-size >= 16px) */
  .message-input { font-size: 16px; }
  .note-entry-input,
  .note-title-edit,
  .notes-modal input,
  .notes-modal textarea { font-size: 16px !important; }

  .mobile-back { display: flex; }

  .info-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 110;
    transform: translateX(100%);
  }
  .info-panel.open { transform: translateX(0); }

  .message-wrapper { max-width: 85%; }
  .modal { max-width: calc(100vw - 32px); }
  .admin-modal { max-width: calc(100vw - 32px); }
}

/* ===========================
   Notes Modal
   =========================== */

.btn-icon-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}
.btn-icon-sm:hover { background: var(--border); }
.btn-icon-danger { color: var(--danger); }
.btn-icon-danger:hover { background: #FEF2F2; }

/* Notes screen layout — each screen fills the modal */
.notes-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Notes List */
.notes-list {
  overflow-y: auto;
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.note-card {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.note-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(37,99,235,0.08); }
.note-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-card-preview {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-card-date {
  font-size: 11px;
  color: var(--text-tertiary, #94A3B8);
  margin-top: 2px;
}

.notes-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--text-secondary);
  text-align: center;
  flex: 1;
}
.notes-empty-icon { font-size: 48px; }
.notes-empty p { font-size: 14px; margin: 0; }

/* Note view title (inline edit) */
.note-view-title-wrap {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.note-title-display {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 4px;
  border-radius: 4px;
}
.note-title-display:hover { background: var(--surface2); }
.note-title-edit {
  width: 100%;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  border: 1px solid var(--primary);
  border-radius: 4px;
  padding: 2px 6px;
  outline: none;
  background: white;
  box-sizing: border-box;
}

/* Chat-like entries area */
.note-entries-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  background: var(--surface2);
  transition: background var(--transition);
}
.note-entries-area.drag-over {
  background: var(--primary-light);
  outline: 2px dashed var(--primary);
  outline-offset: -4px;
}

.note-entry {
  display: flex;
  justify-content: flex-end;
  position: relative;
  padding-left: 68px; /* space for copy + delete btns */
}
.note-entry:hover .note-entry-delete,
.note-entry:hover .note-entry-copy { opacity: 1; pointer-events: auto; }

.note-entry-copy {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.note-entry-copy:hover { background: var(--surface2); }

.note-entry-delete {
  position: absolute;
  left: 34px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.note-entry-bubble {
  background: var(--primary);
  color: white;
  padding: 10px 14px;
  border-radius: 18px 18px 4px 18px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.note-entry-bubble a { color: #93C5FD; text-decoration: underline; word-break: break-all; }
.note-entry-bubble img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  display: block;
  object-fit: contain;
  cursor: pointer;
}
.note-entry-time {
  font-size: 10px;
  opacity: 0.72;
  text-align: right;
  margin-top: 2px;
}

/* Note input area */
.note-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.note-input-media-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}
.note-input-media-btn:hover { background: var(--border); }
.note-entry-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  resize: none;
  overflow-y: auto;
  max-height: 100px;
  font-family: inherit;
  background: var(--surface2);
  color: var(--text);
  line-height: 1.5;
  box-sizing: border-box;
}
.note-entry-input:focus { border-color: var(--primary); background: white; }
.note-entry-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}
.note-entry-send-btn:hover { background: var(--primary-dark); }
.note-entry-send-btn:disabled { background: var(--border); cursor: not-allowed; }

/* Notes modal close button — inline in flex header, not absolute */
.notes-modal .modal-header .modal-close {
  position: static;
  top: auto;
  right: auto;
}

/* Mobile-only settings section */
.settings-mobile-only { display: none; }
@media (max-width: 768px) {
  .settings-mobile-only { display: block; }
}
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-toggle-row + .settings-toggle-row { margin-top: 10px; }
.settings-label-inline { font-size: 14px; color: var(--text); }
.settings-hint { font-size: 12px; color: var(--text-secondary); margin: 2px 0 0; }

/* Notes modal responsive */
@media (max-width: 768px) {
  .notes-modal {
    max-width: 100vw;
    width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
  }
  .modal-overlay:has(.notes-modal) { align-items: flex-end; padding: 0; }
  .note-entry { padding-left: 0; }
  .note-entry-delete, .note-entry-copy { display: none; }
}

@media (max-width: 480px) {
  .hero-title { font-size: 30px; }
  .category-grid { grid-template-columns: 1fr; }
  .footer-links-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; text-align: center; }
}

/* ---- Telegram section ---- */
#tgSection .conv-section-header { display: flex; align-items: center; justify-content: space-between; }

.tg-add-form {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.tg-chatid-input {
  flex: 1;
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}
.tg-chatid-input:focus { outline: none; border-color: #229ED9; }
.icon-btn-sm {
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--text-secondary); padding: 2px 4px; border-radius: 4px;
  transition: background var(--transition);
}
.icon-btn-sm:hover { background: var(--surface2); }

.tg-badge {
  background: #229ED9;
  color: white;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 4px;
  display: none;
}

.tg-msg-from {
  font-size: 12px;
  font-weight: 700;
  color: #229ED9;
  margin-bottom: 2px;
}

.tg-reply-preview {
  border-left: 3px solid #229ED9;
  padding: 3px 8px;
  margin-bottom: 6px;
  background: rgba(34,158,217,0.08);
  border-radius: 0 6px 6px 0;
  font-size: 12px;
}
.tg-reply-preview .tg-reply-from { font-weight: 700; color: #229ED9; }
.tg-reply-preview .tg-reply-text { color: var(--text-secondary); }


.tg-media-placeholder {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-secondary, #f0f0f0);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
