.ai-companion-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 12000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

a.ai-companion-toggle {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ai-companion-toggle {
  position: relative;
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff4d8d 0%, #8b5cf6 55%, #3b82f6 100%);
  box-shadow: 0 10px 30px rgba(255, 77, 141, 0.35);
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-companion-toggle:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 34px rgba(255, 77, 141, 0.45);
}

.ai-avatar-wrap,
.ai-hero-avatar,
.ai-avatar-face {
  position: relative;
  overflow: hidden;
}

.ai-avatar-wrap {
  width: 56px;
  height: 56px;
  margin: 8px auto 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffd1e8 0%, #f8b4d9 100%);
}

.ai-avatar-glow {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.45), transparent 70%);
  animation: aiPulse 2.4s ease-in-out infinite;
}

.ai-avatar-face,
.ai-hero-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe4f1 0%, #ffc4de 100%);
}

.ai-avatar-hair {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 42%;
  background: linear-gradient(180deg, #5b2148 0%, #7a2f61 100%);
  border-radius: 50% 50% 18% 18%;
}

.ai-avatar-eye {
  position: absolute;
  top: 46%;
  width: 8px;
  height: 10px;
  background: #2d1b2e;
  border-radius: 50%;
  animation: aiBlink 4.8s infinite;
}

.ai-avatar-eye.left { left: 30%; }
.ai-avatar-eye.right { right: 30%; }

.ai-avatar-mouth {
  position: absolute;
  left: 50%;
  bottom: 24%;
  width: 14px;
  height: 7px;
  margin-left: -7px;
  border-bottom: 2px solid #d1497e;
  border-radius: 0 0 12px 12px;
}

.ai-toggle-label {
  position: absolute;
  right: -2px;
  top: -2px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 24px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.ai-companion-panel {
  position: absolute;
  right: 0;
  bottom: 86px;
  width: min(360px, calc(100vw - 24px));
  height: 520px;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: rgba(18, 18, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.ai-companion-panel.hidden {
  display: none;
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(135deg, rgba(255, 77, 141, 0.18), rgba(139, 92, 246, 0.12));
}

.ai-panel-hero {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-hero-avatar {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
}

.ai-hero-name {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.ai-hero-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
  font-size: 12px;
}

.ai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
}

.ai-panel-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.ai-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.ai-msg {
  margin-bottom: 12px;
}

.ai-msg-user {
  display: flex;
  justify-content: flex-end;
}

.ai-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  color: #f8fafc;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.ai-msg-user .ai-bubble {
  background: linear-gradient(135deg, #ff4d8d, #8b5cf6);
}

.ai-msg-assistant .ai-bubble {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-bubble-error {
  color: #fecaca;
}

.ai-video-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.ai-video-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-video-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #1f2937;
}

.ai-video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ai-video-thumb-fallback {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #374151, #111827);
}

.ai-video-duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 11px;
}

.ai-video-title {
  padding: 8px;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.35;
  min-height: 42px;
}

.ai-no-videos {
  margin-top: 8px;
  color: #94a3b8;
  font-size: 12px;
}

.ai-panel-form.is-locked {
  opacity: 0.55;
  pointer-events: none;
}

.ai-quota-line {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.3;
}

.ai-quota-free {
  color: #f9a8d4;
}

.ai-quota-vip {
  color: #fde68a;
  font-weight: 600;
}

.ai-quota-vip i {
  margin-right: 4px;
}

.ai-checkin-row {
  margin-top: 6px;
}

.ai-checkin-btn {
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #ec4899, #a855f7);
}

.ai-checkin-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.ai-checkin-done {
  font-size: 11px;
  color: #86efac;
}

.ai-bubble-queue {
  opacity: 0.85;
  font-style: italic;
}

.ai-bubble-checkin {
  border-color: rgba(134, 239, 172, 0.45);
}

.ai-vip-wall {
  padding: 10px 12px 0;
}

.ai-vip-wall.hidden {
  display: none;
}

.ai-vip-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.18), rgba(255, 77, 141, 0.15));
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.ai-vip-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1f1300;
  font-size: 16px;
}

.ai-vip-text strong {
  display: block;
  font-size: 13px;
  color: #fde68a;
  margin-bottom: 2px;
}

.ai-vip-text p {
  margin: 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.4;
}

.ai-vip-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1f1300;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.ai-bubble-vip {
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.1);
}

.ai-vip-inline {
  display: inline-block;
  margin-top: 8px;
  color: #fde68a;
  font-weight: 700;
  text-decoration: underline;
}

.ai-panel-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-panel-form input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  padding: 0 12px;
  font-size: 14px;
}

.ai-panel-form input::placeholder {
  color: #94a3b8;
}

.ai-panel-form button {
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #ff4d8d, #8b5cf6);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.ai-panel-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-companion-panel.is-thinking .ai-hero-status::after {
  content: '...';
}

@keyframes aiPulse {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.05); }
}

@keyframes aiBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}

@media (max-width: 480px) {
  .ai-companion-root {
    right: 12px;
    bottom: 12px;
  }

  .ai-companion-panel {
    width: calc(100vw - 24px);
    height: min(70vh, 520px);
  }
}
