:root {
  --research-accent: var(--accent);
  --research-accent-soft: var(--accent-soft);
  --research-accent-soft-2: var(--accent-soft-2);
  --research-accent-ink: var(--accent);
}

.research-body {
  background:
    radial-gradient(1200px 600px at 50% -200px, var(--peach), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, var(--peach-2), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

.research-body .status-strip .live {
  color: var(--research-accent);
}
.research-body .status-strip .dot {
  background: var(--research-accent);
  box-shadow: 0 0 0 3px var(--research-accent-soft-2);
}

.research-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.research-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
}
.research-topbar .brand-mark {
  text-decoration: none;
  background: linear-gradient(160deg, #9b66ff 0%, #5819e6 100%);
  box-shadow: 0 10px 30px rgba(116, 51, 255, 0.24);
}
.research-topbar .brand-copy h1 {
  margin: 4px 0 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--soft);
}
.research-eyebrow { color: var(--research-accent); }

.nav-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--soft);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background .15s, border-color .15s, color .15s;
}
.nav-chip:hover {
  background: var(--research-accent-soft);
  border-color: var(--research-accent-soft-2);
  color: var(--research-accent-ink);
}
.topbar-right { display: flex; gap: 10px; align-items: center; }

.research-main {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 22px;
  min-height: calc(100vh - 180px);
}

/* Sidebar */
.research-sidebar {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 180px);
  position: sticky;
  top: 60px;
}
.research-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: linear-gradient(160deg, #9b66ff 0%, #5819e6 100%);
  color: #fff;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.88rem;
  box-shadow: 0 10px 24px -10px rgba(116, 51, 255, 0.58);
  transition: transform .12s, box-shadow .12s;
}
.research-new:hover { transform: translateY(-1px); box-shadow: 0 14px 28px -10px rgba(116, 51, 255, 0.68); }

.research-search input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
}
.research-search input:focus {
  border-color: var(--research-accent-soft-2);
  box-shadow: 0 0 0 3px var(--research-accent-soft);
}

.research-conv-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  padding-right: 2px;
  margin-right: -2px;
}
.conv-item {
  display: block;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--soft);
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.35;
  cursor: pointer;
  transition: background .1s, border-color .1s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item:hover { background: var(--research-accent-soft); }
.conv-item.active {
  background: var(--research-accent-soft);
  border-color: var(--research-accent-soft-2);
  color: var(--research-accent-ink);
  font-weight: 500;
}
.conv-item .conv-time {
  display: block;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
  font-weight: 400;
}

/* Center column */
.research-center {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: 0 1px 0 rgba(16,18,27,0.02), 0 24px 60px -30px rgba(16,18,27,0.10);
}

.research-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
}
.research-header-main { flex: 1; min-width: 0; }
.research-header h2 {
  margin: 4px 0 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.research-header-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .12s, color .12s, border-color .12s;
}
.icon-btn:hover:not([disabled]) {
  background: var(--research-accent-soft);
  color: var(--research-accent-ink);
  border-color: var(--research-accent-soft-2);
}
.icon-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

.research-thread {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
}

.research-empty {
  margin: auto;
  max-width: 560px;
  text-align: center;
  padding: 40px 20px;
}
.research-empty-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  background: linear-gradient(160deg, #9b66ff 0%, #5819e6 100%);
  color: #fff;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.2rem;
  box-shadow: 0 14px 30px -8px rgba(116, 51, 255, 0.52);
}
.research-empty h3 { margin: 0 0 10px; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; }
.research-empty p { margin: 0; color: var(--muted); line-height: 1.6; }
.research-suggestions {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.suggestion {
  text-align: left;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--soft);
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.suggestion:hover {
  background: var(--research-accent-soft);
  border-color: var(--research-accent-soft-2);
  color: var(--research-accent-ink);
}

/* Messages */
.msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 780px;
  width: 100%;
}
.msg-role {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.msg.user .msg-role { color: var(--accent); }
.msg.assistant .msg-role { color: var(--research-accent); }

.msg-body {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  color: var(--text);
  line-height: 1.65;
  font-size: 0.96rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .msg-body {
  background: var(--accent-soft);
  border-color: var(--accent-soft-2);
}
.msg.assistant .msg-body {
  background: #fffaf7;
  border-color: var(--accent-soft-2);
}
.msg-body p { margin: 0 0 10px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.msg-section-title {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.msg-section-title + p,
.msg-section-title + .msg-bullets,
.msg-section-title + .sources-block,
.msg-section-title + .msg-empty-section {
  margin-top: 0;
}
.msg-bullets {
  margin: 0 0 12px 0;
  padding-left: 18px;
}
.msg-bullets li {
  margin: 0 0 8px 0;
}
.msg-empty-section {
  color: var(--muted);
}
.msg-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
}
.note-ref {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--research-accent-soft);
  color: var(--research-accent-ink);
  font-family: var(--mono);
  font-size: 0.78em;
  text-decoration: none;
  border: 1px solid var(--research-accent-soft-2);
}
.note-ref:hover { background: var(--research-accent-soft-2); }

.paragraph-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: -4px 0 12px 0;
}
.sources-block {
  margin: 0 0 12px 0;
}
.ref-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: #f1f2f5;
  border: 1px solid #e3e4ea;
  color: #5b5e6a;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  max-width: 260px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: background .12s, color .12s, border-color .12s;
}
.ref-chip:hover {
  background: #e7e8ed;
  color: #2f313a;
  border-color: #d6d8df;
}
.ref-chip::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #9a9ca6;
  flex-shrink: 0;
}

.msg-body > p:last-of-type,
.msg-body > .paragraph-refs:last-child { margin-bottom: 0; }

.msg-citations {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px dashed #e3e4ea;
}
.msg-citations::before {
  content: "Retrieved";
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  width: 100%;
  opacity: 0.7;
}
.citation-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: #f1f2f5;
  border: 1px solid #e3e4ea;
  color: #5b5e6a;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  max-width: 260px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.citation-chip:hover {
  background: #e7e8ed;
  color: #2f313a;
  border-color: #d6d8df;
}
.citation-chip::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #9a9ca6;
  flex-shrink: 0;
}

.msg.typing .msg-body {
  color: var(--muted);
  font-style: italic;
}
.msg.typing .msg-body::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--research-accent);
  animation: blink 1s infinite;
  vertical-align: middle;
}
@keyframes blink { 0%, 100% { opacity: 0.3 } 50% { opacity: 1 } }

/* Composer */
.research-composer {
  border-top: 1px solid var(--line);
  padding: 14px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.7);
}
.research-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  background: #fff;
  outline: none;
  max-height: 180px;
  transition: border-color .12s, box-shadow .12s;
}
.research-composer textarea:focus {
  border-color: var(--research-accent-soft-2);
  box-shadow: 0 0 0 3px var(--research-accent-soft);
}
.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #9b66ff 0%, #5819e6 100%);
  color: #fff;
  box-shadow: 0 10px 24px -10px rgba(116, 51, 255, 0.58);
  transition: transform .1s, box-shadow .1s, opacity .1s;
}
.send-btn:hover:not([disabled]) { transform: translateY(-1px); }
.send-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* Home-page Research nav icon */
.research-nav-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--research-accent-soft);
  color: var(--research-accent-ink);
  text-decoration: none;
  transition: background .15s;
}
.research-nav-icon:hover { background: var(--research-accent-soft-2); }

@media (max-width: 900px) {
  .research-main { grid-template-columns: 1fr; }
  .research-sidebar { position: static; max-height: 320px; }
  .research-suggestions { grid-template-columns: 1fr; }
}

/* ── Raven KB brand mark ── */
.research-topbar .brand-mark.logo-brand {
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(116, 51, 255, 0.12);
  overflow: hidden;
  padding: 3px;
}
.research-topbar .brand-mark.logo-brand img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.research-topbar .brand-mark.logo-brand img { transform: scale(1.62); }

/* ── Borderless angular Einstein logo ── */
.research-topbar .brand-mark.logo-brand.angular-logo {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  overflow: visible;
}
.research-topbar .brand-mark.logo-brand.angular-logo img {
  transform: scale(1.22);
}

/* ── Subtle bottom-of-answer reference bubbles ── */
.msg.assistant .paragraph-refs,
.msg.assistant .sources-block {
  display: none;
}
.answer-refs {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(227, 228, 234, 0.48);
  max-width: 100%;
  opacity: 0.72;
}
.answer-refs-label {
  font-family: var(--mono);
  font-size: 0.52rem;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8f93a0;
  margin-right: 2px;
}
.answer-refs .ref-chip {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(241, 242, 245, 0.66);
  border-color: rgba(227, 228, 234, 0.72);
  color: #7a7d88;
  font-size: 0.56rem;
  line-height: 1.35;
  max-width: 150px;
  text-decoration: none;
}
.answer-refs .ref-chip::before {
  width: 3px;
  height: 3px;
  background: #b5b8c0;
}
.answer-refs:hover {
  opacity: 1;
}
.answer-refs .ref-chip:hover {
  background: rgba(231, 232, 237, 0.9);
  color: #444753;
  border-color: #d7d9e1;
}

/* ── Prompt attachments ── */
.attachment-preview {
  border-top: 1px solid var(--line);
  padding: 10px 16px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: rgba(255, 255, 255, 0.7);
}
.attachment-preview[hidden] { display: none; }
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 360px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-2);
  color: var(--soft);
  font-family: var(--mono);
  font-size: 0.68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-chip em {
  color: #7e8792;
  font-style: normal;
  font-size: 0.62rem;
}
.attachment-chip button {
  border: 0;
  background: transparent;
  color: #7e8792;
  cursor: pointer;
  padding: 0 2px;
  font-size: 0.9rem;
  line-height: 1;
}
.attachment-chip button:hover { color: var(--research-accent-ink); }
.attachment-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--research-accent);
  flex-shrink: 0;
}
.file-input { display: none; }
.attach-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--research-accent-ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .12s, border-color .12s, transform .1s, opacity .1s;
}
.attach-btn:hover:not([disabled]) {
  background: var(--research-accent-soft);
  border-color: var(--research-accent-soft-2);
  transform: translateY(-1px);
}
.attach-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ── Web search composer icon ── */
.web-search-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .12s, border-color .12s, color .12s, transform .1s, opacity .1s;
}
.web-search-btn:hover:not([disabled]),
.web-search-btn.active {
  background: var(--research-accent-soft);
  border-color: var(--research-accent-soft-2);
  color: var(--research-accent-ink);
  transform: translateY(-1px);
}
.web-search-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
