/* Clean Agent — engine styles.
   Layout follows the condensed F.T.T.U showroom: a narrow centered nav, a centered hero and a
   four-card board that tops out around two thirds of the screen instead of running edge to edge.
   Colors follow the standing engine template (indigo / purple / pink on a deep night background). */

:root{
  --indigo:#6366f1; --purple:#a855f7; --indigo-soft:#818cf8; --purple-soft:#c084fc; --pink:#f472b6;
  --serif:'Space Grotesk', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --sans:'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --coral:#ff7a6b;
}
html{font-size:100%;}
html[data-font-size="sm"]{font-size:87.5%;}
html[data-font-size="lg"]{font-size:112.5%;}
html[data-font-size="xl"]{font-size:125%;}

html[data-theme="dark"]{
  --page:#0d0b24;
  --text:#f1f0ff; --text-soft:rgba(228,226,255,0.76); --text-dim:rgba(228,226,255,0.52);
  --bar:rgba(13,11,36,0.9); --bar-line:rgba(255,255,255,0.08);
  --card:rgba(20,17,52,0.72); --card-solid:#161337; --card-line:rgba(255,255,255,0.11);
  --well:rgba(255,255,255,0.06); --chip:rgba(20,17,52,0.82);
  --bubble:rgba(76,70,170,0.34); --value:var(--purple-soft);
  --track:rgba(255,255,255,0.12);
  --glow-a:rgba(99,102,241,0.62); --glow-b:rgba(168,85,247,0.55); --glow-c:rgba(244,114,182,0.42);
  --hero-shadow:0 0.125rem 1.125rem rgba(0,0,0,0.5);
  color-scheme:dark;
}
html[data-theme="light"]{
  --page:#f5f3ff;
  --text:#1b1640; --text-soft:rgba(27,22,64,0.74); --text-dim:rgba(27,22,64,0.66);
  --bar:rgba(250,249,255,0.92); --bar-line:rgba(27,22,64,0.08);
  --card:rgba(255,255,255,0.8); --card-solid:#ffffff; --card-line:rgba(27,22,64,0.1);
  --well:rgba(99,102,241,0.08); --chip:rgba(255,255,255,0.88);
  --bubble:rgba(99,102,241,0.1); --value:#7c3aed;
  --track:rgba(27,22,64,0.1);
  --glow-a:rgba(99,102,241,0.5); --glow-b:rgba(168,85,247,0.42); --glow-c:rgba(244,114,182,0.4);
  --hero-shadow:0 0.0625rem 0.75rem rgba(255,255,255,0.7);
  color-scheme:light;
}

*,*::before,*::after{box-sizing:border-box;}
html{-webkit-text-size-adjust:100%; scroll-padding-top:calc(4.5rem + env(safe-area-inset-top,0px));}
body{margin:0; background:var(--page); color:var(--text); font-family:var(--sans); font-size:0.9375rem; line-height:1.55;}
h1,h2,h3{font-family:var(--serif); font-weight:700; margin:0; line-height:1.1;}
p{margin:0;}
a{color:inherit;}
button{font:inherit; color:inherit;}
:focus-visible{outline:0.125rem solid var(--purple-soft); outline-offset:0.125rem; border-radius:0.375rem;}
[hidden]{display:none !important;}
.sr-only{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); clip-path:inset(50%); white-space:nowrap;}

/* ───────── stage: vibrant glow, no scrim ───────── */
.stage{
  position:relative; isolation:isolate; min-height:100vh; min-height:100svh; padding-bottom:4rem;
  background-color:var(--page);
  background-image:
    radial-gradient(42rem 30rem at 12% 18%, var(--glow-a), transparent 62%),
    radial-gradient(38rem 28rem at 88% 22%, var(--glow-b), transparent 64%),
    radial-gradient(46rem 30rem at 52% 92%, var(--glow-c), transparent 66%),
    radial-gradient(30rem 22rem at 70% 60%, rgba(129,140,248,0.32), transparent 70%);
}
/* Bubbles sit in their own clipped layer so the stage itself never becomes a scroll container
   (that would stop the sticky top bar from sticking). */
.bubbles{position:absolute; inset:0; z-index:-1; overflow:hidden; pointer-events:none;}
.bubble{position:absolute; border-radius:50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.6), rgba(255,255,255,0.1) 20%, transparent 42%),
    radial-gradient(circle at 70% 74%, rgba(244,114,182,0.32), transparent 46%),
    radial-gradient(circle at 24% 70%, rgba(129,140,248,0.3), transparent 50%),
    radial-gradient(circle, rgba(192,132,252,0.1) 58%, rgba(192,132,252,0.42) 69%, transparent 73%);
  border:1px solid rgba(255,255,255,0.14);
}
html[data-theme="light"] .bubble{border-color:rgba(99,102,241,0.18);}
.b1{width:11rem; height:11rem; left:4%; top:30rem;}
.b2{width:6rem; height:6rem; right:7%; top:9rem;}
.b3{width:16rem; height:16rem; right:-4rem; bottom:6rem;}

/* ───────── top bar (condensed, centered) ───────── */
.topbar{
  position:sticky; top:0; z-index:40;
  background:var(--bar); border-bottom:1px solid var(--bar-line);
  padding-top:env(safe-area-inset-top,0px);
  padding-left:env(safe-area-inset-left,0px); padding-right:env(safe-area-inset-right,0px);
}
@supports ((-webkit-backdrop-filter:blur(1px)) or (backdrop-filter:blur(1px))){
  html[data-theme="dark"] .topbar{background:rgba(13,11,36,0.62);}
  html[data-theme="light"] .topbar{background:rgba(250,249,255,0.72);}
  .topbar{-webkit-backdrop-filter:blur(0.75rem); backdrop-filter:blur(0.75rem);}
}
.nav{
  display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:0.5rem 1.25rem;
  padding:0.75rem 1rem; width:100%; max-width:42rem; margin:0 auto;
}
.brand{display:inline-flex; align-items:center; gap:0.5rem; text-decoration:none; font-family:var(--serif); font-weight:700; font-size:1.1875rem; white-space:nowrap;}
.brand-mark{width:1.125rem; height:1.125rem; border-radius:0.3125rem; background:linear-gradient(145deg,var(--indigo-soft),var(--purple) 60%,var(--pink)); box-shadow:0 0 0.75rem rgba(168,85,247,0.6); flex-shrink:0;}
.nav-links{display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:0.25rem 1.125rem; font-size:0.875rem; font-weight:500;}
.nav-links a{text-decoration:none; color:var(--text-soft); padding:0.25rem 0;}
.nav-links a:hover{color:var(--text);}
.nav-links a[aria-current="page"]{color:var(--text);}
.controls{display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:0.5rem 0.75rem;}
.ctl{background:none; border:0; cursor:pointer; color:var(--text); font-weight:500; font-size:0.875rem; white-space:nowrap;}
.theme{display:inline-flex; align-items:center; gap:0.4375rem; padding:0.25rem 0;}
.theme .sun{width:0.625rem; height:0.625rem; border-radius:50%; background:var(--pink); box-shadow:0 0 0.5rem rgba(244,114,182,0.7);}
html[data-theme="light"] .theme .sun{background:var(--indigo); box-shadow:none;}
.sizes{display:inline-flex; align-items:center; gap:0.125rem; padding:0.125rem; border-radius:999px; border:1px solid var(--card-line); background:var(--chip);}
.size{width:1.75rem; height:1.75rem; border-radius:999px; display:inline-flex; align-items:center; justify-content:center; font-weight:700; line-height:1; color:var(--text-soft);}
.size.s-sm{font-size:0.6875rem;} .size.s-md{font-size:0.8125rem;} .size.s-lg{font-size:0.9375rem;} .size.s-xl{font-size:1.0625rem;}
.size[aria-pressed="true"]{background:#4f46e5; background-image:linear-gradient(180deg,#5b4ff0,#4f46e5); color:#fff;}
@media (min-width:47.5em){
  .nav{flex-wrap:nowrap; justify-content:space-between; max-width:42rem; padding:0.875rem 1.25rem;}
}

/* ───────── hero ───────── */
.hero{text-align:center; padding:2.125rem 1.25rem 1.625rem;}
.hero-tag{
  display:inline-block; padding:0.3125rem 0.8125rem; border-radius:999px; margin-bottom:1rem;
  background:var(--chip); border:1px solid var(--card-line); color:var(--purple-soft);
  font-size:0.8125rem; font-weight:600;
}
html[data-theme="light"] .hero-tag{color:#6d28d9;}
.hero h1{font-size:clamp(2.125rem, 5.4vw, 3.125rem); letter-spacing:-0.03em; text-shadow:var(--hero-shadow); overflow-wrap:anywhere;}
.hero h1 .grad{
  color:var(--purple-soft);
  background:linear-gradient(95deg,var(--indigo-soft) 0%,var(--purple-soft) 55%,var(--pink) 100%);
  -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent; text-shadow:none;
}
.hero p{max-width:26em; margin:1.125rem auto 0; font-size:clamp(1rem, 1.35vw, 1.125rem); line-height:1.45; font-weight:500; text-shadow:var(--hero-shadow);}
.hero-link{
  display:inline-block; margin-top:0.875rem; padding:0.5rem 1rem; border-radius:999px;
  background:var(--chip); border:1px solid var(--card-line);
  font-size:0.875rem; font-weight:700; color:var(--purple-soft); text-decoration:none;
}
.hero-link:hover{border-color:var(--purple-soft);}
html[data-theme="light"] .hero-link{color:#6d28d9;}

/* ───────── board: chat + three live cards, condensed ───────── */
.board{
  display:grid; grid-template-columns:minmax(0,1fr); gap:0.875rem; align-items:start;
  width:calc(100% - 1.5rem); margin:0.75rem auto 0;
}
@media (min-width:43.75em){
  .board{grid-template-columns:repeat(3, minmax(0,1fr)); width:calc(100% - 3rem);}
  .chat{grid-column:1 / -1;}
}
@media (min-width:68.75em){
  .board{
    grid-template-columns:1.36fr 1.06fr 0.98fr 0.98fr; gap:0.75rem;
    width:min(calc(100% - 3rem), clamp(56.25rem, 66vw, 83.75rem));
  }
  .chat{grid-column:auto;}
}
.card{
  position:relative; min-width:0;
  background:var(--card-solid); border:1px solid var(--card-line); border-radius:0.875rem;
  box-shadow:0 1.125rem 2.75rem rgba(10,6,40,0.38); padding:0.875rem 1rem 1rem;
}
@supports ((-webkit-backdrop-filter:blur(1px)) or (backdrop-filter:blur(1px))){
  .card{background:var(--card); -webkit-backdrop-filter:blur(0.875rem); backdrop-filter:blur(0.875rem);}
}
.card::before{
  content:""; position:absolute; left:0.625rem; right:0.625rem; top:-1px; height:0.125rem; border-radius:0.125rem;
  background:linear-gradient(90deg, rgba(99,102,241,0.15), var(--indigo) 25%, var(--purple) 60%, var(--pink) 85%, rgba(244,114,182,0.15));
}
.card h2{font-size:1.125rem;}
.mini-h{font-family:var(--sans); font-weight:700; font-size:0.9375rem; line-height:1.3;}
.card-row{display:flex; justify-content:space-between; align-items:baseline; gap:0.75rem; flex-wrap:wrap;}

/* chat */
.chat{display:flex; flex-direction:column; container-type:inline-size;}
.chat-head{position:relative; text-align:center; padding:0 3.75rem;}
.chat-head .sub{font-size:0.8125rem; color:var(--text-soft); margin-top:0.125rem;}
.head-icons{position:absolute; top:0; right:0; display:flex; gap:0.125rem;}
.icon{width:1.75rem; height:1.75rem; border:0; background:none; border-radius:0.375rem; color:var(--text-soft); cursor:pointer; display:inline-flex; align-items:center; justify-content:center;}
.icon:hover{color:var(--text); background:var(--well);}
.icon svg{width:0.9375rem; height:0.9375rem;}
.count-chip{display:inline-flex; align-items:center; gap:0.375rem; margin-top:0.5rem; padding:0.1875rem 0.5625rem; border-radius:999px; background:var(--well); font-size:0.71875rem; font-weight:600;}
.count-chip .dot{width:0.375rem; height:0.375rem; border-radius:50%; background:var(--text-dim);}
.count-chip.live .dot{background:#5ee0b0; box-shadow:0 0 0.375rem #5ee0b0;}
.count-chip.error .dot{background:var(--coral);}
.messages{
  display:flex; flex-direction:column; gap:0.625rem; margin:0.625rem -0.25rem 0; padding:0.125rem 0.5rem 0.125rem 0.25rem;
  height:21rem; max-height:56vh; overflow-y:auto; overscroll-behavior:contain;
  scrollbar-width:thin; scrollbar-color:rgba(192,132,252,0.55) transparent;
}
@media (min-width:68.75em){ .messages{height:clamp(13.75rem, calc(100vh - 33rem), 26.25rem); max-height:none;} .composer{gap:0.375rem;} .send{padding:0 0.875rem;} }
.msg{max-width:94%; padding:0.625rem 0.75rem; border-radius:0.625rem; font-size:0.96875rem; line-height:1.5; white-space:pre-wrap; overflow-wrap:anywhere; text-align:left;}
.msg.assistant{align-self:flex-start; background:var(--bubble);}
.msg.user{align-self:flex-end; background:#4f46e5; background-image:linear-gradient(180deg,#5b4ff0,#4f46e5); color:#fff;}
.msg.error{background:rgba(255,122,107,0.12); border:1px solid rgba(255,122,107,0.5);}
.msg.thinking{display:flex; align-items:center; gap:0.5625rem; color:var(--text-soft);}
.spin{width:0.8125rem; height:0.8125rem; border-radius:50%; border:0.125rem solid var(--card-line); border-top-color:var(--purple-soft); animation:spin .8s linear infinite; flex-shrink:0;}
@keyframes spin{to{transform:rotate(360deg);}}
.composer{display:flex; align-items:flex-end; gap:0.5rem; margin-top:0.75rem;}
.composer textarea{
  flex:1; min-width:0; resize:none; height:2.75rem; max-height:7rem; padding:0.6875rem 0.75rem; overflow-y:hidden;
  border:1.5px solid rgba(129,140,248,0.75); border-radius:0.5625rem; background:var(--bubble); color:var(--text);
  font-family:var(--sans); font-size:max(1rem, 16px); line-height:1.3; outline:none;
}
.composer textarea::placeholder{color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.composer textarea:focus{border-color:var(--purple-soft); box-shadow:0 0 0 0.1875rem rgba(168,85,247,0.25);}
.mic{
  width:2.75rem; height:2.75rem; flex-shrink:0; border-radius:50%; cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center;
  border:1.5px solid rgba(129,140,248,0.7); background:var(--bubble); color:var(--text);
}
.mic svg{width:1.25rem; height:1.25rem;}
.mic:hover{border-color:var(--purple-soft);}
.mic[aria-pressed="true"]{border-color:var(--pink); background:rgba(244,114,182,0.2); color:var(--pink); animation:pulse 1.3s ease-in-out infinite;}
@keyframes pulse{50%{box-shadow:0 0 0 0.375rem rgba(244,114,182,0.18);}}
@media (pointer:coarse){ .mic{width:3rem; height:3rem;} }
.voice-note{margin-top:0.5rem; font-size:0.8125rem; color:var(--text-soft); text-align:center;}
.voice-note.warn{color:var(--coral);}
.send{
  height:2.75rem; padding:0 1.125rem; border:0; border-radius:0.625rem; cursor:pointer; flex-shrink:0;
  background:#4f46e5; background-image:linear-gradient(180deg,#7c3aed,#4f46e5); color:#fff; font-weight:600; font-size:0.9375rem;
  box-shadow:0 0.5rem 1.25rem rgba(99,102,241,0.38);
}
.send:disabled{opacity:.55; cursor:not-allowed;}

/* When the chat card itself is narrow (the four-column desktop row), the text box gets its own full-width line
   and the mic and Send sit underneath on the right, so typing room never shrinks to a sliver. */
@container (max-width:20rem){
  .composer{flex-wrap:wrap; justify-content:flex-end;}
  .composer textarea{flex:1 1 100%;}
}

/* expanded chat */
.chat.expanded{
  position:fixed; z-index:60; inset:0; border-radius:0; grid-column:auto;
  padding:calc(1rem + env(safe-area-inset-top,0px)) calc(1rem + env(safe-area-inset-right,0px)) calc(1rem + env(safe-area-inset-bottom,0px)) calc(1rem + env(safe-area-inset-left,0px));
  background:var(--card-solid);
}
.chat.expanded .messages{height:auto; max-height:none; flex:1;}
.chat.expanded .messages,.chat.expanded .composer,.chat.expanded .chat-head{width:100%; max-width:51.25rem; margin-left:auto; margin-right:auto;}
body.chat-open{overflow:hidden;}
.ico-collapse{display:none;} .chat.expanded .ico-collapse{display:block;} .chat.expanded .ico-expand{display:none;}

/* top match */
.match-tag{display:inline-block; padding:0.1875rem 0.625rem; border-radius:999px; background:var(--well); color:var(--value); font-size:0.78125rem; font-weight:600;}
.match-name{font-family:var(--serif); font-weight:700; color:var(--value); font-size:clamp(1.375rem, 1.9vw, 1.75rem); line-height:1.12; margin:0.75rem 0 0.5rem; overflow-wrap:anywhere;}
.block-title{font-weight:700; font-size:0.90625rem;}
.block-text{font-size:0.84375rem; color:var(--text-soft); margin-top:0.1875rem;}
.divider{margin-top:0.875rem;}
#fitValue{color:var(--text-soft); font-weight:600; text-align:right;}
#fitValue.on{color:var(--text);}
.gauge{height:0.3125rem; border-radius:0.3125rem; margin-top:0.625rem; background:var(--well); overflow:hidden;}
.gauge-fill{display:block; height:100%; width:0; border-radius:inherit; background:linear-gradient(90deg,var(--indigo),var(--purple) 60%,var(--pink)); transition:width .6s ease;}

/* estimated total: the number people came for, shown big */
.total-box{
  display:flex; flex-direction:column; gap:0.125rem; margin-top:0.875rem; padding:0.75rem 0.875rem 0.8125rem;
  border-radius:0.75rem; border:1px solid rgba(168,85,247,0.45);
  background:rgba(99,102,241,0.16);
}
html[data-theme="light"] .total-box{background:rgba(99,102,241,0.08); border-color:rgba(124,58,237,0.35);}
.total-label{font-size:0.78125rem; font-weight:600; color:var(--text-soft);}
.total-amount{font-family:var(--serif); font-weight:700; font-size:clamp(2.25rem, 3.4vw, 2.875rem); line-height:1.05; letter-spacing:-0.02em; color:var(--text); overflow-wrap:anywhere;}
.total-box.empty .total-amount{font-size:1.5rem;}
.total-math{font-size:0.8125rem; color:var(--text-soft);}
.total-box.set{border-color:var(--purple-soft); box-shadow:0 0 0 0.1875rem rgba(168,85,247,0.18), 0 0.75rem 1.75rem rgba(99,102,241,0.25);}
/* the same total, inside the chat on phones where the cards sit below the conversation */
.chat-total{align-self:flex-start; max-width:94%; display:flex; flex-direction:column; gap:0.0625rem; padding:0.625rem 0.875rem; border-radius:0.625rem; border:1px solid var(--purple-soft); background:rgba(99,102,241,0.16); text-align:left;}
html[data-theme="light"] .chat-total{background:rgba(99,102,241,0.08);}
.chat-total .total-amount{font-size:2rem;}
@media (min-width:68.75em){ .chat-total{display:none;} }

/* shortlist */
.donut-wrap{display:flex; justify-content:center; margin:0.875rem 0 0.625rem;}
.donut{width:6rem; height:6rem; position:relative;}
.donut svg{width:100%; height:100%; transform:rotate(-90deg);}
.donut .track{stroke:var(--track);}
.donut .arc{transition:stroke-dashoffset .6s ease;}
.donut .center{position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center;}
.donut .pct{font-family:var(--serif); font-weight:700; font-size:1.375rem; line-height:1;}
.donut .lbl{font-size:0.65625rem; color:var(--text-soft); margin-top:0.1875rem;}
.center-text{text-align:center; font-size:0.84375rem; color:var(--text-soft);}
.picks{display:flex; flex-direction:column; gap:0.375rem; margin-top:0.75rem;}
.pick{
  display:flex; justify-content:space-between; align-items:center; gap:0.625rem; width:100%;
  padding:0.5rem 0.625rem; border-radius:0.5rem; border:1.5px solid transparent; background:var(--well);
  cursor:pointer; text-align:left; font-size:0.84375rem;
}
.pick span:first-child{min-width:0; overflow-wrap:anywhere; font-weight:600;}
.pick span:last-child{flex-shrink:0; color:var(--value); font-weight:700;}
.pick[aria-pressed="true"]{border-color:var(--purple-soft); box-shadow:0 0 0 0.125rem rgba(168,85,247,0.28);}
.pick:hover{border-color:var(--indigo-soft);}

/* listing details */
.terms{list-style:none; margin:0.75rem 0 0; padding:0; display:flex; flex-direction:column; gap:0.4375rem; font-size:0.84375rem;}
.terms li{display:flex; justify-content:space-between; gap:0.75rem;}
.terms li span:first-child{color:var(--text-soft); flex-shrink:0; max-width:48%;}
.terms li span:last-child{text-align:right; font-weight:500; min-width:0; overflow-wrap:anywhere;}
.terms.extra{margin-top:0.875rem; padding-top:0.75rem; border-top:1px solid var(--card-line);}
.next{margin-top:0.875rem;}
.cta-row{display:flex; flex-wrap:wrap; gap:0.5rem; margin-top:0.625rem;}
.cta{
  display:inline-flex; align-items:center; justify-content:center; min-height:2.5rem; padding:0.5rem 0.875rem; border-radius:0.625rem;
  background:#4f46e5; background-image:linear-gradient(180deg,#7c3aed,#4f46e5); color:#fff; font-weight:600; font-size:0.84375rem; text-decoration:none;
}
.cta.ghost{background:var(--well); color:var(--text); border:1px solid var(--card-line);}
.cta:hover{filter:brightness(1.08);}

/* mobile: center headings and copy; label/value lists stay left/right */
@media (max-width:43.6875em){
  .result{text-align:center;}
  .result .card-row{justify-content:center;}
  #fitValue{text-align:center;}
  .result .terms li{text-align:left;}
  .cta-row{justify-content:center;}
}
@media (min-width:43.75em){ .chat-head{text-align:left; padding:0 3.75rem 0 0;} }

/* ───────── notes ───────── */
.notes{background:var(--page); padding:2.75rem 1.25rem 1.25rem;}
.notes-inner{width:100%; max-width:83.75rem; margin:0 auto; display:grid; grid-template-columns:minmax(0,1fr); gap:0.875rem 2.5rem;}
@media (min-width:56.25em){ .notes-inner{grid-template-columns:repeat(2,minmax(0,1fr));} }
.notes h2{font-size:1.5rem; grid-column:1 / -1; text-align:center;}
.notes p{font-size:0.90625rem; color:var(--text-soft); line-height:1.65; text-align:center;}
.notes strong{color:var(--text);}
@media (min-width:43.75em){ .notes h2,.notes p{text-align:left;} }
footer{
  background:var(--page); text-align:center; font-size:0.8125rem; color:var(--text-dim);
  padding:1.5rem calc(1.25rem + env(safe-area-inset-right,0px)) calc(1.75rem + env(safe-area-inset-bottom,0px)) calc(1.25rem + env(safe-area-inset-left,0px));
}
footer a{color:var(--text-soft);}

@media (prefers-reduced-motion:reduce){ *{animation:none !important; transition:none !important; scroll-behavior:auto !important;} }
