/* ============================================
   Aastik AI — Main Stylesheet
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #111114;
  --bg2:       #1a1a1f;
  --bg3:       #22222a;
  --bg4:       #2c2c36;
  --border:    rgba(255,255,255,0.10);
  --purple:    #8b5cf6;
  --purple2:   #7c3aed;
  --blue:      #3b82f6;
  --pink:      #ec4899;
  --green:     #10b981;
  --red:       #ef4444;
  --orange:    #f59e0b;
  --text:      #f1f1f3;
  --text2:     #a1a1aa;
  --text3:     #71717a;
  --input-bg:  #22222a;
  --radius:    14px;
  --radius-sm: 8px;
  --shadow:    0 8px 32px rgba(0,0,0,0.4);
  --glow:      0 0 40px rgba(139,92,246,0.15);
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg:     #f0f2f5;
  --bg2:    #ffffff;
  --bg3:    #f5f6fa;
  --bg4:    #e8eaf0;
  --border: rgba(0,0,0,0.08);
  --text:   #1a1a2e;
  --text2:  #4a4a6a;
  --text3:  #8888aa;
  --input-bg:  #f5f6fa;
  --glow:   0 0 40px rgba(139,92,246,0.1);
}
[data-theme="light"] .auth-card { background: rgba(255,255,255,0.95); }
[data-theme="light"] .auth-orb { opacity: 0.18; }
[data-theme="light"] .message.assistant .msg-bubble { background: rgba(255,255,255,0.9); }
[data-theme="light"] .input-box { background: #fff; border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .chat-header { background: rgba(255,255,255,0.95); backdrop-filter: blur(10px); }
[data-theme="light"] .sidebar { background: #fff; }
[data-theme="light"] .input-area { background: rgba(245,246,250,0.95); }
[data-theme="light"] .nav-btn:hover, [data-theme="light"] .nav-btn.active { background: #f0f0f8; }
[data-theme="light"] .theme-slider { background: #e0e0e8; }
[data-theme="light"] .usage-bar { background: #e0e0e8; }

html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg); color: var(--text);
  height: 100%; height: 100dvh;
  overflow: hidden;
  transition: background 0.3s, color 0.3s;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* sidebar backdrop for mobile */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
}
.sidebar-backdrop.active { display: block; }

/* ── Particle Canvas ── */
.particle-canvas { display: none; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 99px; }

/* ============================================
   AUTH SCREEN
   ============================================ */
.auth-screen {
  height: 100%; height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  position: fixed; inset: 0;
  overflow-y: auto;
}
.auth-bg { position: absolute; inset: 0; z-index: 0; }
.auth-orb {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.35;
  animation: float 8s ease-in-out infinite;
}
.orb1 { width: 500px; height: 500px; background: var(--purple); top: -150px; left: -150px; animation-delay: 0s; }
.orb2 { width: 400px; height: 400px; background: var(--blue); bottom: -100px; right: -100px; animation-delay: 3s; }
.orb3 { width: 300px; height: 300px; background: var(--pink); top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: 6s; }

@keyframes float {
  0%,100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-30px) scale(1.05); }
}

.auth-container {
  position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 20px;
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.logo-icon {
  width: 72px; height: 72px; background: linear-gradient(135deg, var(--purple), var(--blue));
  border-radius: 20px; display: flex; align-items: center; justify-content: center;
  font-size: 32px; margin: 0 auto 16px; box-shadow: 0 0 40px rgba(139,92,246,0.4);
}
.auth-logo h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; }
.auth-logo h1 span { background: linear-gradient(135deg, var(--purple), var(--blue)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.auth-logo p { color: var(--text2); margin-top: 6px; }

/* logo-ring (decorative, hidden) */
.logo-ring { display: none; }

/* auth-badges */
.auth-badges { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.auth-badges span {
  font-size: 11px; color: var(--text2); background: var(--bg3);
  border: 1px solid var(--border); padding: 4px 10px; border-radius: 99px;
  display: flex; align-items: center; gap: 4px;
}

/* auth-grid (decorative, hidden) */
.auth-grid { display: none; }

/* btn-shine (decorative, hidden) */
.btn-shine { display: none; }

.auth-card {
  background: rgba(20,20,22,0.85); backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: 20px; padding: 32px;
  box-shadow: var(--shadow), var(--glow);
}
.auth-tabs { display: flex; gap: 4px; background: var(--bg3); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 24px; }
.auth-tab {
  flex: 1; padding: 10px; border: none; background: transparent; color: var(--text2);
  border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.2s;
}
.auth-tab.active { background: var(--purple); color: #fff; box-shadow: 0 2px 12px rgba(139,92,246,0.4); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.input-group {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 14px; transition: border-color 0.2s;
}
.input-group:focus-within { border-color: var(--purple); }
.input-group > i { color: var(--text3); font-size: 14px; flex-shrink: 0; }
.input-group input {
  flex: 1; background: transparent; border: none; outline: none; color: var(--text);
  padding: 13px 0; font-size: 14px; font-family: inherit;
}
.input-group input::placeholder { color: var(--text3); }
.toggle-pass { background: none; border: none; color: var(--text3); cursor: pointer; padding: 4px; }

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: #fff; border: none; border-radius: var(--radius-sm); padding: 13px 20px;
  font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(139,92,246,0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.auth-msg { font-size: 13px; text-align: center; padding: 8px; border-radius: 6px; min-height: 20px; }
.auth-msg.success { color: var(--green); background: rgba(16,185,129,0.1); }
.auth-msg.error   { color: var(--red);   background: rgba(239,68,68,0.1); }

/* ============================================
   CHAT SCREEN
   ============================================ */
.chat-screen {
  display: flex;
  height: 100%; height: 100dvh;
  position: fixed; inset: 0;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  background: #252530;
  border-right: 1px solid rgba(255,255,255,0.09);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: transform 0.3s ease;
  z-index: 100;
  height: 100%; overflow-y: auto; overflow-x: hidden;
}
[data-theme="light"] .sidebar {
  background: #f2f2f7;
  border-right: 1px solid rgba(0,0,0,0.09);
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.07);
}
[data-theme="light"] .sidebar-header { border-bottom-color: rgba(0,0,0,0.07); }
.sidebar-logo { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: rgba(255,255,255,0.9); }
[data-theme="light"] .sidebar-logo { color: #1a1a2e; }
.logo-icon-sm {
  width: 36px; height: 36px; background: linear-gradient(135deg, var(--purple), var(--blue));
  border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.sidebar-close { display: none; background: none; border: none; color: rgba(255,255,255,0.5); cursor: pointer; font-size: 18px; padding: 4px; }
[data-theme="light"] .sidebar-close { color: #888; }

.user-profile-card {
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
[data-theme="light"] .user-profile-card { border-bottom-color: rgba(0,0,0,0.07); }
.avatar-wrap {
  position: relative; width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  flex-shrink: 0; overflow: hidden; border: 2px solid var(--purple);
}
/* avatar-ring (decorative) */
.avatar-ring { display: none; }
.avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }
.avatar-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s; font-size: 14px;
}
.avatar-wrap:hover .avatar-overlay { opacity: 1; }
.user-info h3 { font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.9); }
[data-theme="light"] .user-info h3 { color: #1a1a2e; }
.nickname-badge {
  font-size: 11px; background: linear-gradient(135deg, var(--purple), var(--pink));
  color: #fff; padding: 2px 8px; border-radius: 99px; margin-top: 4px; display: inline-block;
}

.chat-usage { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.07); }
[data-theme="light"] .chat-usage { border-bottom-color: rgba(0,0,0,0.07); }
.usage-header { display: flex; justify-content: space-between; font-size: 11px; color: var(--text2); margin-bottom: 6px; }
.usage-bar { height: 6px; background: var(--bg4); border-radius: 99px; overflow: hidden; }
.usage-fill { height: 100%; background: linear-gradient(90deg, var(--purple), var(--blue)); border-radius: 99px; transition: width 0.5s ease; position: relative; overflow: hidden; }
.usage-glow { display: none; }
.usage-note { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 6px; }
[data-theme="light"] .usage-note { color: #999; }

.sidebar-nav { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-btn {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px;
  background: transparent; border: none;
  color: rgba(255,255,255,0.65);
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 12.5px; font-weight: 500;
  transition: all 0.18s; text-align: left; width: 100%;
}
.nav-btn:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.95);
}
.nav-btn.active {
  background: rgba(139,92,246,0.18);
  color: #a78bfa;
}
[data-theme="light"] .nav-btn { color: #555570; }
[data-theme="light"] .nav-btn:hover { background: rgba(0,0,0,0.06); color: #1a1a2e; }
[data-theme="light"] .nav-btn.active { background: rgba(139,92,246,0.12); color: var(--purple); }

/* ── Theme Toggle ── */
.theme-toggle-wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
[data-theme="light"] .theme-toggle-wrap { border-top-color: rgba(0,0,0,0.07); }
.theme-toggle-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 500;
  color: rgba(255,255,255,0.6);
  pointer-events: none;
}
[data-theme="light"] .theme-toggle-label { color: #666680; }
.theme-toggle-label i { font-size: 13px; color: var(--purple); }
.theme-switch {
  position: relative;
  width: 44px; height: 24px;
  flex-shrink: 0;
  display: inline-block;
}
.theme-switch input[type=checkbox] {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 10;
  -webkit-appearance: none;
  appearance: none;
}
.theme-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.14);
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,0.18);
  transition: background 0.25s, border-color 0.25s;
  pointer-events: none;
}
[data-theme="light"] .theme-slider { background: rgba(0,0,0,0.13); border-color: rgba(0,0,0,0.18); }
.theme-switch input:checked ~ .theme-slider { background: var(--purple); border-color: var(--purple); }
.theme-slider::after {
  content: '';
  position: absolute;
  left: 3px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  pointer-events: none;
}
.theme-switch input:checked ~ .theme-slider::after { left: calc(100% - 19px); }
.theme-icon { display: none; }

.sidebar-footer { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.07); }
[data-theme="light"] .sidebar-footer { border-top-color: rgba(0,0,0,0.07); }
.btn-logout {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px; background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2);
  color: var(--red); border-radius: var(--radius-sm); cursor: pointer; font-size: 12.5px;
  font-weight: 500; transition: all 0.2s;
}
.btn-logout:hover { background: rgba(239,68,68,0.2); }

/* ── Chat Main ── */
/* ── Chat Background Orbs ── */
.chat-bg {
  position: absolute; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
}
.chat-orb {
  position: absolute; border-radius: 50%;
  filter: blur(70px); opacity: 0.13;
  animation: chatOrbFloat 10s ease-in-out infinite;
}
.co1 { width: 400px; height: 400px; background: var(--purple); top: -100px; left: -80px; animation-delay: 0s; }
.co2 { width: 350px; height: 350px; background: var(--blue);   bottom: 0;   right: -60px; animation-delay: 3s; }
.co3 { width: 280px; height: 280px; background: var(--pink);   top: 40%;    left: 30%;   animation-delay: 6s; }
.co4 { width: 220px; height: 220px; background: var(--green);  bottom: 20%; left: -40px; animation-delay: 9s; }
@keyframes chatOrbFloat {
  0%,100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-30px) scale(1.08); }
}
[data-theme="light"] .chat-orb { opacity: 0.07; }

.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; position: relative; }

.chat-header {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px;
  border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0;
  position: relative; z-index: 2;
}
.menu-btn { display: none; background: none; border: none; color: var(--text2); cursor: pointer; font-size: 20px; }
.header-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; flex: 1; }
/* ai-status-wrap wraps the dot */
.ai-status-wrap { position: relative; width: 10px; height: 10px; flex-shrink: 0; }
.ai-status-dot { width: 10px; height: 10px; background: var(--green); border-radius: 50%; box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
.ai-status-ring { display: none; }
/* model badge */
.header-model-badge {
  font-size: 10px; font-weight: 600; color: var(--purple);
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.25);
  padding: 2px 8px; border-radius: 99px;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.header-actions { display: flex; gap: 8px; }
.icon-btn { background: none; border: none; color: var(--text2); cursor: pointer; padding: 8px; border-radius: 8px; transition: all 0.2s; font-size: 15px; }
.icon-btn:hover { background: var(--bg3); color: var(--text); }

/* ── Messages ── */
.messages-container { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px; display: flex; flex-direction: column; -webkit-overflow-scrolling: touch; position: relative; z-index: 1; }

.welcome-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; }
/* welcome-animation wrapper */
.welcome-animation {
  position: relative;
  width: 100px; height: 100px;
  margin: 0 auto 24px;
  display: flex; align-items: center; justify-content: center;
}
.welcome-orb {
  position: absolute; inset: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  opacity: 0.18;
  animation: orbPulse 3s ease-in-out infinite;
}
@keyframes orbPulse {
  0%,100% { transform: scale(1);   opacity: 0.18; }
  50%      { transform: scale(1.15); opacity: 0.28; }
}
.welcome-icon {
  font-size: 48px;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative; z-index: 1;
  animation: robotFloat 3s ease-in-out infinite;
  display: inline-block;
  filter: drop-shadow(0 8px 24px rgba(139,92,246,0.5));
}
@keyframes robotFloat {
  0%,100% { transform: translateY(0px) rotate(-3deg); }
  25%      { transform: translateY(-10px) rotate(3deg); }
  50%      { transform: translateY(-16px) rotate(-2deg); }
  75%      { transform: translateY(-8px) rotate(2deg); }
}
.welcome-screen h2 { font-size: 28px; font-weight: 800; margin-bottom: 10px; }
.welcome-screen h2 span { background: linear-gradient(135deg, var(--purple), var(--blue)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.welcome-screen p { color: var(--text2); margin-bottom: 28px; }
.suggestion-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.suggestion-chips button {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  padding: 10px 16px; border-radius: 99px; cursor: pointer; font-size: 13px;
  transition: all 0.2s; font-family: inherit;
}
.suggestion-chips button:hover { border-color: var(--purple); color: var(--text); background: var(--bg4); }

/* ── Message Bubbles ── */
.message { display: flex; gap: 12px; margin-bottom: 20px; animation: msgIn 0.3s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.message.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px; overflow: hidden;
}
.message.user .msg-avatar { background: linear-gradient(135deg, var(--purple), var(--blue)); }
.message.assistant .msg-avatar { background: linear-gradient(135deg, var(--bg4), var(--bg3)); border: 1px solid var(--border); }
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

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

.msg-bubble {
  padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.6;
  word-break: break-word; position: relative;
}
.message.user .msg-bubble {
  background: linear-gradient(135deg, var(--purple), var(--purple2));
  color: #fff; border-bottom-right-radius: 4px;
}
.message.assistant .msg-bubble {
  background: rgba(28,28,31,0.75); border: 1px solid var(--border);
  color: var(--text); border-bottom-left-radius: 4px;
  backdrop-filter: blur(12px);
}
[data-theme="light"] .message.assistant .msg-bubble {
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(12px);
}
.msg-bubble pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 8px 0; font-size: 13px; }
.msg-bubble code { background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.msg-bubble pre code { background: none; padding: 0; }

.msg-time { font-size: 11px; color: var(--text3); padding: 0 4px; }

.msg-image { max-width: 220px; max-height: 200px; width: auto; height: auto; object-fit: cover; border-radius: 12px; cursor: pointer; transition: transform 0.2s; display: block; }
.msg-image:hover { transform: scale(1.02); }
.msg-file-attach {
  display: flex; align-items: center; gap: 10px; background: var(--bg4);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
  font-size: 13px; color: var(--text2); text-decoration: none; transition: all 0.2s;
}
.msg-file-attach:hover { border-color: var(--purple); color: var(--text); }

/* send-ripple (decorative) */
.send-ripple { display: none; }

/* ── Typing Indicator ── */
.typing-indicator { display: flex; gap: 5px; padding: 14px 16px; }
.typing-dot { width: 8px; height: 8px; background: var(--text3); border-radius: 50%; animation: typing 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-8px); } }

/* ── Limit Banner ── */
.limit-banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 20px;
  background: rgba(245,158,11,0.1); border-top: 1px solid rgba(245,158,11,0.3);
  color: var(--orange); font-size: 14px; position: relative; z-index: 2;
}
.limit-banner button {
  margin-left: auto; background: var(--orange); color: #000; border: none;
  padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600;
}

/* ── Input Area ── */
.input-area {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  position: relative; z-index: 2;
}

.file-preview { margin-bottom: 10px; }
.file-preview-inner {
  display: inline-flex; align-items: center; gap: 10px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
}
#filePreviewImg, #adminFilePreviewImg, #dmFilePreviewImg { max-height: 56px; max-width: 72px; border-radius: 6px; object-fit: cover; }
.file-info-preview { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); }
.remove-file { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 14px; padding: 2px; }
.remove-file:hover { color: var(--red); }

.input-box {
  display: flex; align-items: flex-end; gap: 10px; background: var(--bg3);
  border: 1.5px solid var(--border); border-radius: var(--radius); padding: 8px 8px 8px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-box:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.12);
}
.attach-btn {
  background: none; border: none; color: var(--text3); cursor: pointer;
  padding: 8px; border-radius: 8px; transition: all 0.2s; font-size: 16px; flex-shrink: 0;
}
.attach-btn:hover { color: var(--purple); background: rgba(139,92,246,0.1); }
#messageInput {
  flex: 1; background: transparent; border: none; outline: none; color: var(--text);
  font-size: 14px; font-family: inherit; resize: none; max-height: 160px;
  line-height: 1.5; padding: 6px 0;
}
#messageInput::placeholder { color: var(--text3); }
.send-btn {
  width: 40px; height: 40px; background: linear-gradient(135deg, var(--purple), var(--blue));
  border: none; border-radius: 10px; color: #fff; cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.2s;
}
.send-btn:hover { transform: scale(1.05); box-shadow: 0 4px 14px rgba(139,92,246,0.4); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.input-note { font-size: 11px; color: var(--text3); text-align: center; margin-top: 8px; }

/* ============================================
   MODALS
   ============================================ */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); }
.modal-content {
  position: relative; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow); z-index: 1; width: 100%;
  animation: modalIn 0.25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.small-modal  { max-width: 460px; }
.large-modal  { max-width: 700px; max-height: 80vh; display: flex; flex-direction: column; }
.viewer-modal { max-width: 90vw; max-height: 90vh; background: transparent; border: none; display: flex; flex-direction: column; align-items: center; }
.editor-modal { max-width: 800px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-header button { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 18px; padding: 4px; }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-body p { color: var(--text2); font-size: 14px; margin-bottom: 14px; }
.modal-body textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 12px; font-size: 14px; font-family: inherit; resize: vertical; outline: none;
}
.modal-body textarea:focus { border-color: var(--purple); }

/* Image Editor */
.editor-body { display: flex; gap: 20px; padding: 20px; flex-wrap: wrap; }
#editorCanvas { max-width: 100%; max-height: 400px; border-radius: 10px; background: var(--bg3); flex: 1; min-width: 200px; }
.editor-tools { display: flex; flex-direction: column; gap: 14px; min-width: 200px; flex: 0 0 220px; }
.tool-group label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; }
.tool-group input[type=range] { width: 100%; accent-color: var(--purple); }
.filter-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-btns button {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; transition: all 0.2s;
}
.filter-btns button:hover { border-color: var(--purple); color: var(--text); }

/* Image Viewer */
.viewer-modal img { max-width: 100%; max-height: 75vh; border-radius: 12px; object-fit: contain; }
.viewer-close {
  position: absolute; top: -16px; right: -16px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.viewer-actions { display: flex; gap: 10px; margin-top: 14px; }
.viewer-actions button, .viewer-actions a {
  display: flex; align-items: center; gap: 6px; padding: 9px 18px;
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; cursor: pointer; font-size: 13px; text-decoration: none; transition: all 0.2s;
}
.viewer-actions button:hover, .viewer-actions a:hover { border-color: var(--purple); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  /* Sidebar slides in as overlay */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 260px;
    background: #252530;
    transform: translateX(-100%);
    box-shadow: 6px 0 30px rgba(0,0,0,0.6);
    z-index: 200;
    height: 100%; height: 100dvh;
  }
  [data-theme="light"] .sidebar { background: #f2f2f7; box-shadow: 6px 0 30px rgba(0,0,0,0.15); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .menu-btn { display: flex; }

  /* Chat takes full width */
  .chat-main { width: 100%; }

  /* Messages */
  .msg-content { max-width: 82%; }
  .msg-bubble { font-size: 13px; padding: 10px 13px; }

  /* Welcome screen */
  .welcome-screen { padding: 20px 16px; }
  .welcome-screen h2 { font-size: 20px; }
  .welcome-screen p { font-size: 13px; margin-bottom: 18px; }
  .welcome-animation { width: 80px; height: 80px; }
  .welcome-icon { font-size: 38px; }
  .suggestion-chips { gap: 8px; }
  .suggestion-chips button { font-size: 12px; padding: 8px 12px; }

  /* Header */
  .chat-header { padding: 12px 14px; }
  .header-model-badge { display: none; }

  /* Input */
  .input-area { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .input-note { display: block; font-size: 10px; }

  /* Modals */
  .modal { padding: 12px; align-items: flex-end; }
  .modal-content { border-radius: 20px 20px 12px 12px; }
  .small-modal { max-width: 100%; }
  .editor-body { flex-direction: column; }
  .editor-tools { flex: none; min-width: unset; }

  /* Auth */
  .auth-container { padding: 16px; }
  .auth-logo { margin-bottom: 20px; }
  .auth-logo h1 { font-size: 26px; }
  .auth-badges { display: none; }
  .auth-card { padding: 24px 18px; }
}

@media (max-width: 400px) {
  .sidebar { width: 260px; }
  .msg-content { max-width: 88%; }
  .chat-header { padding: 10px 12px; }
  .header-title { font-size: 15px; }
  .send-btn { width: 36px; height: 36px; font-size: 13px; }
  .attach-btn { padding: 6px; font-size: 14px; }
  #messageInput { font-size: 13px; }
}

/* ── Chat Mode Toggle ── */
.chat-mode-toggle {
  display: flex; gap: 6px; padding: 10px 16px 0;
  flex-shrink: 0; position: relative; z-index: 2;
}
.mode-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg3); color: var(--text2); cursor: pointer; font-size: 13px;
  font-weight: 500; font-family: inherit; transition: all 0.2s; position: relative;
}
.mode-btn.active {
  background: linear-gradient(135deg, var(--purple), var(--purple2));
  color: #fff; border-color: transparent;
  box-shadow: 0 2px 14px rgba(139,92,246,0.4);
}
.mode-btn:not(.active):hover { border-color: var(--purple); color: var(--text); background: rgba(139,92,246,0.07); }
.unread-dot {
  width: 8px; height: 8px; background: var(--red); border-radius: 50%;
  position: absolute; top: 6px; right: 6px; animation: pulse 1.5s infinite;
}

/* ── DM Friend Toggler ── */
.dm-friend-toggler {
  position: relative;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  z-index: 10;
}
.dm-toggler-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 9px 14px; cursor: pointer;
  color: var(--text); font-family: inherit; transition: all 0.2s;
}
.dm-toggler-btn:hover { border-color: var(--purple); background: var(--bg4); }
.dm-toggler-btn.open { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(139,92,246,0.12); }
.dm-toggler-inner {
  display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500;
}
.dm-toggler-inner img {
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover;
}
.dm-toggler-inner i { color: var(--purple); font-size: 14px; }
#dmDrawerChevron { font-size: 11px; color: var(--text3); transition: transform 0.25s; }
#dmDrawerChevron.open { transform: rotate(180deg); }
.dm-friend-drawer {
  position: absolute; left: 12px; right: 12px; top: calc(100% - 10px);
  background: var(--bg2); border: 1.5px solid var(--purple);
  border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  overflow: hidden; z-index: 100;
  animation: drawerIn 0.2s ease;
}
@keyframes drawerIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
.dm-drawer-list { max-height: 220px; overflow-y: auto; padding: 6px; }
.dm-drawer-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  transition: background 0.15s; font-size: 13px; font-weight: 500;
}
.dm-drawer-item:hover { background: rgba(139,92,246,0.12); }
.dm-drawer-item.active { background: rgba(139,92,246,0.18); color: var(--purple); }
.dm-drawer-item img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.dm-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px; color: var(--text3);
}
.dm-empty i { font-size: 36px; opacity: 0.4; }
.dm-empty p { font-size: 13px; }
.dm-chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg2); flex-shrink: 0;
}
.dm-chat-header img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.dm-chat-header span { flex: 1; font-size: 14px; font-weight: 600; }
.dm-photos-btn {
  background: none; border: 1px solid var(--border); color: var(--text2);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 12px;
  font-family: inherit; transition: all 0.2s;
}
.dm-photos-btn:hover { border-color: var(--purple); color: var(--purple); }

/* ── DM + Admin textarea inputs ── */
#dmInput, #adminMessageInput {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 14px; font-family: inherit;
  resize: none; max-height: 120px; line-height: 1.5; padding: 6px 0;
}
#dmInput::placeholder, #adminMessageInput::placeholder { color: var(--text3); }

/* ── Admin Chat Pane (user side) ── */
#adminChatPane { display: none; flex-direction: column; flex: 1; overflow: hidden; }
#adminMessagesContainer {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column;
  background: radial-gradient(ellipse at top left, rgba(139,92,246,0.04) 0%, transparent 60%),
              radial-gradient(ellipse at bottom right, rgba(59,130,246,0.04) 0%, transparent 60%);
}
[data-theme="light"] #adminMessagesContainer {
  background: radial-gradient(ellipse at top left, rgba(139,92,246,0.03) 0%, transparent 60%);
}
#adminMessagesList .message.assistant .msg-avatar {
  background: linear-gradient(135deg, var(--orange), var(--red));
}
#adminMessagesList .message.assistant .msg-bubble {
  background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2);
  color: var(--text); border-bottom-left-radius: 4px;
}
[data-theme="light"] #adminMessagesList .message.assistant .msg-bubble {
  background: rgba(245,158,11,0.07); border-color: rgba(245,158,11,0.18);
}
#adminWelcomeScreen .welcome-icon {
  font-size: 48px;
  background: linear-gradient(135deg, var(--orange), var(--red));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 20px rgba(245,158,11,0.4));
}
#adminWelcomeScreen .welcome-orb { background: linear-gradient(135deg, var(--orange), var(--red)); }

/* DM messages area */
#dmMessages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }

/* ── Code Blocks (Prism) ── */
.code-block {
  margin: 10px 0; border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(139,92,246,0.25); background: #0d1117;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
[data-theme="light"] .code-block { background: #1e1e2e; border-color: rgba(139,92,246,0.2); }
.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: rgba(139,92,246,0.12);
  border-bottom: 1px solid rgba(139,92,246,0.2);
}
.code-lang {
  font-size: 11px; font-weight: 700; color: #a78bfa;
  text-transform: uppercase; letter-spacing: 1px;
  display: flex; align-items: center; gap: 6px;
}
.code-lang::before {
  content: '';
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--purple); display: inline-block;
  box-shadow: 0 0 6px var(--purple);
}
.code-copy-btn {
  background: rgba(139,92,246,0.15); border: 1px solid rgba(139,92,246,0.3);
  color: #a78bfa; border-radius: 6px;
  padding: 4px 10px; font-size: 11px; cursor: pointer; font-family: inherit;
  transition: all 0.2s; display: flex; align-items: center; gap: 5px;
  font-weight: 500;
}
.code-copy-btn:hover { background: rgba(139,92,246,0.3); border-color: var(--purple); color: #fff; transform: scale(1.03); }
.code-copy-btn:active { transform: scale(0.97); }
.code-block pre[class*="language-"] {
  margin: 0; padding: 16px; background: transparent !important;
  font-size: 13px; line-height: 1.65; overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.code-block code[class*="language-"] { background: none; padding: 0; font-size: 13px; }
.inline-code {
  background: rgba(139,92,246,0.15); color: #c4b5fd;
  padding: 2px 7px; border-radius: 5px; font-size: 0.9em;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid rgba(139,92,246,0.2);
}

/* mobile code block scroll */
@media (max-width: 768px) {
  .code-block pre[class*="language-"] { font-size: 12px; padding: 12px; }
  .msg-content { max-width: 92%; }
  .msg-bubble { font-size: 13px; padding: 9px 12px; }
  .code-block { margin: 6px 0; border-radius: 10px; }
  .chat-mode-toggle { padding: 8px 10px 0; gap: 4px; }
  .mode-btn { padding: 7px 8px; font-size: 11px; gap: 4px; }
  .mode-btn i { font-size: 12px; }
}
