.companion-entry {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.2rem; margin-bottom: 1rem;
  border-radius: 18px; border: 1px solid rgba(167, 139, 250, 0.3);
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.15) 0%, rgba(125, 211, 192, 0.05) 100%);
  box-shadow: inset 0 0 20px rgba(167, 139, 250, 0.05), 0 8px 24px rgba(0,0,0,0.1);
}
.companion-entry__content h3 { margin: 0 0 0.2rem; font-size: 1.1rem; color: var(--accent-2); display: flex; align-items: center; gap: 0.5rem; }
.companion-entry__content p { margin: 0; font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

.companion-view {
  position: fixed; inset: 0; z-index: 9999;
  background: #000; color: #fff;
  display: flex; flex-direction: column;
}

/* Camera Background */
.companion-camera {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0.5; z-index: 1; filter: sepia(0.1) brightness(0.8);
}

/* UI Overlay */
.companion-ui {
  position: relative; z-index: 10; flex: 1;
  display: flex; flex-direction: column; padding: max(env(safe-area-inset-top), 20px) 1.5rem 2rem;
}

.companion-header {
  display: flex; justify-content: space-between; align-items: center; padding: 1rem 0;
}
.companion-header h2 { margin: 0; font-size: 1.2rem; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.btn-close {
  background: rgba(255,255,255,0.2); border: none; color: #fff; width: 36px; height: 36px;
  border-radius: 50%; font-size: 1.2rem; cursor: pointer; backdrop-filter: blur(10px);
}

/* Mode Selector */
.companion-modes {
  flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1.5rem;
}
.mode-card {
  background: rgba(20, 25, 35, 0.75); border: 1px solid rgba(255,255,255,0.15);
  backdrop-filter: blur(16px); padding: 2rem; border-radius: 24px; text-align: center;
  width: 100%; max-width: 320px; cursor: pointer; transition: transform 0.2s, border-color 0.2s;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.mode-card:hover { transform: scale(1.03); border-color: var(--accent); background: rgba(30, 38, 50, 0.85); }
.mode-card h3 { margin: 0 0 0.5rem; font-size: 1.5rem; color: var(--accent); }
.mode-card p { margin: 0; font-size: 0.9rem; color: rgba(255,255,255,0.7); line-height: 1.6; }

/* Active Session UI */
.companion-session {
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 1rem; padding-bottom: 2rem;
}
.companion-pet-selector {
  position: absolute; top: 8%; right: 1rem;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  z-index: 20;
}
.pet-name-badge {
  background: rgba(0,0,0,0.4); padding: 0.4rem 1rem; border-radius: 20px;
  font-weight: bold; font-size: 0.9rem; color: #fff; backdrop-filter: blur(8px);
}
.companion-pet-selector .btn-ghost {
  background: rgba(0,0,0,0.3); border: none; font-size: 1rem; width: 32px; height: 32px;
  border-radius: 50%; color: #fff; cursor: pointer; backdrop-filter: blur(8px);
  transition: transform 0.2s, background 0.2s;
}
.companion-pet-selector .btn-ghost:active { background: rgba(255,255,255,0.2); transform: scale(0.9); }

.pet-avatar-wrapper {
  position: absolute; right: 1.5rem; top: 16%;
  width: 160px; height: 200px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}
.pet-avatar-container {
  width: 140px; height: 140px; background: rgba(255, 255, 255, 0.95);
  border-radius: 50%; padding: 4px; border: 4px solid rgba(255,255,255,0.4);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3), inset 0 0 20px rgba(125,211,192,0.2);
  animation: floatAvatar 4s ease-in-out infinite; z-index: 2; overflow: hidden;
}
.pet-avatar-container img { 
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: #f0f4f8; 
}
.pet-shadow {
  width: 80px; height: 16px; background: rgba(0,0,0,0.35); border-radius: 50%;
  filter: blur(6px); z-index: 1; animation: floatShadow 4s ease-in-out infinite;
  margin-top: 5px;
}

@keyframes floatAvatar { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-30px); } }
@keyframes floatShadow { 0%, 100% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(0.5); opacity: 0.2; } }

.chat-bubble {
  background: rgba(255,255,255,0.92); color: #111; padding: 1rem 1.5rem; border-radius: 20px;
  border-bottom-right-radius: 4px; max-width: 80%;
  font-size: 1.05rem; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  align-self: flex-end; margin-bottom: 2rem; opacity: 0; transform: translateY(20px); transition: all 0.3s;
}
.chat-bubble.show { opacity: 1; transform: translateY(0); }

.chat-input-area {
  display: flex; gap: 0.6rem; width: 100%; max-width: 500px; margin: 0 auto;
}
.chat-input-area input {
  flex: 1; background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.3);
  padding: 1rem 1.5rem; border-radius: 99px; color: #fff; font-size: 1rem; backdrop-filter: blur(12px);
  outline: none; transition: border-color 0.2s;
}
.chat-input-area input:focus { border-color: var(--accent); }
.chat-input-area input::placeholder { color: rgba(255,255,255,0.5); }
.chat-input-area button {
  background: var(--accent); color: #000; border: none; width: 52px; height: 52px; flex-shrink: 0;
  border-radius: 50%; font-size: 1.2rem; cursor: pointer; display: grid; place-items: center; 
  box-shadow: 0 4px 15px rgba(125, 211, 192, 0.4); transition: transform 0.2s;
}
.chat-input-area button:active { transform: scale(0.9); }

/* Companion Dashboard Hero Cards */
.companion-dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1rem 0;
}
.dashboard-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main, #333);
  margin-bottom: 0.5rem;
}
.hero-cards {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.hero-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem 1.5rem;
  border-radius: 24px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.05);
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.hero-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0,0,0,0.08);
}
.hero-card:active { transform: scale(0.98); }
.hero-card.study {
  background: linear-gradient(135deg, #f5f3ff 0%, #ffffff 100%);
  border: 1px solid #e0e7ff;
}
.hero-card.chat {
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
  border: 1px solid #fef3c7;
}
.hero-card-icon {
  font-size: 3rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}
.hero-card-text { flex: 1; }
.hero-card-text h3 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  font-weight: 700;
}
.hero-card.study .hero-card-text h3 { color: #6d28d9; }
.hero-card.chat .hero-card-text h3 { color: #b45309; }

.hero-card-text p {
  margin: 0;
  font-size: 0.95rem;
  color: #64748b;
  line-height: 1.5;
}

.hero-card-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.hero-card-metrics span {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.hero-card-metrics--study span {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(150, 128, 255, 0.18);
  color: #6b5f86;
}

@media (max-width: 880px) {
  .companion-ui {
    padding: calc(env(safe-area-inset-top) + 0.9rem) 0.95rem calc(env(safe-area-inset-bottom) + 0.95rem);
  }

  .companion-header {
    padding: 0.25rem 0 0.8rem;
  }

  .companion-header h2 {
    font-size: 1rem;
  }

  .companion-pet-selector {
    position: static;
    align-self: flex-end;
    margin-bottom: 0.25rem;
  }

  .pet-avatar-wrapper {
    position: static;
    width: 100%;
    height: auto;
    margin: 0 auto;
    align-items: center;
  }

  .pet-avatar-container {
    width: 104px;
    height: 104px;
  }

  .chat-bubble {
    max-width: 100%;
    margin-bottom: 0.9rem;
    font-size: 0.96rem;
  }

  .companion-session {
    justify-content: flex-end;
    padding-bottom: 0.3rem;
  }

  .study-hud {
    padding: 0.75rem 0.85rem;
  }

  .chat-input-area {
    max-width: none;
  }
}
