:root {
  --ink: #1a1a1a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #ffffff;
  --accent: #111827;
  --confirm-bg: #ecfdf5;
  --confirm-ink: #047857;
  --verify-bg: #fffbeb;
  --verify-ink: #b45309;
  --radius: 14px;
  --maxw: 680px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  min-height: 100dvh;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(20px, 6vh, 72px) 20px 40px;
  display: flex;
  flex-direction: column;
}

/* Brand wordmark */
.brand {
  text-align: center;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: clamp(8px, 8vh, 90px) 0 0;
  transition: margin .35s ease, font-size .35s ease;
}
.brand__which { color: var(--muted); font-weight: 500; }
.brand__part  { color: var(--ink); font-weight: 700; }

/* Hero copy */
.hero {
  text-align: center;
  margin: 26px 0 30px;
  transition: opacity .3s ease, max-height .35s ease, margin .35s ease;
  overflow: hidden;
}
.hero__title {
  font-size: clamp(21px, 3.2vw, 26px);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
.hero__sub {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
  margin: 0;
}

/* Search / ask box */
.ask {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 6px 6px 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: box-shadow .2s ease, border-color .2s ease;
  background: #fff;
}
.ask:focus-within {
  border-color: #c7ccd4;
  box-shadow: 0 4px 18px rgba(0,0,0,.08);
}
.ask__input {
  flex: 1;
  border: 0;
  outline: 0;
  font-size: 17px;
  padding: 14px 0;
  background: transparent;
  color: var(--ink);
  min-width: 0;
}
.ask__input::placeholder { color: #9aa1ab; }
.ask__send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: opacity .2s ease, transform .05s ease;
}
.ask__send:hover { opacity: .9; }
.ask__send:active { transform: scale(.96); }
.ask__send:disabled { opacity: .4; cursor: default; }

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 16px 0 0;
  transition: opacity .3s ease;
}

/* Conversation thread */
.thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 18px;
}
.thread:empty { margin: 0; }

.turn { display: flex; flex-direction: column; }
.turn--user { align-items: flex-end; }
.bubble {
  max-width: 88%;
  padding: 12px 15px;
  border-radius: 14px;
  font-size: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.turn--user .bubble {
  background: #f3f4f6;
  border-bottom-right-radius: 5px;
}
.turn--bot .bubble {
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}
.turn--bot.turn--advice .bubble { background: #f8fafc; }

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--muted);
  margin-bottom: 6px;
}

/* Part cards */
.parts { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; max-width: 88%; }
.part {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.part:hover { border-color: #d2d6dd; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.part__name { font-weight: 600; font-size: 15.5px; line-height: 1.35; }
.part__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.part__price { font-size: 17px; font-weight: 700; }
.fit {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}
.fit--confirmed { background: var(--confirm-bg); color: var(--confirm-ink); }
.fit--verify { background: var(--verify-bg); color: var(--verify-ink); }
.part__cta {
  align-self: flex-start;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 14.5px;
  border: 1px solid var(--line);
  padding: 9px 14px;
  border-radius: 10px;
  transition: background .15s ease;
}
.part__cta:hover { background: #f7f8fa; }
.offer-note { font-size: 12.5px; color: var(--muted); }

/* Thinking indicator */
.thinking { display: inline-flex; gap: 5px; padding: 6px 2px; }
.thinking span {
  width: 7px; height: 7px; border-radius: 50%; background: #c4c9d1;
  animation: blink 1.3s infinite ease-in-out;
}
.thinking span:nth-child(2) { animation-delay: .2s; }
.thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity:.25 } 40% { opacity:1 } }

/* Compact state — after first message the hero collapses */
body.started .brand { margin: 0 0 4px; font-size: 22px; }
body.started .hero { opacity: 0; max-height: 0; margin: 0; }
body.started .hint { display: none; }
body.started .wrap { justify-content: flex-start; padding-top: 18px; }

/* Sticky composer once conversation started */
body.started .ask {
  position: sticky;
  bottom: 12px;
  margin-top: auto;
  background: #fff;
}

@media (max-width: 520px) {
  .brand { font-size: 26px; margin-top: 30px; }
  .bubble, .parts { max-width: 100%; }
  .ask__input { font-size: 16px; }
}
