:root {
  --un-blue: #3297eb;
  --un-blue-dark: #1471bf;
  --ink: #172033;
  --muted: #697386;
  --line: #e4eaf2;
  --soft: #f6f9fc;
  --white: #ffffff;
  --danger: #b42318;
  font-family:
    "Aptos",
    "Segoe UI",
    system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--white);
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(50, 151, 235, 0.08), transparent 38%),
    var(--white);
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 34px;
  box-shadow: 0 18px 60px rgba(23, 32, 51, 0.1);
  background: var(--white);
}

.login-logo {
  width: 82px;
  height: 82px;
  object-fit: contain;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--un-blue-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  font-size: 30px;
  line-height: 1.1;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.login-form input,
.composer textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: var(--white);
}

.login-form input {
  height: 44px;
  padding: 0 13px;
}

.login-form input:focus,
.composer textarea:focus {
  border-color: var(--un-blue);
  box-shadow: 0 0 0 3px rgba(50, 151, 235, 0.16);
}

.login-form button,
.composer button,
.new-chat {
  border: 0;
  border-radius: 8px;
  background: var(--un-blue);
  color: var(--white);
  font-weight: 750;
}

.login-form button {
  height: 46px;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 308px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--soft);
  padding: 22px;
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brand p {
  margin: 0 0 2px;
  color: var(--un-blue-dark);
  font-size: 12px;
  font-weight: 800;
}

.brand h1 {
  font-size: 17px;
  line-height: 1.2;
}

.new-chat {
  height: 42px;
}

.chat-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.chat-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.chat-item:hover,
.chat-item.active {
  border-color: var(--line);
  background: var(--white);
}

.chat-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.chat-item span {
  color: var(--muted);
  font-size: 12px;
}

.logout {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 40px;
  color: var(--muted);
  background: var(--white);
}

.chat-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 18px 28px;
}

.chat-header h2 {
  font-size: 22px;
}

.account-context {
  max-width: 46%;
  border: 1px solid rgba(50, 151, 235, 0.32);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--un-blue-dark);
  background: rgba(50, 151, 235, 0.08);
  font-size: 13px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  padding: 28px;
}

.empty-state {
  margin: auto;
  max-width: 520px;
  color: var(--muted);
  text-align: center;
}

.message {
  max-width: min(760px, 88%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--white);
  box-shadow: 0 6px 20px rgba(23, 32, 51, 0.04);
}

.message.user {
  align-self: flex-end;
  border-color: rgba(50, 151, 235, 0.34);
  background: rgba(50, 151, 235, 0.08);
}

.message.assistant {
  align-self: flex-start;
}

.message-role {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.message-content {
  white-space: pre-wrap;
  line-height: 1.5;
}

.citations,
.candidate-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.citation {
  border-left: 3px solid var(--un-blue);
  padding: 7px 10px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
}

.candidate-button {
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(50, 151, 235, 0.34);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--un-blue-dark);
  background: var(--white);
  font-weight: 750;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 16px 28px;
  background: var(--white);
}

.composer textarea {
  min-height: 46px;
  max-height: 160px;
  resize: none;
  padding: 12px 13px;
  line-height: 1.4;
}

.composer button {
  height: 46px;
}

.typing-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  background: var(--white);
  box-shadow: 0 6px 20px rgba(23, 32, 51, 0.04);
}

.typing-indicator .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.message-content.streaming::after {
  content: "▋";
  display: inline-block;
  opacity: 0.7;
  animation: cursor-blink 0.8s step-end infinite;
}

@keyframes cursor-blink {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 0;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 260px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .account-context {
    max-width: 100%;
  }

  .chat-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .message {
    max-width: 100%;
  }
}
