:root {
  --bg: #000;
  --text: #f5f5f7;
  --muted: #86868b;
  --stroke: rgba(255, 255, 255, 0.1);
  --user: linear-gradient(180deg, #f2f2f5, #dcdce2);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Display", BlinkMacSystemFont, "Segoe UI",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body { overflow: hidden; }

#blob {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}

/* ----------------------------- LOGIN ----------------------------- */
.login {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  padding: 0 26px calc(env(safe-area-inset-bottom) + 64px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.login.hidden { opacity: 0; transform: translateY(-12px); pointer-events: none; }
.login::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(130% 65% at 50% 88%,
    rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.35) 42%, transparent 72%);
  pointer-events: none;
}

.login .eyebrow {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.title {
  font-size: clamp(42px, 11vw, 74px);
  line-height: 1.06;
  padding-bottom: 0.12em;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: #ffffff;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.7);
}
.subtitle {
  margin: 20px auto 30px;
  max-width: 460px;
  font-size: clamp(15px, 4vw, 18px);
  line-height: 1.5;
  color: #c8c8cd;
}
.cta {
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  color: #000;
  background: var(--user);
  border: none;
  padding: 15px 44px;
  border-radius: 980px;
  cursor: pointer;
  box-shadow: 0 10px 50px rgba(255, 255, 255, 0.16);
  transition: transform 0.15s ease;
}
.cta:active { transform: scale(0.96); }
.login-note { margin-top: 16px; font-size: 13px; color: var(--muted); }

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, 100%);
  margin: 4px auto 0;
}
.login-form input {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
  text-align: center;
}
.login-form input::placeholder { color: #7a7a80; }
.login-form input:focus { border-color: rgba(255, 255, 255, 0.28); }
.login-form .cta { width: 100%; margin-top: 4px; }
.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  color: #f5f5f7;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--stroke);
  padding: 12px 22px;
  border-radius: 980px;
  cursor: pointer;
}
.google-btn:hover { background: rgba(255, 255, 255, 0.14); }
.login-err {
  min-height: 18px;
  margin-top: 12px;
  font-size: 14px;
  color: #ff6961;
}
.signature {
  margin-top: 28px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #6d6d72;
  font-weight: 500;
}

/* ----------------------------- ONBOARDING ----------------------------- */
.onboard {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
}
.onboard.active { display: flex; animation: fade 0.4s ease; }
.onboard-card {
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(28, 28, 30, 0.7);
  border: 1px solid var(--stroke);
  border-radius: 24px;
  padding: 30px 26px;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.6);
}
.onboard-card h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.onboard-card > p {
  font-size: 15px;
  color: var(--muted);
  margin-top: -8px;
}
.onboard-card label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: #c8c8cd;
}
.onboard-card input {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 13px 15px;
  outline: none;
}
.onboard-card input::placeholder { color: #5c5c61; }
.onboard-card input:focus { border-color: rgba(255, 255, 255, 0.28); }
.onboard-card .cta { margin-top: 6px; width: 100%; padding: 15px; }

/* ----------------------------- MODAIS (conta / termos) ----------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}
.modal.active { display: flex; animation: fade 0.3s ease; }
.modal-card {
  position: relative;
  width: min(440px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(28, 28, 30, 0.94);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  padding: 26px 24px;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.6);
}
.modal-card h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.modal-sub { font-size: 14px; color: var(--muted); margin-top: -6px; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.08); color: var(--text);
  border: none; cursor: pointer; font-size: 18px; line-height: 1;
}
.modal-link {
  font: inherit; font-size: 14px; color: var(--muted);
  background: none; border: none; cursor: pointer; padding: 4px;
}

.terms {
  max-height: 34vh; overflow-y: auto;
  font-size: 13.5px; line-height: 1.55; color: #c8c8cd;
  background: rgba(0,0,0,0.25); border: 1px solid var(--stroke);
  border-radius: 12px; padding: 14px;
}
.terms p { margin-bottom: 9px; }
.terms strong { color: #eaeaec; }
.terms-accept { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #d8d8dc; cursor: pointer; }
.terms-accept input { width: 18px; height: 18px; accent-color: #30d158; }
.terms-wallet { font-size: 13px; color: var(--muted); }
.cta:disabled { opacity: 0.4; cursor: default; }

/* corpo da conta */
.account-body { display: flex; flex-direction: column; gap: 14px; }
.acc-row { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.acc-row .label { color: var(--muted); }
.acc-badge { font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 980px; }
.acc-badge.free { background: rgba(255,255,255,0.1); color: #d8d8dc; }
.acc-badge.active { background: rgba(48,209,88,0.16); color: #30d158; }
.acc-badge.canceled { background: rgba(255,159,10,0.16); color: #ff9f0a; }
.acc-note { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.acc-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

/* botao de assinar dentro de uma mensagem (upsell) */
.upsell-btn {
  display: inline-block; margin-top: 10px;
  font: inherit; font-size: 14px; font-weight: 600; color: #000;
  background: linear-gradient(180deg, #fafafa, #d9d9de);
  border: none; padding: 9px 20px; border-radius: 980px; cursor: pointer;
}

/* ----------------------------- CHAT = A JANELA ----------------------------- */
.app {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
}
.app.active { display: flex; animation: fade 0.4s ease; }
@keyframes fade { from { opacity: 0; } }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 16px) 20px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #f5f5f7;
}
.brand .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #30d158;
  box-shadow: 0 0 8px rgba(48, 209, 88, 0.6);
}
.ghost {
  font: inherit; font-size: 14px; color: var(--muted);
  background: transparent; border: none;
  padding: 6px 4px; cursor: pointer;
}
.ghost:active { color: var(--text); }

.top-actions { position: relative; }
.menu-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  color: var(--muted); background: transparent;
  border: 1px solid transparent; cursor: pointer;
}
.menu-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  min-width: 172px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  background: rgba(30, 30, 32, 0.92);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: menuIn 0.14s ease;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } }
.menu-item {
  font: inherit;
  font-size: 15px;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: none;
  padding: 11px 14px;
  border-radius: 9px;
  cursor: pointer;
}
.menu-item:hover { background: rgba(255, 255, 255, 0.08); }
.menu-item.danger { color: #ff6961; }

.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.messages::-webkit-scrollbar { width: 7px; }
.messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 8px; }

.msg {
  max-width: 86%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop 0.25s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.msg.user {
  align-self: flex-end;
  background: var(--user);
  color: #000;
  border-bottom-right-radius: 5px;
}
.msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--stroke);
  border-bottom-left-radius: 5px;
}
.msg img { max-width: 200px; border-radius: 12px; margin-bottom: 6px; display: block; }
.msg strong { font-weight: 600; }

/* paragrafos e listas com respiro (respostas nao ficam emboladas) */
.msg p { margin: 0 0 0.62em; }
.msg p:last-child { margin-bottom: 0; }
.msg-list { margin: 0.1em 0 0.62em; padding-left: 1.15em; }
.msg-list li { margin: 0.22em 0; }
.msg-list:last-child { margin-bottom: 0; }

/* mensagem pronta pro cliente com botao copiar */
.copyable {
  display: block;
  margin: 8px 0;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 3px solid #30d158;
  border-radius: 12px;
}
.cp-text { display: block; font-style: normal; color: #f0f0f2; }
.copybtn {
  margin-top: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #000;
  background: linear-gradient(180deg, #f2f2f5, #dcdce2);
  border: none;
  padding: 6px 16px;
  border-radius: 980px;
  cursor: pointer;
}
.copybtn.done { background: #30d158; color: #fff; }

.golink {
  display: inline-block;
  margin: 2px 0;
  font-size: 14px;
  font-weight: 500;
  color: #0a84ff;
  text-decoration: none;
  border-bottom: 1px solid rgba(10, 132, 255, 0.4);
}
.audio-chip { font-size: 14px; opacity: 0.85; }

.typing { display: inline-flex; gap: 5px; padding: 3px 2px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* composer */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 8px;
  border-top: 1px solid var(--stroke);
}
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  color: var(--muted); background: rgba(255,255,255,0.05);
  border: 1px solid var(--stroke); cursor: pointer;
}
.icon-btn:active { color: var(--text); }
.icon-btn.rec { color: #ff453a; border-color: #ff453a; animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255,69,58,0.18); } }

.attachment {
  position: relative; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  min-width: 44px; height: 44px; padding: 0 8px;
  border-radius: 12px; background: rgba(255,255,255,0.06);
  border: 1px solid var(--stroke); font-size: 13px; color: var(--muted);
}
.attachment img { width: 40px; height: 40px; object-fit: cover; border-radius: 9px; }
.attachment button {
  position: absolute; top: -8px; right: -8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #1c1c1e; color: #fff; border: 1px solid var(--stroke);
  cursor: pointer; font-size: 14px; line-height: 1;
}

#input {
  flex: 1;
  resize: none;
  max-height: 140px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  padding: 11px 16px;
  outline: none;
}
#input::placeholder { color: var(--muted); }
#input:focus { border-color: rgba(255,255,255,0.22); }

.send {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  color: #000; background: var(--user);
  border: none; cursor: pointer;
}
.send:active { transform: scale(0.94); }
.send:disabled { opacity: 0.4; }

.disclaimer {
  text-align: center;
  font-size: 11px;
  color: #5c5c61;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 8px);
  letter-spacing: 0.01em;
}

@media (min-width: 720px) {
  .app { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--stroke); border-right: 1px solid var(--stroke); }
  .msg { font-size: 15.5px; }
}
