:root {
  --bg: #fff7f3;
  --surface: #ffffff;
  --ink: #1d1224;
  --muted: #7a6b80;
  --line: #efe3de;
  --accent: #ff4f6d;
  --accent-2: #ff8a5b;
  --accent-ink: #ffffff;
  --user: linear-gradient(135deg, #ff5a78, #ff7b5c);
  --draft: #f1ecf3;
  --chip: #ffffff;
  --shadow: 0 1px 2px rgba(29, 18, 36, .06), 0 6px 20px rgba(29, 18, 36, .06);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #150d1c;
    --surface: #221830;
    --ink: #f6eef7;
    --muted: #a898ae;
    --line: #2f2440;
    --draft: #2c2139;
    --chip: #2a1f38;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
body.chat { overflow: hidden; overscroll-behavior: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 52px; padding: 0 18px; border-radius: 16px;
  border: 0; font-weight: 600; font-size: 17px; text-decoration: none;
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-apple { background: #000; color: #fff; }
.btn-google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.btn-ghost { background: transparent; color: var(--muted); font-weight: 500; font-size: 15px; }
@media (prefers-color-scheme: dark) { .btn-apple { background: #fff; color: #000; } }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink);
}
.icon-btn:active { background: var(--line); }

/* ---------------------------------------------------------------- auth pages */

.auth-wrap {
  max-width: 440px; margin: 0 auto; min-height: 100dvh;
  padding: calc(var(--safe-t) + 48px) 24px calc(var(--safe-b) + 28px);
  display: flex; flex-direction: column; gap: 22px;
}
.auth-hero { text-align: center; }
.logo-lg { border-radius: 22px; box-shadow: var(--shadow); }
.auth-hero h1 { font-size: 30px; line-height: 1.15; margin: 18px 0 8px; letter-spacing: -.02em; }
.tagline { color: var(--muted); margin: 0 auto; max-width: 320px; font-size: 17px; }
.auth-buttons { display: flex; flex-direction: column; gap: 12px; }
.email-form { display: flex; flex-direction: column; gap: 10px; }
.email-form input {
  height: 52px; padding: 0 16px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--surface); font-size: 17px; outline: none;
}
.email-form input:focus { border-color: var(--accent); }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.fine { color: var(--muted); font-size: 13px; text-align: center; margin: auto 0 0; }
.notice { padding: 12px 14px; border-radius: 14px; font-size: 15px; }
.notice.ok { background: #e8f7ee; color: #155d33; }
.notice.err { background: #fde9ec; color: #8a1c30; }
.back { color: var(--muted); text-decoration: none; font-size: 15px; }
.qr { display: grid; place-items: center; }
.qr svg { width: 220px; height: 220px; background: #fff; padding: 12px; border-radius: 18px; }
.desktop { justify-content: center; }

.price-card {
  background: var(--surface); border-radius: 24px; padding: 24px 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.price { text-align: center; }
.price .amt { font-size: 44px; font-weight: 800; letter-spacing: -.03em; }
.price .per { color: var(--muted); font-size: 17px; }
.perks { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.perks li { padding-left: 28px; position: relative; }
.perks li::before {
  content: "✓"; position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center;
}

/* ---------------------------------------------------------------- chat shell */

.app {
  height: var(--app-h, 100dvh);
  display: flex; flex-direction: column;
  max-width: 600px; margin: 0 auto;
}
.top {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 6px) 10px 6px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand img { border-radius: 7px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--draft); font-weight: 700; font-size: 14px;
}
.trial-bar {
  flex: none; display: block; text-align: center; font-size: 13px; color: var(--muted);
  text-decoration: none; padding: 2px 0 8px;
}
.trial-bar b { color: var(--accent); margin-left: 6px; }

.scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 8px 16px 12px;
}

/* ---------------------------------------------------------------- empty state */

.empty { padding: 7vh 4px 8px; }
.empty[hidden] { display: none; }
.empty h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 10px; }
.empty p { color: var(--muted); margin: 0 0 24px; font-size: 16px; }
.starters { display: grid; gap: 10px; }
.starter {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 14px 16px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow); font-size: 15.5px; line-height: 1.3;
  transition: transform .08s ease;
}
.starter:active { transform: scale(.985); }
.starter svg { flex: none; color: var(--accent); }

/* ---------------------------------------------------------------- messages */

.thread { display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; flex-direction: column; animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg.user { align-items: flex-end; }
.msg.user .bubble {
  max-width: 82%; padding: 10px 14px; border-radius: var(--radius) var(--radius) 6px var(--radius);
  background: var(--user); color: #fff; white-space: pre-wrap; word-wrap: break-word;
}
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 6px; max-width: 82%; }
.thumbs img { height: 110px; border-radius: 12px; object-fit: cover; box-shadow: var(--shadow); }
.file-tag {
  display: inline-block; padding: 6px 10px; border-radius: 10px; background: var(--draft);
  font-size: 13px; color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.msg.bot .body { max-width: 100%; font-size: 16.5px; }
.msg.bot .body > :first-child { margin-top: 0; }
.msg.bot .body > :last-child { margin-bottom: 0; }
.msg.bot p { margin: 0 0 10px; }
.msg.bot h3 { font-size: 16.5px; margin: 16px 0 6px; }
.msg.bot ul, .msg.bot ol { margin: 0 0 10px; padding-left: 22px; }
.msg.bot li { margin: 3px 0; }
.msg.bot hr { border: 0; height: 1px; background: var(--line); margin: 14px 0; }
.msg.bot code { background: var(--draft); padding: 1px 5px; border-radius: 6px; font-size: .92em; }

/* A draft they could send renders as a message bubble with a Copy button. */
.draft {
  position: relative; margin: 6px 0 12px; padding: 11px 14px 11px 14px;
  background: var(--draft); border-radius: 18px 18px 18px 6px;
  display: flex; flex-direction: column; gap: 8px;
}
.draft-text { font-size: 16px; }
.copy {
  align-self: flex-end; border: 0; background: var(--surface); color: var(--accent);
  font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 999px; box-shadow: var(--shadow);
}

.typing { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .4; animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: 1; transform: translateY(-2px); } }

.err { margin-top: 8px; font-size: 14px; color: #c22746; }
.err button { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0 0 0 4px; }

/* ---------------------------------------------------------------- composer */

.composer {
  flex: none; padding: 8px 12px calc(var(--safe-b) + 8px);
  background: var(--bg);
}
.composer form {
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: 4px 4px 4px 4px; box-shadow: var(--shadow);
}
.composer textarea {
  flex: 1; border: 0; outline: none; background: transparent; resize: none;
  font-size: 16px; /* ≥16px or iOS zooms on focus */
  line-height: 1.35; padding: 9px 4px; max-height: 140px;
}
.composer .attach { color: var(--muted); flex: none; }
.send {
  flex: none; width: 36px; height: 36px; margin: 2px; border: 0; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  transition: opacity .15s ease, transform .08s ease;
}
.send:disabled { opacity: .35; }
.send:active { transform: scale(.94); }

.chips { display: none; gap: 8px; padding: 0 4px 8px; overflow-x: auto; }
.chips.on { display: flex; }
.chip { position: relative; flex: none; }
.chip img { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; display: block; }
.chip .file-tag { height: 56px; display: grid; place-items: center; }
.chip-x {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--bg); background: var(--ink); color: var(--bg); font-size: 14px; line-height: 1;
  display: grid; place-items: center; padding: 0;
}

.paywall { display: none; }
.composer.locked form, .composer.locked .chips { display: none; }
.composer.locked .paywall {
  display: flex; flex-direction: column; gap: 10px; text-align: center;
  background: var(--surface); border-radius: 20px; padding: 16px; box-shadow: var(--shadow);
}
.paywall p { margin: 0; }

/* ---------------------------------------------------------------- menu sheet + toast */

.sheet {
  border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%;
  background: transparent; color: var(--ink);
}
.sheet::backdrop { background: rgba(10, 5, 15, .35); }
.sheet[open] .sheet-body { animation: up .22s ease both; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-body {
  margin: 0 10px calc(var(--safe-b) + 10px); background: var(--surface); border-radius: 22px;
  padding: 8px; display: flex; flex-direction: column;
}
.sheet-head { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.sheet-head span { color: var(--muted); font-size: 14px; }
.sheet-item {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 14px;
  border-radius: 14px; font-size: 17px; color: var(--ink); text-decoration: none;
}
.sheet-item:active { background: var(--draft); }
.sheet-item.danger { color: #d0304f; }
.sheet-item.cancel { text-align: center; font-weight: 600; }
.sheet form { margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 90px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s ease; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- plan picker */

.plans { display: grid; gap: 10px; }
.plan {
  display: grid; gap: 2px; text-align: left; padding: 14px 16px; border-radius: 18px;
  border: 2px solid var(--line); background: var(--bg); color: var(--ink);
  transition: border-color .15s ease, transform .08s ease;
}
.plan:active { transform: scale(.99); }
.plan.on { border-color: var(--accent); background: var(--surface); }
.plan-head { display: flex; align-items: center; gap: 8px; }
.plan-label { font-weight: 700; }
.tag {
  font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  background: var(--accent); color: #fff; padding: 3px 8px; border-radius: 999px;
}
.plan-price { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.plan-price .per { font-size: 15px; font-weight: 500; color: var(--muted); }
.plan-blurb { font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- legal pages */

.legal { max-width: 640px; }
.legal h1 { font-size: 26px; letter-spacing: -.02em; margin: 6px 0 4px; }
.legal h2 { font-size: 17px; margin: 22px 0 6px; }
.legal p, .legal li { color: var(--ink); font-size: 15.5px; line-height: 1.5; }
.legal ul { padding-left: 20px; margin: 8px 0; display: grid; gap: 6px; }
.legal .fine { text-align: center; }
.legal .fine.left { text-align: left; margin: 0 0 8px; }
