:root {
  /* Matched to answeringadventism.com Automatic.css / Bricks palette */
  --bg: #faf8fc;
  --bg-card: #ffffff;
  --fg: #1d0736;
  --fg-muted: #5c4a6e;
  --border: #e4dcf0;
  --accent: #7429ff;
  --accent-hover: #5a1fd4;
  --accent-soft: rgba(116, 41, 255, 0.1);
  --gold: #ffd600;
  --assistant-bg: #f4f0fa;
  --user-bg: #efe6ff;
  --user-fg: #1d0736;
  --danger: #dc3545;
  --shadow: 0 1px 2px rgba(29, 7, 54, 0.05), 0 4px 14px rgba(29, 7, 54, 0.06);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family:
    "DM Sans", Roboto, "Open Sans", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ----- Header ---------------------------------------------------------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 -3px 0 0 var(--gold);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: inset 0 -3px 0 0 var(--gold);
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--fg);
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--fg-muted);
}

.ghost-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--fg);
}
.ghost-btn:hover {
  background: var(--bg);
}

/* ----- Chat shell ------------------------------------------------------ */

.chat-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 20px 32px;
  gap: 16px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  display: flex;
  width: 100%;
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: 86%;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--assistant-bg);
  box-shadow: var(--shadow);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  background: var(--user-bg);
  color: var(--user-fg);
}

.bubble p {
  margin: 0 0 0.6em;
}
.bubble p:last-child {
  margin-bottom: 0;
}

.bubble .content sup.cite {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
  margin: 0 1px;
  cursor: pointer;
  vertical-align: super;
  line-height: 1;
  text-decoration: none;
}
.bubble .content sup.cite:hover {
  background: rgba(116, 41, 255, 0.18);
}

.bubble .content a.inline-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.bubble .content a.inline-link:hover {
  color: var(--accent-hover);
}

/* ----- Code blocks (incl. suggested reply blocks) ---------------------- */

.bubble .content .codeblock {
  margin: 10px 0;
  border: 1px solid rgba(31, 35, 40, 0.12);
  border-radius: 10px;
  background: #f6f7f9;
  overflow: hidden;
}
.bubble .content .codeblock--reply {
  border-color: rgba(116, 41, 255, 0.28);
  background: #f7f2ff;
}
.codeblock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 6px 12px;
  background: rgba(29, 7, 54, 0.04);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
}
.codeblock--reply .codeblock-head {
  background: rgba(116, 41, 255, 0.1);
  color: #4c1d95;
}
.codeblock-label {
  font-weight: 700;
}
.codeblock-copy {
  border: 1px solid rgba(31, 35, 40, 0.18);
  background: var(--bg-card);
  color: var(--fg);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.codeblock-copy:hover {
  background: var(--bg);
}
.codeblock-copy--success {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}
.codeblock-body {
  margin: 0;
  padding: 12px 14px;
  font-family:
    "SFMono-Regular", ui-monospace, Menlo, Consolas, "Liberation Mono",
    monospace;
  font-size: 13.5px;
  white-space: pre-wrap;
  overflow-x: auto;
  color: var(--fg);
}
.codeblock-body code {
  font: inherit;
  background: transparent;
  padding: 0;
}

.sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(31, 35, 40, 0.08);
  font-size: 12.5px;
}
.sources h4 {
  margin: 0 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--fg-muted);
}
.source-list {
  margin: 0;
  padding-left: 18px;
  color: var(--fg-muted);
}
.source-list li {
  margin: 1px 0;
  line-height: 1.4;
}
.source-list li a {
  color: var(--accent);
}

.src-badge {
  display: inline-block;
  padding: 1px 6px;
  margin-right: 7px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  vertical-align: 1px;
  line-height: 1.5;
}
.src-badge--video {
  background: #fff8cc;
  color: #7a6400;
}
.src-badge--article {
  background: #efe6ff;
  color: #5a1fd4;
}

.message.error .bubble {
  background: #ffebe9;
  color: var(--danger);
  border: 1px solid #ffcecb;
}

/* ----- Composer -------------------------------------------------------- */

.composer {
  position: sticky;
  bottom: 12px;
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  box-shadow: var(--shadow);
}

#prompt {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  font: inherit;
  padding: 8px 10px;
  background: transparent;
  color: var(--fg);
  max-height: 180px;
  overflow-y: auto;
}

.primary-btn {
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}
.primary-btn:hover {
  background: var(--accent-hover);
}
.primary-btn:disabled {
  background: #94a3b8;
  cursor: progress;
}

.send-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.primary-btn.loading .send-label {
  display: none;
}
.primary-btn.loading .send-spinner {
  display: inline-block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.footnote {
  text-align: center;
  color: var(--fg-muted);
  font-size: 12px;
  margin: 0;
}

.char-counter {
  margin: 4px 6px 0 auto;
  text-align: right;
  font-size: 11.5px;
  color: var(--fg-muted);
}
.char-counter--warn {
  color: #b06000;
}
.char-counter--max {
  color: var(--danger);
  font-weight: 600;
}

/* ----- Mobile ---------------------------------------------------------- */

@media (max-width: 640px) {
  .app-header {
    padding: 14px 16px;
  }
  .brand-text h1 {
    font-size: 15px;
  }
  .brand-text p {
    font-size: 12px;
  }
  .chat-shell {
    padding: 16px 12px 24px;
  }
  .bubble {
    max-width: 95%;
  }
}
