:root {
  --bg: #f0f5fb;
  --panel: #ffffff;
  --header-bg: #132245;
  --header-bg-alt: #005A8B;
  --brand: #005A8B;
  --brand-dark: #132245;
  --brand-light: #DDEBF9;
  --accent: #FEDE42;
  --text: #201F1F;
  --muted: #5A5A5A;
  --line: #DEDEDE;
  --user-bubble: #DDEBF9;
  --assistant-bubble: #ffffff;
  --shadow: 0 4px 24px rgba(19, 34, 69, 0.10);
  --shadow-header: 0 2px 12px rgba(19, 34, 69, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Inter", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* ── Header ── */
.site-header {
  background: linear-gradient(135deg, var(--header-bg) 0%, var(--header-bg-alt) 50%, var(--header-bg) 100%);
  background-size: 200% 100%;
  animation: gradient-slide 16s ease-in-out infinite;
  box-shadow: var(--shadow-header);
  padding: 0 32px;
  border-bottom: 2px solid var(--accent);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 0;
  user-select: none;
}

.header-umb-logo {
  height: 36px;
  width: auto;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}

.header-logo {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-logo-name {
  font-family: "Lora", serif;
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.header-logo-tagline {
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.header-divider {
  width: 1px;
  height: 36px;
  background: rgba(255, 255, 255, 0.22);
  margin: 0 4px;
}

.header-tool-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.04em;
}

.header-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-ssl-link {
  /* Keeps "Sign in" on one line; the narrow-screen padding otherwise wraps it. */
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--header-bg);
  text-decoration: none;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 6px 14px;
  transition: background 130ms ease, color 130ms ease;
}

.header-ssl-link:hover {
  background: #e8cc2a;
  border-color: #e8cc2a;
}

/* ── Main shell ── */
.shell {
  width: min(1100px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 14px 0 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-layout {
  display: flex;
  flex: 1;
  gap: 16px;
  min-height: 0;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #ffffff;
  background: linear-gradient(135deg, var(--header-bg) 0%, var(--header-bg-alt) 100%);
  flex-shrink: 0;
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  overflow-y: auto;
  flex: 1;
}

.sidebar-empty {
  padding: 12px 16px;
  font-size: 12px;
  color: #aab4be;
  font-style: italic;
}

.sidebar-item {
  padding: 0;
}

.sidebar-link {
  width: 100%;
  display: block;
  border: 0;
  background: transparent;
  padding: 9px 16px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-left: 3px solid transparent;
  line-height: 1.4;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.sidebar-link:hover {
  background: var(--brand-light);
  border-left-color: var(--accent);
  color: var(--brand-dark);
}

/* ── Hero ── */
.hero {
  padding: 0 4px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  flex-shrink: 0;
}

.hero h1 {
  margin: 0 0 4px;
  font-family: "Lora", serif;
  font-size: clamp(18px, 2.2vw, 26px);
  font-weight: 700;
  color: var(--brand-dark);
  line-height: 1.15;
}

.hero-copy {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 680px;
}

/* ── Chat card ── */
.chat-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--header-bg) 0%, var(--header-bg-alt) 50%, var(--header-bg) 100%);
  background-size: 200% 100%;
  animation: gradient-slide 16s ease-in-out infinite;
  border-bottom: none;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #28a745;
  flex-shrink: 0;
  transition: background 200ms ease;
}

.status-dot.processing {
  background: #f59e0b;
  animation: blink-dot 800ms ease-in-out infinite;
}

@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

.chat-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.02em;
}

/* ── Messages ── */
.chat-messages {
  flex: 1;
  padding: 24px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: rise-in 200ms ease;
}

.message.user {
  align-items: flex-end;
}

.message-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0 4px;
}

.assistant-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--brand);
  flex-shrink: 0;
}

.assistant-icon svg {
  width: 14px;
  height: 14px;
}

.message-bubble {
  max-width: min(680px, 82%);
  padding: 13px 16px;
  border-radius: 10px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}

.message-bubble p {
  margin: 0 0 10px;
}

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

.bubble-link {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 130ms ease;
}

.bubble-link:hover {
  color: var(--brand-dark);
}

.message-bubble ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.message-bubble li + li {
  margin-top: 5px;
}

.message.assistant .message-bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--line);
  border-top-left-radius: 2px;
}

.message.user .message-bubble {
  background: var(--user-bubble);
  border: 1px solid #b9d4ee;
  border-top-right-radius: 2px;
  color: var(--brand-dark);
}

/* ── Sources ── */
.message-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(680px, 82%);
  padding: 0 2px;
}

.sources-label {
  width: 100%;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.message-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: min(700px, 84%);
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 4px;
  border: 1px solid #b9d4ee;
  background: var(--brand-light);
  color: var(--brand-dark);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: background 130ms ease, border-color 130ms ease;
}

.source-chip:hover {
  background: #c8ddf5;
  border-color: #93bde0;
}

.source-chip-disabled {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

.option-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 42px;
  max-width: min(520px, 84vw);
  padding: 10px 15px;
  border-radius: 18px;
  border: 1px solid rgba(45, 106, 79, 0.18);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(45, 70, 54, 0.08);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.option-bubble:hover {
  background: #fff;
  border-color: rgba(45, 106, 79, 0.32);
  transform: translateY(-1px);
}

/* ── Suggested questions ── */
.suggested-questions {
  padding: 4px 2px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggested-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
}

.suggested-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggested-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--brand);
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease;
}

.suggested-btn:hover {
  background: var(--brand);
  color: #ffffff;
}

/* ── Composer ── */
.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: #f8fafd;
}

.composer input {
  flex: 1;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 16px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: #ffffff;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

.composer input::placeholder {
  color: #9aacbb;
}

.composer input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 90, 139, 0.12);
}

.composer button {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 999px;
  background: var(--brand);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 130ms ease, transform 130ms ease;
}

.composer button:hover {
  background: var(--brand-dark);
  box-shadow: 0 0 0 2px var(--accent);
}

.composer button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.send-arrow {
  display: inline-block;
  font-size: 22px;
  line-height: 1;
}

/* ── Loading dots ── */
.loading-bubble {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 70px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #93bde0;
  animation: pulse-dot 1.1s infinite ease-in-out;
}

.dot:nth-child(2) { animation-delay: 0.18s; }
.dot:nth-child(3) { animation-delay: 0.36s; }

/* ── Footer ── */
.site-footer {
  padding: 7px 32px;
  border-top: 2px solid #FF791F;
  background: #F5F0E6;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 11px;
  color: var(--brand-dark);
  flex-shrink: 0;
}

.footer-site-link {
  color: var(--brand-dark);
  text-decoration: none;
  transition: color 130ms ease;
}

.footer-site-link:hover {
  color: #FF791F;
}

.footer-credit {
  font-size: 11px;
  color: #8a8a8a;
  font-style: italic;
}

.footer-email-btn {
  font-size: 12px;
  font-weight: 500;
  color: var(--brand-dark);
  text-decoration: none;
  border: 1px solid var(--brand-dark);
  border-radius: 999px;
  padding: 5px 13px;
  transition: background 130ms ease, color 130ms ease;
}

.footer-email-btn:hover {
  background: var(--brand-dark);
  color: #ffffff;
}

/* ── Accessibility ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Suggestion chips (dynamic follow-up questions) ── */
.suggestion-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 2px 2px;
  max-width: min(680px, 82%);
}

.suggestion-chips-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
}

.suggestion-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--brand);
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease;
}

.suggestion-chip:hover {
  background: var(--brand);
  color: #ffffff;
}

/* ── Animations ── */
@keyframes gradient-slide {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes pulse-dot {
  0%, 100% { background: #b9d4ee; transform: scale(0.9); }
  40%       { background: var(--brand); transform: scale(1.1); }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 680px) {
  .site-header { padding: 0 16px; }
  .header-logo-name { font-size: 18px; }
  /* Keep the account controls on small screens. This was display:none, which
     removed Sign in along with everything else, so a visitor on a phone had no
     way to sign in or reach their saved history — the button was in the DOM
     and visible, inside a nav the browser was not painting. Only the external
     SSL link is dropped; it is repeated in the footer. */
  .header-links { gap: 6px; }
  .header-links a.header-ssl-link[href^="https://www.umb.edu"] { display: none; }
  .header-links .header-ssl-link { padding: 5px 10px; font-size: 12px; }
  .account-email { max-width: 96px; }

  .shell {
    width: calc(100vw - 16px);
    padding-top: 20px;
  }

  .hero { padding-bottom: 10px; margin-bottom: 10px; }

  .sidebar { display: none; }

  .chat-card { border-radius: 8px; }

  .chat-messages { padding: 16px 14px; }

  .message-bubble { max-width: 90%; font-size: 14px; }

  .composer { padding: 10px 12px; }
}

/* Optional visitor accounts: sign-in control and dialog. */
.account-area {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* An explicit display value beats the default [hidden] rule, so restate it.
   Without this the sign-in control shows on deployments that have no accounts
   configured. */
.account-area[hidden],
.account-email[hidden] {
  display: none;
}

.account-email {
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sidebar: new-chat control, active chat, delete affordance */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-new {
  background: none;
  border: 1px solid rgba(19, 34, 69, 0.25);
  border-radius: 999px;
  padding: 2px 9px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--header-bg, #132245);
  cursor: pointer;
  white-space: nowrap;
}

.sidebar-new:hover { background: rgba(19, 34, 69, 0.08); }

.sidebar-item { display: flex; align-items: center; gap: 4px; }
.sidebar-item .sidebar-link { flex: 1; text-align: left; }

.sidebar-item.is-active {
  background: rgba(19, 34, 69, 0.08);
  border-radius: 8px;
}

.sidebar-delete {
  background: none;
  border: none;
  color: rgba(19, 34, 69, 0.45);
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease;
}

.sidebar-item:hover .sidebar-delete,
.sidebar-delete:focus-visible { opacity: 1; }
.sidebar-delete:hover { color: #b3261e; background: rgba(179, 38, 30, 0.1); }

/* Confirm-your-email dialog: its own box, shown after a successful signup. */
.notice-dialog { max-width: 380px; text-align: left; }

.notice-body {
  margin: 4px 0 18px;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(19, 34, 69, 0.85);
}

.account-button {
  /* Match the yellow header pills. This used to be a transparent chip with a
     white border, and `font: inherit` also discarded the pill's 13px/600, so
     the control sat next to "Visit SSL" at a different size, weight and
     colour. A <button> only needs its native font and line-height neutralised;
     everything else comes from .header-ssl-link. */
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  -webkit-appearance: none;
  appearance: none;
}

.account-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.sidebar-note {
  margin: 10px 12px 0;
  color: #5b6472;
  font-size: 12px;
  line-height: 1.45;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-delete {
  flex: none;
  background: none;
  border: 0;
  color: #8b95a3;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
}

.sidebar-delete:hover {
  background: #f0f2f6;
  color: #b3261e;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(11, 26, 47, 0.55);
}

.auth-overlay[hidden] {
  display: none;
}

.auth-dialog {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 24px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(11, 26, 47, 0.28);
}

.auth-dialog h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.auth-blurb {
  margin: 0 0 16px;
  color: #5b6472;
  font-size: 13px;
  line-height: 1.5;
}

.auth-dialog label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #3d4757;
}

.auth-dialog input {
  width: 100%;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #d4d9e1;
  border-radius: 8px;
  font: inherit;
  box-sizing: border-box;
}

.auth-dialog input:focus {
  outline: 2px solid #1b4a8a;
  outline-offset: 1px;
}

.auth-submit {
  width: 100%;
  padding: 11px;
  border: 0;
  border-radius: 8px;
  background: #1b4a8a;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: progress;
}

.auth-error {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fdecea;
  color: #b3261e;
  font-size: 12px;
}

.auth-switch {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12px;
  color: #5b6472;
}

.auth-switch button {
  background: none;
  border: 0;
  color: #1b4a8a;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
}

.auth-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: 0;
  color: #8b95a3;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.auth-forgot {
  margin: 10px 0 0;
  text-align: center;
}

.auth-forgot button {
  background: none;
  border: 0;
  color: #5b6472;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
}

.auth-forgot[hidden],
.auth-forgot button[hidden] {
  display: none;
}

.auth-field[hidden] {
  display: none;
}

/* ---- Warming notice -----------------------------------------------------
   The Space sleeps after a quiet period and needs a few seconds to load its
   index on the next visit. That is rare, so this stays hidden unless the
   backend actually reports it -- no spinner flash for the usual warm case. */
.warming-notice {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 16px 10px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--brand-light);
  color: var(--text);
  font-size: 13px;
}

.warming-notice[hidden] { display: none; }

.warming-spinner {
  flex: none;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(0, 90, 139, 0.25);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: warming-spin 750ms linear infinite;
}

@keyframes warming-spin { to { transform: rotate(360deg); } }

.composer input:disabled,
.composer button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .warming-spinner { animation-duration: 2.4s; }
}
