:root {
  --navy: #0f2340;
  --navy-2: #1a3358;
  --gold: #b8913a;
  --gold-soft: #f3ead6;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #1c2230;
  --muted: #5d6677;
  --line: #e2ddd1;
  --user-bg: var(--navy);
  --user-text: #ffffff;
  --chip-bg: #ffffff;
  --header-bg: var(--navy);
  --header-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #131c2e;
    --text: #e8eaf0;
    --muted: #9aa3b5;
    --line: #26314a;
    --user-bg: #2a4572;
    --chip-bg: #131c2e;
    --gold-soft: #2b2416;
    --header-bg: #08101d;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #131c2e;
  --text: #e8eaf0;
  --muted: #9aa3b5;
  --line: #26314a;
  --user-bg: #2a4572;
  --chip-bg: #131c2e;
  --gold-soft: #2b2416;
  --header-bg: #08101d;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

.top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 2px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 2px solid var(--gold);
  background: #e9e6df; color: var(--navy);
  font: 700 26px/1 "Cormorant Garamond", Georgia, serif;
}
h1 {
  margin: 0;
  font: 700 22px/1.1 "Cormorant Garamond", Georgia, serif;
  letter-spacing: .06em; text-transform: uppercase;
}
.sub { margin: 2px 0 0; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.ghost {
  flex: none;
  background: transparent; color: var(--header-text);
  border: 1px solid rgba(255,255,255,.35); border-radius: 999px;
  padding: 6px 14px; font: 500 14px Inter, sans-serif; cursor: pointer;
}

main {
  flex: 1;
  width: 100%; max-width: 720px; margin: 0 auto;
  padding: 20px 16px 12px;
  display: flex; flex-direction: column; gap: 14px;
}

.welcome { padding-top: 8px; }
.lead { font-size: 18px; margin: 0 0 6px; }
.sessions { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.chips { display: flex; flex-direction: column; gap: 8px; }
.chips button {
  text-align: left;
  background: var(--chip-bg); color: var(--text);
  border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 10px; padding: 12px 14px;
  font: 15px Inter, sans-serif; cursor: pointer;
}
.chips button:active { background: var(--gold-soft); }

.msg { max-width: 92%; padding: 12px 14px; border-radius: 14px; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user-bg); color: var(--user-text); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot p { margin: 0 0 .7em; }
.msg.bot p:last-child, .msg.bot ul:last-child, .msg.bot ol:last-child { margin-bottom: 0; }
.msg.bot ul, .msg.bot ol { margin: 0 0 .7em; padding-left: 1.3em; }
.msg.bot li { margin: .2em 0; }
.msg.bot blockquote { margin: 0 0 .7em; padding-left: 12px; border-left: 3px solid var(--gold); color: var(--muted); }
.msg.bot h3 { font: 700 19px/1.2 "Cormorant Garamond", Georgia, serif; margin: .3em 0 .4em; }
.msg.bot em { color: var(--muted); }
.typing::after { content: "▍"; color: var(--gold); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.ask {
  position: sticky; bottom: 0;
  width: 100%; max-width: 720px; margin: 0 auto;
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.ask textarea {
  flex: 1; resize: none; max-height: 140px;
  font: 16px/1.4 Inter, sans-serif; /* 16px stops iOS zooming on focus */
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 10px 14px; outline: none;
}
.ask textarea:focus { border-color: var(--gold); }
.ask button {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: var(--navy); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ask button { background: var(--gold); color: var(--navy); } }
:root[data-theme="dark"] .ask button { background: var(--gold); color: var(--navy); }
.ask button:disabled { opacity: .45; }

dialog {
  border: 0; border-radius: 16px; padding: 24px; width: min(92vw, 380px);
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(8, 16, 29, .6); }
dialog h2 { margin: 0 0 6px; font: 700 24px "Cormorant Garamond", Georgia, serif; }
dialog p { margin: 0 0 14px; color: var(--muted); font-size: 15px; }
dialog input {
  width: 100%; font: 16px Inter, sans-serif; padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text);
}
dialog button { width: 100%; padding: 11px; border: 0; border-radius: 10px; background: var(--navy); color: #fff; font: 600 15px Inter, sans-serif; }
.err { color: #c0392b !important; }
