/* ---------- Tokens ---------- */
:root {
  --white: white;
  --text-black: #100d08;
  --ink: var(--white);
  --primary: #f0440a;
  --transparent: transparent;
  --ink-dim: rgba(255, 255, 255, 0.68);
  --ink-faint: rgba(255, 255, 255, 0.48);
  --line: rgba(255, 255, 255, 0.2);
  --line-strong: rgba(255, 255, 255, 0.5);
  --accent: var(--primary);
  --accent-ink: var(--white);
  --user-bubble: var(--primary);
  --error: #b42318;
  --radius-pill: 999px;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "DM Sans", sans-serif;
}

* { box-sizing: border-box; }

@property --border-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-body);
  color: var(--white);
  background-color: #100d09;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(ellipse at 0 0, rgba(242, 63, 0, 0.48), transparent 30%),
    radial-gradient(ellipse at 100% 45%, rgba(33, 20, 12, 0.42), transparent 45%);
  background-size: 88px 88px, 88px 88px, auto, auto;
  background-attachment: fixed;
  min-height: 100vh;
}

textarea, input, button { font-family: inherit; }

/* ---------- App shell ---------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(22px, 5vw, 76px);
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-black);
  text-decoration: none;
}
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; background: var(--primary); color: var(--white); font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; }
.brand-name b { font-weight: 400; color: var(--ink-dim); }
.nav-links, .account-actions { display: flex; align-items: center; gap: 26px; }
.nav-links a, .account-actions a { color: var(--text-black); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.nav-links a:hover, .account-actions a:hover { color: var(--primary); }
.nav-links span { font-size: 1.1rem; padding-left: 5px; }
.signup-link { background: var(--text-black); color: var(--white) !important; padding: 10px 16px; border-radius: var(--radius-pill); }

.ghost-link {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-black);
  border-radius: var(--radius-pill);
  padding: 7px 16px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.ghost-link:hover { border-color: var(--line-strong); color: var(--ink); }

/* ---------- Hero (landing search) ---------- */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: left;
  position: relative;
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: 72px 24px 36px;
  min-height: 680px;
  transition: padding 0.28s ease;
}
.app--chatting .hero {
  flex: 0 0 auto;
  min-height: auto;
  padding: 54px 24px 8px;
}
.app--chatting .chips {
  display: none;
}

.hero-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto 34px;
}
.hero-copy { position: relative; z-index: 1; flex: 1; min-width: 0; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 20px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.015em;
}
.eyebrow span { display: block; width: 54px; height: 1px; background: rgba(255, 255, 255, 0.8); }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.5rem, 4.7vw, 3.8rem);
  line-height: 0.99;
  letter-spacing: -0.055em;
  margin: 0;
  max-width: 100%;
  color: var(--white);
  white-space: normal;
}
.hero h1 em { font-style: normal; color: var(--primary); }
.hero-art {
  position: relative;
  z-index: 1;
  flex: 0 0 205px;
  height: 175px;
  margin: 0 4px 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-art img { width: 100%; height: 100%; object-fit: contain; }

.chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  margin: 26px auto 0;
  width: 100%;
  max-width: 980px;
  position: relative;
  z-index: 1;
}
.chip {
  background: transparent;
  border: 2px solid #ed7750;
  color: var(--white);
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  min-height: 52px;
  font-size: 0.94rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.chip:hover {
  border-color: var(--primary);
  color: var(--white);
  background: var(--primary);
  transform: translateY(-1px);
}
.powered-by { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 0 0 auto; position: relative; z-index: 1; margin: 0; padding: 0 20px 14px; color: var(--white); font-size: 0.86rem; text-align: center; }
.powered-by a { color: #ff7950; font-weight: 700; text-decoration: none; }
.powered-by a:hover { text-decoration: underline; }

@media (min-width: 701px) and (max-width: 850px) {
  .hero h1 { font-size: clamp(2rem, 4.6vw, 2.45rem); }
}

/* ---------- Search bar (shared: hero position + bottom-bar position) ---------- */
.form-slot { width: 100%; display: flex; justify-content: center; }

.search-bar {
  width: 100%;
  max-width: 980px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #F4EEEB;
  border: 2px solid #f58c6b;
  border-radius: 20px;
  padding: 8px 12px 8px 18px;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.2);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(240, 68, 10, 0.16); }

.app--chatting .search-bar {
  gap: 16px;
  min-height: 72px;
  padding: 12px 22px;
  border: 1px solid rgba(245, 140, 107, 0.78);
  border-radius: 18px;
  background: #F4EEEB;
  box-shadow: none;
  cursor: default;
}
.app--chatting .search-bar:focus-within {
  border-color: rgba(245, 140, 107, 0.78);
  box-shadow: none;
}
.app--chatting .search-bar .field-icon { width: 28px; height: 28px; }
.app--chatting #chat-input {
  color: var(--text-black);
  font-size: 1.08rem;
  font-weight: 600;
  overflow: hidden;
  -webkit-text-fill-color: var(--text-black);
}
.app--chatting .search-bar.is-question-submitted #chat-input { opacity: 0.72; }
.app--chatting #chat-input::placeholder {
  color: #756B64;
  opacity: 1;
}
.app--chatting .search-bar .send-btn { display: none; }
.send-icon--sparkle { display: none; }
.app--chatting .search-bar.is-follow-up {
  border-radius: 16px;
  cursor: text;
}
.app--chatting .search-bar.is-follow-up .send-btn {
  display: flex;
  width: 42px;
  height: 42px;
  border-radius: 10px;
}
.app--chatting .search-bar.is-follow-up .send-icon--arrow { display: none; }
.app--chatting .search-bar.is-follow-up .send-icon--sparkle { display: block; }
.app--chatting .search-bar.is-follow-up #chat-input {
  color: var(--text-black);
  font-weight: 400;
  overflow: auto;
  -webkit-text-fill-color: var(--text-black);
}
.app--chatting .search-bar.is-follow-up #chat-input::placeholder {
  color: #756B64;
}

@keyframes border-orbit {
  to { --border-angle: 360deg; }
}

.field-icon { width: 32px; height: 32px; fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

#chat-input {
  flex: 1;
  resize: none;
  background: none;
  border: none;
  outline: none;
  color: var(--text-black);
  font-size: 1.05rem;
  line-height: 1.4;
  max-height: 120px;
  padding: 6px 0;
}
#chat-input::placeholder { color: #756B64; opacity: 1; }

.send-btn {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.send-btn:hover { transform: scale(1.05); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.send-btn svg { width: 36px; height: 36px; }

/* ---------- Chat log ---------- */
.chat-log {
  flex: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 24px 42px;
  overflow-y: visible;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.chat-turn { display: flex; flex-direction: column; gap: 12px; }
.msg-row { display: flex; }
.msg-row.agent { justify-content: flex-start; }
.msg-row.user { justify-content: flex-start; }

.msg-question {
  position: relative;
  width: 100%;
  padding: 14px 56px 14px 60px;
  border: 1px solid rgba(245, 140, 107, 0.7);
  border-radius: 16px;
  background: rgba(16, 13, 9, 0.28);
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-wrap;
}
.msg-question::before {
  content: "✧";
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary);
  font-size: 1.8rem;
  font-weight: 400;
}
.msg-question::after {
  content: "↓";
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary);
  font-size: 2rem;
  line-height: 1;
}

/* Agent replies flow beneath the question card, like a support answer. */
.msg-agent {
  color: var(--white);
  width: 100%;
  max-width: 100%;
  padding: 18px 28px 24px;
  border: 1px solid rgba(245, 140, 107, 0.7);
  border-radius: 18px;
  background: rgba(16, 13, 9, 0.28);
  font-size: 1.1rem;
  line-height: 1.55;
}
.msg-agent p { margin: 0 0 16px; }
.msg-agent p:last-child { margin-bottom: 0; }
.msg-agent strong { color: #fff; font-weight: 600; }
.msg-agent em { color: var(--white); font-style: italic; }
.msg-agent ul, .msg-agent ol { margin: 0 0 12px; padding-left: 1.3em; }
.msg-agent li { margin: 4px 0; }
.msg-agent li::marker { color: var(--accent); }
.msg-agent h1, .msg-agent h2, .msg-agent h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: #fff;
  margin: 18px 0 8px;
  line-height: 1.3;
}
.msg-agent h1 { font-size: 1.08rem; }
.msg-agent h2 { font-size: 1.02rem; }
.msg-agent h3 { font-size: 0.96rem; }
.msg-agent code {
  background: rgba(255, 255, 255, 0.09);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.88em;
}
.msg-agent pre {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0 0 12px;
}
.msg-agent pre code { background: none; padding: 0; }
.msg-agent a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.msg-agent blockquote {
  margin: 0 0 12px;
  padding-left: 12px;
  border-left: 2px solid var(--line-strong);
  color: var(--ink-dim);
}
.msg-agent::before {
  content: "ANSWER";
  display: block;
  margin: 0 0 12px;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
}
.answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 26px 0 0 62px;
}
.answer-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 20px;
  border: 2px solid #ed7750;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--white);
  font: inherit;
  font-size: 0.92rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.answer-action:hover { border-color: var(--primary); transform: translateY(-1px); }
.answer-action--primary { border-color: var(--primary); background: var(--primary); }
.answer-action--primary:hover { background: #d93c0c; }
.answer-action:focus-visible { outline: 2px solid var(--white); outline-offset: 3px; }

.msg-typing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
}
.typing-row { padding-left: 4px; animation: typing-enter 0.25s ease-out both; }
.answer-enter { animation: answer-enter 0.32s ease-out both; }

.loading-dots { display: inline-flex; align-items: center; gap: 5px; }
.loading-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: loading-bounce 1.1s ease-in-out infinite;
}
.loading-dots i:nth-child(2) { animation-delay: 0.14s; }
.loading-dots i:nth-child(3) { animation-delay: 0.28s; }

@keyframes loading-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-5px); }
}
@keyframes typing-enter {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes answer-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-error {
  color: var(--error);
  font-size: 0.9rem;
  background: rgba(242, 163, 163, 0.08);
  border: 1px solid rgba(242, 163, 163, 0.3);
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 100%;
}

/* ---------- Bottom bar (chat mode) ---------- */
.bottom-bar {
  width: 100%;
  max-width: 1050px;
  margin: 0 auto;
  padding: 12px 24px 18px;
}
.bottom-bar .ghost-link { display: block; margin: 12px auto 0; color: var(--ink-dim); }
.bottom-bar .ghost-link:hover { color: var(--white); }

/* ---------- Lead popup ---------- */
.lead-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 13, 9, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: typing-enter 0.2s ease-out both;
}
.lead-overlay[hidden] { display: none; }

.lead-modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 34px 34px 26px;
  border: 1px solid rgba(245, 140, 107, 0.7);
  border-radius: 20px;
  background-color: #100d09;
  background-image:
    radial-gradient(ellipse at 0 0, rgba(242, 63, 0, 0.32), transparent 55%),
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: auto, 44px 44px, 44px 44px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  animation: answer-enter 0.32s ease-out both;
}
.lead-modal .eyebrow { margin-bottom: 16px; font-size: 0.72rem; }
.lead-modal .eyebrow span { width: 32px; }
.lead-modal h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: var(--white);
}
.lead-modal h2 em { font-style: normal; color: var(--primary); }
.lead-desc { margin: 0 0 24px; color: var(--ink-dim); font-size: 0.98rem; line-height: 1.5; }

.lead-form { display: flex; flex-direction: column; gap: 16px; }
.lead-field { display: flex; flex-direction: column; gap: 7px; }
.lead-field span { font-size: 0.85rem; font-weight: 600; color: var(--white); }
.lead-field input {
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border: 2px solid #f58c6b;
  border-radius: 14px;
  background: #F4EEEB;
  color: var(--text-black);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.lead-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(240, 68, 10, 0.22); }
.lead-field input[aria-invalid="true"] { border-color: #ff6b5a; }

.lead-error {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid rgba(242, 163, 163, 0.4);
  border-radius: 10px;
  background: rgba(242, 163, 163, 0.1);
  color: #ffb4a8;
  font-size: 0.9rem;
}
.lead-submit {
  min-height: 52px;
  margin-top: 4px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}
.lead-submit:hover { background: #d93c0c; transform: translateY(-1px); }
.lead-submit:focus-visible { outline: 2px solid var(--white); outline-offset: 3px; }
.lead-submit:disabled { opacity: 0.6; cursor: wait; transform: none; }
.lead-fineprint { margin: 0; text-align: center; color: var(--ink-faint); font-size: 0.8rem; }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .topbar { padding: 16px 18px; flex-wrap: wrap; gap: 14px; }
  .nav-links { display: none; }
  .account-actions { margin-left: auto; gap: 12px; }
  .account-actions > a:first-child { display: none; }
  .signup-link { padding: 8px 12px; }
  .brand-name b { display: none; }
  .hero { flex: 0 0 auto; justify-content: flex-start; min-height: auto; padding: 40px 20px 24px; }
  .app--chatting .hero { min-height: auto; padding: 24px 20px 4px; }
  .hero-heading { flex-direction: column; align-items: stretch; margin-bottom: 18px; }
  .hero-art { flex: 0 0 64px; width: 76px; height: 64px; align-self: flex-end; margin: 0 2px -4px 0; }
  .eyebrow { gap: 7px; margin-bottom: 14px; font-size: 0.65rem; }
  .eyebrow span { width: 20px; }
  .hero h1 { max-width: 100%; font-size: clamp(1.85rem, 6vw, 2.4rem); }
  .chips { grid-template-columns: 1fr; gap: 8px; margin-top: 14px; }
  .chip { text-align: center; min-height: 38px; padding: 7px 12px; font-size: 0.8rem; line-height: 1.3; }
  .form-slot { width: 100%; }
  .search-bar { min-height: 48px; padding: 4px 6px 4px 10px; gap: 7px; border-radius: 14px; }
  .app--chatting .search-bar { min-height: 52px; padding: 5px 10px; gap: 8px; }
  .app--chatting #chat-input { font-size: 0.9rem; }
  .field-icon { width: 22px; height: 22px; }
  #chat-input { font-size: 0.88rem; padding: 3px 0; }
  .send-btn { width: 36px; height: 36px; border-radius: 9px; }
  .send-btn svg { width: 24px; height: 24px; }
  .chat-log { padding: 12px 20px 24px; }
  .msg-question { padding: 13px 46px 13px 48px; font-size: 0.94rem; }
  .msg-question::before { left: 14px; font-size: 1.5rem; }
  .msg-question::after { right: 12px; font-size: 1.7rem; }
  .msg-agent { padding: 16px 20px 20px; font-size: 0.94rem; }
  .answer-actions { margin: 20px 0 0; }
  .answer-action { min-height: 44px; padding: 9px 14px; font-size: 0.88rem; }
  .bottom-bar { padding: 10px 20px 16px; }
  .lead-modal { padding: 26px 20px 20px; border-radius: 16px; }
  .lead-desc { font-size: 0.9rem; margin-bottom: 18px; }
}

@media (max-width: 420px) {
  .hero-art { flex-basis: 56px; width: 66px; height: 56px; }
  .eyebrow span { width: 12px; }
  .eyebrow { font-size: 0.58rem; gap: 5px; }
  .hero h1 { font-size: clamp(1.3rem, 6vw, 1.65rem); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .hero { transition: none; }
  .search-bar, .typing-row, .answer-enter, .lead-overlay, .lead-modal { animation: none; }
  .loading-dots i { animation: none; opacity: 0.7; }
}
