/* ==========================================================================
   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 170px; /* Leave space for the dock and the sphere perched on it */
  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;
}

/* Sphere 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;
}

/* 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; }
  /* Full width on phones, and clear of the dock and the sphere so the last reply (and its
     buttons) can be read and tapped. */
  .console-stream { width: 100%; max-width: none; padding: 16px 16px 170px; }
  .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);
  }
}

/* Narrow phones: one row leaves the message box too narrow to type in (the placeholder wrapped
   onto three lines at 390px), so the dock takes two rows. The message box fills the first,
   with the sphere still perched on it; the logo, environment, language and account buttons sit
   on a slim row underneath. Order and wrapping follow <html dir>, so Arabic mirrors as usual. */
@media (max-width: 520px) {
  .floating-dock,
  .app-dock {
    flex-wrap: wrap;
    align-content: center;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 8px 12px 6px;
    row-gap: 4px;
    column-gap: 8px;
  }

  .dock-center-chat {
    order: -1;
    flex: 1 0 100%;
    width: 100%;
    max-width: none;
    height: auto;
  }

  .chat-input-bezel {
    height: 58px !important;
    min-height: 58px !important;
    max-height: 58px !important;
  }

  .chat-input-bezel textarea {
    height: 46px !important;
    min-height: 46px !important;
    max-height: 46px !important;
  }

  .dock-slot {
    height: 34px;
  }

  /* The second row has room for the name next to the logo again */
  .brand-dock-profile {
    gap: 8px;
  }

  .avatar-ring.brand-emblem-ring {
    width: 28px;
    height: 28px;
  }

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

  .brand-name-arrab {
    font-size: 0.9rem;
  }

  .user-avatar-ring {
    width: 32px;
    height: 32px;
  }

  /* The dock is about 112px tall here (80px above 520px), so the sphere's top sits about 167px
     from the bottom of the screen: the chat stream clears it, and the account card opens above it. */
  .console-stream {
    padding-bottom: 200px;
  }

  .profile-popover {
    bottom: 136px;
  }
}

@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. LARGE MODAL (the dossier window; no longer used by My CV, which is a page now)
   ========================================================================== */
.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 end slot holds the environment, sound and account buttons, so tighten it */
@media (max-width: 768px) {
  .dock-slot.dock-left {
    gap: 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"] .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;
  }
}


/* ==========================================================================
   INTERACTIVE ELEMENTS UNDER A REPLY (app.js appendAsk) AND SOURCES
   ========================================================================== */
.ask-widget {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 2px;
  max-width: 100%;
}

.ask-options,
.ask-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ask-widget .widget-btn {
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  line-height: 1.3;
  white-space: normal;
  text-align: start;
}

.ask-widget .widget-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.ask-chip[aria-pressed="true"],
.ask-option.is-chosen {
  background: rgba(var(--accent-rgb), 0.28);
  border-color: rgba(var(--accent-rgb), 0.7);
  opacity: 1 !important;
}

.ask-line {
  display: flex;
  gap: 8px;
  align-items: stretch;
  width: min(100%, 520px);
}

.ask-line.is-long {
  flex-direction: column;
}

.ask-line.is-long .ask-submit {
  align-self: flex-end;
}

.ask-input,
.ask-select {
  flex: 1;
  min-width: 0;
  background: var(--surface-monolith);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  padding: 9px 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  resize: vertical;
}

.ask-input:focus,
.ask-select:focus {
  border-color: rgba(var(--accent-rgb), 0.6);
}

.ask-select option {
  color: #111;
}

/* Skip: a quiet text button under a CV question */
.ask-skip {
  align-self: flex-start;
  background: none;
  border: 0;
  padding: 2px 4px;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.ask-skip:hover {
  color: var(--text-secondary);
}

.ask-skip:disabled {
  opacity: 0.45;
  cursor: default;
}

.chat-sources {
  max-width: min(100%, 560px);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chat-sources-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.chat-sources-list {
  margin: 0;
  padding-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-sources-list a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.chat-search-suggestions {
  display: block;
  width: 100%;
  height: 64px;
  margin-top: 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
}

/* ==========================================================================
   FORMS IN THE CHAT: name, job and study entries, skills (app.js)
   ========================================================================== */
.ask-line[hidden] {
  display: none;
}

.ask-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(100%, 520px);
}

.ask-form .entry-error,
.ask-form .ask-submit {
  grid-column: 1 / -1;
  justify-self: start;
}

.entry-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 560px);
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.entry-part {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.entry-part.entry-longtext {
  grid-column: 1 / -1;
}

.entry-part .ask-input,
.entry-part .ask-select {
  width: 100%;
}

.entry-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.entry-error {
  margin: 0;
  font-size: 0.8rem;
  color: #fca5a5;
}

.entry-error:empty {
  display: none;
}

.ask-tags {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ask-widget .ask-cancel {
  background: transparent;
}

.ask-other[aria-expanded="true"] {
  border-color: rgba(var(--accent-rgb), 0.7);
}

/* Screen-reader text (the "Sphere is writing" status behind the dots) */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ==========================================================================
   /add MENU (app.js commandMenu), BETA TAG, NOTICE AND THE "CAN MAKE MISTAKES" LINE
   ========================================================================== */
.command-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  margin: 0 auto;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  background: rgba(var(--menu-rgb), 0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.75);
  z-index: 40;
}

.command-menu[hidden] {
  display: none;
}

.command-head {
  padding: 6px 10px 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.command-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  text-align: start;
  cursor: pointer;
}

.command-item:hover,
.command-item[aria-selected="true"] {
  background: rgba(var(--accent-rgb), 0.22);
}

.command-name {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
}

.command-hint {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.command-empty {
  padding: 10px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #fcd34d;
}

.command-foot {
  margin-top: 4px;
  padding: 6px 10px 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

@media (hover: none) {
  .command-foot {
    display: none;
  }
}

.beta-tag {
  display: inline-block;
  align-self: flex-start;
  margin-top: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  background: rgba(var(--accent-rgb), 0.2);
  color: var(--text-primary);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

html[dir="rtl"] .beta-tag {
  letter-spacing: 0;
  font-size: 0.66rem;
}

.site-notice {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translate(-50%, -8px);
  width: min(600px, calc(100% - 24px));
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px 14px 18px;
  background: rgba(var(--menu-rgb), 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.7);
  z-index: 950;
  opacity: 0;
  transition: opacity 0.25s var(--ease-fluid), transform 0.25s var(--ease-fluid);
}

.site-notice.active {
  opacity: 1;
  transform: translate(-50%, 0);
}

.site-notice[hidden] {
  display: none;
}

.site-notice-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.site-notice-text p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.site-notice-text .site-notice-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.site-notice-title .beta-tag {
  margin: 0 4px 0 0;
}

.site-notice .widget-btn {
  flex-shrink: 0;
  border-radius: 999px;
}

/* Under the message box, in the gap below the dock */
.chat-disclaimer {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  overflow: hidden;
  font-size: 0.68rem;
  line-height: 1.3;
  color: var(--text-tertiary);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 768px) {
  .chat-disclaimer {
    margin-top: 1px;
    font-size: 0.62rem;
  }
}

@media (max-width: 520px) {
  /* The dock has two rows here: the line goes under the whole dock, and the /add menu above it. */
  .dock-center-chat {
    position: static;
  }

  .brand-dock-meta {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  .brand-dock-meta .beta-tag {
    align-self: center;
    margin-top: 0;
  }

  .site-notice {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    top: 10px;
  }
}

/* ==========================================================================
   MY CV: THE PAGE AT #cv (scripts/cv.js)
   The CV reads as a document: a paper sheet, the same in every environment.
   ========================================================================== */
.cv-page {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  background: rgba(var(--dock-rgb), 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  opacity: 0;
  transition: opacity 0.2s var(--ease-fluid);
}

.cv-page.active {
  opacity: 1;
}

.cv-page[hidden] {
  display: none;
}

.cv-page-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.cv-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 8px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.cv-back:hover,
.cv-back:focus-visible {
  border-color: var(--accent-border);
  background: rgba(255, 255, 255, 0.06);
}

html[dir="rtl"] .cv-back svg {
  transform: scaleX(-1);
}

.cv-page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.cv-print-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 9px 16px;
}

.cv-page-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cv-page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 72px;
}

.cv-aside {
  position: sticky;
  top: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cv-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: rgba(var(--bubble-rgb), 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
}

.cv-card[hidden] {
  display: none;
}

.cv-card-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.cv-progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.cv-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgb(var(--accent-rgb)), rgb(var(--accent-2-rgb)));
  transition: width 0.4s var(--ease-fluid);
}

.cv-card .widget-btn {
  border-radius: 999px;
}

.cv-card .widget-btn[hidden] {
  display: none;
}

.cv-consent p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.cv-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.cv-switch input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: rgb(var(--accent-rgb));
}

.cv-note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-tertiary);
}

.cv-status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.8rem;
  font-weight: 600;
  color: #6ee7b7;
}

/* --- The sheet --- */
.cv-sheet {
  --ink: #1d1e23;
  --ink-2: #4a4944;
  --ink-3: #7b786f;
  --ink-4: #a6a29a;
  --rule: #ebe7de;
  --mark: #4b3bb0;
  position: relative;
  min-height: 70vh;
  padding: 48px 52px 40px;
  background: #fdfcf9;
  color: var(--ink);
  border-radius: 18px;
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.04);
  font-size: 0.95rem;
  line-height: 1.6;
}

.cv-sheet-head {
  position: relative;
  padding: 0 90px 22px 0;
  border-bottom: 2px solid var(--ink);
}

html[dir="rtl"] .cv-sheet-head {
  padding: 0 0 22px 90px;
}

.cv-sheet-head .cv-edit-btn {
  position: absolute;
  top: 4px;
  inset-inline-end: 0;
}

.cv-sheet-head:has(.cv-edit) {
  padding-inline-end: 0;
}

.cv-name {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.cv-headline {
  margin: 6px 0 0;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--mark);
}

.cv-meta {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--ink-3);
}

.cv-sheet .is-empty.cv-name,
.cv-sheet .is-empty.cv-headline {
  color: var(--ink-4);
}

.cv-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}

.cv-section:last-child {
  border-bottom: 0;
}

.cv-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.cv-section-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

html[dir="rtl"] .cv-section-title {
  font-size: 0.92rem;
  letter-spacing: 0;
}

.cv-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid #dcd7cc;
  border-radius: 999px;
  color: #3b3a36;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.cv-btn:hover,
.cv-btn:focus-visible {
  background: #f1eee6;
  border-color: #c9c3b6;
}

.cv-btn:focus-visible,
.cv-sheet .widget-btn:focus-visible,
.cv-sheet input:focus-visible,
.cv-sheet select:focus-visible,
.cv-sheet textarea:focus-visible {
  outline: 2px solid var(--mark);
  outline-offset: 2px;
}

.cv-add-btn {
  margin-top: 12px;
  border-style: dashed;
  color: var(--mark);
}

.cv-danger {
  border-color: #e9b8b3;
  color: #b42318;
}

.cv-danger:hover {
  background: #fdecea;
}

.cv-confirm {
  font-size: 0.8rem;
  color: var(--ink-2);
}

.cv-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-4);
}

.cv-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.7;
  color: #2d2c29;
}

.cv-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cv-chip {
  padding: 4px 12px;
  border-radius: 999px;
  background: #efecf9;
  color: #3a2d8c;
  font-size: 0.85rem;
}

.cv-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
  margin: 0;
}

.cv-detail dt {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-3);
}

.cv-detail dd {
  margin: 2px 0 0;
  color: var(--ink);
}

.cv-detail.is-empty dd {
  color: var(--ink-4);
}

.cv-entries {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cv-entry {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cv-entry.is-new {
  margin-top: 6px;
}

.cv-entry-body {
  flex: 1;
  min-width: 0;
}

.cv-entry-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
}

.cv-entry-main {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.cv-entry-when {
  font-size: 0.82rem;
  color: var(--ink-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cv-entry-sub {
  font-size: 0.9rem;
  color: var(--ink-2);
}

.cv-entry-text {
  margin: 6px 0 0;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #3d3c38;
}

.cv-entry-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  opacity: 0.55;
  transition: opacity 0.15s;
}

.cv-entry-tools .cv-btn {
  padding: 2px 10px;
  font-size: 0.72rem;
}

.cv-entry:hover .cv-entry-tools,
.cv-entry:focus-within .cv-entry-tools,
.cv-entry-tools:has(.cv-danger) {
  opacity: 1;
}

@media (hover: none) {
  .cv-entry-tools {
    opacity: 1;
  }
}

.cv-list-note {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--ink-2);
}

.cv-list-note-label {
  color: var(--ink-3);
}

/* --- Editing on the sheet: light fields on the paper --- */
.cv-edit {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.cv-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.cv-edit-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.cv-edit-field:has(textarea),
.cv-edit-field:has(.cv-options),
.cv-edit-field:has(.cv-tags-edit) {
  grid-column: 1 / -1;
}

.cv-edit-actions {
  display: flex;
  gap: 8px;
}

.cv-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.cv-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-monolith);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.5;
  outline: none;
  resize: vertical;
}

select.cv-input option {
  color: #111;
}

.cv-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cv-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
}

.cv-option input {
  accent-color: rgb(var(--accent-rgb));
}

.cv-sheet .cv-label,
.cv-sheet .entry-label {
  color: var(--ink-2);
}

.cv-sheet .cv-input,
.cv-sheet .ask-input,
.cv-sheet .ask-select {
  background: #fff;
  border: 1px solid #d8d3c8;
  color: var(--ink);
}

.cv-sheet .cv-input:focus,
.cv-sheet .ask-input:focus,
.cv-sheet .ask-select:focus {
  border-color: var(--mark);
}

.cv-sheet .ask-input::placeholder,
.cv-sheet .cv-input::placeholder {
  color: var(--ink-4);
}

.cv-sheet .cv-option {
  border-color: #d8d3c8;
  color: var(--ink);
}

.cv-sheet .cv-option:has(input:checked) {
  background: #efecf9;
  border-color: #9c8fe0;
}

.cv-sheet .cv-option input {
  accent-color: var(--mark);
}

.cv-sheet .widget-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border-color: #d8d3c8;
  color: var(--ink);
  background: transparent;
}

.cv-sheet .widget-btn:hover {
  background: #f1eee6;
}

.cv-sheet .widget-btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.cv-sheet .widget-btn.primary:hover {
  background: #33343b;
}

.cv-sheet .widget-btn:disabled {
  opacity: 0.45;
}

.cv-sheet .ask-chip {
  border-color: #d8d3c8;
  color: var(--ink);
}

.cv-sheet .ask-chip[aria-pressed="true"] {
  background: #efecf9;
  border-color: #9c8fe0;
  color: #3a2d8c;
}

.cv-sheet .entry-error {
  color: #b42318;
}

.cv-sheet .entry-form,
.cv-sheet .ask-options {
  width: 100%;
}

html.cv-open .floating-dock,
html.cv-open .site-notice {
  visibility: hidden;
}

@media (max-width: 900px) {
  .cv-page-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .cv-aside {
    position: static;
  }
}

@media (max-width: 640px) {
  .cv-page-bar {
    padding: 0 10px;
    height: 56px;
  }

  .cv-page-title {
    display: none;
  }

  .cv-print-btn span {
    display: none;
  }

  .cv-print-btn {
    padding: 9px 11px;
  }

  .cv-page-layout {
    padding: 12px 10px 48px;
    gap: 14px;
  }

  .cv-sheet {
    padding: 26px 18px 18px;
    border-radius: 14px;
    font-size: 0.92rem;
  }

  .cv-sheet-head {
    padding-right: 64px;
  }

  html[dir="rtl"] .cv-sheet-head {
    padding: 0 0 18px 64px;
  }

  .cv-name {
    font-size: 1.55rem;
  }

  .cv-edit-grid,
  .cv-details {
    grid-template-columns: minmax(0, 1fr);
  }

}

html[data-env="paper"] .cv-page-bar {
  border-bottom-color: rgba(70, 50, 25, 0.12);
}

html[data-env="paper"] .cv-card {
  background: rgba(245, 239, 226, 0.85);
  border-color: rgba(70, 50, 25, 0.12);
}

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

html[data-env="paper"] .cv-status {
  color: #047857;
}

/* The printed CV: only the sheet, as a plain black-on-white document. */
@media print {
  html.cv-open,
  html.cv-open body,
  html.cv-open .stage-viewport,
  html.cv-open .cv-page,
  html.cv-open .cv-page-scroll {
    position: static !important;
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  html.cv-open body > *:not(.stage-viewport),
  html.cv-open .stage-viewport > *:not(.cv-page),
  html.cv-open .cv-page-bar,
  html.cv-open .cv-aside,
  html.cv-open .cv-sheet .cv-btn,
  html.cv-open .cv-sheet .cv-entry-tools,
  html.cv-open .cv-sheet .cv-empty,
  html.cv-open .cv-sheet .is-empty {
    display: none !important;
  }

  html.cv-open .cv-page-layout {
    display: block;
    padding: 0;
    max-width: none;
  }

  html.cv-open .cv-sheet {
    max-width: 180mm;
    min-height: 0;
    margin: 0 auto;
    padding: 0;
    background: #fff;
    border-radius: 0;
    box-shadow: none;
    font-size: 10.5pt;
  }

  @page {
    margin: 16mm 14mm;
  }

  html.cv-open .cv-sheet-head,
  html[dir="rtl"].cv-open .cv-sheet-head {
    padding: 0 0 10pt;
  }

  html.cv-open .cv-section {
    padding: 10pt 0;
    break-inside: avoid;
  }

  html.cv-open .cv-name {
    font-size: 20pt;
  }

  html.cv-open .cv-chip {
    border: 1px solid #ccc;
    background: none;
    color: #111;
  }
}

/* ==========================================================================
   PROFILE SETTINGS (auth.js): sign in or out, and the language
   ========================================================================== */
@media (min-width: 769px) {
  .profile-popover {
    width: 320px;
  }
}

.profile-popover-avatar.is-guest {
  background: transparent;
  border: 1px dashed var(--accent-border);
}

.profile-popover-email {
  line-height: 1.45;
}

.profile-auth-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px;
}

.profile-auth-row[hidden],
.profile-popover-actions[hidden],
.profile-action-btn[hidden] {
  display: none;
}

.profile-section {
  margin: 14px 0;
  padding-top: 14px;
  border-top: 1px solid var(--accent-border);
}

.profile-section-title {
  margin: 0 0 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.lang-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lang-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface-monolith);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  text-align: start;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.lang-option:hover {
  border-color: rgba(var(--accent-rgb), 0.45);
}

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

.lang-option.is-pending {
  border-style: dashed;
  border-color: rgba(var(--accent-rgb), 0.75);
}

.lang-option-name {
  font-size: 1rem;
  font-weight: 600;
}

.lang-option-hint {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.lang-confirm {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
}

.lang-confirm[hidden] {
  display: none;
}

.lang-confirm-text {
  margin: 0 0 10px;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.lang-confirm-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

/* The change of language: the whole page fades to the new language's name and back */
.lang-transition {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg-void);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s var(--ease-fluid), visibility 0.35s;
}

.lang-transition.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lang-transition-name {
  font-size: clamp(2.2rem, 7vw, 4rem);
  font-weight: 700;
  color: var(--text-primary);
  transform: translateY(8px);
  transition: transform 0.5s var(--ease-fluid);
}

.lang-transition.active .lang-transition-name {
  transform: translateY(0);
}

.lang-transition-brand {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

@media (prefers-reduced-motion: reduce) {
  .lang-transition,
  .lang-transition-name {
    transition: none;
  }
}

/* Sign-in window additions */
.auth-forgot {
  align-self: flex-start;
  margin: -4px 0 4px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.auth-forgot:hover {
  color: var(--text-secondary);
}

.auth-note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-tertiary);
}

html[data-env="paper"] .lang-option {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(70, 50, 25, 0.16);
}

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

/* The CV page's account card */
.cv-account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cv-account-actions .widget-btn {
  padding: 8px 14px;
}

.cv-account-danger {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.4);
}

.cv-account-danger:hover {
  background: rgba(248, 113, 113, 0.12);
}

.cv-account-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.cv-account-message {
  margin: 0;
  font-size: 0.8rem;
  color: #fca5a5;
}

.cv-account-message:empty {
  display: none;
}

html[data-env="paper"] .cv-account-danger {
  color: #b42318;
  border-color: rgba(180, 35, 24, 0.35);
}

/* ==========================================================================
   SPHERE TYPING, AND CARDS IN THE CONVERSATION (app.js sphereSays, scripts/matches.js)
   ========================================================================== */
/* "Sphere is typing": the same dots as the message box, in a small bubble */
.chat-row.agent .chat-bubble.is-typing {
  padding: 14px 18px;
  min-width: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* While a reply is being written out, the bubble can be tapped to finish it */
.chat-bubble.is-writing {
  cursor: default;
}

.chat-card {
  width: min(100%, 460px);
  color: var(--text-primary);
  background: rgba(var(--bubble-rgb), calc(var(--bubble-alpha) + 0.15));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: 0 10px 30px -14px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: start;
}

.chat-card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
}

.chat-card-meta {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.chat-card-text {
  margin: 2px 0 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--text-secondary);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* A long job description shows its first lines until "Read the whole description" */
.chat-card-text.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chat-card-more {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: rgb(var(--accent-2-rgb));
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.chat-card-more:hover {
  text-decoration: underline;
}

.chat-card-link {
  font-size: 0.8rem;
  color: rgb(var(--accent-2-rgb));
  text-decoration: none;
  align-self: flex-start;
}

.chat-card-link:hover {
  text-decoration: underline;
}

.chat-card-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 4px 0 0;
  font-size: 0.88rem;
}

.chat-card-facts dt {
  color: var(--text-tertiary);
}

.chat-card-facts dd {
  margin: 0;
  font-weight: 500;
}

.offer-card {
  border-color: rgba(253, 224, 71, 0.45);
}

html[data-env="paper"] .chat-card {
  border-color: rgba(70, 50, 25, 0.16);
  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"] .offer-card {
  border-color: rgba(180, 120, 20, 0.45);
}

.reset-card {
  gap: 10px;
}

.reset-card .ask-submit {
  align-self: flex-start;
}

/* A reply arriving as it is written (an AI): a soft caret after the last word */
.chat-bubble.is-streaming > :last-child::after {
  content: '';
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-inline-start: 3px;
  vertical-align: -0.12em;
  border-radius: 2px;
  background: rgba(var(--accent-rgb), 0.55);
  animation: stream-caret 1s ease-in-out infinite;
}

@keyframes stream-caret {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-bubble.is-streaming > :last-child::after { animation: none; }
}
