/* ============================================================
   hellobeever — main stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ──────────────────────────────────────────── */
:root {
  --bg:          #000000;
  --bg2:         #0d0d0d;
  --surface:     rgba(255,255,255,0.06);
  --surface2:    rgba(255,255,255,0.10);
  --border:      rgba(255,255,255,0.12);
  --border2:     rgba(255,255,255,0.20);
  --primary:     #7c3aed;
  --primary-l:   #a78bfa;
  --primary-d:   #5b21b6;
  --accent:      #ec4899;
  --accent-l:    #f9a8d4;
  --success:     #10b981;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --text:        #f1f5f9;
  --text-2:      #94a3b8;
  --text-3:      #64748b;
  --radius:      14px;
  --radius-sm:   8px;
  --radius-lg:   20px;
  --shadow:      0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg:   0 24px 64px rgba(0,0,0,0.5);
  --glow:        0 0 40px rgba(124,58,237,0.25);
  --transition:  0.2s cubic-bezier(0.4,0,0.2,1);
  --sidebar-w:   240px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-l); text-decoration: none; }
a:hover { color: var(--text); }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: inherit; outline: none; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ── Animated background ────────────────────────────────── */
.bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.bg-canvas::before,
.bg-canvas::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: orb 20s ease-in-out infinite alternate;
}
.bg-canvas::before {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #5b21b6 0%, transparent 70%);
  top: -200px; left: -200px;
  animation-delay: 0s;
}
.bg-canvas::after {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #831843 0%, transparent 70%);
  bottom: -150px; right: -100px;
  animation-delay: -10s;
}
.bg-orb3 {
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, #1e3a8a 0%, transparent 70%);
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  animation: orb 25s ease-in-out infinite alternate;
  animation-delay: -5s;
}
@keyframes orb {
  0%   { transform: translate(0,0) scale(1); }
  33%  { transform: translate(60px,-40px) scale(1.1); }
  66%  { transform: translate(-40px,60px) scale(0.9); }
  100% { transform: translate(20px,20px) scale(1.05); }
}

/* Grid overlay */
.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* ── Typography ─────────────────────────────────────────── */
h1 { font-size: 2rem;   font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 0.9375rem; font-weight: 600; }
p  { color: var(--text-2); }

.gradient-text {
  background: linear-gradient(135deg, var(--primary-l), var(--accent-l));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Utility ─────────────────────────────────────────────── */
.relative  { position: relative; }
.flex      { display: flex; }
.flex-col  { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: 4px; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.gap-6  { gap: 24px; }
.w-full { width: 100%; }
.text-sm  { font-size: 0.875rem; }
.text-xs  { font-size: 0.75rem; }
.text-muted { color: var(--text-2); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

/* ── Glass card ─────────────────────────────────────────── */
.card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card-lg {
  border-radius: var(--radius-lg);
  padding: 32px;
}
.card:hover { border-color: var(--border2); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6d28d9);
  color: #fff;
  box-shadow: 0 4px 20px rgba(124,58,237,0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #6d28d9, #5b21b6);
  box-shadow: 0 6px 28px rgba(124,58,237,0.5);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--border2);
}
.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.25);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 6px 14px; font-size: 0.8125rem; border-radius: 6px; }
.btn-icon {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 1rem;
  transition: all var(--transition);
}
.btn-icon:hover { color: var(--text); border-color: var(--border2); }
.btn[disabled], .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Inputs ─────────────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.02em;
}
.input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.9375rem;
  transition: all var(--transition);
  width: 100%;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.2);
  background: var(--surface2);
}
.input::placeholder { color: var(--text-3); }
.input-icon-wrap { position: relative; }
.input-icon-wrap .input { padding-left: 40px; }
.input-icon-wrap .icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 1rem;
  pointer-events: none;
}

/* ── Auth pages (login, setup, register) ────────────────── */
.auth-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1;
}
.auth-box {
  width: 100%;
  max-width: 420px;
  animation: fadeUp 0.5s ease both;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  justify-content: center;
}
.auth-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--primary), #ec4899);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  box-shadow: var(--glow);
}
.auth-logo-text {
  font-size: 1.375rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-l), var(--accent-l));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-title { font-size: 1.625rem; font-weight: 700; margin-bottom: 6px; }
.auth-sub   { color: var(--text-2); font-size: 0.9375rem; margin-bottom: 28px; }
.auth-form  { display: flex; flex-direction: column; gap: 16px; }
.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.875rem;
  color: var(--text-3);
}

/* ── Native-feel login page ─────────────────────────────── */
.native-auth-page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 0 24px;
  padding-top: max(env(safe-area-inset-top), 0px);
  padding-bottom: max(env(safe-area-inset-bottom), 16px);
}
.native-auth-header {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 0 32px;
  text-align: center;
}
.native-logo-mark {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary), #ec4899);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: white;
  letter-spacing: -0.04em;
  box-shadow: 0 8px 32px rgba(124,58,237,0.45), 0 0 0 1px rgba(255,255,255,0.08);
  margin-bottom: 16px;
}
.native-logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-l), var(--accent-l));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.native-logo-sub {
  color: var(--text-3);
  font-size: 0.875rem;
}
.native-auth-body {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}
.native-form-title {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}
.native-form-sub {
  color: var(--text-2);
  font-size: 0.9rem;
  margin-bottom: 20px;
  margin-top: -12px;
}
.native-auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.native-auth-footer {
  text-align: center;
  padding: 28px 0 8px;
  font-size: 0.875rem;
  color: var(--text-3);
}

.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-3); font-size: 0.8125rem;
  margin: 4px 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Alert / toast ──────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.alert-error   { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.25); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,0.12); border: 1px solid rgba(16,185,129,0.25); color: #6ee7b7; }
.alert-info    { background: rgba(124,58,237,0.12); border: 1px solid rgba(124,58,237,0.25); color: var(--primary-l); }

/* Toast */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  backdrop-filter: blur(20px);
  animation: toastIn 0.3s ease both;
  pointer-events: auto;
  max-width: 320px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow);
}
.toast-success { background: rgba(16,185,129,0.2); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }
.toast-error   { background: rgba(239,68,68,0.2);  border: 1px solid rgba(239,68,68,0.3);  color: #fca5a5; }
.toast-info    { background: rgba(124,58,237,0.2); border: 1px solid rgba(124,58,237,0.3); color: var(--primary-l); }
.toast-out     { animation: toastOut 0.3s ease both; }

/* ── Main app layout ─────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
  /* iOS safe areas for the app shell */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  min-height: 100dvh;
  background: #111111;
  backdrop-filter: none;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform var(--transition);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), #ec4899);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sidebar-logo-text {
  font-size: 1.0625rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-l), var(--accent-l));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}
.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}
.nav-item.active {
  background: rgba(124,58,237,0.15);
  color: var(--primary-l);
  border-color: rgba(124,58,237,0.2);
}
.nav-item .nav-icon { width: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-item .nav-icon svg { display: block; }
.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}
.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.avatar-lg { width: 44px; height: 44px; font-size: 1.125rem; }
.avatar-xl { width: 60px; height: 60px; font-size: 1.5rem; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.875rem; font-weight: 600; truncate: true; }
.sidebar-user-role { font-size: 0.75rem; color: var(--text-3); }
.sidebar-logout {
  background: none;
  color: var(--text-3);
  font-size: 1rem;
  padding: 4px;
  border-radius: 6px;
  transition: color var(--transition);
}
.sidebar-logout:hover { color: var(--danger); }

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.page {
  flex: 1;
  padding: 32px;
  display: none;
  animation: fadeIn 0.25s ease;
}
.page.active { display: flex; flex-direction: column; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-sub { color: var(--text-2); font-size: 0.875rem; margin-top: 2px; }

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 200;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  backdrop-filter: blur(20px);
}

/* ── Messages ─────────────────────────────────────────────── */
.messages-layout {
  display: flex;
  gap: 20px;
  flex: 1;
  min-height: 0;
  height: calc(100vh - 140px);
}
.messages-list-panel {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.channel-section-header {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 12px 14px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.channel-section-header button {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all var(--transition);
}
.channel-section-header button:hover { color: var(--primary-l); background: rgba(124,58,237,0.1); }
.channel-item {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 0.9375rem;
  transition: all var(--transition);
  border: 1px solid transparent;
}
.channel-item:hover { background: var(--surface); color: var(--text); }
.channel-item.active {
  background: rgba(124,58,237,0.15);
  color: var(--primary-l);
  border-color: rgba(124,58,237,0.2);
}
.channel-icon { font-size: 1rem; }
.messages-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #111;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-weight: 600; font-size: 0.9375rem; }
.chat-header-sub  { font-size: 0.75rem; color: var(--text-3); }
.btn-xenc {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-xenc:hover  { border-color: var(--primary); color: var(--primary-l); }
.btn-xenc.active { background: rgba(124,58,237,0.15); border-color: rgba(124,58,237,0.4); color: var(--primary-l); }
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}
.chat-body::-webkit-scrollbar { width: 4px; }
.chat-body::-webkit-scrollbar-track { background: transparent; }
.chat-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
/* ── Message bubbles ─────────────────────────────────────── */
.msg {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  animation: fadeIn 0.2s ease;
  max-width: 100%;
}
/* Own messages: RIGHT side */
.msg-me {
  flex-direction: row-reverse;
  margin-left: auto;
  max-width: 75%;
}
/* Others' messages: LEFT side */
.msg-other {
  flex-direction: row;
  margin-right: auto;
  max-width: 75%;
}
.msg-avatar { flex-shrink: 0; margin-top: 2px; }
.msg-body { min-width: 0; }
.msg-me .msg-body   { align-items: flex-end; display: flex; flex-direction: column; }
.msg-other .msg-body { align-items: flex-start; }
.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
}
.msg-me .msg-meta    { flex-direction: row-reverse; }
.msg-other .msg-meta { flex-direction: row; }
.msg-name { font-size: 0.8125rem; font-weight: 600; }
.msg-time { font-size: 0.6875rem; color: var(--text-3); }
.msg-bubble {
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.5;
  word-break: break-word;
  display: inline-block;
  max-width: 100%;
}
.msg-me .msg-bubble {
  background: rgba(124,58,237,0.2);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 16px 4px 16px 16px;
  color: var(--text);
}
.msg-other .msg-bubble {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
  color: var(--text);
}
.msg-bubble code {
  background: rgba(0,0,0,0.2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: monospace;
}
/* Extra-encrypted message */
.msg-xenc .msg-bubble {
  opacity: 0.7;
}
.msg-xenc-label {
  font-size: 0.6875rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.msg-scramble {
  font-family: monospace;
  font-size: 0.8125rem;
  opacity: 0.6;
  word-break: break-all;
}
.msg-group-header {
  font-size: 0.75rem;
  color: var(--text-3);
  text-align: center;
  padding: 8px 0;
  align-self: center;
}
.chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.9375rem;
  resize: none;
  min-height: 42px;
  max-height: 140px;
  line-height: 1.5;
  transition: all var(--transition);
}
.chat-input:focus { border-color: var(--primary); outline: none; }
.chat-input::placeholder { color: var(--text-3); }
.chat-send { align-self: flex-end; }

/* ── Calendar ─────────────────────────────────────────────── */
.calendar-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 20px;
}
.calendar-nav {
  display: flex; align-items: center; gap: 8px;
}
.calendar-month {
  font-size: 1.25rem; font-weight: 700; min-width: 200px; text-align: center;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day-name {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 0;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  padding: 6px;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  min-height: 80px;
  position: relative;
}
.cal-day:hover { background: var(--surface); border-color: var(--border); }
.cal-day.other-month { opacity: 0.3; }
.cal-day.today {
  background: rgba(124,58,237,0.1);
  border-color: rgba(124,58,237,0.3);
}
.cal-day.today .cal-day-num { color: var(--primary-l); font-weight: 700; }
.cal-day.selected { background: rgba(124,58,237,0.2); border-color: var(--primary); }
.cal-day-num { font-size: 0.875rem; font-weight: 500; margin-bottom: 4px; }
.cal-event {
  font-size: 0.6875rem;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  font-weight: 500;
}
.calendar-sidebar {
  min-width: 260px;
  flex-shrink: 0;
}
.event-list-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  background: var(--surface);
  transition: all var(--transition);
  cursor: pointer;
}
.event-list-item:hover { border-color: var(--border2); }
.event-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Lists ───────────────────────────────────────────────── */
.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}
.list-card:hover { border-color: var(--border2); transform: translateY(-2px); box-shadow: var(--shadow); }
.list-card-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.list-icon { font-size: 1.25rem; }
.list-card-body { padding: 14px 18px; }
.list-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.2s ease;
}
.list-item-row:last-child { border-bottom: none; }
.checkbox {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 2px solid var(--border2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  background: transparent;
}
.checkbox.checked {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox.checked::after { content: '✓'; color: #fff; font-size: 0.6875rem; font-weight: 700; }
.list-item-text { flex: 1; font-size: 0.9375rem; }
.list-item-text.done { text-decoration: line-through; color: var(--text-3); }
.list-card-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.list-card-footer .input { padding: 7px 10px; font-size: 0.875rem; }

/* ── Members ─────────────────────────────────────────────── */
.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.member-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  transition: all var(--transition);
}
.member-card:hover { border-color: var(--border2); }
.member-role {
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.role-owner { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }
.role-member { background: rgba(124,58,237,0.15); color: var(--primary-l); border: 1px solid rgba(124,58,237,0.2); }
.invite-code-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-family: monospace;
  font-size: 1rem;
  letter-spacing: 0.1em;
  color: var(--primary-l);
  word-break: break-all;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6,8,20,0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal {
  width: 100%;
  max-width: 500px;
  background: #0e1120;
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 30px; height: 30px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-form { display: flex; flex-direction: column; gap: 14px; }

/* ── Loading / spinner ──────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--primary-l);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
.loading-state {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 40px; color: var(--text-2);
}
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  z-index: 999;
}
.page-loader-logo {
  font-size: 2.5rem;
  animation: pulse 1.5s ease infinite;
}

/* ── Encryption badge ────────────────────────────────────── */
.enc-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.6875rem; font-weight: 600;
  color: #10b981;
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.2);
  padding: 2px 8px; border-radius: 20px;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px;
  padding: 60px 20px; color: var(--text-2); text-align: center;
}
.empty-state-icon { font-size: 3rem; opacity: 0.5; }
.empty-state h3 { color: var(--text); }

/* ── Scrollbar global ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes pulse   { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ── Color picker dots ──────────────────────────────────── */
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot {
  width: 26px; height: 26px;
  border-radius: 50%; cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
}
.color-dot:hover, .color-dot.selected {
  border-color: #fff;
  transform: scale(1.15);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: flex; align-items: center; justify-content: center;
  }
  .page { padding: 20px 16px 80px; }
  .messages-layout { flex-direction: column; height: auto; }
  .messages-list-panel { width: 100%; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .calendar-grid { gap: 2px; }
  .cal-day { min-height: 60px; padding: 4px; }
  .members-grid, .lists-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
  .auth-box { max-width: 100%; }
}

@media (max-width: 480px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .calendar-grid { display: none; }
  .calendar-list-view { display: block !important; }
}

/* ── Message actions (react, reply, delete) ─────────────── */
.msg-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  align-self: center;
  flex-shrink: 0;
}
.msg:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.msg-action-btn:hover { background: var(--surface); color: var(--text); }
.msg-delete-btn:hover { color: var(--danger); }

/* ── Reply preview inside bubble ────────────────────────── */
.msg-reply-quote {
  border-left: 2px solid var(--primary-l);
  padding: 4px 8px;
  margin-bottom: 6px;
  border-radius: 0 4px 4px 0;
  background: rgba(255,255,255,0.05);
  font-size: 0.8125rem;
  cursor: pointer;
}
.msg-reply-quote-sender {
  font-weight: 600;
  font-size: 0.75rem;
  margin-bottom: 2px;
}
.msg-reply-quote-text {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

/* ── Reply bar (above input) ────────────────────────────── */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.15s ease;
}
.reply-bar.hidden { display: none; }
.reply-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.reply-bar-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-l);
}
.reply-bar-text {
  font-size: 0.8125rem;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-cancel-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--surface2);
  border: none;
  color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Reaction bar ───────────────────────────────────────── */
.msg-reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  user-select: none;
}
.reaction-pill:hover { background: var(--surface); border-color: var(--border2); }
.reaction-pill.mine  { border-color: var(--primary); background: rgba(124,58,237,0.15); }
.reaction-pill-count { font-size: 0.75rem; color: var(--text-2); font-weight: 600; }

/* ── Floating reaction picker ────────────────────────────── */
.react-picker {
  position: fixed;
  z-index: 200;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 6px 8px;
  display: flex;
  gap: 2px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.15s ease both;
}
.react-picker.hidden { display: none; }
.react-opt {
  font-size: 1.25rem;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.react-opt:hover { background: var(--surface2); }

/* ── Search bar ─────────────────────────────────────────── */
.chat-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.chat-search-bar.hidden { display: none; }
.chat-search-input {
  flex: 1;
  background: none;
  border: none;
  font-size: 0.9375rem;
  color: var(--text);
  outline: none;
}
.chat-search-input::placeholder { color: var(--text-3); }
.msg.search-hidden { display: none !important; }
.msg.search-match .msg-bubble-text { background: rgba(124,58,237,0.25); }

/* ── Read receipts ──────────────────────────────────────── */
.read-receipts {
  display: flex;
  gap: -4px;
  margin-top: 3px;
  height: 16px;
}
.read-avatar {
  width: 14px; height: 14px;
  border-radius: 50%;
  font-size: 0.5rem;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--bg);
  margin-left: -3px;
  flex-shrink: 0;
  color: white;
  font-weight: 700;
}
