.research-chat-page {
  display: grid;
  height: calc(100vh - var(--topbar) - 48px);
  min-height: 560px;
  grid-template-rows: auto minmax(0, 1fr);
}

.research-chat-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 8px;
}

.research-chat-page-head h1 {
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: -.02em;
}

.research-chat-page-head p {
  margin-top: 5px;
  color: var(--muted-strong);
  font-size: 14px;
}

.research-chat-workspace {
  display: grid;
  width: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
}

.research-chat-header {
  display: flex;
  width: min(100%, 880px);
  align-items: flex-start;
  justify-self: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 4px 13px;
}

.research-chat-header h2 {
  font-size: 17px;
  line-height: 1.35;
}

.research-chat-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.research-chat-updated {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.research-chat-updated i,
.research-chat-updated svg {
  width: 15px;
  height: 15px;
}

.research-chat-messages {
  display: grid;
  min-height: 0;
  align-content: start;
  gap: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 8px 28px;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

.research-chat-message {
  display: grid;
  width: min(100%, 880px);
  justify-self: center;
}

.research-chat-message.is-assistant {
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
}

.research-chat-message.is-user {
  justify-items: end;
}

.research-chat-assistant-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid #c6d8ee;
  border-radius: 50%;
  background: #f5f9ff;
  color: var(--blue);
}

.research-chat-assistant-mark i,
.research-chat-assistant-mark svg {
  width: 17px;
  height: 17px;
}

.research-chat-message-body {
  min-width: 0;
}

.research-chat-message-meta {
  display: flex;
  min-height: 24px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}

.research-chat-message-label {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.research-chat-message-meta time {
  color: var(--muted);
  font-size: 13px;
}

.research-chat-message-content {
  color: var(--text);
  font-size: 14px;
  line-height: 1.78;
}

.research-chat-message-content p {
  margin: 0;
}

.research-chat-message.is-user .research-chat-message-body {
  display: grid;
  max-width: min(78%, 680px);
  justify-items: end;
}

.research-chat-message.is-user .research-chat-message-meta {
  min-height: 0;
  margin: 6px 2px 0;
  order: 2;
}

.research-chat-message.is-user .research-chat-message-label {
  display: none;
}

.research-chat-message.is-user .research-chat-message-content {
  border: 1px solid #bed1ec;
  border-radius: 8px;
  background: var(--blue-soft);
  padding: 10px 13px;
}

.research-chat-citations {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}

.research-chat-citation-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 2px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
}

.research-chat-citation-label i,
.research-chat-citation-label svg {
  width: 15px;
  height: 15px;
  color: var(--blue);
}

.research-chat-citation {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid #cbdaf0;
  border-radius: 999px;
  background: #fff;
  color: var(--muted-strong);
  padding: 2px 9px;
  font-size: 13px;
}

.research-chat-message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 7px;
}

.research-chat-copy {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted-strong);
  padding: 3px 7px;
  font-size: 13px;
  cursor: pointer;
}

.research-chat-copy:hover {
  background: #eaf1f9;
  color: var(--blue-strong);
}

.research-chat-copy i,
.research-chat-copy svg {
  width: 14px;
  height: 14px;
}

.research-chat-empty {
  display: grid;
  width: min(100%, 680px);
  min-height: 100%;
  align-content: center;
  justify-self: center;
  justify-items: center;
  padding: 30px 20px;
  text-align: center;
}

.research-chat-empty-icon {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 1px solid #c5d6ec;
  border-radius: 50%;
  background: #f5f9ff;
  color: var(--blue);
}

.research-chat-empty-icon i,
.research-chat-empty-icon svg {
  width: 24px;
  height: 24px;
}

.research-chat-empty h2 {
  margin-top: 14px;
  font-size: 20px;
}

.research-chat-empty > p {
  max-width: 540px;
  margin-top: 7px;
  color: var(--muted-strong);
  font-size: 14px;
}

.research-chat-prompts {
  display: grid;
  width: min(100%, 560px);
  gap: 8px;
  margin-top: 22px;
}

.research-chat-prompts button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
}

.research-chat-prompts button:hover {
  border-color: #91acd0;
  background: #f8fbff;
  color: var(--blue-strong);
}

.research-chat-composer {
  position: relative;
  z-index: 2;
  width: min(calc(100% - 16px), 880px);
  justify-self: center;
  margin: 8px 8px 4px;
  overflow: hidden;
  border: 1px solid #aebfd5;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(16, 36, 64, .09);
}

.research-chat-composer:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(15, 88, 201, .12), 0 8px 22px rgba(16, 36, 64, .09);
}

.research-chat-composer textarea {
  display: block;
  width: 100%;
  min-height: 54px;
  max-height: 144px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 13px 14px 7px;
  font: inherit;
  line-height: 1.55;
}

.research-chat-composer textarea::placeholder {
  color: #8794a6;
}

.research-chat-composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 7px 7px 14px;
}

.research-chat-composer-footer > span {
  color: var(--muted);
  font-size: 13px;
}

.research-chat-composer-footer button {
  display: inline-flex;
  min-width: 82px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  padding: 0 13px;
  font-weight: 700;
  cursor: pointer;
}

.research-chat-composer-footer button:hover {
  background: var(--blue-strong);
}

.research-chat-composer-footer button i,
.research-chat-composer-footer button svg {
  width: 16px;
  height: 16px;
}

.research-chat-composer-footer button:focus-visible,
.research-chat-prompts button:focus-visible,
.research-chat-copy:focus-visible,
.research-chat-composer textarea:focus-visible {
  outline: 3px solid var(--focus-ring, #ffd54a);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px var(--focus-edge, #6b4f00);
}

.research-chat-footnote {
  width: min(100%, 880px);
  justify-self: center;
  color: var(--muted);
  padding: 5px 8px 0;
  font-size: 13px;
  text-align: center;
}

@media (max-width: 900px) {
  .research-chat-page {
    min-width: 620px;
  }

  .research-chat-message.is-user .research-chat-message-body {
    max-width: 86%;
  }
}

@media (max-height: 760px) {
  .research-chat-page-head p,
  .research-chat-footnote {
    display: none;
  }

  .research-chat-header {
    padding-top: 6px;
  }

  .research-chat-messages {
    padding-block: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .research-chat-messages {
    scroll-behavior: auto;
  }
}
