.rag-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  min-height: 72vh;
}

.rag-sidebar,
.rag-main {
  min-width: 0;
}

.rag-card,
.rag-header,
.chat-form,
.message {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.96));
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.08);
}

.rag-card {
  padding: 18px;
  margin-bottom: 18px;
}

.rag-card h2,
.rag-header h1 {
  margin: 0;
  color: #0f172a;
}

.rag-card-head,
.rag-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rag-inline-end {
  justify-content: flex-end;
}

.rag-label,
.rag-muted,
.rag-eyebrow {
  display: block;
}

.rag-label,
.rag-eyebrow {
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0f766e;
}

.rag-muted {
  margin: 10px 0 0;
  color: #475569;
  font-size: 0.95rem;
}

.rag-input,
.rag-textarea {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  background: #fff;
  color: #0f172a;
  padding: 12px 14px;
  font: inherit;
}

.rag-textarea {
  min-height: 92px;
  resize: vertical;
}

.rag-button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f766e, #0ea5e9);
  color: #fff;
  font-weight: 700;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.rag-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.2);
}

.rag-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.rag-button-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.rag-button-danger {
  width: 100%;
  margin-top: 14px;
  background: linear-gradient(135deg, #dc2626, #f97316);
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.conversation-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: #fff;
  padding: 12px 14px;
  cursor: pointer;
}

.conversation-item.is-active {
  border-color: rgba(14, 165, 233, 0.45);
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(14, 165, 233, 0.08));
}

.conversation-title {
  display: block;
  font-weight: 700;
  color: #0f172a;
}

.conversation-meta {
  display: block;
  margin-top: 4px;
  font-size: 0.88rem;
  color: #64748b;
}

.rag-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.rag-header,
.chat-form {
  padding: 20px 22px;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  padding: 18px 20px;
}

.message.user {
  border-color: rgba(14, 165, 233, 0.2);
}

.message.assistant {
  border-color: rgba(15, 118, 110, 0.18);
}

.message-role {
  margin-bottom: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0f766e;
}

.message-content {
  color: #0f172a;
  line-height: 1.72;
  word-break: break-word;
}

.message-content p,
.message-content ol,
.message-content ul,
.message-content pre,
.message-content blockquote {
  margin: 0 0 14px;
}

.message-content ol,
.message-content ul {
  padding-left: 28px;
}

.message-content li + li {
  margin-top: 6px;
}

.message-content code {
  padding: 0.15em 0.35em;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.06);
  font-size: 0.92em;
}

.message-content pre {
  overflow-x: auto;
  padding: 14px 16px;
  border-radius: 14px;
  background: #0f172a;
  color: #e2e8f0;
}

.message-content pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.message-content blockquote {
  border-left: 4px solid rgba(15, 118, 110, 0.35);
  margin-left: 0;
  padding-left: 14px;
  color: #334155;
}

.source-panel {
  margin-top: 16px;
  border-top: 1px dashed rgba(15, 23, 42, 0.12);
  padding-top: 14px;
}

.source-panel summary {
  cursor: pointer;
  font-weight: 700;
  color: #0f172a;
}

.source-item {
  margin-top: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: #fff;
  padding: 12px 14px;
}

.source-title {
  font-weight: 700;
  color: #0f172a;
}

.source-preview {
  margin-top: 6px;
  color: #475569;
  white-space: pre-wrap;
}

@media (max-width: 960px) {
  .rag-shell {
    grid-template-columns: 1fr;
  }
}
