@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Noto+Sans+Thai:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  font-family: "DM Sans", "Noto Sans Thai", sans-serif;
  color: #24203a;
  background: #f7f4ff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --purple: #7654e8;
  --purple-dark: #6040ce;
  --muted: #827e91;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 12% 9%, rgba(201, 185, 255, .33), transparent 31rem),
    radial-gradient(ellipse at 88% 85%, rgba(255, 215, 232, .36), transparent 30rem),
    #f7f4ff;
}

button, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(100% - 32px, 900px);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
}

.brand strong { font-weight: 700; }

.brand-mark, .avatar {
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #a68aff, #704fe3);
}

.brand-mark {
  width: 35px;
  height: 35px;
  border-radius: 12px;
  font-size: 19px;
  box-shadow: 0 5px 13px #8f70ed55;
}

.connection {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-links { display: flex; align-items: center; gap: 16px; }
.topbar-links > a { color: #7562ba; text-decoration: none; font-size: 12px; }
.topbar-links > a:hover { text-decoration: underline; }

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aaa5b7;
}

.connection.is-online .connection-dot { background: #30b980; }
.connection.is-offline .connection-dot { background: #e29a42; }

.chat-card {
  width: min(100%, 780px);
  min-height: 680px;
  margin: 28px auto 24px;
  padding: 38px 38px 25px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 26px;
  background: rgba(255,255,255,.87);
  box-shadow: 0 24px 70px rgba(58, 38, 111, .10), 0 2px 8px rgba(58, 38, 111, .04);
  display: flex;
  flex-direction: column;
}

.intro { text-align: center; }
.eyebrow { color: var(--purple); font-size: 10px; font-weight: 700; letter-spacing: .16em; }
.intro h1 { margin: 10px 0 5px; font-size: clamp(24px, 4.5vw, 32px); letter-spacing: -.04em; }
.intro p { margin: 0; color: var(--muted); font-size: 14px; }

.conversation {
  flex: 1;
  min-height: 260px;
  max-height: 580px;
  overflow: auto;
  margin: 22px 0 14px;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.message { display: flex; align-items: flex-start; gap: 10px; }
.user-message { justify-content: flex-end; }
.avatar { flex: 0 0 30px; width: 30px; height: 30px; border-radius: 11px; font-size: 15px; }
.bubble { max-width: min(84%, 490px); padding: 12px 15px; border-radius: 4px 16px 16px 16px; background: #f4f1fb; }
.bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.7; }
.user-message .bubble { color: #fff; border-radius: 16px 4px 16px 16px; background: var(--purple); }
.message-error .bubble { color: #8e3d45; background: #fff0f0; }
.speak-button { margin-top: 8px; padding: 3px 0; border: 0; color: var(--purple-dark); background: transparent; font-size: 12px; }
.speak-button:hover { text-decoration: underline; }

/* 3 Product Package Bubbles */
.product-bubbles-message { align-items: flex-start; width: 100%; }
.product-bubbles-grid {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.bubble.product-bubble {
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 13px 13px 12px;
  border: 1px solid #e7dff8;
  border-radius: 14px 16px 16px 16px;
  background: linear-gradient(160deg, #ffffff 0%, #f8f5ff 100%);
  box-shadow: 0 6px 18px rgba(88, 60, 170, 0.06);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.bubble.product-bubble:hover {
  transform: translateY(-2px);
  border-color: #c5b3f9;
  box-shadow: 0 10px 24px rgba(88, 60, 170, 0.11);
}
.bubble.product-bubble.is-recommended {
  border-color: #ec008c66;
  background: linear-gradient(160deg, #fff8fc 0%, #f6f1ff 100%);
}
.product-bubble-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.product-bubble-code {
  font-size: 10px;
  font-weight: 600;
  color: #6d6582;
}
.product-bubble-discount {
  padding: 2px 7px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(110deg, #ec008c, #7654e8);
  font-size: 10px;
  font-weight: 700;
}
.product-bubble-media {
  display: block;
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid #ede7fa;
  background: #fdfcff;
}
.product-bubble-media img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}
.product-bubble-title {
  margin: 2px 0 0;
  color: #24203a;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.4;
}
.product-bubble-desc {
  margin: 0;
  color: #6f6980;
  font-size: 11.5px;
  line-height: 1.5;
}
.product-bubble-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid #ede8f7;
}
.product-bubble-price strong {
  color: #ec008c;
  font-size: 17px;
  font-weight: 700;
}
.product-bubble-price del {
  color: #9e98ad;
  font-size: 11.5px;
}
.product-bubble-shipping {
  color: #158058;
  font-size: 10.5px;
  font-weight: 600;
}
.product-bubble-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}
.product-bubble-select,
.product-bubble-cart {
  min-height: 33px;
  padding: 0 8px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: filter .15s ease, transform .15s ease;
}
.product-bubble-select {
  border: 0;
  color: #fff;
  background: linear-gradient(110deg, #ec008c, #7654e8);
}
.product-bubble-cart {
  border: 1px solid #dfd6f7;
  color: var(--purple-dark);
  background: #fff;
}
.product-bubble-select:hover,
.product-bubble-cart:hover {
  filter: brightness(1.05);
}
.chat-basket-badge {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  color: #fff;
  background: #ec008c;
  font-size: 10px;
  font-weight: 700;
}

@media (max-width: 680px) {
  .product-bubbles-grid {
    grid-template-columns: 1fr;
  }
}

.live-spec { margin-left: auto; color: #8e879e; font-size: 11px; }

.composer { padding: 13px 15px 11px; border: 1px solid #e9e5f1; border-radius: 16px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: #b7a4f5; box-shadow: 0 0 0 3px #8a6de719; }
.composer textarea { width: 100%; min-height: 48px; max-height: 130px; resize: vertical; border: 0; outline: 0; color: #29253a; background: transparent; font-size: 14px; line-height: 1.6; }
.composer textarea::placeholder { color: #aaa6b5; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status-message { color: #928da0; font-size: 11px; }
.action-buttons { display: flex; align-items: center; gap: 8px; }
.icon-button, .send-button { height: 38px; border: 0; border-radius: 11px; transition: transform .15s, background .15s; }
.icon-button { width: 40px; color: #6b55b9; background: #f1edfc; font-size: 17px; }
.icon-button:hover { background: #e7e0fa; }
.icon-button.is-listening { color: #fff; background: #e65d72; animation: pulse 1.2s infinite; }
.send-button { display: inline-flex; align-items: center; gap: 10px; padding: 0 14px; color: #fff; background: var(--purple); font-size: 12px; font-weight: 600; }
.send-button:hover { background: var(--purple-dark); }
.send-button:disabled { cursor: wait; opacity: .65; }
.icon-button:active, .send-button:active { transform: scale(.97); }
.privacy-note { margin: 12px 3px 0; color: #a09bab; text-align: center; font-size: 10px; line-height: 1.6; }

footer { margin-top: auto; padding: 14px 0 22px; color: #9691a4; text-align: center; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
footer span { padding: 0 4px; }
footer a { color: #7562ba; text-decoration: none; }
footer a:hover { text-decoration: underline; }
.footer-powered { display: inline-flex; align-items: center; gap: 6px; color: #7b758b; font-size: 11px; }
.footer-powered .powered-brand { display: inline-flex; align-items: center; gap: 4px; color: #473a6e; font-weight: 600; }
.footer-powered svg { vertical-align: middle; }
.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 pulse { 50% { box-shadow: 0 0 0 6px #e65d7228; } }

@media (max-width: 600px) {
  .topbar { height: 68px; }
  .topbar-links { gap: 9px; }
  .chat-card { min-height: min(720px, calc(100vh - 112px)); margin: 12px auto 15px; padding: 32px 19px 19px; border-radius: 20px; }
  .conversation { min-height: 170px; margin-top: 24px; }
  .auto-speak { margin-left: auto; }
  .status-message { max-width: 55%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
