/* ─── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --espresso:        #222222;
  --roast:           #1a1a1a;
  --crema:           #f0f0f0;
  --warm-white:      #222222;
  --copper:          #888888;
  --copper-hover:    #aaaaaa;
  --copper-light:    #2e2e2e;
  --bubble-ai-bg:    #2a2a2a;
  --bubble-ai-text:  #f0f0f0;
  --bubble-user-bg:  #333333;
  --bubble-user-text:#f0f0f0;
  --text-primary:    #f0f0f0;
  --text-secondary:  #aaaaaa;
  --text-muted:      #666666;
  --border:          #3a3a3a;
  --shadow-sm:       0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  --shadow-md:       0 4px 10px rgba(0,0,0,.45), 0 2px 4px rgba(0,0,0,.25);
  --shadow-lg:       0 12px 28px rgba(0,0,0,.55), 0 4px 8px rgba(0,0,0,.35);
  --radius:          14px;
  --radius-sm:       8px;
  --radius-xs:       6px;
  --max-w:           880px;
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: var(--espresso);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: dodgerblue; }
a:hover { color: #1a8fff; }

/* ─── Main layout ────────────────────────────────────────────────────────────── */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 10px 24px 72px;
}

/* ─── Chat section ───────────────────────────────────────────────────────────── */
.chat-section { margin-bottom: 44px; }

.chat-container {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.chat-window {
  height: 600px;
  overflow-y: auto;
  padding: 24px 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* custom scrollbar */
.chat-window::-webkit-scrollbar { width: 5px; }
.chat-window::-webkit-scrollbar-track { background: transparent; }
.chat-window::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

/* ─── Messages ───────────────────────────────────────────────────────────────── */
.message {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  animation: msgIn .18s ease both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.message.ai   { align-self: flex-start; }
.message.user { align-self: flex-end;   }

.message-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.message.user .message-label { text-align: right; }

.message-bubble {
  padding: 15px 19px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1.72;
}

.message.ai .message-bubble {
  background: var(--bubble-ai-bg);
  color: var(--bubble-ai-text);
  border-bottom-left-radius: 3px;
}

.message.user .message-bubble {
  background: var(--bubble-user-bg);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 3px;
}

/* markdown content inside bubbles */
.message-bubble p { margin-bottom: 7px; }
.message-bubble p:last-child { margin-bottom: 0; }

.message-bubble ul,
.message-bubble ol {
  margin: 7px 0;
  padding-left: 18px;
}

.message-bubble li { margin-bottom: 3px; }

.message-bubble strong { font-weight: 700; }
.message-bubble em     { font-style: italic; }

/* ─── Typing indicator ───────────────────────────────────────────────────────── */
.typing-indicator {
  align-self: flex-start;
  background: var(--bubble-ai-bg);
  border-radius: var(--radius-sm);
  border-bottom-left-radius: 3px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 5px;
  animation: msgIn .18s ease both;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.3s ease infinite;
}
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: .4; }
  30%           { transform: translateY(-7px); opacity: 1;  }
}

/* ─── Input area ─────────────────────────────────────────────────────────────── */
.input-area {
  border-top: 1px solid var(--border);
  background: var(--warm-white);
  padding: 12px 14px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

#user-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  font-size: 18px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--roast);
  resize: none;
  line-height: 1.5;
  min-height: 40px;
  max-height: 120px;
  outline: none;
  transition: border-color .15s;
}

#user-input:focus        { border-color: var(--copper); }
#user-input::placeholder { color: var(--text-muted); }
#user-input:disabled     { opacity: .5; cursor: not-allowed; }

#send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--copper);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, transform .1s;
}

#send-btn:hover   { background: var(--copper-hover); }
#send-btn:active  { transform: scale(.93); }
#send-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

/* ─── Suggestion pills ───────────────────────────────────────────────────────── */
.suggestion-pills {
  padding: 10px 14px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: var(--warm-white);
}

.pill {
  background: var(--roast);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  white-space: nowrap;
}

.pill:hover {
  border-color: var(--copper);
  background: var(--copper-light);
  color: var(--crema);
}

/* ─── Affiliate section ──────────────────────────────────────────────────────── */

.affiliate-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-heading {
  font-size: 19px;
  font-weight: 800;
  color: var(--crema);
  letter-spacing: -0.3px;
  margin-left: 10px;
}

.affiliate-disclosure {
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
  margin-right: 10px;
}

/* product grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.product-card {
  position: relative;
  display: block;
  min-width: 0;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  text-decoration: none;
  background: #2a2a2a;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s, transform .18s;
}

.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.product-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 14px;
  display: block;
}

.product-img-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  opacity: .35;
}

.product-name {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 10px 24px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  background: linear-gradient(to bottom, rgba(0,0,0,.72) 0%, transparent 100%);
}

.product-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 10px 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  background: linear-gradient(to top, rgba(0,0,0,.75) 0%, transparent 100%);
}

.product-badge {
  font-size: 11px;
  font-weight: 700;
  color: #1a1200;
  background: #f5c400;
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}

.product-price {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
}

/* ─── SEO content ────────────────────────────────────────────────────────────── */
.seo-content {
  margin-bottom: 52px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.seo-content article h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--crema);
  margin-bottom: 12px;
  line-height: 1.25;
  letter-spacing: -0.3px;
}

.seo-content article p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.78;
  margin-bottom: 12px;
}

.seo-content article p:last-child { margin-bottom: 0; }

/* ─── FAQ ────────────────────────────────────────────────────────────────────── */
.faq-section { margin-bottom: 52px; }

.faq-section > h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--crema);
  letter-spacing: -0.4px;
  margin-bottom: 20px;
}

details {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: box-shadow .15s;
}

details[open] { box-shadow: var(--shadow-sm); }

summary {
  padding: 15px 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

summary::-webkit-details-marker { display: none; }

summary::after {
  content: '+';
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  color: var(--copper);
  flex-shrink: 0;
  transition: transform .2s ease;
}

details[open] summary::after { transform: rotate(45deg); }

details p {
  padding: 0 20px 16px;
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.72;
}

/* ─── Static pages (about, privacy) ─────────────────────────────────────────── */
.static-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 0 72px;
}

.static-page h1 {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 800;
  color: var(--crema);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.static-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 40px;
}

.static-page section {
  margin-bottom: 36px;
}

.static-page h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--crema);
  margin-bottom: 10px;
  letter-spacing: -0.2px;
}

.static-page p {
  font-size: 15.5px;
  color: var(--text-secondary);
  line-height: 1.78;
  margin-bottom: 12px;
}

.static-page p:last-child { margin-bottom: 0; }

.static-page a {
  color: dodgerblue;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.static-page a:hover { color: #1a8fff; }

.back-link {
  display: inline-block;
  font-size: 14px;
  color: dodgerblue;
  text-decoration: none;
  margin-bottom: 32px;
  transition: color .15s;
}

.back-link:hover { color: #1a8fff; }

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
footer {
  background: var(--roast);
  border-top: 2px solid var(--copper);
  padding: 36px 24px;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.footer-links {
  display: flex;
  gap: 28px;
}

.footer-links a {
  color: dodgerblue;
  text-decoration: none;
  font-size: 14px;
  opacity: .8;
  transition: opacity .15s;
}

.footer-links a:hover { opacity: 1; }

.footer-disclosure {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 520px;
  line-height: 1.55;
}

.footer-copy {
  font-size: 12px;
  color: var(--text-muted);
  opacity: .5;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  main { padding: 28px 16px 56px; }

  .chat-window { height: 500px; }

  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .message { max-width: 88%; }

  .affiliate-header { flex-direction: column; gap: 4px; }
}

@media (max-width: 420px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  .product-info  { padding: 8px 10px 4px; }
  .product-cta   { margin: 4px 10px 10px; }
}
