* {
  box-sizing: border-box;
}

:root {
  font-family:
    Inter,
    "Segoe UI",
    Arial,
    sans-serif;

  color: #172033;
  background: #f5f7fb;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(
      180deg,
      #f7f9fc 0%,
      #f2f5fa 100%
    );
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.page {
  min-height: 100vh;
}

.fatal-config-error {
  margin: 0;
  padding: 30px;
  font-family: sans-serif;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 430px;
  background: #ffffff;
  border: 1px solid #e5e9f0;
  border-radius: 18px;
  padding: 32px;
  box-shadow:
    0 18px 50px rgba(20, 32, 55, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 30px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: #1f5eff;
  color: white;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.brand p {
  margin: 0;
  color: #697386;
  font-size: 14px;
}

label {
  display: block;
  margin: 18px 0 7px;
  font-size: 14px;
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  border: 1px solid #d8deea;
  border-radius: 10px;
  background: white;
  color: #172033;
  outline: none;
}

input {
  height: 46px;
  padding: 0 13px;
}

textarea {
  resize: vertical;
  min-height: 120px;
  padding: 16px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: #3972ff;
  box-shadow:
    0 0 0 3px rgba(57, 114, 255, 0.10);
}

button[type="submit"] {
  border: 0;
  border-radius: 10px;
  background: #1f5eff;
  color: white;
  font-weight: 700;
  padding: 12px 20px;
  min-height: 44px;
}

#loginButton {
  width: 100%;
  margin-top: 24px;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.error {
  padding: 12px 14px;
  border-radius: 9px;
  background: #fff1f1;
  color: #a32b2b;
  font-size: 14px;
}

.topbar {
  min-height: 72px;
  background: white;
  border-bottom: 1px solid #e7ebf2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px;
}

.brand-small {
  margin: 0;
}

.brand-small .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
}

.brand-small strong,
.brand-small span {
  display: block;
}

.brand-small span {
  color: #7b8495;
  font-size: 12px;
  margin-top: 2px;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #647087;
  font-size: 14px;
}

.secondary-button {
  border: 1px solid #d8deea;
  background: white;
  color: #38445a;
  border-radius: 9px;
  padding: 8px 14px;
}

.content {
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: 54px 0 80px;
}

.hero {
  text-align: center;
  margin-bottom: 30px;
}

.hero h1 {
  font-size: clamp(28px, 4vw, 38px);
  margin: 0 0 10px;
  letter-spacing: -0.8px;
}

.hero p {
  max-width: 630px;
  margin: 0 auto;
  color: #687489;
  line-height: 1.55;
}

.question-card,
.answer-card,
.loading-card {
  background: white;
  border: 1px solid #e3e8f0;
  border-radius: 16px;
  box-shadow:
    0 8px 28px rgba(20, 32, 55, 0.05);
}

.question-card {
  padding: 18px;
}

.question-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.hint {
  color: #9199a8;
  font-size: 12px;
}

.loading-card {
  margin-top: 18px;
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.loading-card p {
  margin: 5px 0 0;
  color: #737e91;
  font-size: 14px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #dce4f4;
  border-top-color: #1f5eff;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

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

.answer-card {
  margin-top: 20px;
  padding: 26px;
}

.section-title {
  font-size: 12px;
  font-weight: 800;
  color: #667085;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.answer-text {
  color: #202a3c;
  font-size: 16px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.answer-text p {
  margin: 0 0 14px;
}

.answer-text p:last-child {
  margin-bottom: 0;
}

.answer-heading {
  margin: 24px 0 9px;
  color: #111b2e;
  letter-spacing: -0.02em;
}

.answer-text h2.answer-heading {
  font-size: 20px;
}

.answer-text h3.answer-heading {
  font-size: 17px;
}

.answer-text strong {
  color: #111827;
  font-weight: 750;
}

.answer-list {
  margin: 8px 0 18px;
  padding-left: 24px;
}

.answer-list li {
  margin: 7px 0;
  padding-left: 2px;
}

.citation-cluster {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  margin-left: 2px;
  vertical-align: super;
  line-height: 0;
}

.citation-ref {
  appearance: none;
  border: 0;
  background: transparent;
  color: #1f5eff;
  padding: 0 1px;
  min-width: 0;
  font-size: 10px;
  line-height: 1;
  font-weight: 800;
  cursor: pointer;
  border-radius: 3px;
}

.citation-ref:hover,
.citation-ref:focus-visible {
  color: #0f46d8;
  background: #edf3ff;
  outline: none;
}

.citation-separator {
  color: #1f5eff;
  font-size: 9px;
  line-height: 1;
}

.sources {
  margin-top: 28px;
  border-top: 1px solid #e8ecf2;
  padding-top: 20px;
}

.sources h2 {
  font-size: 14px;
  margin: 0 0 12px;
  color: #253047;
}

#sourcesList {
  display: grid;
  gap: 9px;
}

.source-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: 11px;
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: #f7f9fc;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.source-number {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e8efff;
  color: #1f5eff;
  font-size: 12px;
  font-weight: 800;
}

.source-body {
  min-width: 0;
}

.source-title {
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.source-page {
  color: #707b8d;
  font-size: 13px;
  margin-top: 4px;
}

.source-highlight {
  border-color: #9db8ff;
  background: #f1f5ff;
  box-shadow:
    0 0 0 3px rgba(31, 94, 255, 0.08);
}

.app-error {
  margin-top: 18px;
}

@media (max-width: 650px) {
  .topbar {
    padding: 10px 16px;
  }

  .user-area span {
    display: none;
  }

  .content {
    width: min(100% - 20px, 900px);
    padding-top: 34px;
  }

  .login-card {
    padding: 24px;
  }

  .hint {
    display: none;
  }

  .question-footer {
    justify-content: flex-end;
  }

  .answer-card {
    padding: 20px;
  }

  .answer-text {
    font-size: 15px;
  }
}

[hidden] {
  display: none !important;
}
