:root {
  --paper: #EEF1F4;
  --surface: #FFFFFF;
  --ink: #1B2333;
  --muted: #5B6676;
  --rule: #D5DBE3;
  --blue: #1F4E8C;
  --blue-soft: #E3EBF6;
  --blue-solid: #1F4E8C;
  --on-blue: #FFFFFF;
  --highlight: #FFE36E;
  --ok: #1E7A4C;
  --warn: #9A5B00;
  --danger: #B42318;
  --shadow: 0 1px 2px rgba(27, 35, 51, 0.04), 0 10px 30px rgba(27, 35, 51, 0.05);
  --font-ui: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Source Serif 4", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --font-condensed: "IBM Plex Sans Condensed", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10151F;
    --surface: #171E2B;
    --ink: #E6EAF0;
    --muted: #9AA6B8;
    --rule: #2A3446;
    --blue: #7FA8E8;
    --blue-soft: #1C2B44;
    --blue-solid: #1F4E8C;
    --on-blue: #FFFFFF;
    --highlight: rgba(232, 197, 71, 0.35);
    --ok: #5CC48D;
    --warn: #F2B54A;
    --danger: #F08A7E;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 36px rgba(0, 0, 0, 0.24);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--blue);
  text-underline-offset: 2px;
}

::selection {
  background: var(--highlight);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--blue-solid);
  color: var(--on-blue);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 16px;
}

.site-header,
.workspace,
.footnote {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
}

.site-header {
  display: flex;
  gap: 24px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--rule);
}

.brand {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-condensed);
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.powered-by {
  display: inline-flex;
  flex: none;
  gap: 8px;
  align-items: center;
  max-width: 390px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  overflow-wrap: anywhere;
}

.powered-by::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

.powered-by[hidden] {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 22px 24px 40px;
}

.workspace > * {
  min-width: 0;
}

.card {
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-pane {
  display: flex;
  height: clamp(560px, 78vh, 820px);
  flex-direction: column;
  overflow: hidden;
}

.sources-pane {
  position: sticky;
  top: 20px;
}

.pane-head {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--rule);
}

.pane-title {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.09em;
  line-height: 1.4;
  text-transform: uppercase;
}

.pane-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.marker-sample {
  padding: 0 4px;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue);
  font-family: var(--font-mono);
  font-size: 0.9em;
  font-weight: 500;
  white-space: nowrap;
}

.transcript {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  padding: 16px 20px 18px;
  overflow-y: auto;
  scrollbar-color: var(--rule) transparent;
  scrollbar-width: thin;
}

.how-to {
  width: 100%;
  margin: auto 0;
  padding: 18px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
}

.how-to-title {
  margin: 0 0 12px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
}

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

.document-spine {
  list-style: none;
}

.spine-link {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--blue-soft);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 140ms ease, background-color 140ms ease;
}

a.spine-link:hover {
  border-color: var(--blue);
  border-left-color: var(--blue);
  background: var(--blue-soft);
}

a.spine-link:focus-visible {
  border-color: var(--blue);
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.spine-top {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
}

.document-code {
  color: var(--blue);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.document-title {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.doc-pages {
  flex: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 14px;
}

.example-chip {
  max-width: 100%;
  padding: 6px 11px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.example-chip:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.example-chip:focus-visible:not(:disabled) {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.example-chip:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.how-to-hint {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.how-to-fallback {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.how-to-fallback[hidden] {
  display: none;
}

.how-to-run {
  margin: 12px 0 0;
  font-size: 13px;
}

.how-to-run a {
  color: var(--blue);
  font-weight: 500;
  text-decoration: none;
}

.how-to-run a:hover {
  text-decoration: underline;
}

.message {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.message.user {
  align-self: flex-end;
  max-width: 85%;
  padding: 9px 14px;
  border-radius: 12px 12px 3px 12px;
  background: var(--blue-solid);
  color: var(--on-blue);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message.answer {
  align-self: stretch;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--blue-soft);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.6;
  white-space: normal;
}

.message.answer p {
  margin: 0 0 0.72em;
}

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

.message.answer strong {
  font-weight: 600;
}

.message.answer em {
  font-style: italic;
}

.message.answer code {
  padding: 0.08em 0.3em;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.82em;
  overflow-wrap: anywhere;
}

.message.answer ul,
.message.answer ol {
  margin: 0.35em 0 0.85em;
  padding-left: 1.25em;
}

.message.answer li {
  margin: 0.25em 0;
}

.message.answer .answer-meta {
  margin: 10px 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.message.error {
  align-self: flex-start;
  padding: 9px 12px;
  border: 1px solid var(--danger);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  background: transparent;
  color: var(--danger);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.citation {
  display: inline;
  margin: 0 2px;
  padding: 0 4px;
  border: 0;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue);
  font-family: var(--font-mono);
  font-size: 0.78em;
  font-weight: 500;
  line-height: 1.4;
  vertical-align: baseline;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.citation:hover,
.citation:focus,
.citation:active {
  background: var(--highlight);
  color: var(--ink);
}

.citation:focus-visible {
  background: var(--highlight);
  color: var(--ink);
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.composer {
  flex: 0 0 auto;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--rule);
  border-radius: 0 0 10px 10px;
  background: var(--surface);
}

.field-label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

textarea {
  display: block;
  width: 100%;
  min-height: 76px;
  max-height: 180px;
  padding: 10px 12px;
  resize: vertical;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

textarea:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 2px var(--blue);
}

textarea:disabled {
  background: var(--paper);
  color: var(--muted);
  cursor: not-allowed;
}

.composer-row {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.status[data-state="ok"] {
  color: var(--ok);
  font-weight: 500;
}

.status[data-state="error"] {
  color: var(--danger);
}

.quota {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 8px 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
}

.quota[hidden] {
  display: none;
}

.quota--low {
  color: var(--warn);
  font-weight: 500;
}

.quota--low::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

.quota--locked {
  color: var(--warn);
  font-weight: 500;
}

.quota--locked::before {
  content: "\1F512";
  flex: none;
  font-size: 12px;
  line-height: 1;
}

.send {
  flex: none;
  min-width: 84px;
  padding: 9px 20px;
  border: 0;
  border-radius: 8px;
  background: var(--blue-solid);
  color: var(--on-blue);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: filter 140ms ease, transform 120ms ease;
}

.send:hover:not(:disabled) {
  filter: brightness(1.12);
}

.send:focus-visible:not(:disabled) {
  filter: brightness(1.12);
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.send:active:not(:disabled) {
  transform: translateY(1px);
}

.send:disabled {
  cursor: progress;
  opacity: 0.55;
}

.sources {
  display: flex;
  max-height: calc(100vh - 250px);
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px 20px;
  overflow-y: auto;
  scrollbar-color: var(--rule) transparent;
  scrollbar-width: thin;
}

.empty-state {
  margin: 0;
  padding: 22px 14px;
  border: 1px dashed var(--rule);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  text-wrap: balance;
}

.source-card {
  position: relative;
  padding: 11px 13px 13px 15px;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--blue-soft);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(27, 35, 51, 0.04);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.source-card.is-active {
  border-color: var(--blue);
  border-left-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.source-card.is-hover {
  border-left-color: var(--blue);
}

.source-card:focus {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.source-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

.source-file {
  min-width: 0;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.source-page {
  flex: none;
  padding: 1px 6px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.source-snippet {
  display: -webkit-box;
  margin: 0;
  margin-inline: -4px;
  padding: 0 4px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.55;
  transition: color 200ms ease;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

/* Signature: a marker stroke per wrapped line, swept left to right. */
.source-mark {
  padding: 0.05em 0.15em;
  background-image: linear-gradient(
    transparent 12%, var(--highlight) 12%, var(--highlight) 88%, transparent 88%
  );
  background-repeat: no-repeat;
  background-position: left center;
  background-size: 0% 100%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-size 450ms ease;
}

.source-card.is-active .source-snippet,
.source-card.is-hover .source-snippet {
  color: var(--ink);
}

.source-card.is-active .source-mark,
.source-card.is-hover .source-mark {
  background-size: 100% 100%;
}

@media (prefers-reduced-motion: reduce) {
  .source-mark {
    transition: none;
  }
}

.footnote {
  margin-top: 0;
  padding: 0 24px 36px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.footnote p {
  margin: 0;
}

@media (max-width: 860px) {
  .site-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    padding: 20px 16px 14px;
  }

  .powered-by {
    max-width: 100%;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 16px 16px 36px;
  }

  .chat-pane {
    height: clamp(560px, 78vh, 760px);
  }

  .sources-pane {
    position: static;
    top: auto;
  }

  .sources {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .site-header {
    padding-inline: 14px;
  }

  h1 {
    font-size: 27px;
  }

  .workspace {
    padding-inline: 14px;
  }

  .pane-head,
  .transcript,
  .composer,
  .sources {
    padding-inline: 14px;
  }

  .message.user {
    max-width: 92%;
  }

  .status {
    font-size: 12px;
  }

  .send {
    padding: 9px 16px;
  }
}

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