:root {
  color-scheme: light;
  --ink: #191820;
  --muted: #6d6a78;
  --paper: #f4f1e9;
  --surface: #fffdf8;
  --line: #d9d4ca;
  --purple: #6746d6;
  --purple-dark: #4d31b7;
  --yellow: #f9d84a;
  --green: #1e9d68;
  --shadow: 0 18px 60px rgba(31, 27, 46, .10);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 2%, rgba(249, 216, 74, .35), transparent 28rem),
    radial-gradient(circle at 92% 18%, rgba(103, 70, 214, .12), transparent 30rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

a {
  color: inherit;
}

.page {
  width: min(1180px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: 190px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
  border-bottom: 1px solid rgba(25, 24, 32, .14);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark,
.mini-mark {
  display: grid;
  place-items: center;
  color: white;
  background: var(--purple);
  font-weight: 850;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px 4px 12px 4px;
  box-shadow: 5px 5px 0 var(--yellow);
  font-size: 21px;
}

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

.brand strong {
  font-size: 15px;
  letter-spacing: -.01em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.corpus-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 253, 248, .7);
  font: 650 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(30, 157, 104, .12);
}

.workspace {
  width: min(850px, 100%);
  margin: 0 auto;
}

.intro {
  padding: clamp(64px, 10vw, 122px) 0 68px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--purple);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 {
  max-width: 790px;
  margin: 0;
  font-size: clamp(48px, 8vw, 88px);
  font-weight: 790;
  letter-spacing: -.065em;
  line-height: .92;
}

h1 span {
  color: var(--purple);
}

.intro-copy {
  max-width: 610px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.55;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 38px;
}

.suggestion {
  min-height: 64px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 253, 248, .55);
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.suggestion span {
  display: block;
  margin-bottom: 7px;
  color: var(--purple);
  font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.suggestion:hover,
.suggestion:focus-visible {
  border-color: var(--purple);
  background: var(--surface);
  outline: none;
  transform: translateY(-2px);
}

.conversation {
  display: grid;
  gap: 18px;
  padding: 30px 0 80px;
  border-top: 1px solid var(--line);
}

.conversation:empty {
  display: none;
}

.message {
  position: relative;
  padding: 24px;
  border-radius: 20px;
}

.user-message {
  width: min(680px, 88%);
  margin-left: auto;
  color: white;
  background: var(--ink);
  border-bottom-right-radius: 6px;
}

.assistant-message {
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.user-message .message-meta {
  color: rgba(255, 255, 255, .58);
}

.mini-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px 2px 7px 2px;
  font-size: 11px;
}

.message-body {
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.68;
}

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

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

.markdown h2,
.markdown h3 {
  margin: 1.5em 0 .55em;
  line-height: 1.2;
}

.markdown h2 {
  font-size: 22px;
}

.markdown h3 {
  font-size: 18px;
}

.markdown p {
  margin: .8em 0;
}

.markdown ul,
.markdown ol {
  padding-left: 1.35em;
}

.markdown li + li {
  margin-top: .35em;
}

.markdown code {
  padding: .16em .38em;
  border-radius: 5px;
  color: #4b2db1;
  background: #eee8ff;
  font: .88em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.markdown pre {
  overflow-x: auto;
  padding: 16px;
  border-radius: 12px;
  color: #f7f4ff;
  background: #211d2e;
}

.markdown pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

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

.thinking {
  display: flex;
  gap: 5px;
  padding: 6px 0 2px;
}

.thinking span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--purple);
  animation: thinking 1.15s infinite ease-in-out;
}

.thinking span:nth-child(2) {
  animation-delay: .14s;
}

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

@keyframes thinking {
  0%, 70%, 100% { opacity: .25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-4px); }
}

.sources {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.sources-heading {
  display: flex;
  justify-content: space-between;
  margin-bottom: 11px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.source-count {
  color: var(--muted);
}

.source-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.source-card {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #faf8f2;
  text-decoration: none;
  transition: border-color .18s ease, transform .18s ease;
}

.source-card:hover,
.source-card:focus-visible {
  border-color: var(--purple);
  outline: none;
  transform: translateY(-1px);
}

.source-index {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 7px;
  color: var(--purple-dark);
  background: #ece6ff;
  font: 750 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

.source-copy strong,
.source-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-copy strong {
  font-size: 12px;
}

.source-copy small {
  margin-top: 3px;
  color: var(--muted);
  font: 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.source-arrow {
  color: var(--purple);
}

.composer-wrap {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(900px, calc(100% - 32px));
  margin: 0 auto 18px;
}

.composer {
  padding: 11px;
  border: 1px solid rgba(25, 24, 32, .18);
  border-radius: 21px;
  background: rgba(255, 253, 248, .94);
  box-shadow: 0 20px 80px rgba(27, 23, 42, .20);
  backdrop-filter: blur(18px);
}

.composer:focus-within {
  border-color: rgba(103, 70, 214, .65);
  box-shadow: 0 20px 80px rgba(27, 23, 42, .20), 0 0 0 3px rgba(103, 70, 214, .10);
}

#question {
  display: block;
  width: 100%;
  max-height: 180px;
  resize: none;
  padding: 10px 12px 13px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 17px;
  line-height: 1.5;
}

#question::placeholder {
  color: #9994a1;
}

.composer-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.filters {
  display: flex;
  gap: 7px;
}

.filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7f4ed;
}

.filters label > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.filters select {
  max-width: 130px;
  height: 34px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.send {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 0 7px 0 17px;
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--purple);
  font-size: 13px;
  font-weight: 800;
  transition: background .18s ease, transform .18s ease;
}

.send:hover,
.send:focus-visible {
  background: var(--purple-dark);
  outline: none;
  transform: translateY(-1px);
}

.send:disabled {
  opacity: .75;
}

.send-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--yellow);
  font-size: 17px;
}

.send.is-running {
  background: #302d39;
}

.send.is-running .send-icon {
  color: white;
  background: #e35f5f;
}

.request-status {
  display: flex;
  justify-content: space-between;
  padding: 8px 8px 0;
  color: var(--muted);
  font-size: 10px;
}

.status-text {
  font-weight: 700;
}

.error-message {
  color: #a12d2d;
}

.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: 720px) {
  .page {
    width: min(100% - 24px, 1180px);
    padding-bottom: 230px;
  }

  .topbar {
    min-height: 72px;
  }

  .brand small,
  .corpus-chip {
    display: none;
  }

  .intro {
    padding: 58px 0 45px;
  }

  h1 {
    font-size: clamp(46px, 15vw, 68px);
  }

  .suggestions {
    grid-template-columns: 1fr;
  }

  .message {
    padding: 19px;
  }

  .user-message {
    width: 94%;
  }

  .source-list {
    grid-template-columns: 1fr;
  }

  .composer-wrap {
    width: calc(100% - 16px);
    margin-bottom: 8px;
  }

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

  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .filters label {
    justify-content: space-between;
  }

  .filters select {
    width: 100%;
  }

  .send {
    justify-content: space-between;
    width: 100%;
  }

  .request-status > span:first-child {
    display: none;
  }

  .request-status {
    justify-content: flex-end;
  }
}

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