:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --ink: #16161d;
  --ink-2: #3b3b45;
  --muted: #6e6d78;
  --line: #e7e4de;
  --accent: #ff5a1f;
  --accent-ink: #ffffff;
  --accent-soft: #fff0e8;
  --ok: #1f7a46;
  --ok-soft: #e7f4ec;
  --pending-soft: #efeee9;
  --user: #16161d;
  --user-ink: #ffffff;
  --shadow: 0 1px 2px rgba(22, 22, 29, 0.04), 0 8px 24px rgba(22, 22, 29, 0.06);
  --radius: 18px;
  --maxw: 1080px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --surface: #1a1a1f;
    --surface-2: #16161a;
    --ink: #f2f1ee;
    --ink-2: #d6d5d0;
    --muted: #9b9aa3;
    --line: #2a2a31;
    --accent: #ff6a33;
    --accent-soft: #2b1c15;
    --ok: #5ccf8c;
    --ok-soft: #15281d;
    --pending-soft: #24242a;
    --user: #f2f1ee;
    --user-ink: #16161d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 Manrope, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* ---------- top bar ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(16px, calc((100vw - var(--maxw)) / 2));
  background: color-mix(in srgb, var(--bg) 95%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: -0.01em; }
.mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-size: 15px;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.langs { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.langs a { padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; text-decoration: none; color: var(--muted); }
.langs a.on { background: var(--ink); color: var(--bg); }
.top select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  max-width: 46vw;
  cursor: pointer;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 700; text-decoration: none;
  background: var(--ink); color: var(--bg); border: 0; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

/* ---------- layout ---------- */
.thread {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 16px 200px;
}

/* ---------- home hero ---------- */
.hero { text-align: center; padding: 9vh 0 24px; max-width: 760px; margin: 0 auto; }
.hero-mark {
  width: 56px; height: 56px; margin: 0 auto 22px;
  display: grid; place-items: center; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink); font-size: 26px;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 35%, transparent);
}
.hero .eyebrow { margin-bottom: 12px; }
.hero h1 { font-size: clamp(28px, 5vw, 46px); line-height: 1.08; letter-spacing: -0.03em; margin: 0 0 14px; font-weight: 800; }
.hero p { color: var(--muted); font-size: 17px; margin: 0 auto 26px; max-width: 560px; }
.examples { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.notice {
  max-width: 760px; margin: 12px auto 0; padding: 12px 16px;
  border-radius: 12px; background: var(--accent-soft); color: var(--ink-2); text-align: center; font-weight: 600;
}

/* ---------- storefront hero ---------- */
.sf-hero { padding: 18px 0 8px; max-width: 820px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent);
}
.sf-hero h1 { font-size: clamp(28px, 4.6vw, 44px); line-height: 1.08; letter-spacing: -0.03em; margin: 10px 0 12px; font-weight: 800; }
.lead { font-size: 18px; color: var(--ink-2); margin: 0 0 18px; max-width: 720px; }
.intro { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; max-width: 720px; }
.intro p { margin: 3px 0 0; color: var(--ink-2); }
.intro q { font-weight: 700; color: var(--ink); quotes: '«' '»'; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: 13px; color: var(--muted); font-weight: 600; }
.linkish { border: 0; background: none; padding: 0; cursor: pointer; color: var(--accent); font-weight: 700; }

/* ---------- conversation ---------- */
.conv, #live { display: flex; flex-direction: column; gap: 18px; }
.conv { margin-top: 28px; }
#live { margin-top: 18px; }
.msg { display: flex; gap: 12px; align-items: flex-start; scroll-margin-top: 80px; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: 720px; }
.msg .bubble p { margin: 0 0 8px; }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg.user .bubble {
  background: var(--user); color: var(--user-ink);
  padding: 10px 16px; border-radius: 18px 18px 4px 18px; max-width: min(560px, 85%);
  font-weight: 500;
}
.msg.assistant .bubble { padding-top: 3px; font-size: 16.5px; color: var(--ink); }
.bubble.error { color: #c0392b; }
.avatar {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 800; letter-spacing: 0.02em;
  background: var(--accent-soft); color: var(--accent);
}
.sf-link { display: inline-block; margin-top: 6px; font-weight: 700; font-size: 14px; color: var(--accent); text-decoration: none; }
details.history {
  border: 1px dashed var(--line); border-radius: 14px; padding: 10px 14px; background: var(--surface-2);
}
details.history summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--muted); }
details.history[open] { display: flex; flex-direction: column; gap: 14px; }
details.history[open] summary { margin-bottom: 4px; }

.turn { display: flex; flex-direction: column; gap: 18px; scroll-margin-top: 76px; }
.status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.clarify { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); }
.clarify p { font-weight: 700; margin: 0 0 10px !important; }
.opts, .suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest { padding-left: 42px; }

/* ---------- pills & chips ---------- */
.pill {
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.pill:hover { transform: translateY(-1px); }
.pill.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 600; }
.pill.ghost:hover { border-color: var(--ink); }

.intents {
  margin-left: 42px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.intents-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--pending-soft); color: var(--ink-2); border: 1px solid transparent;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.chip b { font-weight: 800; font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--surface); }
.chip i { font-style: normal; font-size: 12px; color: var(--muted); }
.chip.ok, .chip.found { background: var(--ok-soft); color: var(--ok); }
.chip.ok .dot, .chip.found .dot { background: var(--ok); }
.chip.none { background: transparent; border-color: var(--line); color: var(--muted); }
.chip.none .dot { background: transparent; border: 1.5px solid var(--muted); }
.chip.pending .dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.chip.toggle { cursor: pointer; border-color: var(--line); background: var(--surface); }
.chip.toggle.on { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.chip.toggle.on .dot { background: var(--ok); }
.chip.toggle.off { text-decoration: line-through; opacity: 0.55; }
.chip.toggle .x { font-size: 16px; line-height: 1; opacity: 0.6; }
.chip.toggle.new { border-style: dashed; }
.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-weight: 600; color: var(--ink-2); }
.confirm > span:first-child { margin-right: 4px; }
.confirm .pill { padding: 5px 12px; font-size: 13px; }
.ok-note { color: var(--ok); font-weight: 600; }
.add-intent {
  flex: 1 1 220px; min-width: 0;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; background: var(--surface-2); font-size: 14px;
}
.add-intent:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }

/* ---------- shelves & cards ---------- */
.shelf { margin-top: 6px; }
.shelf header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0 0 12px; }
.shelf h2 { font-size: 21px; letter-spacing: -0.02em; margin: 0; font-weight: 800; }
.shelf header p { margin: 0; color: var(--muted); font-size: 14.5px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; box-shadow: var(--shadow);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 2px 4px rgba(22,22,29,.05), 0 16px 36px rgba(22,22,29,.10); }
.card-img { position: relative; aspect-ratio: 1 / 1; background: #fff; display: grid; place-items: center; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.noimg { font-size: 34px; color: var(--line); }
.badge {
  position: absolute; top: 10px; left: 10px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 11.5px; font-weight: 800; padding: 4px 9px; border-radius: 999px; letter-spacing: 0.01em;
}
.card-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 14px; flex: 1; }
.merchant { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.card h3 {
  margin: 0; font-size: 14.5px; line-height: 1.35; font-weight: 700;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pitch {
  margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.cta { font-size: 13px; font-weight: 800; color: var(--accent); white-space: nowrap; }

/* ---------- composer ---------- */
.composer-wrap {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 14px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, color-mix(in srgb, var(--bg) 0%, transparent));
}
.composer {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: 8px 8px 8px 18px; box-shadow: var(--shadow);
}
.composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.composer textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent;
  font-size: 16px; line-height: 1.45; padding: 8px 0; max-height: 160px;
}
.composer button {
  flex: none; width: 42px; height: 42px; border-radius: 14px; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
}
.composer button:disabled { opacity: 0.5; cursor: progress; }
.fine { max-width: 760px; margin: 8px auto 0; text-align: center; font-size: 11.5px; color: var(--muted); }
.is-home:not(.chatting) .composer-wrap { position: static; background: none; padding-top: 0; }
.is-home:not(.chatting) .thread { padding-bottom: 12px; }
.is-home:not(.chatting) .composer { max-width: 680px; }

.toast {
  position: fixed; left: 50%; bottom: 120px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: 14px;
  transition: all 0.2s ease; pointer-events: none; z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- footer ---------- */
.site-foot {
  max-width: var(--maxw); margin: 0 auto;
  padding: 20px 16px calc(150px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted); text-align: center;
}
.site-foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; margin-bottom: 8px; }
.site-foot a, .site-foot .linkish { color: var(--ink-2); font-weight: 600; text-decoration: none; font-size: 12.5px; }
.site-foot .linkish { color: var(--ink-2); }
.site-foot a:hover, .site-foot .linkish:hover { color: var(--accent); }
.site-foot p { margin: 0; }
.is-home:not(.chatting) .site-foot, .is-legal .site-foot { padding-bottom: 28px; }
.thread { padding-bottom: 48px; }

/* ---------- cookie consent ---------- */
.consent {
  position: fixed; z-index: 60; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 980px; margin: 0 auto;
  display: flex; align-items: center; gap: 18px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px;
  box-shadow: 0 12px 40px rgba(22, 22, 29, 0.18);
}
.consent[hidden] { display: none; }
.consent-text { flex: 1; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.consent-text b { color: var(--ink); }
.consent-text a { color: var(--accent); font-weight: 700; text-decoration: none; }
.consent-buttons { display: flex; gap: 8px; flex: none; }
.cbtn { border-radius: 999px; padding: 9px 16px; font-size: 14px; font-weight: 700; cursor: pointer; border: 1px solid var(--ink); white-space: nowrap; }
.cbtn.dark { background: var(--ink); color: var(--bg); }
.cbtn.outline { background: var(--surface); color: var(--ink); }

/* ---------- legal pages ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: 32px 16px 40px; }
.legal h1 { font-size: clamp(28px, 4.5vw, 40px); letter-spacing: -0.03em; line-height: 1.1; margin: 0 0 18px; }
.legal h2 { font-size: 19px; letter-spacing: -0.01em; margin: 28px 0 8px; }
.legal p, .legal li { color: var(--ink-2); font-size: 15.5px; line-height: 1.65; }
.legal ul { padding-left: 20px; margin: 8px 0; }
.legal li { margin-bottom: 6px; }
.legal-note { font-size: 13px !important; color: var(--muted) !important; font-style: italic; }
.choices { margin-top: 24px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.choices-status { margin: 0 0 14px; font-weight: 700; color: var(--ink) !important; }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .thread { padding: 16px 16px 40px; }
  .intents, .suggest { margin-left: 0; padding-left: 0; }
  .intents { padding: 12px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-body { padding: 10px 11px 12px; }
  .pitch { -webkit-line-clamp: 3; font-size: 13px; }
  .price { font-size: 16px; }
  .cta { display: none; }
  .brand span:last-child { display: none; }
  .hero { padding-top: 5vh; }
  .lead { font-size: 16.5px; }
  .consent { flex-direction: column; align-items: stretch; gap: 12px; left: 10px; right: 10px; padding: 14px; }
  .consent-buttons .cbtn { flex: 1; }
  .is-legal .top .btn { display: none; }
}
