/* Change these to match your brand. */
:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --text: #2b2a27;
  --muted: #76736b;
  --border: #e6e2d8;
  --user-bubble: #f0ede4;
  --accent: #c2410c;        /* send button, links, highlights */
  --accent-text: #ffffff;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }

#app { display: flex; flex-direction: column; height: 100dvh; }

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.mark, .hero-mark, .avatar {
  display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-family: var(--serif); font-weight: 600;
}
.mark { width: 28px; height: 28px; font-size: 15px; }
.logo { height: 32px; width: auto; max-width: 200px; object-fit: contain; display: block; }
.hero-logo { max-height: 80px; max-width: min(280px, 70vw); width: auto; object-fit: contain; }
.top-actions { display: flex; gap: 4px; }
.ghost { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 0; color: var(--muted);
  padding: 7px 10px; border-radius: 10px; font-size: 14px; }
.ghost:hover { background: var(--user-bubble); color: var(--text); }
.ghost.icon { padding: 7px; }

/* ---- conversation ---- */
main { flex: 1; overflow-y: auto; padding: 8px 16px 24px; scroll-behavior: smooth; }
.thread { max-width: 740px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.hero { display: none; }
#app.empty main { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
#app.empty .hero { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-bottom: 18px; text-align: center; }
.hero-mark { width: 46px; height: 46px; font-size: 24px; }
.hero h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(26px, 5vw, 36px); margin: 0; letter-spacing: -0.01em; }

.msg { display: flex; gap: 12px; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.user { justify-content: flex-end; }
.msg.user .body { background: var(--user-bubble); padding: 10px 16px; border-radius: var(--radius); max-width: 85%;
  white-space: pre-wrap; word-wrap: break-word; }
.msg.assistant .avatar { width: 28px; height: 28px; font-size: 14px; flex: none; margin-top: 2px; }
.msg.assistant .content { flex: 1; min-width: 0; }
.msg.assistant .body { word-wrap: break-word; }
.body > :first-child { margin-top: 0; } .body > :last-child { margin-bottom: 0; }
.body p { margin: 0 0 .8em; }
.body ul, .body ol { margin: 0 0 .8em; padding-left: 1.4em; }
.body li { margin: .2em 0; }
.body h1, .body h2, .body h3, .body h4 { font-family: var(--serif); font-weight: 600; line-height: 1.3; margin: 1em 0 .4em; }
.body h1 { font-size: 1.35em; } .body h2 { font-size: 1.2em; } .body h3, .body h4 { font-size: 1.05em; }
.body a { color: var(--accent); }
.body blockquote { margin: 0 0 .8em; padding: 2px 14px; border-left: 3px solid var(--border); color: var(--muted); }
.body code { background: var(--user-bubble); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.body pre { background: #2b2a27; color: #f5f3ee; padding: 12px 14px; border-radius: 10px; overflow-x: auto; }
.body pre code { background: none; padding: 0; color: inherit; }
.typing::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  margin-left: 4px; vertical-align: middle; animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; background: var(--surface); }
.copy { background: none; border: 0; color: var(--muted); padding: 3px 6px; border-radius: 6px; font-size: 12.5px; }
.copy:hover { background: var(--user-bubble); color: var(--text); }

/* ---- hand-off card ---- */
.handoff { margin-top: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.handoff-msg { margin: 0 0 12px; }
.handoff-form { display: flex; flex-direction: column; gap: 8px; }
.handoff-form .row { display: flex; gap: 8px; }
.handoff-form .row > * { flex: 1; min-width: 0; }
.handoff input:not([type=checkbox]), .handoff textarea {
  font: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); width: 100%; }
.handoff input:focus, .handoff textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--muted); }
.consent input { margin-top: 4px; }
.handoff-actions { display: flex; justify-content: flex-end; gap: 8px; }
.primary { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 10px; padding: 8px 16px; font-weight: 600; }
.primary:disabled { opacity: .5; cursor: default; }
.handoff-status { margin: 0; font-size: 14px; color: var(--muted); }
.handoff-status.error { color: #b42318; }
.handoff.done .handoff-form > :not(.handoff-status) { display: none; }

/* ---- composer ---- */
.composer-wrap { padding: 0 16px calc(10px + env(safe-area-inset-bottom)); }
.suggestions { max-width: 740px; margin: 0 auto 10px; display: none; flex-wrap: wrap; gap: 8px; justify-content: center; }
#app.empty .suggestions { display: flex; }
.suggestions button { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px;
  font-size: 14px; color: var(--text); }
.suggestions button:hover { border-color: var(--muted); }
.composer { max-width: 740px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 12px 12px 10px 16px; box-shadow: 0 2px 12px rgba(40,30,10,.06); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: #d4cfc2; box-shadow: 0 4px 18px rgba(40,30,10,.09); }
.composer textarea { width: 100%; border: 0; outline: 0; resize: none; font: inherit; color: var(--text); background: transparent;
  max-height: 200px; padding: 2px 0; }
.composer-bar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.model-picker { margin-right: auto; position: relative; display: inline-flex; align-items: center; color: var(--muted); }
.model-picker select { appearance: none; border: 0; background: transparent; font: inherit; font-size: 13.5px; color: var(--muted);
  padding: 4px 22px 4px 8px; border-radius: 8px; cursor: pointer; }
.model-picker select:hover { background: var(--user-bubble); color: var(--text); }
.model-picker svg { position: absolute; right: 6px; pointer-events: none; }
.send { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; transition: opacity .15s; }
.send:disabled { opacity: .35; cursor: default; }
.mic { width: 34px; height: 34px; border-radius: 10px; border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; transition: background .15s, color .15s; }
.mic:hover { background: var(--user-bubble); color: var(--text); }
.mic.listening { background: #fde8e8; color: #c81e1e; animation: micpulse 1.2s infinite ease-in-out; }
@keyframes micpulse { 50% { box-shadow: 0 0 0 6px rgba(200,30,30,.12); } }
.voice-note { max-width: 740px; margin: 6px auto 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.voice-note:empty { display: none; }
.disclaimer { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.version { text-align: center; font-size: 10.5px; color: var(--muted); opacity: .6; margin: 2px 0 0; }
.version:empty { display: none; }

/* ---- embedded (inside the WordPress bubble) ---- */
body.embed .topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
body.embed .hero h1 { font-size: 24px; }
body.embed .newchat-label { display: none; }

@media (max-width: 520px) {
  body { font-size: 15.5px; }
  #newChat span { display: none; }
  .handoff-form .row { flex-direction: column; }
}
