:root {
  color-scheme: light;
  --blue-950: #062d57;
  --blue-900: #083d73;
  --blue-800: #0a4d91;
  --blue-700: #0b5eae;
  --blue-600: #1473d2;
  --blue-100: #dceeff;
  --blue-50: #eef7ff;
  --canvas: #f6faff;
  --surface: #fbfdff;
  --surface-strong: #f0f6fc;
  --ink: #10243d;
  --muted: #5b6f84;
  --border: #d5e1ec;
  --border-strong: #9db5cb;
  --error: #b42318;
  --success: #087443;
  --sidebar-width: 288px;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
  border-radius: 0 !important;
}

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

body {
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button,
label[for="file-input"],
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: inherit;
  text-decoration: none;
}

.is-hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  font-size: 18px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.brand-mark,
.empty-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: var(--blue-600);
  color: var(--surface);
  font-size: 17px;
  font-weight: 800;
}

.brand-on-blue {
  color: var(--surface);
}

.brand-on-blue .brand-mark {
  background: var(--surface);
  color: var(--blue-900);
}

.auth-screen {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(480px, 1.08fr);
  min-height: 100dvh;
  background: var(--surface);
}

.auth-intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100dvh;
  padding: clamp(32px, 5vw, 72px);
  background: var(--blue-900);
  color: var(--surface);
}

.auth-intro-copy {
  max-width: 590px;
}

.section-label {
  margin: 0 0 22px;
  color: #b9daf8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.auth-intro h1 {
  max-width: 10ch;
  margin: 0;
  font-size: clamp(46px, 5vw, 76px);
  font-weight: 720;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.auth-intro-copy > p:last-child {
  max-width: 49ch;
  margin: 28px 0 0;
  color: #dcecfb;
  font-size: 17px;
  line-height: 1.65;
}

.auth-note {
  margin: 0;
  color: #b9daf8;
  font-size: 13px;
  line-height: 1.5;
}

.auth-panel {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 40px 28px;
}

.auth-form-wrap {
  width: min(100%, 440px);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 48px;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  position: relative;
  padding: 14px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.auth-tab::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
  content: "";
}

.auth-tab:hover,
.auth-tab:focus-visible,
.auth-tab.is-active {
  color: var(--blue-700);
}

.auth-tab.is-active::after {
  background: var(--blue-600);
}

.auth-heading h2 {
  margin: 0;
  font-size: 32px;
  font-weight: 720;
  letter-spacing: -0.035em;
}

.auth-heading p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 22px;
  margin-top: 34px;
}

.field-group {
  display: grid;
  gap: 9px;
}

.field-group label {
  font-size: 14px;
  font-weight: 700;
}

.field-group input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  outline: none;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-group input::placeholder,
.composer textarea::placeholder {
  color: #697d91;
}

.field-group input:focus,
.composer textarea:focus {
  border-color: var(--blue-600);
  box-shadow: inset 3px 0 0 var(--blue-600);
}

.form-error {
  min-height: 20px;
  margin: -6px 0 -4px;
  color: var(--error);
  font-size: 13px;
  line-height: 1.5;
}

.primary-button,
.send-button {
  background: var(--blue-700);
  color: var(--surface);
  font-weight: 750;
  transition: background-color 160ms ease, transform 120ms ease;
}

.primary-button:hover,
.send-button:hover {
  background: var(--blue-800);
}

.primary-button:focus-visible,
.send-button:focus-visible,
.new-chat-button:focus-visible,
.upload-button:focus-visible,
.prompt-suggestions button:focus-visible,
.logout-button:focus-visible,
.docs-link:focus-visible,
.menu-button:focus-visible,
.text-button:focus-visible {
  outline: 3px solid var(--blue-100);
  outline-offset: 2px;
}

.primary-button:active,
.send-button:active,
.new-chat-button:active,
.prompt-suggestions button:active {
  transform: translateY(1px);
}

.auth-submit {
  min-height: 50px;
  padding: 0 22px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100dvh;
  overflow: hidden;
  background: var(--surface);
}

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  border-right: 1px solid #155b9c;
  background: var(--blue-900);
  color: var(--surface);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(222, 239, 255, 0.2);
}

.new-chat-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin: 18px;
  padding: 0 15px;
  border: 1px solid #6fa9db;
  background: transparent;
  color: var(--surface);
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}

.new-chat-button span {
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.new-chat-button:hover {
  background: rgba(238, 247, 255, 0.1);
}

.chat-history-section,
.document-section {
  min-height: 0;
  padding: 10px 18px 20px;
}

.chat-history-section {
  padding-top: 0;
}

.document-section {
  flex: 1;
  overflow-y: auto;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sidebar-section-header h2,
.sidebar-section-header span {
  margin: 0;
  color: #c7e3fb;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-history-list {
  display: grid;
  gap: 4px;
  max-height: 210px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.chat-history-item button {
  width: 100%;
  padding: 10px 12px;
  border-left: 2px solid transparent;
  background: transparent;
  color: #d8ebfb;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
}

.chat-history-item button:hover,
.chat-history-item button.is-active {
  border-left-color: #8ec6f4;
  background: rgba(238, 247, 255, 0.1);
}

.chat-history-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-history-date,
.chat-history-empty {
  color: #a9cce9;
  font-size: 11px;
}

.chat-history-date {
  display: block;
  margin-top: 3px;
}

.chat-history-empty {
  padding: 8px 12px;
}

.upload-button {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(222, 239, 255, 0.36);
  background: rgba(238, 247, 255, 0.07);
  color: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.upload-button:hover {
  border-color: #9ac5e9;
  background: rgba(238, 247, 255, 0.13);
}

.upload-types {
  color: #b9daf8;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.upload-status {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 3px solid #85c5ff;
  background: rgba(238, 247, 255, 0.08);
  color: #e9f5ff;
  font-size: 12px;
  line-height: 1.5;
}

.upload-status.is-error {
  border-left-color: #ff9d95;
  color: #ffe4e1;
}

.upload-status.is-success {
  border-left-color: #73e5ae;
  color: #dffbed;
}

.document-list {
  display: grid;
  gap: 2px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.document-item,
.document-empty {
  padding: 11px 12px;
  color: #d8ebfb;
  font-size: 13px;
  line-height: 1.4;
}

.document-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-left: 2px solid #8ec6f4;
  background: rgba(238, 247, 255, 0.08);
}

.document-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-type {
  color: #a9d0f1;
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.document-empty {
  color: #a9cce9;
}

.sidebar-account {
  display: grid;
  gap: 14px;
  margin-top: auto;
  padding: 18px;
  border-top: 1px solid rgba(222, 239, 255, 0.2);
}

.account-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.account-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  background: #dceeff;
  color: var(--blue-900);
  font-weight: 800;
  text-transform: uppercase;
}

.account-copy > span:last-child {
  display: grid;
  min-width: 0;
}

.account-copy strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy small {
  margin-top: 2px;
  color: #a9cce9;
  font-size: 11px;
}

.logout-button {
  padding: 8px 0;
  background: transparent;
  color: #c7e3fb;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.logout-button:hover {
  color: var(--surface);
}

.chat-layout {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100dvh;
  background: var(--surface);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(251, 253, 255, 0.96);
}

.chat-title {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 760;
}

.chat-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.docs-link {
  margin-left: auto;
  padding: 8px 0;
  color: var(--blue-700);
  font-size: 13px;
  font-weight: 740;
}

.docs-link:hover {
  color: var(--blue-900);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.chat-scroll {
  min-height: 0;
  overflow-y: auto;
  background: var(--canvas);
  scroll-behavior: smooth;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(100% - 40px, 760px);
  min-height: 100%;
  margin: 0 auto;
  padding: 64px 0;
  text-align: center;
}

.empty-mark {
  width: 52px;
  height: 52px;
  margin-bottom: 24px;
  font-size: 23px;
}

.empty-state h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 720;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.empty-state > p {
  max-width: 580px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.prompt-suggestions {
  display: grid;
  width: min(100%, 620px);
  margin-top: 34px;
  border-top: 1px solid var(--border);
}

.prompt-suggestions button {
  min-height: 48px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--blue-800);
  font-size: 14px;
  font-weight: 680;
  text-align: left;
  transition: background-color 160ms ease, padding-left 160ms ease;
}

.prompt-suggestions button:hover {
  padding-left: 12px;
  background: var(--blue-50);
}

.message-list {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 38px 24px 50px;
}

.message {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 15px;
  padding: 22px 0;
}

.message + .message {
  border-top: 1px solid var(--border);
}

.message-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--blue-700);
  color: var(--surface);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.message.user .message-avatar {
  background: var(--ink);
}

.message-content {
  min-width: 0;
  padding-top: 2px;
}

.message-role {
  display: block;
  margin-bottom: 7px;
  color: var(--blue-800);
  font-size: 12px;
  font-weight: 800;
}

.message.user .message-role {
  color: var(--ink);
}

.message-text {
  margin: 0;
  color: #1d344d;
  font-size: 15px;
  line-height: 1.72;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message.error .message-text {
  color: var(--error);
}

.markdown-body {
  white-space: normal;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.45em 0 0.55em;
  color: var(--ink);
  font-weight: 760;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.markdown-body h1 {
  font-size: 1.55em;
}

.markdown-body h2 {
  font-size: 1.3em;
}

.markdown-body h3,
.markdown-body h4 {
  font-size: 1.08em;
}

.markdown-body p {
  margin: 0.85em 0;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.85em 0;
  padding-left: 1.5em;
}

.markdown-body li {
  margin: 0.35em 0;
  padding-left: 0.2em;
}

.markdown-body a {
  color: var(--blue-700);
  font-weight: 650;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.markdown-body a:hover {
  color: var(--blue-900);
}

.markdown-body code {
  padding: 0.16em 0.38em;
  border: 1px solid var(--border);
  background: #eaf2fa;
  color: #0d426f;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
}

.markdown-body pre {
  max-width: 100%;
  margin: 1em 0;
  padding: 16px;
  overflow-x: auto;
  border-left: 3px solid var(--blue-600);
  background: var(--blue-950);
  color: #eaf5ff;
}

.markdown-body pre code {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 0.87em;
  line-height: 1.65;
  white-space: pre;
}

.markdown-body blockquote {
  margin: 1em 0;
  padding: 4px 0 4px 16px;
  border-left: 3px solid var(--blue-600);
  color: var(--muted);
}

.markdown-table-wrap {
  max-width: 100%;
  margin: 1em 0;
  overflow-x: auto;
  border: 1px solid var(--border-strong);
}

.markdown-body table {
  width: 100%;
  min-width: 440px;
  border-collapse: collapse;
  background: var(--surface);
}

.markdown-body th,
.markdown-body td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.markdown-body th:last-child,
.markdown-body td:last-child {
  border-right: 0;
}

.markdown-body tbody tr:last-child td {
  border-bottom: 0;
}

.markdown-body th {
  background: var(--blue-50);
  color: var(--blue-900);
  font-size: 0.9em;
  font-weight: 760;
}

.stream-error {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-left: 3px solid var(--error);
  background: #fff1f0;
  color: var(--error);
  font-size: 13px;
  line-height: 1.5;
}

.message-loading {
  display: grid;
  gap: 8px;
  width: min(100%, 540px);
  padding-top: 6px;
}

.message-loading span {
  display: block;
  height: 9px;
  background: #dbe6f0;
  transform-origin: left;
}

.message-loading span:nth-child(1) {
  width: 88%;
}

.message-loading span:nth-child(2) {
  width: 70%;
}

.message-loading span:nth-child(3) {
  width: 46%;
}

@media (prefers-reduced-motion: no-preference) {
  .message-loading span {
    animation: loading-pulse 1.1s ease-in-out infinite alternate;
  }

  .message-loading span:nth-child(2) {
    animation-delay: 120ms;
  }

  .message-loading span:nth-child(3) {
    animation-delay: 240ms;
  }
}

@keyframes loading-pulse {
  from {
    opacity: 0.38;
    transform: scaleX(0.82);
  }
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

.composer-area {
  padding: 14px 28px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.answer-mode-control {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: min(100%, 860px);
  margin: 0 auto 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.answer-mode-control select {
  padding: 6px 28px 6px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--blue-800);
  font: inherit;
}

.answer-mode-control select:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: min(100%, 860px);
  margin: 0 auto;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.composer textarea {
  min-height: 54px;
  max-height: 180px;
  padding: 16px 18px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

.composer textarea:focus {
  box-shadow: inset 3px 0 0 var(--blue-600);
}

.send-button {
  align-self: stretch;
  min-width: 80px;
  padding: 0 20px;
}

.composer-note {
  width: min(100%, 860px);
  margin: 9px auto 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}

.menu-button,
.text-button {
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--blue-800);
  font-size: 12px;
  font-weight: 750;
}

.text-button {
  border-color: rgba(222, 239, 255, 0.38);
  color: var(--surface);
}

.mobile-only {
  display: none;
}

.sidebar-scrim {
  display: none;
}

@media (max-width: 860px) {
  .auth-screen {
    grid-template-columns: 1fr;
  }

  .auth-intro {
    min-height: auto;
    padding: 28px 24px 44px;
  }

  .auth-intro-copy {
    margin: 70px 0 56px;
  }

  .auth-intro h1 {
    max-width: 12ch;
    font-size: clamp(42px, 10vw, 64px);
  }

  .auth-panel {
    min-height: auto;
    padding: 56px 24px 72px;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, var(--sidebar-width));
    transform: translateX(-102%);
    transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-scrim {
    position: fixed;
    z-index: 10;
    inset: 0;
    display: block;
    visibility: hidden;
    background: rgba(6, 45, 87, 0.42);
    opacity: 0;
    transition: opacity 180ms ease, visibility 180ms ease;
  }

  .sidebar-scrim.is-visible {
    visibility: visible;
    opacity: 1;
  }

  .chat-header {
    padding: 0 16px;
  }

  .chat-layout {
    width: 100%;
  }

  .composer-area {
    padding: 12px 14px;
  }

  .message-list {
    padding-right: 18px;
    padding-left: 18px;
  }
}

@media (max-width: 560px) {
  .auth-intro-copy {
    margin: 56px 0 44px;
  }

  .auth-note {
    max-width: 34ch;
  }

  .auth-tabs {
    margin-bottom: 38px;
  }

  .chat-header {
    min-height: 64px;
  }

  .chat-subtitle,
  .docs-link {
    display: none;
  }

  .empty-state {
    width: calc(100% - 32px);
    padding: 40px 0;
  }

  .empty-state h1 {
    max-width: 10ch;
  }

  .empty-state > p {
    font-size: 14px;
  }

  .prompt-suggestions {
    margin-top: 26px;
  }

  .message {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 11px;
    padding: 18px 0;
  }

  .message-avatar {
    width: 30px;
    height: 30px;
    font-size: 10px;
  }

  .message-text {
    font-size: 14px;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 66px;
  }

  .composer textarea {
    padding: 15px 12px;
    font-size: 14px;
  }

  .send-button {
    min-width: 66px;
    padding: 0 12px;
  }

  .composer-note {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
