
:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #122033;
  --muted: #637489;
  --line: #dfe7f1;
  --brand: #2643ff;
  --brand-soft: #edf1ff;
  --assistant: #eef5ff;
  --user: #2643ff;
  --user-text: #ffffff;
  --shadow: 0 14px 30px rgba(18, 32, 51, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f7f9fc 0%, #eef3f9 100%);
}

a { color: inherit; }

.page-shell {
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  gap: 16px;
  padding: 14px;
}

.ad-column {
  display: none;
  flex: 0 0 19%;
  min-width: 180px;
}

.ad-placeholder {
  min-height: 280px;
  border: 1px dashed #c8d4e3;
  border-radius: 18px;
  background: rgba(255,255,255,0.7);
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.chat-shell {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.chat-window {
  width: 100%;
  max-width: 640px;
  min-height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
  border-radius: 28px;
  background: rgba(255,255,255,0.9);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.chat-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.94);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1d34c7, #4460ff);
  color: #fff;
  font-weight: 800;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand-text strong { font-size: 16px; }
.brand-text span { color: var(--muted); font-size: 12px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-toggle, .menu-toggle, .send-button, .mic-button, .product-link, .share-chip {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
}

.voice-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.voice-toggle.is-on {
  background: #1635ff;
  color: #fff;
}
.voice-toggle-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: currentColor;
}

.menu-toggle {
  width: 42px;
  height: 42px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 20px;
}

.page-menu {
  position: absolute;
  right: 16px;
  top: 72px;
  width: min(280px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}
.page-menu a {
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f6f8fc;
}
.menu-share {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.menu-share button {
  border: 0;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  padding: 8px 12px;
  cursor: pointer;
}

.chat-thread {
  flex: 1 1 auto;
  overflow: auto;
  padding: 18px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.message {
  max-width: 92%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.message.assistant { align-self: flex-start; }
.message.user { align-self: flex-end; }

.bubble {
  border-radius: 22px;
  padding: 14px 16px;
  line-height: 1.5;
  box-shadow: 0 8px 18px rgba(18, 32, 51, 0.06);
}
.message.assistant .bubble {
  background: var(--assistant);
}
.message.user .bubble {
  background: var(--user);
  color: var(--user-text);
}

.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 10px 22px; padding: 0; }
.bubble a { color: #1335d3; font-weight: 600; }

.message-meta {
  font-size: 12px;
  color: var(--muted);
  padding: 0 6px;
}

.typing-bubble::after {
  content: "…";
  letter-spacing: 3px;
  animation: blink 1s infinite;
}
@keyframes blink { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }

.product-stack {
  display: grid;
  gap: 14px;
}

.product-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: #fff;
}

.product-carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  background: #f2f5fa;
}
.product-carousel img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #fff;
  scroll-snap-align: start;
  flex: 0 0 100%;
}

.product-share-row {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -22px 12px 0;
}
.share-chip {
  padding: 8px 12px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--line);
  font-size: 13px;
  box-shadow: 0 8px 18px rgba(18, 32, 51, 0.08);
}

.product-content {
  padding: 14px;
}
.product-title {
  margin: 0 0 8px;
  font-size: 17px;
}
.product-title a {
  text-decoration: none;
}
.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}
.price-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 12px;
}
.price-current {
  color: #1038f7;
  font-size: 22px;
  font-weight: 800;
}
.price-old {
  text-decoration: line-through;
  color: var(--muted);
}
.product-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.product-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background: #1038f7;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.chat-input-area {
  border-top: 1px solid var(--line);
  padding: 12px;
  background: rgba(255,255,255,0.98);
}
.chat-input-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: end;
}
.mic-button, .send-button {
  height: 48px;
  min-width: 48px;
  padding: 0 16px;
  font-weight: 700;
}
.mic-button {
  background: var(--brand-soft);
  color: var(--brand);
}
.mic-button.is-recording {
  background: #ffe9ec;
  color: #cf2846;
}
#chatInput {
  min-height: 48px;
  max-height: 92px;
  resize: none;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  font: inherit;
  outline: none;
}
.send-button {
  background: #1038f7;
  color: #fff;
}
.chat-status {
  min-height: 20px;
  padding: 8px 4px 0;
  color: var(--muted);
  font-size: 13px;
}
.chat-footer {
  padding: 0 16px 14px;
  color: var(--muted);
  font-size: 12px;
}

.ad-bottom {
  display: block;
  padding: 0 14px 14px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (min-width: 450px) {
  .page-shell { gap: 14px; }
  .chat-shell { flex: 0 1 62%; justify-content: flex-start; min-width: 350px; }
  .ad-right { display: block; flex-basis: 38%; }
}

@media (min-width: 791px) {
  .page-shell { justify-content: center; }
  .ad-left, .ad-right { display: block; flex-basis: 19%; }
  .chat-shell { flex: 0 1 62%; justify-content: center; }
  .ad-bottom { display: none; }
}

@media (max-width: 790px) {
  .ad-left { display: none !important; }
}

@media (max-width: 449px) {
  .page-shell {
    display: block;
    padding: 0;
  }
  .chat-window {
    min-height: auto;
    border-radius: 0;
  }
  .ad-right { display: none !important; }
  .ad-bottom { display: block; }
}

.hidden { display: none !important; }
