.chat-assistant {
  position: fixed;
  z-index: 94;
  right: 24px;
  bottom: 28px;
  color: var(--text);
}

.chat-assistant[hidden] { display: none; }

.chat-assistant-launcher {
  display: grid;
  place-items: center;
  position: relative;
  width: 68px;
  height: 68px;
  padding: 0;
  color: #fff;
  background: linear-gradient(145deg, #168fff, #6744ea 82%);
  border: 1px solid rgba(159, 213, 255, .55);
  border-radius: 24px;
  box-shadow: 0 17px 38px rgba(15, 92, 217, .34), inset 0 1px rgba(255, 255, 255, .25);
  cursor: pointer;
  animation: chat-flight 4.2s ease-in-out infinite;
  transition: transform .22s ease, border-radius .22s ease;
}
.chat-assistant-launcher:hover { transform: translateY(-4px) scale(1.04); border-radius: 50%; }
.chat-assistant.is-open .chat-assistant-launcher { animation-play-state: paused; }

.chat-launcher-ring {
  position: absolute;
  inset: -7px;
  border: 1px solid rgba(79, 171, 255, .28);
  border-radius: 27px;
  animation: chat-ring 2.8s ease-out infinite;
}
.chat-launcher-icon { display: grid; place-items: center; position: relative; }
.chat-launcher-icon img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 50%;
  filter: drop-shadow(0 3px 9px rgba(0,0,0,.28));
}
.chat-launcher-icon i {
  position: absolute;
  top: -9px;
  right: -9px;
  color: #d8f2ff;
  font-size: 12px;
  font-style: normal;
  text-shadow: 0 0 10px #fff;
}

.chat-assistant-callout {
  position: absolute;
  right: 81px;
  bottom: 13px;
  width: max-content;
  padding: 10px 14px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 14px 14px 3px 14px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .22);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  animation: chat-callout 8s ease both;
}
.chat-assistant.is-open .chat-assistant-callout { display: none; }

.chat-assistant-panel {
  display: flex;
  flex-direction: column;
  position: absolute;
  right: 0;
  bottom: 88px;
  width: min(378px, calc(100vw - 30px));
  height: min(610px, calc(100dvh - 140px));
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  background: color-mix(in srgb, var(--surface) 93%, transparent);
  border: 1px solid rgba(96, 169, 246, .22);
  border-radius: 25px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .45);
  backdrop-filter: blur(22px);
  transform: translateY(18px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .24s ease, transform .28s cubic-bezier(.2,.8,.2,1), visibility .24s;
}
.chat-assistant.is-open .chat-assistant-panel { visibility: visible; opacity: 1; transform: none; }

.chat-assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  padding: 18px 19px 14px;
  background: linear-gradient(120deg, rgba(24, 136, 255, .11), rgba(111, 67, 234, .09));
  border-bottom: 1px solid var(--line);
}
.chat-assistant-identity { display: flex; align-items: center; gap: 11px; }
.chat-assistant-mini-icon {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  color: #90d1ff;
  background: rgba(30, 134, 255, .12);
  border: 1px solid rgba(70, 164, 255, .2);
  border-radius: 13px;
}
.chat-assistant-mini-icon img {
  width: 31px;
  height: 31px;
  object-fit: contain;
  border-radius: 50%;
  filter: drop-shadow(0 2px 7px rgba(0,0,0,.24));
}
.chat-assistant-identity strong { display: block; font: 650 14px/1.1 var(--font-display); letter-spacing: .01em; }
.chat-assistant-identity small { display: flex; align-items: center; gap: 6px; margin-top: 5px; color: var(--text-soft); font-size: 10px; }
.chat-assistant-identity small i { width: 6px; height: 6px; background: var(--success); border-radius: 50%; box-shadow: 0 0 8px var(--success); }
.chat-assistant-close {
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--text-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.chat-assistant-close:hover { color: var(--text); background: rgba(255,255,255,.06); }

.chat-assistant-progress { flex: 0 0 2px; background: rgba(91, 152, 217, .1); }
.chat-assistant-progress i { display: block; width: 25%; height: 100%; background: linear-gradient(90deg, #2396ff, #8c68ff); box-shadow: 0 0 9px rgba(54, 147, 255, .6); transition: width .25s ease; }

.chat-assistant-body {
  flex: 1 1 auto;
  padding: 20px 18px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(93, 157, 224, .25) transparent;
}
.chat-message { display: flex; gap: 10px; margin-bottom: 17px; animation: chat-in .22s ease both; }
.chat-message-mark {
  display: grid;
  place-items: center;
  flex: 0 0 27px;
  height: 27px;
  color: #a5daff;
  background: rgba(35, 141, 255, .12);
  border-radius: 9px;
  font-size: 11px;
}
.chat-message-copy {
  padding: 12px 14px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 5px 15px 15px;
  font-size: 13px;
  line-height: 1.55;
}
.chat-message-copy strong { display: block; margin-bottom: 4px; color: #8bcaff; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.chat-user-summary { justify-content: flex-end; }
.chat-user-summary .chat-message-copy { color: #eaf6ff; background: linear-gradient(135deg, #126ec0, #5540bd); border: 0; border-radius: 15px 5px 15px 15px; }

.chat-options { display: grid; gap: 9px; margin: 5px 0 18px 37px; animation: chat-in .25s .06s ease both; }
.chat-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 13px;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 13px;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.chat-option span { font-size: 12px; font-weight: 560; }
.chat-option b { color: #72bdff; font-size: 15px; }
.chat-option:hover { background: rgba(35, 137, 255, .08); border-color: rgba(77, 169, 255, .32); transform: translateX(3px); }
.chat-option-primary { background: linear-gradient(135deg, rgba(22, 126, 225, .22), rgba(91, 59, 198, .22)); border-color: rgba(82, 169, 255, .28); }

.chat-message-preview {
  margin: 0 0 16px 37px;
  padding: 14px;
  color: var(--text-soft);
  background: rgba(29, 87, 145, .1);
  border: 1px dashed rgba(91, 166, 241, .25);
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.6;
}
.chat-message-preview strong { display: block; margin-bottom: 7px; color: var(--text); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }

.chat-assistant-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  padding: 11px 18px;
  color: var(--text-faint);
  border-top: 1px solid var(--line);
  font-size: 9px;
  letter-spacing: .04em;
}
.chat-assistant-footer button { padding: 0; color: var(--text-soft); background: transparent; border: 0; font-size: 10px; cursor: pointer; }
.chat-assistant-footer button:hover { color: var(--text); }

@keyframes chat-flight {
  0%, 100% { transform: translate3d(0,0,0) rotate(-1deg); }
  35% { transform: translate3d(-4px,-8px,0) rotate(2deg); }
  68% { transform: translate3d(3px,-3px,0) rotate(-2deg); }
}
@keyframes chat-ring {
  0%, 30% { opacity: .65; transform: scale(.92); }
  75%, 100% { opacity: 0; transform: scale(1.16); }
}
@keyframes chat-callout {
  0%, 10% { opacity: 0; transform: translateX(8px); }
  16%, 78% { opacity: 1; transform: none; }
  88%, 100% { opacity: 0; transform: translateX(5px); }
}
@keyframes chat-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 720px) {
  .chat-assistant { right: 12px; bottom: calc(92px + env(safe-area-inset-bottom)); }
  .chat-assistant-launcher { width: 58px; height: 58px; border-radius: 20px; }
  .chat-launcher-icon img { width: 42px; height: 42px; }
  .chat-assistant-callout { right: 68px; bottom: 9px; font-size: 11px; }
  .chat-assistant-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(162px + env(safe-area-inset-bottom));
    width: auto;
    height: min(590px, calc(100dvh - 176px - env(safe-area-inset-bottom)));
    border-radius: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-assistant-launcher,
  .chat-launcher-ring,
  .chat-assistant-callout { animation: none; }
}
