.casaic-root {
  position: fixed;
  z-index: 999999;
  bottom: 20px;
  --casaic-brand: #C52050;
  --casaic-accent: #DD6658;
  --casaic-dark: #171717;
  --casaic-soft: #f7f4f5;
  --casaic-border: rgba(23, 23, 23, 0.08);
  --casaic-launcher-bg: #C52050;
  --casaic-launcher-text: #FFFFFF;
  --casaic-header-bg: #C52050;
  --casaic-header-text: #FFFFFF;
  --casaic-icon-color: #FFFFFF;
  --casaic-icon-hover: #FFFFFF;
  --casaic-send-bg: #DD6658;
  --casaic-user-bg: #C52050;
  --casaic-user-text: #FFFFFF;
  --casaic-bot-bg: #FFFFFF;
  font-family: inherit;
}

.casaic-root.bottom-right { right: 20px; }
.casaic-root.bottom-left { left: 20px; }
.casaic-root *,
.casaic-root *::before,
.casaic-root *::after { box-sizing: border-box; }

.casaic-launcher {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 12px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--casaic-launcher-bg);
  color: var(--casaic-launcher-text);
  cursor: pointer;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.casaic-launcher:hover { transform: translateY(-1px); box-shadow: 0 18px 44px rgba(0,0,0,.26); }
.casaic-launcher-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  flex: 0 0 auto;
}
.casaic-launcher-icon svg,
.casaic-launcher-icon img,
.casaic-send svg,
.casaic-icon-btn svg { width: 20px; height: 20px; display: block; }
.casaic-launcher-text-wrap { display: flex; flex-direction: column; align-items: flex-start; text-align: left; line-height: 1.1; }
.casaic-launcher-label { font-size: 15px; font-weight: 700; }
.casaic-launcher-sub { font-size: 12px; opacity: .92; }

.casaic-panel {
  width: 380px;
  max-width: calc(100vw - 24px);
  height: min(640px, calc(100vh - 32px));
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.24);
  border: 1px solid var(--casaic-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.casaic-root.bottom-right .casaic-panel,
.casaic-root.bottom-left .casaic-panel { margin-bottom: 0; }

.casaic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 16px;
  color: var(--casaic-header-text);
  background: var(--casaic-header-bg);
}
.casaic-header-title { font-size: 17px; font-weight: 700; line-height: 1.2; }
.casaic-header-subtitle {
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  opacity: .95;
}
.casaic-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #9bffb0;
  box-shadow: 0 0 0 4px rgba(255,255,255,.16);
}
.casaic-header-actions { display: flex; align-items: center; gap: 8px; }
.casaic-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.15);
  color: var(--casaic-icon-color);
  cursor: pointer;
}
.casaic-icon-btn:hover { background: rgba(255,255,255,.22); color: var(--casaic-icon-hover); }

.casaic-messages {
  flex: 1;
  overflow: auto;
  padding: 16px;
  background: linear-gradient(180deg, #fcfbfb 0%, var(--casaic-soft) 100%);
}
.casaic-message {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 18px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.casaic-message a {
  color: var(--casaic-header-bg);
  text-decoration: underline;
}
.casaic-bot {
  background: var(--casaic-bot-bg);
  color: var(--casaic-dark);
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 10px 24px rgba(0,0,0,.04);
}
.casaic-user {
  margin-left: auto;
  color: var(--casaic-user-text);
  background: var(--casaic-user-bg);
  box-shadow: 0 14px 26px rgba(0,0,0,.13);
}

.casaic-suggestion-row {
  display: flex;
  gap: 8px;
  padding: 10px 16px 0;
  background: #fff;
  overflow-x: auto;
  scrollbar-width: none;
}
.casaic-suggestion-row::-webkit-scrollbar { display: none; }
.casaic-chip {
  border: 1px solid rgba(0,0,0,.08);
  background: #fff;
  color: #333;
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.casaic-chip:hover { border-color: rgba(0,0,0,.18); }

.casaic-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 14px 16px 16px;
  border-top: 1px solid rgba(0,0,0,.06);
  background: #fff;
}
.casaic-input,
.casaic-lead-form input,
.casaic-lead-form textarea {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #d9d9dd;
  border-radius: 16px;
  background: #fff;
  font: inherit;
  color: #222;
  resize: none;
}
.casaic-input {
  min-height: 48px;
  max-height: 120px;
  overflow-y: auto;
}
.casaic-input:focus,
.casaic-lead-form input:focus,
.casaic-lead-form textarea:focus {
  outline: none;
  border-color: var(--casaic-brand);
  box-shadow: none;
}
.casaic-send {
  min-width: 48px;
  min-height: 48px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  background: var(--casaic-send-bg);
  color: #fff;
  box-shadow: none;
}
.casaic-send-full {
  width: 100%;
  min-height: 46px;
}

.casaic-lead-wrap {
  border-top: 1px solid rgba(0,0,0,.06);
  background: #fff;
  padding: 0 16px 16px;
}
.casaic-lead-wrap summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  color: var(--casaic-brand);
  padding-top: 6px;
}
.casaic-lead-wrap summary::-webkit-details-marker { display: none; }
.casaic-lead-copy { margin: 12px 0; font-size: 13px; color: #555; }
.casaic-lead-form { display: grid; gap: 10px; }

.casaic-lead-status {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
}
.casaic-lead-status-info { background: #f5f5f7; color: #333; }
.casaic-lead-status-success { background: #ecfdf3; color: #166534; }
.casaic-lead-status-error { background: #fef2f2; color: #991b1b; }
.casaic-lead-back {
  width: 100%;
  min-height: 44px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.10);
  background: #fff;
  color: #222;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.casaic-lead-back:hover { background: #f7f7f8; }

.casaic-sources {
  margin-top: 8px;
  font-size: 12px;
  color: #666;
}

.casaic-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 10px;
}
.casaic-typing span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #c7c7cd;
  animation: casaic-bounce 1s infinite ease-in-out;
}
.casaic-typing span:nth-child(2) { animation-delay: .15s; }
.casaic-typing span:nth-child(3) { animation-delay: .30s; }

.casaic-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@keyframes casaic-bounce {
  0%, 80%, 100% { transform: scale(.8); opacity: .55; }
  40% { transform: scale(1); opacity: 1; }
}

@media (max-width: 640px) {
  .casaic-root { left: 12px !important; right: 12px !important; bottom: 12px; }
  .casaic-launcher {
    width: 100%;
    justify-content: center;
  }
  .casaic-panel {
    width: 100%;
    max-width: 100%;
    height: min(78vh, 620px);
    border-radius: 22px;
  }
  .casaic-message { max-width: 92%; }
}


/* hard toggle states */
.casaic-root .casaic-panel { display: none !important; }
.casaic-root.casaic-open .casaic-panel { display: flex !important; }
.casaic-root.casaic-open .casaic-launcher { display: none !important; }
.casaic-root:not(.casaic-open) .casaic-launcher { display: inline-flex !important; }
.casaic-root .casaic-panel[hidden] { display: none !important; }


.casaic-products {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}
.casaic-products-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #6b7280;
}
.casaic-product-card {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 12px;
  padding: 10px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 8px 20px rgba(0,0,0,.05);
}
.casaic-product-thumb {
  width: 68px;
  height: 68px;
  border-radius: 14px;
  overflow: hidden;
  background: #f4f4f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.casaic-product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.casaic-product-body {
  min-width: 0;
}
.casaic-product-title {
  font-size: 14px;
  font-weight: 700;
  color: #171717;
  margin-bottom: 4px;
}
.casaic-product-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--casaic-header-bg);
  margin-bottom: 6px;
}
.casaic-product-reason {
  font-size: 12px;
  line-height: 1.45;
  color: #4b5563;
  margin-bottom: 9px;
}
.casaic-product-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--casaic-send-bg);
  color: #fff !important;
  text-decoration: none !important;
  font-size: 12px;
  font-weight: 700;
}
.casaic-product-link:hover {
  opacity: .92;
}
@media (max-width: 480px) {
  .casaic-product-card {
    grid-template-columns: 56px 1fr;
  }
  .casaic-product-thumb {
    width: 56px;
    height: 56px;
  }
}
