/* ChitChat. Plain CSS, no build step. Tokens use light-dark(): the theme switch only sets color-scheme. */

@font-face {
  font-family: "Geist";
  src: url("/assets/Geist-Variable-a81b9fbd.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/assets/GeistMono-Variable-82972491.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: light-dark(#f7f7f5, #0b0b0c);
  --surface: light-dark(#ffffff, #141416);
  --raised: light-dark(#efefec, #1d1d20);
  --line: light-dark(rgb(12 12 14 / .09), rgb(255 255 255 / .08));
  --line-strong: light-dark(rgb(12 12 14 / .16), rgb(255 255 255 / .15));
  --text: light-dark(#0b0b0c, #ededef);
  --muted: light-dark(#66666c, #93939a);
  --accent: light-dark(#cf4419, #ff7043);
  --grad: linear-gradient(135deg, #d4461a, #c02e55); /* white text stays above 4.5:1 on both ends */
  --glow: light-dark(rgb(255 98 46 / .16), rgb(255 98 46 / .2));
  --green: light-dark(#14883e, #3ddc84);
  --danger: light-dark(#c62828, #ff6b6b);
  --shadow: light-dark(0 1px 2px rgb(0 0 0 / .05), 0 1px 2px rgb(0 0 0 / .4));
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --gutter: 16px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
h1, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px;
  font-weight: 550; white-space: nowrap;
  transition: transform .15s var(--ease), background-color .2s, border-color .2s, box-shadow .2s, filter .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--grad); color: #fff;
  box-shadow: 0 1px 0 rgb(255 255 255 / .25) inset, 0 8px 24px -8px rgb(212 70 26 / .55);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary .icon { transition: transform .2s var(--ease); }
.btn.primary:hover .icon { transform: translateX(3px); }
.btn.ghost { background: var(--surface); border-color: var(--line-strong); box-shadow: var(--shadow); }
.btn.ghost:hover { background: var(--raised); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--muted);
  transition: color .2s, background-color .2s, transform .15s var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--raised); }
.icon-btn:active { transform: scale(.94); }

/* ---------- Logo & theme switch ---------- */

.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.02em; font-size: 16px; }
.logo .mark { width: 28px; height: 28px; }
.logo .back { fill: var(--text); opacity: .9; }
.logo .front { fill: #ff6a3d; stroke: var(--bg); stroke-width: 1.6; paint-order: stroke; }

.segmented {
  display: inline-flex; gap: 2px; margin: 0; padding: 3px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface);
}
.segmented label {
  display: grid; place-items: center; width: 30px; height: 28px;
  border-radius: 8px; color: var(--muted); cursor: pointer;
  transition: color .2s, background-color .2s;
}
.segmented label:hover { color: var(--text); }
.segmented label:has(:checked) { background: var(--raised); color: var(--text); box-shadow: var(--shadow); }
.segmented label:has(:focus-visible) { outline: 2px solid var(--accent); }
.segmented .icon { width: 15px; height: 15px; }

/* ---------- Home ---------- */

.home {
  position: relative; isolation: isolate;
  display: grid; grid-template-rows: auto 1fr auto;
  min-height: 100dvh; overflow-x: clip;
  padding: max(env(safe-area-inset-top), 0px) var(--gutter) max(env(safe-area-inset-bottom), 20px);
}
.backdrop { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.backdrop::before { /* faint grid that fades out from the center */
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 20%, transparent 75%);
}
.backdrop::after { /* ember glow */
  content: ""; position: absolute; left: 50%; top: 18%;
  width: min(760px, 120vw); aspect-ratio: 2; translate: -50% -50%;
  background: radial-gradient(closest-side, var(--glow), transparent);
  filter: blur(20px);
  animation: breathe 9s ease-in-out infinite alternate;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  width: min(1080px, 100%); margin: 0 auto; padding: 18px 0;
}

.hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 18px; padding: 20px 0;
}
.hero > * { animation: rise .7s var(--ease) both; }
.hero > :nth-child(2) { animation-delay: .06s; }
.hero > :nth-child(3) { animation-delay: .12s; }
.hero > :nth-child(4) { animation-delay: .18s; }

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px; border: 1px solid var(--line); border-radius: 99px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(8px);
  color: var(--muted); font: 500 12.5px/1 var(--mono); letter-spacing: -.01em;
}
.live { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.live::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--green);
  animation: ping 1.8s var(--ease) infinite;
}

.hero h1 {
  font-size: clamp(40px, min(7.4vw, 8.4vh), 74px); line-height: .98; font-weight: 640; letter-spacing: -.055em;
  text-wrap: balance;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, #ff7a45, #ff3d77 60%, #b05cff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { max-width: 30em; color: var(--muted); font-size: 17px; text-wrap: pretty; }

.join {
  display: grid; gap: 12px; width: min(580px, 100%); margin-top: 4px; padding: 14px;
  border: 1px solid var(--line); border-radius: 20px; text-align: left;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  backdrop-filter: blur(12px); box-shadow: 0 24px 60px -32px rgb(0 0 0 / .35);
}
.join .btn { width: 100%; }

.choices { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.choices-label { flex: none; width: 112px; padding-left: 2px; color: var(--muted); font: 500 12px/1 var(--mono); text-transform: uppercase; letter-spacing: .04em; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 99px; background: var(--surface);
  font-size: 14px; font-weight: 500; cursor: pointer; user-select: none;
  transition: background-color .2s, border-color .2s, color .2s, transform .15s var(--ease);
}
.chip:hover { background: var(--raised); }
.chip:active { transform: scale(.96); }
.chip .icon { width: 15px; height: 15px; }
.chip:has(:checked) { border-color: transparent; background: var(--grad); color: #fff; box-shadow: 0 6px 16px -8px rgb(212 70 26 / .6); }
.chip:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip.soon { color: var(--muted); border-style: dashed; cursor: not-allowed; }
.chip.soon:hover { background: var(--surface); }
.chip.soon:active { transform: none; }
.chip small { padding: 2px 6px; border-radius: 99px; background: var(--raised); font: 500 10.5px/1.2 var(--mono); }
.field {
  position: relative; flex: 1; display: flex; align-items: center;
  border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
.field.invalid { border-color: var(--danger); }
.field input {
  flex: 1; min-width: 0; height: 44px; padding: 0 6px 0 14px;
  border: 0; background: none; outline: none; font-size: 16px;
}
.field input::placeholder { color: var(--muted); }
.dice { width: 34px; height: 34px; margin-right: 4px; border: 0; background: none; }
.dice:hover { background: var(--raised); }
.error { color: var(--danger); font-size: 14px; }

.features {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px;
  width: min(1080px, 100%); margin: 0 auto; padding: 22px 0 0; list-style: none;
  border-top: 1px solid var(--line);
}
.features li { display: flex; gap: 12px; color: var(--muted); font-size: 14px; animation: rise .7s .3s var(--ease) both; }
.features .icon {
  width: 34px; height: 34px; padding: 8px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--accent);
}
.features strong { display: block; color: var(--text); font-weight: 600; }

/* ---------- Chat ---------- */

.chat {
  --column: min(820px, 100% - 2 * var(--gutter));
  display: grid; grid-template-rows: auto 1fr auto;
  height: 100dvh;
}

.chatbar {
  display: flex; align-items: center; gap: 14px;
  padding: max(env(safe-area-inset-top), 10px) var(--gutter) 10px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  position: relative; z-index: 2;
}
.home-link .word { display: none; }
.home-link { padding-right: 14px; border-right: 1px solid var(--line); }
.actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.status { display: flex; align-items: center; gap: 11px; min-width: 0; animation: fade .35s var(--ease); }
.status .who { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; line-height: 1.25; }
.status strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { color: var(--muted); }
.avatar .icon { width: 60%; height: 60%; }
.status small { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; color: var(--muted); font-size: 12.5px; }
.status .dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.status .typing { display: none; color: var(--accent); }
.status.is-typing .typing { display: flex; }
.status.is-typing .presence { display: none; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: hop 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }

.avatar {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  color: #fff; font-weight: 650; font-size: 15px;
  box-shadow: 0 0 0 1px rgb(255 255 255 / .12) inset;
}
.avatar.g0 { background: linear-gradient(135deg, #ff8a5b, #d4461a); }
.avatar.g1 { background: linear-gradient(135deg, #a78bfa, #6d28d9); }
.avatar.g2 { background: linear-gradient(135deg, #34d399, #0f766e); }
.avatar.g3 { background: linear-gradient(135deg, #60a5fa, #1d4ed8); }
.searching-avatar { border: 2px dashed var(--line-strong); box-shadow: none; animation: spin 6s linear infinite; }

.skip .label { display: grid; }
.skip .label > * { grid-area: 1 / 1; transition: opacity .2s, transform .2s var(--ease); }
.skip .sure { opacity: 0; transform: translateY(6px); }
.skip.confirm, .skip.confirm:hover { background: var(--grad); border-color: transparent; color: #fff; }
.skip.confirm:hover { filter: brightness(1.08); }
.skip.confirm .idle { opacity: 0; transform: translateY(-6px); }
.skip.confirm .sure { opacity: 1; transform: none; }
.chat:not(:has(#status[data-state="chatting"])) .skip { display: none; }

.thread {
  display: flex; flex-direction: column;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  padding: 20px calc((100% - var(--column)) / 2) 12px;
}

.searching { display: none; margin: auto; padding: 24px 0; text-align: center; animation: fade .5s var(--ease); }
.chat:has(#status[data-state="waiting"]) .searching { display: grid; justify-items: center; gap: 8px; }
.radar { position: relative; display: grid; place-items: center; width: 168px; height: 168px; margin-bottom: 18px; }
.radar span {
  position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--accent);
  opacity: 0; animation: ripple 3s var(--ease) infinite;
}
.radar span:nth-child(2) { animation-delay: 1s; }
.radar span:nth-child(3) { animation-delay: 2s; }
.radar .avatar { width: 64px; height: 64px; font-size: 24px; box-shadow: 0 0 0 8px var(--glow); }
.searching .title { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.searching .hint { max-width: 22em; color: var(--muted); }

turbo-cable-stream-source { display: none; }
#messages { display: flex; flex-direction: column; gap: 3px; }

.msg { display: flex; max-width: min(78%, 560px); margin-top: 10px; animation: pop .28s var(--ease) both; }
.msg.cont { margin-top: 0; }
.msg.mine { align-self: flex-end; }
.bubble {
  display: flow-root; padding: 8px 12px 7px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}
.msg:not(.mine).cont .bubble { border-top-left-radius: 7px; }
.msg.mine .bubble { background: var(--grad); border-color: transparent; color: #fff; }
.msg.mine.cont .bubble { border-top-right-radius: 7px; }
.text { white-space: pre-wrap; }
.meta {
  float: right; position: relative; top: 7px; margin: 0 -4px 0 10px;
  display: inline-flex; align-items: center; gap: 3px;
  font: 500 10.5px/1 var(--mono); opacity: .62;
}
.status-icon { display: none; }
.msg.mine .status-icon { display: inline-flex; }
.status-icon .icon { width: 13px; height: 13px; stroke-width: 2.2; }
.i-pending, .i-failed, .pending .i-sent, .failed .i-sent { display: none; }
.pending .i-pending, .failed .i-failed { display: block; }
.msg.pending .bubble { opacity: .75; }
.msg.failed { flex-direction: column; align-items: flex-end; cursor: pointer; }
.msg.failed .bubble { background: none; color: var(--text); border: 1px dashed var(--danger); }
.msg.failed .meta { color: var(--danger); opacity: 1; }
.msg.failed::after { content: "Não enviada. Toque para tentar de novo."; color: var(--danger); font-size: 12px; margin-top: 3px; }
.msg.jumbo .bubble { background: none; border: 0; box-shadow: none; padding: 0; color: var(--text); }
.msg.jumbo .text { font-size: 44px; line-height: 1.15; }
.msg.jumbo .meta { float: none; top: 0; margin: 0 0 0 6px; }

.notice {
  display: flex; align-items: center; gap: 8px; align-self: center;
  margin: 14px 0 6px; padding: 7px 14px; max-width: 100%;
  border: 1px solid var(--line); border-radius: 99px; background: var(--surface);
  color: var(--muted); font-size: 13px; animation: pop .35s var(--ease) both;
}
.notice strong { color: var(--text); font-weight: 600; }
.notice .icon { width: 16px; height: 16px; color: var(--accent); }
.notice.left .icon { color: var(--muted); }

.dock { padding: 8px calc((100% - var(--column)) / 2) max(env(safe-area-inset-bottom), 14px); }
.composer {
  position: relative; display: flex; align-items: flex-end; gap: 8px;
  padding: 6px 6px 6px 16px;
  border: 1px solid var(--line-strong); border-radius: 24px; background: var(--surface);
  box-shadow: var(--shadow), 0 10px 30px -18px rgb(0 0 0 / .35);
  transition: border-color .2s, box-shadow .2s, opacity .2s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
.composer:has(textarea:disabled) { opacity: .55; }
.composer textarea {
  flex: 1; min-width: 0; resize: none; field-sizing: content;
  min-height: 34px; max-height: calc(6 * 1.4em + 14px); padding: 7px 0;
  border: 0; outline: none; background: none; line-height: 1.4; font-size: 16px;
  scrollbar-width: thin;
}
.composer textarea::placeholder { color: var(--muted); }
.send {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 50%; background: var(--grad); color: #fff;
  transition: transform .15s var(--ease), opacity .2s;
}
.send .icon { stroke-width: 2.4; }
.send:active { transform: scale(.9); }
.send:disabled { opacity: .5; cursor: default; }
.composer-error { position: absolute; right: 14px; bottom: calc(100% + 6px); color: var(--danger); font-size: 12.5px; }

.ended {
  display: none; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 18px; border: 1px solid var(--line-strong); border-radius: 18px;
  background: var(--surface); animation: pop .35s var(--ease) both;
}
.ended p { color: var(--muted); }
.chat:has(#status[data-state="ended"]) .ended { display: flex; }
.chat:has(#status[data-state="ended"]) .composer { display: none; }

/* ---------- Flash ---------- */

.toast {
  position: fixed; top: 16px; left: 50%; z-index: 10; translate: -50% 0;
  padding: 10px 16px; border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--surface); box-shadow: 0 12px 32px -12px rgb(0 0 0 / .35);
  font-size: 14px; animation: toast 4s var(--ease) forwards;
}
.toast-alert { color: var(--danger); }

/* ---------- Motion ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(14px); filter: blur(4px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes ping { 75%, 100% { transform: scale(2.6); opacity: 0; } }
@keyframes ripple { 0% { transform: scale(.35); opacity: .7; } 100% { transform: scale(1); opacity: 0; } }
@keyframes breathe { from { opacity: .7; scale: 1; } to { opacity: 1; scale: 1.12; } }
@keyframes hop { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }
@keyframes spin { to { rotate: 360deg; } }
@keyframes toast { 0% { opacity: 0; translate: -50% -12px; } 8%, 85% { opacity: 1; translate: -50% 0; } 100% { opacity: 0; translate: -50% -12px; visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Small screens ---------- */

@media (max-width: 680px) {
  .theme-slot, .skip .icon { display: none; }
  .skip { padding: 0 14px; }
  .home-link { display: none; }
  .msg { max-width: 86%; }
}
@media (max-width: 560px) {
  .features { grid-template-columns: 1fr; gap: 14px; }
  .choices-label { width: 100%; margin-bottom: 2px; }
  .lead { font-size: 16px; }
}
@media (max-height: 640px) and (max-width: 560px) {
  .features { display: none; }
}
