:root {
  color-scheme: light;
  --blue: #203f78;
  --blue-dark: #17325f;
  --blue-pale: #e9eef5;
  --charcoal: #212530;
  --ink: #0b0b0b;
  --muted: #474f64;
  --canvas: #f8f7f3;
  --surface: #ffffff;
  --border: #dbdee7;
  --control: #6f7785;
  --danger: #683229;
  --danger-bg: #f8ece9;
  --danger-border: #e5cdc6;
  --focus: #315f9d;
  --content-width: 820px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--charcoal);
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--blue);
  text-underline-offset: 0.18em;
}

:focus-visible {
  border-radius: 4px;
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  inset-block-start: 10px;
  inset-inline-start: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 4px 18px rgb(33 37 48 / 18%);
  font-weight: 700;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.site-header {
  position: relative;
  z-index: 10;
  flex: 0 0 auto;
  border-block-end: 1px solid var(--border);
  background: rgb(248 247 243 / 96%);
}

.header-inner {
  display: grid;
  width: min(100%, 1280px);
  min-height: 82px;
  margin: 0 auto;
  padding: 10px 28px;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;
}

.back-link {
  display: inline-flex;
  width: fit-content;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  font-size: 0.93rem;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--charcoal);
  line-height: 0.86;
  text-transform: uppercase;
}

.brand-eyebrow {
  align-self: flex-start;
  margin-inline-start: 2px;
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.brand-title {
  font-size: 1.16rem;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.header-actions {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 10px;
}

.new-conversation,
.download-conversation,
.autoplay-session,
.autoplay-edit {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--control);
  border-radius: 6px;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
}

.new-conversation:disabled,
.download-conversation:disabled,
.autoplay-session:disabled,
.autoplay-edit:disabled {
  cursor: default;
  opacity: 0.45;
}

.new-conversation:not(:disabled):hover,
.download-conversation:not(:disabled):hover,
.autoplay-session:not(:disabled):hover,
.autoplay-edit:not(:disabled):hover {
  background: var(--blue-pale);
}

.autoplay-edit {
  display: inline-flex;
  width: 44px;
  padding: 0;
  align-items: center;
  justify-content: center;
}

.autoplay-edit[hidden] {
  display: none;
}

.conversation-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
}

.conversation-column {
  width: min(100%, var(--content-width));
  margin: 0 auto;
  padding: 38px 24px 32px;
}

.empty-state {
  padding: clamp(20px, 4vh, 52px) 0 24px;
  text-align: center;
}

.kicker {
  margin: 0 0 14px;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  max-width: 720px;
  margin: 0 auto;
  color: var(--charcoal);
  font-size: clamp(2rem, 5vw, 3.8rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.02;
}

.intro {
  max-width: 650px;
  margin: 20px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.1rem);
  line-height: 1.65;
}

.suggestions {
  display: flex;
  max-width: 720px;
  margin: 34px auto 0;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.suggestion {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.3;
}

.suggestion:hover {
  border-color: var(--blue);
  background: #f4f7fb;
}

.suggestion:disabled {
  cursor: default;
  opacity: 0.48;
}

.browse-note {
  margin: 30px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.conversation {
  display: grid;
  gap: 20px;
}

.conversation[hidden],
.empty-state[hidden] {
  display: none;
}

.turn {
  display: grid;
  gap: 14px;
}

.turn + .turn {
  padding-block-start: 4px;
}

.question-wrap {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.turn-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.question {
  max-width: min(560px, 86%);
  margin: 0;
  padding: 11px 15px;
  border-radius: 14px 14px 4px;
  background: var(--blue);
  color: var(--surface);
  font-size: 0.98rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.answer-wrap {
  display: grid;
  max-width: min(680px, 96%);
  justify-items: start;
  gap: 6px;
}

.answer-card,
.thinking-card,
.error-card,
.non-answer-card {
  width: 100%;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(33 37 48 / 4%);
}

.answer-body {
  color: var(--charcoal);
  font-size: 1rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.answer-body p {
  margin: 0 0 0.8em;
}

.answer-body p:last-child {
  margin-block-end: 0;
}

.thinking-card {
  width: fit-content;
  min-width: 126px;
  color: var(--muted);
  font-weight: 650;
}

.thinking-dots {
  display: inline-flex;
  width: 1.35em;
  justify-content: flex-start;
}

.thinking-dot {
  animation: dot-fade 1.2s ease-in-out infinite;
  opacity: 0.3;
}

.thinking-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dot-fade {
  0%,
  65%,
  100% {
    opacity: 0.3;
  }

  30% {
    opacity: 1;
  }
}

.non-answer-card {
  border-inline-start: 4px solid var(--blue);
  color: var(--charcoal);
  line-height: 1.65;
}

.error-card {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
  line-height: 1.6;
}

.error-card p,
.non-answer-card p {
  margin: 0;
}

.citation-link {
  display: inline-flex;
  min-width: 24px;
  min-height: 24px;
  margin-inline: 2px;
  align-items: center;
  justify-content: center;
  border: 1px solid #aebbd0;
  border-radius: 999px;
  background: var(--blue-pale);
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  vertical-align: 0.13em;
}

.citation-link:hover {
  border-color: var(--blue);
  background: #dce5f2;
}

.sources {
  width: 100%;
  margin-block-start: 15px;
  padding-block-start: 14px;
  border-block-start: 1px solid var(--border);
}

.sources h3 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sources ol {
  display: grid;
  margin: 0;
  padding-inline-start: 1.4rem;
  gap: 8px;
}

.sources li {
  padding-inline-start: 3px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.sources a {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.composer-region {
  position: relative;
  z-index: 9;
  flex: 0 0 auto;
  padding: 12px 20px max(13px, env(safe-area-inset-bottom));
  border-block-start: 1px solid var(--border);
  background: rgb(248 247 243 / 97%);
  box-shadow: 0 -8px 24px rgb(33 37 48 / 4%);
}

.composer {
  width: min(100%, var(--content-width));
  margin: 0 auto;
}

.composer-label {
  display: block;
  margin-block-end: 7px;
  color: var(--charcoal);
  font-size: 0.84rem;
  font-weight: 750;
}

.composer-box {
  display: flex;
  min-height: 56px;
  align-items: flex-end;
  gap: 8px;
  padding: 6px;
  border: 1.5px solid var(--control);
  border-radius: 12px;
  background: var(--surface);
}

.composer-box:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgb(32 63 120 / 12%);
}

textarea {
  width: 100%;
  min-height: 42px;
  max-height: 140px;
  padding: 9px 10px;
  field-sizing: content;
  overflow-y: auto;
  resize: none;
  border: 0;
  background: transparent;
  font-size: 1rem;
  line-height: 1.45;
  outline: none;
}

textarea:focus-visible {
  outline: none;
}

textarea::placeholder {
  color: #747b8b;
  opacity: 1;
}

.send-button,
.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 17px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 750;
}

.send-button,
.primary-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: var(--surface);
}

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

.send-button:disabled {
  cursor: default;
  opacity: 0.48;
}

.secondary-button {
  border: 1px solid var(--control);
  background: var(--surface);
  color: var(--charcoal);
}

.composer-help,
.composer-error {
  margin: 7px 2px 0;
  font-size: 0.78rem;
  line-height: 1.4;
}

.composer-help {
  color: var(--muted);
}

.composer-error {
  color: var(--danger);
  font-weight: 650;
}

.composer-error:empty {
  display: none;
}

.sr-status,
.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;
}

.reset-dialog {
  width: min(calc(100% - 32px), 470px);
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--charcoal);
  box-shadow: 0 24px 70px rgb(12 25 48 / 24%);
}

.reset-dialog::backdrop {
  background: rgb(20 28 43 / 52%);
}

.reset-dialog h2 {
  margin: 0;
  font-size: 1.35rem;
}

.reset-dialog p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.dialog-actions {
  display: flex;
  margin-block-start: 24px;
  justify-content: flex-end;
  gap: 10px;
}

.noscript-message {
  position: fixed;
  z-index: 200;
  inset: 20px;
  padding: 16px;
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
}

@media (max-width: 700px) {
  .header-inner {
    min-height: 72px;
    padding: 8px 16px;
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .brand-lockup {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: center;
  }

  .back-link,
  .header-actions {
    grid-row: 2;
  }

  .header-inner {
    padding-block-end: 10px;
  }

  .back-link span:last-child {
    max-width: 145px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .conversation-column {
    padding: 24px 16px 24px;
  }

  .empty-state {
    padding-block-start: 22px;
  }

  .suggestions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .suggestion {
    border-radius: 10px;
    text-align: start;
  }

  .question {
    max-width: 92%;
  }

  .answer-wrap {
    max-width: 100%;
  }

  .composer-region {
    padding-inline: 12px;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions button {
    width: 100%;
  }
}

@media (max-width: 390px) {
  .back-link {
    font-size: 0.82rem;
  }

  .new-conversation,
  .autoplay-session {
    padding-inline: 10px;
    font-size: 0.82rem;
  }

  .answer-card,
  .thinking-card,
  .error-card,
  .non-answer-card {
    padding: 16px;
  }

  .send-button {
    padding-inline: 13px;
  }
}

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

  .thinking-dot {
    opacity: 1;
  }
}

@media (forced-colors: active) {
  .question,
  .send-button,
  .primary-button {
    border: 2px solid ButtonText;
  }

  .citation-link {
    border: 1px solid LinkText;
  }
}

.autoplay-session[data-running="true"] {
  background: var(--blue);
  color: #fff;
}

.autoplay-dialog {
  width: min(calc(100% - 32px), 640px);
}

.autoplay-label {
  display: block;
  margin-block-start: 18px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.autoplay-textarea {
  display: block;
  width: 100%;
  margin-block-start: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--canvas);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
}

.autoplay-count {
  margin-block-start: 6px;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.autoplay-actions {
  flex-wrap: wrap;
}
