:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1d2733;
  --muted: #6b7785;
  --border: #e2e6ea;
  --brand: #0a6cba;
  --brand-ink: #ffffff;
  --user-bg: #0a6cba;
  --user-ink: #ffffff;
  --assistant-bg: #eef1f4;
  --assistant-ink: #1d2733;
  --shadow: 0 1px 3px rgba(16, 28, 43, 0.08), 0 8px 24px rgba(16, 28, 43, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --panel: #171d25;
    --text: #e6ebf1;
    --muted: #9aa6b3;
    --border: #28323d;
    --brand: #3a9be0;
    --assistant-bg: #1f2731;
    --assistant-ink: #e6ebf1;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  justify-content: center;
}

.chat {
  width: min(820px, 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.chat__brand { display: flex; align-items: center; gap: 12px; }

.chat__logo {
  width: 38px; height: 38px;
  border-radius: 9px;
  object-fit: contain;
  flex: none;
}

.chat__title { margin: 0; font-size: 16px; }
.chat__subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.chat__badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
}

.chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg { display: flex; }
.msg--user { justify-content: flex-end; }
.msg--assistant { justify-content: flex-start; }

.msg__bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg--user .msg__bubble {
  background: var(--user-bg);
  color: var(--user-ink);
  border-bottom-right-radius: 4px;
}

.msg--assistant .msg__bubble {
  background: var(--assistant-bg);
  color: var(--assistant-ink);
  border-bottom-left-radius: 4px;
}

.msg__bubble--typing { display: inline-flex; gap: 5px; align-items: center; }
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  opacity: 0.5;
  animation: blink 1.3s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 0.9; } }

.chat__composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 16px 6px;
  border-top: 1px solid var(--border);
}

.chat__input {
  flex: 1;
  resize: none;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  max-height: 160px;
}
.chat__input:focus { outline: 2px solid var(--brand); outline-offset: 0; }

.chat__send {
  font: inherit;
  font-weight: 600;
  color: var(--brand-ink);
  background: var(--brand);
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  cursor: pointer;
}
.chat__send:disabled { opacity: 0.5; cursor: default; }

.chat__disclaimer {
  margin: 0;
  padding: 4px 16px 12px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

/* Support-ticket confirmation card */
.confirm-card {
  align-self: flex-start;
  max-width: 88%;
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 12px;
  background: var(--assistant-bg);
  padding: 12px 14px;
  font-size: 14px;
}
.confirm-card__head { font-weight: 700; margin-bottom: 8px; }
.confirm-card__row { display: flex; gap: 8px; margin: 2px 0; }
.confirm-card__row > span { color: var(--muted); min-width: 64px; }
.confirm-card__desc {
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--panel);
  border-radius: 8px;
  white-space: pre-wrap;
  max-height: 180px;
  overflow-y: auto;
}
.confirm-card__actions { display: flex; gap: 8px; margin-top: 6px; }
.confirm-card__yes, .confirm-card__no {
  font: inherit; font-weight: 600; border-radius: 9px; padding: 7px 14px; cursor: pointer; border: none;
}
.confirm-card__yes { background: var(--brand); color: var(--brand-ink); }
.confirm-card__no { background: transparent; color: var(--text); border: 1px solid var(--border); }
.confirm-card__yes:disabled, .confirm-card__no:disabled { opacity: 0.5; cursor: default; }
.confirm-card--done { opacity: 0.7; }

/* Background-action confirmation chip (auto CRM, raised ticket) */
.action-chip {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--assistant-bg);
  border-radius: 999px;
  padding: 4px 12px;
  margin: 2px 0;
}
.action-chip a { color: var(--brand); }

/* Header sign-in state (standalone page) */
.chat__session { display: flex; align-items: center; gap: 10px; }

.chat__user {
  font-size: 13px;
  color: var(--text);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat__signin {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  color: var(--brand-ink);
  background: var(--brand);
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
}
.chat__signin:hover { filter: brightness(1.05); }

.chat__link-btn {
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  text-decoration: underline;
}
.chat__link-btn:hover { color: var(--text); }

/* OIDC callback popup page (/oauth/callback) */
.oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}
.oauth__panel { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.oauth__logo { width: 40px; height: 40px; border-radius: 9px; object-fit: contain; }
.oauth__msg { margin: 0; color: var(--muted); font-size: 14px; }
