:root {
  --primary: #1f2a44;
  --primary-light: #2c3a60;
  --accent: #e0a95f;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #1c1f2a;
  --muted: #6b7280;
  --border: #e3e6ee;
  --user-bg: #1f2a44;
  --user-text: #ffffff;
  --bot-bg: #ffffff;
  --bot-border: #e3e6ee;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

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

/* ========== Sidebar ========== */
.sidebar {
  background: var(--primary);
  color: #fff;
  padding: 22px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.brand .logo {
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: var(--primary);
  font-weight: 700;
  font-size: 22px;
  display: grid;
  place-items: center;
  border-radius: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.4px;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.7;
}

.panel {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px;
  border-radius: 10px;
}

.panel h3 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent);
}

.modules {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modules li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.modules li.current {
  background: rgba(224, 169, 95, 0.18);
  border: 1px solid rgba(224, 169, 95, 0.4);
}

.modules li.done {
  opacity: 0.7;
}

.modules .badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.modules .badge.ok { background: #4ade80; color: #052e16; }

#session-info {
  font-size: 12px;
  margin-bottom: 10px;
  opacity: 0.85;
}

.output-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.outputs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.outputs li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 8px;
  border-radius: 6px;
}

.outputs a {
  color: var(--accent);
  text-decoration: none;
}

.outputs a:hover {
  text-decoration: underline;
}

/* ========== Agora ========== */
.small { font-size: 11px; opacity: 0.75; margin: 0 0 8px; }

.personas {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.persona-btn {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
}

.persona-btn:hover { background: rgba(255, 255, 255, 0.10); }

.persona-btn .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}

.persona-btn .info { display: flex; flex-direction: column; line-height: 1.15; }
.persona-btn .info .name { font-weight: 600; font-size: 13px; }
.persona-btn .info .role { font-size: 11px; opacity: 0.7; }

.divider {
  flex-basis: 100%;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Persona-coloured chat bubbles */
.msg.persona {
  align-self: flex-start;
  border-left: 4px solid var(--persona-color, #888);
  background: var(--bot-bg);
  border: 1px solid var(--bot-border);
  border-left: 4px solid var(--persona-color, #888);
  border-bottom-left-radius: 4px;
}

.msg.persona .persona-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--persona-color, #555);
  margin-bottom: 6px;
}

.msg.persona .persona-tag .avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--persona-color, #555);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 10px;
}

.fallback-flag {
  font-size: 10px;
  background: #fbbf24;
  color: #78350f;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.persona-retry,
.persona-action {
  background: rgba(0, 212, 184, 0.10);
  border: 1px solid rgba(0, 212, 184, 0.35);
  color: #00D4B8;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
}
.persona-retry { margin-top: 8px; padding: 5px 12px; font-size: 12px; }
.persona-retry:hover, .persona-action:hover { background: rgba(0, 212, 184, 0.20); }
.persona-retry[disabled], .persona-action[disabled] { opacity: 0.5; cursor: wait; }

.persona-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ========== Refine modal ========== */
.refine-list { display: flex; flex-direction: column; gap: 14px; max-height: 50vh; overflow-y: auto; padding: 4px; }
.refine-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
}
.refine-q { font-size: 13px; color: #c5cde0; margin-bottom: 8px; }
.refine-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .refine-cols { grid-template-columns: 1fr; } }
.refine-col { display: flex; flex-direction: column; gap: 6px; }
.refine-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #8a96b3; font-weight: 700; }
.refine-rationale { color: #00D4B8; text-transform: none; font-weight: 400; }
.refine-text {
  font-size: 12px;
  line-height: 1.45;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e6e9f2;
  min-height: 80px;
  font-family: inherit;
}
.refine-original { white-space: pre-wrap; opacity: 0.75; }
.refine-refined { resize: vertical; width: 100%; }
.refine-actions { margin-top: 8px; font-size: 12px; color: #c5cde0; }
.refine-actions input[type="checkbox"] { accent-color: #00D4B8; margin-right: 6px; }

/* Header de bloque refinado · ancla para scrollIntoView */
.msg.refine-anchor {
  background: rgba(0, 212, 184, 0.10);
  border-left: 3px solid #00D4B8;
  font-weight: 600;
  color: #00D4B8 !important;
}

/* Flash highlight cuando llegan los refinados al chat */
.flash-highlight {
  animation: flash-bg 1.6s ease-out;
}
@keyframes flash-bg {
  0%   { background: rgba(0, 212, 184, 0.40); }
  100% { background: rgba(0, 212, 184, 0.10); }
}

/* Respuestas refinadas aplicadas · aparecen en el chat para que el
   founder vea exactamente que cambio y siga desde ahi. */
.msg.refined-applied {
  border-left: 3px solid #00D4B8;
  background: rgba(0, 212, 184, 0.06);
  padding: 12px 14px;
}
.msg.refined-applied .refined-q {
  font-size: 12px;
  color: #8a96b3;
  margin-bottom: 6px;
}
.msg.refined-applied .refined-a {
  font-size: 14px;
  color: #e6e9f2;
  line-height: 1.5;
  white-space: pre-wrap;
}
.msg.refined-applied .refined-rationale {
  margin-top: 6px;
  font-style: italic;
}

/* Tag transparencia · que modelo LLM genero esta respuesta */
.llm-badge {
  font-size: 10px;
  background: rgba(0, 212, 184, 0.12);
  color: #00D4B8;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 500;
  letter-spacing: 0.2px;
  cursor: help;
}

/* ========== Toast notifications ========== */
#toast-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  min-width: 280px;
  max-width: 420px;
  background: #0A1628;
  color: #e6e9f2;
  border-left: 4px solid #00D4B8;
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  animation: toast-in 0.25s ease-out;
}
.toast-success { border-left-color: #00D4B8; }
.toast-error   { border-left-color: #F38281; }
.toast-warn    { border-left-color: #E0A95F; }
.toast-info    { border-left-color: #60A5FA; }
.toast-body { flex: 1; }
.toast-action {
  background: rgba(0, 212, 184, 0.15);
  color: #00D4B8;
  border: 1px solid rgba(0, 212, 184, 0.4);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.toast-action:hover { background: rgba(0, 212, 184, 0.25); }
.toast-close {
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}
.toast-close:hover { color: #fff; }
.toast-exit { animation: toast-out 0.25s ease-in forwards; }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateX(40px); opacity: 0; }
}

/* ========== Progress overlay (tareas largas como /outputs/all) ========== */
.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.78);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 9998;
  animation: overlay-in 0.2s ease-out;
}
.progress-card {
  background: #0F1E36;
  color: #e6e9f2;
  border-radius: 14px;
  padding: 28px 32px;
  min-width: 340px;
  max-width: 440px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 212, 184, 0.25);
  text-align: center;
}
.progress-card.failed { border-color: rgba(243, 130, 129, 0.5); }
.progress-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(0, 212, 184, 0.18);
  border-top-color: #00D4B8;
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 1.2s linear infinite;
}
.progress-card.failed .progress-spinner {
  border-top-color: #F38281;
  animation: none;
}
.progress-title {
  font-size: 17px;
  margin: 0 0 6px;
  font-weight: 700;
  color: #fff;
}
.progress-step {
  font-size: 13px;
  margin: 0 0 14px;
  color: #c5cde0;
  min-height: 18px;
}
.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  width: 5%;
  background: linear-gradient(90deg, #00D4B8, #60A5FA);
  transition: width 0.6s ease-out;
}
.progress-hint {
  font-size: 11px;
  color: #8a96b3;
  margin: 10px 0 0;
  font-style: italic;
}
@keyframes overlay-in {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Placeholder mientras la persona "piensa" — pulse + cursor parpadeando */
.persona-thinking {
  color: var(--persona-color, #888);
  font-style: italic;
  opacity: 0.75;
  animation: thinking-pulse 1.4s ease-in-out infinite;
}
.persona-thinking::after {
  content: "▌";
  margin-left: 4px;
  animation: thinking-blink 0.7s steps(1) infinite;
}
@keyframes thinking-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.95; }
}
@keyframes thinking-blink {
  50% { opacity: 0; }
}

/* ========== Voice button ========== */
.voice-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #eef1f8;
  color: var(--primary);
  border: none;
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.voice-btn:hover { background: #dbe2f1; }
.voice-btn.recording {
  background: #b91c1c;
  color: #fff;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(185, 28, 28, 0); }
}

/* ========== Q&A Rifle ========== */
.rifle-card {
  background: #1f2a44;
  color: #fff;
  border-radius: 14px;
  padding: 18px 20px;
  margin: 8px 0;
  border-left: 4px solid #e0a95f;
}

.rifle-card .category {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #e0a95f;
  margin-bottom: 6px;
}

.rifle-card .question {
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.rifle-card textarea {
  width: 100%;
  min-height: 80px;
  border-radius: 8px;
  border: none;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

.rifle-card .actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.rifle-card .progress { font-size: 12px; opacity: 0.8; }

.score-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.score-1 { background: #fecaca; color: #7f1d1d; }
.score-2 { background: #fed7aa; color: #7c2d12; }
.score-3 { background: #fde68a; color: #78350f; }
.score-4 { background: #bbf7d0; color: #064e3b; }
.score-5 { background: #86efac; color: #064e3b; }

/* ========== Investor matches ========== */
.investor-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 8px 0;
}

.investor-card .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.investor-card .name { font-weight: 700; font-size: 15px; color: var(--primary); }
.investor-card .score { font-size: 12px; color: var(--accent); font-weight: 700; }
.investor-card .meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.investor-card .reasons { font-size: 12px; margin: 6px 0; color: #444; }
.investor-card .intro {
  font-size: 12px;
  background: #f6f7fb;
  padding: 8px 10px;
  border-radius: 6px;
  white-space: pre-wrap;
  margin-top: 8px;
  font-family: 'Courier New', monospace;
}

/* ========== Modal ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: grid;
  place-items: center;
  z-index: 10500;  /* sobre user-menu (9999) y user-drop (10000) */
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: #fff;
  color: var(--text);
  border-radius: 14px;
  width: min(720px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 26px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  border: none;
  padding: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
  color: var(--primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--muted);
}

.modal .muted { color: var(--muted); font-size: 13px; }

.profile-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 12px 0 16px;
  padding: 10px;
  border-radius: 8px;
  background: #f6f7fb;
  font-size: 13px;
}

.profile-row input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
}

.profile-row button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
}

/* Provider cards inside modal */
.provider-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 10px 0;
  background: #fff;
  position: relative;
}
.provider-card.suggested {
  border-color: var(--accent);
  background: #fffaf2;
}
.provider-card.active {
  border-color: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.provider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.provider-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
}

.provider-badges { display: flex; gap: 6px; flex-wrap: wrap; }

.provider-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef1f8;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.3px;
}
.provider-badge.suggested { background: var(--accent); color: var(--primary); }
.provider-badge.active { background: #16a34a; color: #fff; }
.provider-badge.configured { background: #16a34a; color: #fff; }
.provider-badge.via-env { background: #fbbf24; color: #78350f; }
.provider-badge.vision { background: #6366f1; color: #fff; }

.provider-card .tagline {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 8px;
}

.provider-card .actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.provider-card .actions input {
  flex: 1;
  min-width: 200px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: monospace;
  font-size: 12px;
}

.provider-card button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.provider-card button.secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.provider-card button.danger {
  background: #fff;
  color: #b91c1c;
  border: 1px solid #b91c1c;
}

.provider-card .links {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  font-size: 12px;
}

.provider-card .links a {
  color: var(--accent);
  text-decoration: none;
}
.provider-card .links a:hover { text-decoration: underline; }

.provider-card .test-result {
  margin-top: 8px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
}
.provider-card .test-result.ok { background: #dcfce7; color: #166534; }
.provider-card .test-result.err { background: #fee2e2; color: #991b1b; }

/* ========== Live Financial Model ========== */
.modal-wide {
  width: min(1100px, 100%);
  max-height: 95vh;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.kpi-card {
  background: linear-gradient(135deg, #1f2a44 0%, #2c3a60 100%);
  color: #fff;
  border-radius: 10px;
  padding: 12px 14px;
}

.kpi-card .kpi-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  margin-bottom: 6px;
}

.kpi-card .kpi-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kpi-card .kpi-sub {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}

.model-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 8px 0 14px;
}

.model-table-wrap {
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.model-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.model-table thead th {
  position: sticky;
  top: 0;
  background: #1f2a44;
  color: #fff;
  padding: 8px 10px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.model-table thead th:first-child {
  text-align: left;
  min-width: 220px;
  z-index: 2;
  left: 0;
  position: sticky;
}

.model-table tbody td {
  padding: 0;
  border-bottom: 1px solid var(--border);
}

.model-table tbody td.lever-name {
  padding: 8px 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--bg);
  position: sticky;
  left: 0;
  border-right: 1px solid var(--border);
}

.model-cell {
  width: 100%;
  height: 36px;
  text-align: right;
  border: none;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: background 0.15s;
}

.model-cell:hover { background: rgba(31, 42, 68, 0.06); }
.model-cell:focus { background: rgba(224, 169, 95, 0.15); }
.model-cell.custom { background: rgba(34, 197, 94, 0.10); font-weight: 600; }
.model-cell.custom:focus { background: rgba(34, 197, 94, 0.22); }

.changes-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 18px 0 8px;
}

.model-changes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}

.model-changes li {
  font-size: 12px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.model-changes li .ts {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.status {
  margin-top: auto;
  padding-top: 10px;
  font-size: 12px;
  opacity: 0.75;
}

.pill {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: 999px;
}

.pill.ok { background: #166534; }
.pill.err { background: #991b1b; }
.pill.warn { background: #92400e; color: #fffbeb; }

/* ========== Main ========== */
.main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  max-width: 76%;
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: var(--shadow);
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bot-bg);
  border: 1px solid var(--bot-border);
  border-bottom-left-radius: 4px;
}

.msg.system {
  align-self: center;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  font-size: 13px;
  font-style: italic;
}

.msg .meta {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 6px;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 14px 20px 6px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.composer textarea:focus {
  border-color: var(--primary);
}

.quick-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 20px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.quick-actions button {
  background: #eef1f8;
  color: var(--primary);
  border: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.quick-actions button:hover {
  background: #dbe2f1;
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s, transform 0.05s;
}

button:hover { background: rgba(255, 255, 255, 0.12); }
button:active { transform: translateY(1px); }

button.primary {
  background: var(--accent);
  color: var(--primary);
  border: none;
  font-weight: 600;
}

button.primary:hover {
  background: #d59750;
}

.composer button.primary {
  padding: 0 18px;
}

.block {
  width: 100%;
  margin-top: 8px;
}

select.block {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.muted {
  color: rgba(255, 255, 255, 0.65);
}

/* Scrollbar */
.messages::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb {
  background: #c5c8d4;
  border-radius: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
}
