/* ── Shared / invariant tokens ── */
:root {
  --accent:    #4f8ef7;
  --accent-dim:#1e3a6e;
  --success:   #34d399;
  --warn:      #f59e0b;
  --radius:    12px;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --bg:            #0f1117;
  --surface:       #181c25;
  --border:        #2a2f3d;
  --user-bg:       #1a2a4a;
  --bot-bg:        #1a1e28;
  --text:          #dde3f0;
  --muted:         #6b7591;
  --avatar-bot-bg: #1f2535;
  --input-bg:      #0f1117;
  --code-bg:       #0d1117;
  --accent-dim:    #1e3a6e;
}

/* ── Light theme ── */
[data-theme="light"] {
  --bg:            #f0f4f9;
  --surface:       #ffffff;
  --border:        #c2cfe0;
  --user-bg:       #1d4ed8;
  --user-text:     #ffffff;
  --user-border:   #1e40af;
  --bot-bg:        #ffffff;
  --text:          #0a0f1e;
  --muted:         #374151;
  --avatar-bot-bg: #e2e8f0;
  --input-bg:      #ffffff;
  --code-bg:       #f1f5f9;
  --accent-dim:    #bfdbfe;
}

/* ── High-contrast theme (Teams only) ── */
[data-theme="contrast"] {
  --bg:            #000000;
  --surface:       #000000;
  --border:        #ffffff;
  --user-bg:       #1a1a1a;
  --bot-bg:        #0a0a0a;
  --text:          #ffffff;
  --muted:         #aaaaaa;
  --avatar-bot-bg: #111111;
  --input-bg:      #000000;
  --code-bg:       #0a0a0a;
  --accent:        #ffff00;
  --accent-dim:    #333300;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(12px, 4vw, 48px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.header-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.header-title { font-weight: 600; font-size: 16px; }
.header-sub   { font-size: 13px; color: var(--muted); font-family: var(--font-mono); }
#header-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
}
#new-chat-btn {
  padding: 5px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 500;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
#new-chat-btn:hover { background: var(--accent); color: #fff; }
#new-chat-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#new-chat-btn .new-chat-spinner { display: none; }
#new-chat-btn.loading .new-chat-icon    { display: none; }
#new-chat-btn.loading .new-chat-spinner { display: inline-block; }
#status-dot {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  transition: background .3s;
}
.dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot.loading { background: var(--warn);   animation: pulse 1s infinite; }

/* ── Beta banner ── */
#beta-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px clamp(12px, 4vw, 48px);
  background: #1a1040;
  border-bottom: 1px solid #6d4ed8;
  color: #c4b5fd;
  font-size: 13px;
  flex-shrink: 0;
}
#beta-banner[hidden] { display: none; }
#beta-banner-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: #c4b5fd;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  opacity: .7;
}
#beta-banner-dismiss:hover { opacity: 1; }
[data-theme="light"] #beta-banner {
  background: #f5f3ff;
  border-color: #7c3aed;
  color: #4c1d95;
}
[data-theme="light"] #beta-banner-dismiss { color: #4c1d95; }
[data-theme="contrast"] #beta-banner {
  background: #000;
  border-color: #c4b5fd;
  color: #c4b5fd;
}
[data-theme="contrast"] #beta-banner-dismiss { color: #c4b5fd; }

/* ── Indexer banner ── */
#indexer-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px clamp(12px, 4vw, 48px);
  background: #2d1f00;
  border-bottom: 1px solid var(--warn);
  color: #fcd34d;
  font-size: 13px;
  flex-shrink: 0;
  animation: fadeUp .25s ease both;
}
#indexer-banner[hidden] { display: none; }
.indexer-banner-icon {
  font-size: 14px;
  flex-shrink: 0;
  animation: spin 2s linear infinite;
}
#indexer-banner-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: #fcd34d;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  opacity: .7;
}
#indexer-banner-dismiss:hover { opacity: 1; }
[data-theme="light"] #indexer-banner {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
}
[data-theme="light"] #indexer-banner-dismiss { color: #92400e; }
[data-theme="contrast"] #indexer-banner {
  background: #000;
  border-color: #ffff00;
  color: #ffff00;
}
[data-theme="contrast"] #indexer-banner-dismiss { color: #ffff00; }

/* ── Chat window ── */
/* ── Chat area — wraps chat-window + input-bar ── */
#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── Conversation starters ── */
#starters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 10px 16px 4px;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}
#app:not(.no-messages) #starters { display: none; }

.starter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  white-space: nowrap;
}
.starter-btn i { font-size: 11px; opacity: .75; }
.starter-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-dim);
}

/* ── No-messages state: center welcome + input like Claude ── */
#app.no-messages #chat-area {
  justify-content: center;
}
#app.no-messages #chat-window {
  flex: 0 0 auto;
  overflow: visible;
  padding: 0 16px 16px;
}
#app.no-messages #input-bar {
  position: relative;
  bottom: auto;
}
#app.no-messages #welcome {
  opacity: 1;
  padding: 0 20px 8px;
}

/* ── Chatting state ── */
#chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
#chat-window::-webkit-scrollbar { width: 4px; }
#chat-window::-webkit-scrollbar-track { background: transparent; }
#chat-window::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#chat-spacer { display: none; }

/* ── Messages ── */
.msg-row {
  display: flex;
  gap: 10px;
  animation: fadeUp .25s ease both;
  width: 100%;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}
.msg-row.user  { flex-direction: row-reverse; }
.msg-row.user > div:last-child { display: flex; flex-direction: column; align-items: flex-end; }

.avatar {
  width: 30px; height: 30px; border-radius: 8px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
  overflow: hidden;
}
.msg-row.user .avatar { background: var(--accent-dim); color: var(--accent); font-size: 14px; }
.msg-row.bot  .avatar { background: var(--avatar-bot-bg); border: 1px solid var(--border); }
.avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
/* Thinking animation — spinning gradient ring around the bot avatar */
.avatar.thinking {
  overflow: visible;
  position: relative;
  border: none !important;
}
.avatar.thinking::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 11px;
  padding: 3px;
  background: conic-gradient(from 0deg, #eba34c, var(--accent), #7bb39d, #d56a4a, #eba34c);
  animation: ring-spin 1.4s linear infinite;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
          mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
}
@keyframes ring-spin {
  to { transform: rotate(360deg); }
}
.avatar.thinking img {
  animation: avatar-spin 4s linear infinite;
}
@keyframes avatar-spin {
  to { transform: rotate(-360deg); }
}

.bubble {
  max-width: clamp(260px, 78%, 900px);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1.65;
  position: relative;
}
.msg-row.user .bubble {
  background: var(--user-bg);
  border: 1px solid var(--user-border, var(--accent-dim));
  border-top-right-radius: 3px;
  color: var(--user-text, #c8d8f8);
  max-width: clamp(260px, 90%, 860px);
  width: max-content;
}

[data-theme="light"] .msg-row.user .bubble {
  background: var(--user-bg);
  border-color: var(--user-border);
  color: var(--user-text);
  font-weight: 500;
}

[data-theme="light"] .msg-row.bot .bubble {
  border-left: none;
}
.msg-row.bot .bubble {
  background: none;
  border: none;
  border-radius: 0;
  padding: 2px 0;
  max-width: clamp(260px, 92%, 960px);
  font-size: 16px;
}
.bubble.error {
  background: #2a1010;
  border: 1px solid #6b2020;
  border-radius: var(--radius);
  color: #f08080;
  padding: 10px 14px;
}

.meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  font-family: var(--font-mono);
  padding: 0 4px;
}
.msg-row.user .meta { text-align: right; }

/* ── HTML content inside bot bubbles ── */
.msg-row.bot .bubble p            { margin: 0 0 8px; }
.msg-row.bot .bubble p:last-child { margin-bottom: 0; }
.msg-row.bot .bubble ul,
.msg-row.bot .bubble ol           { margin: 6px 0 8px 18px; }
.msg-row.bot .bubble li           { margin-bottom: 3px; }
.msg-row.bot .bubble strong,
.msg-row.bot .bubble b            { color: var(--text); font-weight: 600; }
.msg-row.bot .bubble em,
.msg-row.bot .bubble i            { color: #b8c8e8; font-style: italic; }
[data-theme="light"] .msg-row.bot .bubble em,
[data-theme="light"] .msg-row.bot .bubble i  { color: #374ea2; }
[data-theme="contrast"] .msg-row.bot .bubble em,
[data-theme="contrast"] .msg-row.bot .bubble i { color: #ffff99; }
.msg-row.bot .bubble a            { color: var(--accent); text-decoration: underline; word-break: break-word; }
.msg-row.bot .bubble a:hover      { color: #6aa3ff; }
.msg-row.bot .bubble code         {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
  font-family: var(--font-mono); font-size: 13px; color: #7dd3fc;
}
.msg-row.bot .bubble pre          {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; overflow-x: auto;
  margin: 8px 0; font-family: var(--font-mono); font-size: 13px; color: #7dd3fc;
}
.msg-row.bot .bubble pre code     { background: none; border: none; padding: 0; }
.msg-row.bot .bubble h1,
.msg-row.bot .bubble h2,
.msg-row.bot .bubble h3,
.msg-row.bot .bubble h4 {
  font-weight: 600;
  margin: 10px 0 6px;
  color: var(--text);
  line-height: 1.3;
}
.msg-row.bot .bubble h1           { font-size: 20px; }
.msg-row.bot .bubble h2           { font-size: 18px; }
.msg-row.bot .bubble h3           { font-size: 16px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 14px; }
.msg-row.bot .bubble h4           { font-size: 15px; }
.msg-row.bot .bubble p            { margin: 6px 0; }
.msg-row.bot .bubble > p          { font-size: 16px; }
.msg-row.bot .bubble ul,
.msg-row.bot .bubble ol           { margin: 6px 0 6px 18px; padding: 0; }
.msg-row.bot .bubble li           { margin: 4px 0; }
.msg-row.bot .bubble a            { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.msg-row.bot .bubble a:hover      { color: #6aa3ff; }
.msg-row.bot .bubble strong       { font-weight: 600; color: var(--text); }
.msg-row.bot .bubble table        { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 14px; }
.msg-row.bot .bubble th,
.msg-row.bot .bubble td           { border: 1px solid var(--border); padding: 5px 8px; text-align: left; }
.msg-row.bot .bubble th           { background: #1f2535; color: #fff; font-weight: 600; }
.msg-row.bot .bubble hr           { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

/* ── Google Search result style for document results ── */
.msg-row.bot .bubble ul:has(li a.linktosp),
.msg-row.bot .bubble ol:has(li a.linktosp) {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
.msg-row.bot .bubble li:has(a.linktosp) {
  border-top: 1px solid var(--border);
  margin: 0;
  padding: 12px 0;
}

/* Document name — Google blue title */
.msg-row.bot .bubble li:has(a.linktosp) strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent) !important;
  margin-bottom: 3px;
  line-height: 1.4;
}
.msg-row.bot .bubble a.doc-title-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.msg-row.bot .bubble a.doc-title-link::after {
  content: '\f35d';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 11px;
  margin-left: 6px;
  opacity: 0.6;
  vertical-align: middle;
}
.msg-row.bot .bubble a.doc-title-link:hover {
  text-decoration: underline;
}
.msg-row.bot .bubble a.doc-title-link:hover::after {
  opacity: 1;
}
/* URL — Google green breadcrumb (standalone URL links only) */
.msg-row.bot .bubble a.linktosp:not(.doc-title-link) {
  color: #4ade80 !important;
  display: inline-block;
  font-size: 13px;
  margin-bottom: 5px;
  opacity: .85;
  text-decoration: none;
  word-break: break-all;
}
.msg-row.bot .bubble a.linktosp:not(.doc-title-link):hover {
  opacity: 1;
  text-decoration: underline;
}
[data-theme="light"] .msg-row.bot .bubble a.linktosp:not(.doc-title-link) {
  color: #15803d !important;
}
/* Doc feedback pinned to the right of the result row */
.msg-row.bot .bubble li:has(a.linktosp) {
  position: relative;
}
.msg-row.bot .bubble li:has(a.linktosp) .doc-feedback-bar {
  position: absolute;
  top: 12px;
  right: 0;
  display: flex;
  gap: 4px;
}

/* ── Document card body ── */
.msg-row.bot .bubble li:has(a.linktosp) .doc-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 6px;
  line-height: 1.4;
}
.msg-row.bot .bubble li:has(a.linktosp) .doc-summary {
  font-size: 14px;
  color: var(--text);
  margin: 0;
  line-height: 1.6;
}

/* ── Citation-style sources list ── */
.msg-row.bot .bubble p.citations-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 14px 0 4px !important;
}
.msg-row.bot .bubble ol.doc-citations {
  list-style: none;
  counter-reset: citation-counter;
  margin: 0;
  padding: 0;
}
.msg-row.bot .bubble ol.doc-citations li {
  counter-increment: citation-counter;
  border-top: none !important;
  padding: 3px 0 !important;
  font-size: 13px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.msg-row.bot .bubble ol.doc-citations li .doc-feedback-bar {
  display: none;
}
.msg-row.bot .bubble ol.doc-citations li::before {
  content: "[" counter(citation-counter) "]";
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
  min-width: 22px;
}
.msg-row.bot .bubble ol.doc-citations a.doc-title-link {
  font-weight: 500;
  font-size: 13px;
}
.msg-row.bot .bubble ol.doc-citations .doc-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 0 !important;
  display: inline;
}

/* ── No-results prompt ── */
.no-results-bubble {
  background: var(--bot-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-top-left-radius: 3px;
}
.no-results-bubble p { margin: 0; }
.no-results-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-body);
  padding: 5px 14px;
  transition: all .15s;
}
.no-results-btn:hover { border-color: var(--accent); color: var(--accent); }
.no-results-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.no-results-btn.primary:hover { background: #6aa3ff; border-color: #6aa3ff; }

/* deflection badge */
.deflect-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 8px;
  background: #2d1f00;
  border: 1px solid var(--warn);
  color: var(--warn);
  border-radius: 20px;
  font-size: 12px;
  font-family: var(--font-mono);
}

/* ── Feedback buttons ── */
.feedback-bar {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.fb-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 8px;
  transition: all .15s;
  line-height: 1.6;
}
.fb-btn:hover          { border-color: var(--accent); color: var(--text); }
.fb-btn.voted-positive { border-color: var(--success); color: var(--success); background: #0d2318; }
.fb-btn.voted-negative { border-color: #f87171;       color: #f87171;       background: #2a1010; }
.fb-btn:disabled       { cursor: default; opacity: .7; }

/* ── Thumbs icon: two-tone effect per theme ── */
.fb-icon {
  --fa-primary-color:   var(--accent);
  --fa-secondary-color: var(--muted);
  --fa-secondary-opacity: 0.4;
  opacity: 0.55;
  transition: opacity .15s;
}
.fb-btn:hover .fb-icon   { opacity: 1; }
.fb-btn:disabled .fb-icon { opacity: 0.4; }

[data-theme="light"] .fb-icon {
  --fa-primary-color:   #1d4ed8;
  --fa-secondary-color: #94a3b8;
  --fa-secondary-opacity: 0.35;
}
[data-theme="contrast"] .fb-icon {
  --fa-primary-color:   #ffff00;
  --fa-secondary-color: #ffffff;
  --fa-secondary-opacity: 0.5;
}
.fb-btn.voted-positive .fb-icon { opacity: 1; --fa-primary-color: var(--success); }
.fb-btn.voted-negative .fb-icon { opacity: 1; --fa-primary-color: #f87171; }
.doc-feedback-bar {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.fb-btn-sm {
  font-size: .95rem;
  padding: 2px 8px;
}

/* ── Copilot-style follow-up suggestions ── */
.action-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.action-btn {
  align-items: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  font-family: var(--font-body);
  font-size: 14px;
  gap: 8px;
  line-height: 1.4;
  padding: 5px 10px;
  text-align: left;
  transition: border-color .15s, color .15s, background .15s;
  width: fit-content;
}
.action-btn i {
  color: var(--accent);
  flex-shrink: 0;
  font-size: 12px;
  opacity: 0.8;
  transform: rotate(90deg);
}
.action-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-dim);
}
.action-btn:hover i { opacity: 1; }

/* ── Message edit button ── */
.edit-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, color .15s;
  align-self: flex-end;
  margin-top: 2px;
}
.msg-row.user:hover .edit-btn {
  opacity: 1;
  pointer-events: auto;
}
.edit-btn:hover { color: var(--accent); }

/* ── Inline edit state ── */
.edit-textarea {
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--accent);
  color: inherit;
  font-family: var(--font-body);
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  outline: none;
  resize: none;
  width: 100%;
  padding: 0 0 4px;
  overflow: hidden;
  min-height: 1.5em;
}
.edit-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 8px;
}
.edit-save-btn,
.edit-cancel-btn {
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 4px 12px;
  transition: all .15s;
}
.edit-save-btn {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}
.edit-save-btn:hover   { background: #6aa3ff; border-color: #6aa3ff; }
.edit-cancel-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--user-text, #c8d8f8);
}
.edit-cancel-btn:hover { border-color: rgba(255,255,255,0.5); }
[data-theme="light"] .edit-cancel-btn {
  border-color: rgba(0,0,0,0.2);
  color: var(--user-text);
}
[data-theme="light"] .edit-cancel-btn:hover { border-color: rgba(0,0,0,0.4); }

/* Typing indicator */
.typing-bubble {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
}
.typing-dots { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
.typing-label {
  font-size: 13px;
  color: var(--muted);
  opacity: .8;
}
.typing-label-fade {
  animation: typing-label-in .35s ease both;
}
@keyframes typing-label-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: .8; transform: translateY(0); }
}

/* ── Welcome ── */
#welcome {
  margin: auto;
  text-align: center;
  padding: 40px 20px;
  opacity: .7;
}
#welcome .big-icon { font-size: 48px; margin-bottom: 16px; }
.welcome-logo { width: 220px; max-width: 100%; margin-bottom: 20px; opacity: .9; }
.welcome-logo svg { width: 100%; height: auto; display: block; }

/* In dark/contrast themes only invert the text (cls-1 = dark navy #103951),
   leaving the coloured icon paths (cls-2 through cls-5) unchanged */
[data-theme="dark"]     .welcome-logo .cls-1,
[data-theme="contrast"] .welcome-logo .cls-1 { fill: #ffffff; }
#welcome h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
#welcome p  { font-size: 14px; color: var(--muted); max-width: 300px; margin: 0 auto; }

/* ── Input bar — floating pill ── */
#input-bar {
  position: sticky;
  bottom: 0;
  width: 100%;
  padding: 20px clamp(12px, 4vw, 48px) 22px;
  background: transparent;
  will-change: transform; /* spring animation drives transform via rAF */
  display: flex;
  justify-content: center;
}
#input-pill {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 60%;
  min-width: 320px;
  max-width: 600px;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: 26px;
  padding: 8px 8px 8px 20px;
  box-shadow: 0 6px 28px rgba(0,0,0,.28), 0 1px 4px rgba(0,0,0,.14);
  transition: border-color .2s, box-shadow .2s;
}
#input-pill:focus-within {
  border-color: var(--accent);
  box-shadow: 0 6px 32px rgba(79,142,247,.26), 0 1px 4px rgba(0,0,0,.12);
}
#user-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 6px 0;
  resize: none;
  outline: none;
  max-height: 140px;
  min-height: 32px;
  line-height: 1.55;
}
#user-input::placeholder { color: var(--muted); }

#send-btn {
  width: 36px; height: 36px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}
#send-btn:hover    { background: #6aa3ff; }
#send-btn:active   { transform: scale(.90); }
#send-btn:disabled { background: var(--border); cursor: not-allowed; opacity: .6; }

/* ── Responsive breakpoints ── */
@media (max-width: 480px) {
  #chat-window { padding: 12px 12px 8px; gap: 10px; }
  #header      { padding: 10px 12px; }
  #input-bar  { padding: 14px 10px 16px; }
  #input-pill { padding: 6px 6px 6px 14px; border-radius: 22px; width: 100%; }
  .header-sub  { display: none; }
  .bubble                 { max-width: 95%; font-size: 15px; }
  .msg-row.user .bubble   { max-width: 85%; }
  #welcome h2  { font-size: 16px; }
}

@media (min-width: 481px) and (max-width: 768px) {
  .bubble               { max-width: 88%; }
  .msg-row.user .bubble { max-width: 75%; }
}

@media (min-width: 769px) and (max-width: 1199px) {
  .bubble               { max-width: 80%; }
  .msg-row.user .bubble { max-width: 68%; }
}

@media (min-width: 1200px) {
  .bubble               { max-width: 100%; }
  .msg-row.user .bubble { max-width: 100%; }
  #chat-window { padding: 24px clamp(48px, 8vw, 120px); }
}

/* ── Keyframes ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%,100% { opacity: 1; } 50% { opacity: .3; }
}
@keyframes bounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-5px); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Typewriter cursor */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: blink-cursor .6s step-end infinite;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Closing follow-up question paragraph */
.msg-row.bot .bubble .sharon-closing {
  margin-top: 1rem;
  font-style: normal;
}

/* ── Related Pages in SharePoint ── */
.site-pages-section {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.site-pages-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}
.site-pages-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.site-pages-list li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
a.page-title-link {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
}
a.page-title-link::before {
  content: '\f0c1';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 11px;
  margin-right: 5px;
  opacity: 0.55;
}
a.page-title-link:hover { text-decoration: underline; }

/* ── Inaccessible document links ── */
.access-denied-link {
  color: #b91c1c;
  text-decoration: none;
  border-bottom: 1px dashed #b91c1c;
  transition: color 0.15s ease, background 0.15s ease;
  border-radius: 2px;
  padding: 0 2px;
}
.access-denied-link:hover {
  color: #991b1b;
  background: rgba(185, 28, 28, 0.08);
  border-bottom-style: solid;
}
.page-summary {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
          line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.page-meta {
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.7;
  margin: 0;
}
