:root {
  --bg: #F5F1EA;
  --ink: #1C1A17;
  --ink-soft: #6B655C;
  --coral: #F2846B;
  --coral-soft: #F6BFAE;
  --teal: #49C6C0;
  --blue: #A9E1E8;
  --yellow: #E9C468;
  --olive: #ABBE6E;
  --pink: #F3B7C6;
  --white: #FFFFFF;
  --line: #E7E1D6;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(28,26,23,0.04), 0 8px 24px rgba(28,26,23,0.06);
  --font-display: 'Fredoka', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; cursor: pointer; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px;
  max-width: 1180px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.logo-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

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

.get-app-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--white);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: none;
}

/* ---------- Landing hero ---------- */
.hero-wrap {
  max-width: 900px;
  margin: 60px auto 0;
  padding: 0 24px;
  text-align: center;
}

.hero-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 44px;
  margin-bottom: 36px;
}

.hero-logo .logo-mark { width: 44px; height: 44px; }

.hero-box {
  background: var(--coral-soft);
  border-radius: var(--radius-lg);
  padding: 48px 40px 40px;
}

.hero-box h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 34px;
  line-height: 1.25;
  margin: 0 0 26px;
  color: var(--ink);
}

.search-form {
  display: flex;
  gap: 10px;
  background: var(--white);
  border-radius: var(--radius-pill);
  padding: 6px 6px 6px 22px;
  box-shadow: var(--shadow);
}

.search-form input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 17px;
  font-family: var(--font-body);
  color: var(--ink);
  padding: 14px 0;
}

.search-form input::placeholder { color: #A69E90; }

.search-submit {
  border: none;
  background: var(--ink);
  color: var(--white);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
}

.pill-row-label {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: -16px;
}

.pill {
  border: none;
  padding: 14px 22px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap;
}

.pill:nth-child(8n+1) { background: var(--blue); }
.pill:nth-child(8n+2) { background: var(--coral); color: var(--white); }
.pill:nth-child(8n+3) { background: var(--pink); }
.pill:nth-child(8n+4) { background: var(--yellow); }
.pill:nth-child(8n+5) { background: var(--olive); }
.pill:nth-child(8n+6) { background: var(--teal); color: var(--white); }
.pill:nth-child(8n+7) { background: var(--coral-soft); }
.pill:nth-child(8n+0) { background: var(--blue); }

.footer-links {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  margin: 70px 0 30px;
}

.footer-links span { margin: 0 10px; }

/* ---------- Results view ---------- */
.results-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 24px 140px;
  display: none;
}

body.mode-results .hero-wrap { display: none; }
body.mode-results .results-wrap { display: block; }

.results-query-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 30px;
}

.results-query-bar .search-form { flex: 1; }

.new-search-btn {
  border: 1px solid var(--line);
  background: var(--white);
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 28px 30px;
  box-shadow: var(--shadow);
  font-size: 17px;
  line-height: 1.7;
  color: #33302B;
}

.summary-card q, .summary-card .quote { font-style: italic; }

.summary-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skel-line { height: 14px; border-radius: 7px; background: linear-gradient(90deg, #EFEAE0 25%, #F7F3EC 37%, #EFEAE0 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.skel-line.w-full { width: 100%; }
.skel-line.w-90 { width: 90%; }
.skel-line.w-70 { width: 70%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.sources-row {
  display: flex;
  gap: 14px;
  margin: 26px 4px;
  flex-wrap: wrap;
}

.source-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 8px 14px 8px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.source-chip .dot {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--teal);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 11px; font-weight: 700;
}

.cards-row {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding: 6px 4px 20px;
  scroll-snap-type: x proximity;
}

.pick-card {
  scroll-snap-align: start;
  flex: 0 0 260px;
  background: var(--white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.pick-card-label {
  position: absolute;
  margin: 14px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
}

.pick-card-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #F0ECE3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pick-card-media img { width: 100%; height: 100%; object-fit: cover; }

.pick-card-body {
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.pick-card-title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
  min-height: 40px;
}

.pick-card-reason {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.pick-card-price {
  font-weight: 700;
  font-size: 16px;
  margin-top: 4px;
}

.pick-card-cta {
  margin-top: 10px;
  border: none;
  background: var(--ink);
  color: var(--white);
  padding: 11px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 13px;
  text-align: center;
}

.offers-panel {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.offer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  font-size: 13px;
}

.offer-row .merchant { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.offer-row .merchant img { width: 16px; height: 16px; border-radius: 3px; }
.offer-row .price { font-weight: 700; }
.offer-row .go {
  background: var(--teal);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
}

.offers-loading { font-size: 13px; color: var(--ink-soft); padding: 8px 0; }

.error-box {
  background: #FBE4DF;
  color: #A6412C;
  border-radius: var(--radius-md);
  padding: 20px;
  font-size: 14px;
  font-weight: 500;
}

.followup-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(180deg, rgba(245,241,234,0) 0%, var(--bg) 40%);
  padding: 30px 24px 26px;
}

.followup-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  background: var(--white);
  border-radius: var(--radius-pill);
  padding: 6px 6px 6px 20px;
  box-shadow: var(--shadow);
}

.followup-inner input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; font-family: var(--font-body); padding: 12px 0;
}

.followup-inner button {
  border: none; background: var(--ink); color: white;
  width: 40px; height: 40px; border-radius: 50%;
}

@media (max-width: 640px) {
  .topbar { padding: 16px; }
  .hero-wrap { margin-top: 30px; }
  .hero-box { padding: 32px 20px 28px; }
  .hero-box h1 { font-size: 26px; }
  .pick-card { flex-basis: 220px; }
}

/* Kuponly integration */
.kuponly-logo-img{height:42px;width:auto;max-width:150px;object-fit:contain}.kuponly-ai-logo span{display:inline-flex;background:#f05a28;color:#fff;border-radius:999px;padding:5px 9px;font-size:13px}.hero-kuponly-logo{height:62px;width:auto;max-width:210px;object-fit:contain}.hero-logo span{font-size:28px}.get-app-btn{text-decoration:none}.search-submit,.pick-card-cta,.offer-row .go{background:#f05a28!important}.hero-box{background:#dbeff0}.quote{background:rgba(240,90,40,.14)!important}.pill:nth-child(8n+2){background:#f05a28}.pill:nth-child(8n+6){background:#334155}@media(max-width:640px){.topbar{padding:14px 16px}.kuponly-logo-img{height:36px}.hero-wrap{margin-top:28px}.hero-kuponly-logo{height:48px}.hero-logo{gap:8px;margin-bottom:24px}.hero-logo span{font-size:21px}.hero-box{padding:32px 18px 24px}.hero-box h1{font-size:27px}.results-wrap{padding-left:14px;padding-right:14px}}

/* ===== Responsive product & offer layout fix ===== */
.cards-row {
  scrollbar-width: thin;
  scrollbar-color: rgba(28,26,23,.22) transparent;
  overscroll-behavior-inline: contain;
}

.pick-card {
  flex: 0 0 300px;
  min-width: 0;
}

.pick-card-body,
.offers-panel,
.offer-row,
.offer-row .merchant {
  min-width: 0;
}

.pick-card-title {
  min-height: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pick-card-reason {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.offers-panel {
  width: 100%;
  gap: 10px;
}

.offer-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "merchant price"
    "merchant action";
  align-items: center;
  column-gap: 10px;
  row-gap: 7px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.offer-row:last-child { border-bottom: 0; }

.offer-row .merchant {
  grid-area: merchant;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.offer-row .merchant img {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.offer-row .price {
  grid-area: price;
  justify-self: end;
  white-space: nowrap;
  font-size: 13px;
}

.offer-row .go {
  grid-area: action;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 32px;
  padding: 7px 13px;
  white-space: nowrap;
  line-height: 1;
}

@media (min-width: 900px) {
  .cards-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
    overflow: visible;
  }

  .pick-card {
    width: 100%;
    flex-basis: auto;
  }
}

@media (max-width: 640px) {
  body { overflow-x: hidden; }

  .topbar {
    gap: 10px;
  }

  .topbar-actions { gap: 8px; }

  .get-app-btn {
    padding: 9px 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  .hero-wrap {
    padding: 0 14px;
  }

  .hero-logo {
    flex-direction: column;
    gap: 10px;
  }

  .hero-logo span {
    line-height: 1.15;
    text-align: center;
  }

  .search-form {
    padding-left: 16px;
  }

  .search-form input {
    min-width: 0;
    font-size: 16px;
  }

  .pill-row {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    margin-left: -14px;
    margin-right: -14px;
    padding: 0 14px 10px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .pill-row::-webkit-scrollbar { display: none; }
  .pill { flex: 0 0 auto; scroll-snap-align: start; }

  .results-query-bar {
    gap: 8px;
    margin-bottom: 20px;
  }

  .new-search-btn {
    flex: 0 0 auto;
    padding: 11px 13px;
    font-size: 13px;
  }

  .summary-card {
    padding: 20px;
    font-size: 15px;
    line-height: 1.65;
  }

  .sources-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-left: -14px;
    margin-right: -14px;
    padding: 0 14px 8px;
    scrollbar-width: none;
  }

  .sources-row::-webkit-scrollbar { display: none; }
  .source-chip { flex: 0 0 auto; }

  .cards-row {
    gap: 14px;
    margin-left: -14px;
    margin-right: -14px;
    padding: 6px 14px 22px;
    scroll-padding-left: 14px;
    scrollbar-width: none;
  }

  .cards-row::-webkit-scrollbar { display: none; }

  .pick-card {
    flex: 0 0 min(84vw, 320px);
  }

  .pick-card-body {
    padding: 15px 16px 18px;
  }

  .offer-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .offer-row .merchant {
    font-size: 12px;
  }

  .offer-row .go {
    min-width: 82px;
    padding-inline: 11px;
  }

  .followup-bar {
    padding: 24px 14px calc(14px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 380px) {
  .kuponly-logo-img { max-width: 118px; height: 32px; }
  .kuponly-ai-logo span { font-size: 11px; padding: 4px 7px; }
  .get-app-btn { padding: 8px 10px; font-size: 11px; }
  .new-search-btn { padding-inline: 11px; }
  .pick-card { flex-basis: 88vw; }
}


/* Google AI Mode-like progressive response */
.ai-loading-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 112px;
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.86);
  box-shadow: var(--shadow);
}
.ai-loading-orb {
  position: relative;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
}
.ai-loading-orb span {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  animation: ai-orbit 1.2s ease-in-out infinite;
}
.ai-loading-orb span:nth-child(1) { left: 2px; top: 15px; background: var(--coral); }
.ai-loading-orb span:nth-child(2) { right: 2px; top: 5px; background: var(--teal); animation-delay: -.4s; }
.ai-loading-orb span:nth-child(3) { right: 7px; bottom: 2px; background: var(--yellow); animation-delay: -.8s; }
@keyframes ai-orbit {
  0%,100% { transform: scale(.72); opacity: .55; }
  50% { transform: scale(1.08); opacity: 1; }
}
.ai-loading-copy { display: grid; gap: 5px; text-align: left; }
.ai-loading-copy strong { font-family: var(--font-display); font-size: 18px; }
.ai-loading-copy span { color: var(--ink-soft); font-size: 14px; }
.ai-answer-card { white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-typed-content { display: inline; }
.ai-typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.08em;
  margin-left: 3px;
  vertical-align: -.12em;
  border-radius: 2px;
  background: var(--ink);
  animation: ai-cursor-blink .75s steps(1,end) infinite;
}
@keyframes ai-cursor-blink { 50% { opacity: 0; } }
.sources-row,
.cards-row { transition: opacity .38s ease, transform .38s ease; }
.sources-row:not(.ai-reveal),
.cards-row:not(.ai-reveal) { opacity: 0; transform: translateY(10px); }
.sources-row.ai-reveal,
.cards-row.ai-reveal { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .ai-loading-orb span, .ai-typing-cursor { animation-duration: .01ms; animation-iteration-count: 1; }
  .sources-row, .cards-row { transition: none; }
}
@media (max-width: 640px) {
  .ai-loading-card { padding: 20px; gap: 13px; }
  .ai-loading-orb { width: 42px; height: 42px; flex-basis: 42px; }
  .ai-loading-copy strong { font-size: 16px; }
}
