:root {
  --paper: #fbf4f5;
  --paper-deep: #f3e8ea;
  --ink: #241a20;
  --ink-soft: #6b5b64;
  --ink-faint: #a69aa1;
  --line: #e8d9dd;
  --rose: #b8405e;
  --rose-deep: #93304a;
  --rose-wash: #f6dde3;
  --plum: #2e2430;
  --white: #ffffff;
  --green: #3a9a5b;
  --amber: #c98a1d;
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--rose); }
:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { height: 100dvh; display: flex; flex-direction: column; max-width: 860px; margin: 0 auto; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 10px; gap: 12px;
}
.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.wordmark {
  font-family: var(--font-display); font-size: 30px; font-weight: 500; letter-spacing: -0.01em;
  font-variation-settings: "SOFT" 100, "opsz" 72; line-height: 1; margin: 0; white-space: nowrap;
}
.wordmark em { font-style: italic; font-weight: 400; }
.wordmark .dot { color: var(--rose); }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 14px; white-space: nowrap; }
.status i { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(58,154,91,.18); }
.status.away i { background: var(--amber); box-shadow: 0 0 0 3px rgba(201,138,29,.18); }
.status.offline i { background: var(--ink-faint); box-shadow: none; }

.btn {
  border: 0; border-radius: 999px; padding: 10px 18px; background: var(--plum); color: var(--white);
  font-weight: 600; font-size: 15px; transition: transform .08s ease, background .15s ease;
}
.btn:hover { background: #3d3040; }
.btn:active { transform: translateY(1px); }
.btn.rose { background: var(--rose); }
.btn.rose:hover { background: var(--rose-deep); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.ghost:hover { background: var(--white); }
.btn.sm { padding: 7px 14px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }

/* account menu */
.account { position: relative; display: flex; align-items: center; gap: 10px; }
.counter { font-size: 14px; color: var(--ink-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.counter.low { color: var(--rose-deep); font-weight: 600; }
.avatar-btn { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 4px 4px 4px 12px; border-radius: 999px; }
.avatar-btn:hover { background: var(--paper-deep); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--plum); color: var(--white); display: grid; place-items: center; font-weight: 600; font-size: 14px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; letter-spacing: .01em; }
.pill.trial { background: var(--paper-deep); color: var(--ink-soft); }
.pill.payg { background: #e7eef9; color: #2f5aa8; }
.pill.subscription { background: var(--rose-wash); color: var(--rose-deep); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 280px; background: var(--white);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 40px -20px rgba(36,26,32,.35);
  padding: 14px; z-index: 20; display: none;
}
.menu.open { display: block; }
.menu .who { font-weight: 600; }
.menu .mail { color: var(--ink-soft); font-size: 13.5px; word-break: break-all; }
.menu .meter { margin: 12px 0; font-size: 14px; color: var(--ink-soft); }
.menu .meter b { color: var(--ink); }
.menu .row { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.menu .link { background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 10px; font-size: 15px; }
.menu .link:hover { background: var(--paper); }

/* ---------- chat ---------- */
.thread { flex: 1; overflow-y: auto; padding: 10px 20px 20px; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { .thread { scroll-behavior: auto; } }
.day { text-align: center; color: var(--ink-faint); font-size: 13px; margin: 18px 0 10px; }
.msg { display: flex; margin: 6px 0; max-width: 78%; }
.msg.chloe { justify-content: flex-start; }
.msg.user { margin-left: auto; justify-content: flex-end; }
.bubble {
  padding: 11px 15px; border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 16px; line-height: 1.45;
}
.msg.chloe .bubble { background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.user .bubble { background: var(--plum); color: var(--white); border-bottom-right-radius: 6px; }
.msg.pending .bubble { opacity: .6; }
.msg.failed .bubble { background: #f2c9d2; color: var(--rose-deep); }
.stamp { font-size: 12px; color: var(--ink-faint); margin: 2px 6px 0; }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing span { animation: none; opacity: .6; } }

.intro { max-width: 560px; margin: 28px auto 10px; text-align: left; }
.intro h2 { font-family: var(--font-display); font-weight: 400; font-size: 40px; line-height: 1.1; margin: 0 0 14px; font-variation-settings: "SOFT" 100, "opsz" 72; letter-spacing: -0.015em; }
.intro h2 em { font-style: italic; color: var(--rose); }
.intro p { color: var(--ink-soft); margin: 0 0 8px; max-width: 46ch; }

/* paywall */
.wall { margin: 16px auto 8px; max-width: 560px; background: var(--white); border: 1px solid var(--line); border-radius: 20px; padding: 20px; }
.wall h3 { font-family: var(--font-display); font-weight: 500; font-size: 24px; margin: 0 0 6px; }
.wall p { color: var(--ink-soft); margin: 0 0 14px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plan { border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; text-align: left; background: var(--paper); display: flex; flex-direction: column; gap: 4px; }
.plan:hover { border-color: var(--rose); background: var(--white); }
.plan b { font-size: 18px; }
.plan small { color: var(--ink-soft); }
.plan.best { border-color: var(--rose); }
@media (max-width: 560px) { .plans { grid-template-columns: 1fr; } }

/* composer */
.composer { padding: 10px 20px 18px; }
.box {
  display: flex; align-items: flex-end; gap: 8px; background: var(--white); border: 1.5px solid var(--line);
  border-radius: 24px; padding: 8px 8px 8px 18px; transition: border-color .15s ease;
}
.box:focus-within { border-color: var(--rose); }
.box textarea { flex: 1; border: 0; background: transparent; resize: none; max-height: 160px; min-height: 26px; padding: 6px 0; outline: none; line-height: 1.4; }
.send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--rose); color: var(--white); display: grid; place-items: center; flex-shrink: 0; }
.send:hover { background: var(--rose-deep); }
.send[disabled] { background: var(--line); cursor: default; }
.hint { font-size: 13px; color: var(--ink-faint); margin: 8px 6px 0; display: flex; justify-content: space-between; gap: 10px; }
.hint .left { color: var(--ink-soft); }
.hint .left.low { color: var(--rose-deep); font-weight: 600; }

/* account sheets */
.modal.wide { max-width: 480px; }
.plan-now { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--paper); border-radius: 14px; padding: 14px 16px; margin: 0 0 16px; }
.plan-now b { display: block; font-size: 17px; }
.plan-now span { color: var(--ink-soft); font-size: 14px; }
.modal h3 { font-size: 15px; font-weight: 600; margin: 18px 0 8px; color: var(--ink-soft); }
.modal .plans { margin-bottom: 4px; }
.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
.hist td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.hist td:last-child { text-align: right; }
.hist td:first-child { color: var(--ink-soft); }
.muted { color: var(--ink-soft); font-size: 14px; margin: 0; }
.modal .btn.inline-btn { width: auto; margin: 0; }
.modal .ok { color: var(--green); font-size: 14px; margin: 8px 0 0; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(36,26,32,.45); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.overlay.open { display: flex; }
.modal { background: var(--white); border-radius: 22px; width: 100%; max-width: 400px; padding: 28px; position: relative; box-shadow: 0 30px 60px -30px rgba(36,26,32,.5); }
.modal h2 { font-family: var(--font-display); font-weight: 500; font-size: 28px; margin: 0 0 4px; font-variation-settings: "SOFT" 100, "opsz" 72; }
.modal .sub { color: var(--ink-soft); margin: 0 0 18px; font-size: 15px; }
.close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--paper); font-size: 18px; }
.gbtn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--white); font-weight: 600; }
.gbtn:hover { background: var(--paper); }
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-faint); font-size: 13px; margin: 16px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: 13.5px; color: var(--ink-soft); margin-bottom: 4px; }
.field input { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--paper); }
.field input:focus { border-color: var(--rose); outline: none; background: var(--white); }
.modal .btn { width: 100%; margin-top: 6px; }
.switch { text-align: center; margin: 14px 0 0; font-size: 14px; color: var(--ink-soft); }
.switch button { background: none; border: 0; color: var(--rose); font-weight: 600; padding: 0; }
.err { color: var(--rose-deep); background: var(--rose-wash); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 0 0 10px; display: none; }
.err.show { display: block; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--plum); color: var(--white); padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
.toast.show { opacity: 1; }

@media (max-width: 600px) {
  .top { padding: 14px 16px 8px; }
  .wordmark { font-size: 24px; }
  .status .txt { display: none; }
  .counter { font-size: 13px; }
  .pill { display: none; }
  .thread, .composer { padding-left: 16px; padding-right: 16px; }
  .msg { max-width: 88%; }
  .intro h2 { font-size: 32px; }
  .modal { padding: 22px; }
}
