:root {
  --font: 'Manrope', system-ui, sans-serif;
  --cta:          #0176D3;
  --cta-hover:    #025CB2;
  --cta-light:    #EAF5FE;
  --accent:       #0B5CAB;
  --accent-hover: #084D96;
  --accent-light: #EEF4FF;
  --hero-from:    #16325C;
  --hero-to:      #1B3F73;
}

.main--rag {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Chat shell ── */
.chat-shell {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-shell__head {
  padding: 1rem 1rem .85rem;
  background: linear-gradient(180deg, #F8FBFF 0%, #EEF4FB 100%);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.chat-shell__eyebrow {
  display: inline-block;
  margin-bottom: .2rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cta);
}
.chat-shell__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .2rem;
}
.chat-shell__sub {
  font-size: .83rem;
  color: var(--text-secondary);
  line-height: 1.45;
  max-width: 560px;
}
.chat-trust {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .42rem .65rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Messages ── */
.chat-messages {
  flex: 1;
  min-height: 340px;
  max-height: 420px;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  gap: .6rem;
  max-width: 88%;
  animation: fadeUp .18s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg--user { align-self: flex-end; flex-direction: row-reverse; }
.msg--bot  { align-self: flex-start; }

.msg__avatar {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
}
.msg--bot  .msg__avatar { background: var(--cta-light); color: var(--accent); }
.msg--user .msg__avatar { background: #E7F0FB; color: var(--hero-from); }

.msg__bubble {
  padding: .6rem .85rem;
  border-radius: 10px;
  font-size: .875rem;
  line-height: 1.55;
  word-break: break-word;
}
.msg--bot  .msg__bubble { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border-light); border-top-left-radius: 3px; }
.msg--user .msg__bubble { background: linear-gradient(135deg, var(--cta), var(--accent)); color: #fff; border-top-right-radius: 3px; }

/* Typing indicator */
.typing { display: flex; align-items: center; gap: 4px; padding: .5rem .85rem; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--cta); opacity: .5;
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .25; transform: scale(.85); }
  40%            { opacity: 1;   transform: scale(1.1); }
}

/* ── Divider ── */
.chat-divider { border: none; border-top: 1px solid var(--border-light); margin: 0; }

/* ── Sample chips ── */
.chat-chips {
  padding: .75rem 1rem .85rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  background: #FAFBFD;
  border-bottom: 1px solid var(--border-light);
}
.chip-label {
  font-size: .7rem;
  color: var(--text-muted);
  font-weight: 700;
  width: 100%;
  margin-bottom: 0;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.chip-note {
  width: 100%;
  font-size: .75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: .15rem;
}
.chip {
  font-size: .76rem;
  padding: .34rem .62rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: #F8FBFF;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease), color var(--ease), transform var(--ease);
  line-height: 1.3;
}
.chip:hover {
  border-color: #BFD5EE;
  color: var(--accent);
  background: #F1F7FD;
  transform: translateY(-1px);
}

/* ── Input bar ── */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .75rem 1rem;
}
.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .75rem;
  font-family: var(--font);
  font-size: .875rem;
  color: var(--text);
  background: #fff;
  line-height: 1.5;
  min-height: 42px;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color var(--ease);
}
.chat-input:focus { outline: none; border-color: var(--cta); }
.chat-input:disabled { background: var(--surface-alt); }

.btn-send {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: 8px;
  border: none;
  background: var(--cta);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--ease);
}
.btn-send:hover:not(:disabled) { background: var(--cta-hover); }
.btn-send:disabled { background: var(--border); cursor: not-allowed; }

/* ── Unavailable state ── */
.unavailable-banner {
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  border-radius: 8px;
  padding: .85rem 1rem;
  font-size: .85rem;
  color: #92400E;
  display: flex;
  gap: .6rem;
  align-items: flex-start;
}

/* ── Info card ── */
.rag-info {
  background: #F6FAFE;
  border: 1px solid #D5E1F0;
  border-radius: 8px;
  padding: .95rem 1rem;
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.55;
}
.rag-info strong { font-weight: 700; color: var(--text); }

/* ── Error ── */
.msg--error .msg__bubble { background: var(--danger-light); color: var(--danger); border-color: #FECACA; }

@media (max-width: 640px) {
  .main--rag {
    padding: 1rem .75rem 2rem;
  }
  .chat-shell__head,
  .chat-chips,
  .chat-messages,
  .chat-input-bar {
    padding-left: .85rem;
    padding-right: .85rem;
  }
  .chat-shell__sub {
    max-width: none;
  }
}

@media (max-width: 500px) {
  .chat-shell__head {
    flex-direction: column;
    align-items: stretch;
  }
  .chat-trust {
    white-space: normal;
  }
  .chip {
    width: 100%;
    text-align: left;
    border-radius: 10px;
    padding: .55rem .7rem;
  }
  .msg { max-width: 96%; }
  .chat-messages { min-height: 280px; max-height: 350px; }
}
