:root {
  font-family: Inter, Arial, ui-sans-serif, system-ui, sans-serif;
  color: #152238;
  background: #f4f7fb;
  line-height: 1.55;
  --navy: #143f8f;
  --blue: #0069b4;
  --cyan: #00a6d6;
  --ink: #152238;
  --muted: #5f6f84;
  --line: #d9e3ef;
  --surface: #fff;
  --soft: #edf7fb;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

header {
  min-height: 76px;
  padding: 0 max(20px, calc((100% - 1060px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 4px solid var(--cyan);
  box-shadow: 0 8px 24px #0f31591a;
  color: var(--ink);
}

header a {
  color: var(--blue);
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 700;
}

main {
  max-width: 1060px;
  margin: 28px auto;
  padding: 0 20px;
}

.narrow {
  max-width: 460px;
  margin: 9vh auto;
}

.card,
.messages {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 10px 32px #143f8f14;
}

h1 {
  margin-top: 0;
  font-size: 1.4rem;
}

h2 {
  margin-top: 0;
}

label {
  display: grid;
  gap: .4rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #a8b6c7;
  border-radius: 7px;
  font: inherit;
}

button,
.button-link {
  min-height: 44px;
  background: var(--blue);
  color: white;
  border: 0;
  border-radius: 7px;
  padding: 10px 18px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.button-link:hover {
  background: var(--navy);
}

button:disabled {
  opacity: .55;
  cursor: wait;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

form {
  display: flex;
  gap: 12px;
  align-items: end;
}

.narrow form,
.card > form {
  flex-direction: column;
  align-items: stretch;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand img {
  display: block;
  width: 170px;
  height: auto;
}

.brand span {
  display: grid;
  border-left: 1px solid #cfd9e6;
  padding-left: 18px;
  line-height: 1.25;
}

.brand strong {
  color: var(--navy);
  font-size: 15px;
}

.brand small {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.login-page {
  min-height: 100dvh;
  background:
    radial-gradient(circle at top left, #dff6ff 0, transparent 32%),
    linear-gradient(180deg, #f7fbff 0, #eef4fa 60%, #f7f9fc 100%);
}

.login-page header {
  justify-content: flex-start;
}

.login-card {
  padding: 30px;
  border-top: 4px solid var(--blue);
}

.login-heading h1 {
  font-size: 26px;
  margin: 4px 0 8px;
  color: var(--navy);
}

.login-heading p,
.admin-title p {
  color: var(--muted);
  margin-top: 0;
}

.eyebrow {
  font-size: 11px;
  font-weight: 900;
  color: var(--blue);
  letter-spacing: .08em;
}

.access-switch {
  text-align: center;
  margin: 18px 0 0;
}

.access-switch a {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.login-alert {
  display: grid;
  gap: 3px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border-left: 4px solid var(--danger);
  background: #fff2f2;
  color: #7a1b14;
  border-radius: 4px;
}

.login-alert strong {
  font-size: 14px;
}

.login-alert span {
  font-size: 13px;
}

.login-card input[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fffafa;
  box-shadow: 0 0 0 1px var(--danger);
}

.password-toggle {
  display: flex !important;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.password-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--blue);
}

.login-card form {
  gap: 14px;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 96px);
}

.messages {
  min-height: 58vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
}

.messages article {
  max-width: min(78%, 720px);
  padding: 13px 16px;
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.question {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--blue), var(--navy));
  color: white;
}

.answer {
  align-self: flex-start;
  display: flex;
  gap: 11px;
  background: var(--soft);
  border: 1px solid #d6edf6;
}

.bot-mark {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--cyan), var(--blue));
  color: white;
  font-size: 13px;
  font-weight: 900;
}

.welcome p {
  margin: 3px 0 0;
  color: var(--muted);
}

.message-content {
  min-width: 0;
}

.message-content > :first-child {
  margin-top: 0;
}

.message-content > :last-child {
  margin-bottom: 0;
}

.message-content h1 {
  font-size: 1.25rem;
}

.message-content h2 {
  font-size: 1.1rem;
}

.message-content h3 {
  font-size: 1rem;
}

.message-content p,
.message-content ul,
.message-content ol {
  margin: 8px 0;
}

.message-content table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.message-content th,
.message-content td {
  border: 1px solid #cbd5df;
  padding: 7px 9px;
  text-align: left;
}

.message-content pre {
  overflow: auto;
  background: #152238;
  color: #eef7fb;
  padding: 12px;
  border-radius: 6px;
}

.message-content code {
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.composer {
  position: sticky;
  bottom: 0;
  background: #f4f7fb;
  padding-top: 10px;
}

.composer textarea {
  min-height: 48px;
  max-height: 160px;
  resize: none;
  background: white;
}

.composer button {
  min-width: 94px;
}

.composer-hint {
  text-align: right;
  margin: 4px 0 0;
  color: #6b7a8d;
  font-size: 12px;
}

.typing {
  align-items: center;
  min-width: 205px;
}

.typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-radius: 50%;
  background: #59728f;
  animation: pulse 1.1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: .15s;
}

.typing span:nth-child(3) {
  animation-delay: .3s;
}

.typing small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.error {
  color: #8f1d1d;
  background: #fff1f1;
}

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

.admin-title {
  margin: 8px 0 24px;
}

.admin-title h1 {
  font-size: 28px;
  margin: 4px 0 5px;
  color: var(--navy);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: .7rem;
  border-bottom: 1px solid #e5e7eb;
}

.actions,
.actions form {
  display: flex;
  gap: .4rem;
}

.secondary {
  background: #52657b;
}

.danger {
  background: var(--danger);
}

.preview-notice {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 14px;
  padding: 10px 14px;
  border-left: 4px solid var(--cyan);
  background: #e9f9ff;
  color: #234052;
  border-radius: 4px;
}

.preview-notice span {
  font-size: 13px;
}

.error-page {
  min-height: 100dvh;
  background: #f4f7fb;
}

.error-page header {
  justify-content: flex-start;
}

.error-shell {
  max-width: 600px;
  margin: 11vh auto;
}

.error-card {
  text-align: center;
  padding: 40px;
}

.error-code {
  display: block;
  color: var(--blue);
  font-size: 58px;
  font-weight: 900;
  line-height: 1;
}

.error-card h1 {
  margin: 14px 0 8px;
  color: var(--navy);
  font-size: 27px;
}

.error-card p {
  color: var(--muted);
  margin: 0 auto 24px;
  max-width: 440px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: .3;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }

  .typing span {
    animation: none;
    opacity: .7;
  }
}

@media (max-width: 600px) {
  header {
    min-height: 70px;
    padding: 0 16px;
  }

  .brand {
    gap: 10px;
  }

  .brand img {
    width: 128px;
  }

  .brand span {
    padding-left: 10px;
  }

  .brand small {
    display: none;
  }

  .login-page header {
    justify-content: center;
  }

  .login-card {
    padding: 22px;
  }

  .header-actions {
    gap: 10px;
  }

  .header-actions a {
    font-size: 12px;
  }

  .chat-shell {
    margin: 14px auto;
    padding: 0 12px;
  }

  .messages {
    padding: 14px;
    min-height: 62vh;
  }

  .messages article {
    max-width: 94%;
  }

  .composer {
    align-items: stretch;
    flex-direction: column;
  }

  .composer button {
    width: 100%;
  }

  .composer-hint {
    display: none;
  }

  .preview-notice {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  table {
    font-size: .9rem;
  }

  .error-shell {
    margin: 9vh auto;
    padding: 0 16px;
  }

  .error-card {
    padding: 30px 22px;
  }
}
