:root {
  --asc-chat-scale: 1.2;
  --asc-chat-font-scale: 1.2;
}

.asc-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: calc(64px * var(--asc-chat-scale));
  height: calc(64px * var(--asc-chat-scale));
  border-radius: 50%;
  background: linear-gradient(135deg, #111827, #1f2937);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.15s ease;
  z-index: 1100;
}

.asc-chat-launcher:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.28);
  background: linear-gradient(135deg, #0b1220, #111827);
}

.asc-chat-launcher.is-hidden {
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
}

.asc-chat-launcher img {
  width: calc(30px * var(--asc-chat-scale));
  height: calc(30px * var(--asc-chat-scale));
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(255, 255, 255, 0.08));
}

.asc-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: min(94vw, calc(480px * var(--asc-chat-scale)));
  height: min(94vh, calc(720px * var(--asc-chat-scale)));
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 18px;
  box-shadow:
    0 18px 46px rgba(15, 23, 42, 0.14),
    0 4px 12px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 1100;
}

.asc-chat-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.asc-chat-header {
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.asc-chat-title {
  font-size: calc(1.3rem * var(--asc-chat-font-scale));
  font-weight: 700;
  margin: 0;
  color: #0f172a;
}

.asc-chat-subtitle {
  margin: 0;
  color: #6b7280;
  font-size: calc(1.15rem * var(--asc-chat-font-scale));
  line-height: 1.3;
}

.asc-chat-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.asc-chat-icon-btn {
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #f8fafc;
  color: #475569;
  width: calc(34px * var(--asc-chat-scale));
  height: calc(34px * var(--asc-chat-scale));
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  padding: 0;
  line-height: 1;
  font-size: calc(1.3rem * var(--asc-chat-font-scale));
}

.asc-chat-icon-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.2);
}

.asc-chat-icon-btn:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

.asc-chat-stream {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  flex: 1;
  background: #f7f7fb;
}

.asc-chat-turn {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  justify-content: flex-start;
}

.asc-chat-turn.is-user {
  justify-content: flex-end;
}

.asc-chat-avatar {
  display: none;
}

.asc-chat-avatar img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.asc-chat-bubble {
  background: #ffffff;
  border-radius: 14px;
  padding: 0.85rem 1rem;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
  font-size: calc(1.25rem * var(--asc-chat-font-scale));
  line-height: 1.45;
  border: 1px solid #e4e7ec;
  max-width: 85%;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}

.asc-chat-turn.is-user .asc-chat-bubble {
  background: #3773b8;
  color: #ffffff;
  border: none;
  box-shadow: none;
}

.asc-chat-role {
  display: none;
}

.asc-chat-placeholder {
  text-align: center;
  color: #94a3b8;
  padding: 1.5rem 0.5rem;
  font-size: calc(1.2rem * var(--asc-chat-font-scale));
}

.asc-chat-cta {
  color: #0f172a;
  font-size: calc(1.35rem * var(--asc-chat-font-scale));
  font-weight: 600;
  text-align: center;
  margin-top: 1rem;
}

.asc-chat-cta small {
  display: block;
  color: #94a3b8;
  font-weight: 500;
  margin-top: 0.35rem;
}

.asc-chat-loader {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #475569;
  font-size: calc(1.2rem * var(--asc-chat-font-scale));
}

.asc-chat-footer {
  padding: 0.75rem 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  background: #ffffff;
}

.asc-chat-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.asc-chat-input {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #ffffff;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  padding: 0.55rem 0.8rem 0.55rem 1rem;
  box-shadow:
    0 6px 18px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.asc-chat-input textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  min-height: 36px;
  max-height: 120px;
  font-size: calc(1.28rem * var(--asc-chat-font-scale));
  padding: 0.15rem 0;
  outline: none;
  color: #0f172a;
}

.asc-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.6rem 0.8rem;
  background: #f3f4f6;
  border-radius: 999px;
}

.asc-chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  display: inline-block;
  animation: asc-chat-bounce 1.4s infinite;
}

.asc-chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.asc-chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes asc-chat-bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.6; }
  40% { transform: scale(1); opacity: 1; }
}

.asc-chat-send {
  border: none;
  width: calc(40px * var(--asc-chat-scale));
  height: calc(40px * var(--asc-chat-scale));
  border-radius: 50%;
  background: #3773b8;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-size: calc(1.3rem * var(--asc-chat-font-scale));
}

.asc-chat-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.25);
}

.asc-chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.asc-chat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.asc-chat-status {
  font-size: calc(1.15rem * var(--asc-chat-font-scale));
  color: #475569;
}

.asc-chat-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: calc(1.1rem * var(--asc-chat-font-scale));
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-weight: 600;
}

.asc-chat-footnote {
  font-size: calc(1.08rem * var(--asc-chat-font-scale));
  color: #94a3b8;
  text-align: center;
  width: 100%;
}

.asc-chat-debug summary {
  cursor: pointer;
  color: #64748b;
  font-size: calc(1.15rem * var(--asc-chat-font-scale));
}

.asc-chat-debug pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem;
  font-size: calc(1.1rem * var(--asc-chat-font-scale));
  overflow: auto;
  max-height: 220px;
  margin-top: 0.4rem;
}

@media (max-width: 640px) {
  .asc-chat-panel {
    right: 12px;
    left: 12px;
    width: auto;
    height: min(82vh, calc(640px * var(--asc-chat-scale)));
  }
  .asc-chat-launcher {
    right: 16px;
    bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .asc-chat-panel,
  .asc-chat-launcher,
  .asc-chat-send {
    transition: none;
  }
}
