/* ============================================================ */
/* Lab 14 — per-lab styles (microRAG walkthrough)                */
/* Same shape as lab-09 (microMCP) — the patterns are stable.    */
/* ============================================================ */

.course-frame {
  font-family: var(--serif); font-size: 17px; line-height: 1.65;
  color: var(--ink-soft); margin: 10px 0 24px 0;
  padding: 6px 0 6px 16px; border-left: 3px solid var(--accent-soft);
}
.course-frame strong { color: var(--ink); }
body.presentation-mode .course-frame {
  font-size: 22px; padding-left: 22px; margin: 14px 0 32px 0;
}

.time-tag {
  display: inline-block; margin-left: 10px; padding: 2px 8px;
  font-family: var(--sans); font-size: 11px; font-weight: 500;
  text-transform: none; letter-spacing: 0; color: var(--ink-mute);
  background: var(--bg-elev); border: 1px solid var(--rule);
  border-radius: 10px; vertical-align: 2px;
}

pre.term-snippet {
  background: #14110d; color: #e8e1d5;
  font-family: var(--mono); font-size: 13px; line-height: 1.55;
  padding: 14px 18px; border-radius: 6px;
  overflow-x: auto; margin: 14px 0;
}
pre.term-snippet .term-comment    { color: #6fab5c; }
pre.term-snippet .term-cmd        { color: #f6efe1; }
pre.term-snippet .term-prompt-echo{ color: #b2d3e8; }

/* Comparison table */
.msp {
  background: #faf8f2;
  border: 1px solid #e6e2d6;
  border-radius: 6px;
  padding: 12px 14px;
  margin: 18px 0;
}
.msp-rows { display: flex; flex-direction: column; }
.msp-row {
  display: grid; grid-template-columns: 1.2fr 1.4fr 1.4fr 1.4fr;
  gap: 14px; padding: 6px 0;
  border-bottom: 1px dashed #d8d2c0;
  font-size: 13px;
}
.msp-row:last-child { border-bottom: none; }
.msp-row.msp-head {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-mute);
}
.msp-row span code {
  background: var(--bg-elev); padding: 1px 5px;
  border-radius: 3px; font-size: 0.92em;
}
.msp-foot {
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-family: var(--serif); font-size: 13px;
  color: var(--ink-soft); font-style: italic;
}
@media (max-width: 760px) {
  .msp-row { grid-template-columns: 1fr; gap: 4px; }
  .msp-row.msp-head { display: none; }
}

/* Exercise blocks */
.exercise {
  background: var(--bg-elev);
  border-left: 3px solid var(--accent-soft);
  padding: 10px 14px;
  border-radius: 0 5px 5px 0;
  margin: 18px 0;
}
.exercise-q {
  display: block;
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); margin-bottom: 5px;
}
.exercise details { margin-top: 8px; }
.exercise summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); }
.exercise details[open] summary { margin-bottom: 6px; }

/* inline download chip */
.inline-dl {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  font-family: var(--mono); font-size: 0.82rem;
  background: var(--accent); color: white;
  border-radius: 4px;
  text-decoration: none; font-weight: 700;
  vertical-align: 1px;
  transition: filter 150ms;
}
.inline-dl:hover { filter: brightness(1.08); color: white; }

/* table styling for the comparison tables */
main table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
}
main table thead { border-bottom: 2px solid var(--rule); }
main table th {
  text-align: left;
  font-family: var(--sans);
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-mute);
  padding: 8px 10px;
}
main table td {
  padding: 8px 10px;
  border-bottom: 1px dashed #d8d2c0;
  vertical-align: top;
}
main table tr:last-child td { border-bottom: none; }

/* ============================================================ */
/* Interactive widgets                                           */
/* ============================================================ */

/* Shared mini-button */
.btn-mini {
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  background: var(--bg-elev); border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 5px 10px; border-radius: 4px;
  cursor: pointer; transition: all 120ms;
}
.btn-mini:hover { background: white; border-color: var(--accent-soft); }
.btn-mini.active { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.btn-mini.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-mini.btn-primary:hover { filter: brightness(1.08); }

/* ============================================================ */
/* Widget 1 · interactive RAG pipeline                           */
/* ============================================================ */
#viz-pipeline { padding: 16px 18px; }

.pipe-flow {
  display: flex; align-items: stretch; gap: 6px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.pipe-stage {
  flex: 1; min-width: 110px;
  background: #fff8e8;
  border: 1px solid #e7d9a8;
  border-radius: 8px;
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 150ms;
}
.pipe-stage:hover { background: #fff0c8; border-color: #d8c478; }
.pipe-stage.active {
  background: var(--accent); color: white; border-color: var(--accent);
  box-shadow: 0 4px 10px rgba(177, 74, 46, 0.25);
}
.pipe-stage-num {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; opacity: 0.7;
  margin-bottom: 4px;
}
.pipe-stage-label {
  font-family: var(--serif); font-size: 17px; font-weight: 700;
  margin-bottom: 4px;
}
.pipe-stage-sub {
  font-family: var(--mono); font-size: 11px;
  opacity: 0.75;
}
.pipe-arrow {
  align-self: center;
  font-size: 22px; font-weight: 700;
  color: var(--ink-mute);
  margin: 0 -2px;
}
@media (max-width: 760px) {
  .pipe-flow { flex-direction: column; }
  .pipe-arrow { transform: rotate(90deg); margin: 0; }
}

.pipe-detail {
  background: white;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px 16px;
}
.pipe-detail-row {
  display: grid; grid-template-columns: 1fr 1.3fr;
  gap: 18px;
  margin-bottom: 14px;
}
@media (max-width: 760px) {
  .pipe-detail-row { grid-template-columns: 1fr; }
}
.pipe-detail-block { min-width: 0; }
.pipe-detail-head {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-mute); margin-bottom: 6px;
}
.pipe-detail-block p {
  font-family: var(--serif); font-size: 14px; line-height: 1.5;
  color: var(--ink-soft); margin: 0;
}
.pipe-detail-block pre {
  background: #14110d; color: #e8e1d5;
  font-family: var(--mono); font-size: 12px;
  padding: 10px 12px; border-radius: 5px;
  margin: 0; overflow-x: auto; line-height: 1.45;
}
.pipe-detail-snap {
  margin-top: 6px; padding-top: 10px;
  border-top: 1px dashed var(--rule);
}
.pipe-snap {
  background: #f7f3e6; color: #3d3a30;
  font-family: var(--mono); font-size: 12px;
  padding: 10px 12px; border-radius: 5px;
  margin: 0; overflow-x: auto; line-height: 1.5;
  white-space: pre;
}
.pipe-controls {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--rule);
}
.pipe-hint {
  margin-left: auto;
  font-family: var(--serif); font-size: 13px; font-style: italic;
  color: var(--ink-mute);
}

/* ============================================================ */
/* Widget 2 · chunking visualizer                                */
/* ============================================================ */
#viz-chunking { padding: 14px 16px; }

.ck-controls {
  display: grid; grid-template-columns: 1fr 1fr 1.2fr;
  gap: 16px;
  margin-bottom: 14px;
}
@media (max-width: 760px) { .ck-controls { grid-template-columns: 1fr; } }
.ck-controls label {
  display: flex; flex-direction: column;
  font-family: var(--sans); font-size: 12px;
  color: var(--ink-mute);
}
.ck-controls label strong { color: var(--ink); font-family: var(--mono); }
.ck-controls input[type=range] { width: 100%; margin-top: 4px; }
.ck-stats {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
}
.ck-stats span {
  background: var(--bg-elev); padding: 4px 10px;
  border-radius: 12px; border: 1px solid var(--rule);
}
.ck-text {
  background: white; border: 1px solid var(--rule);
  border-radius: 5px; padding: 12px 14px;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto;
  margin: 0;
}
.ck-text .ch-0 { background: #fde0d2; }
.ck-text .ch-1 { background: #d5e6dc; }
.ck-text .ch-2 { background: #e4d9ee; }
.ck-text .ch-3 { background: #d6e1f0; }
.ck-text .ch-overlap { background: #f0eee5; outline: 1px dashed #b14a2e; }
.ck-legend {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-top: 10px;
  font-family: var(--sans); font-size: 11px; color: var(--ink-mute);
}
.ck-swatch {
  display: inline-block; width: 14px; height: 14px;
  border-radius: 3px; vertical-align: -3px; margin-right: 4px;
  border: 1px solid rgba(0,0,0,0.05);
}
.ck-legend .ch-0 { background: #fde0d2; }
.ck-legend .ch-1 { background: #d5e6dc; }
.ck-legend .ch-2 { background: #e4d9ee; }
.ck-legend .ch-3 { background: #d6e1f0; }
.ck-legend .ch-overlap { background: #f0eee5; outline: 1px dashed #b14a2e; }

/* ============================================================ */
/* Widget 3 · TF-IDF inspector                                   */
/* ============================================================ */
#viz-tfidf { padding: 14px 16px; }
.tfidf-hint {
  font-family: var(--serif); font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 10px;
}
.tfidf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.tfidf-cell {
  display: flex; align-items: center; gap: 8px;
  background: white; border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 5px 9px;
  font-family: var(--mono); font-size: 12px;
  cursor: pointer;
  transition: all 120ms;
}
.tfidf-cell:hover { border-color: var(--accent-soft); background: #fff8e8; }
.tfidf-cell.active {
  background: var(--accent); color: white; border-color: var(--accent);
}
.tfidf-cell .tfidf-term { font-weight: 700; flex: 1; }
.tfidf-cell .tfidf-num { font-size: 10px; opacity: 0.7; }
.tfidf-cell .tfidf-df { color: var(--ink-mute); }
.tfidf-cell.active .tfidf-num { color: rgba(255,255,255,0.85); opacity: 1; }
.tfidf-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.tfidf-chip {
  font-family: var(--mono); font-size: 11px;
  padding: 4px 9px;
  background: var(--bg-elev); color: var(--ink-mute);
  border: 1px solid var(--rule); border-radius: 12px;
  transition: all 120ms;
}
.tfidf-chip.hit {
  background: #fde0d2; color: var(--ink); border-color: var(--accent);
  font-weight: 700;
}

/* ============================================================ */
/* Widget 4 · hybrid retrieval scorer                            */
/* ============================================================ */
#viz-hybrid { padding: 14px 16px; }
.hyb-controls { margin-bottom: 14px; }
.hyb-query {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.hyb-query label {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-mute);
}
.hyb-query input {
  flex: 1; font-family: var(--mono); font-size: 13px;
  padding: 7px 10px; border: 1px solid var(--rule);
  border-radius: 4px; background: white;
}
.hyb-query input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.hyb-presets {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 12px;
}
.hyb-knobs {
  display: grid; grid-template-columns: 2fr 1fr; gap: 18px;
  font-family: var(--sans); font-size: 12px; color: var(--ink-mute);
}
@media (max-width: 760px) { .hyb-knobs { grid-template-columns: 1fr; } }
.hyb-knobs label {
  display: flex; flex-direction: column;
}
.hyb-knobs label strong { color: var(--ink); font-family: var(--mono); }
.hyb-knobs input[type=range] { width: 100%; margin-top: 4px; }
.hyb-knob-end {
  font-family: var(--mono); font-size: 10px;
  display: inline-block; margin: 0 4px;
}
.hyb-legend {
  display: flex; align-items: center; gap: 14px;
  margin: 14px 0 8px;
  font-family: var(--sans); font-size: 11px; color: var(--ink-mute);
}
.hyb-legend .hyb-bar-kw { background: #ee9774; height: 14px; width: 14px; display: inline-block; border-radius: 3px; margin-right: 4px; vertical-align: -3px; }
.hyb-legend .hyb-bar-em { background: #7eb893; height: 14px; width: 14px; display: inline-block; border-radius: 3px; margin-right: 4px; vertical-align: -3px; }
.hyb-rows { display: flex; flex-direction: column; gap: 4px; }
.hyb-row {
  display: grid;
  grid-template-columns: 160px 1.6fr 110px 2fr;
  gap: 10px; align-items: center;
  padding: 6px 10px;
  background: white; border: 1px solid var(--rule);
  border-radius: 5px;
  font-size: 12px;
}
.hyb-row.top {
  background: #fff8e8; border-color: var(--accent-soft);
}
.hyb-id { font-family: var(--mono); font-size: 12px; }
.hyb-id span { color: var(--ink-mute); }
.hyb-bar {
  position: relative; height: 22px;
  background: var(--bg-elev); border-radius: 3px;
  overflow: hidden; display: flex;
}
.hyb-bar-kw { background: #ee9774; height: 100%; }
.hyb-bar-em { background: #7eb893; height: 100%; }
.hyb-bar-label {
  position: absolute; top: 0; left: 8px;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  line-height: 22px; color: var(--ink);
  text-shadow: 0 0 4px rgba(255,255,255,0.8);
}
.hyb-scores { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); }
.hyb-scores strong { color: var(--ink); }
.hyb-body {
  font-family: var(--serif); font-size: 12px; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 900px) {
  .hyb-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ============================================================ */
/* Production-stack callout                                       */
/* ============================================================ */
.prod-stack {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px; margin: 18px 0;
}
.prod-card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent-soft);
  border-radius: 5px;
  padding: 10px 14px;
}
.prod-card-head {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); margin-bottom: 6px;
}
.prod-card p {
  margin: 0; font-family: var(--serif);
  font-size: 13px; line-height: 1.5;
  color: var(--ink-soft);
}
.prod-card code { font-size: 0.9em; background: white; padding: 1px 4px; border-radius: 2px; }


/* ============================================================ */
/*  Widget · vector database (2-D k-NN)                          */
/* ============================================================ */
.vdb-wrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; margin-top: 6px; }
.vdb-canvas { flex: 1 1 340px; max-width: 470px; }
.vdb-svg { display: block; width: 100%; height: auto; aspect-ratio: 44 / 30; background: var(--bg-elev); border: 1px solid var(--rule); border-radius: 6px; cursor: crosshair; touch-action: none; font-family: var(--sans); }
.vdb-panel { flex: 1 1 250px; min-width: 230px; }
.vdb-k { display: flex; align-items: center; gap: 10px; font-family: var(--sans); font-size: 13px; margin-bottom: 10px; }
.vdb-k input { flex: 1; }
.vdb-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 12px; font-family: var(--sans); font-size: 11px; color: var(--ink-mute); }
.vdb-legend span { display: inline-flex; align-items: center; gap: 5px; }
.vdb-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.vdb-results { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.vdb-res-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; background: var(--bg-elev); font-family: var(--sans); font-size: 12.5px; }
.vdb-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.vdb-res-rank { font-family: var(--mono); color: var(--ink-mute); }
.vdb-res-dist { margin-left: auto; font-family: var(--mono); color: var(--ink-mute); font-size: 11.5px; }
.vdb-record { font-family: var(--mono); font-size: 11.5px; line-height: 1.5; background: #14110d; color: #e8e1d5; border-radius: 6px; padding: 10px 12px; overflow-x: auto; white-space: pre; }
.vdb-record .vdb-key { color: #b2d3e8; }
.vdb-record .vdb-str { color: #a8cf95; }
.vdb-record .vdb-num { color: #f0c987; }
.vdb-record .vdb-dim { color: #7d766a; }

/* ============================================================ */
/*  Widget · production RAG pipeline (hover a stage)             */
/* ============================================================ */
.pp-wrap { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; margin-top: 6px; }
.pp-canvas { flex: 1 1 300px; max-width: 480px; }
.pp-svg { display: block; width: 100%; height: auto; font-family: var(--sans); }
.pp-stage { cursor: pointer; }
.pp-stage rect { transition: fill-opacity .12s, stroke-width .12s; }
.pp-stage:hover rect, .pp-stage:focus rect { fill-opacity: 0.26; stroke-width: 2.4; outline: none; }
.pp-side { flex: 1 1 240px; min-width: 220px; }
.pp-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-family: var(--sans); font-size: 11px; color: var(--ink-mute); margin-bottom: 12px; }
.pp-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.pp-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.pp-legend .pp-note { flex-basis: 100%; font-style: italic; }
.pp-panel { font-family: var(--sans); font-size: 13.5px; line-height: 1.5; background: var(--bg-elev); border-left: 3px solid var(--accent-soft); border-radius: 0 6px 6px 0; padding: 12px 14px; min-height: 8em; }
.pp-panel .pp-hint { margin: 0; color: var(--ink-mute); }
.pp-panel-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.pp-map { font-size: 13px; margin-bottom: 6px; }
.pp-sub { font-family: var(--mono); font-size: 11.5px; color: var(--ink-mute); margin-bottom: 6px; }
.pp-row { margin-top: 4px; }
.pp-row .pp-k { font-weight: 700; color: var(--ink-soft); }

/* ============================================================ */
/*  Widget · NLI answer-grounding check                         */
/* ============================================================ */
.nli-wrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; margin-top: 6px; }
.nli-left, .nli-right { flex: 1 1 300px; min-width: 260px; }
.nli-head { font-family: var(--sans); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-mute); margin-bottom: 8px; }
.nli-ctx { font-size: 13px; line-height: 1.5; background: var(--bg-elev); border: 1px solid var(--rule); border-left: 3px solid var(--rule); border-radius: 4px; padding: 8px 10px; margin-bottom: 8px; transition: border-color .12s, background .12s; }
.nli-ctx.active { border-left-color: var(--accent); background: #fdf3ee; }
.nli-cid { display: block; font-family: var(--mono); font-size: 10.5px; color: var(--ink-mute); margin-bottom: 3px; }
.nli-btns { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.nli-btn { text-align: left; font-family: var(--serif); font-size: 13.5px; line-height: 1.4; padding: 8px 10px; background: #fff; border: 1px solid var(--rule); border-radius: 5px; cursor: pointer; transition: all .12s; }
.nli-btn:hover { border-color: var(--accent-soft); background: var(--bg-elev); }
.nli-btn.active { border-color: var(--accent); background: #fdf3ee; }
.nli-card { font-family: var(--sans); font-size: 13px; line-height: 1.5; background: var(--bg-elev); border-left: 3px solid var(--accent-soft); border-radius: 0 6px 6px 0; padding: 12px 14px; min-height: 6em; }
.nli-card .nli-hint { margin: 0; color: var(--ink-mute); }
.nli-line { margin-bottom: 5px; }
.nli-k { color: var(--ink-mute); }
.nli-none { color: #c0392b; font-style: italic; }
.nli-verdict { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.nli-badge { color: #fff; font-family: var(--sans); font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 8px; border-radius: 4px; }
.nli-ground { font-weight: 700; }
.nli-ground.ok { color: #3f8a5f; }
.nli-ground.bad { color: #c0392b; }
.nli-reason { font-size: 12.5px; line-height: 1.5; color: var(--ink-soft); }
