/* ============================================
   習陵祭装飾パート - Futuristic Design System
   ============================================ */

:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --secondary: #ec4899;
  --accent: #06b6d4;
  --bg-dark: #060610;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --border: rgba(255,255,255,0.08);
  --border-bright: rgba(255,255,255,0.15);
  --glow-primary: 0 0 40px rgba(99,102,241,0.3);
  --glow-secondary: 0 0 40px rgba(236,72,153,0.3);
  --radius-sm: 8px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar-width: 280px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans JP', 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ===================== LOADING SCREEN ===================== */
#loading-screen {
  position: fixed; inset: 0;
  background: var(--bg-dark);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.8s ease;
}

.loading-content {
  display: flex; flex-direction: column; align-items: center; gap: 24px;
}

.loading-logo {
  position: relative; width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
}

.logo-ring {
  position: absolute; inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

.logo-ring.ring2 {
  inset: 8px;
  border-top-color: var(--secondary);
  animation-duration: 0.9s;
  animation-direction: reverse;
}

.logo-ring.ring3 {
  inset: 16px;
  border-top-color: var(--accent);
  animation-duration: 0.6s;
}

.logo-icon {
  font-size: 24px;
  animation: pulse 1.5s ease-in-out infinite;
}

.loading-text {
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: 4px;
  text-transform: uppercase;
  animation: fadeInOut 1.5s ease-in-out infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }
@keyframes fadeInOut { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }

/* ===================== PAGE SYSTEM ===================== */
.page { display: none; }
.page.active { display: block; }

/* ===================== HEADER ===================== */
.main-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(6,6,16,0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex; align-items: center; gap: 32px;
}

.header-logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px; white-space: nowrap;
}

.logo-spark {
  font-size: 20px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  animation: sparkle 3s ease-in-out infinite;
}

@keyframes sparkle {
  0%,100% { filter: brightness(1); }
  50% { filter: brightness(1.5) drop-shadow(0 0 8px rgba(99,102,241,0.8)); }
}

.header-nav {
  display: flex; gap: 4px; flex: 1;
}

.nav-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  padding: 6px 16px; border-radius: var(--radius-sm);
  transition: var(--transition);
  letter-spacing: 1px;
}

.nav-btn:hover, .nav-btn.active {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.nav-menu-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 18px;
  padding: 8px; border-radius: var(--radius-sm);
  transition: var(--transition); margin-left: auto;
}

.nav-menu-btn:hover { color: var(--text-primary); }

/* Mobile Nav */
.mobile-nav {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(6,6,16,0.97);
  backdrop-filter: blur(20px);
  display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  opacity: 0; transition: opacity 0.3s ease;
}

.mobile-nav.open { display: flex; opacity: 1; }

.mobile-nav-close {
  position: absolute; top: 24px; right: 24px;
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 24px;
}

.mobile-nav-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-primary); font-size: 18px; font-weight: 500;
  padding: 16px 48px; border-radius: var(--radius);
  cursor: pointer; transition: var(--transition); width: 240px;
}

.mobile-nav-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  box-shadow: var(--glow-primary);
}

/* ===================== HERO SECTION ===================== */
.hero-section {
  position: relative; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding-top: 64px;
}

.hero-bg {
  position: absolute; inset: 0; z-index: 0;
}

.particle-field {
  position: absolute; inset: 0;
}

.particle {
  position: absolute;
  width: 2px; height: 2px;
  background: var(--primary);
  border-radius: 50%;
  animation: particleFloat var(--duration, 8s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  opacity: 0;
}

@keyframes particleFloat {
  0% { transform: translateY(100vh) translateX(0); opacity: 0; }
  10% { opacity: 0.8; }
  90% { opacity: 0.3; }
  100% { transform: translateY(-20px) translateX(var(--drift, 20px)); opacity: 0; }
}

.hero-gradient {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 60% at 30% 40%, rgba(99,102,241,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 70% 60%, rgba(236,72,153,0.1) 0%, transparent 60%),
    radial-gradient(ellipse 80% 80% at 50% 100%, rgba(6,182,212,0.05) 0%, transparent 50%);
}

.hero-content {
  position: relative; z-index: 1;
  text-align: center; padding: 48px 24px;
  max-width: 800px;
}

.hero-badge {
  display: inline-flex; align-items: center;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.3);
  color: var(--primary-light);
  font-size: 12px; font-weight: 600;
  padding: 6px 16px; border-radius: 100px;
  letter-spacing: 2px; margin-bottom: 24px;
  animation: badgePulse 3s ease-in-out infinite;
}

@keyframes badgePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
  50% { box-shadow: 0 0 0 8px rgba(99,102,241,0.1); }
}

.hero-title {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 24px;
}

.title-line {
  font-size: clamp(48px, 8vw, 96px);
  font-weight: 900;
  background: linear-gradient(135deg, #fff 0%, var(--primary-light) 50%, var(--secondary) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  line-height: 1.1;
  animation: titleGlow 4s ease-in-out infinite;
}

@keyframes titleGlow {
  0%,100% { filter: brightness(1); }
  50% { filter: brightness(1.1); }
}

.title-sub {
  font-size: clamp(16px, 3vw, 24px);
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 8px;
  text-transform: uppercase;
}

.hero-desc {
  font-size: 18px; line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 40px;
  max-width: 600px; margin-left: auto; margin-right: auto;
}

.hero-actions {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
}

.btn-primary {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; border: none; cursor: pointer;
  padding: 16px 32px; border-radius: 100px;
  font-size: 15px; font-weight: 600;
  transition: var(--transition);
  box-shadow: 0 4px 24px rgba(99,102,241,0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 40px rgba(99,102,241,0.6);
}

.btn-outline {
  display: flex; align-items: center; gap: 8px;
  background: transparent;
  color: var(--text-primary); border: 1px solid var(--border-bright);
  cursor: pointer;
  padding: 16px 32px; border-radius: 100px;
  font-size: 15px; font-weight: 500;
  transition: var(--transition);
}

.btn-outline:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.scroll-indicator {
  position: absolute; bottom: 32px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 10px; letter-spacing: 3px;
  animation: scrollBounce 2s ease-in-out infinite;
}

.scroll-line {
  width: 1px; height: 48px;
  background: linear-gradient(to bottom, transparent, var(--primary), transparent);
}

@keyframes scrollBounce {
  0%,100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(8px); }
}

/* ===================== SECTIONS ===================== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

.section-header {
  text-align: center; margin-bottom: 64px;
  position: relative;
}

.section-tag {
  display: inline-block;
  color: var(--primary-light);
  font-size: 11px; font-weight: 700;
  letter-spacing: 4px; text-transform: uppercase;
  margin-bottom: 12px;
}

.section-title {
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
}

.section-desc {
  color: var(--text-secondary); font-size: 16px;
  max-width: 500px; margin: 0 auto;
}

/* ===================== ABOUT SECTION ===================== */
.about-section {
  padding: 120px 0;
  background: linear-gradient(180deg, transparent 0%, rgba(99,102,241,0.03) 50%, transparent 100%);
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.about-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  transition: var(--transition);
  position: relative; overflow: hidden;
  cursor: default;
}

.about-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(99,102,241,0.05), transparent);
  opacity: 0; transition: opacity 0.3s;
}

.about-card:hover {
  border-color: rgba(99,102,241,0.3);
  transform: translateY(-8px);
  box-shadow: 0 20px 60px rgba(99,102,241,0.15);
}

.about-card:hover::before { opacity: 1; }

.card-icon {
  font-size: 40px; margin-bottom: 20px;
  display: block;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.about-card h3 {
  font-size: 20px; font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.about-card p {
  color: var(--text-secondary); line-height: 1.7; font-size: 14px;
}

/* ===================== BOARD SECTION ===================== */
.board-section {
  padding: 120px 0;
}

.admin-login-btn {
  position: absolute; right: 0; top: 0;
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  color: var(--primary-light);
  font-size: 12px; cursor: pointer;
  padding: 8px 16px; border-radius: var(--radius-sm);
  transition: var(--transition); display: flex; align-items: center; gap: 6px;
}

.admin-login-btn:hover {
  background: rgba(99,102,241,0.2);
  border-color: rgba(99,102,241,0.4);
}

.board-posts {
  display: flex; flex-direction: column; gap: 16px;
}

.board-post {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  transition: var(--transition);
  position: relative; overflow: hidden;
  animation: slideUp 0.5s ease forwards;
  opacity: 0;
}

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

.board-post:hover {
  border-color: rgba(99,102,241,0.3);
  transform: translateX(4px);
}

.board-post.pinned {
  border-color: rgba(236,72,153,0.3);
  background: linear-gradient(135deg, rgba(236,72,153,0.05), var(--bg-card));
}

.board-post-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}

.post-pin-badge {
  background: rgba(236,72,153,0.15);
  border: 1px solid rgba(236,72,153,0.3);
  color: var(--secondary);
  font-size: 10px; font-weight: 700;
  padding: 3px 10px; border-radius: 100px; letter-spacing: 1px;
}

.board-post-title {
  font-size: 20px; font-weight: 700; margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.board-post-content {
  color: var(--text-secondary); line-height: 1.8;
  font-size: 15px; white-space: pre-wrap;
}

.board-post-image {
  width: 100%; max-height: 400px; object-fit: cover;
  border-radius: var(--radius-sm); margin-top: 16px;
  cursor: pointer; transition: var(--transition);
}

.board-post-image:hover { opacity: 0.9; }

.board-post-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

.board-post-date {
  color: var(--text-muted); font-size: 12px;
}

.board-post-actions {
  display: flex; gap: 8px;
}

.post-action-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  transition: var(--transition);
}

.post-action-btn:hover { color: var(--primary-light); background: var(--bg-card-hover); }

.loading-posts {
  display: flex; justify-content: center; padding: 40px;
}

.loading-spinner {
  width: 32px; height: 32px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.board-empty {
  text-align: center; padding: 80px;
  color: var(--text-muted);
}

.admin-floating-btn {
  position: fixed; bottom: 32px; right: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white; border: none; cursor: pointer;
  width: 56px; height: 56px; border-radius: 50%;
  font-size: 24px; display: none; align-items: center; justify-content: center;
  box-shadow: 0 8px 32px rgba(99,102,241,0.4);
  transition: var(--transition); z-index: 50;
}

.admin-floating-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 48px rgba(99,102,241,0.6);
}

/* ===================== GATE SECTION ===================== */
.gate-section {
  padding: 120px 0;
  background: linear-gradient(180deg, transparent, rgba(99,102,241,0.03), transparent);
}

.gate-container {
  max-width: 480px; margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px;
  position: relative; overflow: hidden;
}

.gate-container::before {
  content: '';
  position: absolute; top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(99,102,241,0.03), transparent);
  animation: rotate 10s linear infinite;
}

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

.gate-tabs {
  display: flex; gap: 4px; margin-bottom: 40px;
  background: rgba(255,255,255,0.04);
  padding: 4px; border-radius: var(--radius-sm);
  position: relative;
}

.gate-tab {
  flex: 1;
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  padding: 10px; border-radius: 6px;
  transition: var(--transition); position: relative; z-index: 1;
}

.gate-tab.active {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.gate-form { display: none; flex-direction: column; gap: 16px; }
.gate-form.active { display: flex; }

/* Form floating labels */
.form-floating {
  position: relative;
}

.form-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit; font-size: 15px;
  padding: 20px 16px 8px;
  transition: var(--transition); outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  background: rgba(99,102,241,0.05);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.form-floating label {
  position: absolute; left: 16px; top: 14px;
  color: var(--text-muted); font-size: 15px;
  transition: var(--transition); pointer-events: none;
}

.form-input:focus + label,
.form-input:not(:placeholder-shown) + label {
  top: 6px; font-size: 11px; color: var(--primary-light);
}

.form-textarea {
  min-height: 120px; resize: vertical; padding-top: 24px;
}

.gate-submit-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; border: none; cursor: pointer;
  padding: 16px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; font-family: inherit;
  transition: var(--transition);
  box-shadow: 0 4px 24px rgba(99,102,241,0.3);
}

.gate-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 40px rgba(99,102,241,0.5);
}

.terms-check {
  margin-top: 4px;
}

.checkbox-label {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; color: var(--text-secondary); font-size: 14px;
}

.checkbox-label input[type="checkbox"] { display: none; }

.checkmark {
  width: 18px; height: 18px; min-width: 18px;
  border: 2px solid var(--border-bright);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.checkbox-label input:checked + .checkmark {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox-label input:checked + .checkmark::after {
  content: '✓';
  color: white; font-size: 11px; font-weight: 700;
}

.checkbox-label a { color: var(--primary-light); text-decoration: none; }
.checkbox-label a:hover { text-decoration: underline; }

.form-error {
  color: #f87171; font-size: 13px; text-align: center;
  min-height: 20px; transition: var(--transition);
}

/* ===================== FOOTER ===================== */
.main-footer {
  border-top: 1px solid var(--border);
  padding: 48px 24px;
  text-align: center;
}

.footer-logo {
  font-size: 18px; font-weight: 700; margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.footer-copy { color: var(--text-muted); font-size: 13px; }

/* ===================== CHAT LAYOUT ===================== */
.chat-layout {
  display: flex; height: 100vh; overflow: hidden;
}

/* SIDEBAR */
.chat-sidebar {
  width: var(--sidebar-width);
  background: rgba(6,6,16,0.95);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}

.sidebar-user {
  display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;
}

.user-avatar {
  width: 40px; height: 40px; min-width: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  background: var(--primary);
  font-weight: 700; cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.user-avatar:hover { transform: scale(1.05); }

.user-avatar::after {
  content: '';
  position: absolute; bottom: 1px; right: 1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--bg-dark);
}

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

.user-name {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.user-status {
  font-size: 11px; color: var(--text-muted);
}

.user-status.online { color: #22c55e; }

.sidebar-actions {
  display: flex; gap: 4px;
}

.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 15px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: var(--transition);
}

.icon-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }

.sidebar-search {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border);
}

.sidebar-search i { color: var(--text-muted); font-size: 13px; }

.sidebar-search input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 14px;
}

.sidebar-search input::placeholder { color: var(--text-muted); }

.sidebar-section { overflow: hidden; flex-shrink: 0; }
.sidebar-section:last-child { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.sidebar-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px;
  color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase;
}

.icon-btn-sm {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 12px;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; transition: var(--transition);
}

.icon-btn-sm:hover { color: var(--text-primary); background: var(--bg-card-hover); }

.room-list, .dm-list {
  overflow-y: auto; flex: 1;
  padding: 0 8px 8px;
}

.room-item, .dm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition);
  margin-bottom: 2px;
}

.room-item:hover, .dm-item:hover,
.room-item.active, .dm-item.active {
  background: var(--bg-card-hover);
}

.room-item.active, .dm-item.active {
  background: rgba(99,102,241,0.15);
  border-left: 2px solid var(--primary);
}

.room-hash {
  color: var(--text-muted); font-size: 16px; font-weight: 700;
  width: 20px; text-align: center;
}

.room-name { font-size: 14px; color: var(--text-secondary); flex: 1; }
.room-item.active .room-name,
.room-item:hover .room-name { color: var(--text-primary); }

.dm-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; position: relative;
}

.dm-avatar.online::after {
  content: '';
  position: absolute; bottom: 0; right: 0;
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e;
  border: 1px solid var(--bg-dark);
}

.dm-info { flex: 1; min-width: 0; }
.dm-name { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-item.active .dm-name, .dm-item:hover .dm-name { color: var(--text-primary); }
.dm-preview { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* CHAT MAIN */
.chat-main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
}

.chat-header {
  height: 56px; padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  background: rgba(6,6,16,0.8);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.sidebar-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px;
  padding: 6px; border-radius: var(--radius-sm);
  transition: var(--transition);
}

.sidebar-toggle:hover { color: var(--text-primary); }

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

.chat-room-name {
  font-size: 15px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chat-room-members { font-size: 12px; color: var(--text-muted); }

.chat-header-actions { display: flex; gap: 4px; }

#encrypt-indicator {
  color: #22c55e;
}

/* TYPING INDICATOR */
.typing-indicator {
  display: none; align-items: center; gap: 8px;
  padding: 8px 20px;
  color: var(--text-muted); font-size: 12px;
}

.typing-indicator.visible { display: flex; }

.typing-dots {
  display: flex; gap: 3px;
}

.typing-dots span {
  width: 6px; height: 6px;
  background: var(--primary-light);
  border-radius: 50%;
  animation: typingDot 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 typingDot {
  0%,60%,100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* MESSAGES */
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 20px; display: flex; flex-direction: column;
  gap: 4px;
}

.chat-welcome {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; gap: 16px; color: var(--text-muted);
  text-align: center;
}

.welcome-icon { font-size: 64px; opacity: 0.3; }
.chat-welcome h3 { font-size: 20px; font-weight: 600; color: var(--text-secondary); }
.chat-welcome p { font-size: 14px; }

/* Message */
.message-group {
  display: flex; gap: 12px;
  padding: 4px 0;
  animation: messageIn 0.3s ease;
}

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

.message-group.own {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px; height: 36px; min-width: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; align-self: flex-end;
  cursor: pointer; transition: var(--transition);
}

.msg-avatar:hover { transform: scale(1.1); }

.msg-content { max-width: 70%; display: flex; flex-direction: column; gap: 2px; }
.message-group.own .msg-content { align-items: flex-end; }

.msg-header {
  display: flex; align-items: center; gap: 8px;
  padding: 0 4px;
}

.msg-username {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
}

.msg-time {
  font-size: 10px; color: var(--text-muted);
}

.msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 16px;
  font-size: 14px; line-height: 1.6;
  word-break: break-word;
  position: relative; cursor: default;
  transition: var(--transition);
}

.msg-bubble:hover { border-color: var(--border-bright); }

.message-group.own .msg-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: transparent;
  border-radius: 18px 18px 4px 18px;
  color: white;
}

.msg-bubble.deleted {
  color: var(--text-muted); font-style: italic;
  background: rgba(255,255,255,0.02);
}

/* Image message */
.msg-image {
  max-width: 300px; max-height: 300px;
  border-radius: 12px; cursor: pointer;
  transition: var(--transition); display: block;
}

.msg-image:hover { opacity: 0.9; transform: scale(1.02); }

.msg-image-btn {
  display: flex; align-items: center; gap: 8px;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 12px; padding: 12px 20px;
  color: var(--primary-light); cursor: pointer;
  font-size: 14px; text-decoration: none;
  transition: var(--transition);
}

.msg-image-btn:hover {
  background: rgba(99,102,241,0.25);
  transform: translateY(-1px);
}

/* Context menu */
.msg-actions {
  position: absolute; top: -32px;
  display: none; gap: 4px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 4px;
  z-index: 10;
}

.msg-bubble:hover .msg-actions { display: flex; }

.msg-action-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 12px;
  padding: 4px 8px; border-radius: 4px;
  transition: var(--transition);
}

.msg-action-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }

/* Date divider */
.date-divider {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0; color: var(--text-muted); font-size: 12px;
}

.date-divider::before, .date-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* INPUT AREA */
.chat-input-area {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: rgba(6,6,16,0.8);
  flex-shrink: 0;
}

.chat-input-toolbar {
  display: flex; gap: 4px; margin-bottom: 8px;
}

.toolbar-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: var(--transition);
}

.toolbar-btn:hover { color: var(--primary-light); background: rgba(99,102,241,0.1); }

.chat-input-wrapper {
  display: flex; align-items: flex-end; gap: 8px;
}

.message-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 18px;
  color: var(--text-primary); font-size: 14px; font-family: inherit;
  outline: none; line-height: 1.5;
  max-height: 160px; overflow-y: auto;
  transition: var(--transition);
  word-break: break-word;
}

.message-input:focus {
  border-color: rgba(99,102,241,0.5);
  background: rgba(99,102,241,0.05);
}

.message-input:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.send-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none; cursor: pointer; color: white;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(99,102,241,0.5);
}

.send-btn:active { transform: scale(0.95); }

/* Image preview */
.image-preview-area {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px;
}

.image-preview-item {
  position: relative;
  width: 80px; height: 80px;
  border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border);
}

.image-preview-item img {
  width: 100%; height: 100%; object-fit: cover;
}

.image-preview-remove {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,0.7); color: white; border: none;
  width: 18px; height: 18px; border-radius: 50%;
  cursor: pointer; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.image-preview-remove:hover { background: #ef4444; }

/* ===================== MODALS ===================== */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.open { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: rgba(12,12,24,0.98);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
  position: relative;
  animation: modalSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 40px 80px rgba(0,0,0,0.5);
}

.modal-large { max-width: 600px; }

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

.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 18px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: var(--transition);
}

.modal-close:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.modal-close.white { color: white; }

.modal-title {
  font-size: 20px; font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 28px;
}

.modal-submit-btn {
  width: 100%; margin-top: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; border: none; cursor: pointer;
  padding: 14px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; font-family: inherit;
  transition: var(--transition);
}

.modal-submit-btn:hover { box-shadow: 0 4px 24px rgba(99,102,241,0.4); transform: translateY(-1px); }

.modal-delete-btn {
  width: 100%; margin-top: 8px;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #f87171; cursor: pointer;
  padding: 14px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; font-family: inherit;
  transition: var(--transition);
}

.modal-delete-btn:hover { background: rgba(239,68,68,0.25); }

.modal-actions { display: flex; flex-direction: column; gap: 8px; }

.terms-content {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 24px; margin-bottom: 16px;
  max-height: 300px; overflow-y: auto;
  font-size: 13px; line-height: 1.8; color: var(--text-secondary);
}

.terms-content h4 { color: var(--text-primary); margin: 16px 0 8px; font-size: 14px; }
.terms-content:first-child h4 { margin-top: 0; }

/* Friends modal */
.friend-search-results {
  margin-top: 8px;
  max-height: 200px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}

.friend-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.friend-item:hover { border-color: rgba(99,102,241,0.3); background: rgba(99,102,241,0.05); }

.friend-item-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.friend-item-info { flex: 1; }
.friend-item-name { font-size: 14px; font-weight: 600; }
.friend-item-id { font-size: 11px; color: var(--text-muted); }

.friend-item-actions { display: flex; gap: 4px; }

.friend-action-btn {
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  color: var(--primary-light); cursor: pointer;
  font-size: 11px; padding: 4px 10px; border-radius: 4px;
  transition: var(--transition);
}

.friend-action-btn:hover { background: rgba(99,102,241,0.2); }

.friends-divider {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  color: var(--text-muted); text-transform: uppercase;
  padding: 16px 0 8px;
  border-top: 1px solid var(--border); margin-top: 8px;
}

.friends-list-modal {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 200px; overflow-y: auto;
}

/* Profile modal */
.profile-avatar-picker {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  margin-bottom: 24px;
}

.profile-avatar-display {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  border: 3px solid var(--primary);
  box-shadow: 0 0 20px rgba(99,102,241,0.3);
}

.emoji-picker-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px;
}

.emoji-option {
  font-size: 24px; cursor: pointer;
  padding: 6px; border-radius: 8px;
  transition: var(--transition); text-align: center;
  border: 2px solid transparent;
}

.emoji-option:hover { background: var(--bg-card-hover); transform: scale(1.2); }
.emoji-option.selected { border-color: var(--primary); background: rgba(99,102,241,0.1); }

.color-picker-section {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; color: var(--text-secondary); font-size: 14px;
}

.color-options {
  display: flex; gap: 8px; flex-wrap: wrap;
}

.color-option {
  width: 24px; height: 24px; border-radius: 50%;
  cursor: pointer; transition: var(--transition);
  border: 2px solid transparent;
}

.color-option:hover { transform: scale(1.2); }
.color-option.selected { border-color: white; transform: scale(1.1); }

/* Image viewer */
.modal-dark { background: rgba(0,0,0,0.9); }

.image-viewer-content {
  position: relative; max-width: 90vw; max-height: 90vh;
}

.viewer-image {
  max-width: 90vw; max-height: 90vh;
  object-fit: contain; border-radius: var(--radius-sm);
}

/* Emoji picker popup */
.emoji-picker-popup {
  display: none; position: fixed; z-index: 400;
  background: rgba(12,12,24,0.98);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  width: 280px;
  max-height: 300px; overflow-y: auto;
}

.emoji-picker-popup.open { display: block; }

.emoji-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}

.emoji-grid button {
  background: none; border: none; cursor: pointer;
  font-size: 20px; padding: 4px; border-radius: 4px;
  transition: var(--transition);
}

.emoji-grid button:hover { background: var(--bg-card-hover); transform: scale(1.2); }

/* ===================== TOAST ===================== */
.toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 500; pointer-events: none;
}

.toast {
  background: rgba(12,12,24,0.95);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 12px 20px;
  font-size: 14px; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  animation: toastIn 0.3s ease;
  pointer-events: auto;
}

.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error { border-color: rgba(239,68,68,0.3); }

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

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  .header-nav { display: none; }
  .nav-menu-btn { display: flex; }

  .hero-actions { flex-direction: column; align-items: center; }

  .gate-container { padding: 32px 24px; }

  .chat-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
    transform: translateX(-100%);
  }

  .chat-sidebar.open { transform: translateX(0); }

  .sidebar-toggle { display: flex; }

  .chat-messages { padding: 16px; }

  .chat-input-area { padding: 12px; }

  .modal-box { margin: 16px; padding: 28px; }

  .about-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .msg-content { max-width: 85%; }
  .hero-title .title-line { font-size: clamp(36px, 12vw, 72px); }
}

/* Checkbox row */
.checkbox-row {
  padding: 4px 0;
}

/* Admin floating btn visibility */
.admin-floating-btn.visible { display: flex; }
