@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

:root {
  --bg: #0D1117;
  --surface: #10141a;
  --charcoal: #161B22;
  --surface-high: #262a31;
  --surface-bright: #353940;
  --primary: #c3f5ff;
  --primary-container: #00e5ff;
  --status-cyan: #2DD4BF;
  --secondary: #d2bbff;
  --secondary-container: #6001d1;
  --tertiary: #ffeac0;
  --error: #ffb4ab;
  --red: #ef4444;
  --green: #10b981;
  --gold: #fec931;
  --text: #dfe2eb;
  --text2: #94A3B8;
  --text3: #64748b;
  --border: rgba(248, 250, 252, 0.1);
  --border2: rgba(248, 250, 252, 0.08);
  --outline: #3b494c;
  --font: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --radius: 12px;
  --sidebar-width: 280px;
}

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

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Prevent Safari Auto-Zoom on Input Focus across all mobile screens */
@media (max-width: 1023px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-bright); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* Utilities */
.glass-panel {
  background: rgba(22, 27, 34, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
}

.glass-card {
  background: rgba(22, 27, 34, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border2);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* Layout */
#app {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: rgba(16, 20, 26, 0.8);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 50;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.tool-menu-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
  text-align: left;
}

.tool-menu-btn:hover { background: var(--surface-high); }

.history {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.hist-item {
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text2);
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}

.hist-item:hover {
  background: var(--surface-high);
  color: var(--text);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 40;
  display: none;
  pointer-events: none;
}
.overlay.open,
.overlay[style*="display: block"],
.overlay[style*="display: flex"] {
  display: block;
  pointer-events: auto;
}
.overlay[style*="display: none"] {
  display: none !important;
  pointer-events: none !important;
}

/* Topbar */
.topbar {
  height: 60px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

/* Chat Container & Views */
#chat-view, .chat-view {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  width: 100%;
}

#chat, .chat {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  width: 100%;
}

.msg {
  display: flex;
  width: 100%;
  max-width: 800px;
  gap: 16px;
  animation: fadeUp 0.3s ease-out forwards;
}

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

.msg.user { flex-direction: row-reverse; }

.msg-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 85%;
}

.msg.user .msg-body {
  align-items: flex-end;
}

.msg-from {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}

.msg.user .msg-from {
  text-align: right;
  color: var(--status-cyan);
}

.bubble {
  padding: 14px 18px;
  font-size: 15px;
  line-height: 1.6;
  border-radius: 16px;
  max-width: 100%;
  word-wrap: break-word;
}

.msg.ai .bubble {
  background: rgba(22, 27, 34, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary-container);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.msg.user .bubble {
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-bottom-right-radius: 4px;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.msg.user .bubble * {
  color: #ffffff;
}

.av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.av.ai {
  background: linear-gradient(135deg, #00e5ff, #2DD4BF);
  color: #0d1117;
}

.av.u {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Input Area */
.input-area {
  padding: 20px;
  display: flex;
  justify-content: center;
  background: linear-gradient(transparent, var(--bg) 80%);
}

.input-box {
  width: 100%;
  max-width: 800px;
  background: rgba(22, 27, 34, 0.75);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.input-box:focus-within {
  border-color: var(--primary-container);
  background: rgba(26, 32, 40, 0.9);
}

@keyframes processPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 229, 255, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(0, 229, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 229, 255, 0); }
}

.input-box.processing {
  animation: processPulse 2s infinite;
  border-color: var(--primary-container);
}

.input-box textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  resize: none;
  outline: none;
  max-height: 120px;
}

/* Auth Screens & Modals */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: none;
}
.auth-overlay.open,
.auth-overlay.show,
.auth-overlay[style*="display: flex"],
.auth-overlay[style*="display: block"] {
  display: flex;
  pointer-events: auto;
}
.auth-overlay[style*="display: none"] {
  display: none !important;
  pointer-events: none !important;
}

.auth-box {
  background: rgba(14, 20, 32, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 28px;
  padding: 32px 24px;
  width: 100%;
  max-width: 440px;
  margin: auto 0;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 242, 254, 0.15);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
  position: relative;
  z-index: 10001;
  pointer-events: auto !important;
}

.auth-box:hover {
  border-color: rgba(0, 242, 254, 0.55);
  box-shadow: 0 35px 100px rgba(0, 0, 0, 0.8), 0 0 50px rgba(0, 242, 254, 0.25), inset 0 0 30px rgba(56, 189, 248, 0.18);
}

.admin-box { max-width: 800px; padding: 0; }
.admin-head {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-close {
  background: transparent; border: none; color: var(--text2); cursor: pointer; font-size: 20px;
}

.auth-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 16px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
}
.auth-tab.active { color: #030712; background: linear-gradient(135deg, #00e5ff, #3b82f6); box-shadow: 0 0 15px rgba(0, 229, 255, 0.4); }

.auth-field { margin-bottom: 18px; }
.auth-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.auth-field input, .auth-field select {
  width: 100%;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 12px 16px;
  border-radius: 14px;
  color: #ffffff;
  font-size: 16px !important;
  outline: none;
  pointer-events: auto !important;
  touch-action: manipulation;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.auth-field input:focus, .auth-field select:focus {
  border-color: #00e5ff;
  background: rgba(0, 0, 0, 0.65);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
}
.auth-field select option { background: #0d1117; color: #ffffff; }

.auth-btn, .admin-btn {
  background: linear-gradient(135deg, #00e5ff, #3b82f6);
  color: #030712;
  border: none;
  padding: 14px 24px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  width: 100%;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.35);
}
.auth-btn:hover, .admin-btn:hover { transform: translateY(-1px); box-shadow: 0 0 30px rgba(0, 229, 255, 0.6); opacity: 0.98; }
.admin-btn { width: auto; background: var(--surface-high); color: var(--text); }

.auth-err {
  background: rgba(239, 68, 68, 0.2);
  color: var(--error);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  display: none;
}
.auth-err.show { display: block; }

/* Badges */
.badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-high);
}

/* Notebook Pane */
.notebook-pane {
  position: fixed;
  right: 20px;
  top: 80px;
  bottom: 100px;
  width: 400px;
  background: rgba(22, 27, 34, 0.85);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 20px;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  z-index: 40;
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
}
.notebook-pane.open { transform: translateX(0); }

/* Mode selector */
.mode-popup-menu {
  position: absolute;
  background: rgba(22, 27, 34, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
}
.mode-popup-menu.show { display: flex; }

.mode-item {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text2);
}
.mode-item:hover, .mode-item.active {
  background: var(--surface-high);
  color: var(--text);
}

/* Mobile Bottom Nav */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 60;
  justify-content: space-around;
  align-items: center;
}
.nav-item {
  background: transparent;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.nav-item.active { color: var(--primary-container); }

/* Typing indicator */
.typing { display: flex; gap: 4px; padding: 12px 18px; align-items: center; }
.pulse-dot { width: 6px; height: 6px; background: var(--text2); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
.pulse-dot:nth-child(1) { animation-delay: -0.32s; }
.pulse-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* Token Bars & Misc */
.token-bar { background: var(--surface-high); height: 4px; border-radius: 2px; overflow: hidden; margin-top: 8px; }
.token-fill { background: var(--primary-container); height: 100%; width: 50%; }

.offline-banner {
  background: var(--red); color: white; text-align: center; padding: 8px; font-size: 14px; display: none;
}
.offline-banner.show { display: block; }

/* Welcome */
.orb { width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, var(--primary-container), var(--secondary-container)); animation: orbit 4s linear infinite; }
@keyframes orbit { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .sidebar { width: 240px; }
}

@media (max-width: 768px) {
  .sidebar { position: fixed; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .bottom-nav { display: flex; }
  .notebook-pane {
    width: 100%; right: 0; bottom: 60px; top: auto; height: 70vh; border-radius: 20px 20px 0 0; transform: translateY(100%);
  }
  .notebook-pane.open { transform: translateY(0); }
  .chat { padding-bottom: 120px; }
}
/* ══════════════════════════════════════════════════════════════
   ULTIMATE LIQUID GLASS UI ENGINE — MOBILE & LAPTOP RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
.glass-panel, .glass-card, .liquid-glass-card {
  background: rgba(22, 27, 38, 0.55);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45), 
              inset 0 1px 0 0 rgba(255, 255, 255, 0.18), 
              inset 0 -1px 0 0 rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-panel::before, .glass-card::before, .liquid-glass-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(500px circle at var(--mouse-x, -500px) var(--mouse-y, -500px), rgba(255, 255, 255, 0.08), transparent 45%);
  pointer-events: none;
  z-index: 1;
  border-radius: inherit;
}

.glass-panel > *, .glass-card > *, .liquid-glass-card > * {
  position: relative;
  z-index: 2;
}

.glass-card-hover {
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-card-hover:hover {
  background: rgba(32, 40, 56, 0.65);
  border-color: rgba(78, 222, 163, 0.45);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 
              0 0 24px rgba(78, 222, 163, 0.2), 
              inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.light-leak::after {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.09) 0%, rgba(255, 255, 255, 0.01) 40%, transparent 70%);
  pointer-events: none;
  border-radius: inherit;
}

.glass-pill {
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9999px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.glass-btn {
  background: linear-gradient(135deg, rgba(78, 222, 163, 0.25) 0%, rgba(56, 189, 248, 0.2) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(78, 222, 163, 0.45);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  color: var(--on-surface);
  font-weight: 600;
  border-radius: 0.75rem;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-btn:hover {
  background: linear-gradient(135deg, rgba(78, 222, 163, 0.4) 0%, rgba(56, 189, 248, 0.35) 100%);
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.glass-btn:active {
  transform: translateY(0) scale(0.98);
}

/* Liquid Mesh Animated Glow Background */
.aurora-bg {
  position: fixed;
  inset: -50%;
  z-index: -1;
  background: radial-gradient(circle at 30% 20%, rgba(16, 185, 129, 0.12), transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(56, 189, 248, 0.1), transparent 50%),
              radial-gradient(circle at 50% 50%, rgba(167, 139, 250, 0.08), transparent 60%);
  animation: fluid 18s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
  opacity: 1;
}

/* Glass Inputs & Interactive focus states */
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(78, 222, 163, 0.25), 0 4px 20px rgba(0, 0, 0, 0.3) !important;
}

/* Mobile glass touch optimization */
@media (max-width: 768px) {
  .glass-panel, .glass-card {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
  }
}

/* Modal Positioning Fixes */
#auth-screen {
    position: fixed;
    inset: 0;
    min-height: 100vh;
    min-height: 100dvh;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: transparent;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px 16px;
    pointer-events: auto !important;
}
#auth-screen[style*="display: none"] {
    display: none !important;
    pointer-events: none !important;
}

#admin-panel, #local-ai-panel, #admin-chat-modal {
    display: none;
    position: fixed;
    inset: 0;
    min-height: 100vh;
    z-index: 200;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

#admin-panel.open, #local-ai-panel.open, #admin-chat-modal.open, #admin-chat-modal.show,
#admin-panel[style*="display: flex"], #local-ai-panel[style*="display: flex"], #admin-chat-modal[style*="display: flex"],
#admin-panel[style*="display: block"], #local-ai-panel[style*="display: block"], #admin-chat-modal[style*="display: block"] {
    display: flex;
    pointer-events: auto;
}

#admin-panel[style*="display: none"], #local-ai-panel[style*="display: none"], #admin-chat-modal[style*="display: none"] {
    display: none !important;
    pointer-events: none !important;
}

/* OFFLINE PROMPT MODAL & OTHER OVERLAYS */
#offline-prompt-modal {
    display: none;
    pointer-events: none;
}
#offline-prompt-modal.open, #offline-prompt-modal.show,
#offline-prompt-modal[style*="display: flex"], #offline-prompt-modal[style*="display: block"] {
    display: flex;
    pointer-events: auto;
}
#offline-prompt-modal[style*="display: none"] {
    display: none !important;
    pointer-events: none !important;
}

/* OFFLINE BANNER */
#offline-banner {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 300;
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.15), rgba(201, 168, 76, 0.1));
    border-bottom: 1px solid rgba(251, 146, 60, 0.3);
    text-align: center;
    font-size: 12px;
    color: #fb923c;
    letter-spacing: 0.04em;
    backdrop-filter: blur(12px);
}
#offline-banner.show {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
#offline-banner.show ~ #auth-screen, #offline-banner.show ~ #app {
    padding-top: 40px;
}

/* WEBLLM LOADING OVERLAY */
#webllm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    min-height: 100vh;
    z-index: 250;
    background: rgba(2, 4, 10, 0.92);
    backdrop-filter: blur(12px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    pointer-events: none;
}
#webllm-overlay.show, #webllm-overlay.open,
#webllm-overlay[style*="display: flex"], #webllm-overlay[style*="display: block"] {
    display: flex;
    pointer-events: auto;
}
#webllm-overlay[style*="display: none"] {
    display: none !important;
    pointer-events: none !important;
}

/* Welcome View & Input Box Fixes */
#welcome {
  width: 100% !important;
  max-width: 800px !important;
  margin: 0 auto !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px 0 !important;
}

#welcome .grid {
  width: 100% !important;
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
  gap: 16px !important;
}

.input-box {
  width: 100%;
  max-width: 800px;
  background: rgba(22, 27, 34, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 8px 14px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  transition: all 0.3s;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

/* MOBILE SIDEBAR & SCALING FIXES */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99;
}
#overlay.open, #overlay.show {
  display: block !important;
}

@media (max-width: 768px) {
  #sidebar {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    max-width: 85vw !important;
    z-index: 100 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.6) !important;
  }
  #sidebar.open, #sidebar.show {
    transform: translateX(0) !important;
  }
  
  #chat {
    padding: 12px 8px !important;
    gap: 16px !important;
  }
  
  .input-box {
    border-radius: 20px !important;
    padding: 6px 10px !important;
  }
  
  input, textarea, select {
    font-size: 16px !important; /* Prevents iOS auto-zoom */
  }
  
  #welcome h1 {
    font-size: 24px !important;
  }
  #welcome p {
    font-size: 13px !important;
  }
  .cards {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
}

/* CLEAN INPUT PILL & ZERO TEXTAREA OUTLINE FIX */
#inp, #inp:focus, #inp:active {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  -webkit-tap-highlight-color: transparent !important;
}

.input-box {
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.input-box:focus-within {
  border-color: rgba(0, 229, 255, 0.4) !important;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.15), 0 12px 40px rgba(0, 0, 0, 0.6) !important;
}

/* RESPONSIVE MOBILE SCALING FOR INPUT BAR & CHAT */
@media (max-width: 768px) {
  .input-box {
    border-radius: 24px !important;
    padding: 4px 8px !important;
    gap: 4px !important;
  }
  #inp {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom */
    min-height: 36px !important;
  }
  #sendbtn {
    width: 34px !important;
    height: 34px !important;
  }
  #chat {
    padding: 10px 8px !important;
  }
}

/* WELCOME INTRO ULTRA-COMPACT SLIM PILLS */
.welcome {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  width: 100% !important;
  max-width: 600px !important;
  margin: 0 auto !important;
  padding: 12px 12px !important;
}

.orb-wrap {
  margin-bottom: 8px;
}

.orb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00e5ff, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
  animation: orbPulse 3s infinite ease-in-out;
}

@keyframes orbPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(0, 229, 255, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 30px rgba(0, 229, 255, 0.6); }
}

.welcome h1 {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.welcome p {
  font-size: 13px;
  color: #94a3b8;
  max-width: 420px;
  line-height: 1.4;
  margin-bottom: 16px;
}

.cards {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: center !important;
  gap: 8px !important;
  width: 100% !important;
  max-width: 540px !important;
}

.card {
  background: rgba(15, 23, 42, 0.65) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 9999px !important;
  padding: 6px 14px !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  text-align: left !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
}

.card:hover {
  background: rgba(30, 41, 59, 0.85) !important;
  border-color: rgba(0, 229, 255, 0.4) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), 0 0 15px rgba(0, 229, 255, 0.2) !important;
}

.card-icon {
  font-size: 14px;
  margin: 0;
  display: inline-block;
}

.card-title {
  font-size: 12px;
  font-weight: 500;
  color: #e2e8f0;
  margin: 0;
  white-space: nowrap;
}

.card-sub {
  display: none !important;
}

@media (max-width: 640px) {
  .cards {
    gap: 6px !important;
  }
  .card {
    padding: 5px 12px !important;
  }
  .card-title {
    font-size: 11px !important;
  }
}

/* LIFT INPUT CONTAINER ABOVE MOBILE FIXED BOTTOM NAV BAR */
@media (max-width: 768px) {
  #chat-view > div:last-child {
    padding-bottom: 80px !important;
  }
}

/* AUDIO WAVEFORM VISUALIZER ANIMATION */
@keyframes waveAnim {
  0%, 100% { height: 8px; transform: scaleY(0.5); }
  50% { height: 22px; transform: scaleY(1.2); }
}

.animate-wave1 { animation: waveAnim 0.8s infinite ease-in-out; }
.animate-wave2 { animation: waveAnim 0.6s infinite ease-in-out 0.15s; }
.animate-wave3 { animation: waveAnim 0.9s infinite ease-in-out 0.3s; }
.animate-wave4 { animation: waveAnim 0.7s infinite ease-in-out 0.45s; }

#voice-status.show {
  display: flex !important;
  animation: voicePulseIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

@keyframes voicePulseIn {
  from { opacity: 0; transform: translateY(6px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Mobile Touch & Viewport Optimizations */
@media (max-width: 640px) {
  #auth-screen {
    padding: 16px 12px;
    justify-content: flex-start;
  }
  .auth-box {
    padding: 24px 18px;
    border-radius: 20px;
    max-width: 100%;
    margin-top: 10px;
  }
  .auth-logo h1 {
    font-size: 24px !important;
  }
  .auth-field input, .auth-field select {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom on input focus */
    padding: 12px 14px;
    border-radius: 12px;
  }
  .auth-btn {
    padding: 13px 18px;
    font-size: 14px;
    border-radius: 12px;
  }
}

/* ─── MATERIAL SYMBOLS & SIDEBAR ICON ALIGNMENT FIX ───────────────────────── */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined' !important;
  font-weight: normal !important;
  font-style: normal !important;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga' 1;
  -webkit-font-feature-settings: 'liga' 1;
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
  flex-shrink: 0;
}

#sidebar nav button {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  white-space: nowrap !important;
  padding: 10px 14px !important;
}

#sidebar nav button span.material-symbols-outlined {
  font-size: 20px !important;
  width: 20px !important;
  height: 20px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* ==========================================================================
   👑 ARIA QUANTUM ADMIN COMMAND DECK (APPLE-GRADE LIQUID GLASSMORPHISM)
   ========================================================================== */

.admin-command-modal {
  max-width: 1280px !important;
  width: 96% !important;
  max-height: 92vh !important;
  background: radial-gradient(circle at 10% 0%, rgba(56, 189, 248, 0.08) 0%, transparent 45%),
              radial-gradient(circle at 90% 100%, rgba(168, 85, 247, 0.08) 0%, transparent 45%),
              rgba(10, 14, 22, 0.94) !important;
  backdrop-filter: blur(40px) saturate(200%) !important;
  -webkit-backdrop-filter: blur(40px) saturate(200%) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.85), 0 0 60px rgba(56, 189, 248, 0.12) !important;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-command-modal.is-expanded {
  max-width: 98vw !important;
  width: 98vw !important;
  max-height: 98vh !important;
  height: 98vh !important;
  border-radius: 20px !important;
}

/* Tab Navigation */
.admin-nav-tabs {
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  padding: 6px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-nav-tabs::-webkit-scrollbar { display: none; }

.admin-nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(226, 232, 240, 0.7);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.admin-nav-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}
.admin-nav-tab.active {
  color: #030712;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
  font-weight: 700;
}

/* Metric Cards with Neon Hover Glow */
.admin-stat-card {
  position: relative;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.admin-stat-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4), 0 0 24px rgba(56, 189, 248, 0.15);
}
.admin-stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
}
.admin-stat-card.cyan::before { background: linear-gradient(90deg, #38bdf8, #06b6d4); }
.admin-stat-card.emerald::before { background: linear-gradient(90deg, #10b981, #34d399); }
.admin-stat-card.purple::before { background: linear-gradient(90deg, #a855f7, #c084fc); }
.admin-stat-card.amber::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.admin-stat-card.rose::before { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.admin-stat-card.indigo::before { background: linear-gradient(90deg, #6366f1, #818cf8); }

/* Filter Chips */
.admin-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.2s ease;
}
.admin-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.admin-chip.active {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

/* User Luxury Table */
.admin-user-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.3);
}
.admin-user-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}
.admin-user-table th {
  padding: 14px 16px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}
.admin-user-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}
.admin-user-table tbody tr {
  transition: background 0.15s ease;
}
.admin-user-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* Scholar Avatar & Info */
.admin-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

/* Quota Mini Bar */
.admin-quota-track {
  width: 100%;
  min-width: 110px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}
.admin-quota-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.admin-quota-bar.normal { background: linear-gradient(90deg, #10b981, #34d399); }
.admin-quota-bar.warning { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.admin-quota-bar.critical { background: linear-gradient(90deg, #ef4444, #f87171); }

/* Table Action Buttons Suite */
.tbl-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
.tbl-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.tbl-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.2);
}
.tbl-btn.chats {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}
.tbl-btn.boost {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}
.tbl-btn.pro {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.3);
}
.tbl-btn.reset {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}
.tbl-btn.ban {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}
.tbl-btn.unban {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.4);
}
.tbl-btn.del {
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  border-color: rgba(255, 255, 255, 0.1);
}
.tbl-btn.del:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

/* User Card Grid View */
.admin-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.admin-user-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.admin-user-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(56, 189, 248, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Node Health Card */
.admin-node-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

