/* ==========================================================================
   Multi-Document Comparison with the Send API — enterprise SaaS UI
   Shares the design language of the sibling RAG projects:
     deep violet #2F004F · plum #722268 · coral #E85F5C
     amber #F5AB00 · teal #0E7C86 · off-white #F7F7F9 · ink #221331
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --violet-950: #22003b;
  --violet-900: #2f004f;
  --violet-800: #3d0f63;
  --violet-100: #efe6f7;
  --plum: #722268;
  --coral: #e85f5c;
  --coral-dark: #d14b48;
  --coral-soft: #fdeeed;
  --amber: #f5ab00;
  --amber-soft: #fdf3da;
  --teal: #0e7c86;
  --teal-soft: #e2f4f5;
  --indigo: #4f46b5;
  --indigo-soft: #ecebfa;
  --bg: #f7f7f9;
  --surface: #ffffff;
  --ink: #221331;
  --muted: #6f677e;
  --border: #e7e3ee;
  --border-strong: #d8d2e2;
  --success: #1e9e6a;
  --success-soft: #e4f5ee;
  --danger: #c43d3b;
  --danger-soft: #fbe9e9;
  --radius: 12px;
  --radius-sm: 8px;
  --rail-w: 244px;
  --topbar-h: 60px;
  --shadow-sm: 0 1px 2px rgba(34, 0, 59, 0.06), 0 1px 3px rgba(34, 0, 59, 0.08);
  --shadow-md: 0 4px 16px rgba(34, 0, 59, 0.10);
  --shadow-lg: 0 12px 40px rgba(34, 0, 59, 0.18);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
code, pre, .mono { font-family: 'JetBrains Mono', monospace; font-size: 0.85em; }
code { background: var(--violet-100); color: var(--violet-900); padding: 0.1em 0.4em; border-radius: 5px; }
h1, h2, h3, h4 { margin: 0 0 0.5rem 0; font-weight: 700; color: var(--ink); }
p { margin: 0 0 0.5rem 0; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--plum); }
::selection { background: var(--coral); color: #fff; }

/* ==========================================================================
   Shell: nav rail + main column
   ========================================================================== */

.app-shell { display: flex; min-height: 100vh; }

.nav-rail {
  width: var(--rail-w);
  background: linear-gradient(180deg, var(--violet-900) 0%, var(--violet-950) 100%);
  color: #efe9f6;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  transform: translateX(-100%);
  transition: transform 0.24s ease;
}
.nav-rail.open { transform: translateX(0); box-shadow: var(--shadow-lg); }

.nav-brand {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 1.15rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 800; font-size: 1rem; color: #ffffff; letter-spacing: 0.01em; }
.brand-sub { font-size: 0.68rem; color: #b9a8cd; font-weight: 500; }

.nav-menu { padding: 0.9rem 0.7rem; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.7rem;
  width: 100%;
  background: transparent; border: none;
  color: #cbbcdc;
  font-size: 0.9rem; font-weight: 600;
  padding: 0.68rem 0.85rem;
  border-radius: 9px;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #ffffff; }
.nav-item.active { background: rgba(255, 255, 255, 0.11); color: #ffffff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -0.7rem; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--coral);
}

.nav-foot {
  margin-top: auto;
  padding: 1rem 1.1rem 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}
.nav-pipeline { font-size: 0.68rem; line-height: 1.7; color: #a893be; font-weight: 500; }
.nav-pipeline b { color: #d9c9ea; font-weight: 700; }

.backdrop {
  position: fixed; inset: 0; background: rgba(34, 0, 59, 0.45);
  z-index: 55; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ==========================================================================
   Topbar
   ========================================================================== */

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0 1.1rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.page-title { font-size: 1.08rem; font-weight: 800; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; min-width: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem; font-weight: 600;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
}
.chip-model { max-width: 220px; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 1.5; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex-shrink: 0; }
.status-dot.ok { background: var(--success); }

.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--ink);
  border-radius: var(--radius-sm); width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
}
.only-mobile { display: inline-flex; }

/* ==========================================================================
   Content area
   ========================================================================== */

.content { flex: 1; padding: 1.25rem 1.1rem 2rem; width: 100%; max-width: 1120px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.page-lede { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 0.95rem; font-weight: 800; margin-bottom: 0.85rem; display: flex; align-items: center; gap: 0.5rem; }
.card-title svg { color: var(--plum); flex-shrink: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.grid-2.tight { gap: 0.35rem 1.2rem; margin-bottom: 0.3rem; }
.span-2 { grid-column: 1 / -1; }

/* ---------- forms ---------- */

.field { display: block; margin-bottom: 0.8rem; min-width: 0; }
.field > span { display: block; font-size: 0.78rem; font-weight: 600; color: var(--muted); margin-bottom: 0.35rem; }
.field .val { color: var(--plum); font-weight: 800; }
.optional { font-style: normal; font-weight: 500; color: var(--border-strong); text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.05em; }

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.58rem 0.75rem;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--plum);
  box-shadow: 0 0 0 3px rgba(114, 34, 104, 0.13);
}
textarea { resize: vertical; min-height: 2.4rem; line-height: 1.45; }
::placeholder { color: #b3abc1; }
select { appearance: none; -webkit-appearance: none; background-image:
  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236f677e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 0.6rem center; padding-right: 1.8rem; cursor: pointer; }

input[type="range"] { width: 100%; accent-color: var(--coral); height: 24px; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.85rem; font-weight: 600; color: var(--ink);
  margin-bottom: 0.8rem; cursor: pointer; gap: 0.6rem;
}
.switch-row input[type="checkbox"] { position: absolute; opacity: 0; }
.switch {
  width: 40px; height: 22px; border-radius: 999px; background: var(--border);
  border: 1px solid var(--border-strong); position: relative; flex-shrink: 0;
  transition: background 0.18s ease;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease;
}
.switch-row input:checked + .switch { background: var(--success); border-color: var(--success); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }

.hint { font-size: 0.76rem; color: var(--muted); line-height: 1.5; }
.form-error { color: var(--danger); font-size: 0.8rem; font-weight: 600; margin: 0.2rem 0 0.6rem; }
.key-status { font-weight: 700; color: var(--success); }

/* ---------- buttons ---------- */

.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 0.62rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  min-height: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover { border-color: var(--plum); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn-primary:hover { background: var(--coral-dark); border-color: var(--coral-dark); }
.btn-secondary { background: var(--violet-100); border-color: var(--violet-100); color: var(--violet-900); }
.btn-secondary:hover { border-color: var(--plum); }
.btn-ghost-danger { background: transparent; color: var(--danger); border-color: var(--border); margin-top: 0.4rem; }
.btn-ghost-danger:hover { border-color: var(--danger); background: var(--danger-soft); }

/* ---------- toasts ---------- */

.toast-container {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 0.5rem; align-items: center;
  width: min(92vw, 430px);
}
.toast {
  width: 100%; border-radius: var(--radius-sm); padding: 0.68rem 0.95rem;
  font-size: 0.83rem; font-weight: 600; box-shadow: var(--shadow-md);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink);
  animation: toast-in 0.2s ease;
}
.toast.success { border-color: var(--success); background: var(--success-soft); color: #0f6b46; }
.toast.error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   Documents view — dropzone, stats, document list
   ========================================================================== */

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--plum); }
.dropzone.drag-over { border-color: var(--coral); background: var(--coral-soft); }
.dropzone-inner svg { color: var(--plum); margin-bottom: 0.3rem; }
.link-text { color: var(--coral); font-weight: 700; text-decoration: underline; cursor: pointer; }

.file-chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.file-chip {
  display: flex; align-items: center; gap: 0.45rem;
  background: var(--violet-100); border: 1px solid transparent; border-radius: 999px;
  padding: 0.28rem 0.7rem; font-size: 0.76rem; font-weight: 600; color: var(--violet-900);
  max-width: 100%;
}
.file-chip span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.file-chip button { background: none; border: none; color: var(--plum); font-size: 0.9rem; line-height: 1; padding: 0; }
.file-chip button:hover { color: var(--danger); }

.progress-wrap { margin: 0.9rem 0; }
.progress-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--coral), var(--amber)); transition: width 0.3s ease; }

.kb-stats { margin-top: 1.1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; margin-bottom: 1rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.9rem; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-num { display: block; font-size: 1.5rem; font-weight: 800; color: var(--violet-900); }
.stat-label { font-size: 0.72rem; font-weight: 600; color: var(--muted); }

.doc-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.doc-item {
  display: flex; align-items: stretch; gap: 0.4rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
  transition: border-color 0.15s ease;
}
.doc-item:hover { border-color: var(--border-strong); }
.doc-item-body { flex: 1; min-width: 0; padding: 0.75rem 0.9rem; }
.doc-item-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; margin-bottom: 0.25rem; }
.doc-item-title { font-size: 0.9rem; font-weight: 800; color: var(--ink); word-break: break-word; }
.doc-item-meta { font-size: 0.7rem; font-weight: 600; color: var(--muted); }
.doc-item-preview { font-size: 0.78rem; color: var(--muted); margin: 0; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.doc-del {
  flex-shrink: 0; background: transparent; border: none; color: var(--muted);
  padding: 0 0.7rem; font-size: 0.85rem;
}
.doc-del:hover { color: var(--danger); background: var(--danger-soft); }

.empty-hint { color: var(--muted); font-size: 0.88rem; padding: 0.8rem 0.2rem; }

/* ==========================================================================
   Compare view — presets, field editor, document selector
   ========================================================================== */

.kb-banner {
  display: flex; align-items: center; gap: 0.55rem;
  background: var(--amber-soft); border: 1px solid var(--amber);
  color: #7a5600; font-size: 0.8rem; font-weight: 600;
  border-radius: var(--radius-sm); padding: 0.6rem 0.85rem; margin-bottom: 0.9rem;
}
.kb-banner svg { flex-shrink: 0; color: #b07d00; }

.preset-row { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 1rem; }
.preset-btn {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 0.4rem 0.9rem; font-size: 0.8rem; font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.preset-btn:hover { border-color: var(--plum); }
.preset-btn.active { background: var(--violet-900); border-color: var(--violet-900); color: #fff; }

.fields-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.fields-head .card-title { margin-bottom: 0; }
.field-count { font-size: 0.72rem; font-weight: 700; color: var(--muted); }

.field-editor { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.85rem; }
.field-row { display: grid; grid-template-columns: minmax(0, 1.1fr) 7rem minmax(0, 1.8fr) 2rem; gap: 0.4rem; align-items: center; }
.field-row input, .field-row select { padding: 0.45rem 0.6rem; font-size: 0.82rem; }
.field-row .fr-del {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: var(--radius-sm); height: 34px; font-size: 0.8rem;
}
.field-row .fr-del:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.doc-select { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.doc-pill {
  display: inline-flex; align-items: center; gap: 0.45rem;
  border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 999px; padding: 0.4rem 0.85rem; font-size: 0.8rem; font-weight: 700;
  color: var(--ink); cursor: pointer; user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.doc-pill:hover { border-color: var(--plum); }
.doc-pill.on { background: var(--violet-100); border-color: var(--plum); color: var(--violet-900); }
.doc-pill .box {
  width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.doc-pill.on .box { background: var(--plum); border-color: var(--plum); color: #fff; }
.doc-pill .box svg { width: 10px; height: 10px; opacity: 0; }
.doc-pill.on .box svg { opacity: 1; }
.doc-empty { font-size: 0.8rem; color: var(--muted); }

/* ==========================================================================
   Results — map-reduce trajectory (reuses the sibling graph-trace timeline)
   ========================================================================== */

.graph-trace {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem 0.7rem; margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.trace-title {
  font-size: 0.64rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 0.8rem;
}
.gt-steps { display: flex; flex-direction: column; }

.gt-step { display: grid; grid-template-columns: 26px 1fr; gap: 0.6rem; position: relative; padding-bottom: 0.9rem; }
.gt-step:last-child { padding-bottom: 0.15rem; }
.gt-step:not(:last-child)::before {
  content: ""; position: absolute; left: 12.5px; top: 24px; bottom: -2px;
  width: 2px; background: var(--border-strong);
}
.gt-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0; z-index: 1; box-shadow: var(--shadow-sm);
}
.gt-dot svg { width: 14px; height: 14px; }
.gt-dot.plan      { background: var(--indigo); }
.gt-dot.fanout    { background: var(--plum); }
.gt-dot.extract   { background: var(--violet-900); }
.gt-dot.synthesize{ background: var(--coral); }
.gt-dot.done      { background: var(--success); }
.gt-dot.running   { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(114,34,104,0.0); } 50% { box-shadow: 0 0 0 4px rgba(114,34,104,0.16); } }

.gt-body { min-width: 0; padding-top: 0.2rem; }
.gt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.gt-title { font-size: 0.86rem; font-weight: 800; color: var(--ink); }
.gt-badge {
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase;
  border-radius: 6px; padding: 0.08rem 0.4rem;
}
.gt-badge.kb     { background: var(--violet-100); color: var(--violet-900); }
.gt-badge.warn   { background: var(--amber-soft); color: #8a6100; }
.gt-badge.ok     { background: var(--success-soft); color: var(--success); }
.gt-badge.bad    { background: var(--danger-soft); color: var(--danger); }
.gt-detail { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; line-height: 1.5; word-break: break-word; }
.gt-detail .arrow { color: var(--coral); font-weight: 800; margin: 0 0.25rem; }

/* field chips inside the plan step */
.gt-fieldchips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.5rem; }
.gt-fieldchip {
  font-size: 0.68rem; font-weight: 700; border-radius: 999px; padding: 0.12rem 0.5rem;
  background: var(--indigo-soft); color: var(--indigo); border: 1px solid transparent;
}
.gt-fieldchip .ft { opacity: 0.7; font-weight: 800; text-transform: uppercase; font-size: 0.58rem; margin-left: 0.25rem; }

/* ==========================================================================
   Fan-out grid — one card per document (the parallel MAP phase)
   ========================================================================== */

.fanout-grid { display: grid; grid-template-columns: 1fr; gap: 0.6rem; margin-top: 0.7rem; }
.fan-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); padding: 0.7rem 0.8rem;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.fan-card.running { border-color: var(--amber); background: var(--amber-soft); }
.fan-card.done { border-color: #bfe6d3; background: var(--success-soft); }
.fan-card.error { border-color: #f1cfcf; background: var(--danger-soft); }
.fan-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.fan-title { font-size: 0.82rem; font-weight: 800; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fan-status {
  flex-shrink: 0; font-size: 0.62rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  border-radius: 999px; padding: 0.14rem 0.5rem; display: inline-flex; align-items: center; gap: 0.3rem;
}
.fan-status.queued { background: var(--violet-100); color: var(--muted); }
.fan-status.running { background: #fff; color: #8a6100; border: 1px solid var(--amber); }
.fan-status.done { background: #fff; color: var(--success); border: 1px solid #bfe6d3; }
.fan-status.error { background: #fff; color: var(--danger); border: 1px solid #f1cfcf; }
.fan-status .spinner {
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--amber-soft); border-top-color: var(--amber);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.fan-highlights { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.2rem; }
.fan-highlights .hl { font-size: 0.74rem; color: var(--ink); line-height: 1.45; padding-left: 0.9rem; position: relative; }
.fan-highlights .hl::before { content: "•"; position: absolute; left: 0.1rem; color: var(--coral); font-weight: 800; }
.fan-meta { margin-top: 0.4rem; font-size: 0.68rem; font-weight: 600; color: var(--muted); }

/* ==========================================================================
   Results — synthesis + comparison table
   ========================================================================== */

.result-head { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.result-head .card-title { margin-bottom: 0; }
.table-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; }

.answer-text { white-space: pre-wrap; font-size: 0.9rem; line-height: 1.65; }
.answer-text.streaming::after {
  content: "▌"; display: inline-block; margin-left: 1px;
  animation: blink 1s step-start infinite; color: var(--coral);
}
@keyframes blink { 50% { opacity: 0; } }
.answer-text.error-text { color: var(--danger); font-weight: 600; }
/* light markdown rendering */
.answer-text h1, .answer-text h2, .answer-text h3 { font-size: 0.98rem; margin: 0.9rem 0 0.4rem; }
.answer-text ul { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; }
.answer-text li { margin-bottom: 0.2rem; }
.answer-text p { margin-bottom: 0.6rem; }
.answer-text strong { color: var(--violet-900); }
.usage-caption { font-size: 0.72rem; font-weight: 600; color: var(--muted); }

.compare-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.compare-table { border-collapse: collapse; width: 100%; font-size: 0.82rem; min-width: 520px; }
.compare-table th, .compare-table td { text-align: left; vertical-align: top; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.compare-table thead th { background: var(--violet-900); color: #fff; font-weight: 800; position: sticky; top: 0; }
.compare-table thead th:first-child { background: var(--violet-950); }
.compare-table th.row-head {
  background: var(--bg); color: var(--ink); font-weight: 800; white-space: nowrap;
  position: sticky; left: 0; z-index: 1; border-right: 1px solid var(--border);
}
.compare-table tbody tr:nth-child(even) td { background: #fbfafd; }
.compare-table tbody tr:nth-child(even) th.row-head { background: #f3f0f8; }
.compare-table tbody tr:hover td { background: var(--violet-100); }
.compare-table td { color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.compare-table .type-tag { display: block; font-size: 0.58rem; font-weight: 700; text-transform: uppercase; color: var(--plum); letter-spacing: 0.04em; margin-top: 0.15rem; }
.compare-table tr.summary-row th.row-head, .compare-table tr.summary-row td { background: var(--amber-soft) !important; font-style: normal; }
.compare-table tr.summary-row td { color: var(--muted); }
.compare-table td.cell-error { color: var(--danger); font-weight: 600; }

/* ==========================================================================
   Settings view
   ========================================================================== */

.lock-wrap { display: flex; justify-content: center; padding: 2.5rem 0; }
.lock-card { width: min(100%, 400px); text-align: center; padding: 1.8rem 1.6rem; }
.lock-icon {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--violet-100); color: var(--violet-900);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 0.9rem;
}
.lock-card h3 { font-size: 1.05rem; }
.lock-card .field > span { text-align: left; }
.lock-card form { margin-top: 1rem; text-align: left; }

.settings-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.settings-head-text { min-width: 0; }
.settings-title { font-size: 1.15rem; font-weight: 800; margin-bottom: 0.2rem; }
.settings-head .page-lede { margin-bottom: 0; }
.settings-head .btn { flex-shrink: 0; }

.config-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-bottom: 1rem; }
.cfg-item {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.7rem 0.85rem; box-shadow: var(--shadow-sm);
}
.cfg-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.cfg-dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.cfg-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.cfg-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.cfg-label { font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.cfg-value { font-size: 0.82rem; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 0.3rem; }
.conn-result { font-size: 0.78rem; font-weight: 700; }
.conn-result.testing { color: var(--muted); }
.conn-result.ok { color: var(--success); }
.conn-result.err { color: var(--danger); }

.input-wrap { position: relative; display: block; }
.input-wrap input { padding-right: 2.6rem; }
.pw-toggle {
  position: absolute; top: 50%; right: 0.5rem; transform: translateY(-50%);
  background: transparent; border: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; padding: 0;
}
.pw-toggle:hover { color: var(--plum); background: var(--violet-100); }
.pw-toggle.on { color: var(--plum); }

.footer { text-align: center; font-size: 0.72rem; color: var(--muted); padding: 1.1rem 1rem 1.4rem; }

/* ==========================================================================
   Responsive breakpoints
   ========================================================================== */

@media (min-width: 720px) {
  .fanout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .only-mobile { display: none; }
  .nav-rail { transform: none; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
  .backdrop { display: none; }
  .content { padding: 1.6rem 2rem 2.4rem; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
  .config-summary { grid-template-columns: repeat(4, 1fr); }
  .config-summary-3 { grid-template-columns: repeat(3, 1fr); }
  .fanout-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
  .content { max-width: 1200px; }
}

@media (max-width: 719px) {
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row .fr-name { grid-column: 1 / 2; }
  .field-row .fr-type { grid-column: 2 / 3; }
  .field-row .fr-desc { grid-column: 1 / 3; }
  .field-row .fr-del { grid-column: 1 / 3; height: 30px; }
}

@media (max-width: 480px) {
  .chip-model { display: none; }
  .page-title { font-size: 0.98rem; }
  .stat-grid, .stat-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 1rem 0.85rem 1.6rem; }
}
