:root {
  --bg: #0f1419;
  --surface: #171d26;
  --surface-2: #1e2630;
  --border: #2a3340;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --accent: #4f9cf9;
  --accent-2: #35d0a5;
  --warn: #e0a94b;
  --danger: #e5705a;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app { display: grid; grid-template-columns: 290px 1fr; height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 22px;
  overflow-y: auto;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-weight: 800; font-size: 22px; color: #06121f;
}
.brand-text h1 { font-size: 15px; line-height: 1.2; margin: 0; letter-spacing: .2px; }
.brand-text p { margin: 3px 0 0; font-size: 11.5px; color: var(--text-dim); }

.panel-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--text-dim); margin-bottom: 9px;
}

.mode-toggle { display: flex; background: var(--surface-2); border-radius: 10px; padding: 4px; gap: 4px; }
.mode-btn {
  flex: 1; border: 0; background: transparent; color: var(--text-dim);
  padding: 8px 0; border-radius: 7px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.mode-btn.active { background: var(--accent); color: #06121f; }

.agent-list { display: flex; flex-direction: column; gap: 9px; }
.agent-card {
  text-align: left; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 12px; cursor: pointer; color: var(--text);
  transition: border-color .15s, background .15s;
}
.agent-card:hover { border-color: #3a4656; }
.agent-card.selected { border-color: var(--accent); background: #16263c; }
.agent-card .ac-label { font-weight: 650; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.agent-card .ac-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }
.agent-card .pill { font-size: 9.5px; padding: 2px 6px; border-radius: 20px; background: #0d3b2e; color: var(--accent-2); }
.agent-list.disabled { opacity: .45; pointer-events: none; }

.samples { display: flex; flex-direction: column; gap: 7px; }
.sample {
  text-align: left; background: transparent; border: 1px dashed var(--border);
  color: var(--text-dim); border-radius: 9px; padding: 8px 10px; font-size: 12px; cursor: pointer;
}
.sample:hover { border-color: var(--accent); color: var(--text); }

.sidebar-foot {
  margin-top: auto; font-size: 11.5px; color: var(--text-dim);
  display: flex; align-items: center; gap: 7px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  padding: 18px 26px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.chat-header h2 { margin: 0; font-size: 16px; }
.chat-header p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-dim); }
.header-badges { display: flex; gap: 8px; }
.badge { font-size: 11px; padding: 5px 10px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); }

.messages { flex: 1; overflow-y: auto; padding: 24px 26px; display: flex; flex-direction: column; gap: 18px; }

.empty-state { margin: auto; text-align: center; max-width: 420px; color: var(--text-dim); }
.empty-icon { font-size: 40px; }
.empty-state h3 { color: var(--text); margin: 10px 0 6px; }
.empty-state p { font-size: 13.5px; line-height: 1.55; }

.msg { display: flex; flex-direction: column; max-width: 820px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.user .bubble {
  background: var(--accent); color: #06121f; padding: 11px 15px;
  border-radius: 14px 14px 4px 14px; font-size: 14px; line-height: 1.5; max-width: 560px;
}
.msg.agent { align-self: stretch; }

.answers { display: grid; gap: 14px; }
.answers.compare { grid-template-columns: 1fr 1fr; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 15px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.card-head .name { font-weight: 650; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.card-head .tag { font-size: 10.5px; color: var(--text-dim); }
.status-ok { color: var(--accent-2); }
.status-bad { color: var(--danger); }
.card-body { padding: 15px; font-size: 13.5px; line-height: 1.6; }

.section { margin-bottom: 14px; }
.section:last-child { margin-bottom: 0; }
.section h4 {
  margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--accent); display: flex; align-items: center; gap: 6px;
}
.section.limitations h4 { color: var(--warn); }
.section p { margin: 0; }
.section ul { margin: 0; padding-left: 18px; }
.section li { margin: 3px 0; }
.evidence { font-size: 12px; color: var(--text-dim); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.evidence li { word-break: break-word; }
.err { color: var(--danger); font-size: 13px; }

/* typing / loading */
.loading { display: flex; gap: 5px; padding: 6px 2px; }
.loading span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); animation: blink 1.2s infinite both; }
.loading span:nth-child(2) { animation-delay: .2s; }
.loading span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- Composer ---------- */
.composer {
  display: flex; gap: 10px; padding: 16px 26px 22px; border-top: 1px solid var(--border);
}
#input {
  flex: 1; resize: none; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 12px; padding: 13px 15px; font-size: 14px;
  font-family: inherit; max-height: 160px; line-height: 1.5;
}
#input:focus { outline: none; border-color: var(--accent); }
#sendBtn {
  background: var(--accent); color: #06121f; border: 0; border-radius: 12px;
  padding: 0 22px; font-weight: 700; font-size: 14px; cursor: pointer;
}
#sendBtn:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .answers.compare { grid-template-columns: 1fr; }
}
