:root {
  color-scheme: light;
  --ink: #25282a;
  --muted: #6c7073;
  --line: #d9dcde;
  --panel: #ffffff;
  --canvas: #f5f5f4;
  --brand: #28495a;
  --brand-dark: #1d3542;
  --brand-soft: #eaf0f3;
  --accent: #f04b32;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--panel);
}

button, textarea { font: inherit; }

.chat-shell {
  position: relative;
  height: 100%;
  min-height: 500px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
}

.chat-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 12px 18px;
  color: var(--brand);
  background: white;
  border-top: 5px solid var(--brand);
  border-bottom: 2px solid var(--accent);
}

.brand-logo {
  display: block;
  width: min(205px, 100%);
  height: auto;
}

.status { margin-right: 30px; color: var(--brand); font-size: 0.72rem; opacity: 0.88; }
.status span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--brand);
}

.messages {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  padding: 18px 16px 8px;
  background: var(--canvas);
}

.message {
  width: fit-content;
  max-width: 90%;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px;
  background: white;
  box-shadow: 0 3px 10px rgb(45 48 50 / 5%);
  font-size: 0.9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.message.user {
  margin-left: auto;
  border-color: #cfd2d4;
  border-radius: 14px 4px 14px 14px;
  background: var(--brand-soft);
}

.message.user .content { white-space: pre-wrap; }
.message.pending .content { color: var(--muted); font-style: italic; }
.content p { margin: 0 0 7px; }
.content p:last-child { margin-bottom: 0; }
.content ul, .content ol { margin: 4px 0 7px; padding-left: 20px; }
.content li { margin: 2px 0; }
.content a, .sources a { color: var(--brand); font-weight: 650; }

.sender {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.sources-label {
  margin: 10px 0 3px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.sources { margin: 0; padding-left: 18px; font-size: 0.84rem; }

.quick-actions {
  display: grid;
  gap: 7px;
  padding: 10px 16px 12px;
  background: var(--canvas);
}

.quick-actions[hidden] { display: none; }

.quick-actions p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.75rem;
}

.quick-actions button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 39px;
  padding: 8px 11px;
  border: 1px solid #cbd5da;
  border-left: 4px solid var(--brand);
  border-radius: 5px;
  color: var(--brand-dark);
  background: white;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.quick-actions button:hover, .quick-actions button:focus-visible {
  border-color: var(--brand);
  background: var(--brand-soft);
  outline: none;
}

.quick-actions button:disabled { cursor: wait; opacity: 0.55; }

.composer {
  display: flex;
  align-items: end;
  gap: 8px;
  padding: 12px 14px 7px;
  border-top: 1px solid var(--line);
}

textarea {
  flex: 1;
  min-width: 0;
  max-height: 92px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 11px;
  color: var(--ink);
  background: white;
}

textarea:focus { outline: 3px solid rgb(40 73 90 / 16%); border-color: var(--brand); }
textarea:disabled { background: var(--canvas); cursor: not-allowed; }

#send {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  color: white;
  background: var(--brand);
  cursor: pointer;
}

#send:hover { background: var(--brand-dark); }
#send:disabled { cursor: wait; opacity: 0.55; }
#send svg { width: 19px; fill: currentColor; }

.disclaimer {
  margin: 0;
  padding: 0 16px 10px;
  color: var(--muted);
  background: white;
  font-size: 0.65rem;
  line-height: 1.35;
  text-align: center;
}

.login {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(29 53 66 / 45%);
}

.login[hidden] { display: none; }

.login-card {
  width: min(330px, 100%);
  padding: 18px 18px 14px;
  border-top: 5px solid var(--brand);
  border-radius: 10px;
  background: white;
  box-shadow: 0 18px 50px rgb(29 53 66 / 28%);
  font-size: 0.86rem;
  line-height: 1.45;
}

.login-card h2 { margin: 0 0 6px; color: var(--brand-dark); font-size: 1.02rem; }
.login-card p { margin: 0 0 12px; color: var(--ink); }
.login-card label { display: block; margin-bottom: 4px; font-size: 0.75rem; font-weight: 700; color: var(--muted); }

.login-card input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
}

.login-card input:focus { outline: 3px solid rgb(40 73 90 / 16%); border-color: var(--brand); }
.login-error { margin: 6px 0 0 !important; color: #b3261e !important; font-size: 0.78rem; }
.login-error[hidden] { display: none; }

.login-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 14px 0 10px; }

.login-actions button {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  color: white;
  background: var(--brand);
  font-weight: 700;
  cursor: pointer;
}

.login-actions button:hover { background: var(--brand-dark); }
.login-actions .login-secondary { color: var(--brand); background: white; }
.login-actions .login-secondary:hover { background: var(--brand-soft); }
.login-actions button:disabled { cursor: wait; opacity: 0.55; }
.login-note { margin: 0 !important; color: var(--muted) !important; font-size: 0.7rem; }
.login-note a { color: var(--brand); font-weight: 650; }

.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;
}

@media (max-width: 420px) {
  .status { display: none; }
  .chat-header { grid-template-columns: 1fr; min-height: 70px; }
  .brand-logo { width: 190px; }
}
