:root {
  --navy: #26285b;
  --navy-2: #1d1f4a;
  --orange: #e07c00;
  --orange-soft: #fdf1e2;
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1b1d2e;
  --muted: #646880;
  --border: #e3e5ee;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand img { height: 52px; width: auto; border-radius: 6px; }
.brand-title { font-weight: 700; font-size: 18px; }
.brand-sub { font-size: 13px; color: #c9cbe6; }
.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .35);
  color: inherit;
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.ghost:hover { background: rgba(255, 255, 255, .1); }
.layout { flex: 1; overflow-y: auto; }
.chat { max-width: 860px; margin: 0 auto; padding: 28px 20px 140px; }
.welcome h1 { font-size: 28px; margin: 12px 0 8px; color: var(--navy); }
.welcome p { color: var(--muted); line-height: 1.55; margin: 0 0 22px; }
.suggestions { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.suggestion {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
}
.suggestion:hover { border-color: var(--orange); }
.suggestion small { display: block; color: var(--orange); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.msg { margin: 18px 0; display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 100%; border-radius: var(--radius); padding: 14px 18px; line-height: 1.6; font-size: 15px; }
.msg.user .bubble { background: var(--navy); color: #fff; max-width: 80%; }
.msg.bot .bubble { background: var(--card); border: 1px solid var(--border); width: 100%; }
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ol, .bubble ul { margin: 6px 0 10px; padding-left: 22px; }
.bubble li { margin: 4px 0; }
.cite {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  margin: 0 1px;
  border-radius: 6px;
  background: var(--orange-soft);
  color: var(--orange);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  vertical-align: 1px;
}
.cite:hover { background: var(--orange); color: #fff; }
.sources { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.sources h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; }
.source {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 8px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
}
.source:hover, .source.flash { background: var(--orange-soft); }
.source img { width: 112px; height: 63px; object-fit: cover; border-radius: 6px; flex: none; background: #ddd; }
.source .doc-icon { width: 112px; height: 63px; border-radius: 6px; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.source .num { color: var(--orange); font-weight: 700; margin-right: 4px; }
.source .title { font-weight: 600; font-size: 14px; }
.source .where { font-size: 12px; color: var(--orange); font-weight: 600; margin: 2px 0; }
.source .excerpt { font-size: 13px; color: var(--muted); line-height: 1.45; }
.typing { display: inline-flex; gap: 5px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); 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; } 40% { opacity: 1; } }
.error { color: #b42318; }
.composer {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(860px, calc(100% - 32px));
  display: flex;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 10px 10px 16px;
  box-shadow: 0 10px 30px rgba(20, 22, 60, .12);
}
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; font: inherit; font-size: 15px; max-height: 160px; padding: 8px 0; background: transparent; color: var(--text); }
.composer button { background: var(--orange); color: #fff; border: 0; border-radius: 12px; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; flex: none; align-self: flex-end; }
.composer button:disabled { opacity: .5; cursor: default; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(420px, 100%);
  background: var(--card);
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; background: var(--navy); color: #fff; }
.drawer-head h2 { font-size: 16px; margin: 0; }
.drawer ul { list-style: none; margin: 0; padding: 8px 12px; overflow-y: auto; }
.drawer li a { display: flex; gap: 10px; padding: 10px 8px; text-decoration: none; color: var(--text); font-size: 14px; border-bottom: 1px solid var(--border); }
.drawer li a:hover { background: var(--bg); }
.drawer .kind { font-size: 11px; font-weight: 700; color: var(--orange); text-transform: uppercase; min-width: 44px; }
.scrim { position: fixed; inset: 0; background: rgba(10, 12, 40, .4); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 10; }
.scrim.open { opacity: 1; pointer-events: auto; }
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .brand img { height: 40px; }
  .brand-sub { display: none; }
  .chat { padding: 20px 16px 130px; }
  .welcome h1 { font-size: 23px; }
  .source img, .source .doc-icon { width: 84px; height: 48px; }
  .msg.user .bubble { max-width: 92%; }
}
.bubble li > p { margin: 4px 0; }
.bubble ul ul, .bubble ol ul { margin: 4px 0; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4 { font-size: 15px; margin: 12px 0 6px; }
