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

/* ═══ DARK THEME (Default — Cyberpunk Neon) ═══ */
:root, [data-theme="dark"] {
  --void: #05050d;
  --abyss: #0a0a18;
  --deep: #0f1025;
  --surface: #151530;
  --elevated: #1a1a40;
  --border: #252555;
  --text-primary: #e0e0f0;
  --text-secondary: #8888aa;
  --text-dim: #555577;
  --neon-cyan: #00f0ff;
  --neon-magenta: #ff00e5;
  --neon-green: #00ff41;
  --neon-amber: #ffb800;
  --neon-red: #ff003c;
  --neon-blue: #4d6dff;
  --neon-cyan-glow: 0 0 10px #00f0ff44, 0 0 30px #00f0ff22;
  --neon-magenta-glow: 0 0 10px #ff00e544, 0 0 30px #ff00e522;
  --neon-green-glow: 0 0 10px #00ff4144, 0 0 30px #00ff4122;
  --font-display: 'Orbitron', monospace;
  --font-body: 'Rajdhani', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
  --radius: 6px;
  --dock-height: 72px;
  --topbar-height: 36px;
  --chat-user-bg: rgba(0, 240, 255, 0.08);
  --chat-ai-bg: rgba(20, 20, 50, 0.6);
  --panel-bg: rgba(15, 16, 37, 0.95);
  --input-bg: rgba(10, 10, 24, 0.9);
  --glass-bg: rgba(10, 10, 30, 0.85);
  --glass-border: rgba(0, 240, 255, 0.1);
}

/* ═══ LIGHT THEME ═══ */
[data-theme="light"] {
  --void: #f0f2f5;
  --abyss: #e8eaef;
  --deep: #ffffff;
  --surface: #f8f9fb;
  --elevated: #ffffff;
  --border: #d0d4dd;
  --text-primary: #1a1a2e;
  --text-secondary: #5a5e6e;
  --text-dim: #8a8e9e;
  --neon-cyan: #0088aa;
  --neon-magenta: #cc00b0;
  --neon-green: #00a82e;
  --neon-amber: #cc8800;
  --neon-red: #d0002e;
  --neon-blue: #3a58cc;
  --neon-cyan-glow: 0 0 8px #0088aa22, 0 0 20px #0088aa11;
  --neon-magenta-glow: 0 0 8px #cc00b022, 0 0 20px #cc00b011;
  --neon-green-glow: 0 0 8px #00a82e22, 0 0 20px #00a82e11;
  --chat-user-bg: rgba(0, 136, 170, 0.06);
  --chat-ai-bg: rgba(255, 255, 255, 0.9);
  --panel-bg: rgba(255, 255, 255, 0.95);
  --input-bg: rgba(255, 255, 255, 0.95);
  --glass-bg: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(0, 136, 170, 0.15);
}

/* Light theme overrides for specific elements */
[data-theme="light"] .topbar { background: linear-gradient(180deg, #e8eaef, #dfe1e6); border-bottom: 1px solid #ccd0d8; }
[data-theme="light"] .dock { background: rgba(255, 255, 255, 0.92); border-top: 1px solid #ccd0d8; box-shadow: 0 -4px 20px rgba(0,0,0,0.06); }
[data-theme="light"] .dock-icon { filter: none; }
[data-theme="light"] .win-glass { background: rgba(255, 255, 255, 0.95); border-color: #ccd0d8; box-shadow: 0 8px 32px rgba(0,0,0,0.08); }
[data-theme="light"] .win-titlebar { background: linear-gradient(180deg, #f0f2f5, #e8eaef); border-bottom: 1px solid #ccd0d8; }
[data-theme="light"] .chat-msg.ai { background: var(--chat-ai-bg); border-color: #d0d4dd; }
[data-theme="light"] .chat-msg.user { background: var(--chat-user-bg); }
[data-theme="light"] .chat-input { background: var(--input-bg); border-color: #ccd0d8; color: var(--text-primary); }
[data-theme="light"] .smart-panel { background: var(--panel-bg); border-color: #ccd0d8; }
[data-theme="light"] .context-menu { background: rgba(255, 255, 255, 0.97); border-color: #ccd0d8; }
[data-theme="light"] .ctx-item:hover { background: rgba(0, 136, 170, 0.08); }
[data-theme="light"] .notification { background: rgba(255, 255, 255, 0.97); border-color: #ccd0d8; }
[data-theme="light"] .boot-logo { background: linear-gradient(135deg, #0088aa, #cc00b0); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
[data-theme="light"] ::selection { background: #0088aa; color: white; }
[data-theme="light"] .chat-action-btn { background: rgba(0, 136, 170, 0.06); border-color: #d0d4dd; color: #666; }
[data-theme="light"] .chat-action-btn:hover { background: rgba(0, 136, 170, 0.12); color: #0088aa; border-color: #0088aa; }
[data-theme="light"] .chat-copy-btn { background: rgba(0, 136, 170, 0.06); border-color: #d0d4dd; color: #666; }
[data-theme="light"] .chat-translate-chip { background: rgba(0, 136, 170, 0.06); border-color: #d0d4dd; color: #0088aa; }
[data-theme="light"] .chat-context-chain { background: rgba(0, 136, 170, 0.04); border-color: #d0d4dd; }
[data-theme="light"] .chat-context-chain .chain-topic { color: #0088aa; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #ccd0d8; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #0088aa; }

*, *::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, #register-screen {
  position: fixed; inset: 0; z-index: 10001;
  display: flex; align-items: center; justify-content: center;
  background: var(--void);
  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:
    linear-gradient(rgba(0,240,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,240,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: loginGridMove 20s linear infinite;
}
@keyframes loginGridMove {
  0% { transform: translate(0, 0); }
  100% { transform: translate(40px, 40px); }
}
.login-container {
  position: relative; z-index: 1;
  width: 380px; padding: 48px 40px;
  background: rgba(15, 16, 37, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 0 60px rgba(0,240,255,0.08), 0 0 120px rgba(255,0,229,0.04);
}
.login-logo {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 900;
  letter-spacing: 6px; text-align: center;
  color: var(--neon-cyan);
  margin-bottom: 4px;
}
.login-logo span {
  background: linear-gradient(135deg, var(--neon-magenta), var(--neon-cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-subtitle {
  font-family: var(--font-body);
  font-size: 13px; letter-spacing: 4px;
  text-align: center; color: var(--text-secondary);
  margin-bottom: 6px;
}
.login-version {
  font-family: var(--font-mono);
  font-size: 10px; text-align: center;
  color: var(--text-dim); margin-bottom: 32px;
}
.login-field {
  margin-bottom: 16px;
}
.login-field input {
  width: 100%; padding: 12px 16px;
  background: var(--abyss);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  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: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0,240,255,0.15);
}
.login-field input::placeholder {
  color: var(--text-dim);
  font-family: var(--font-body);
}
.login-error {
  color: var(--neon-red);
  font-family: var(--font-mono);
  font-size: 12px; min-height: 18px;
  margin-bottom: 12px; text-align: center;
}
.login-btn {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta));
  border: none; border-radius: var(--radius);
  color: #fff; font-family: var(--font-display);
  font-size: 13px; font-weight: 700;
  letter-spacing: 3px; cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.login-btn:hover { opacity: 0.9; }
.login-btn:active { transform: scale(0.98); }
.login-btn:disabled { opacity: 0.5; cursor: wait; }
.login-footer {
  text-align: center; margin-top: 24px;
  font-family: var(--font-body);
  font-size: 13px; color: var(--text-secondary);
}
.login-footer a {
  color: var(--neon-cyan);
  text-decoration: none; margin-left: 6px;
  cursor: pointer;
}
.login-footer a:hover { text-decoration: underline; }

.otp-sent-info {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; margin-bottom: 16px;
  padding: 12px; border: 1px solid rgba(0, 255, 100, 0.2);
  border-radius: 8px; background: rgba(0, 255, 100, 0.05);
}

/* ═══════════════════════════════════════════
   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 {
  font-family: var(--font-display);
  font-size: 42px; font-weight: 900;
  letter-spacing: 8px;
  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(0, 240, 255, 0.008) 2px, rgba(0, 240, 255, 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: linear-gradient(180deg, rgba(10,10,24,0.95), rgba(10,10,24,0.85));
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 240, 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-brand {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 700;
  letter-spacing: 3px;
  color: var(--neon-cyan);
  text-shadow: var(--neon-cyan-glow);
}
.topbar-brand span { color: var(--neon-magenta); }

.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(10, 10, 24, 0.8);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(0, 240, 255, 0.1);
  border-radius: 18px;
  z-index: 9000;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(0, 240, 255, 0.05);
}

.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(0, 240, 255, 0.08);
  border-color: rgba(0, 240, 255, 0.2);
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.15);
}
.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(10, 10, 24, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 240, 255, 0.12);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.7), 0 0 1px rgba(0, 240, 255, 0.3);
  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(0, 240, 255, 0.25);
  box-shadow: 0 16px 80px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 240, 255, 0.06);
}
.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(20, 20, 50, 0.8), rgba(15, 15, 40, 0.8));
  border-bottom: 1px solid rgba(0, 240, 255, 0.06);
  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;
}

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

.sp-header {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-primary);
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 240, 255, 0.1);
}

.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(0, 240, 255, 0.15);
  border-radius: 6px;
}

.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(0, 255, 65, 0.05);
  border: 1px solid rgba(0, 255, 65, 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.3);
  border: 1px solid rgba(0, 240, 255, 0.12);
  border-radius: 8px;
  padding: 10px;
  animation: msgIn 0.3s ease;
}

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

.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(77, 109, 255, 0.2);
}

.sp-card-kb {
  border-color: rgba(0, 255, 65, 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(0, 240, 255, 0.1);
  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(0, 240, 255, 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(10, 10, 24, 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: 5px 4px;
  font-size: 10px;
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 0.12);
  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(0, 240, 255, 0.18);
  color: var(--neon-cyan);
  border-color: rgba(0, 240, 255, 0.35);
}

/* 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(0, 240, 255, 0.3);
  background: rgba(0, 240, 255, 0.08);
  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(0, 240, 255, 0.08);
  border: 2px solid rgba(0, 240, 255, 0.3);
  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(0, 240, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 0.15);
  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(0, 255, 65, 0.08);
  border: 1px solid rgba(0, 255, 65, 0.2);
  border-radius: 3px;
  color: var(--neon-green);
}
.sp-badge-community {
  font-size: 9px;
  padding: 2px 6px;
  background: rgba(255, 184, 0, 0.08);
  border: 1px solid rgba(255, 184, 0, 0.2);
  border-radius: 3px;
  color: #ffb800;
}

/* ═══ 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(0, 240, 255, 0.06);
}
.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: 2px 6px;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 3px;
  color: var(--neon-cyan);
}

/* ═══ 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(0, 255, 65, 0.1);
  border: 1px solid rgba(0, 255, 65, 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: 80%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px; line-height: 1.5;
  font-family: var(--font-body);
  animation: msgIn 0.3s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(77, 109, 255, 0.15));
  border: 1px solid rgba(0, 240, 255, 0.2);
}
.chat-msg.ai {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.chat-msg.ai .sender {
  font-family: var(--font-display);
  font-size: 9px; letter-spacing: 2px;
  color: var(--neon-cyan);
  margin-bottom: 4px;
}

/* ═══ 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(0, 240, 255, 0.15); 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(0, 240, 255, 0.08), 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(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.15);
  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(0, 240, 255, 0.12);
  background: rgba(0, 0, 0, 0.3);
}
.chat-msg-content .md-code-block .md-code-lang {
  font-size: 9px; padding: 3px 8px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-dim);
  background: rgba(0, 240, 255, 0.06);
  border-bottom: 1px solid rgba(0, 240, 255, 0.08);
}
.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;
}

/* 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(0, 240, 255, 0.15);
}
.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, 0, 255, 0.04);
  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(0, 240, 255, 0.3);
  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(0, 240, 255, 0.2);
}
.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(255, 170, 0, 0.06);
  border: 1px solid rgba(255, 170, 0, 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: #ff6b6b; background: rgba(255, 80, 80, 0.06);
  border: 1px solid rgba(255, 80, 80, 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;
}
.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(0, 240, 255, 0.05);
  border: 1px solid rgba(0, 240, 255, 0.1);
  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(0, 240, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 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(0, 240, 255, 0.15);
  color: var(--neon-cyan);
  border-color: rgba(0, 240, 255, 0.3);
}
.chat-action-btn.active {
  background: rgba(0, 240, 255, 0.2);
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
}
.chat-copy-btn {
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 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(0, 240, 255, 0.15); 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(0, 240, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 4px;
  color: var(--neon-cyan);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}
.chat-translate-chip:hover {
  background: rgba(0, 240, 255, 0.15);
  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(0, 240, 255, 0.04);
  border: 1px solid rgba(0, 240, 255, 0.1);
  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(0, 240, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 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(0, 240, 255, 0.15);
  color: var(--neon-cyan);
  border-color: rgba(0, 240, 255, 0.3);
}

/* Reply context banner above chat input */
.chat-reply-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 0.15);
  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(0, 240, 255, 0.4);
  background: rgba(0, 240, 255, 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(0, 240, 255, 0.08);
}
.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(15, 15, 25, 0.95));
  pointer-events: none;
}
.chat-msg.user .chat-msg-content.collapsed::after {
  background: linear-gradient(transparent, rgba(0, 50, 60, 0.95));
}
.chat-expand-btn {
  display: block;
  width: 100%;
  background: rgba(0, 240, 255, 0.04);
  border: 1px solid rgba(0, 240, 255, 0.1);
  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(0, 240, 255, 0.12);
  border-color: rgba(0, 240, 255, 0.25);
}

/* ═══════════════════════════════════════════
   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(0, 240, 255, 0.04);
  border: 1px solid rgba(0, 240, 255, 0.08);
  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(0, 240, 255, 0.05);
  border-color: rgba(0, 240, 255, 0.15);
}
.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-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);
}

/* ═══════════════════════════════════════════
   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(255, 0, 229, 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(77, 109, 255, 0.08);
  border-color: rgba(77, 109, 255, 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: #ffb800; }
.dtl-duration { color: #ffb800; }

.code-toolbar {
  display: flex; gap: 8px; align-items: center;
}
.code-run {
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--neon-green), #00cc33);
  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 {
  height: 100px;
  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(255, 0, 60, 0.08);
  border: 1px solid rgba(255, 0, 60, 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), #cc0030);
  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(255, 0, 60, 0.15); color: var(--neon-red); }
.med-severity.medium { background: rgba(255, 184, 0, 0.15); color: var(--neon-amber); }
.med-severity.low { background: rgba(0, 255, 65, 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(10, 10, 24, 0.75);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 240, 255, 0.08);
  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(15, 16, 37, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 240, 255, 0.15);
  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(0, 240, 255, 0.1);
  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(15, 16, 37, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 240, 255, 0.2);
  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(0, 240, 255, 0.2);
  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(0, 240, 255, 0.08);
}
.tk-preset.active {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

.src-tag {
  padding: 3px 8px;
  border: 1px solid rgba(255, 0, 200, 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(255, 0, 200, 0.1);
}

.collab-btn {
  padding: 4px 8px;
  border: 1px solid rgba(0, 255, 65, 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(0, 255, 65, 0.1);
}

/* ═══════════════════════════════════════════
   CHAT INPUT TOOLBAR (Mic, Image, TTS)
   ═══════════════════════════════════════════ */
.chat-input-row {
  display: flex;
  align-items: center;
  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(0, 240, 255, 0.08);
}
.chat-toolbar-btn.active {
  border-color: var(--neon-red);
  color: var(--neon-red);
  background: rgba(255, 0, 60, 0.1);
  animation: micPulse 1s infinite;
}
.chat-toolbar-btn.tts-active {
  border-color: var(--neon-green);
  color: var(--neon-green);
  background: rgba(0, 255, 65, 0.1);
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 0, 60, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(255, 0, 60, 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(0, 255, 65, 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);
}

/* 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(0, 240, 255, 0.08);
}
.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(255,0,60,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(0,240,255,0.06); border-color: var(--glass-border); }
.conv-history-item.active { border-color: var(--neon-cyan); background: rgba(0,240,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(255,0,60,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(0,240,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(0,255,65,0.08);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(0,255,65,0.2);
}
.kb-logout-btn {
  background: none;
  border: 1px solid rgba(255,0,60,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(255,0,60,0.1); }
.kb-login-btn {
  background: rgba(0,240,255,0.08);
  border: 1px solid rgba(0,240,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(0,240,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(0,255,65,0.1); color: var(--neon-green); border-color: rgba(0,255,65,0.3); }
.kb-btn-success:hover { background: rgba(0,255,65,0.2); }
.kb-btn-danger { background: rgba(255,0,60,0.1); color: var(--neon-red); border-color: rgba(255,0,60,0.3); }
.kb-btn-danger:hover { background: rgba(255,0,60,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(255,0,60,0.08);
  border: 1px solid rgba(255,0,60,0.2);
  color: var(--neon-red);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 11px;
  margin-top: 8px;
}
.kb-success {
  background: rgba(0,255,65,0.08);
  border: 1px solid rgba(0,255,65,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(0,255,65,0.04);
  color: var(--neon-green);
}

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