/* Ascend live chat — minimal round widget */

.asc-brief {
  --c-bg: #0e0a0b;
  --c-panel: #161012;
  --c-border: rgba(255, 255, 255, 0.08);
  --c-text: #f5f0f1;
  --c-muted: #8f7d82;
  --c-red: #c92d40;
  --c-red-soft: rgba(201, 45, 64, 0.15);
  --font-display: "Batman Forever Alternate", sans-serif;
  --font-body: "Montserrat", sans-serif;
  --font-serif: "Lora", Georgia, serif;
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 9999;
  font-family: var(--font-body);
  font-size: 14px;
  pointer-events: none;
}

.asc-brief * {
  box-sizing: border-box;
}

.asc-brief > * {
  pointer-events: auto;
}

/* Backdrop */
.asc-brief-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s;
  pointer-events: none;
}

.asc-brief.is-open .asc-brief-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}

body.asc-brief-scroll-lock {
  overflow: hidden;
}

/* FAB wrapper + powered by */
.asc-brief-fab-wrap {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  transition: opacity 0.3s ease, transform 0.35s ease;
}

.asc-brief.is-open .asc-brief-fab-wrap {
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
}

/* Round FAB + animated bot SVG */
.asc-brief-fab {
  position: relative;
  right: auto;
  bottom: auto;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: var(--c-bg);
  box-shadow:
    0 0 0 1px var(--c-border),
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 24px rgba(201, 45, 64, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s;
  animation: ascFabFloat 3.5s ease-in-out infinite;
}

.asc-brief-fab:hover {
  transform: scale(1.06);
  box-shadow:
    0 0 0 1px rgba(201, 45, 64, 0.35),
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 36px rgba(201, 45, 64, 0.35);
}

.asc-brief.is-open .asc-brief-fab {
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
  animation: none;
}

.asc-brief-powered {
  font-size: 0.62rem;
  letter-spacing: 0.03em;
  color: var(--c-muted);
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.85;
  transition: color 0.2s, opacity 0.2s;
}

.asc-brief-powered:hover {
  color: var(--c-text);
  opacity: 1;
}

.asc-brief-powered--fab {
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.asc-brief-powered--panel {
  display: block;
  text-align: center;
  padding: 0.15rem 0 0.35rem;
  margin-top: 0.1rem;
}

.asc-brief-fab__pulse {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid rgba(201, 45, 64, 0.5);
  animation: ascFabPulse 2.5s ease-out infinite;
}

.asc-bot-svg {
  position: relative;
  z-index: 1;
  display: block;
}

.asc-bot-svg__glow {
  animation: ascBotGlow 2.8s ease-in-out infinite;
  transform-origin: 32px 32px;
}

.asc-bot-svg__body {
  animation: ascBotBob 3s ease-in-out infinite;
  transform-origin: 32px 35px;
}

.asc-bot-svg__antenna {
  animation: ascBotAntenna 2s ease-in-out infinite;
  transform-origin: 32px 20px;
}

.asc-bot-svg__antenna-tip {
  animation: ascBotTip 2s ease-in-out infinite;
}

.asc-bot-svg__eye {
  animation: ascBotBlink 4.5s ease-in-out infinite;
}

.asc-bot-svg__smile {
  animation: ascBotSmile 3s ease-in-out infinite;
}

@keyframes ascFabFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes ascFabPulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}

@keyframes ascBotGlow {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.03); }
}

@keyframes ascBotBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1.5px); }
}

@keyframes ascBotAntenna {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

@keyframes ascBotTip {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes ascBotBlink {
  0%, 42%, 44%, 100% { transform: scaleY(1); }
  43% { transform: scaleY(0.12); }
}

@keyframes ascBotSmile {
  0%, 100% { d: path("M26 42 Q32 46 38 42"); }
  50% { d: path("M27 42 Q32 45 37 42"); }
}

/* Panel */
.asc-brief-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9999;
  width: min(380px, calc(100vw - 2rem));
  max-height: min(560px, calc(100vh - 2rem));
  display: flex;
  flex-direction: column;
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transform-origin: 100% 100%;
  transition:
    opacity 0.35s ease,
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.35s;
  overflow: hidden;
}

.asc-brief.is-open .asc-brief-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.asc-brief-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--c-border);
}

.asc-brief-panel__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--c-text);
}

.asc-brief-panel__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
  animation: ascLivePulse 2s ease-in-out infinite;
}

@keyframes ascLivePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.asc-brief-panel__close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--c-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.asc-brief-panel__close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--c-text);
}

.asc-brief-panel__close:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(201, 45, 64, 0.45);
}

.asc-brief-panel__close svg {
  display: block;
  pointer-events: none;
}

.asc-brief-panel__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0.75rem 0 0.5rem;
}

/* Thread */
.asc-brief-thread {
  flex: 1;
  overflow-y: auto;
  min-height: 220px;
  max-height: 360px;
  padding: 0 1rem;
  scroll-behavior: smooth;
}

.asc-brief-thread::-webkit-scrollbar {
  width: 4px;
}

.asc-brief-thread::-webkit-scrollbar-thumb {
  background: var(--c-border);
  border-radius: 4px;
}

.asc-brief-msg {
  margin-bottom: 0.65rem;
  display: flex;
  animation: ascMsgIn 0.3s ease backwards;
}

@keyframes ascMsgIn {
  from { opacity: 0; transform: translateY(6px); }
}

.asc-brief-msg--bot {
  justify-content: flex-start;
}

.asc-brief-msg--user {
  justify-content: flex-end;
}

.asc-brief-msg__bubble {
  max-width: 88%;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: 16px;
}

.asc-brief-msg--bot .asc-brief-msg__bubble {
  background: rgba(255, 255, 255, 0.05);
  color: var(--c-text);
  border-bottom-left-radius: 4px;
  font-family: var(--font-serif);
}

.asc-brief-msg--user .asc-brief-msg__bubble {
  background: var(--c-red);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.asc-brief-msg__bubble p {
  margin: 0 0 0.35rem;
}

.asc-brief-msg__bubble p:last-child {
  margin-bottom: 0;
}

.asc-brief-msg__bubble a {
  color: #f9c4cc;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.asc-chat-hint {
  font-size: 0.78rem !important;
  color: var(--c-muted) !important;
}

.asc-brief-slot-intro {
  margin-top: 0.5rem !important;
  font-size: 0.72rem !important;
  color: var(--c-muted) !important;
}

.asc-brief-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.asc-brief-slot {
  padding: 0.4rem 0.5rem;
  font-size: 0.72rem;
  text-align: left;
  background: var(--c-red-soft);
  border: 1px solid rgba(201, 45, 64, 0.25);
  border-radius: 10px;
  color: var(--c-text);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.asc-brief-slot:hover {
  border-color: var(--c-red);
  background: rgba(201, 45, 64, 0.22);
}

/* Typing */
.asc-brief-typing {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem 0.35rem;
  font-size: 0.72rem;
  color: var(--c-muted);
}

.asc-brief-typing[hidden] {
  display: none !important;
}

.asc-brief-typing__dots {
  display: flex;
  gap: 3px;
}

.asc-brief-typing__dots i {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c-red);
  animation: ascDot 1.2s ease-in-out infinite;
}

.asc-brief-typing__dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.asc-brief-typing__dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ascDot {
  0%, 80%, 100% { opacity: 0.35; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* Chips */
.asc-brief-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 1rem 0.5rem;
}

.asc-brief-chips[hidden] {
  display: none !important;
}

.asc-brief-chip {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  color: var(--c-text);
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.asc-brief-chip:hover {
  border-color: var(--c-red);
  background: var(--c-red-soft);
}

/* Input */
.asc-brief-inputbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0.75rem;
  padding: 0.35rem 0.35rem 0.35rem 0.85rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--c-border);
  border-radius: 999px;
}

#chat-input {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0;
  border: none;
  background: transparent;
  color: var(--c-text);
  font-size: 0.875rem;
  font-family: inherit;
}

#chat-input:focus {
  outline: none;
}

#chat-input:disabled {
  opacity: 0.45;
}

.asc-brief-send {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--c-red);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.15s;
}

.asc-brief-send:hover:not(:disabled) {
  transform: scale(1.05);
}

.asc-brief-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.asc-brief-link {
  display: block;
  width: 100%;
  margin: 0.15rem 0 0;
  padding: 0.4rem;
  border: none;
  background: none;
  font-size: 0.72rem;
  color: var(--c-red);
  cursor: pointer;
  text-align: center;
}

.asc-brief-link--muted {
  color: var(--c-muted);
}

.asc-brief-link:hover {
  color: var(--c-text);
}

#book-from-chat[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Feedback */
.close-container {
  margin: 0.5rem 1rem 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--c-border);
  border-radius: 12px;
}

.close-container h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-family: var(--font-serif);
  color: var(--c-text);
}

.close-container .stars {
  text-align: center;
  margin: 0.5rem 0;
  font-size: 1.25rem;
}

.close-container .star {
  cursor: pointer;
  color: rgba(255, 255, 255, 0.2);
}

.close-container textarea {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  color: var(--c-text);
  font-family: inherit;
  font-size: 0.8rem;
}

.close-container #feedback-submit {
  width: 100%;
  padding: 0.55rem;
  border: none;
  border-radius: 999px;
  background: var(--c-red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.asc-brief-thanks {
  text-align: center;
  color: var(--c-muted);
  font-size: 0.85rem;
}

.chat-button {
  display: inline-block;
  margin: 0.25rem 0.25rem 0 0;
  padding: 0.3rem 0.5rem;
  font-size: 0.72rem;
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  color: var(--c-muted);
  cursor: pointer;
}

@media (max-width: 640px) {
  .asc-brief-fab-wrap {
    right: 1rem;
    bottom: 1rem;
  }

  .asc-brief-fab {
    width: 3.25rem;
    height: 3.25rem;
  }

  .asc-bot-svg {
    width: 48px;
    height: 48px;
  }

  .asc-brief-panel {
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: none;
    transform: translateY(100%);
    transform-origin: 50% 100%;
  }

  .asc-brief.is-open .asc-brief-panel {
    transform: translateY(0);
  }

  .asc-brief-panel__head {
    padding-top: max(0.85rem, env(safe-area-inset-top));
  }

  .asc-brief-thread {
    max-height: none;
    flex: 1;
  }

  .asc-brief-inputbar {
    margin-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }

  .asc-brief-slots {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .asc-brief-fab,
  .asc-brief-fab__pulse,
  .asc-bot-svg__glow,
  .asc-bot-svg__body,
  .asc-bot-svg__antenna,
  .asc-bot-svg__antenna-tip,
  .asc-bot-svg__eye,
  .asc-bot-svg__smile,
  .asc-brief-panel__dot {
    animation: none;
  }

  .asc-brief-panel,
  .asc-brief-msg {
    transition: none;
    animation: none;
  }
}
