@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Orbitron:wght@400;500;600;700;900&family=Rajdhani:wght@300;400;500;600;700&family=Fira+Code:wght@400;500&family=Share+Tech+Mono&display=swap');

/* ═══ DARK THEME (Default — Clean Black) ═══ */
:root, [data-theme="dark"] {
  --void: #0a0a0a;
  --abyss: #111111;
  --deep: #181818;
  --surface: #1e1e1e;
  --elevated: #252525;
  --border: #333333;
  --text-primary: #f0f0f0;
  --text-secondary: #999999;
  --text-dim: #666666;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-subtle: rgba(59, 130, 246, 0.12);
  --accent-dim: rgba(59, 130, 246, 0.06);
  --neon-cyan: #3b82f6;
  --neon-magenta: #6366f1;
  --neon-green: #22c55e;
  --neon-amber: #f59e0b;
  --neon-red: #ef4444;
  --neon-blue: #3b82f6;
  --neon-cyan-glow: 0 0 8px rgba(59, 130, 246, 0.2);
  --neon-magenta-glow: 0 0 8px rgba(99, 102, 241, 0.2);
  --neon-green-glow: 0 0 8px rgba(34, 197, 94, 0.2);
  --font-display: 'Orbitron', monospace;
  --font-body: 'Inter', 'Segoe UI', -apple-system, sans-serif;
  --font-mono: 'Fira Code', 'Consolas', monospace;
  --radius: 8px;
  --dock-height: 72px;
  --topbar-height: 36px;
  --chat-user-bg: #0d1117;
  --chat-ai-bg: #161616;
  --panel-bg: #111111;
  --input-bg: #0f0f0f;
  --glass-bg: #121212;
  --glass-border: #2a2a2a;
}

/* ═══ LIGHT THEME (Clean White) ═══ */
[data-theme="light"] {
  --void: #ffffff;
  --abyss: #f7f7f7;
  --deep: #ffffff;
  --surface: #fafafa;
  --elevated: #ffffff;
  --border: #e0e0e0;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-dim: #999999;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-subtle: rgba(37, 99, 235, 0.08);
  --accent-dim: rgba(37, 99, 235, 0.04);
  --neon-cyan: #2563eb;
  --neon-magenta: #4f46e5;
  --neon-green: #16a34a;
  --neon-amber: #d97706;
  --neon-red: #dc2626;
  --neon-blue: #2563eb;
  --neon-cyan-glow: none;
  --neon-magenta-glow: none;
  --neon-green-glow: none;
  --chat-user-bg: #f0f4ff;
  --chat-ai-bg: #ffffff;
  --panel-bg: #fafafa;
  --input-bg: #ffffff;
  --glass-bg: #fcfcfc;
  --glass-border: #e0e0e0;
}

/* Light theme overrides — use ID selectors to beat dark defaults */
[data-theme="light"] #topbar { background: rgba(255, 255, 255, 0.97) !important; border-bottom: 1px solid #e0e0e0 !important; }
[data-theme="light"] #dock { background: rgba(255, 255, 255, 0.97) !important; border: 1px solid #e0e0e0 !important; box-shadow: 0 4px 24px rgba(0,0,0,0.08) !important; }
[data-theme="light"] .dock-item { background: rgba(0, 0, 0, 0.02); }
[data-theme="light"] .dock-item:hover { background: rgba(37, 99, 235, 0.06); border-color: rgba(37, 99, 235, 0.15); box-shadow: 0 4px 16px rgba(37, 99, 235, 0.1); }
[data-theme="light"] .dock-item .icon { filter: none; }
[data-theme="light"] .app-window { background: rgba(255, 255, 255, 0.98) !important; border-color: #e0e0e0 !important; box-shadow: 0 8px 40px rgba(0,0,0,0.1) !important; }
[data-theme="light"] .app-window.focused { border-color: rgba(37, 99, 235, 0.3) !important; box-shadow: 0 12px 48px rgba(0,0,0,0.12) !important; }
[data-theme="light"] .window-titlebar { background: #fafafa !important; border-bottom: 1px solid #e0e0e0 !important; }
[data-theme="light"] .chat-msg.ai { background: #ffffff; border-color: #e8e8e8; }
[data-theme="light"] .chat-msg.user { background: rgba(37, 99, 235, 0.04); }
[data-theme="light"] .chat-input { background: #ffffff !important; border-color: #e0e0e0 !important; color: #1a1a1a !important; }
[data-theme="light"] .smart-panel { background: #fafafa !important; border-color: #e0e0e0 !important; }
[data-theme="light"] #context-menu { background: #ffffff !important; border-color: #e0e0e0 !important; }
[data-theme="light"] .ctx-item:hover { background: rgba(37, 99, 235, 0.06); }
[data-theme="light"] .notification { background: #ffffff; border-color: #e0e0e0; }
[data-theme="light"] .boot-logo { color: #2563eb; }
[data-theme="light"] ::selection { background: #2563eb; color: white; }
[data-theme="light"] .chat-action-btn { background: #f5f5f5; border-color: #e0e0e0; color: #666666; }
[data-theme="light"] .chat-action-btn:hover { background: rgba(37, 99, 235, 0.08); color: #2563eb; border-color: #2563eb; }
[data-theme="light"] .chat-copy-btn { background: #f5f5f5; border-color: #e0e0e0; color: #666666; }
[data-theme="light"] .chat-translate-chip { background: #f5f5f5; border-color: #e0e0e0; color: #2563eb; }
[data-theme="light"] .chat-context-chain { background: #f9f9f9; border-color: #e0e0e0; }
[data-theme="light"] .chat-context-chain .chain-topic { color: #2563eb; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #d0d0d0; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #2563eb; }
[data-theme="light"] .desktop-widgets { color: #1a1a1a; }
[data-theme="light"] .lock-container { background: #ffffff !important; }
[data-theme="light"] .dock-user-dropdown { background: #ffffff !important; border-color: #e0e0e0 !important; }
[data-theme="light"] .sp-resize-handle { background: #e0e0e0 !important; }
[data-theme="light"] .login-container { background: rgba(255,255,255,0.97); }
[data-theme="light"] .window-content { background: #ffffff !important; }
[data-theme="light"] .chat-container { background: #ffffff !important; }
[data-theme="light"] .chat-body { background: #fafafa !important; }
[data-theme="light"] .dock-tooltip { background: #1a1a1a !important; color: #ffffff !important; }
[data-theme="light"] .titlebar-title { color: #1a1a1a !important; }
[data-theme="light"] .titlebar-btn:hover { background: rgba(0,0,0,0.06) !important; }
[data-theme="light"] .topbar-left, [data-theme="light"] .topbar-right { color: #1a1a1a; }
[data-theme="light"] #topbar-clock { color: #1a1a1a !important; }

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--void);
  color: var(--text-primary);
  cursor: default;
  user-select: none;
  -webkit-app-region: no-drag;
}

::selection { background: var(--neon-cyan); color: var(--void); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--neon-cyan); }

/* ═══════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════ */
/* ═══ LOGIN SCREEN — Professional Green/White Theme ═══ */
#login-screen, #register-screen {
  position: fixed; inset: 0; z-index: 10001;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 30%, #2563eb 60%, #1d4ed8 100%);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#login-screen.hidden, #register-screen.hidden {
  opacity: 0; visibility: hidden; pointer-events: none;
}
.login-bg-grid {
  position: absolute; inset: 0; z-index: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.06) 0%, transparent 50%);
}
@keyframes loginGridMove {
  0% { transform: translate(0, 0); }
  100% { transform: translate(40px, 40px); }
}
.login-container {
  position: relative; z-index: 1;
  width: 400px; padding: 48px 40px;
  background: #ffffff;
  border: none;
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2), 0 4px 20px rgba(0,0,0,0.08);
}
.login-logo-img {
  display: block;
  margin: 0 auto 12px auto;
  width: 80px; height: 80px;
  object-fit: contain;
  border-radius: 16px;
  filter: drop-shadow(0 4px 12px rgba(37, 99, 235, 0.2));
}
.login-logo {
  font-family: 'Mukta', 'Noto Sans Devanagari', var(--font-display), sans-serif;
  font-size: 26px; font-weight: 800;
  letter-spacing: 2px; text-align: center;
  color: #1d4ed8;
  margin-bottom: 4px;
}
.login-logo span {
  color: #2563eb;
  -webkit-text-fill-color: #2563eb;
  background: none; -webkit-background-clip: unset;
}
.login-subtitle {
  font-family: var(--font-body);
  font-size: 12px; letter-spacing: 3px;
  text-align: center; color: #64748b;
  margin-bottom: 6px; text-transform: uppercase;
}
.login-version {
  font-family: var(--font-mono);
  font-size: 10px; text-align: center;
  color: #94a3b8; margin-bottom: 36px;
}
.login-field {
  margin-bottom: 16px;
}
.login-field input {
  width: 100%; padding: 14px 16px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  color: #1e293b;
  font-family: var(--font-body);
  font-size: 15px; outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  box-sizing: border-box;
}
.login-field input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  background: #fff;
}
.login-field input::placeholder {
  color: #94a3b8;
  font-family: var(--font-body);
}
.login-error {
  color: #ef4444;
  font-family: var(--font-body);
  font-size: 12px; min-height: 18px;
  margin-bottom: 12px; text-align: center;
}
.login-btn {
  width: 100%; padding: 14px;
  background: #2563eb;
  border: none; border-radius: 8px;
  color: #ffffff; font-family: var(--font-display);
  font-size: 13px; font-weight: 700;
  letter-spacing: 2px; cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.login-btn:hover { background: #1d4ed8; }
.login-btn:active { transform: scale(0.98); }
.login-btn:disabled { opacity: 0.5; cursor: wait; }
/* ═══ LOGIN SCREEN — Dark Mode ═══ */
@media (prefers-color-scheme: dark) {
  #login-screen, #register-screen {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 30%, #1d4ed8 60%, #0f172a 100%);
  }
  .login-container {
    background: #111827;
    box-shadow: 0 25px 60px rgba(0,0,0,0.5), 0 4px 20px rgba(0,0,0,0.3);
  }
  .login-logo { color: #3b82f6; }
  .login-logo span { color: #60a5fa; -webkit-text-fill-color: #60a5fa; }
  .login-subtitle { color: #9ca3af; }
  .login-version { color: #6b7280; }
  .login-field input {
    background: #1f2937;
    border-color: #374151;
    color: #f3f4f6;
  }
  .login-field input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.15);
    background: #1f2937;
  }
  .login-field input::placeholder { color: #6b7280; }
  .login-error { color: #f87171; }
  .login-btn { background: #2563eb; }
  .login-btn:hover { background: #60a5fa; }
}
.login-footer {
  text-align: center; margin-top: 24px;
  font-family: var(--font-body);
  font-size: 13px; color: #64748b;
}
.login-footer a {
  color: #2563eb;
  text-decoration: none; margin-left: 6px;
  cursor: pointer; font-weight: 500;
}
.login-footer a:hover { text-decoration: underline; color: #1d4ed8; }

.otp-sent-info {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; margin-bottom: 16px;
  padding: 12px; border: 1px solid #bfdbfe;
  border-radius: 8px; background: #eff6ff;
}
@media (prefers-color-scheme: dark) {
  .login-footer { color: #9ca3af; }
  .login-footer a { color: #3b82f6; }
  .login-footer a:hover { color: #60a5fa; }
  .otp-sent-info {
    border-color: rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
  }
  .login-field select {
    background: #1f2937 !important;
    border-color: #374151 !important;
    color: #f3f4f6 !important;
  }
}

/* ═══════════════════════════════════════════
   BOOT SEQUENCE
   ═══════════════════════════════════════════ */
#boot-screen {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--void);
  transition: opacity 0.8s ease, visibility 0.8s ease;
}
#boot-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.boot-logo-img {
  display: block;
  margin: 0 auto 16px auto;
  width: 100px; height: 100px;
  object-fit: contain;
  border-radius: 20px;
  filter: drop-shadow(0 0 20px rgba(0, 255, 255, 0.4));
  animation: bootLogoPulse 2s ease-in-out infinite;
}
@keyframes bootLogoPulse {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(0, 255, 255, 0.4)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 30px rgba(0, 255, 255, 0.7)); transform: scale(1.02); }
}
.boot-logo {
  font-family: 'Mukta', 'Noto Sans Devanagari', var(--font-display), sans-serif;
  font-size: 38px; font-weight: 800;
  letter-spacing: 4px;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  animation: bootPulse 1.5s ease-in-out infinite;
}
.boot-tagline {
  font-family: var(--font-mono);
  color: var(--neon-green);
  font-size: 13px;
  margin-top: 12px;
  letter-spacing: 3px;
  opacity: 0;
  animation: fadeIn 0.5s ease forwards 0.5s;
}
.boot-progress {
  width: 300px; height: 2px;
  background: var(--border);
  margin-top: 40px;
  border-radius: 1px;
  overflow: hidden;
}
.boot-progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta));
  box-shadow: var(--neon-cyan-glow);
  animation: bootLoad 2.5s ease forwards 0.3s;
}
.boot-status {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 16px;
  min-height: 14px;
}

@keyframes bootPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
}
@keyframes bootLoad { to { width: 100%; } }
@keyframes fadeIn { to { opacity: 1; } }

/* ═══════════════════════════════════════════
   DESKTOP BACKGROUND
   ═══════════════════════════════════════════ */
#desktop {
  position: fixed; inset: 0;
  background: var(--void);
  opacity: 0;
  transition: opacity 0.6s ease;
}
#desktop.visible { opacity: 1; }

#circuit-bg {
  position: absolute; inset: 0;
  overflow: hidden;
  opacity: 0.06;
}
#circuit-bg canvas { width: 100%; height: 100%; }

.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--neon-cyan) 1px, transparent 1px),
    linear-gradient(90deg, var(--neon-cyan) 1px, transparent 1px);
  background-size: 80px 80px;
  opacity: 0.015;
  animation: gridScroll 60s linear infinite;
}
@keyframes gridScroll {
  to { background-position: 80px 80px; }
}

.scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(59, 130, 246, 0.008) 2px, rgba(59, 130, 246, 0.008) 4px
  );
  pointer-events: none;
  z-index: 9998;
}

.vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, var(--void) 100%);
  pointer-events: none;
  z-index: 9997;
}

/* ═══════════════════════════════════════════
   TOP BAR
   ═══════════════════════════════════════════ */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: rgba(15, 15, 15, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 9000;
  -webkit-app-region: drag;
}

.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-center { display: flex; align-items: center; gap: 20px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.topbar-logo-img {
  width: 24px; height: 24px;
  object-fit: contain;
  border-radius: 6px;
  filter: drop-shadow(0 0 6px rgba(0, 255, 255, 0.3));
}
.topbar-brand {
  font-family: 'Mukta', 'Noto Sans Devanagari', var(--font-display), sans-serif;
  font-size: 13px; font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--neon-cyan);
  text-shadow: var(--neon-cyan-glow);
}
.topbar-brand span { color: var(--neon-magenta); font-family: var(--font-display), monospace; letter-spacing: 3px; }

.sys-indicator {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 5px;
}
.sys-indicator .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--neon-green);
  box-shadow: 0 0 6px var(--neon-green);
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.topbar-clock {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.topbar-btn {
  -webkit-app-region: no-drag;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.topbar-btn.minimize { background: var(--neon-amber); }
.topbar-btn.maximize { background: var(--neon-green); }
.topbar-btn.close { background: var(--neon-red); }
.topbar-btn:hover { transform: scale(1.2); filter: brightness(1.3); }

/* ═══════════════════════════════════════════
   DOCK
   ═══════════════════════════════════════════ */
#dock {
  position: fixed; bottom: 12px;
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  z-index: 9000;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.dock-item {
  position: relative;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
}
.dock-item:hover {
  transform: translateY(-8px) scale(1.15);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}
.dock-item:active { transform: translateY(-4px) scale(1.05); }

.dock-item .icon {
  font-size: 24px;
  filter: drop-shadow(0 0 4px currentColor);
}
.dock-item[data-app="chat"] .icon { color: var(--neon-cyan); }
.dock-item[data-app="files"] .icon { color: var(--neon-amber); }
.dock-item[data-app="terminal"] .icon { color: var(--neon-green); }
.dock-item[data-app="settings"] .icon { color: var(--text-secondary); }
.dock-item[data-app="appstore"] .icon { color: var(--neon-magenta); }
.dock-item[data-app="code"] .icon { color: var(--neon-blue); }
.dock-item[data-app="knowledge"] .icon { color: #b088ff; }
.dock-item[data-app="medical"] .icon { color: var(--neon-red); }

.dock-tooltip {
  position: absolute;
  top: -34px; left: 50%; transform: translateX(-50%) scale(0.8);
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 11px; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  opacity: 0; visibility: hidden;
  transition: all 0.2s;
  pointer-events: none;
}
.dock-item:hover .dock-tooltip { opacity: 1; visibility: visible; transform: translateX(-50%) scale(1); }

.dock-dot {
  position: absolute; bottom: 2px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--neon-cyan);
  box-shadow: 0 0 6px var(--neon-cyan);
  opacity: 0;
  transition: opacity 0.3s;
}
.dock-item.active .dock-dot { opacity: 1; }

/* ═══════════════════════════════════════════
   WINDOW SYSTEM
   ═══════════════════════════════════════════ */
.app-window {
  position: absolute;
  display: flex; flex-direction: column;
  min-width: 480px; min-height: 360px;
  background: rgba(15, 15, 15, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.7), 0 0 1px rgba(255, 255, 255, 0.15);
  transition: box-shadow 0.3s, opacity 0.2s, transform 0.2s;
  opacity: 0; transform: scale(0.95) translateY(10px);
}
.app-window.visible {
  opacity: 1; transform: scale(1) translateY(0);
}
.app-window.focused {
  border-color: rgba(59, 130, 246, 0.25);
  box-shadow: 0 16px 80px rgba(0, 0, 0, 0.8), 0 0 40px rgba(255, 255, 255, 0.04);
}
.app-window.minimized {
  opacity: 0; transform: scale(0.8) translateY(40px);
  pointer-events: none;
}

.window-titlebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  height: 38px;
  background: linear-gradient(180deg, rgba(25, 25, 25, 0.8), rgba(20, 20, 20, 0.8));
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: grab;
  flex-shrink: 0;
}
.window-titlebar:active { cursor: grabbing; }

.window-title {
  font-family: var(--font-display);
  font-size: 10px; font-weight: 500;
  letter-spacing: 2px;
  color: var(--text-secondary);
  text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.window-title .win-icon { font-size: 14px; }

.window-controls {
  display: flex; gap: 8px;
}
.win-ctrl {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0.6;
}
.win-ctrl:hover { opacity: 1; transform: scale(1.2); }
.win-ctrl.min { background: var(--neon-amber); }
.win-ctrl.max { background: var(--neon-green); }
.win-ctrl.cls { background: var(--neon-red); }

.window-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  position: relative;
}

.window-resize {
  position: absolute; bottom: 0; right: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
  opacity: 0.3;
}
.window-resize::after {
  content: '';
  position: absolute; bottom: 3px; right: 3px;
  width: 8px; height: 8px;
  border-right: 2px solid var(--neon-cyan);
  border-bottom: 2px solid var(--neon-cyan);
}

/* ═══════════════════════════════════════════
   APP: ALIFZETTA CHAT
   ═══════════════════════════════════════════ */
/* ═══ Chat Layout: 3-panel with Smart Panel ═══ */
.chat-layout {
  display: flex;
  height: 100%;
  gap: 0;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 12px;
  min-width: 0;
  padding: 12px 8px 12px 16px;
}

.chat-container { display: flex; flex-direction: column; height: 100%; gap: 12px; }

.chat-messages {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding-right: 4px;
}

/* ═══ vGPU Bottom Sheet ═══ */
.vgpu-sheet {
  position: fixed;
  bottom: 48px; /* above taskbar */
  right: 280px; /* offset from smart panel */
  width: 380px;
  max-height: 80vh;
  background: var(--bg-secondary, #111827);
  border: 1px solid rgba(0,255,255,0.15);
  border-radius: 12px 12px 0 0;
  z-index: 900;
  overflow: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}
.vgpu-sheet.hidden { display: none; }
.vgpu-sheet.half { display: block; max-height: 48px; overflow: hidden; }
.vgpu-sheet.full { display: block; max-height: 80vh; overflow-y: auto; }

.vgpu-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 48px;
  cursor: pointer;
  background: linear-gradient(90deg, rgba(0,255,255,0.06), rgba(139,92,246,0.06));
  font-size: 12px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  color: var(--neon-cyan, #00ffff);
  letter-spacing: 0.5px;
  user-select: none;
}
.vgpu-bar:hover { background: linear-gradient(90deg, rgba(0,255,255,0.12), rgba(139,92,246,0.12)); }
.vgpu-bar-chevron { font-size: 10px; transition: transform 0.3s; }
.vgpu-sheet.full .vgpu-bar-chevron { transform: rotate(180deg); }

.vgpu-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 8px;
}
.vgpu-tab {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim, #6b7280);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.vgpu-tab:hover { color: var(--text-primary, #e5e7eb); }
.vgpu-tab.active { color: var(--neon-cyan, #00ffff); border-bottom-color: var(--neon-cyan, #00ffff); }

.vgpu-tab-content { padding: 8px 12px; }

.vgpu-metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.vgpu-metric-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}
.vgpu-metric-value {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  color: var(--neon-cyan, #00ffff);
}
.vgpu-metric-label {
  font-size: 9px;
  color: var(--text-dim, #6b7280);
  letter-spacing: 1px;
  margin-top: 2px;
}

.vgpu-cores-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  margin-bottom: 8px;
}
.vgpu-core-cell {
  height: 10px;
  border-radius: 2px;
  background: rgba(0,255,255,0.15);
  transition: background 0.3s, opacity 0.3s;
}

.vgpu-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 10px;
}
.vgpu-progress-label {
  width: 28px;
  color: var(--text-dim, #6b7280);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 10px;
}
.vgpu-progress-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.vgpu-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--neon-cyan, #00ffff);
  transition: width 0.5s ease;
}
.vgpu-progress-fill.vgpu-progress-mem { background: var(--neon-magenta, #ff00ff); }
.vgpu-progress-pct {
  width: 36px;
  text-align: right;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  color: var(--text-dim, #6b7280);
  font-size: 10px;
}

.vgpu-train-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 10px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  color: var(--text-dim, #6b7280);
  border-top: 1px solid rgba(255,255,255,0.04);
  margin-top: 6px;
}
.vgpu-train-label { color: var(--neon-amber, #f59e0b); font-weight: 600; }

/* Pipeline Trace */
.pipeline-tier {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 11px;
  opacity: 0.3;
  transition: opacity 0.3s, background 0.3s;
}
.pipeline-tier.checking { opacity: 1; animation: pipeline-pulse 0.6s ease-in-out infinite; }
.pipeline-tier.checked { opacity: 0.4; }
.pipeline-tier.hit { opacity: 1; background: rgba(34,197,94,0.08); border-radius: 6px; }

@keyframes pipeline-pulse {
  0%, 100% { background: rgba(59,130,246,0.05); }
  50% { background: rgba(59,130,246,0.15); }
}

.pipeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim, #6b7280);
  transition: background 0.3s;
}
.pipeline-tier.checking .pipeline-dot { background: var(--neon-cyan, #3b82f6); box-shadow: 0 0 6px rgba(59,130,246,0.5); }
.pipeline-tier.checked .pipeline-dot { background: var(--text-dim, #6b7280); }
.pipeline-tier.hit .pipeline-dot { background: #22c55e; box-shadow: 0 0 8px rgba(34,197,94,0.5); }

.pipeline-name { flex: 1; }
.pipeline-tier.hit .pipeline-name { color: #22c55e; font-weight: 600; }
.pipeline-ms { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 10px; color: var(--text-dim, #6b7280); }
.pipeline-tier.hit .pipeline-ms { color: #22c55e; }

.pipeline-connector {
  width: 1px;
  height: 8px;
  margin-left: 11px; /* center under dot */
  background: rgba(255,255,255,0.08);
}

.pipeline-result-badge {
  text-align: center;
  padding: 8px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #22c55e;
  background: rgba(34,197,94,0.08);
  border-radius: 8px;
  border: 1px solid rgba(34,197,94,0.2);
}

/* ═══ Smart Panel (Right Sidebar) ═══ */
.smart-panel {
  width: 260px;
  min-width: 180px;
  max-width: 500px;
  height: 100%;
  overflow-y: auto;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
  position: relative;
  flex-shrink: 0;
  transition: none;
}

/* ═══ Smart Panel Resize Handle ═══ */
.sp-resize-handle {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.2s;
}
.sp-resize-handle:hover,
.sp-resize-handle.dragging {
  background: var(--neon-cyan);
  opacity: 0.5;
}
.sp-resize-handle::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 30px;
  border-radius: 1px;
  background: var(--text-dim);
  opacity: 0;
  transition: opacity 0.2s;
}
.sp-resize-handle:hover::after,
.sp-resize-handle.dragging::after {
  opacity: 1;
}

/* When panel is collapsed */
.smart-panel.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  border-left: none;
}
.sp-toggle-btn {
  position: absolute;
  left: -24px;
  top: 8px;
  width: 22px;
  height: 22px;
  border-radius: 4px 0 0 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 11;
}
.sp-toggle-btn:hover {
  color: var(--neon-cyan);
  background: var(--elevated);
}

.sp-header {
  font-family: 'Mukta', 'Noto Sans Devanagari', var(--font-display), sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-primary);
  padding-bottom: 8px;
  border-bottom: none;
  position: relative;
}
.sp-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta), transparent);
  border-radius: 2px;
}

.sp-stats {
  display: flex;
  gap: 6px;
}

.sp-stat {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(59, 130, 246, 0.18);
  border-radius: 6px;
  transition: all 0.2s;
}
.sp-stat:hover {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: inset 0 0 12px rgba(59, 130, 246, 0.08);
}

.sp-stat-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.sp-stat-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-top: 2px;
}

.sp-kb-status {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 6px 8px;
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 4px;
}

.sp-context {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sp-empty {
  text-align: center;
  padding: 30px 10px;
  opacity: 0.6;
}

.sp-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: 8px;
  padding: 10px;
  animation: msgIn 0.3s ease;
  transition: border-color 0.2s;
}
.sp-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
}

.sp-card-tag {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 3px 8px;
  border-radius: 3px;
  margin-bottom: 6px;
  border: 1px solid currentColor;
}

.sp-card-title {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.sp-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.sp-card-llm {
  border-color: rgba(59, 130, 246, 0.2);
}

.sp-card-kb {
  border-color: rgba(59, 130, 246, 0.2);
}

/* ═══ Smart Panel Entity Images ═══ */
.sp-card-img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.4);
}
.sp-card-img.person {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  float: right;
  margin: 0 0 6px 8px;
}

/* ═══ Rich Smart Panel Cards ═══ */
.sp-rich-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 8px;
  overflow: hidden;
  animation: msgIn 0.3s ease;
}

/* Hero image with title overlay */
.sp-card-hero {
  position: relative;
  height: 100px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.5);
}
.sp-hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sp-hero-gradient {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 60%;
  background: linear-gradient(transparent, rgba(15, 15, 15, 0.95));
}
.sp-hero-title {
  position: absolute;
  bottom: 6px; left: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
  letter-spacing: 0.5px;
}
.sp-flag-badge {
  position: absolute;
  top: 6px; right: 6px;
  width: 30px; height: auto;
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Quick facts 2-column grid */
.sp-facts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 6px;
  padding: 6px 10px;
}
.sp-fact {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.3;
}
.sp-fact b {
  color: var(--text-primary);
  display: block;
  font-size: 11px;
}

/* Sub-action buttons */
.sp-actions {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  flex-wrap: wrap;
}
.sp-action-btn {
  flex: 1;
  min-width: 55px;
  padding: 6px 6px;
  font-size: 10px;
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.18);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  white-space: nowrap;
}
.sp-action-btn:hover {
  background: rgba(59, 130, 246, 0.15);
  color: var(--neon-cyan);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.2);
}

/* Person card */
.sp-person-header {
  display: flex;
  gap: 10px;
  padding: 10px;
  align-items: center;
}
.sp-person-img {
  width: 52px; height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}
.sp-person-initials {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--neon-cyan);
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}
.sp-person-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.2;
}
.sp-person-role {
  font-size: 10px;
  color: var(--neon-cyan);
  margin-top: 2px;
}
.sp-person-org {
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 1px;
}

/* Company card */
.sp-company-header {
  display: flex;
  gap: 10px;
  padding: 10px;
  align-items: center;
}
.sp-company-logo {
  width: 42px; height: 42px;
  object-fit: contain;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  padding: 4px;
  flex-shrink: 0;
}
.sp-company-icon {
  width: 42px; height: 42px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}
.sp-company-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
}

/* Fact-check / controversy badges */
.sp-badge-row {
  display: flex;
  gap: 4px;
  padding: 4px 10px;
  flex-wrap: wrap;
}
.sp-badge-verified {
  font-size: 9px;
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 3px;
  color: var(--neon-green);
}
.sp-badge-community {
  font-size: 9px;
  padding: 2px 6px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 3px;
  color: #f59e0b;
}

/* ═══ Fullscreen Chat — hide titlebar (immersive) ═══ */
.app-window[data-maximized="true"][data-app="chat"] .window-titlebar {
  height: 0;
  overflow: hidden;
  padding: 0;
  border: none;
  opacity: 0;
  pointer-events: none;
  transition: height 0.2s, opacity 0.2s;
}
.app-window[data-maximized="true"][data-app="chat"]:hover .window-titlebar {
  height: 38px;
  padding: 0 12px;
  opacity: 1;
  pointer-events: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.app-window[data-maximized="true"][data-app="chat"] .window-body {
  padding: 0;
}
.app-window[data-maximized="true"][data-app="chat"] {
  border-radius: 0;
  border: none;
}
.app-window[data-maximized="true"][data-app="chat"] .window-resize {
  display: none;
}

.sp-source-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 3px 8px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.30);
  border-radius: 3px;
  color: var(--neon-cyan);
}

/* ═══ Suggestion Chips (interactive follow-up questions) ═══ */
.suggestion-chips-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.suggestion-chips-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.suggestion-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.suggestion-chip {
  padding: 5px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  background: transparent;
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 20px;
  color: var(--neon-cyan);
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.4;
}
.suggestion-chip:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.25);
  transform: translateY(-1px);
  color: #fff;
}

/* ═══ Chat Message Header (timestamps, badges) ═══ */
.chat-msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.chat-msg-header .sender {
  margin-bottom: 0;
}

.chat-timestamp {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
}

.chat-kb-badge {
  font-size: 10px;
  padding: 1px 5px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 3px;
  color: var(--neon-green);
  cursor: help;
}

.chat-engine-badge {
  font-size: 10px;
  padding: 1px 4px;
  cursor: help;
}

.chat-msg {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px; line-height: 1.6;
  font-family: var(--font-body);
  animation: msgIn 0.25s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } }

.chat-msg.user {
  align-self: flex-end;
  background: #1a2d47;
  border: 1px solid rgba(59, 130, 246, 0.18);
  border-radius: 14px 14px 4px 14px;
  color: #e2e8f0;
}
.chat-msg.ai {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px 14px 14px 14px;
}
.chat-msg.ai .sender {
  font-family: 'Mukta', 'Noto Sans Devanagari', var(--font-display), sans-serif;
  font-size: 10px; letter-spacing: 1.5px;
  color: var(--neon-cyan);
  margin-bottom: 4px;
  opacity: 0.85;
}

/* ═══ Enhanced Markdown Rendering ═══ */
.chat-msg-content { line-height: 1.6; font-size: 13.5px; }

/* Headers */
.chat-msg-content .md-h2 {
  margin: 12px 0 6px; font-size: 16px; color: var(--neon-cyan);
  font-weight: 700; letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1); padding-bottom: 4px;
}
.chat-msg-content .md-h3 {
  margin: 10px 0 5px; font-size: 14px; color: var(--neon-cyan);
  font-weight: 600;
}
.chat-msg-content .md-h4 {
  margin: 8px 0 4px; font-size: 13px; color: var(--neon-magenta);
  font-weight: 600;
}

/* Section headers (bold on own line — e.g., **💊 Drug Formulary: Paracetamol**) */
.chat-msg-content .md-section-header {
  margin: 10px 0 6px; font-size: 14px; font-weight: 700;
  color: var(--neon-cyan);
  padding: 4px 8px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), transparent);
  border-left: 3px solid var(--neon-cyan);
  border-radius: 0 4px 4px 0;
}

/* Bold & Italic */
.chat-msg-content .md-bold { color: var(--text-primary); font-weight: 600; }
.chat-msg-content .md-italic { color: var(--text-secondary); font-style: italic; }

/* Inline code */
.chat-msg-content .md-inline-code {
  font-family: var(--font-mono); font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px; padding: 1px 5px;
  color: var(--neon-green);
}

/* Code blocks */
.chat-msg-content .md-code-block {
  margin: 8px 0; border-radius: 6px; overflow: hidden;
  border: 1px solid rgba(59, 130, 246, 0.12);
  background: rgba(0, 0, 0, 0.3);
}
.chat-msg-content .md-code-block .md-code-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.chat-msg-content .md-code-block .md-code-lang {
  font-size: 9px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-dim);
}
.md-code-actions { display: flex; gap: 5px; }
.md-code-run-btn, .md-code-copy-btn {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.18);
  color: var(--neon-cyan);
  padding: 2px 10px; border-radius: 3px;
  cursor: pointer; font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  transition: all 0.2s;
}
.md-code-run-btn:hover { background: rgba(0, 255, 136, 0.15); color: var(--neon-green); border-color: rgba(0, 255, 136, 0.3); }
.md-code-copy-btn:hover { background: rgba(59, 130, 246, 0.2); }
.chat-msg-content .md-code-block pre {
  margin: 0; padding: 8px 10px; font-size: 12px;
  font-family: var(--font-mono); color: var(--neon-green);
  overflow-x: auto; line-height: 1.5; white-space: pre-wrap;
}

/* ═══ Code Preview Modal ═══ */
.code-preview-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 9999;
  backdrop-filter: blur(3px);
}
.code-preview-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 85vw; max-width: 960px;
  height: 72vh; max-height: 640px;
  background: var(--bg-dark, #0a0a1a);
  border: 1px solid var(--neon-cyan, #0ff);
  border-radius: 8px;
  z-index: 10000;
  display: flex; flex-direction: column;
  box-shadow: 0 0 40px rgba(0, 255, 255, 0.12), 0 8px 32px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.preview-titlebar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px;
  background: rgba(0, 255, 255, 0.06);
  border-bottom: 1px solid rgba(0, 255, 255, 0.15);
}
.preview-title {
  font-family: var(--font-mono, monospace);
  font-size: 12px; letter-spacing: 1px;
  color: var(--neon-cyan, #0ff);
}
.preview-controls { display: flex; gap: 6px; }
.preview-ctrl {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim, #888);
  width: 26px; height: 26px;
  border-radius: 4px; cursor: pointer;
  font-size: 13px; display: flex;
  align-items: center; justify-content: center;
  transition: all 0.2s;
}
.preview-ctrl:hover { background: rgba(255, 50, 50, 0.2); color: #f55; border-color: rgba(255, 50, 50, 0.3); }
.preview-body {
  flex: 1; display: flex;
  min-height: 0;
}
.preview-code-pane {
  width: 45%; display: flex; flex-direction: column;
  border-right: 1px solid rgba(0, 255, 255, 0.1);
  overflow: hidden;
}
.preview-output-pane {
  width: 55%; display: flex; flex-direction: column;
  overflow: hidden;
}
.preview-pane-label {
  font-family: var(--font-mono, monospace);
  font-size: 9px; letter-spacing: 1.5px;
  color: var(--text-dim, #888);
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.preview-source {
  flex: 1; margin: 0; padding: 12px;
  font-family: var(--font-mono, monospace);
  font-size: 12px; line-height: 1.6;
  color: var(--neon-green, #0f0);
  background: rgba(0, 0, 0, 0.3);
  overflow: auto; white-space: pre-wrap;
}
.preview-iframe {
  flex: 1; width: 100%; border: none;
  background: #fff;
}
/* Simulated output for non-web languages */
.sim-output .sim-content {
  flex: 1; padding: 16px; overflow: auto;
  background: rgba(0, 0, 0, 0.2);
}
.sim-header {
  font-family: var(--font-mono, monospace);
  font-size: 13px; font-weight: bold;
  color: var(--neon-cyan, #0ff);
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.1);
}
.sim-line {
  font-family: var(--font-mono, monospace);
  font-size: 12px; color: var(--neon-green, #0f0);
  padding: 4px 10px; margin: 3px 0;
  border-left: 3px solid rgba(0, 255, 136, 0.4);
  background: rgba(0, 255, 136, 0.04);
}
.sim-info {
  font-family: var(--font-mono, monospace);
  font-size: 11px; color: var(--text-dim, #888);
  padding: 4px 10px; margin: 4px 0;
}
.sim-table table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-mono, monospace); font-size: 11px;
  margin-top: 8px;
}
.sim-table th {
  background: rgba(0, 255, 255, 0.08);
  color: var(--neon-cyan, #0ff);
  padding: 6px 10px; text-align: left;
  border: 1px solid rgba(0, 255, 255, 0.1);
}
.sim-table td {
  padding: 5px 10px; color: var(--text-dim, #ccc);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Bullet & numbered lists */
.chat-msg-content .md-list-item {
  padding: 3px 0 3px 18px; position: relative;
  border-left: 2px solid rgba(255, 255, 255, 0.06);
  margin-left: 4px;
}
.chat-msg-content .md-list-item .md-bullet {
  position: absolute; left: 5px; top: 3px;
  color: var(--neon-cyan); font-size: 12px;
}
.chat-msg-content .md-list-item.md-numbered {
  border-left-color: rgba(255, 255, 255, 0.1);
}
.chat-msg-content .md-list-item .md-list-num {
  position: absolute; left: 2px; top: 3px;
  color: var(--neon-cyan); font-size: 12px; font-weight: 600;
  font-family: var(--font-mono);
}

/* Blockquotes */
.chat-msg-content .md-blockquote {
  margin: 6px 0; padding: 6px 12px;
  border-left: 3px solid var(--neon-magenta);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary); font-style: italic;
  border-radius: 0 4px 4px 0;
}

/* Links */
.chat-msg-content .md-link {
  color: var(--neon-cyan); text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  transition: color 0.2s, border-color 0.2s;
}
.chat-msg-content .md-link:hover {
  color: var(--neon-magenta);
  border-bottom-color: var(--neon-magenta);
}

/* Horizontal rule */
.chat-msg-content .md-hr {
  border: none; border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 10px 0;
}

/* Source attribution */
.chat-msg-content .md-source {
  margin-top: 10px; padding: 5px 8px; font-size: 11px;
  color: var(--text-dim); background: rgba(0, 0, 0, 0.2);
  border-radius: 4px; border-left: 2px solid rgba(255, 255, 255, 0.12);
}
.chat-msg-content .md-source .md-link { font-size: 11px; }

/* Medical disclaimer */
.chat-msg-content .md-disclaimer {
  margin-top: 8px; padding: 6px 10px; font-size: 11px;
  color: var(--neon-amber); background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.15); border-radius: 4px;
  line-height: 1.4;
}

/* Warning blocks */
.chat-msg-content .md-warning {
  margin: 8px 0; padding: 6px 10px; font-size: 12px;
  color: #f87171; background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.15); border-radius: 4px;
  line-height: 1.4;
}

/* Legacy support */
.chat-msg-content h3 { margin: 10px 0 6px; font-size: 14px; color: var(--neon-cyan); font-weight: 600; }
.chat-msg-content strong { color: var(--text-primary); font-weight: 600; }
.chat-msg-content em { color: var(--text-secondary); font-style: italic; }
.chat-msg-content hr { border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 10px 0; }

.chat-input-row {
  display: flex; gap: 8px;
}
.chat-input {
  flex: 1; padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  overflow-y: auto;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.4;
}
.chat-input:focus { border-color: var(--neon-cyan); }
.chat-input::placeholder { color: var(--text-dim); }

.chat-send {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue));
  border: none; border-radius: 8px;
  color: var(--void);
  font-family: var(--font-display);
  font-size: 11px; font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
}
.chat-send:hover { filter: brightness(1.2); transform: scale(1.03); }

/* Thinking dots animation */
.thinking-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.dot-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neon-cyan);
  animation: dotPulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 6px var(--neon-cyan);
}
@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.6); }
  40% { opacity: 1; transform: scale(1); }
}

/* Streaming text — tokens appear one-by-one */
.chat-stream-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.5;
  min-height: 1.2em;
}

/* Performance stats badge after streamed message */
.chat-stats {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 6px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  display: inline-block;
}

/* Copy button on chat messages */
/* ── Per-message action buttons (Read Aloud, Translate, Copy) ── */
.chat-msg-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}
.chat-msg { position: relative; }
.chat-msg:hover .chat-msg-actions { opacity: 1; }
.chat-action-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 3px 8px;
  transition: all 0.2s;
  line-height: 1;
}
.chat-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--neon-cyan);
  border-color: rgba(255, 255, 255, 0.15);
}
.chat-action-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
}
.chat-action-btn.tts-pulse {
  animation: ttsPulse 1.2s ease-in-out infinite;
}
@keyframes ttsPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 255, 255, 0.4); }
  50% { box-shadow: 0 0 8px 3px rgba(0, 255, 255, 0.15); }
}
.chat-copy-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 8px;
  transition: all 0.2s;
}
.chat-copy-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--neon-cyan); }
.chat-copy-btn.copied { color: var(--green); border-color: var(--green); }

/* Translation chips */
.chat-translate-chip {
  font-size: 10px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: var(--neon-cyan);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}
.chat-translate-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--neon-cyan);
}
.chat-translation {
  animation: fadeIn 0.3s ease;
}

/* Context chain indicator */
.chat-context-chain {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(59, 130, 246, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  margin: 4px 0 8px;
  font-size: 10px;
  color: var(--text-dim);
}
.chat-context-chain .chain-topic {
  color: var(--neon-cyan);
  font-weight: 600;
}
.chat-context-chain .chain-arrow {
  color: var(--text-dim);
  font-size: 9px;
}

/* ═══ Reply Button & Thread Context ═══ */
.chat-reply-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 8px;
  transition: all 0.2s;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 3px;
}
.chat-reply-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--neon-cyan);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Reply context banner above chat input */
.chat-reply-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  font-size: 11px;
  color: var(--text-secondary);
  animation: msgIn 0.2s ease;
}
.chat-reply-banner .reply-label {
  color: var(--neon-cyan);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.chat-reply-banner .reply-preview {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-style: italic;
  max-width: 400px;
}
.chat-reply-banner .reply-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  transition: color 0.2s;
  line-height: 1;
}
.chat-reply-banner .reply-close:hover {
  color: var(--neon-magenta);
}

/* Reply quote shown in the message itself */
.chat-reply-quote {
  padding: 4px 10px;
  margin-bottom: 6px;
  border-left: 2px solid rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.04);
  border-radius: 0 4px 4px 0;
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  cursor: pointer;
  transition: background 0.2s;
}
.chat-reply-quote:hover {
  background: rgba(255, 255, 255, 0.05);
}
.chat-reply-quote .reply-quote-sender {
  color: var(--neon-cyan);
  font-weight: 600;
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.5px;
  margin-right: 4px;
}

/* ═══ Collapsible Long Messages ═══ */
.chat-msg-content.collapsed {
  max-height: 7.5em; /* ~5 lines at 1.5 line-height */
  overflow: hidden;
  position: relative;
}
.chat-msg-content.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2.5em;
  background: linear-gradient(transparent, rgba(18, 18, 18, 0.95));
  pointer-events: none;
}
.chat-msg.user .chat-msg-content.collapsed::after {
  background: linear-gradient(transparent, rgba(20, 20, 20, 0.95));
}
.chat-expand-btn {
  display: block;
  width: 100%;
  background: rgba(59, 130, 246, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--neon-cyan);
  cursor: pointer;
  font-size: 11px;
  padding: 4px 10px;
  margin-top: 4px;
  transition: all 0.2s;
  text-align: center;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}
.chat-expand-btn:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.2);
}

/* ═══════════════════════════════════════════
   APP: FILE MANAGER
   ═══════════════════════════════════════════ */
.files-container { height: 100%; }

.files-breadcrumb {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--neon-cyan);
  padding: 8px 12px;
  background: rgba(59, 130, 246, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}
.file-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  padding: 14px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.file-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}
.file-item .f-icon { font-size: 32px; }
.file-item .f-name {
  font-size: 11px; text-align: center;
  color: var(--text-secondary);
  word-break: break-word;
}

/* ═══════════════════════════════════════════
   APP: TERMINAL
   ═══════════════════════════════════════════ */
.terminal-container {
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  display: flex; flex-direction: column;
}
.terminal-output {
  flex: 1; overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--neon-green);
  line-height: 1.6;
}
.terminal-output .prompt { color: var(--neon-cyan); }
.terminal-output .error { color: var(--neon-red); }
.terminal-output .info { color: var(--neon-amber); }
.terminal-output .success { color: var(--neon-green); font-weight: 500; }

.terminal-input-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px;
}
.terminal-prompt-symbol {
  color: var(--neon-cyan);
  font-family: var(--font-mono);
  font-size: 13px;
}
.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--neon-green);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  caret-color: var(--neon-cyan);
  transition: border-color 0.2s;
}
.terminal-input:focus {
  border-bottom: 1px solid var(--neon-cyan);
  box-shadow: 0 1px 4px rgba(0, 255, 255, 0.15);
}

/* ═══════════════════════════════════════════
   APP: SETTINGS / SYSTEM INFO
   ═══════════════════════════════════════════ */
.settings-container { display: flex; flex-direction: column; gap: 16px; }

.settings-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.settings-section h3 {
  font-family: var(--font-display);
  font-size: 10px; font-weight: 600;
  letter-spacing: 2px;
  color: var(--neon-cyan);
  margin-bottom: 12px;
  text-transform: uppercase;
}
.setting-row {
  display: flex; justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.setting-row:last-child { border-bottom: none; }
.setting-label {
  font-size: 13px;
  color: var(--text-secondary);
}
.setting-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}

.meter-bar {
  width: 120px; height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}
.meter-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease;
}
.meter-fill.cyan { background: var(--neon-cyan); box-shadow: 0 0 8px var(--neon-cyan); }
.meter-fill.green { background: var(--neon-green); box-shadow: 0 0 8px var(--neon-green); }
.meter-fill.amber { background: var(--neon-amber); box-shadow: 0 0 8px var(--neon-amber); }

/* ═══════════════════════════════════════════
   APP: APP STORE
   ═══════════════════════════════════════════ */
.store-container { display: flex; flex-direction: column; gap: 16px; }

.store-header {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 700;
  color: var(--neon-magenta);
  letter-spacing: 2px;
}

.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.store-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  transition: all 0.3s;
  cursor: pointer;
}
.store-card:hover {
  border-color: var(--neon-magenta);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.1);
  transform: translateY(-2px);
}
.store-card .sc-icon { font-size: 28px; margin-bottom: 8px; }
.store-card .sc-name {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 600;
  letter-spacing: 1px; color: var(--text-primary);
}
.store-card .sc-desc {
  font-size: 12px; color: var(--text-dim);
  margin-top: 4px; line-height: 1.4;
}
.store-card .sc-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  border-radius: 20px;
  border: 1px solid var(--neon-green);
  color: var(--neon-green);
}

/* ═══════════════════════════════════════════
   APP: CODE PLAYGROUND
   ═══════════════════════════════════════════ */
.code-container { display: flex; flex-direction: column; height: 100%; gap: 8px; }

.code-tabs {
  display: flex; gap: 4px;
}
.code-tab {
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.code-tab.active {
  color: var(--neon-blue);
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.3);
}

.code-editor {
  flex: 1;
  position: relative;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 0 6px 6px 6px;
  padding: 12px;
  overflow: hidden;
}
.code-editor textarea {
  position: relative;
  z-index: 2;
  width: 100%; height: 100%;
  background: transparent;
  border: none;
  color: var(--neon-green);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  outline: none;
  resize: none;
}
.code-editor textarea.dtl-active {
  color: transparent;
  caret-color: var(--neon-green);
}

/* DTL Syntax Highlighting Overlay */
.code-highlight {
  display: none;
  position: absolute;
  top: 12px; left: 12px; right: 12px; bottom: 12px;
  overflow: auto;
  pointer-events: none;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-primary);
}
.dtl-key { color: var(--neon-cyan); font-weight: bold; }
.dtl-string { color: var(--neon-green); }
.dtl-number { color: var(--neon-amber); }
.dtl-bool { color: var(--neon-magenta); }
.dtl-comment { color: var(--text-dim); font-style: italic; }
.dtl-size { color: var(--neon-amber); font-weight: 500; }
.dtl-duration { color: var(--neon-amber); font-weight: 500; }
.dtl-pipe { color: var(--neon-magenta); font-weight: bold; }
.dtl-null { color: var(--text-dim); font-style: italic; }
/* DTL directives: @include, @schema, @import */
.dtl-directive { color: #ff69b4; font-weight: bold; }
.dtl-directive-path { color: #e0a0ff; }
/* Environment variable interpolation: ${VAR:default} */
.dtl-envvar { color: #00ffff; background: rgba(0,255,255,0.08); border-radius: 2px; padding: 0 2px; }
/* Multi-line text blocks (content after @key |) */
.dtl-multiline { color: #a8e6a0; font-style: italic; }
/* Nesting depth indicators */
.dtl-depth-1 { border-left: 2px solid rgba(0,212,255,0.15); padding-left: 2px; }
.dtl-depth-2 { border-left: 2px solid rgba(200,80,192,0.15); padding-left: 2px; }
.dtl-depth-3 { border-left: 2px solid rgba(0,230,118,0.15); padding-left: 2px; }
.dtl-depth-4 { border-left: 2px solid rgba(255,215,0,0.15); padding-left: 2px; }

.code-toolbar {
  display: flex; gap: 8px; align-items: center;
}
.code-run {
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--neon-green), #2563eb);
  border: none; border-radius: 6px;
  color: var(--void);
  font-family: var(--font-display);
  font-size: 10px; font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
}
.code-run:hover { filter: brightness(1.2); }

.code-output {
  min-height: 120px;
  max-height: 300px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  overflow-y: auto;
}

/* ═══════════════════════════════════════════
   APP: KNOWLEDGE BASE
   ═══════════════════════════════════════════ */
.kb-container { display: flex; flex-direction: column; gap: 12px; }

.kb-search {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}
.kb-search:focus { border-color: #b088ff; }
.kb-search::placeholder { color: var(--text-dim); }

.kb-categories { display: flex; gap: 8px; flex-wrap: wrap; }
.kb-cat {
  padding: 6px 14px;
  font-size: 12px; font-weight: 500;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.kb-cat:hover, .kb-cat.active {
  border-color: #b088ff;
  color: #b088ff;
  background: rgba(176, 136, 255, 0.08);
}

.kb-list { display: flex; flex-direction: column; gap: 8px; }
.kb-item {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.kb-item:hover {
  border-color: #b088ff;
  background: rgba(176, 136, 255, 0.04);
}
.kb-item-title {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 500;
  letter-spacing: 1px;
  color: var(--text-primary);
}
.kb-item-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
.kb-item-tag {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  border-radius: 4px;
  background: rgba(176, 136, 255, 0.1);
  color: #b088ff;
}

/* ═══════════════════════════════════════════
   APP: MEDICAL INTELLIGENCE
   ═══════════════════════════════════════════ */
.medical-container { display: flex; flex-direction: column; gap: 14px; }

.medical-alert {
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  font-size: 12px;
  color: var(--neon-red);
  display: flex; align-items: center; gap: 8px;
}

.medical-search-row { display: flex; gap: 8px; }
.medical-input {
  flex: 1; padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
}
.medical-input:focus { border-color: var(--neon-red); }

.medical-btn {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--neon-red), #dc2626);
  border: none; border-radius: 8px;
  color: white;
  font-family: var(--font-display);
  font-size: 10px; font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
}

.medical-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.med-stat {
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}
.med-stat .ms-value {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  color: var(--neon-cyan);
}
.med-stat .ms-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.medical-panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.medical-panel h4 {
  font-family: var(--font-display);
  font-size: 10px; letter-spacing: 2px;
  color: var(--neon-red);
  margin-bottom: 10px;
}
.med-entry {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 13px;
  display: flex; justify-content: space-between;
}
.med-entry:last-child { border-bottom: none; }
.med-severity {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
}
.med-severity.high { background: rgba(239, 68, 68, 0.15); color: var(--neon-red); }
.med-severity.medium { background: rgba(245, 158, 11, 0.15); color: var(--neon-amber); }
.med-severity.low { background: rgba(59, 130, 246, 0.15); color: var(--neon-green); }

/* ═══════════════════════════════════════════
   DESKTOP WIDGETS (right side)
   ═══════════════════════════════════════════ */
.desktop-widgets {
  position: absolute;
  top: calc(var(--topbar-height) + 20px);
  right: 20px;
  width: 260px;
  display: flex; flex-direction: column; gap: 12px;
  z-index: 100;
}
.widget {
  background: rgba(15, 15, 15, 0.75);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 16px;
  animation: fadeIn 0.5s ease;
}
.widget-title {
  font-family: var(--font-display);
  font-size: 9px; font-weight: 600;
  letter-spacing: 2px;
  color: var(--neon-cyan);
  margin-bottom: 10px;
  text-transform: uppercase;
}
.widget-metric {
  display: flex; justify-content: space-between;
  padding: 5px 0;
  font-size: 12px;
}
.widget-metric .label { color: var(--text-dim); }
.widget-metric .value { color: var(--text-primary); font-family: var(--font-mono); }

/* ═══════════════════════════════════════════
   CONTEXT MENU
   ═══════════════════════════════════════════ */
.context-menu {
  position: fixed;
  min-width: 180px;
  background: rgba(20, 20, 20, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px;
  z-index: 99999;
  display: none;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}
.context-menu.show { display: block; }
.ctx-item {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; gap: 8px;
}
.ctx-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}
.ctx-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ═══════════════════════════════════════════
   NOTIFICATION
   ═══════════════════════════════════════════ */
.notification {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  right: 16px;
  padding: 12px 18px;
  background: rgba(20, 20, 20, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  z-index: 99998;
  transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.notification.show { transform: translateX(0); }
.notif-title {
  font-family: var(--font-display);
  font-size: 10px; font-weight: 600;
  letter-spacing: 1px;
  color: var(--neon-cyan);
}
.notif-body {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════
   APP: TRAINING STUDIO (Dataset Wizard)
   ═══════════════════════════════════════════ */
.tk-preset {
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: all 0.2s;
}
.tk-preset:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: rgba(255, 255, 255, 0.05);
}
.tk-preset.active {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.12);
}

.src-tag {
  padding: 3px 8px;
  border: 1px solid rgba(37, 99, 235, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  transition: all 0.2s;
}
.src-tag:hover {
  border-color: var(--neon-magenta);
  color: var(--neon-magenta);
}
.src-tag.active {
  border-color: var(--neon-magenta);
  color: var(--neon-magenta);
  background: rgba(37, 99, 235, 0.1);
}

.collab-btn {
  padding: 4px 8px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  transition: all 0.2s;
}
.collab-btn:hover {
  border-color: var(--neon-green);
  color: var(--neon-green);
}
.collab-btn.active {
  border-color: var(--neon-green);
  color: var(--neon-green);
  background: rgba(59, 130, 246, 0.1);
}

/* ═══════════════════════════════════════════
   CHAT INPUT TOOLBAR (Mic, Image, TTS)
   ═══════════════════════════════════════════ */
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.chat-toolbar-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-dim);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.chat-toolbar-btn:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: rgba(255, 255, 255, 0.05);
}
.chat-toolbar-btn.active {
  border-color: var(--neon-red);
  color: var(--neon-red);
  background: rgba(239, 68, 68, 0.1);
  animation: micPulse 1s infinite;
}
.chat-toolbar-btn.tts-active {
  border-color: var(--neon-green);
  color: var(--neon-green);
  background: rgba(59, 130, 246, 0.1);
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* TTS toggle in response header */
.tts-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 6px;
}
.tts-btn:hover { border-color: var(--neon-green); color: var(--neon-green); }
.tts-btn.playing { border-color: var(--neon-green); color: var(--neon-green); background: rgba(59, 130, 246, 0.08); }

/* Image paste preview */
.chat-image-preview {
  max-width: 300px;
  max-height: 200px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 8px 0;
}
.chat-image-container {
  position: relative;
  display: inline-block;
}
.chat-image-container .ocr-badge {
  position: absolute;
  top: 4px; right: 4px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--neon-cyan);
  border-radius: 3px;
  font-size: 9px;
  color: var(--neon-cyan);
  font-family: var(--font-mono);
}

/* AI-Generated Image in Chat */
.chat-generated-image-wrap {
  margin: 10px 0 4px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 240, 255, 0.2);
  display: inline-block;
  max-width: 100%;
  position: relative;
  box-shadow: 0 2px 16px rgba(0, 240, 255, 0.08);
  transition: border-color 0.3s ease;
}
.chat-generated-image-wrap:hover {
  border-color: rgba(0, 240, 255, 0.5);
  box-shadow: 0 2px 24px rgba(0, 240, 255, 0.15);
}
.chat-generated-image {
  display: block;
  max-width: 100%;
  max-height: 512px;
  object-fit: contain;
  cursor: zoom-in;
  border-radius: 8px;
}
.chat-img-error {
  padding: 20px;
  color: var(--neon-red, #f44);
  font-size: 12px;
  text-align: center;
  font-family: var(--font-mono);
}

/* ═══ Image Generation Canvas ═══ */
.img-gen-canvas-wrap {
  margin: 10px 0 4px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0, 240, 255, 0.25);
  display: inline-block;
  max-width: 100%;
  position: relative;
  box-shadow: 0 2px 24px rgba(0, 240, 255, 0.1), inset 0 0 40px rgba(0, 240, 255, 0.03);
  background: #0a0e14;
}
.img-gen-canvas-wrap.generating {
  animation: imgGenPulse 2.5s ease-in-out infinite;
}
@keyframes imgGenPulse {
  0%, 100% { border-color: rgba(0, 240, 255, 0.2); box-shadow: 0 2px 24px rgba(0, 240, 255, 0.08); }
  50%      { border-color: rgba(0, 240, 255, 0.5); box-shadow: 0 2px 36px rgba(0, 240, 255, 0.2), inset 0 0 60px rgba(0, 240, 255, 0.05); }
}
.img-gen-canvas {
  display: block;
  width: 380px;
  height: 380px;
  border-radius: 9px;
}
.img-gen-status {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 10px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--neon-cyan);
  text-transform: uppercase;
}
.img-gen-status .gen-spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(0, 240, 255, 0.2);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.img-gen-status .gen-progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(0, 240, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
.img-gen-status .gen-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta));
  border-radius: 2px;
  width: 0%;
  animation: genProgress 30s ease-out forwards;
}
@keyframes genProgress {
  0%  { width: 0%; }
  30% { width: 40%; }
  60% { width: 65%; }
  80% { width: 78%; }
  95% { width: 88%; }
  100% { width: 92%; }
}
.img-gen-canvas-wrap.revealed .img-gen-status { display: none; }
.img-gen-canvas-wrap.revealed {
  animation: none;
  border-color: rgba(0, 240, 255, 0.3);
  cursor: zoom-in;
}
.img-gen-canvas-wrap.revealed:hover {
  border-color: rgba(0, 240, 255, 0.5);
  box-shadow: 0 2px 24px rgba(0, 240, 255, 0.15);
}

/* Theme toggle indicator in context menu */
.ctx-theme-icon {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--neon-amber);
  display: inline-block;
  margin-right: 4px;
  transition: all 0.3s;
}
[data-theme="light"] .ctx-theme-icon {
  background: var(--neon-amber);
  box-shadow: 0 0 6px var(--neon-amber);
}

/* Conversation switcher */
.conv-switcher {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}
.conv-tab {
  padding: 4px 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.conv-tab:hover { border-color: var(--neon-cyan); color: var(--text-secondary); }
.conv-tab.active {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: rgba(255, 255, 255, 0.05);
}
.conv-tab-new {
  padding: 4px 8px;
  font-size: 14px;
  color: var(--text-dim);
  background: none;
  border: 1px dashed var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.conv-tab-new:hover { border-color: var(--neon-green); color: var(--neon-green); }

/* ═══════════════════════════════════════════
   CHAT HISTORY PANEL
   ═══════════════════════════════════════════ */
.conv-history-panel {
  position: absolute;
  top: 30px;
  right: 8px;
  width: 320px;
  max-height: 380px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  flex-direction: column;
  animation: fadeSlideDown 0.2s ease;
}
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.conv-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--neon-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.conv-history-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
}
.conv-history-close:hover { color: var(--neon-red); background: rgba(239,68,68,0.1); }
.conv-history-search {
  margin: 8px;
  padding: 6px 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
}
.conv-history-search:focus { border-color: var(--neon-cyan); }
.conv-history-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px 8px 8px;
}
.conv-history-item {
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
  margin-bottom: 4px;
}
.conv-history-item:hover { background: rgba(255,255,255,0.06); border-color: var(--glass-border); }
.conv-history-item.active { border-color: var(--neon-cyan); background: rgba(255,255,255,0.08); }
.conv-hist-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-body);
}
.conv-hist-preview {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-hist-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-dim);
}
.conv-hist-delete {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 1px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.2s;
}
.conv-history-item:hover .conv-hist-delete { opacity: 1; }
.conv-hist-delete:hover { color: var(--neon-red); background: rgba(239,68,68,0.15); }

/* ═══════════════════════════════════════════
   ENTITY LINKS — Hyperlinked Knowledge
   ═══════════════════════════════════════════ */
.entity-link {
  color: var(--neon-cyan);
  text-decoration: none;
  border-bottom: 1px dotted var(--neon-cyan);
  cursor: pointer;
  transition: all 0.2s;
  padding-bottom: 1px;
}
.entity-link:hover {
  color: var(--neon-magenta);
  border-bottom-color: var(--neon-magenta);
  text-shadow: 0 0 8px rgba(255,0,229,0.3);
}

/* Entity Hover Popup */
.entity-popup {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  animation: entityPopupIn 0.15s ease;
}
@keyframes entityPopupIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.entity-popup-inner {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 12px;
  min-width: 200px;
  max-width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 1px rgba(255,255,255,0.3);
}
.entity-popup-img {
  width: 100%;
  max-height: 80px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 8px;
}
.entity-popup-type {
  font-size: 9px;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--neon-cyan);
  margin-bottom: 4px;
}
.entity-popup-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-body);
  margin-bottom: 6px;
}
.entity-popup-summary {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
}
.entity-popup-hint {
  font-size: 10px;
  color: var(--neon-magenta);
  font-style: italic;
}

/* ═══════════════════════════════════════════
   KNOWLEDGE BUILDER APP
   ═══════════════════════════════════════════ */
.kb-builder {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--abyss);
  font-family: var(--font-body);
}
.kb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.3);
}
.kb-title {
  font-family: var(--font-display);
  font-size: 14px;
  color: #ff9500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.kb-admin-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--neon-green);
  background: rgba(16,185,129,0.08);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(16,185,129,0.2);
}
.kb-logout-btn {
  background: none;
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--neon-red);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
}
.kb-logout-btn:hover { background: rgba(239,68,68,0.1); }
.kb-login-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--neon-cyan);
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
}
.kb-login-btn:hover { background: rgba(255,255,255,0.15); }
.kb-login-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border);
}
.kb-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.kb-tab {
  flex: 1;
  padding: 8px 12px;
  text-align: center;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}
.kb-tab:hover { color: var(--text-secondary); background: rgba(255,255,255,0.02); }
.kb-tab.active {
  color: #ff9500;
  border-bottom-color: #ff9500;
  background: rgba(255,149,0,0.06);
}
.kb-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}
.kb-section { margin-bottom: 16px; }
.kb-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.kb-info {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
  line-height: 1.5;
}
.kb-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.kb-input {
  flex: 1;
  padding: 7px 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
}
.kb-input:focus { border-color: #ff9500; }
.kb-url-input { flex: 3; }
.kb-textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 11px;
  font-family: var(--font-mono);
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}
.kb-textarea:focus { border-color: #ff9500; }
.kb-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
}
.kb-btn:hover { background: rgba(255,255,255,0.08); }
.kb-btn-primary { background: rgba(255,149,0,0.15); color: #ff9500; border-color: rgba(255,149,0,0.3); }
.kb-btn-primary:hover { background: rgba(255,149,0,0.25); }
.kb-btn-success { background: rgba(16,185,129,0.1); color: var(--neon-green); border-color: rgba(16,185,129,0.3); }
.kb-btn-success:hover { background: rgba(16,185,129,0.2); }
.kb-btn-danger { background: rgba(239,68,68,0.1); color: var(--neon-red); border-color: rgba(239,68,68,0.3); }
.kb-btn-danger:hover { background: rgba(239,68,68,0.2); }
.kb-btn-small { padding: 3px 8px; font-size: 10px; }
.kb-locked {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-dim);
  font-size: 13px;
}
.kb-loading {
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 12px;
}
.kb-empty {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-dim);
  font-size: 12px;
}
.kb-error {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--neon-red);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 11px;
  margin-top: 8px;
}
.kb-success {
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
  color: var(--neon-green);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 11px;
  margin-top: 8px;
}
.kb-result { margin-top: 12px; }
.kb-preview {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}
.kb-preview-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--neon-cyan);
  margin-bottom: 10px;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.kb-field {
  margin-bottom: 8px;
}
.kb-field label {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}
.kb-list { margin-top: 8px; }
.kb-list-item {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 6px;
  transition: border-color 0.2s;
}
.kb-list-item:hover { border-color: rgba(255,149,0,0.3); }
.kb-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.kb-item-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.kb-item-badge {
  font-size: 10px;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.kb-item-hits {
  font-size: 10px;
  color: var(--neon-cyan);
  font-family: var(--font-mono);
}
.kb-item-source {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.kb-item-keywords {
  font-size: 10px;
  color: var(--neon-cyan);
  margin-bottom: 2px;
}
.kb-item-preview {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  max-height: 40px;
  overflow: hidden;
}
.kb-item-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  justify-content: flex-end;
}
.kb-count {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}
.kb-dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 30px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.kb-dropzone:hover { border-color: #ff9500; color: var(--text-secondary); }
.kb-dropzone.dragover {
  border-color: var(--neon-green);
  background: rgba(16,185,129,0.04);
  color: var(--neon-green);
}

/* ═══════════════════════════════════════════
   ASK MODE — Chat-focused Intelligence
   ═══════════════════════════════════════════ */
body.ask-mode .desktop-widgets { display: none; }
body.ask-mode .topbar-title { display: none; }
body.ask-mode .topbar {
  background: var(--void);
  border-bottom: 1px solid var(--border);
  height: 28px;
}
body.ask-mode .dock {
  background: var(--abyss);
  border-top: 1px solid var(--border);
  height: 56px;
  padding: 4px 0;
}
body.ask-mode .dock-item {
  width: 42px;
  height: 42px;
  font-size: 18px;
}
body.ask-mode #circuit-canvas { opacity: 0.3; }

/* ═══════════════════════════════════════════
   CLEAN MODE — Professional Chat-First Experience
   Fullscreen chat, auto-hide dock, solid colors, no visual noise
   ═══════════════════════════════════════════ */

/* --- Hide visual noise --- */
body.clean-mode #circuit-bg,
body.clean-mode .grid-overlay,
body.clean-mode .scanlines,
body.clean-mode .vignette,
body.clean-mode .desktop-widgets {
  display: none !important;
}

/* --- Hide topbar --- */
body.clean-mode #topbar {
  height: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  border: none !important;
  padding: 0 !important;
}

/* --- Auto-hide dock --- */
body.clean-mode #dock {
  transform: translateX(-50%) translateY(calc(100% + 20px));
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
  opacity: 0;
  background: var(--surface) !important;
  backdrop-filter: blur(20px) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2) !important;
}
body.clean-mode #dock.dock-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
body.clean-mode #dock-hover-zone {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 12px;
  z-index: 8999;
  cursor: default;
}

/* --- Fullscreen chat window --- */
body.clean-mode .app-window[data-app="chat"] {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  z-index: 500 !important;
  background: var(--void) !important;
}
body.clean-mode .app-window[data-app="chat"] .window-titlebar {
  display: none !important;
}
body.clean-mode .app-window[data-app="chat"] .window-body {
  height: 100% !important;
  padding: 0 !important;
}
body.clean-mode .app-window[data-app="chat"] .window-resize {
  display: none !important;
}
/* Non-chat windows stack above */
body.clean-mode .app-window:not([data-app="chat"]) {
  z-index: 600 !important;
}

/* --- Solid colors everywhere (no glass/blur) --- */
body.clean-mode .app-window {
  backdrop-filter: none !important;
}
body.clean-mode .window-titlebar {
  background: var(--surface) !important;
  backdrop-filter: none !important;
  border-bottom: 1px solid var(--border) !important;
}
body.clean-mode #context-menu {
  background: var(--surface) !important;
  backdrop-filter: none !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;
}
body.clean-mode .notification {
  background: var(--surface) !important;
  backdrop-filter: none !important;
  border: 1px solid var(--border) !important;
  top: 12px !important;
}
body.clean-mode .widget {
  background: var(--surface) !important;
  backdrop-filter: none !important;
  border: 1px solid var(--border) !important;
}
body.clean-mode .smart-panel {
  background: var(--abyss) !important;
  border-left: 1px solid var(--border) !important;
  backdrop-filter: none !important;
}
body.clean-mode .conv-switcher {
  background: var(--surface) !important;
  display: none !important;
}
body.clean-mode .chat-input {
  background: var(--input-bg) !important;
  border: 1.5px solid var(--border) !important;
  backdrop-filter: none !important;
}
body.clean-mode .dock-user-dropdown {
  background: var(--surface) !important;
  backdrop-filter: none !important;
  border: 1px solid var(--border) !important;
  bottom: 90px !important;
}
body.clean-mode #lock-screen {
  backdrop-filter: blur(30px) !important;
}

/* --- Branded chat header --- */
.clean-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  z-index: 10;
}
.clean-chat-brand {
  display: flex;
  align-items: baseline;
  gap: 0;
}
.clean-brand-name {
  font-family: 'Mukta', 'Noto Sans Devanagari', var(--font-display), sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--accent);
}
.clean-brand-accent {
  color: var(--neon-magenta);
}
.clean-brand-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 2px;
  margin-left: 12px;
  text-transform: uppercase;
}
/* ─── Model Selector ──────────────────────── */
.model-selector-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 12px;
  flex-shrink: 1;
  min-width: 0;
}
.model-selector {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  max-width: 260px;
  min-width: 120px;
  outline: none;
  transition: border-color 0.15s;
}
.model-selector:hover,
.model-selector:focus {
  border-color: var(--accent);
  color: var(--text-primary);
}
.model-selector option {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
}
.model-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
  box-shadow: 0 0 4px currentColor;
  transition: background 0.3s;
}

/* ─── Product Model Pill Bar (ZettaPetta/Cetta/Metta/Itta) ──────── */
.product-model-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.product-model-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  line-height: 1;
}
.product-model-pill:hover {
  background: var(--accent-subtle);
  color: var(--text-secondary);
  border-color: var(--border);
}
.product-model-pill.active {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--neon-cyan-glow);
  font-weight: 600;
}
.product-model-pill .pill-emoji {
  font-size: 11px;
  line-height: 1;
}
.product-model-pill .pill-label {
  letter-spacing: 0.3px;
}

/* System message (model switch notification in chat) */
.chat-msg.system-msg {
  display: flex;
  justify-content: center;
  padding: 4px 12px;
}
.system-msg-text {
  font-size: 10px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 12px;
  font-family: var(--font-body);
  letter-spacing: 0.3px;
}
.system-msg-text strong {
  color: var(--accent);
  font-weight: 600;
}

.clean-chat-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.clean-action-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.clean-action-btn:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
}
.clean-action-btn.active {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
}
.clean-action-btn svg {
  width: 16px;
  height: 16px;
}

/* --- Chat Tab Bar (shows open conversations in clean mode) --- */
.chat-tab-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.chat-tab-bar::-webkit-scrollbar { display: none; }
.chat-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: var(--font-body);
}
.chat-tab:hover {
  background: var(--accent-subtle);
  color: var(--text-primary);
  border-color: var(--border);
}
.chat-tab.active {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.chat-tab-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-tab-count {
  font-size: 9px;
  background: var(--border);
  color: var(--text-dim);
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 14px;
  text-align: center;
}
.chat-tab.active .chat-tab-count {
  background: var(--accent);
  color: #fff;
}
.chat-tab-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  opacity: 0;
  transition: all 0.15s;
}
.chat-tab:hover .chat-tab-close { opacity: 1; }
.chat-tab-close:hover {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
}
.chat-tab-add {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  font-size: 14px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.chat-tab-add:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
}

/* --- Polished chat messages --- */
body.clean-mode .chat-main {
  max-width: 100%;
}
body.clean-mode .chat-messages {
  padding: 20px 32px;
}
body.clean-mode .chat-msg {
  max-width: 70%;
}
/* User messages: right-aligned — professional dark blue */
body.clean-mode .chat-msg.user {
  align-self: flex-end !important;
  margin-left: auto !important;
  margin-right: 0 !important;
  border-radius: 14px 14px 4px 14px !important;
  background: #1a2d47 !important;
  color: #e2e8f0 !important;
  border: 1px solid rgba(59, 130, 246, 0.18) !important;
}
body.clean-mode .chat-msg.user .sender { display: none; }
body.clean-mode .chat-msg.user .chat-msg-content { color: #e2e8f0; }
body.clean-mode .chat-msg.user .chat-msg-content .md-bold { color: #ffffff; }

/* AI messages: left-aligned — professional clean */
body.clean-mode .chat-msg.ai {
  align-self: flex-start !important;
  margin-right: auto !important;
  margin-left: 0 !important;
  border-radius: 4px 14px 14px 14px !important;
  max-width: 80%;
}

/* Chat message wrapper with avatar */
body.clean-mode .chat-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 85%;
  animation: msgIn 0.3s ease;
}
body.clean-mode .chat-msg-row.user-row {
  flex-direction: row-reverse;
  align-self: flex-end;
  margin-left: auto;
}
body.clean-mode .chat-msg-row.ai-row {
  align-self: flex-start;
  margin-right: auto;
}

/* Avatars next to messages */
.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.chat-avatar.user-avatar {
  background: var(--accent);
  color: #ffffff;
  font-family: var(--font-body);
}
.chat-avatar.ai-avatar {
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 16px;
  padding: 0;
  overflow: hidden;
}
.avatar-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
[data-theme="light"] .chat-avatar.ai-avatar {
  background: #f0f4ff;
  border-color: #dbeafe;
}
body.clean-mode .chat-input-row {
  max-width: 840px;
  margin: 0 auto;
  width: 100%;
  padding: 12px 32px 16px;
  border-top: 1px solid var(--border);
  background: var(--void);
}
body.clean-mode .chat-input {
  border-radius: 12px !important;
  font-size: 15px !important;
  padding: 12px 16px !important;
}
body.clean-mode .chat-send {
  border-radius: 12px;
}

/* --- Chat history as side panel --- */
body.clean-mode .conv-history-panel {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: auto !important;
  width: 300px !important;
  max-height: 100vh !important;
  height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  border-right: 1px solid var(--border) !important;
  z-index: 700 !important;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15) !important;
  background: var(--surface) !important;
  backdrop-filter: none !important;
  overflow-y: auto !important;
}
body.clean-mode .conv-history-header {
  padding: 16px;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--accent);
}
body.clean-mode .conv-history-search {
  margin: 0 12px 8px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text-primary);
}
body.clean-mode .conv-history-item {
  padding: 12px 14px;
  border-radius: 8px;
  margin: 2px 8px;
  cursor: pointer;
  transition: background 0.15s;
}
body.clean-mode .conv-history-item:hover {
  background: var(--accent-subtle);
}

/* --- History panel backdrop overlay --- */
body.clean-mode .conv-history-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 699;
  cursor: pointer;
}

/* --- Smart panel clean --- */
body.clean-mode .sp-card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  backdrop-filter: none !important;
}
body.clean-mode .sp-stat {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
}

/* Entity links & popup must be visible in clean mode */
body.clean-mode .entity-popup {
  z-index: 10000 !important;
}
body.clean-mode .entity-link {
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
}
body.clean-mode .entity-link:hover {
  color: var(--neon-magenta) !important;
  border-bottom-color: var(--neon-magenta) !important;
}

/* ═══════════════════════════════════════════
   DESKTOP SIDEBAR — System & User Info
   Static on desktop, hidden behind fullscreen chat
   ═══════════════════════════════════════════ */
#desktop-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--abyss);
  border-right: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 20px;
  overflow-y: auto;
}
/* Hidden behind fullscreen chat (z-index: 500) */
body.clean-mode #desktop-sidebar {
  z-index: 100;
}

.ds-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.ds-brand-name {
  font-family: 'Mukta', 'Noto Sans Devanagari', var(--font-display), sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--accent);
}
.ds-brand-accent {
  color: var(--neon-magenta);
}
.ds-brand-ver {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.ds-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ds-section-title {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2.5px;
  color: var(--text-dim);
  font-weight: 600;
}

.ds-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.ds-user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-body);
  flex-shrink: 0;
}
.ds-user-info {
  flex: 1;
  min-width: 0;
}
.ds-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-user-email {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-user-role {
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--accent);
  margin-top: 2px;
}

.ds-status-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ds-status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}
.ds-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ds-dot-green { background: #22c55e; box-shadow: 0 0 6px rgba(34, 197, 94, 0.4); }
.ds-dot-blue { background: var(--accent); box-shadow: 0 0 6px rgba(59, 130, 246, 0.3); }
.ds-dot-amber { background: #f59e0b; }
.ds-status-label {
  flex: 1;
  color: var(--text-secondary);
  font-size: 12px;
}
.ds-status-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  font-weight: 500;
}

.ds-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.ds-stat-box {
  text-align: center;
  padding: 10px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.ds-stat-val {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
.ds-stat-label {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-top: 2px;
  text-transform: uppercase;
}

.ds-section-bottom {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.ds-tagline {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.ds-company {
  font-size: 9px;
  color: var(--text-dim);
}
.ds-location {
  font-size: 9px;
  color: var(--accent);
  margin-top: 2px;
  font-weight: 500;
}

/* Light theme sidebar */
[data-theme="light"] #desktop-sidebar {
  background: #f8fafc;
  border-right-color: #e2e8f0;
}
[data-theme="light"] .ds-user-card,
[data-theme="light"] .ds-status-item,
[data-theme="light"] .ds-stat-box {
  background: #ffffff;
  border-color: #e2e8f0;
}

/* ═══════════════════════════════════════════
   DOCK USER ICON & DROPDOWN
   ═══════════════════════════════════════════ */
.dock-separator {
  width: 1px;
  height: 32px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 4px;
}
[data-theme="light"] .dock-separator {
  background: rgba(0, 0, 0, 0.12);
}

.dock-user-item .icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px !important;
  font-weight: 700;
  font-family: var(--font-body);
  filter: none !important;
  line-height: 1;
}

.dock-user-dropdown {
  position: fixed;
  bottom: calc(var(--dock-height) + 20px);
  right: 20px;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
  z-index: 9500;
  overflow: hidden;
  font-family: var(--font-body);
  animation: ddFadeIn 0.15s ease;
}
@keyframes ddFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.user-dd-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}
.user-dd-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-dd-info { flex: 1; min-width: 0; }
.user-dd-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-dd-email {
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-dd-role {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent-subtle);
  color: var(--accent);
  margin-top: 4px;
}
.user-dd-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}
.user-dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}
.user-dd-item:hover {
  background: var(--accent-subtle);
}
.user-dd-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
}
.user-dd-logout {
  color: var(--neon-red);
}
.user-dd-logout:hover {
  background: rgba(239, 68, 68, 0.08);
}

/* ═══════════════════════════════════════════
   LOCK SCREEN
   ═══════════════════════════════════════════ */
#lock-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(24px) saturate(0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lockFadeIn 0.3s ease;
}
@keyframes lockFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
[data-theme="light"] #lock-screen {
  background: rgba(255, 255, 255, 0.7);
}
.lock-container {
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}
.lock-brand {
  margin-bottom: 20px;
}
.lock-brand-name {
  font-family: 'Mukta', 'Noto Sans Devanagari', var(--font-display), sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
}
.lock-brand-tag {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--text-dim);
  font-weight: 500;
  margin-top: 2px;
}
.lock-footer-version {
  display: block;
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.lock-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-body);
  margin: 0 auto 12px;
}
.lock-username {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-body);
}
.lock-role {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent-subtle);
  color: var(--accent);
  margin: 6px 0 16px;
}
.lock-time {
  font-size: 36px;
  font-weight: 300;
  color: var(--text-primary);
  font-family: var(--font-body);
  margin-bottom: 24px;
}
.lock-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--abyss);
  border: 1.5px solid var(--border);
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
  font-family: var(--font-body);
  border-radius: 10px;
  text-align: center;
  letter-spacing: 6px;
  outline: none;
  box-sizing: border-box;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}
.lock-input:focus {
  border-color: var(--accent);
}
.lock-error {
  font-size: 12px;
  color: var(--neon-red);
  margin-bottom: 8px;
  min-height: 18px;
}
.lock-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 8px;
}
.lock-btn:hover {
  background: var(--accent-hover);
}
.lock-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  margin-top: 4px;
}
.lock-link:hover {
  text-decoration: underline;
}
.lock-expired-banner {
  background: rgba(234, 88, 12, 0.12);
  border: 1px solid rgba(234, 88, 12, 0.3);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #fb923c;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  line-height: 1.4;
}
.lock-expired-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.lock-newpin-title {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--neon-cyan);
  margin-bottom: 10px;
  text-transform: uppercase;
}
.lock-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 900px) {
  .desktop-widgets { display: none; }
  .app-window { min-width: 320px; }
}

/* ═══════════════════════════════════════════
   CLUSTER & MODEL FAMILY
   ═══════════════════════════════════════════ */

/* Pulse animation for active cluster workers */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Model tree item hover */
.model-tree-item {
  transition: background 0.2s, border-color 0.2s;
}
.model-tree-item:hover {
  background: var(--elevated) !important;
  border-color: var(--neon-cyan) !important;
  cursor: pointer;
}

/* Sidebar cluster worker dots container */
#ds-cluster-worker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px 0;
}

/* Training sidebar mini-stats */
#ds-training-section .ds-stat-val {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Amber dot for sidebar status */
.ds-dot-amber {
  background: var(--neon-amber) !important;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

/* ─── DATASET STUDIO / KB TAB BAR ─── */
.ds-tab {
  padding: 6px 14px;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  font-family: var(--font-mono);
  user-select: none;
}
.ds-tab:hover {
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.08);
}
.ds-tab.active {
  color: var(--neon-cyan);
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ─── SECURITY TOGGLE SWITCH ─── */
.sec-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.sec-toggle-label {
  font-size: 11px;
  color: var(--text-primary);
}
.sec-toggle-switch {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.sec-toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.2s;
}
.sec-toggle-switch.active {
  background: rgba(0, 255, 136, 0.3);
}
.sec-toggle-switch.active::after {
  left: 19px;
  background: var(--neon-green);
  box-shadow: 0 0 6px rgba(0, 255, 136, 0.4);
}

/* ─── NODE CARD (Server Chain) ─── */
.node-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 8px;
  padding: 14px;
  position: relative;
  transition: border-color 0.2s;
}
.node-card:hover {
  border-color: rgba(59, 130, 246, 0.35);
}
.node-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: absolute;
  top: 14px;
  right: 14px;
}
.node-status-dot.online {
  background: var(--neon-green);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
  animation: pulse-dot 2s infinite;
}
.node-status-dot.stale {
  background: var(--neon-amber);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}
.node-status-dot.offline {
  background: var(--neon-red);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ═══════════════════════════════════════════════════════════
   MAIL APP — IMAP Email Client
   ═══════════════════════════════════════════════════════════ */

.mail-app { display: flex; flex-direction: column; height: 100%; background: var(--bg-primary); }
.mail-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); flex-shrink: 0; overflow-x: auto; }
.mail-btn { background: transparent; border: 1px solid var(--border); color: var(--text-primary); padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; white-space: nowrap; transition: all 0.2s; }
.mail-btn:hover { border-color: var(--neon-cyan); color: var(--neon-cyan); }
.mail-btn.active { border-color: var(--neon-cyan); background: rgba(0, 255, 255, 0.1); color: var(--neon-cyan); }
.mail-btn-primary { background: var(--neon-cyan); color: var(--bg-primary); border: none; padding: 10px 24px; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600; }
.mail-btn-primary:hover { opacity: 0.8; }
.mail-search { background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-primary); padding: 4px 10px; border-radius: 4px; font-size: 12px; width: 160px; }
.mail-content { display: flex; flex: 1; overflow: hidden; }
.mail-list { width: 320px; overflow-y: auto; border-right: 1px solid var(--border); flex-shrink: 0; }
.mail-detail { flex: 1; overflow-y: auto; padding: 16px; }
.mail-item { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.05); cursor: pointer; transition: background 0.2s; }
.mail-item:hover { background: rgba(0, 255, 255, 0.05); }
.mail-item.selected { background: rgba(0, 255, 255, 0.1); border-left: 3px solid var(--neon-cyan); }
.mail-item.unread { border-left: 3px solid var(--neon-cyan); }
.mail-item.unread .mail-sender { font-weight: 700; color: var(--text-primary); }
.mail-item.unread .mail-item-subject { font-weight: 600; }
.mail-item-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.mail-sender { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.mail-date { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.mail-item-subject { font-size: 12px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-detail-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); font-size: 14px; }
.mail-detail-header { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.mail-detail-header h3 { color: var(--text-primary); margin: 0 0 8px 0; font-size: 16px; }
.mail-detail-meta { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.mail-detail-body { font-size: 13px; color: var(--text-primary); line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; }
.mail-detail-actions { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.mail-loading { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); font-size: 13px; padding: 20px; }
.mail-status { padding: 6px 12px; background: var(--bg-secondary); border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.mail-config-form { max-width: 400px; margin: 20px auto; padding: 24px; }
.mail-form-group { margin-bottom: 12px; }
.mail-form-group label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.mail-form-group input[type="text"],
.mail-form-group input[type="password"],
.mail-form-group input[type="number"] { width: 100%; background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-primary); padding: 8px 12px; border-radius: 4px; font-size: 13px; box-sizing: border-box; }
.mail-form-group input:focus { border-color: var(--neon-cyan); outline: none; }
.mail-reply-suggestions { margin-top: 16px; padding: 12px; background: rgba(0, 255, 255, 0.05); border-radius: 8px; border: 1px solid rgba(0, 255, 255, 0.2); }
.mail-reply-option { padding: 8px 12px; margin: 6px 0; background: var(--bg-secondary); border-radius: 4px; cursor: pointer; font-size: 13px; color: var(--text-primary); transition: all 0.2s; }
.mail-reply-option:hover { background: rgba(0, 255, 255, 0.1); border-left: 3px solid var(--neon-cyan); }

/* ═══════════════════════════════════════════════════════════
   ONEDRIVE APP — Microsoft Graph File Manager
   ═══════════════════════════════════════════════════════════ */

.drive-app { display: flex; flex-direction: column; height: 100%; background: var(--bg-primary); }
.drive-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); flex-shrink: 0; overflow-x: auto; }
.drive-btn { background: transparent; border: 1px solid var(--border); color: var(--text-primary); padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; white-space: nowrap; transition: all 0.2s; }
.drive-btn:hover { border-color: #0078d4; color: #0078d4; }
.drive-btn-primary { background: #0078d4; color: #fff; border: none; padding: 12px 28px; border-radius: 8px; cursor: pointer; font-size: 15px; font-weight: 600; transition: all 0.2s; }
.drive-btn-primary:hover { background: #106ebe; transform: scale(1.02); }
.drive-search { background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-primary); padding: 4px 10px; border-radius: 4px; font-size: 12px; width: 160px; }
.drive-breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-secondary); }
.drive-crumb { cursor: pointer; color: var(--text-secondary); transition: color 0.2s; }
.drive-crumb:hover { color: #0078d4; }
.drive-crumb:last-child { color: var(--text-primary); font-weight: 600; }
.drive-content { flex: 1; overflow-y: auto; padding: 8px; }
.drive-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px; cursor: pointer; transition: background 0.2s; }
.drive-item:hover { background: rgba(0, 120, 212, 0.08); }
.drive-item-icon { font-size: 24px; flex-shrink: 0; }
.drive-item-name { flex: 1; font-size: 13px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drive-item-size { font-size: 11px; color: var(--text-muted); white-space: nowrap; min-width: 70px; text-align: right; }
.drive-item-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.drive-item:hover .drive-item-actions { opacity: 1; }
.drive-action-btn { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); padding: 2px 6px; border-radius: 3px; cursor: pointer; font-size: 11px; }
.drive-action-btn:hover { border-color: #0078d4; color: #0078d4; }
.drive-loading { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); font-size: 13px; }
.drive-status { padding: 6px 12px; background: var(--bg-secondary); border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.drive-connect-panel { text-align: center; padding: 40px; }
.drive-quota-bar { width: 100%; height: 20px; background: var(--bg-secondary); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.drive-quota-fill { height: 100%; background: linear-gradient(90deg, #0078d4, #00bcf2); border-radius: 10px; transition: width 0.5s ease; }
