/* ==========================================================================
   AETHER // COMPONENTS
   ========================================================================== */

/* 1. Top Brand Pill (Minimal Ambient Watermark) */
.top-brand-header {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 0 10px;
  z-index: 20;
  pointer-events: none;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px 6px 12px;
  background: rgba(18, 18, 30, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.brand-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.25);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

/* 2. Expansive Chat Stream */
.console-stream {
  width: calc( (100vw - 48px) * 0.5 );
  max-width: 620px;
  flex: 1;
  overflow-y: auto;
  padding: 20px 0 110px; /* Leave space for the dock */
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 auto;
  z-index: 10;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.console-stream::before {
  content: "";
  flex: 1 1 auto;
}

.console-stream::-webkit-scrollbar {
  display: none;
}

.chat-row {
  display: flex;
  animation: slideUp 0.4s var(--ease-fluid) forwards;
  opacity: 0;
  transform: translateY(10px);
}

@keyframes slideUp {
  to { opacity: 1; transform: translateY(0); }
}

.chat-row.user {
  justify-content: flex-end; /* In LTR, this is Right */
}

.chat-row.agent {
  justify-content: flex-start; /* In LTR, this is Left */
}

.chat-bubble {
  max-width: 85%;
  font-size: 0.95rem; /* Slightly smaller as requested */
  line-height: 1.6;
  font-weight: 400;
  letter-spacing: -0.01em;
  text-align: start; /* bubbles carry dir="auto", so each message flows in its own script's direction */
}

.chat-row.agent .chat-bubble {
  color: var(--text-primary);
  background: rgba(var(--bubble-rgb), var(--bubble-alpha));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px 22px;
  border-radius: 24px;
  border-top-right-radius: 6px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* A reply that failed (timeout, server error): same bubble, tinted so it isn't mistaken for an answer */
.chat-row.agent .chat-bubble.is-error {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.4);
}

.chat-row.user .chat-bubble {
  color: var(--text-primary);
  text-align: start;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.18), rgba(var(--accent-2-rgb), 0.18));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  padding: 14px 20px;
  border-radius: 24px;
  border-top-left-radius: 6px;
  box-shadow: 0 10px 30px -10px rgba(var(--accent-rgb), 0.25);
}

/* ==========================================================================
   3. FLOATING DOCK (العريضة العائمة في الطرف السفلي)
   ========================================================================== */
.floating-dock,
.app-dock {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 48px);
  max-width: 1240px;
  height: 86px !important;
  min-height: 86px !important;
  max-height: 86px !important;
  background: rgba(var(--dock-rgb), 0.76);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px;
  box-shadow: 
    0 24px 60px -10px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 16px;
  z-index: 100;
  box-sizing: border-box;
  overflow: visible;
  transition: all 0.3s var(--ease-fluid);
}

.dock-slot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  min-width: 160px;
}

/* Start side: brand (right in Arabic, left in English). The dock is a flex row, so it mirrors with <html dir>. */
.dock-slot.dock-right {
  justify-content: flex-start;
}

/* End side: language, audio and account (left in Arabic, right in English) */
.dock-slot.dock-left {
  justify-content: flex-end;
}

/* User Account Button (Icon only) */
.user-account-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s var(--ease-fluid);
  outline: none;
}

.user-account-btn:hover {
  transform: scale(1.08);
}

.user-account-btn:active {
  transform: scale(0.95);
}

.user-avatar-ring {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.3), rgba(var(--accent-2-rgb), 0.3));
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.user-avatar-ring.initial {
  background: #ffffff;
  color: #0b0c14;
  font-size: 0.85rem;
  font-weight: 700;
}

.user-avatar-ring .user-icon {
  width: 18px;
  height: 18px;
  color: var(--text-primary);
}

.user-handle {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.user-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  margin-right: 2px;
}

/* Center: Chat Dialog Bar (يتوسطها مربع الحوار بمساحة لا تزيد عن ٥٠٪ من عرض الشريط) */
.dock-center-chat {
  flex: 0 1 50%;
  width: 50%;
  max-width: 50%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.chat-input-bezel {
  width: 100%;
  height: 72px !important;
  min-height: 72px !important;
  max-height: 72px !important;
  box-sizing: border-box;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(var(--bezel-rgb), 0.82);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 22px;
  padding: 6px 14px 6px 10px;
  border: 1px solid rgba(var(--accent-rgb), 0.42);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.32), 0 0 16px rgba(var(--accent-rgb), 0.12);
  transition: border-color 0.25s var(--ease-fluid), box-shadow 0.25s var(--ease-fluid), background 0.25s var(--ease-fluid);
}

.chat-input-bezel:focus-within {
  border-color: rgba(var(--accent-hi-rgb), 0.78);
  box-shadow: 
    0 0 0 1px rgba(var(--accent-rgb), 0.5),
    0 0 28px rgba(var(--accent-rgb), 0.3),
    inset 0 2px 4px rgba(0, 0, 0, 0.35);
  background: rgba(var(--bezel-focus-rgb), 0.92);
}

.chat-input-bezel textarea {
  flex: 1;
  height: 60px !important;
  min-height: 60px !important;
  max-height: 60px !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem !important;
  line-height: 24px !important;
  resize: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scrollbar-width: none !important; /* Firefox */
  -ms-overflow-style: none !important; /* IE / Edge */
  padding: 0 6px !important;
  direction: inherit !important; /* follows <html dir>: rtl for Arabic, ltr for English */
  text-align: start !important;
  box-sizing: border-box !important;
}

/* Requirement 2: Completely remove and hide scrollbar from textarea across all engines */
.chat-input-bezel textarea::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}
.chat-input-bezel textarea::-webkit-scrollbar-track,
.chat-input-bezel textarea::-webkit-scrollbar-thumb,
.chat-input-bezel textarea::-webkit-scrollbar-corner {
  display: none !important;
  background: transparent !important;
}

.chat-input-bezel textarea::placeholder {
  color: var(--text-tertiary);
  text-align: start;
}

/* Safeer Input Box Takeover (استحواذ السفير على صندوق الإرسال بكتابة ديناميكية) */
.chat-box-takeover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 8;
  border-radius: 22px;
  background: rgba(var(--bezel-rgb), 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s var(--ease-fluid), visibility 0.25s;
}

.chat-input-bezel.takeover-active .chat-box-takeover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.chat-input-bezel.takeover-active textarea {
  opacity: 0 !important;
  pointer-events: none !important;
}

.chat-input-bezel.takeover-active .chat-action-btn,
.chat-input-bezel.takeover-active .attach-wrapper {
  opacity: 0.2 !important;
  pointer-events: none !important;
}

/* Three dynamic glowing yellow-purple dots in the exact center (smaller & non-overlapping sequential wave) */
.takeover-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.takeover-dots span {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fde047, #c084fc);
  box-shadow: 0 0 6px rgba(253, 224, 71, 0.6), 0 0 10px rgba(192, 132, 252, 0.4);
  animation: takeover-pulse 1.35s infinite ease-in-out both;
}

.takeover-dots span:nth-child(1) {
  animation-delay: 0s;
}
.takeover-dots span:nth-child(2) {
  animation-delay: 0.45s;
}
.takeover-dots span:nth-child(3) {
  animation-delay: 0.90s;
}

@keyframes takeover-pulse {
  0% {
    transform: scale(0.85);
    opacity: 0.28;
    box-shadow: 0 0 4px rgba(253, 224, 71, 0.3);
  }
  12% {
    transform: scale(1.35) translateY(-2px);
    opacity: 1;
    box-shadow: 0 0 10px rgba(253, 224, 71, 0.95), 0 0 16px rgba(192, 132, 252, 0.8);
  }
  24% {
    transform: scale(0.85);
    opacity: 0.28;
    box-shadow: 0 0 4px rgba(253, 224, 71, 0.3);
  }
  100% {
    transform: scale(0.85);
    opacity: 0.28;
    box-shadow: 0 0 4px rgba(253, 224, 71, 0.3);
  }
}

/* Chat Input Action Buttons (Microphone and Attachments) */
.chat-input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-action-btn {
  -webkit-appearance: none;
  appearance: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s var(--ease-fluid);
  position: relative;
  outline: none;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.chat-action-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(var(--accent-hi-rgb), 0.5);
  color: #ffffff;
  transform: scale(1.08);
  box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.35);
}

.chat-action-btn:active {
  transform: scale(0.94);
}

.chat-action-btn svg {
  display: block;
  stroke: currentColor;
}

/* Microphone active / recording state with pulsating aura */
.chat-action-btn.mic-btn.recording {
  background: rgba(239, 68, 68, 0.25) !important;
  border-color: rgba(239, 68, 68, 0.8) !important;
  color: #ef4444 !important;
  animation: pulse-mic 1.4s infinite;
}

@keyframes pulse-mic {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* Attach menu dropdown */
.attach-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.attach-menu-dropdown {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 0;
  min-width: 170px;
  background: rgba(var(--menu-rgb), 0.96);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  box-shadow: 
    0 20px 40px -8px rgba(0, 0, 0, 0.9), 
    0 0 0 1px rgba(var(--accent-rgb), 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 200;
}

.attach-menu-dropdown.active {
  display: flex !important;
  animation: popoverFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.attach-menu-item {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: #f1f5f9;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
  text-align: start;
  outline: none;
  margin: 0;
  box-sizing: border-box;
}

.attach-menu-item:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

.attach-menu-item svg {
  color: rgb(var(--accent-hi-rgb));
  stroke: rgb(var(--accent-hi-rgb));
  flex-shrink: 0;
}

/* Cute 3D Sphere Character perched in the center partially entering the chat bar */
.sphere-perch {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: calc(100% - 24px);
  transform: translateX(-50%);
  width: 84px;
  height: 84px;
  z-index: 15;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.65));
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sphere-perch:hover {
  transform: translateX(-50%) scale(1.06) translateY(-3px);
}

.sphere-perch canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Brand Logo on Right Side of Dock (شعار العرّاب على الطرف الأيمن) */
.brand-dock-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: default;
  user-select: none;
}

.avatar-ring.brand-emblem-ring {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(255, 215, 0, 0.4);
  box-shadow: 
    0 0 16px rgba(255, 215, 0, 0.25),
    0 0 24px rgba(14, 165, 233, 0.2);
  transition: transform 0.25s var(--ease-fluid), box-shadow 0.25s var(--ease-fluid);
  flex-shrink: 0;
}

.brand-dock-profile:hover .avatar-ring.brand-emblem-ring {
  transform: scale(1.08) rotate(3deg);
  box-shadow: 
    0 0 24px rgba(255, 215, 0, 0.45),
    0 0 32px rgba(14, 165, 233, 0.35);
}

.brand-dock-profile .avatar-ring.brand-emblem-ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-dock-meta {
  display: flex;
  flex-direction: column;
}

.brand-name-arrab {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.15;
  letter-spacing: -0.02em;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
}

/* Agent Meta & Audio on Left (Legacy support) */
.agent-dock-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-ring.mini {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  filter: grayscale(0.4);
  transition: filter 0.2s;
}

.agent-dock-profile:hover .avatar-ring.mini {
  filter: grayscale(0);
}

.avatar-ring.mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.agent-dock-meta {
  display: flex;
  flex-direction: column;
}

.agent-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
}

.agent-dock-meta .status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.agent-dock-meta .status-indicator .dot {
  width: 6px;
  height: 6px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.audio-toggle {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 8px;
  transition: color 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-toggle:hover {
  color: var(--text-primary);
  transform: scale(1.08);
}

.audio-icon {
  width: 20px;
  height: 20px;
}

/* Language switch: same footprint as the audio toggle, shows the language it switches to */
.lang-toggle {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: var(--text-tertiary);
  cursor: pointer;
  min-width: 34px;
  height: 30px;
  padding: 0 9px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  transition: color 0.2s, border-color 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-toggle:hover {
  color: var(--text-primary);
  border-color: rgba(var(--accent-rgb), 0.5);
  transform: scale(1.08);
}

.lang-toggle-label[lang="ar"] {
  font-size: 0.95rem;
}

/* Widgets */
.agent-widget {
  margin-top: 24px;
  background: var(--surface-raised);
  border: 1px solid var(--accent-border);
  border-radius: 16px;
  padding: 24px;
}

.widget-header {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.widget-item {
  margin-bottom: 16px;
}

.widget-item h4 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.widget-item p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.widget-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.widget-btn {
  padding: 12px 20px;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.widget-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.widget-btn.primary {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.widget-btn.primary:hover {
  background: #e0e0e0;
}

@media (max-width: 768px) {
  .stage-3d-wrapper { padding: 0; }
  .tactical-console { border-radius: 0; height: 100vh; max-height: 100vh; border: none; transform: none !important; }
  .console-header { padding: 24px; }
  .console-stream { padding: 0 24px; }
  .console-input-area { padding: 24px; }
}

/* 5. Aether Pulse Loader & Markdown formatting */
.aether-pulse-loader {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}

.aether-pulse-loader span {
  width: 7px;
  height: 7px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  display: inline-block;
  animation: aetherPulse 1.4s infinite ease-in-out both;
}

.aether-pulse-loader span:nth-child(1) { animation-delay: -0.32s; }
.aether-pulse-loader span:nth-child(2) { animation-delay: -0.16s; }
.aether-pulse-loader span:nth-child(3) { animation-delay: 0s; }

@keyframes aetherPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.25; }
  40% { transform: scale(1.0); opacity: 1; background: #ffffff; }
}

.chat-bubble p {
  margin: 0 0 12px 0;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble pre {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  font-family: var(--font-mono, monospace);
  font-size: 0.9rem;
  margin: 12px 0;
  color: #e2e8f0;
}

.chat-bubble code {
  font-family: var(--font-mono, monospace);
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
}

.chat-bubble pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.chat-bubble ul, .chat-bubble ol {
  margin: 8px 0 12px 20px;
  padding: 0;
}

.chat-bubble li {
  margin-bottom: 6px;
}

/* ==========================================================================
   6. HEADER ACTIONS & AUTH BADGE
   ========================================================================== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-header-slot {
  display: flex;
  align-items: center;
}

.auth-nav-btn {
  background: var(--surface-raised);
  border: 1px solid var(--accent-border);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s var(--ease-fluid);
}

.auth-nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.user-profile-badge {
  background: var(--surface-raised);
  border: 1px solid var(--accent-border);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 12px 4px 6px;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s var(--ease-fluid);
}

.user-profile-badge:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
}

.user-avatar-initial {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  color: #000000;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-handle {
  font-size: 0.8rem;
  letter-spacing: -0.01em;
}

.user-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

/* Profile Popover (Floats above user account icon on the left) */
.profile-popover {
  position: fixed;
  bottom: 106px;
  left: max(24px, calc((100vw - 1240px) / 2 + 18px));
  right: auto;
  width: 300px;
  background: rgba(18, 19, 32, 0.94);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 24px 50px -10px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  padding: 18px;
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.25s var(--ease-fluid);
}

.profile-popover.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateY(0);
}

.profile-popover-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--accent-border);
  margin-bottom: 14px;
}

.profile-popover-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  color: #000000;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.profile-popover-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-popover-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.profile-popover-badge {
  display: inline-block;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(139, 92, 246, 0.45);
  color: #c4b5fd;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 6px;
  letter-spacing: 0.04em;
}

.profile-popover-email {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.profile-popover-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.profile-popover-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-popover-item .label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
}

.profile-popover-item .val {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}

.profile-popover-item .status-active {
  color: #10b981;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
}

.profile-popover-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-action-btn {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface-monolith);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.profile-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.profile-action-btn.upgrade {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.85), rgba(14, 165, 233, 0.85));
  color: #ffffff;
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
}

.profile-action-btn.upgrade:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.45);
}

.profile-action-btn.danger {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
}

.profile-action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* ==========================================================================
   7. INTERACTIVE ONBOARDING CHIPS & STEPS
   ========================================================================== */
.onboarding-step-wrapper {
  margin-top: 14px;
}

.onboarding-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.onboarding-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface-raised);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s var(--ease-fluid);
  text-align: start;
}

.onboarding-chip .chip-icon {
  font-size: 0.95rem;
}

.onboarding-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.onboarding-chip:active {
  transform: scale(0.98);
}

/* ==========================================================================
   8. SOVEREIGN DOSSIER CARD
   ========================================================================== */
.sovereign-dossier-card {
  margin-top: 18px;
  background: #080808;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.dossier-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.dossier-card-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 4px;
}

.dossier-card-title h3 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.dossier-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.dossier-status-badge.pending {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.dossier-status-badge.active {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d178;
}

.status-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.dossier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: var(--surface-monolith);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 18px;
}

.dossier-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dossier-cell .cell-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
}

.dossier-cell .cell-value {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.dossier-cell .cell-value.font-mono {
  font-family: var(--font-mono);
  color: #60a5fa;
  font-size: 0.78rem;
}

.dossier-cta-banner {
  padding-top: 14px;
  border-top: 1px solid var(--accent-border);
}

.dossier-cta-banner p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}

.dossier-cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dossier-btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.18s var(--ease-fluid);
}

.dossier-btn.primary {
  background: #ffffff;
  color: #000000;
  border: none;
}

.dossier-btn.primary:hover {
  background: #eaeaea;
  transform: translateY(-1px);
}

.dossier-btn.secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--accent-border);
}

.dossier-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   9. AUTH MODAL (SIGN IN / SIGN UP) - FIXED OVERLAY & DEFAULT HIDDEN
   ========================================================================== */
.auth-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.25s var(--ease-fluid), visibility 0.25s;
}

.auth-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.auth-modal,
.auth-modal-card {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 90%;
  max-width: 440px;
  background: rgba(12, 13, 22, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  box-shadow: 0 30px 80px -15px rgba(0, 0, 0, 0.95), 0 0 40px rgba(139, 92, 246, 0.2);
  padding: 32px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.25s var(--ease-fluid), transform 0.25s var(--ease-fluid), visibility 0.25s;
}

.auth-modal.active,
.auth-modal-overlay.active .auth-modal-card {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.auth-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.auth-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.auth-modal-title-group h2 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.auth-modal-subtitle,
.auth-modal-title-group p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.auth-close-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: color 0.15s;
}

.auth-close-btn:hover {
  color: var(--text-primary);
}

/* Tabs */
.auth-tab-bar {
  display: flex;
  background: var(--surface-monolith);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 22px;
}

.auth-tab {
  flex: 1;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.auth-tab.active {
  background: var(--surface-raised);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Forms */
.auth-form {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.auth-form.active {
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  width: 100%;
  background: var(--surface-monolith);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: rgba(255, 255, 255, 0.35);
}

.form-group input::placeholder {
  color: var(--text-tertiary);
}

.auth-feedback {
  font-size: 0.8rem;
  min-height: 18px;
}

.auth-feedback.error {
  color: #f87171;
}

.auth-feedback.success {
  color: #34d178;
}

.auth-submit-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.18s var(--ease-fluid);
  margin-top: 4px;
}

.auth-submit-btn.primary {
  background: #ffffff;
  color: #000000;
  border: none;
}

.auth-submit-btn.primary:hover:not(:disabled) {
  background: #eaeaea;
  transform: translateY(-1px);
}

.auth-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Success Confirmation Banner */
.auth-success-banner {
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 14px;
  padding: 18px 20px;
}

.auth-success-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: #34d178;
  letter-spacing: 0.05em;
}

.auth-success-badge .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d178;
  box-shadow: 0 0 6px rgba(52, 209, 120, 0.6);
}

/* Demo Mode Divider & Quick Button in Auth Modal */
.auth-demo-divider {
  display: flex;
  align-items: center;
  margin: 20px 0 14px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.78rem;
}

.auth-demo-divider::before,
.auth-demo-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-demo-divider span {
  padding: 0 12px;
  letter-spacing: 0.02em;
}

.auth-demo-btn {
  width: 100%;
  position: relative;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(14, 165, 233, 0.14));
  border: 1px solid rgba(139, 92, 246, 0.38);
  border-radius: 14px;
  padding: 13px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.25s var(--ease-fluid);
  overflow: hidden;
}

.auth-demo-btn:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.24), rgba(14, 165, 233, 0.24));
  border-color: rgba(139, 92, 246, 0.7);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -6px rgba(139, 92, 246, 0.4);
}

.auth-demo-btn:active {
  transform: scale(0.98);
}

.demo-btn-content {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.92rem;
}

.demo-btn-content svg {
  color: #a78bfa;
}

.demo-btn-subtitle {
  color: var(--text-secondary);
  font-size: 0.73rem;
  letter-spacing: 0.01em;
}

/* Demo Mode Success Banner */
.auth-success-banner.demo-mode-banner {
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.35);
  box-shadow: 0 8px 30px -10px rgba(139, 92, 246, 0.25);
}

.demo-mode-banner .auth-success-badge {
  color: #c4b5fd;
}

.demo-mode-banner .auth-success-badge .pulse-dot {
  background: #a78bfa;
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.7);
}

/* Avatar Demo Ring & Tag */
.user-avatar-ring.demo-ring {
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.55);
  border-color: rgba(139, 92, 246, 0.6);
  position: relative;
}

.demo-avatar-tag {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #ffffff;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}



@media (max-width: 768px) {
  .floating-dock,
  .app-dock {
    width: calc(100% - 24px);
    bottom: 14px;
    padding: 0 12px;
    gap: 8px;
    height: 80px !important;
    min-height: 80px !important;
    max-height: 80px !important;
    overflow: visible;
  }
  
  .dock-slot {
    min-width: auto;
  }

  .dock-center-chat {
    flex: 1 1 auto;
    max-width: 70%;
  }

  .chat-input-bezel {
    height: 66px !important;
    min-height: 66px !important;
    max-height: 66px !important;
    padding: 5px 10px;
    border-radius: 20px;
  }

  .chat-input-bezel textarea {
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
    font-size: 0.95rem;
    line-height: 22px !important;
    padding: 0 4px !important;
  }

  .brand-dock-meta,
  .agent-dock-meta {
    display: none;
  }

  .sphere-perch {
    width: 70px;
    height: 70px;
    left: 50% !important;
    bottom: calc(100% - 20px) !important;
    transform: translateX(-50%) !important;
  }

  .profile-popover {
    left: 12px;
    right: auto;
    bottom: 84px;
    width: calc(100vw - 24px);
  }
}

@media (max-width: 600px) {
  .dossier-grid {
    grid-template-columns: 1fr;
  }
  .auth-modal,
  .auth-modal-card {
    padding: 24px;
    width: 94%;
  }
  .profile-popover {
    left: 12px;
    right: auto;
    width: calc(100vw - 24px);
  }
}

/* ==========================================================================
   11. FULL SOVEREIGN DOSSIER MODAL (ملف المستخدم السيادي الكامل)
   ========================================================================== */
.profile-action-btn.view-dossier-btn {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(14, 165, 233, 0.2));
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #ffffff;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
}

.profile-action-btn.view-dossier-btn:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(14, 165, 233, 0.35));
  border-color: rgba(139, 92, 246, 0.65);
  transform: translateY(-1px);
}

.dossier-modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 1001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-fluid);
}

.dossier-modal-backdrop.active {
  display: block !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.dossier-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: 92%;
  max-width: 860px;
  max-height: 88vh;
  background: rgba(11, 13, 23, 0.98);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 26px;
  box-shadow: 0 35px 90px -15px rgba(0, 0, 0, 0.98), 0 0 50px rgba(139, 92, 246, 0.25);
  z-index: 1002;
  opacity: 0;
  pointer-events: none;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.25s var(--ease-fluid), transform 0.25s var(--ease-fluid);
}

.dossier-modal.active {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translate(-50%, -50%) scale(1) !important;
}

.dossier-modal-header {
  padding: 24px 28px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: rgba(18, 20, 36, 0.5);
  flex-shrink: 0;
}

.dossier-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  color: #a78bfa;
  letter-spacing: normal;
  margin-bottom: 6px;
}

.dossier-header-badge .status-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a78bfa;
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.8);
}

.dossier-header-title-group h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: normal;
  color: #ffffff;
}

.dossier-modal-body {
  padding: 22px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}

.dossier-modal-body::-webkit-scrollbar {
  width: 6px;
}

.dossier-modal-body::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 6px;
}

/* Dossier Cards */
.dossier-section-card {
  background: rgba(18, 20, 36, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 18px 20px;
  transition: border-color 0.2s;
}

.dossier-section-card:hover {
  border-color: rgba(139, 92, 246, 0.25);
}

.dossier-section-card.identity-card {
  background: linear-gradient(135deg, rgba(22, 24, 44, 0.85), rgba(15, 17, 30, 0.85));
  border: 1px solid rgba(139, 92, 246, 0.35);
  box-shadow: 0 8px 30px -10px rgba(139, 92, 246, 0.2);
}

.identity-main {
  display: flex;
  align-items: center;
  gap: 20px;
}

.identity-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.identity-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #0ea5e9);
  color: #ffffff;
  font-size: 1.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.identity-verified-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #10b981;
  color: #000000;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0b0d17;
}

.identity-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.identity-name-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.identity-name-row h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.demo-pill-tag {
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(139, 92, 246, 0.5);
  color: #c4b5fd;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 9999px;
  font-family: var(--font-sans);
  letter-spacing: normal;
}

.identity-sub {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.identity-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.identity-tag {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  letter-spacing: normal;
}

.identity-tag.success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d178;
}

.identity-tag.cipher {
  background: rgba(14, 165, 233, 0.1);
  border-color: rgba(14, 165, 233, 0.3);
  color: #38bdf8;
}

/* Columns Grid */
.dossier-columns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.section-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.section-card-title svg {
  color: #8b5cf6;
}

.dossier-spec-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dossier-spec-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.spec-label {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: normal;
}

.spec-value {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
}

.spec-value.highlight {
  color: #ffffff;
  font-weight: 600;
}

.spec-value.score {
  font-family: var(--font-mono);
  color: #34d178;
  font-weight: 700;
  font-size: 1rem;
}

.score-percentile {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 400;
}

.spec-value.comp-highlight {
  color: #38bdf8;
  font-weight: 700;
  font-size: 1.05rem;
}

.spec-value.danger-stop {
  color: #f87171;
  font-weight: 600;
}

.spec-value.text-shield {
  color: #34d178;
  font-weight: 500;
}

.capabilities-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.capabilities-pills span {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--text-secondary);
  letter-spacing: normal;
}

/* Modal Footer */
.dossier-modal-footer {
  padding: 16px 28px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(14, 16, 28, 0.9);
  flex-shrink: 0;
}

.dossier-footer-info {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.dossier-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

@media (max-width: 768px) {
  .dossier-columns-grid {
    grid-template-columns: 1fr;
  }
  .identity-main {
    flex-direction: column;
    text-align: center;
  }
  .identity-name-row {
    justify-content: center;
  }
  .identity-tags {
    justify-content: center;
  }
  .dossier-modal {
    width: 95%;
    max-height: 92vh;
    border-radius: 20px;
  }
  .dossier-modal-header,
  .dossier-modal-body,
  .dossier-modal-footer {
    padding-left: 18px;
    padding-right: 18px;
  }
  .dossier-modal-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .dossier-footer-actions {
    width: 100%;
    justify-content: stretch;
  }
  .dossier-footer-actions button {
    flex: 1;
  }
}

/* ==========================================================================
   12. TEXT DIRECTION
   The physical rules above were written for the Arabic (RTL) layout. English (the main
   language) is LTR, so the side-specific ones are mirrored here.
   ========================================================================== */
html[dir="ltr"] .chat-row.agent .chat-bubble {
  border-top-right-radius: 24px;
  border-top-left-radius: 6px;
}

html[dir="ltr"] .chat-row.user .chat-bubble {
  border-top-left-radius: 24px;
  border-top-right-radius: 6px;
}

html[dir="ltr"] .attach-menu-dropdown {
  right: auto;
  left: 0;
}

html[dir="ltr"] .profile-popover {
  left: auto;
  right: max(24px, calc((100vw - 1240px) / 2 + 18px));
}

/* The submit arrows point "forward": left in Arabic, right in English */
html[dir="ltr"] .auth-submit-btn svg {
  transform: scaleX(-1);
}

@media (max-width: 768px) {
  html[dir="ltr"] .profile-popover {
    left: 12px;
    right: auto;
  }
}

/* Phones: the language switch shares the end slot with sound and account, so tighten it */
@media (max-width: 768px) {
  .dock-slot.dock-left {
    gap: 6px;
  }

  .lang-toggle {
    min-width: 28px;
    height: 26px;
    padding: 0 6px;
  }
}

/* ==========================================================================
   13. ENVIRONMENTS
   The scene behind the chat (space, sea, road, sky, paper) is chosen in the dock's
   environment panel; <html data-env> carries it. Each environment retunes the color tokens
   from index.css, and paper turns the whole interface light: ink on paper.
   ========================================================================== */

/* The picker button: same footprint as the sound toggle */
.env-picker {
  position: relative;
  display: flex;
  align-items: center;
}

.env-toggle {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, transform 0.15s;
}

.env-toggle:hover,
.env-picker.open .env-toggle {
  color: var(--text-primary);
  transform: scale(1.08);
}

.env-toggle:focus-visible,
.env-option:focus-visible,
.env-switch:focus-visible {
  outline: 2px solid rgba(var(--accent-hi-rgb), 0.9);
  outline-offset: 2px;
}

.env-icon,
.env-swatch svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The panel opens above the dock, aligned to the button's end edge */
.env-panel {
  position: absolute;
  bottom: calc(100% + 34px);
  inset-inline-end: -10px;
  width: 288px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(var(--menu-rgb), 0.96);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  box-shadow:
    0 24px 50px -10px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(var(--accent-rgb), 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  z-index: 210;
  animation: popoverFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.env-panel[hidden] {
  display: none;
}

.env-panel-title {
  padding: 8px 10px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

html[lang="ar"] .env-panel-title {
  letter-spacing: normal;
  font-size: 0.8rem;
}

.env-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.env-option {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 7px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--text-primary);
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.env-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.env-option[aria-checked="true"] {
  background: rgba(var(--accent-rgb), 0.16);
  border-color: rgba(var(--accent-rgb), 0.45);
}

/* A tiny window onto each place */
.env-swatch {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.env-swatch svg {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.env-option[data-env="space"] .env-swatch {
  background:
    radial-gradient(1px 1px at 22% 30%, #ffffff, transparent),
    radial-gradient(1px 1px at 76% 22%, #d2e8ff, transparent),
    radial-gradient(1.4px 1.4px at 64% 72%, #ffffff, transparent),
    radial-gradient(1px 1px at 30% 80%, #fff2d7, transparent),
    #05050c;
}

.env-option[data-env="sea"] .env-swatch {
  background: linear-gradient(180deg, #050b1a 0%, #1a2c4c 49%, #16284a 51%, #030812 100%);
}

.env-option[data-env="road"] .env-swatch {
  background: linear-gradient(180deg, #1a1840 0%, #9b4567 38%, #f6b26b 50%, #2b1a35 53%, #0e0b12 100%);
}

.env-option[data-env="sky"] .env-swatch {
  background: linear-gradient(180deg, #2c5a96 0%, #9db6d8 36%, #f4d4b6 47%, #ead8d0 52%, #93a6c8 100%);
}

.env-option[data-env="paper"] .env-swatch {
  background: radial-gradient(circle at 30% 25%, #fbf6ea, #ece2cd);
  color: #4d4337;
  box-shadow: inset 0 0 0 1px rgba(70, 50, 25, 0.18);
}

.env-option[data-env="paper"] .env-swatch svg {
  filter: none;
}

.env-option-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.env-option-name {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
}

.env-option-hint {
  font-size: 0.76rem;
  color: var(--text-tertiary);
  line-height: 1.35;
}

.env-panel-divider {
  height: 1px;
  margin: 6px 8px;
  background: rgba(255, 255, 255, 0.1);
}

/* Sound switches */
.env-switch {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 9px 10px;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  text-align: start;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.env-switch:hover {
  background: rgba(255, 255, 255, 0.06);
}

.env-switch:disabled {
  opacity: 0.45;
  cursor: default;
}

.env-switch-label {
  display: flex;
  flex-direction: column;
}

.env-switch-hint {
  font-size: 0.74rem;
  color: var(--text-tertiary);
}

.env-switch-track {
  position: relative;
  flex-shrink: 0;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.2s ease;
}

.env-switch-thumb {
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s var(--ease-fluid);
}

.env-switch[aria-checked="true"] .env-switch-track {
  background: rgb(var(--accent-rgb));
}

.env-switch[aria-checked="true"] .env-switch-thumb {
  transform: translateX(14px);
}

html[dir="rtl"] .env-switch[aria-checked="true"] .env-switch-thumb {
  transform: translateX(-14px);
}

/* Phones: the dock has no room for both buttons, so the sound toggle steps aside
   (sound is switched in the environment panel) and the panel spans the screen */
@media (max-width: 768px) {
  .audio-toggle {
    display: none;
  }

  .env-toggle {
    padding: 6px;
  }

  /* Anchor the panel to the dock itself (the nearest positioned box), as wide as the dock */
  .env-picker {
    position: static;
  }

  .env-panel {
    left: 0;
    right: 0;
    bottom: calc(100% + 10px);
    width: auto;
  }
}

/* --- Per-environment palettes ------------------------------------------- */

html[data-env="sea"] {
  --bg-void: #030812;
  --accent-rgb: 56, 189, 220;
  --accent-2-rgb: 59, 130, 246;
  --accent-hi-rgb: 103, 232, 249;
  --dock-rgb: 6, 14, 28;
  --bezel-rgb: 8, 24, 42;
  --bezel-focus-rgb: 10, 32, 56;
  --bubble-rgb: 9, 20, 38;
  --menu-rgb: 8, 16, 30;
}

html[data-env="road"] {
  --bg-void: #0b0710;
  --accent-rgb: 245, 158, 11;
  --accent-2-rgb: 236, 72, 153;
  --accent-hi-rgb: 251, 191, 36;
  --dock-rgb: 20, 12, 22;
  --bezel-rgb: 38, 20, 30;
  --bezel-focus-rgb: 50, 26, 38;
  --bubble-rgb: 28, 16, 30;
  --menu-rgb: 22, 13, 24;
}

html[data-env="sky"] {
  --bg-void: #3c69a6;
  --accent-rgb: 56, 152, 236;
  --accent-2-rgb: 244, 162, 97;
  --accent-hi-rgb: 125, 196, 255;
  --dock-rgb: 14, 30, 58;
  --bezel-rgb: 16, 36, 70;
  --bezel-focus-rgb: 20, 46, 88;
  --bubble-rgb: 16, 34, 64;
  --bubble-alpha: 0.68;
  --menu-rgb: 14, 30, 58;
}

/* --- Paper: the light theme ---------------------------------------------- */

html[data-env="paper"] {
  color-scheme: light;
  --bg-void: #f1e9d8;
  --text-primary: #2b241b;
  --text-secondary: #4d4337;
  --text-tertiary: #7a6e5e;
  --accent-rgb: 37, 70, 140;    /* fountain-pen ink */
  --accent-2-rgb: 120, 85, 45;  /* sepia */
  --accent-hi-rgb: 37, 70, 140;
  --accent-border: rgba(70, 50, 25, 0.14);
  --surface-raised: rgba(255, 252, 245, 0.75);
  --surface-monolith: rgba(255, 252, 245, 0.92);
  --dock-rgb: 250, 246, 237;
  --bezel-rgb: 255, 253, 248;
  --bezel-focus-rgb: 255, 255, 252;
  --bubble-rgb: 255, 253, 247;
  --bubble-alpha: 0.88;
  --menu-rgb: 252, 249, 242;
}

html[data-env="paper"] .floating-dock {
  border-color: rgba(70, 50, 25, 0.14);
  box-shadow:
    0 18px 44px -18px rgba(80, 55, 20, 0.4),
    0 0 0 1px rgba(70, 50, 25, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

html[data-env="paper"] .chat-row.agent .chat-bubble {
  border-color: rgba(70, 50, 25, 0.12);
  box-shadow: 0 10px 28px -16px rgba(80, 55, 20, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

html[data-env="paper"] .chat-row.agent .chat-bubble.is-error {
  color: #9b2c2c;
  border-color: rgba(185, 28, 28, 0.35);
}

html[data-env="paper"] .chat-row.user .chat-bubble {
  background: rgba(var(--accent-rgb), 0.07);
  border-color: rgba(var(--accent-rgb), 0.22);
  box-shadow: 0 10px 28px -18px rgba(var(--accent-rgb), 0.35);
}

html[data-env="paper"] .chat-input-bezel {
  border-color: rgba(var(--accent-rgb), 0.3);
  box-shadow: inset 0 1px 3px rgba(80, 55, 20, 0.12);
}

html[data-env="paper"] .chat-input-bezel:focus-within {
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12), inset 0 1px 3px rgba(80, 55, 20, 0.12);
}

html[data-env="paper"] .chat-action-btn {
  background: rgba(70, 50, 25, 0.05);
  border-color: rgba(70, 50, 25, 0.16);
  color: #3a3126;
}

html[data-env="paper"] .chat-action-btn:hover {
  background: rgba(var(--accent-rgb), 0.08);
  color: rgb(var(--accent-rgb));
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

html[data-env="paper"] .brand-name-arrab {
  color: var(--text-primary);
  filter: none;
}

html[data-env="paper"] .avatar-ring.brand-emblem-ring {
  border-color: rgba(70, 50, 25, 0.25);
  box-shadow: 0 2px 8px rgba(80, 55, 20, 0.25);
}

html[data-env="paper"] .lang-toggle {
  border-color: rgba(70, 50, 25, 0.22);
}

html[data-env="paper"] .user-avatar-ring {
  border-color: rgba(70, 50, 25, 0.18);
  box-shadow: none;
}

html[data-env="paper"] .sphere-perch {
  filter: drop-shadow(0 6px 12px rgba(80, 55, 20, 0.35));
}

html[data-env="paper"] .attach-menu-dropdown,
html[data-env="paper"] .env-panel,
html[data-env="paper"] .profile-popover {
  background: rgba(var(--menu-rgb), 0.97);
  border-color: rgba(70, 50, 25, 0.14);
  box-shadow: 0 20px 44px -12px rgba(80, 55, 20, 0.35), 0 0 0 1px rgba(70, 50, 25, 0.04);
}

html[data-env="paper"] .attach-menu-item {
  color: var(--text-primary);
}

html[data-env="paper"] .attach-menu-item:hover,
html[data-env="paper"] .env-option:hover,
html[data-env="paper"] .env-switch:hover,
html[data-env="paper"] .profile-action-btn:hover {
  background: rgba(70, 50, 25, 0.06);
}

html[data-env="paper"] .env-option[aria-checked="true"] {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--accent-rgb), 0.35);
}

html[data-env="paper"] .env-panel-divider {
  background: rgba(70, 50, 25, 0.12);
}

html[data-env="paper"] .env-switch-track {
  background: rgba(70, 50, 25, 0.18);
}

html[data-env="paper"] .env-switch[aria-checked="true"] .env-switch-track {
  background: rgb(var(--accent-rgb));
}

html[data-env="paper"] .profile-popover-avatar,
html[data-env="paper"] .user-avatar-ring.initial {
  background: var(--text-primary);
  color: #faf6ed;
}

html[data-env="paper"] .chat-bubble pre {
  background: rgba(70, 50, 25, 0.06);
  border-color: rgba(70, 50, 25, 0.12);
  color: var(--text-primary);
}

html[data-env="paper"] .chat-bubble code {
  background: rgba(70, 50, 25, 0.07);
}

html[data-env="paper"] .widget-btn:hover {
  background: rgba(70, 50, 25, 0.06);
}

html[data-env="paper"] .widget-btn.primary {
  background: var(--text-primary);
  color: #faf6ed;
  border-color: var(--text-primary);
}

html[data-env="paper"] ::-webkit-scrollbar-thumb {
  background: rgba(70, 50, 25, 0.18);
}

/* The sign-in card becomes a sheet of its own */
html[data-env="paper"] .auth-modal-backdrop {
  background: rgba(60, 45, 25, 0.35);
}

html[data-env="paper"] .auth-modal {
  background: rgba(252, 249, 242, 0.98);
  border-color: rgba(70, 50, 25, 0.14);
  box-shadow: 0 30px 80px -20px rgba(60, 40, 15, 0.5);
}

html[data-env="paper"] .auth-tab.active {
  box-shadow: 0 1px 3px rgba(80, 55, 20, 0.2);
}

html[data-env="paper"] .form-group input:focus {
  border-color: rgba(var(--accent-rgb), 0.5);
}

html[data-env="paper"] .auth-submit-btn.primary {
  background: var(--text-primary);
  color: #faf6ed;
}

html[data-env="paper"] .auth-submit-btn.primary:hover:not(:disabled) {
  background: #463c30;
}

html[data-env="paper"] .auth-demo-btn {
  background: rgba(var(--accent-rgb), 0.06);
  border-color: rgba(var(--accent-rgb), 0.3);
}

html[data-env="paper"] .auth-demo-btn:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 8px 24px -10px rgba(var(--accent-rgb), 0.35);
}

html[data-env="paper"] .demo-btn-content {
  color: var(--text-primary);
}

html[data-env="paper"] .demo-btn-content svg {
  color: rgb(var(--accent-rgb));
}

@media (prefers-reduced-motion: reduce) {
  .env-panel {
    animation: none;
  }
}
