/**
 * Bridge AI OS — Dash Face Interface v2.0
 * Graphics, layout, mobile-friendly, terminal
 */
:root {
  --dash-face-bg: #0a0a0f;
  --dash-face-surface: #0f0f18;
  --dash-face-border: rgba(0, 102, 255, 0.2);
  --dash-face-primary: #0066FF;
  --dash-face-secondary: #00D4FF;
  --dash-face-accent: var(--electric-cyan, #00D4FF);
  --dash-face-online: #22c55e;
  --dash-face-offline: #ef4444;
  --dash-face-processing: #f59e0b;
  --dash-face-text: #e2e8f0;
  --dash-face-muted: #94a3b8;
  --dash-face-touch: 44px;
  --dash-face-nav-h: 56px;
  --dash-face-radius: 12px;
  --dash-face-radius-sm: 8px;
}

* { box-sizing: border-box; font-family: 'Inter', sans-serif; }
.dash-face .mono { font-family: 'JetBrains Mono', monospace; }

/* Skip link (fallback if Tailwind sr-only not loaded) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.sr-only.focus\:not-sr-only:focus { position: static; width: auto; height: auto; padding: 0.5rem 1rem; margin: 0; overflow: visible; clip: auto; white-space: normal; }

body.dash-face {
  background: var(--dash-face-bg);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-tap-highlight-color: transparent;
}

/* Decorative background layers */
.dash-face-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.dash-face-bg-gradient {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse 60% 80% at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse 50% 50% at 20% 50%, rgba(99, 102, 241, 0.06) 0%, transparent 50%);
}
.dash-face-bg-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(99, 102, 241, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 20%, transparent 70%);
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 20%, transparent 70%);
}
.dash-face-bg-glow {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 40%;
  background: radial-gradient(ellipse 100% 100% at 50% 100%, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
}

.dash-face-main { position: relative; z-index: 1; min-height: 100vh; padding-bottom: var(--dash-face-nav-h); }

/* Layout: column on mobile, row on desktop */
.dash-face-layout {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--dash-face-nav-h));
}
@media (min-width: 768px) {
  .dash-face-layout { flex-direction: row; }
}

.dash-face-left {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 1rem 1.5rem;
  min-height: min(100vh - var(--dash-face-nav-h), 520px);
}
@media (min-width: 768px) {
  .dash-face-left { width: 50%; padding: 2rem; min-height: auto; }
}

.dash-face-avatar {
  position: relative;
  width: min(280px, 70vw);
  height: min(280px, 70vw);
  background: linear-gradient(135deg, rgba(15, 15, 25, 0.9) 0%, rgba(10, 10, 15, 0.95) 100%);
  border: 1px solid var(--dash-face-border);
}
@media (min-width: 768px) {
  .dash-face-avatar { width: 320px; height: 320px; }
}
@media (min-width: 1024px) {
  .dash-face-avatar { width: 400px; height: 400px; }
}

.dash-face-right {
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--dash-face-border);
}
@media (min-width: 768px) {
  .dash-face-right { width: 50%; border-top: none; border-left: 1px solid var(--dash-face-border); }
}

.gradient-text {
  background: linear-gradient(135deg, var(--dash-face-primary) 0%, var(--dash-face-secondary) 50%, var(--dash-face-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Title block */
.dash-face-title-block { margin-top: 1.5rem; text-align: center; }
.dash-face-title { font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 700; margin: 0 0 0.25rem 0; }
.dash-face-subtitle { color: var(--dash-face-muted); font-size: 0.8rem; margin: 0; }

/* Pillar cards with icons */
.dash-face-pillars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: center;
  margin-top: 1.25rem;
  max-width: 420px;
}
.pillar-card {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.4rem 0.75rem;
  background: rgba(15, 15, 25, 0.8);
  border: 1px solid var(--dash-face-border);
  border-radius: var(--dash-face-radius-sm);
  font-size: 0.75rem;
  min-height: var(--dash-face-touch);
}
.pillar-icon {
  font-size: 0.9rem;
  opacity: 0.9;
  line-height: 1;
}
.pillar-icon-core { color: var(--dash-face-primary); }
.pillar-icon-api { color: var(--dash-face-online); }
.pillar-icon-memory { color: var(--dash-face-accent); }
.pillar-icon-governed { color: var(--dash-face-secondary); }
.pillar-label { color: var(--dash-face-text); }

.dash-face-voice-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; flex-wrap: wrap; justify-content: center; }

.dash-face-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  min-height: var(--dash-face-touch);
  min-width: var(--dash-face-touch);
  border-radius: var(--dash-face-radius);
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dash-face-btn:active { transform: scale(0.98); }
.dash-face-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.dash-face-btn-icon { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.dash-face-btn-primary {
  background: linear-gradient(135deg, var(--dash-face-primary), var(--dash-face-secondary));
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.dash-face-btn-primary:hover { box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45); }
.dash-face-btn-secondary {
  background: var(--dash-face-surface);
  color: var(--dash-face-text);
  border: 1px solid var(--dash-face-border);
}
.dash-face-btn-secondary:hover { background: rgba(99, 102, 241, 0.1); }
.dash-face-send { padding-left: 1.25rem; padding-right: 1.25rem; }

/* Tabs */
.dash-face-tabs {
  display: flex;
  border-bottom: 1px solid var(--dash-face-border);
  background: rgba(0, 0, 0, 0.3);
  padding: 0 0.25rem;
}
.dash-face-tab {
  padding: 0.875rem 1rem;
  min-height: var(--dash-face-touch);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--dash-face-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.dash-face-tab:hover { color: var(--dash-face-text); }
.dash-face-tab.tab-active { color: var(--dash-face-primary); border-bottom-color: var(--dash-face-primary); }

.dash-face-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.dash-face-chat-inner { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.dash-face-chat-header {
  padding: 1rem;
  border-bottom: 1px solid var(--dash-face-border);
  background: rgba(0, 0, 0, 0.3);
}
.dash-face-chat-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.15rem 0;
}
.dash-face-chat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dash-face-online);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  animation: pulse 2s ease-in-out infinite;
}
.dash-face-chat-desc { color: var(--dash-face-muted); font-size: 0.8rem; margin: 0; }
.dash-face-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  -webkit-overflow-scrolling: touch;
}
.dash-face-input-area { padding: 1rem; border-top: 1px solid var(--dash-face-border); background: rgba(0, 0, 0, 0.3); }
.dash-face-input-row { display: flex; gap: 0.5rem; }
.dash-face-input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem;
  min-height: var(--dash-face-touch);
  font-size: 1rem;
  background: var(--dash-face-surface);
  border: 1px solid var(--dash-face-border);
  border-radius: var(--dash-face-radius);
  color: var(--dash-face-text);
  transition: border-color 0.15s;
}
.dash-face-input::placeholder { color: var(--dash-face-muted); }
.dash-face-input:disabled { opacity: 0.7; cursor: not-allowed; }
.dash-face-input:focus { outline: none; border-color: var(--dash-face-primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); }
.dash-face-input:focus-visible { outline: none; border-color: var(--dash-face-primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35); }
.dash-face-btn:focus-visible { outline: 2px solid var(--dash-face-primary); outline-offset: 2px; }
.dash-face-tab:focus-visible { outline: 2px solid var(--dash-face-primary); outline-offset: 2px; }
.dash-face-terminal-clear:focus-visible { outline: 2px solid var(--dash-face-muted); outline-offset: 2px; }
.dash-face-nav-link:focus-visible { outline: 2px solid var(--dash-face-primary); outline-offset: 2px; border-radius: 4px; }

/* Terminal */
.dash-face-terminal {
  border-top: 1px solid var(--dash-face-border);
  background: rgba(0, 0, 0, 0.6);
  min-height: 140px;
  display: flex;
  flex-direction: column;
}
.dash-face-terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--dash-face-border);
  background: rgba(0, 0, 0, 0.4);
}
.dash-face-terminal-prompt { font-size: 0.75rem; color: var(--dash-face-muted); }
.dash-face-terminal-actions { display: flex; align-items: center; gap: 0.35rem; }
.dash-face-term-dollar { color: #22c55e; margin-right: 0.25rem; }
.dash-face-terminal-clear {
  padding: 0.35rem 0.6rem;
  font-size: 0.7rem;
  color: var(--dash-face-muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  min-height: 28px;
}
.dash-face-terminal-clear:hover { color: var(--dash-face-text); background: rgba(255,255,255,0.05); }
.dash-face-cli-link {
  padding: 0.35rem 0.6rem;
  font-size: 0.7rem;
  color: var(--dash-face-primary);
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid var(--dash-face-border);
  border-radius: 4px;
  text-decoration: none;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
}
.dash-face-cli-link:hover { color: var(--dash-face-accent); background: rgba(99, 102, 241, 0.25); border-color: rgba(99, 102, 241, 0.4); }
.dash-face-terminal-body {
  flex: 1;
  padding: 0.5rem 0.75rem;
  overflow-y: auto;
  font-size: 0.7rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
.dash-face-terminal-body::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}
@media (min-width: 768px) {
  .dash-face-terminal { min-height: 180px; }
  .dash-face-terminal-body { font-size: 0.75rem; }
}

.dash-face .hidden { display: none !important; }
.dash-face-kernel-panel { min-height: 200px; }
.dash-face-kernel-panel:not(.hidden) { display: flex; flex-direction: column; }
.dash-face-kernel-canvas { flex: 1; min-height: 200px; background: #0a0f19; }
.dash-face-kernel-terminal {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  padding: 0.75rem;
  overflow-y: auto;
  min-height: 120px;
  background: #0b0f16;
  color: #00ffaa;
}

/* Avatar panel: talking head */
.dash-face-avatar-panel-inner { padding: 14px; }
.dash-face-avatar-panel-label {
  font-size: 12px;
  color: #c7d2fe;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.dash-face-avatar-panel-desc {
  font-size: 0.8rem;
  color: var(--dash-face-muted);
  margin: 0 0 12px 0;
  line-height: 1.4;
}
.dash-face-avatar-video {
  width: 100%;
  border-radius: 14px;
  background: #060812;
}
.dash-face-avatar-canvas {
  width: 100%;
  border-radius: 14px;
  background: radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.22), transparent 55%), #070815;
}
.dash-face-avatar-status {
  margin-top: 10px;
  color: #9ca3af;
  font-size: 11px;
}

/* Nav: mobile-friendly with safe area */
.dash-face-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--dash-face-border);
  padding: 0.5rem 1rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}
.dash-face-nav-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.dash-face-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
}
.dash-face-nav-link {
  color: var(--dash-face-muted);
  font-size: 0.875rem;
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.dash-face-nav-link:hover { color: var(--dash-face-text); }
.dash-face-nav-link-current { color: var(--dash-face-primary); font-weight: 500; }
.dash-face-nav-copy { color: var(--dash-face-muted); font-size: 0.7rem; }

#avatar-container {
  position: relative;
  width: 100%;
  height: 100%;
}

/* 3D, P5, and webcam stay behind the 2D face overlay so the twin reads as one. */
#three-canvas, #pixi-canvas, #p5-canvas, #webcam-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.face-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  height: 320px;
  pointer-events: none;
  z-index: 2;
}

/* Skin: warmer human undertone + center highlight for realism */
.face-skin {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  border-radius: 50% 50% 45% 45%;
  background:
    radial-gradient(ellipse 50% 45% at 50% 38%, rgba(48, 42, 38, 0.25) 0%, transparent 55%),
    radial-gradient(ellipse 85% 95% at 50% 48%, rgba(38, 32, 28, 0.92) 0%, rgba(28, 24, 22, 0.96) 45%, rgba(18, 16, 14, 0.98) 100%);
  box-shadow: inset 0 0 60px rgba(99, 102, 241, 0.04), inset -8px -10px 40px rgba(0, 0, 0, 0.15);
}

/* Ears: left and right */
.face-ear {
  position: absolute;
  top: 28%;
  z-index: 1;
  width: 22px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(ellipse 60% 80% at 50% 50%, rgba(32, 36, 55, 0.9) 0%, rgba(18, 20, 32, 0.95) 100%);
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.face-ear-left { left: -9px; top: 27.5%; }
.face-ear-right { right: -7px; top: 28.5%; }

/* Hairline: arc at top */
.face-hairline {
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 22%;
  z-index: 1;
  border-radius: 50% 50% 0 0;
  border-top: 2px solid rgba(99, 102, 241, 0.2);
  border-left: 1px solid rgba(99, 102, 241, 0.15);
  border-right: 1px solid rgba(99, 102, 241, 0.15);
  background: linear-gradient(to bottom, rgba(12, 14, 24, 0.7) 0%, transparent 100%);
}

.face-outline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  border: 3px solid rgba(99, 102, 241, 0.35);
  border-radius: 50% 50% 45% 45%;
  box-shadow: inset 0 0 50px rgba(99, 102, 241, 0.07);
  animation: faceGlow 3s ease-in-out infinite;
}

/* Nose bridge: between eyes for human proportion */
.face-nose-bridge {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(to bottom, rgba(30, 26, 24, 0.7) 0%, transparent 100%);
  border-left: 1px solid rgba(99, 102, 241, 0.2);
  border-right: 1px solid rgba(99, 102, 241, 0.2);
  z-index: 1;
}

/* Nose: tip and nostrils hint */
.face-nose {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 38px;
  border-radius: 0 0 14px 14px;
  background: linear-gradient(to bottom, transparent 0%, rgba(28, 24, 22, 0.5) 30%, rgba(99, 102, 241, 0.08) 100%);
  border-left: 1px solid rgba(99, 102, 241, 0.28);
  border-right: 1px solid rgba(99, 102, 241, 0.28);
  border-bottom: 1px solid rgba(99, 102, 241, 0.22);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Nose shadow: cast on upper lip/cheeks for depth */
.face-nose-shadow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, 0);
  width: 50px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(ellipse 100% 80% at 50% 0%, rgba(0, 0, 0, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

/* Cheeks: under eyes, react to expression; slight asymmetry */
.face-cheek {
  position: absolute;
  top: 42%;
  width: 42px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(ellipse 70% 60% at 50% 50%, rgba(180, 120, 100, 0.06) 0%, rgba(99, 102, 241, 0.06) 40%, transparent 70%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.face-cheek-left { left: 13.5%; top: 41.8%; }
.face-cheek-right { right: 13.8%; top: 42.2%; }

/* Jaw: lower face, moves with mouth */
.face-jaw {
  position: absolute;
  bottom: 18%;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 32px;
  border-radius: 0 0 45px 45px;
  background: linear-gradient(to bottom, transparent 0%, rgba(20, 24, 40, 0.6) 100%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  transition: transform 0.15s ease;
}

/* Chin / neck shadow for depth */
.face-chin-shadow {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 36px;
  border-radius: 0 0 60px 60px;
  background: radial-gradient(ellipse 100% 100% at 50% 100%, rgba(0, 0, 0, 0.2) 0%, transparent 65%);
  pointer-events: none;
}

/* Eyebrows: human characteristic, expression-driven */
.face-brow {
  position: absolute;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent 0%, rgba(40, 35, 32, 0.9) 20%, rgba(35, 30, 28, 0.95) 50%, rgba(40, 35, 32, 0.9) 80%, transparent 100%);
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
  transition: top 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
  z-index: 3;
}
.face-brow-left { left: 20%; width: 52px; top: 23%; transform: rotate(-2deg); }
.face-brow-right { right: 20%; width: 52px; top: 23%; transform: rotate(2deg); }

/* Philtrum: dip above upper lip */
.face-philtrum {
  position: absolute;
  bottom: 24%;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 12px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.15) 0%, transparent 100%);
  pointer-events: none;
}

@keyframes faceGlow {
  0%, 100% { box-shadow: inset 0 0 50px rgba(99, 102, 241, 0.07), 0 0 28px rgba(99, 102, 241, 0.18); }
  50% { box-shadow: inset 0 0 50px rgba(99, 102, 241, 0.07), 0 0 45px rgba(139, 92, 246, 0.3); }
}

.eye {
  position: absolute;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle at 50% 50%, rgba(220, 215, 210, 0.12) 0%, rgba(28, 26, 24, 0.95) 100%);
  border: 2px solid rgba(99, 102, 241, 0.5);
  border-radius: 50%;
  top: 30%;
  overflow: hidden;
}
.eye-left { left: 19.5%; top: 29.8%; }
.eye-right { right: 19.8%; top: 30.2%; }

/* Limbus: ring between sclera and iris for realism */
.eye-limbus {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(60, 55, 90, 0.6);
  pointer-events: none;
}

.pupil {
  position: absolute;
  width: 24px;
  height: 24px;
  background: radial-gradient(circle at 30% 30%, #66a3ff 0%, #00D4FF 40%, #0066FF 70%, #0052CC 100%);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.1s ease;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.8), 0 0 40px rgba(139, 92, 246, 0.4);
}

.pupil::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  top: 15%;
  left: 15%;
}

.pupil::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  bottom: 20%;
  right: 20%;
}

.mouth {
  position: absolute;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  width: 70px;
  height: 25px;
  border: 2px solid rgba(99, 102, 241, 0.5);
  border-top: none;
  border-radius: 0 0 50px 50px;
  transition: all 0.3s ease;
  background: linear-gradient(to bottom, rgba(80, 50, 45, 0.15) 0%, rgba(99, 102, 241, 0.08) 60%, transparent 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

.mouth.speaking {
  animation: speak 0.15s ease-in-out infinite alternate;
}

@keyframes speak {
  0% { height: 14px; width: 58px; border-radius: 0 0 45px 45px; }
  50% { height: 28px; width: 72px; border-radius: 0 0 50px 50px; }
  100% { height: 22px; width: 78px; border-radius: 0 0 48px 48px; }
}

.mouth.thinking {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  animation: thinkPulse 1.5s ease-in-out infinite;
}

@keyframes thinkPulse {
  0%, 100% { opacity: 0.9; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.6; transform: translateX(-50%) scale(1.05); }
}

/* Twin-driven expressions (high-grade, simple) */
.dash-face-expression-neutral .face-outline { border-color: rgba(99, 102, 241, 0.3); }
.dash-face-expression-thinking .face-outline {
  border-color: rgba(139, 92, 246, 0.45);
  animation: faceGlow 2s ease-in-out infinite;
}
.dash-face-expression-thinking .eye { border-color: rgba(139, 92, 246, 0.5); }
.dash-face-expression-thinking .face-brow { top: 22%; transform: rotate(0deg); opacity: 0.85; }
.dash-face-expression-thinking .face-brow-left { transform: translateY(-1px) rotate(-3deg); }
.dash-face-expression-thinking .face-brow-right { transform: translateY(-1px) rotate(3deg); }
.dash-face-expression-happy .face-outline { border-color: rgba(34, 197, 94, 0.35); }
.dash-face-expression-happy .face-brow { top: 21.5%; }
.dash-face-expression-happy .face-brow-left { transform: rotate(-4deg); }
.dash-face-expression-happy .face-brow-right { transform: rotate(4deg); }
.dash-face-expression-happy .mouth:not(.speaking):not(.thinking) {
  height: 18px;
  border-radius: 0 0 45px 45px;
  border-bottom-width: 3px;
}
.dash-face-expression-listening .face-outline { border-color: rgba(245, 158, 11, 0.4); }
.dash-face-expression-listening .eye { border-color: rgba(245, 158, 11, 0.5); }
.dash-face-expression-listening .face-brow { top: 23.5%; }

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.online { background: var(--dash-face-online); box-shadow: 0 0 10px rgba(34, 197, 94, 0.5); }
.status-dot.offline { background: var(--dash-face-offline); box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
.status-dot.processing { background: var(--dash-face-processing); box-shadow: 0 0 10px rgba(245, 158, 11, 0.5); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

.chat-container {
  background: rgba(15, 15, 25, 0.9);
  border: 1px solid rgba(99, 102, 241, 0.2);
  backdrop-filter: blur(10px);
}

.chat-message {
  animation: fadeIn 0.3s ease;
}

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

.terminal-line {
  animation: typeIn 0.3s ease;
}

@keyframes typeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.glow-border {
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.3), inset 0 0 40px rgba(99, 102, 241, 0.05);
}

#voice-btn.listening {
  animation: listenPulse 1s ease-in-out infinite;
  background: linear-gradient(to right, #ef4444, #dc2626);
}

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

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--dash-face-primary);
  border-radius: 50%;
  animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
}

/* Chat message body: inline code and line breaks */
.dash-face-message-body { word-break: break-word; }
.dash-face-inline-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 4px;
}

.neural-network {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.3;
}

@media (max-width: 768px) {
  .face-container {
    width: 55%;
    height: 60%;
    max-width: 200px;
    max-height: 240px;
  }
  .eye {
    width: 45px;
    height: 45px;
  }
  .pupil {
    width: 18px;
    height: 18px;
  }
  .mouth {
    width: 50px;
    height: 20px;
  }
}

@media (max-width: 640px) {
  .face-container {
    width: 50%;
    max-width: 140px;
    max-height: 180px;
  }
  .eye {
    width: 35px;
    height: 35px;
  }
  .pupil {
    width: 14px;
    height: 14px;
  }
  .mouth {
    width: 40px;
    height: 16px;
  }
  .dash-face-terminal-body { font-size: 0.65rem; }
  .pillar-card { padding: 0.35rem 0.5rem; font-size: 0.7rem; }
}
