/* ─── Reset & Base ─── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #060612; color: #e0e0e0;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  overscroll-behavior: none; /* prevent iOS bounce */
  -webkit-overflow-scrolling: touch;
}

/* ─── Login Screen ─── */
#login-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: radial-gradient(ellipse at center, #0a1628 0%, #060612 70%);
  display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-y: auto;
}
#login-screen.hidden { display: none; }
.login-card {
  text-align: center; padding: 48px 40px;
  background: rgba(10, 14, 30, 0.9);
  border: 1px solid rgba(0, 255, 255, 0.15);
  border-radius: 16px; backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 255, 255, 0.05);
  max-width: 380px; width: 90%;
}
.login-logo { margin-bottom: 8px; }
.login-brand {
  font-family: 'Orbitron', sans-serif;
  font-size: 36px; font-weight: 900; letter-spacing: 5px;
  background: linear-gradient(90deg, #00b4d8, #00d4a8, #4ade80);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 10px rgba(0, 180, 216, 0.4));
  text-shadow: none;
}
.login-tagline { color: rgba(255,255,255,0.4); font-size: 12px; margin-bottom: 32px; letter-spacing: 1px; }
.login-btn {
  width: 100%; padding: 12px; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: all 0.2s; min-height: 44px; touch-action: manipulation;
}
.login-google { background: #fff; color: #333; font-weight: 600; }
.login-google:hover { background: #f0f0f0; }
.login-email-btn { background: rgba(0, 200, 255, 0.15); color: #00ccff; border-color: rgba(0, 200, 255, 0.3); font-weight: 600; }
.login-email-btn:hover { background: rgba(0, 200, 255, 0.25); }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: rgba(255,255,255,0.2); font-size: 11px; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.1); }
.login-input {
  width: 100%; padding: 10px 14px; margin-bottom: 10px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; color: #e0e0e0; font-size: 13px; font-family: inherit;
}
.login-input:focus { outline: none; border-color: rgba(0, 200, 255, 0.4); }
.login-toggle { color: rgba(255,255,255,0.3); font-size: 12px; margin-top: 16px; }
.login-toggle a { color: #00ccff; text-decoration: none; }
.login-error { color: #ff4466; font-size: 12px; margin-top: 12px; min-height: 16px; }

/* ─── 3D World Container ─── */
#world-container {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  cursor: grab;
}
#world-container:active { cursor: grabbing; }

/* ─── HUD Overlay ─── */
#hud {
  position: absolute; top: 0; left: 0; width: 100%;
  pointer-events: none; z-index: 10;
  overflow: hidden; /* prevent HUD children from extending past viewport */
}
#hud-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px;
  position: relative;
}
#hud-top > * { pointer-events: auto; }

/* ═══════════════════════════════════════════
   LOGO + THINKING ANIMATIONS + NAV
   Vertically stacked: Logo → Thinking → Hamburger → (Stocks below)
   ═══════════════════════════════════════════ */

/* ─── Left column container (logo + hamburger vertically aligned) ─── */
#hud-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 16px 20px; position: relative;
  overflow: visible; /* must be visible so nav dropdown shows outside */
}

/* Left stack: logo → hamburger (vertically aligned) */
.hud-left-stack {
  display: flex; flex-direction: column; align-items: flex-start;
  pointer-events: auto;
  overflow: hidden; /* clip thinking animation pseudo-elements */
  min-width: 0;
}

/* ─── Logo block ─── */
.hud-logo-block {
  display: flex; flex-direction: column; align-items: flex-start;
  pointer-events: auto; position: relative;
  padding: 4px 0;
  overflow: hidden; /* clip thinking animation pseudo-elements at block edges */
}

/* The text itself — Orbitron, teal-to-green gradient */
.hud-logo-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 32px; font-weight: 900; letter-spacing: 5px;
  background: linear-gradient(90deg, #00b4d8, #00d4a8, #4ade80);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 12px rgba(0, 210, 180, 0.35)) drop-shadow(0 0 40px rgba(0, 180, 216, 0.15));
  line-height: 1; position: relative; z-index: 2;
  transition: filter 0.5s;
}

/* ─── Idle dot ─── */
.hud-logo-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: #00b4d8; margin: 8px 0 0 2px;
  box-shadow: 0 0 6px rgba(0, 180, 216, 0.6);
  transition: opacity 0.4s;
}
.hud-logo-block.thinking .hud-logo-dot { opacity: 0; }

/* ─── THINKING text (simple, no size pulse) ─── */
.hud-thinking {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px; letter-spacing: 4px; font-weight: 700;
  color: #00d4a8; text-transform: uppercase;
  margin-top: 4px; opacity: 0.8;
  text-shadow: 0 0 10px rgba(0, 212, 168, 0.5);
}
.hud-thinking.hidden { display: none; }

/* ═══ THINKING MODE: Epic animations around the logo ═══ */

/* 1. Gradient shimmer sweep across text */
.hud-logo-block.thinking .hud-logo-text {
  background: linear-gradient(90deg, #00b4d8, #4ade80, #00ffcc, #00b4d8, #4ade80);
  background-size: 300% 100%;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: logo-shimmer 2.5s linear infinite;
  filter: drop-shadow(0 0 20px rgba(0, 255, 204, 0.5)) drop-shadow(0 0 60px rgba(0, 180, 216, 0.3));
}
@keyframes logo-shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

/* 2. Scanning line that sweeps across the text */
.hud-logo-block.thinking::before {
  content: '';
  position: absolute; top: 0; left: -20%; width: 15%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 204, 0.15), rgba(255, 255, 255, 0.08), transparent);
  z-index: 3; pointer-events: none;
  animation: scan-line 2s ease-in-out infinite;
}
@keyframes scan-line {
  0% { left: -20%; }
  100% { left: 120%; }
}

/* 3. Glowing underline that pulses */
.hud-logo-block.thinking::after {
  content: '';
  position: absolute; bottom: 18px; left: 0; right: 40%;
  height: 1px;
  background: linear-gradient(90deg, #00b4d8, #00ffcc, transparent);
  box-shadow: 0 0 8px rgba(0, 255, 204, 0.6), 0 0 20px rgba(0, 180, 216, 0.3);
  animation: underline-glow 1.5s ease-in-out infinite alternate;
  z-index: 1;
}
@keyframes underline-glow {
  0% { opacity: 0.3; right: 60%; }
  100% { opacity: 1; right: 10%; }
}

/* 4. Particle sparkles around the text (via box-shadow on dot) */
.hud-logo-block.thinking .hud-logo-dot {
  opacity: 1; width: 0; height: 0; background: transparent;
  box-shadow:
    -8px -28px 0 1px rgba(0, 255, 204, 0.7),
    40px -32px 0 0.5px rgba(74, 222, 128, 0.5),
    90px -26px 0 1px rgba(0, 180, 216, 0.6),
    140px -30px 0 0.5px rgba(0, 255, 204, 0.4),
    180px -28px 0 1px rgba(74, 222, 128, 0.5),
    20px -36px 0 0.5px rgba(0, 212, 168, 0.6),
    110px -34px 0 0.5px rgba(0, 255, 204, 0.3),
    60px -38px 0 1px rgba(74, 222, 128, 0.4);
  animation: sparkle-dance 3s ease-in-out infinite;
}
@keyframes sparkle-dance {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  25% { transform: translateY(-2px); opacity: 1; }
  50% { transform: translateY(1px); opacity: 0.4; }
  75% { transform: translateY(-1px); opacity: 0.9; }
}

/* ─── Hamburger nav toggle — aligned under logo ─── */
.nav-toggle {
  background: none; border: none; color: rgba(0, 180, 216, 0.85);
  font-size: 22px; cursor: pointer; padding: 6px 4px;
  pointer-events: auto; transition: color 0.15s;
  margin-top: 4px; display: block;
  position: relative; z-index: 2000;
}
.nav-toggle:hover { color: #0cf; }

/* Nav dropdown menu */
#nav-dropdown {
  position: absolute; top: 90px; left: 20px; z-index: 100;
  background: rgba(8, 8, 22, 0.96); border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 10px; backdrop-filter: blur(16px); padding: 8px 0;
  min-width: 200px; box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
#nav-dropdown.hidden { display: none; }
.nav-dropdown-item {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 10px 16px; background: none;
  border: none; color: #aab; font-size: 13px; text-align: left;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.nav-dropdown-item:hover { background: rgba(0, 255, 255, 0.06); color: #fff; }
.nav-dropdown-email { color: #667; font-size: 11px; padding: 6px 16px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.nav-dropdown-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 4px 0; }
/* Old orbital logo CSS removed — replaced by gradient text logo above */
/* ─── Bottom Bar (indicator + profile) ─── */
#jarvis-bottom-bar {
  position: fixed;
  bottom: 16px; left: 16px;
  z-index: 50;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
}
#jarvis-bottom-bar > * { pointer-events: auto; }

#jarvis-indicator {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px 6px 10px;
  border-radius: 20px;
  background: rgba(6, 6, 18, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(100, 100, 100, 0.2);
  transition: all 0.3s ease;
  pointer-events: none;
}
.indicator-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: block; flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.indicator-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  transition: color 0.3s;
}

/* States */
.indicator-idle { border-color: rgba(0, 255, 100, 0.25); }
.indicator-idle .indicator-dot { background: #00ff66; box-shadow: 0 0 8px rgba(0, 255, 100, 0.6); }
.indicator-idle .indicator-label { color: #00ff66; }

.indicator-working { border-color: rgba(0, 200, 255, 0.35); }
.indicator-working .indicator-dot {
  background: #00ccff;
  box-shadow: 0 0 10px rgba(0, 200, 255, 0.7);
  animation: indicator-pulse 1.2s ease-in-out infinite;
}
.indicator-working .indicator-label { color: #00ccff; }

.indicator-error { border-color: rgba(255, 50, 50, 0.3); }
.indicator-error .indicator-dot { background: #ff4444; box-shadow: 0 0 8px rgba(255, 50, 50, 0.6); }
.indicator-error .indicator-label { color: #ff4444; }

.indicator-disconnected { border-color: rgba(100, 100, 100, 0.2); }
.indicator-disconnected .indicator-dot { background: #555; box-shadow: none; }
.indicator-disconnected .indicator-label { color: #555; }

@keyframes indicator-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(0, 200, 255, 0.7); }
  50% { transform: scale(1.5); box-shadow: 0 0 20px rgba(0, 255, 255, 0.9); }
}

#hud-status {
  font-size: 11px; padding: 4px 12px; border-radius: 3px;
  letter-spacing: 1px;
}
.status-disconnected { background: rgba(255, 50, 50, 0.3); color: #ff6666; border: 1px solid #ff3333; }
#hud-profile {
  padding: 6px 14px 6px 10px; border-radius: 20px; font-size: 11px; letter-spacing: 0.5px;
  background: rgba(6, 6, 18, 0.85); border: 1px solid rgba(0, 200, 255, 0.2);
  backdrop-filter: blur(10px);
  color: #88ccdd; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
#hud-profile::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #00cc88; flex-shrink: 0; }
#hud-profile:hover { background: rgba(0, 200, 255, 0.12); border-color: rgba(0, 200, 255, 0.35); }
.status-connected { background: rgba(0, 255, 100, 0.2); color: #00ff66; border: 1px solid #00ff66; }
.status-working { background: rgba(0, 200, 255, 0.2); color: #00ccff; border: 1px solid #00ccff; animation: pulse-border 1.5s infinite; }

@keyframes pulse-border {
  0%, 100% { border-color: #00ccff; }
  50% { border-color: #00ffff; box-shadow: 0 0 10px rgba(0, 255, 255, 0.3); }
}

#hud-hint {
  text-align: center; padding: 8px;
  color: rgba(0, 255, 255, 0.5); font-size: 12px;
  animation: fade-hint 3s ease-in-out infinite;
}
@keyframes fade-hint {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ─── Side Panel ─── */
#side-panel {
  position: absolute; top: 0; right: 0;
  width: 480px; max-width: 100vw; height: 100%;
  background: rgba(6, 6, 18, 0.92);
  border-left: 1px solid rgba(0, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  display: flex; flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 20;
}
#side-panel.collapsed { transform: translateX(100%); }
#side-panel.collapsed #panel-toggle { transform: translateX(-100%) rotate(180deg); }

#panel-toggle {
  position: absolute; left: -32px; top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 48px;
  background: rgba(6, 6, 18, 0.9);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-right: none; border-radius: 6px 0 0 6px;
  color: #00ffff; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.3s;
}
#panel-toggle:hover { background: rgba(0, 255, 255, 0.1); }

/* ─── Tabs ─── */
#panel-tabs {
  display: flex; border-bottom: 1px solid rgba(0, 255, 255, 0.15);
  flex-shrink: 0;
  overflow: hidden;
}
.tab-btn {
  flex: 1; padding: 10px 8px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: #668; font-size: 11px; font-weight: 600; letter-spacing: 1px;
  cursor: pointer; transition: all 0.2s;
  font-family: inherit;
}
.tab-btn:hover { color: #aac; background: rgba(0, 255, 255, 0.03); }
.tab-btn.active {
  color: #00ffff; border-bottom-color: #00ffff;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
}

/* ─── Tab Panels ─── */
.tab-panel {
  display: none; flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative; /* contain absolute-positioned children (e.g. VFS panel) */
}
.tab-panel.active { display: flex; }

/* ─── Building Panel (dynamic content area) ─── */
#panel-building {
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* ─── Chat Panel (used by JARVIS building panel.js) ─── */
.jarvis-messages {
  flex: 1;
  overflow-y: scroll;
  overflow-x: hidden;
  padding: 12px;
  min-height: 0;
}
.jarvis-messages > * {
  margin-bottom: 8px;
}
.chat-message {
  padding: 8px 12px; border-radius: 6px;
  max-width: 95%; word-wrap: break-word;
}
.chat-message.user {
  align-self: flex-end;
  background: rgba(0, 100, 255, 0.15);
  border: 1px solid rgba(0, 100, 255, 0.3);
}
.chat-message.assistant {
  align-self: flex-start;
  background: rgba(0, 255, 255, 0.05);
  border: 1px solid rgba(0, 255, 255, 0.15);
}
.chat-message.tool {
  align-self: flex-start; font-size: 11px;
  background: rgba(255, 200, 0, 0.08);
  border: 1px solid rgba(255, 200, 0, 0.2);
  color: #ccaa44;
}
.message-role {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  margin-bottom: 4px; text-transform: uppercase;
}
.chat-message.user .message-role { color: #4488ff; }
.chat-message.assistant .message-role { color: #00ffff; }
.message-text { white-space: pre-wrap; line-height: 1.5; }

/* ─── Live Coding Blocks ─── */
.tool-block {
  margin: 6px 0; border-radius: 6px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
}
.tool-header {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; font-weight: 600; font-size: 11px;
}
.tool-header.read { background: rgba(0, 150, 255, 0.1); color: #4499dd; }
.tool-header.write { background: rgba(0, 220, 100, 0.1); color: #44cc77; }
.tool-header.search { background: rgba(200, 150, 0, 0.1); color: #ccaa44; }
.tool-header.command { background: rgba(180, 100, 255, 0.1); color: #bb88ee; }
.tool-header.list { background: rgba(100, 180, 255, 0.08); color: #6699cc; }
.tool-header.working { background: rgba(0, 200, 255, 0.08); color: #00ccff; }
.tool-header.error { background: rgba(255, 50, 50, 0.1); color: #ff6666; }
.tool-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; }
.tool-icon.spinner { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { 100% { transform: rotate(360deg); } }
.tool-action { text-transform: uppercase; letter-spacing: 0.5px; }
.tool-filepath {
  color: #55aadd; cursor: pointer; text-decoration: underline;
  text-decoration-color: rgba(85, 170, 221, 0.3);
}
.tool-filepath:hover { text-decoration-color: #55aadd; }
.tool-meta { color: #667; margin-left: auto; font-weight: 400; }
.tool-cmd { color: #bb88ee; background: rgba(180, 100, 255, 0.1); padding: 2px 6px; border-radius: 3px; font-size: 11px; }
.tool-code {
  margin: 0; padding: 8px 10px; max-height: 250px; overflow-y: auto;
  overflow-x: auto;
  background: rgba(0, 0, 0, 0.3); font-size: 11px; line-height: 1.5;
  white-space: pre; font-family: 'SF Mono', 'Fira Code', monospace;
  color: #aabbcc;
}
.tool-diff { background: rgba(0, 0, 0, 0.4); }
.line-num { color: #334; user-select: none; margin-right: 8px; }
.diff-add { display: block; background: rgba(0, 200, 80, 0.12); color: #66dd88; }
.diff-remove { display: block; background: rgba(255, 50, 50, 0.1); color: #cc6666; text-decoration: line-through; opacity: 0.7; }
.tool-truncated { color: #445; font-style: italic; }
.tool-block.collapsed .tool-code { display: none; }
.tool-block.collapsed .tool-header { opacity: 0.7; }
.tool-block.collapsed { border-color: transparent; }
.tool-working { opacity: 0.7; }
.tool-screenshot { width: 100%; border-radius: 4px; border: 1px solid rgba(100,150,255,0.2); }
.tool-verify-pass { border-color: rgba(0,200,80,0.2); }
.tool-live-stream { border-color: rgba(0, 220, 100, 0.25); }
.tool-live-stream .tool-stream-code {
  max-height: 300px; overflow-y: auto;
  border-left: 2px solid rgba(0, 220, 100, 0.4);
}
.tool-stream-status { color: #44cc77; animation: pulse-border 1.5s infinite; }

.jarvis-input-area {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(0, 255, 255, 0.1);
  position: relative;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.4);
}
.jarvis-input-toolbar {
  display: flex; align-items: center; gap: 4px;
}
.jarvis-input-row {
  display: flex; align-items: flex-end; gap: 8px;
}
.jarvis-input {
  flex: 1;
  min-height: 60px; /* ~2 lines visible by default */
  max-height: 160px; /* ~5-6 lines max before capping */
  height: 60px; /* JS will override this as user types */
  overflow-y: auto; resize: none;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 8px; color: #e0e0e0;
  font-family: inherit; font-size: 16px; line-height: 1.5;
  outline: none;
  /* scroll-padding-bottom keeps cursor visible at bottom */
  scroll-padding-bottom: 4px;
}
.jarvis-input:focus { border-color: #00ffff; box-shadow: 0 0 8px rgba(0, 255, 255, 0.15); }
.jarvis-send {
  height: 40px; padding: 0 16px; flex-shrink: 0;
  background: rgba(0, 255, 255, 0.15);
  border: 1px solid rgba(0, 255, 255, 0.4);
  border-radius: 8px; color: #00ffff;
  font-family: inherit; font-size: 11px; font-weight: 700;
  letter-spacing: 1px; cursor: pointer;
  transition: all 0.2s;
}
.jarvis-send:hover { background: rgba(0, 255, 255, 0.25); }
.jarvis-clear {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 10px;
  background: rgba(255, 50, 50, 0.1);
  border: 1px solid rgba(255, 50, 50, 0.3);
  border-radius: 6px; color: #cc4444;
  cursor: pointer; transition: all 0.2s;
  font-family: inherit;
}
.jarvis-stop {
  padding: 8px 14px;
  background: rgba(255, 50, 50, 0.2);
  border: 1px solid rgba(255, 50, 50, 0.5);
  border-radius: 6px; color: #ff4444;
  font-family: inherit; font-size: 11px; font-weight: 700;
  letter-spacing: 1px; cursor: pointer; transition: all 0.2s;
}
.jarvis-stop:hover { background: rgba(255, 50, 50, 0.35); }
.jarvis-clear:hover { background: rgba(255, 50, 50, 0.2); }
/* ─── VFS Section in FILES tab ─── */
.vfs-section {
  display: flex; flex-direction: column;
  border-top: 1px solid rgba(0, 200, 255, 0.1);
  flex: 1; overflow: hidden;
}
.vfs-header {
  display: flex; align-items: center; padding: 8px 12px;
  border-bottom: 1px solid rgba(0, 200, 255, 0.1);
  background: rgba(0, 200, 255, 0.04);
}
.vfs-title {
  flex: 1; font-size: 13px; font-weight: 600;
  color: #00ccff; letter-spacing: 0.5px;
}
.vfs-header button {
  background: none; border: none; color: #668;
  font-size: 16px; cursor: pointer; padding: 2px 6px;
}
.vfs-header button:hover { color: #00ccff; }
.vfs-body {
  overflow-y: auto; flex: 1; padding: 6px 0;
}
.vfs-group { margin-bottom: 4px; }
.vfs-group-header {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: rgba(255,255,255,0.4);
  padding: 6px 12px 3px; letter-spacing: 0.5px;
  text-transform: uppercase;
}
.vfs-count { color: rgba(255,255,255,0.25); }
.vfs-file {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px; font-size: 12px;
  color: rgba(255,255,255,0.7);
  transition: background 0.15s;
}
.vfs-file:hover { background: rgba(0, 200, 255, 0.06); }
.vfs-filename { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vfs-size { color: rgba(255,255,255,0.3); font-size: 11px; min-width: 50px; text-align: right; }
.vfs-download {
  display: inline-flex; align-items: center;
  color: #448; text-decoration: none; background: none; border: none;
  cursor: pointer; padding: 0 2px;
}
.vfs-download:hover { color: #00ccff; }
.vfs-delete {
  display: inline-flex; align-items: center;
  background: none; border: none; color: #644;
  cursor: pointer; padding: 0 2px;
}
.vfs-delete:hover { color: #ff4444; }
.vfs-file-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 18px; }
.vfs-preview {
  display: inline-flex; align-items: center;
  background: none; border: none; color: #448;
  cursor: pointer; padding: 0 2px;
}
.vfs-preview:hover { color: #00ccff; }
/* ─── File Viewer Overlay ─── */
.file-viewer-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8); z-index: 10000;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.file-viewer {
  background: rgba(12, 16, 30, 0.98);
  border: 1px solid rgba(0, 200, 255, 0.2);
  border-radius: 12px; width: 90vw; max-width: 900px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.7), 0 0 40px rgba(0, 200, 255, 0.05);
  overflow: hidden;
}
.file-viewer-header {
  display: flex; align-items: center; padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 200, 255, 0.1);
  background: rgba(0, 200, 255, 0.04);
}
.file-viewer-title {
  flex: 1; font-size: 14px; font-weight: 600;
  color: #00ccff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-viewer-actions { display: flex; align-items: center; gap: 10px; }
.file-viewer-download {
  display: inline-flex; align-items: center; gap: 4px;
  color: #4af; text-decoration: none; font-size: 12px;
  padding: 4px 10px; border: 1px solid rgba(0, 200, 255, 0.2);
  border-radius: 4px; transition: background 0.15s;
  background: none; cursor: pointer;
}
.file-viewer-download:hover { background: rgba(0, 200, 255, 0.1); }
.file-viewer-close {
  background: none; border: none; color: #668; font-size: 20px;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.file-viewer-close:hover { color: #ff4444; }
.file-viewer-body {
  flex: 1; overflow: auto; min-height: 200px;
  color: rgba(255, 255, 255, 0.85);
}
.file-viewer-markdown { font-size: 13px; line-height: 1.6; color: #ccc; }
.file-viewer-markdown h1, .file-viewer-markdown h2, .file-viewer-markdown h3 { color: #00ccff; margin: 12px 0 6px; }
.file-viewer-markdown code { background: rgba(0, 200, 255, 0.08); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.file-viewer-markdown strong { color: #fff; }
/* ─── Token Usage Panel ─── */
.usage-card {
  background: rgba(0, 255, 255, 0.03); border: 1px solid rgba(0, 255, 255, 0.1);
  border-radius: 10px; padding: 16px 20px;
}
.usage-label { font-size: 11px; color: rgba(255,255,255,0.4); letter-spacing: 1px; margin-bottom: 6px; }
.usage-value { font-family: 'Orbitron', sans-serif; font-size: 28px; font-weight: 700; color: #00d4ff; letter-spacing: 2px; }
#usage-total .usage-value, #usage-total { color: #4ade80; }
.usage-card:last-child .usage-value { color: #4ade80; }

.clear-confirm-overlay {
  position: absolute; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.clear-confirm-dialog {
  background: rgba(12, 12, 30, 0.95); border: 1px solid rgba(255, 80, 80, 0.3);
  border-radius: 12px; padding: 20px 24px; max-width: 320px; width: 90%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.jarvis-mic {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 10px;
  background: rgba(100, 100, 255, 0.1);
  border: 1px solid rgba(100, 100, 255, 0.3);
  border-radius: 6px; color: #8888ff;
  cursor: pointer; transition: all 0.2s;
  font-family: inherit;
}
.jarvis-mic:hover { background: rgba(100, 100, 255, 0.2); }
.jarvis-tts-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 10px; background: rgba(50, 180, 100, 0.1);
  border: 1px solid rgba(50, 180, 100, 0.3); border-radius: 6px;
  color: #44aa66; cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.jarvis-tts-btn:hover { background: rgba(50, 180, 100, 0.2); }
.jarvis-tts-btn.active { background: rgba(50, 255, 100, 0.2); border-color: rgba(50, 255, 100, 0.5); color: #44ff66; }
.jarvis-mic.listening {
  background: rgba(255, 50, 50, 0.2);
  border-color: rgba(255, 50, 50, 0.5);
  color: #ff4444;
  animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 50, 50, 0.3); }
  50% { box-shadow: 0 0 12px 4px rgba(255, 50, 50, 0.2); }
}

.jarvis-attach-wrapper {
  position: relative;
}
.jarvis-attach-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; cursor: pointer;
  color: #557; background: none; border: 1px solid rgba(0,255,255,0.15);
  border-radius: 6px; transition: all 0.2s; font-family: inherit;
}
.jarvis-attach-btn:hover { color: #00ccff; border-color: rgba(0,255,255,0.3); }
.jarvis-attach-menu {
  display: none; flex-direction: column;
  position: absolute; bottom: 100%; left: 0;
  margin-bottom: 6px; min-width: 170px;
  background: rgba(8, 12, 24, 0.97);
  border: 1px solid rgba(0, 200, 255, 0.15);
  border-radius: 8px; z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  overflow: hidden;
}
.jarvis-attach-option {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; font-size: 13px;
  color: rgba(255,255,255,0.7); cursor: pointer;
  transition: background 0.15s;
}
.jarvis-attach-option:hover {
  background: rgba(0, 200, 255, 0.08); color: #00ccff;
}
.jarvis-attachments {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 0;
}
.jarvis-attachments:empty { display: none; }
.attachment-chip {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 4px;
  background: rgba(0, 200, 255, 0.08);
  border: 1px solid rgba(0, 200, 255, 0.2);
  font-size: 11px; color: #88aacc;
  max-width: 220px;
}
.attachment-thumb {
  width: 28px; height: 28px; border-radius: 3px;
  object-fit: cover;
}
.att-icon { display: inline-flex; align-items: center; flex-shrink: 0; }
.att-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { font-size: 9px; color: #667; flex-shrink: 0; }
.att-remove { display: inline-flex; align-items: center; cursor: pointer; color: #664444; margin-left: 4px; flex-shrink: 0; }
.att-remove svg { width: 10px; height: 10px; }
.att-remove:hover { color: #ff4444; }
.att-status { display: inline-flex; align-items: center; flex-shrink: 0; margin-left: 2px; }
.att-status svg { width: 10px; height: 10px; }
.att-progress { color: #00ccff; font-weight: 600; min-width: 28px; text-align: right; }
.att-ready { color: #44cc88; }
.att-error { color: #ff4444; }
.att-uploading { border-color: rgba(0, 200, 255, 0.4); animation: att-pulse 1.5s ease-in-out infinite; }
.att-failed { border-color: rgba(255, 68, 68, 0.3); background: rgba(255, 68, 68, 0.06); opacity: 0.6; }
@keyframes att-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
.drag-over {
  border-color: #00ffff !important;
  background: rgba(0, 255, 255, 0.08) !important;
  box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.1) !important;
}
.drag-over::after {
  content: 'Drop files or folders here';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #00ccff; font-size: 13px; pointer-events: none;
  text-shadow: 0 0 8px rgba(0, 200, 255, 0.4);
}

#file-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.1);
  flex-shrink: 0; color: #668;
}
#file-toolbar button {
  background: none; border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 4px; color: #00cccc; padding: 2px 8px;
  cursor: pointer; font-size: 14px; font-family: inherit;
}
#file-toolbar button:hover { background: rgba(0, 255, 255, 0.1); }
#file-tree {
  flex: 1; overflow-y: auto; padding: 8px;
}
.file-item {
  padding: 6px 10px; cursor: pointer; border-radius: 4px;
  display: flex; align-items: center; gap: 8px;
  transition: background 0.15s;
}
.file-item:hover { background: rgba(0, 255, 255, 0.06); }
.file-item.selected { background: rgba(0, 255, 255, 0.12); border-left: 2px solid #00ffff; }
.file-item.directory { color: #55aacc; font-weight: 600; }
.file-item.file { color: #aabbcc; }
.file-icon { font-size: 12px; width: 18px; text-align: center; display: inline-block; }
.dir-arrow { font-size: 10px; transition: transform 0.15s; }
.dir-children { border-left: 1px solid rgba(0, 255, 255, 0.08); margin-left: 20px; }

#editor-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.1);
  flex-shrink: 0;
}
#editor-filename { color: #55aacc; font-size: 12px; }
#editor-save {
  padding: 4px 14px;
  background: rgba(0, 200, 100, 0.15);
  border: 1px solid rgba(0, 200, 100, 0.4);
  border-radius: 4px; color: #00cc66;
  font-family: inherit; font-size: 11px; font-weight: 700;
  letter-spacing: 1px; cursor: pointer;
}
#editor-save:hover { background: rgba(0, 200, 100, 0.25); }
#monaco-editor { flex: 1; }

#log-content {
  flex: 1; overflow-y: auto; padding: 10px;
  font-size: 11px; line-height: 1.6;
}
.log-entry { padding: 2px 0; }
.log-time { color: #445; margin-right: 6px; }
.log-entry.info { color: #88aacc; }
.log-entry.success { color: #44cc88; }
.log-entry.error { color: #ff6666; }
.log-entry.tool { color: #ccaa44; }
.log-entry.ai { color: #00ccff; }

.queue-display {
  padding: 6px 10px; border-bottom: 1px solid rgba(0,200,255,0.15);
  background: rgba(0,200,255,0.04); flex-shrink: 0;
}
.queue-header { font-size: 10px; color: #00aacc; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 4px; }
.queue-item { font-size: 11px; color: #668; padding: 2px 0; display: flex; align-items: center; gap: 6px; }
.queue-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.queue-remove { background: none; border: none; color: #f44; font-size: 14px; cursor: pointer; padding: 0 4px; opacity: 0.5; flex-shrink: 0; }
.queue-remove:hover { opacity: 1; }

.input-lock-banner {
  padding: 8px 16px; text-align: center;
  background: rgba(255, 170, 0, 0.12); border-bottom: 1px solid rgba(255, 170, 0, 0.3);
  color: #ddaa33; font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
  animation: pulse-border 1.5s infinite;
  flex-shrink: 0;
}

#saves-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid rgba(0,255,255,0.1); flex-shrink: 0;
}
#saves-toolbar button {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(0,255,255,0.08); border: 1px solid rgba(0,255,255,0.2);
  border-radius: 4px; color: #00cccc; padding: 5px 12px; cursor: pointer;
  font-size: 11px; font-family: inherit;
}
#saves-toolbar button:hover { background: rgba(0,255,255,0.15); }
#saves-undo { color: #ccaa44; border-color: rgba(200,170,0,0.3); background: rgba(200,170,0,0.08); }
#saves-undo:hover { background: rgba(200,170,0,0.15); }
#saves-status { color: #557; font-size: 11px; margin-left: auto; }
#saves-list { flex: 1; overflow-y: scroll; padding: 8px; min-height: 0; }
.save-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 5px; margin-bottom: 4px; font-size: 11px;
  border: 1px solid rgba(255,255,255,0.04);
}
.save-item:hover { background: rgba(0,255,255,0.03); }
.save-item.current { border-color: rgba(0,200,255,0.3); background: rgba(0,200,255,0.05); }
.save-hash { color: #00cccc; font-weight: 700; width: 52px; flex-shrink: 0; font-family: monospace; }
.save-msg { color: #aab; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-date { color: #445; font-size: 10px; flex-shrink: 0; }
.save-revert {
  color: #557; cursor: pointer; font-size: 10px; padding: 2px 8px;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 3px;
  opacity: 0; transition: opacity 0.15s;
}
.save-item:hover .save-revert { opacity: 1; }
.save-revert:hover { color: #ff8844; border-color: rgba(255,136,68,0.3); }

#hud-context-bar {
  width: 120px; height: 16px; background: rgba(255,255,255,0.06);
  border: 1px solid rgba(0,255,255,0.15); border-radius: 8px;
  position: relative; cursor: pointer; overflow: hidden;
  pointer-events: auto;
}
#context-fill {
  height: 100%; background: linear-gradient(90deg, #00cc66, #00ccff);
  border-radius: 8px; transition: width 0.5s ease;
  width: 0%;
}
#context-fill.warn { background: linear-gradient(90deg, #ccaa00, #ff8800); }
#context-fill.danger { background: linear-gradient(90deg, #ff4400, #ff0000); }
#context-label {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; letter-spacing: 0.5px; color: #ccc;
}
#hud-workspace {
  font-size: 10px; color: #557; pointer-events: auto; cursor: pointer;
  padding: 2px 8px; border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.06);
}
#hud-workspace.modified { color: #ccaa44; background: rgba(200,170,0,0.1); border-color: rgba(200,170,0,0.2); }
#hud-agents {
  font-size: 10px; color: #557; pointer-events: auto; cursor: pointer;
  padding: 2px 8px; border-radius: 3px;
}
#hud-agents.active { color: #00ccff; background: rgba(0,200,255,0.1); }

/* Runtime Panel */
#runtime-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid rgba(0,255,255,0.1); flex-shrink: 0;
}
#runtime-toolbar button {
  background: rgba(0,255,255,0.08); border: 1px solid rgba(0,255,255,0.2);
  border-radius: 4px; color: #00cccc; padding: 4px 10px; cursor: pointer;
  font-size: 11px; font-family: inherit; margin-left: auto;
}
#runtime-toolbar button:hover { background: rgba(0,255,255,0.15); }
.runtime-section {
  border: 1px solid rgba(255,255,255,0.06); border-radius: 8px;
  padding: 10px 12px; background: rgba(255,255,255,0.02);
}
.runtime-section-title {
  font-size: 10px; font-weight: 700; color: #668; letter-spacing: 1px;
  text-transform: uppercase; margin-bottom: 8px;
}
.runtime-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.runtime-stat {
  display: flex; flex-direction: column; gap: 2px;
}
.runtime-stat-label { font-size: 10px; color: #557; }
.runtime-stat-value { font-size: 13px; color: #aac; font-weight: 600; }
.runtime-empty { font-size: 11px; color: #446; font-style: italic; }
.runtime-jobs-list, .runtime-workspace-list {
  display: flex; flex-direction: column; gap: 4px;
}
.runtime-job-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: rgba(255,255,255,0.03); border-radius: 6px; font-size: 11px;
}
.runtime-job-tool { color: #aac; font-weight: 600; }
.runtime-job-status { font-size: 10px; padding: 1px 6px; border-radius: 3px; }
.runtime-job-status.running { color: #00ccff; background: rgba(0,200,255,0.1); }
.runtime-job-status.done { color: #44dd66; background: rgba(0,200,80,0.1); }
.runtime-job-status.error { color: #ff6666; background: rgba(255,80,80,0.1); }
.runtime-job-status.queued { color: #ccaa44; background: rgba(200,170,0,0.1); }
.runtime-job-status.cancelled { color: #888; background: rgba(128,128,128,0.1); }
.runtime-job-duration { color: #557; margin-left: auto; }
.runtime-overlay-item {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px;
  background: rgba(255,255,255,0.03); border-radius: 6px; font-size: 11px;
}
.runtime-overlay-path { color: #aac; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runtime-overlay-reset {
  font-size: 9px; color: #ff6666; cursor: pointer; padding: 2px 6px;
  border: 1px solid rgba(255,80,80,0.2); border-radius: 3px; background: transparent;
}
.runtime-overlay-reset:hover { background: rgba(255,50,50,0.15); }
.runtime-env-summary {
  display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: #889;
}
.runtime-env-row { display: flex; gap: 6px; }
.runtime-env-label { color: #557; min-width: 80px; }
.runtime-env-value { color: #aac; }
/* Job result card in chat */
.job-result-card {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: 8px; font-size: 12px; margin: 4px 0;
}
.job-result-card.success {
  background: rgba(0,200,80,0.08); border: 1px solid rgba(0,200,80,0.2); color: #44dd66;
}
.job-result-card.failure {
  background: rgba(255,50,50,0.08); border: 1px solid rgba(255,50,50,0.2); color: #ff6666;
}
.job-result-icon { display: inline-flex; align-items: center; }
.job-result-text { flex: 1; }
.job-result-duration { color: #557; font-size: 10px; }

#context-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid rgba(0,255,255,0.1); flex-shrink: 0;
}
#context-toolbar button {
  background: rgba(0,255,255,0.08); border: 1px solid rgba(0,255,255,0.2);
  border-radius: 4px; color: #00cccc; padding: 4px 10px; cursor: pointer;
  font-size: 11px; font-family: inherit;
}
#context-toolbar button:hover { background: rgba(0,255,255,0.15); }
#context-summary { color: #668; font-size: 11px; margin-left: auto; }
#context-breakdown {
  padding: 8px 12px; border-bottom: 1px solid rgba(0,255,255,0.05);
  display: flex; gap: 12px; flex-wrap: wrap; flex-shrink: 0;
}
.ctx-stat {
  display: flex; flex-direction: column; align-items: center;
  font-size: 10px; color: #557; gap: 2px;
  transition: opacity 0.2s, transform 0.1s;
}
.ctx-filter { cursor: pointer; border-radius: 6px; padding: 4px 6px; }
.ctx-filter:hover { background: rgba(255,255,255,0.05); transform: scale(1.05); }
.ctx-stat-value { font-size: 14px; font-weight: 700; }
.ctx-stat-value.system { color: #8866cc; }
.ctx-stat-value.user { color: #4488ff; }
.ctx-stat-value.assistant { color: #00cccc; }
.ctx-stat-value.tool { color: #ccaa44; }
#context-messages {
  flex: 1; overflow-y: scroll; padding: 4px; min-height: 0;
}
#panel-context {
  min-height: 0;
}
.ctx-msg {
  padding: 2px 0; border-radius: 3px; font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.02);
}
.ctx-msg:hover { background: rgba(0,255,255,0.03); }
.ctx-msg-header {
  display: flex; align-items: center; gap: 6px; padding: 3px 8px;
  cursor: pointer;
}
.ctx-msg.expanded { background: rgba(0,255,255,0.04); }
.ctx-msg-full {
  padding: 0 8px 6px 66px;
}
.ctx-child {
  padding: 4px 8px; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.ctx-child-role {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  margin-right: 6px;
}
.ctx-child-role.system { color: #8866cc; }
.ctx-child-role.user { color: #4488ff; }
.ctx-child-role.assistant { color: #00cccc; }
.ctx-child-role.tool { color: #ccaa44; }
.ctx-child-tokens { font-size: 9px; color: #445; margin-right: 6px; }
.ctx-child-tools { font-size: 9px; color: #886; }
.ctx-full-content {
  margin: 4px 0 0 0; padding: 6px 8px; background: rgba(0,0,0,0.25);
  border-radius: 4px; font-size: 11px; color: #99aabb;
  white-space: pre-wrap; word-break: break-word;
  max-height: 300px; overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.ctx-role {
  width: 50px; font-weight: 600; text-transform: uppercase; font-size: 9px;
  letter-spacing: 0.5px; flex-shrink: 0;
}
.ctx-role.system { color: #8866cc; }
.ctx-role.user { color: #4488ff; }
.ctx-role.assistant { color: #00cccc; }
.ctx-role.tool { color: #ccaa44; }
.ctx-tokens {
  width: 40px; text-align: right; color: #445; font-size: 10px; flex-shrink: 0;
}
.ctx-preview { color: #667; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.ctx-msg.cleared { opacity: 0.4; }
.ctx-msg.summary { border-left: 2px solid #8866cc; }
.ctx-delete {
  opacity: 0; color: #663; cursor: pointer; font-size: 10px; flex-shrink: 0;
}
.ctx-msg:hover .ctx-delete { opacity: 1; }
.ctx-delete:hover { color: #f44; }

#agents-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid rgba(0,255,255,0.1); flex-shrink: 0;
}
#agents-toolbar button {
  background: rgba(0,255,255,0.08); border: 1px solid rgba(0,255,255,0.2);
  border-radius: 4px; color: #00cccc; padding: 4px 10px; cursor: pointer;
  font-size: 11px; font-family: inherit;
}
#agents-count { color: #668; font-size: 11px; margin-left: auto; }
#agents-list { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.agent-card {
  padding: 10px 12px; border-radius: 6px; margin-bottom: 8px;
  border: 1px solid rgba(0,255,255,0.1);
  background: rgba(0,255,255,0.02);
}
.agent-card.running { border-color: rgba(0,200,255,0.3); }
.agent-card.done { border-color: rgba(0,200,80,0.3); }
.agent-card.error { border-color: rgba(255,50,50,0.3); }
.agent-name { font-weight: 600; color: #aac; font-size: 12px; }
.agent-status { font-size: 10px; color: #557; margin-top: 4px; }
.agent-status.running { color: #00ccff; }
.agent-status.done { color: #44cc66; }
.agent-status.error { color: #ff6666; }
.agent-time { color: #557; font-family: monospace; margin-left: 4px; }
.agent-output {
  margin-top: 6px; padding: 6px 8px; background: rgba(0,0,0,0.2);
  border-radius: 4px; font-size: 11px; color: #889; max-height: 120px;
  overflow-y: auto; white-space: pre-wrap;
}

.jarvis-notification {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 30, 60, 0.95); border: 1px solid rgba(0, 200, 255, 0.4);
  border-radius: 8px; padding: 12px 20px; z-index: 1000;
  backdrop-filter: blur(10px); min-width: 250px; max-width: 500px;
  animation: notif-in 0.3s ease;
}
.jarvis-notification.fade-out { opacity: 0; transition: opacity 0.5s; }
.notif-title { color: #00ccff; font-weight: 700; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.notif-body { color: #ccc; font-size: 13px; }
@keyframes notif-in { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 255, 255, 0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 255, 255, 0.3); }

/* ─── Building Popups (non-JARVIS buildings) ─── */
.building-popup {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 520px; max-width: 90vw;
  height: 70vh; max-height: 80vh;
  background: rgba(8, 8, 22, 0.95);
  border: 1px solid rgba(0, 255, 255, 0.25);
  border-radius: 10px;
  backdrop-filter: blur(16px);
  display: flex; flex-direction: column;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 255, 255, 0.08);
  animation: popup-in 0.25s ease;
  overflow: hidden;
}
.building-popup.popup-focus {
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 255, 255, 0.15);
}
@keyframes popup-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.popup-titlebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0, 255, 255, 0.06);
  border-bottom: 1px solid rgba(0, 255, 255, 0.15);
  cursor: grab; user-select: none; flex-shrink: 0;
}
.popup-titlebar:active { cursor: grabbing; }
.popup-title {
  color: #00ccff; font-weight: 700; font-size: 13px;
  letter-spacing: 1.5px; text-transform: uppercase;
}
.popup-close {
  background: none; border: none; color: #667;
  font-size: 20px; cursor: pointer; padding: 0 4px;
  line-height: 1; transition: color 0.15s;
}
.popup-close:hover { color: #ff4466; }
.popup-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 0;
}

/* ─── Nav Menu (inside bottom bar, opens upward) ─── */
.nav-menu {
  position: absolute; bottom: 100%; left: 0; margin-bottom: 8px;
  background: rgba(8, 8, 22, 0.95); border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 10px; backdrop-filter: blur(16px);
  box-shadow: 0 -4px 30px rgba(0,0,0,0.5); min-width: 200px;
  padding: 6px 0; animation: menu-up 0.15s ease;
}
@keyframes menu-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.nav-menu.hidden { display: none; }
.nav-item {
  display: block; width: 100%; padding: 10px 18px; border: none; background: none;
  color: #ccd; font-size: 13px; text-align: left; cursor: pointer;
  font-family: inherit; transition: background 0.15s;
}
.nav-item:hover { background: rgba(0, 200, 255, 0.08); color: #fff; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 4px 0; }

/* ─── Settings Popup ─── */
.settings-popup {
  position: fixed; bottom: 56px; left: 16px; z-index: 55;
  width: 340px; max-width: calc(100vw - 32px); max-height: 70vh;
  background: rgba(8, 8, 22, 0.95); border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 12px; backdrop-filter: blur(16px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 20px rgba(0,255,255,0.06);
  overflow: hidden; animation: popup-in 0.2s ease;
}
.settings-popup.hidden { display: none; }
.settings-popup-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #00ccff; font-weight: 700; font-size: 12px; letter-spacing: 1.5px;
}
.settings-popup-body { padding: 16px; overflow-y: auto; max-height: 60vh; }

/* ─── Settings Styles ─── */
.settings-section { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.settings-label { font-weight: 700; color: #aab; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
.settings-btn {
  padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid rgba(0,200,255,0.3); background: rgba(0,200,255,0.08);
  color: #00ccff; margin-right: 6px; margin-top: 6px; transition: all 0.2s; font-family: inherit;
}
.settings-btn:hover { background: rgba(0,200,255,0.15); }
.settings-btn.danger { border-color: rgba(255,50,50,0.3); background: rgba(255,50,50,0.08); color: #ff5566; }
.settings-btn.danger:hover { background: rgba(255,50,50,0.15); }
.settings-select, .settings-input {
  width: 100%; padding: 8px 10px; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
  color: #ddd; font-size: 12px; font-family: inherit;
}
.settings-select:focus, .settings-input:focus { outline: none; border-color: rgba(0,200,255,0.3); }
.settings-toggle-label { color: #aab; font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 8px; }

/* ─── Integration Cards ─── */
.integration-card {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border: 1px solid rgba(255,255,255,0.06); border-radius: 8px;
  margin-bottom: 8px; transition: all 0.2s;
}
.integration-card:hover { border-color: rgba(0, 255, 255, 0.2); background: rgba(0,255,255,0.02); }
.integration-card.connected { border-color: rgba(0, 255, 100, 0.2); }
.integrations-search {
  flex: 1; padding: 6px 10px; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
  color: #ddd; font-size: 12px; font-family: inherit;
}
.integrations-search:focus { outline: none; border-color: rgba(0,200,255,0.3); }
#integrations-toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.integration-logo { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; border-radius: 4px; }
.integration-info { flex: 1; min-width: 0; }
.integration-name { font-weight: 700; color: #ddd; font-size: 13px; }
.integration-desc { color: #667; font-size: 11px; margin-top: 2px; }
.integration-btn {
  padding: 6px 14px; border-radius: 6px; font-size: 11px;
  font-weight: 700; cursor: pointer; transition: all 0.2s; border: 1px solid; flex-shrink: 0;
}
.integration-btn.connect { background: rgba(0,200,255,0.1); border-color: rgba(0,200,255,0.3); color: #00ccff; }
.integration-btn.connect:hover { background: rgba(0,200,255,0.2); }
.integration-btn.disconnect { background: rgba(0,255,100,0.1); border-color: rgba(0,255,100,0.2); color: #44dd66; }

/* ─── Tablet (< 900px) ─── */
@media (max-width: 900px) {
  #side-panel { width: 100%; }
  .building-popup { width: 95vw; height: 60vh; }
  .hud-title { padding: 8px 12px; min-height: 56px; gap: 10px; }
  .hud-title-brand { font-size: 20px !important; }
  .hud-logo-mark { width: 36px !important; height: 36px !important; }
}

/* ─── Mobile (< 600px) ─── */
@media (max-width: 600px) {
  /* HUD: compact logo, hide non-essential */
  .hud-title { padding: 6px 10px; min-height: 44px; gap: 8px; border-radius: 16px; }
  .hud-title-brand { font-size: 16px !important; letter-spacing: 2px !important; }
  .hud-logo-mark { width: 28px !important; height: 28px !important; }
  #hud-top { padding: 8px 10px; flex-wrap: wrap; gap: 6px; }
  #hud-context-bar { display: none; } /* hide context bar on mobile */
  #hud-agents { display: none; }
  #hud-status { font-size: 9px; padding: 3px 8px; }

  /* Side panel: slides up from bottom on mobile */
  #side-panel {
    width: 100%; height: 60vh;
    top: auto; bottom: 0; right: 0;
    border-left: none; border-top: 1px solid rgba(0, 255, 255, 0.15);
    border-radius: 16px 16px 0 0;
    transform: translateY(0);
    transition: transform 0.3s ease;
  }
  #side-panel.collapsed { transform: translateY(100%); }
  #panel-toggle {
    left: 50%; top: -36px;
    transform: translateX(-50%) rotate(-90deg);
    width: 40px; height: 36px;
    font-size: 18px; border-radius: 10px 10px 0 0;
  }
  #side-panel.collapsed #panel-toggle {
    transform: translateX(-50%) rotate(90deg);
  }
  #panel-tabs {
    flex-wrap: wrap; gap: 2px; padding: 4px;
    justify-content: center;
  }
  .tab-btn { font-size: 10px; padding: 6px 8px; }

  /* Chat input area */
  .jarvis-input { font-size: 16px !important; }
  .jarvis-input-toolbar button { padding: 10px 12px !important; }
  .jarvis-send { padding: 0 12px !important; }

  /* Bottom bar: above the panel */
  #jarvis-bottom-bar {
    bottom: 8px; left: 8px; right: 8px;
    gap: 6px; flex-wrap: wrap;
    transition: bottom 0.3s;
  }
  #jarvis-indicator { padding: 5px 10px; font-size: 10px; }
  .indicator-label { font-size: 9px !important; }
  #hud-profile { font-size: 10px; padding: 5px 10px; }

  /* Settings popup: full width on mobile */
  .settings-popup { left: 8px; right: 8px; width: auto; max-height: 60vh; }

  /* Building popups: full screen */
  .building-popup {
    width: 100vw !important; height: 100vh !important;
    max-width: 100vw; max-height: 100vh;
    top: 0 !important; left: 0 !important;
    transform: none !important; border-radius: 0;
  }

  /* Login screen: mobile-friendly */
  #login-screen { padding: 16px; }
  .login-card { padding: 28px 20px; max-width: 100%; width: 100%; border-radius: 12px; }
  .login-brand { font-size: 24px !important; letter-spacing: 4px !important; }
  .login-tagline { font-size: 11px; margin-bottom: 24px; }
  .login-btn { font-size: 15px; padding: 14px; min-height: 48px; }
  .login-input { font-size: 16px !important; padding: 12px 14px; } /* 16px prevents iOS zoom */
  .login-toggle { font-size: 13px; }
  .login-error { font-size: 13px; }

  /* Tool blocks: smaller */
  .tool-code { font-size: 11px; max-height: 200px; }
  .tool-header { font-size: 11px; padding: 6px 10px; }

  /* Monaco editor */
  #monaco-editor { min-height: 200px; }
}

/* ─── Small mobile (< 400px) ─── */
@media (max-width: 400px) {
  .hud-title-brand { font-size: 14px !important; }
  .tab-btn { font-size: 9px; padding: 5px 6px; }
  #hud-profile-email { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ─── Touch devices ─── */
@media (hover: none) {
  /* Larger touch targets */
  .tab-btn { min-height: 40px; }
  .jarvis-input-toolbar button, .jarvis-attach-btn { min-height: 44px; min-width: 44px; }
  .jarvis-send { min-height: 44px; min-width: 44px; }
  #panel-toggle { min-height: 56px; min-width: 44px; }
  .nav-item { min-height: 44px; display: flex; align-items: center; }
  .settings-btn { min-height: 40px; }
  .login-btn { min-height: 48px; }
  /* Remove hover effects that don't work on touch */
  .tool-block:hover { border-color: inherit; }
}


/* ─── Mobile Joystick ─── */
/* Hidden by default — shown by JS on touch devices only */
/* Lives in the HUD layer, z-index below side-panel (z-index: 20) */
/* Users/Jarvis can hide per-user by adding #mobile-joystick { display:none!important } in their overlay CSS */
.mobile-joystick-hidden {
  display: none !important;
}

#mobile-joystick {
  position: fixed;
  bottom: 24px;
  left: 20px;
  width: 110px;
  height: 110px;
  z-index: 15; /* below side-panel (20) and panel-toggle, above world canvas */
  touch-action: none;
  pointer-events: auto;
  opacity: 0.55;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.2s;
}

#mobile-joystick:active { opacity: 0.75; }

/* On mobile, move joystick up above the panel when panel is open */
@media (max-width: 600px) {
  #mobile-joystick {
    bottom: calc(60vh + 8px); /* above the bottom panel */
  }
  /* When panel is collapsed, return to bottom */
  body.panel-collapsed #mobile-joystick {
    bottom: 24px;
  }
}

#joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(80,90,120,0.4), rgba(20,25,50,0.3));
  border: 2px solid rgba(0,200,255,0.35);
  box-shadow: 0 0 16px rgba(0,200,255,0.15);
}

#joystick-knob {
  position: absolute;
  top: 50%; left: 50%;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(0,200,255,0.7), rgba(0,120,200,0.5));
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 10px rgba(0,200,255,0.4);
  transition: transform 0.05s;
}
