:root {
  --bzd-blue-900: #003a78;
  --bzd-blue-700: #1f4f83;
  --bzd-blue-500: #5b82ad;
  --bzd-blue-300: #6f93b8;
  --bzd-text-light: #f4f8ff;
  --bzd-overlay: rgba(4, 21, 45, 0.56);
  --bzd-input-bg: #d9e0e8;
  --bzd-input-text: #557ca7;
  --bzd-orange: #f4a137;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0;
  padding: 24px;
  background: #f5f6f9;
  color: #111827;
  min-height: 180vh;
}

h1 {
  margin-top: 0;
}

#rag-chat {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 9999;
}

#rag-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 21, 45, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#rag-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

#rag-window {
  position: fixed;
  right: 64px;
  bottom: 0;
  width: min(560px, 100vw);
  height: min(78vh, 860px);
  min-width: 340px;
  min-height: 420px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  resize: both;
  overflow: hidden;
  background: #003a78;
  color: #fff;
  display: flex;
  flex-direction: column;
  transform: translateY(102%);
  transition: transform 0.6s ease;
  box-shadow: 0 -24px 40px rgba(4, 21, 45, 0.45);
}

#rag-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 12px 18px;
  background: #0d477f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#rag-session-select,
#rag-collection-select,
#rag-new-chat,
#rag-delete-chat {
  border: 0;
  min-height: 34px;
  border-radius: 6px;
  font-size: 14px;
}

#rag-session-select,
#rag-collection-select {
  padding: 0 10px;
  color: #0d3763;
}

.rag-toolbar-selects {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.rag-toolbar-actions {
  display: inline-flex;
  gap: 8px;
}

#rag-new-chat,
#rag-delete-chat {
  padding: 0 12px;
  color: #0d3763;
  font-weight: 600;
  cursor: pointer;
}

#rag-new-chat {
  background: #f4a137;
}

#rag-delete-chat {
  background: #e8eef7;
}


#rag-window.open {
  transform: translateY(0);
}

#rag-log {
  flex: 1;
  overflow-y: auto;
  padding: 84px 30px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: relative;
  left: -10px;
  width: calc(100% + 10px);
}

.rag-entry {
  display: flex;
  flex-direction: column;
  gap: 6px;
  line-height: 1.4;
}

.rag-entry-role {
  display: none;
}

.rag-entry-text {
  font-size: clamp(16px, 1.5vw, 22px);
  white-space: normal;
}

.rag-entry-text p,
.rag-entry-text ul,
.rag-entry-text h4 {
  margin: 0;
}

.rag-entry-text p + p,
.rag-entry-text p + ul,
.rag-entry-text ul + p,
.rag-entry-text h4 + ul,
.rag-entry-text ul + h4,
.rag-entry-text h4 + p {
  margin-top: 10px;
}

.rag-entry-text h4 {
  font-size: 1.04em;
  font-weight: 700;
}

.rag-entry-text ul {
  padding-left: 1.15em;
}

.rag-entry-text li + li {
  margin-top: 6px;
}

.rag-entry-text .rag-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 14px;
  border: 1px solid rgba(191, 220, 255, 0.4);
  background: rgba(17, 72, 127, 0.45);
  color: #ebf4ff;
  text-decoration: none;
  font-weight: 600;
}

.rag-entry-text .rag-cta-link {
  background: #f4a137;
  color: #0d3763;
  border-color: transparent;
  font-weight: 700;
}

.rag-entry-feedback {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  color: #bfdcff;
  font-size: 13px;
}

.rag-entry-feedback button {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(17, 72, 127, 0.5);
  color: #fff;
  border-radius: 999px;
  padding: 4px 8px;
  cursor: pointer;
}

.rag-entry-feedback button.active {
  background: #f4a137;
  color: #0d3763;
  border-color: transparent;
}

.rag-entry--user .rag-entry-text {
  background: rgba(91, 130, 173, 0.35);
  color: #f2f8ff;
  font-size: clamp(16px, 1.4vw, 21px);
  line-height: 1.35;
  padding: 20px 22px;
}

.rag-entry--user .rag-entry-time {
  font-size: clamp(12px, 1vw, 15px);
  color: rgba(223, 236, 251, 0.55);
}

.rag-entry--bot .rag-entry-text,
.rag-entry--neutral .rag-entry-text {
  color: #f4f8ff;
}

.rag-entry--error .rag-entry-text {
  color: #ffd4d4;
}

.rag-entry--sources .rag-entry-text {
  color: #bfdcff;
  font-size: clamp(14px, 1.2vw, 18px);
}

#rag-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 0 0;
  padding: 24px 30px;
  background: #003a78;
  color: #fff;
  font-size: clamp(16px, 1.45vw, 24px);
  font-weight: 500;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  left: -10px;
  width: calc(100% + 10px);
}

.rag-dots {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.rag-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: ragBlink 1s infinite ease-in-out;
}

.rag-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.rag-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ragBlink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: scale(1);
  }
  40% {
    opacity: 1;
    transform: scale(1.25);
  }
}

#rag-form {
  display: grid;
  grid-template-columns: 1fr 62px;
  align-items: stretch;
  background: #d9e0e8;
  min-height: 136px;
}

#rag-input {
  border: 0;
  resize: none;
  width: 100%;
  font-size: clamp(15px, 1.2vw, 21px);
  line-height: 1.45;
  color: #557ca7;
  background: transparent;
  padding: 22px 24px;
}

#rag-input::placeholder {
  color: #6f93b8;
}

#rag-input:focus {
  outline: none;
}

#rag-submit {
  border: 0;
  align-self: end;
  height: 62px;
  width: 62px;
  background: #f4a137;
  color: #0d3763;
  font-size: 20px;
  cursor: pointer;
}

#rag-submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

#rag-toggle {
  position: fixed;
  bottom: 0;
  right: 0;
  height: 64px;
  min-width: 150px;
  border: 0;
  background: #003a78;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  font-size: 34px;
  font-size: clamp(20px, 2.4vw, 34px);
  cursor: pointer;
}

#rag-toggle.hidden {
  display: none;
}

.rag-toggle-text {
  white-space: nowrap;
}

.rag-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;
}

@media (max-width: 860px) {
  #rag-window {
    right: 16px;
    width: min(74vw, 560px);
    height: min(86vh, 900px);
  }

  #rag-log {
    padding: 68px 20px 18px;
    gap: 20px;
    left: -6px;
    width: calc(100% + 6px);
  }

  #rag-status {
    padding: 22px 20px;
    left: -6px;
    width: calc(100% + 6px);
  }

  #rag-form {
    min-height: 128px;
    grid-template-columns: 1fr 54px;
  }

  #rag-input {
    padding: 22px 20px;
  }

  #rag-submit {
    width: 54px;
    height: 54px;
  }

  #rag-toggle {
    height: 60px;
    padding: 0 18px;
    min-width: 136px;
  }
}
