/* Module 08 — RAG. Only what styles.css does not already provide:
   the pipeline strip, scored chunk cards, and the assembled-prompt block.
   Tokens come from styles.css :root — nothing is hard-coded here except the
   two tints that need to sit between the existing soft colours. */

/* ------------------------------------------------------------ pipeline */

.stage-strip {
  display: flex;
  align-items: stretch;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
  margin-bottom: 14px;
}
.stage-strip::-webkit-scrollbar { display: none; }

.stage {
  flex: 1 0 128px;
  min-width: 128px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: 10px 12px;
  display: grid;
  gap: 2px;
  align-content: start;
  color: var(--ink-faint);
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.stage.done {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-dark);
}
.stage-n {
  font-family: var(--mono);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .06em;
}
.stage-name { font-weight: 700; font-size: .95rem; color: var(--ink); }
.stage.done .stage-name { color: var(--accent-dark); }
.stage-fact { font-size: .8rem; line-height: 1.35; }
.stage-arrow {
  display: flex;
  align-items: center;
  color: var(--line-strong);
  font-size: 1.05rem;
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  .stage { transition: none; }
}

/* --------------------------------------------------------- chunk cards */

.chunk-list { display: grid; gap: 10px; }

.chunk {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: 11px 13px;
  opacity: .72;
}
.chunk.kept {
  background: var(--surface);
  border-left-color: var(--accent);
  opacity: 1;
}
.chunk.cited { border-left-color: var(--ok); background: var(--ok-soft); }
.chunk.archived.kept { border-left-color: var(--warn); }

.chunk-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 9px;
}
.chunk-rank {
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 700;
  color: var(--ink-faint);
  min-width: 2.2em;
}
.chunk-id {
  font-family: var(--mono);
  font-weight: 700;
  font-size: .9rem;
  color: var(--accent-dark);
}
.chunk-title { flex: 1 1 130px; font-size: .93rem; color: var(--ink); font-weight: 600; }
.chunk-score {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  margin-left: auto;
}

.chunk-bar {
  height: 7px;
  border-radius: 999px;
  background: #e3e9f2;
  overflow: hidden;
  margin: 8px 0 9px;
}
.chunk-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--line-strong);
  transition: width .25s ease;
}
.chunk.kept .chunk-fill { background: var(--accent); }
.chunk.cited .chunk-fill { background: var(--ok); }
@media (prefers-reduced-motion: reduce) {
  .chunk-fill { transition: none; }
}

.chunk-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-faint);
  white-space: nowrap;
}
.tag-kept { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent-line); }
.tag-cite { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cc; }
.tag-warn { background: var(--warn-soft); color: var(--warn); border-color: #f0d9b5; }
.tag-zero { background: var(--danger-soft); color: var(--danger); border-color: #f0c2c2; }

.chunk-terms {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
}
.chunk-why {
  font-size: .8rem;
  font-weight: 700;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.term-pill {
  font-family: var(--mono);
  font-size: .8rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid var(--accent-line);
}
.term-miss {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f0c2c2;
  text-decoration: line-through;
}
.term-cite { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cc; }

.chunk-text {
  margin: 10px 0 0;
  font-size: .92rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.cut-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--danger);
  margin: 2px 0;
}
.cut-line::before, .cut-line::after {
  content: "";
  flex: 1;
  height: 0;
  border-top: 2px dashed #f0c2c2;
}

/* ------------------------------------------------------- assembled prompt */

.prompt-box {
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px;
  margin: 0;
  max-height: 420px;
  overflow-y: auto;
  color: var(--ink);
}

.query-echo {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-alt);
  border-left: 4px solid var(--accent-line);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 9px 13px;
  margin: 12px 0;
}

/* ------------------------------------------------------- failure demos */

.demo {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
  padding: 16px;
  margin-bottom: 18px;
}
.demo > h3 { margin-bottom: 6px; }
.demo .actions { margin-bottom: 12px; }
.demo .chunk { background: var(--surface); }

.response.bad .response-head { background: var(--danger-soft); color: #8f1616; }
.response.bad .response-head .t { color: #8f1616; }

.verdict-line { font-weight: 700; margin: 4px 0 0; }
.verdict-line.ok { color: var(--ok); }
.verdict-line.no { color: var(--warn); }
.verdict-line:empty { display: none; }

/* phones: keep every tap target honest */
#panel-ask .chip, #panel-fails .chip { min-height: 44px; }

@media (max-width: 460px) {
  .stage { flex: 1 0 120px; min-width: 120px; }
  .chunk-score { font-size: .95rem; }
  .prompt-box { font-size: .78rem; max-height: 340px; }
}
