:root {
  --navy: #122b52;
  --blue: #2563c9;
  --blue-soft: #e8f0fc;
  --bg: #f6f9ff;
  --surface: #ffffff;
  --text: #13213a;
  --muted: #62708a;
  --line: #dbe3ef;
  --bubble-user: #2563c9;
  --bubble-user-text: #ffffff;
  --bubble-bot: #ffffff;
  --shadow: 0 1px 2px rgba(18, 43, 82, .06), 0 6px 20px rgba(18, 43, 82, .07);
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

.screen { min-height: 100dvh; }

/* ---------- Logo ---------- */
.logo { font-weight: 800; font-size: 40px; letter-spacing: -1px; color: #fff; }
.logo span { color: #7fb0ff; }
.logo.small { font-size: 22px; color: var(--navy); }
.logo.small span { color: var(--blue); }

/* ---------- Welcome ---------- */
.welcome {
  background:
    radial-gradient(90% 60% at 50% 0%, #dbe8ff 0%, rgba(219, 232, 255, 0) 70%),
    radial-gradient(70% 50% at 100% 100%, #fde7f1 0%, rgba(253, 231, 241, 0) 70%),
    #ffffff;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  text-align: center;
}
.welcome-inner { width: 100%; max-width: 420px; }
.welcome .logo { color: var(--navy); }
.welcome .logo span { color: var(--blue); }
.hero-faces { display: flex; justify-content: center; margin-bottom: 18px; }
.hero-faces .avatar { --size: 46px; margin-left: -10px; box-shadow: 0 0 0 3px #fff; }
.hero-faces .avatar:first-child { margin-left: 0; }
.eyebrow {
  display: inline-block; margin-bottom: 10px; padding: 5px 12px; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue); font-size: 13px; font-weight: 700; letter-spacing: .2px;
}
.tagline { color: var(--muted); font-size: 17px; line-height: 1.45; margin: 14px 0 6px; }
.punch { font-weight: 700; font-size: 17px; margin: 0 0 34px; color: var(--navy); }
.name-form { display: grid; gap: 12px; text-align: left; }
.name-form label { font-size: 14px; color: var(--muted); font-weight: 600; }
.name-form input {
  font-size: 17px; padding: 15px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  outline: none; box-shadow: var(--shadow);
}
.name-form input::placeholder { color: #9aa6ba; }
.name-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.btn-primary {
  border: 0; border-radius: 14px; padding: 15px 18px; font-weight: 700; font-size: 17px;
  background: var(--blue); color: #fff; box-shadow: 0 6px 20px rgba(37, 99, 201, .35);
  transition: transform .1s;
}
.btn-primary:active { transform: scale(.98); }
.fine { font-size: 12px; color: var(--muted); margin-top: 18px; }

/* ---------- Picker ---------- */
.picker { padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.picker-head h1 { font-size: 24px; margin: 14px 0 4px; letter-spacing: -.3px; }
.picker-head p { color: var(--muted); margin: 0 0 18px; font-size: 15px; }
.persona-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .persona-grid { grid-template-columns: 1fr 1fr; } }
.persona-card {
  display: flex; gap: 14px; align-items: center; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); width: 100%;
  transition: transform .12s, border-color .12s;
}
.persona-card:active { transform: scale(.985); border-color: var(--blue); }
.persona-card .info { min-width: 0; flex: 1; }
.persona-card .name { font-weight: 700; font-size: 17px; }
.persona-card .line { color: var(--muted); font-size: 14px; margin-top: 2px; line-height: 1.35; }
.persona-card .price {
  display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--blue);
  background: var(--blue-soft); padding: 3px 9px; border-radius: 999px;
}
.persona-card .resume { font-size: 12px; color: var(--muted); margin-left: 6px; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 16px; display: block; margin: 8px auto 0; font-size: 14px; }

/* ---------- Avatars ---------- */
.avatar {
  --size: 64px;
  width: var(--size); height: var(--size); flex: 0 0 var(--size);
  border-radius: 50%; overflow: hidden; position: relative;
  display: grid; place-items: center; font-size: calc(var(--size) * .5);
  background: var(--c, var(--blue)); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c, var(--blue));
}
.avatar img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.avatar.sm { --size: 38px; box-shadow: none; }
.avatar.xs { --size: 28px; box-shadow: none; font-size: 15px; }

/* ---------- Chat ---------- */
.chat { height: 100dvh; display: flex; flex-direction: column; }
.chat-head {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 10px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  z-index: 2;
}
.icon-btn { background: none; border: 0; font-size: 28px; line-height: 1; width: 40px; height: 40px; border-radius: 12px; color: var(--text); }
.icon-btn:active { background: var(--blue-soft); }
.chat-title { flex: 1; min-width: 0; }
.chat-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.chat-status i { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; display: inline-block; }
.menu {
  position: absolute; right: 10px; top: calc(100% - 4px); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; min-width: 240px;
}
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 12px; border-radius: 10px; font-size: 15px; }
.menu button:active { background: var(--blue-soft); }

.messages {
  flex: 1; overflow-y: auto; padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.row { display: flex; gap: 8px; align-items: flex-end; max-width: 720px; width: 100%; margin: 0 auto; }
.row.user { justify-content: flex-end; }
.bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 20px; font-size: 16px; line-height: 1.42;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
  animation: pop .18s ease-out;
}
.row.bot .bubble { background: var(--bubble-bot); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.row.user .bubble { background: var(--bubble-user); color: var(--bubble-user-text); border-bottom-right-radius: 6px; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .25; transform: translateY(-2px); } }
.system-note { text-align: center; font-size: 12px; color: var(--muted); margin: 4px 0; }

.composer-wrap {
  background: var(--bg);
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
}
.composer {
  display: flex; align-items: flex-end; gap: 8px; max-width: 720px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 6px 6px 6px 16px;
  box-shadow: var(--shadow);
}
.composer textarea {
  flex: 1; border: 0; outline: none; resize: none; background: transparent; color: var(--text);
  font: inherit; font-size: 16px; line-height: 1.4; padding: 8px 0; max-height: 140px;
}
.send {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; border: 0;
  background: var(--blue); color: #fff; font-size: 20px; font-weight: 700;
}
.send:disabled { background: var(--line); color: var(--muted); }
.disclaimer { text-align: center; font-size: 11px; color: var(--muted); margin: 6px 0 0; }
.disclaimer a { color: inherit; }

/* ---------- Modal + toast ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(8, 18, 36, .6); display: grid; place-items: center; padding: 20px; z-index: 10;
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  background: var(--surface); border-radius: 22px; padding: 26px 22px 12px; max-width: 360px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); animation: pop .25s ease-out;
}
.modal-card h2 { margin: 6px 0 8px; font-size: 21px; }
.modal-card p { color: var(--muted); margin: 0 0 18px; }
.modal-card .btn-primary { width: 100%; }
.modal-emoji { font-size: 44px; }
.modal-avatar { display: flex; justify-content: center; margin-bottom: 6px; }
.modal-avatar .avatar { --size: 84px; }
.toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 11; max-width: calc(100% - 32px); text-align: center; animation: pop .2s;
}
