/* Christian Daily International — reader assistant
   Palette and type follow christiandaily.com: Noto Serif headlines,
   Google Sans body, near-black on white, #d9d9d9 rules, #cc0000 accent. */

:root {
  --ink: #111111;
  --text: #212529;
  --muted: #666666;
  --faint: #999999;
  --rule: #d9d9d9;
  --rule-soft: #ececec;
  --paper: #ffffff;
  --wash: #f5f5f5;
  --wash-2: #f9f9f9;
  --accent: #cc0000;
  --focus: #0098de;

  --serif: "Noto Serif", Georgia, "Times New Roman", serif;
  --sans: "Google Sans", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;

  --col: 760px;
  --gutter: 20px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.app { display: flex; flex-direction: column; height: 100dvh; }
.column { width: 100%; max-width: var(--col); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Top bar ---------- */
.topbar {
  flex: none;
  display: flex; align-items: center; gap: 14px;
  height: 64px; padding: 0 var(--gutter);
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.brand { display: flex; align-items: center; flex: 0 1 auto; min-width: 0; height: 100%; overflow: hidden; }
.brand-logo { display: block; height: 26px; width: 200px; max-width: 100%; object-fit: contain; object-position: left center; }
.brand-divider { width: 1px; height: 26px; background: var(--rule); }
.brand-product {
  font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--accent); white-space: nowrap;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.lang-picker {
  position: relative; display: flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 8px; border-radius: 18px; cursor: pointer;
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}
.lang-picker:hover { background: var(--wash); }
.lang-picker svg { width: 18px; height: 18px; }
.lang-picker select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent;
  font-weight: 600; text-transform: uppercase; cursor: pointer; padding-right: 2px;
}
.lang-picker select:focus { outline: none; }
.lang-picker:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px; border: 1px solid var(--rule); border-radius: 18px;
  background: var(--paper); cursor: pointer; font-size: 13px; font-weight: 600;
}
.icon-btn:hover { background: var(--wash); }
.icon-btn svg { width: 16px; height: 16px; }
#closeBtn { padding: 0; width: 36px; justify-content: center; border-color: transparent; }
.only-embed { display: none !important; }
.is-embed .only-embed { display: inline-flex !important; }

/* ---------- Scroll area ---------- */
.scroller { flex: 1; overflow-y: auto; scroll-behavior: smooth; overscroll-behavior: contain; }

/* ---------- Welcome ---------- */
.welcome { padding: 56px 0 24px; }
.kicker {
  margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--accent);
}
.welcome-title {
  margin: 0 0 12px; font: 700 clamp(28px, 4.2vw, 40px)/1.15 var(--serif); color: var(--ink);
  letter-spacing: -.2px;
}
.welcome-sub { margin: 0 0 28px; color: var(--muted); font-size: 16px; max-width: 580px; }

.suggestions { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.suggestions li { border-bottom: 1px solid var(--rule); }
.suggestion {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 2px; border: 0; background: none; cursor: pointer; text-align: left;
  font: 600 17px/1.35 var(--serif); color: var(--ink);
}
.suggestion svg { flex: none; width: 18px; height: 18px; color: var(--faint); transition: transform .15s, color .15s; }
.suggestion:hover { color: #000; }
.suggestion:hover svg { color: var(--ink); transform: translateX(3px); }
.suggestion-tag {
  display: block; margin-bottom: 2px; font: 700 11px/1.4 var(--sans); letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted);
}

/* ---------- Thread ---------- */
.thread { padding: 8px 0 24px; }
.has-messages .welcome { display: none; }
.has-messages .thread { padding-top: 28px; }

.msg { margin: 0 0 28px; animation: rise .25s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .msg { animation: none; } .scroller { scroll-behavior: auto; } }

.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  max-width: 85%; padding: 10px 16px; border-radius: 20px 20px 4px 20px;
  background: var(--wash); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere;
}

.msg-bot .byline { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff;
  display: grid; place-items: center; font: 700 12px/1 var(--serif); letter-spacing: .3px; flex: none;
}
.byline-name { font-size: 13px; font-weight: 700; color: var(--ink); }
.byline-status { font-size: 13px; color: var(--muted); }

.answer { color: var(--text); font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer p { margin: 0 0 12px; }
.answer h1, .answer h2, .answer h3, .answer h4 {
  font-family: var(--serif); color: var(--ink); line-height: 1.3; margin: 20px 0 8px;
}
.answer h1 { font-size: 22px; } .answer h2 { font-size: 20px; } .answer h3, .answer h4 { font-size: 18px; }
.answer strong { color: var(--ink); }
.answer a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.answer a:hover { text-decoration-color: var(--ink); }
.answer ul, .answer ol { margin: 0 0 14px; padding-left: 0; list-style: none; }
.answer ol { counter-reset: n; }
/* Article lists read like the site's story list: serif headline, divider rule. */
.answer > ol > li, .answer > ul > li {
  position: relative; padding: 14px 0 14px 34px; border-top: 1px solid var(--rule-soft);
}
.answer > ol > li:last-child, .answer > ul > li:last-child { border-bottom: 1px solid var(--rule-soft); }
.answer > ol > li::before {
  counter-increment: n; content: counter(n);
  position: absolute; left: 0; top: 15px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff; font: 700 12px/22px var(--sans); text-align: center;
}
.answer > ul > li::before {
  content: ""; position: absolute; left: 8px; top: 25px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink);
}
.answer li > a:first-child, .answer li > strong:first-child > a, .answer li > p:first-child > a:first-child,
.answer li > p:first-child > strong:first-child > a {
  font: 700 17px/1.35 var(--serif); text-decoration: none;
}
.answer li > a:first-child:hover, .answer li > strong:first-child > a:hover,
.answer li > p:first-child > a:first-child:hover, .answer li > p:first-child > strong:first-child > a:hover { text-decoration: underline; }
.answer li ul, .answer li ol { margin: 6px 0 0; }
/* Headline on its own line, date + summary underneath. */
.answer > ol > li > strong:first-child, .answer > ul > li > strong:first-child,
.answer > ol > li > a:first-child, .answer > ul > li > a:first-child,
.answer > ol > li > p:first-child > strong:first-child, .answer > ul > li > p:first-child > strong:first-child,
.answer > ol > li > p:first-child > a:first-child, .answer > ul > li > p:first-child > a:first-child { display: block; margin-bottom: 4px; }
.answer li li { padding: 2px 0 2px 16px; position: relative; border: 0; color: var(--text); }
.answer li li::before { content: ""; position: absolute; left: 3px; top: 12px; width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }
.answer li p { margin: 0 0 4px; }
.answer blockquote { margin: 0 0 12px; padding: 2px 0 2px 16px; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.answer code { background: var(--wash); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.answer hr { border: 0; border-top: 1px solid var(--rule); margin: 18px 0; }
.answer table { border-collapse: collapse; width: 100%; margin: 0 0 14px; font-size: 14px; }
.answer th, .answer td { border-bottom: 1px solid var(--rule); padding: 8px 6px; text-align: left; }

.cursor::after {
  content: ""; display: inline-block; width: 8px; height: 1.05em; margin-left: 2px;
  background: var(--ink); vertical-align: text-bottom; animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: bounce 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

.msg-tools { display: flex; gap: 4px; margin-top: 10px; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 0; border-radius: 15px; background: none; color: var(--muted); font-size: 13px; cursor: pointer;
}
.tool-btn:hover { background: var(--wash); color: var(--ink); }
.tool-btn svg { width: 15px; height: 15px; }

/* Google Search suggestions (required display for Search grounding). */
.search-suggestions { margin-top: 12px; max-width: 100%; overflow: hidden; }

.error-note { color: var(--accent); font-size: 15px; }

/* ---------- Composer ---------- */
.composer-wrap {
  flex: none; padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(255,255,255,0), var(--paper) 18px);
}
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 8px 8px 18px; border: 1px solid var(--rule); border-radius: 26px; background: var(--paper);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: #9a9a9a; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.07); }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: none; background: transparent;
  padding: 8px 0; max-height: 160px; font-size: 16px; line-height: 1.5; color: var(--ink);
}
.composer textarea::placeholder { color: var(--faint); }
.send-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--ink); color: #fff; transition: background .15s, opacity .15s;
}
.send-btn:disabled { background: var(--rule); cursor: default; }
.send-btn:not(:disabled):hover { background: #000; }
.send-btn svg { width: 20px; height: 20px; stroke-width: 2.2; }
.send-btn .i-stop { display: none; fill: currentColor; stroke: none; }
.is-busy .send-btn .i-send { display: none; }
.is-busy .send-btn .i-stop { display: block; }
.disclaimer { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--faint); }

/* ---------- Small screens & embedded panel ---------- */
@media (max-width: 560px) {
  :root { --gutter: 16px; }
  .topbar { height: 56px; gap: 10px; }
  .brand-logo { height: 20px; width: 150px; }
  .brand-divider, .brand-product { display: none; }
  .icon-btn-label { display: none; }
  .icon-btn { width: 36px; padding: 0; justify-content: center; }
  .welcome { padding-top: 32px; }
  .suggestion { font-size: 16px; }
}
.is-embed { --gutter: 18px; }
.is-embed .topbar { height: 56px; gap: 10px; }
.is-embed .brand-logo { height: 20px; width: 150px; }
.is-embed .brand-product { font-size: 11px; letter-spacing: 1px; }
.is-compact .lang-picker { padding: 0 6px; }
.is-embed .icon-btn-label { display: none; }
.is-embed #newChatBtn { width: 36px; padding: 0; justify-content: center; }
.is-embed .welcome { padding-top: 28px; }
.is-embed .welcome-title { font-size: 26px; }
.is-embed .welcome-sub { font-size: 15px; margin-bottom: 20px; }
.is-embed .suggestion { font-size: 15.5px; padding: 13px 2px; }
@media (max-width: 400px) { .is-embed .brand-divider, .is-embed .brand-product { display: none; } }
