/* RAG AI Agent, built on the Simple Loop AI Agent's stylesheet. Opened full screen or in an iframe, which cannot
   see the site's own light/dim switch, so it follows the reader's system
   preference, as the Kubernetes viewers do (their controls and cards are
   copied here, so the two series look alike). */

:root {
  --bg: #ffffff;
  --card: #ffffff;
  --border: #dfe3e8;
  --text: #22272e;
  --dim: #5f6b78;
  --accent: #326ce5;
  --btn: #f4f5f7;
  --panel: #0d2436;
  --panel-text: #eaf1f6;
  --raw: #f7f8fa;
  --flash: rgba(255, 196, 0, 0.3);
  --r-user: #326ce5;
  --r-assistant: #7a4fd0;
  --r-tool: #c96a12;
  --r-sys: #5f6b78;
  --k-function: #2f7d9a;
  --k-rag: #0f8a6a;
  --f-trips: #1a8a5a;
  --f-gear: #c2417e;
  --f-health: #b07d00;
  --f-home: #6d5bd0;
  --q: #e8590c;
  --code-bg: #f6f8fa;
  --js: #0a6b3d;
  --jk: #1b4f9c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1d2b;
    --card: #112b40;
    --border: #234862;
    --text: #eaf1f6;
    --dim: #9fb2c2;
    --accent: #6f9bff;
    --btn: #16374f;
    --panel: #081b29;
    --raw: #0d2233;
    --flash: rgba(255, 196, 0, 0.18);
    --r-user: #7ea6ff;
    --r-assistant: #b79bff;
    --r-tool: #f0a050;
    --r-sys: #9fb2c2;
    --k-function: #6cc4e0;
    --k-rag: #4fd1a8;
    --f-trips: #5fd08f;
    --f-gear: #f08cbc;
    --f-health: #e8c04a;
    --f-home: #a99bff;
    --q: #ff8a4c;
    --code-bg: #0d2233;
    --js: #8fe3a8;
    --jk: #9cc2ff;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.dim { color: var(--dim); font-weight: 400; }
.kv-app { padding: 0.5rem 16px 1rem; max-width: 1700px; margin: 0 auto; }
.kv-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.9rem; margin: 0 0 0.45rem; }
.kv-head h1 { font-size: 1.3rem; margin: 0; letter-spacing: -0.01em; }
.kv-head p { margin: 0; color: var(--dim); font-size: 0.92rem; }
.in-viewer .kv-head { display: none; }

/* --- controls */
.kv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 0.6rem; }
.kv-bar .count { font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; color: var(--dim); }
.kv-btn { background: var(--btn); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.35rem 0.9rem; font-size: 0.88rem; cursor: pointer; font-family: inherit; }
.kv-btn:hover:not(:disabled) { border-color: var(--accent); }
.kv-btn:disabled { opacity: 0.45; cursor: default; }
.kv-btn.play { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; min-width: 6rem; }
.kv-btn.go { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.kv-btn.tiny { padding: 0.05rem 0.45rem; font-size: 0.74rem; border-radius: 5px; }
.kv-app select { background: var(--btn); color: var(--text); border: 1px solid var(--border); border-radius: 7px;
  padding: 0.3rem 0.4rem; font-size: 0.86rem; font-family: inherit; min-width: 0; max-width: 100%; }
.api-pick { margin-left: auto; display: inline-flex; align-items: center; gap: 0; font-size: 0.82rem; color: var(--dim); }
.api-pick .seg-btn { border-radius: 0; font-size: 0.8rem; padding: 0.3rem 0.7rem; }
.api-pick .seg-btn:first-of-type { border-radius: 8px 0 0 8px; margin-left: 0.45rem; }
.api-pick .seg-btn:last-of-type { border-radius: 0 8px 8px 0; border-left: none; }
.api-pick .seg-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* --- the stage: the user on the left, the agent in the middle, the model
   and the events on the right. Every card has a fixed size and scrolls. */
.al-stage { position: relative; display: grid; gap: 12px;
  grid-template-columns: minmax(0, 290px) minmax(0, 1fr) minmax(0, 390px);
  grid-template-rows: minmax(0, 1.55fr) auto minmax(0, 0.8fr);
  grid-template-areas: "user agent model" "user rag model" "user wire log";
  height: max(800px, calc(100vh - 6.2rem)); }
@media (min-width: 1101px) { .in-viewer .al-stage { height: max(800px, calc(100vh - 4.1rem)); } }
.al-user { grid-area: user; } .al-agent { grid-area: agent; } .al-rag { grid-area: rag; }
.al-wire { grid-area: wire; } .al-model { grid-area: model; } .al-log { grid-area: log; }
@media (max-width: 1100px) {
  .al-stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); height: auto;
    grid-template-rows: 600px auto 440px 440px 440px;
    grid-template-areas: "agent agent" "rag rag" "user model" "wire wire" "log log"; }
}
/* The cards stand one under another and the page follows the step, so the
   controls stay pinned to the top of the screen */
@media (max-width: 1100px) {
  .kv-bar { position: sticky; top: 0; z-index: 40; background: var(--bg); margin: 0 -16px 0.6rem; padding: 0.4rem 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }
}
@media (max-width: 640px) {
  .kv-bar { gap: 0.35rem 0.5rem; }
  .kv-bar .kv-btn { padding: 0.3rem 0.7rem; }
  .kv-bar select { flex: 1 1 10rem; }
  .api-pick .more { display: none; }
  .api-pick .seg-btn:first-of-type { margin-left: 0; }
}
@media (max-width: 640px) {
  .al-stage { grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 440px 420px 440px 440px;
    grid-template-areas: "agent" "rag" "user" "model" "wire" "log"; }
  .api-pick { margin-left: 0; }
  .al-stage .agent-body { grid-template-columns: minmax(0, 1fr); overflow: visible; }
  .al-stage .loop { height: 250px; flex: none; }
  .al-stage .chips { max-height: 260px; }
  .al-stage .side { overflow: visible; }
  .al-stage .tool-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .al-stage .rag-body { grid-template-columns: minmax(0, 1fr); }
}

.kv-card { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); font-size: 0.84rem;
  transition: box-shadow 0.25s, border-color 0.25s; }
.kv-card.here { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.kv-card > header { flex: none; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.45rem 0.7rem 0.4rem; border-bottom: 1px solid var(--border); }
.kv-card > header h2 { font-size: 0.92rem; margin: 0; flex: 1; min-width: 0; }
.kv-card > header h2 code { font-size: 0.72rem; color: var(--dim); font-weight: 400; margin-left: 0.3rem; }
.kv-card > header .turn { font-size: 0.8rem; padding: 0.2rem 0.6rem; animation: al-due 1.4s ease-in-out infinite; }
@keyframes al-due { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); } }
.kv-body { flex: 1; min-height: 0; overflow: auto; padding: 0.5rem 0.7rem; }
h3 { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); margin: 0 0 0.35rem; }

/* --- the user: a chat above the picture */
.chat { display: flex; flex-direction: column; gap: 0.4rem; }
.bubble { max-width: 88%; padding: 0.4rem 0.6rem; border-radius: 12px; line-height: 1.38; white-space: pre-wrap; font-size: 0.8rem; }
.bubble.user { align-self: flex-end; background: var(--r-user); color: #fff; border-bottom-right-radius: 3px; }
.bubble.agent { align-self: flex-start; background: var(--raw); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.you-foot { flex: none; display: flex; justify-content: center; padding: 0.3rem 0 0.4rem; border-top: 1px solid var(--border); }
.art.you { position: relative; display: block; height: min(230px, 28vh); }
.art.you img { display: block; height: 100%; width: auto; }
.you-screen { text-align: left; position: absolute; left: 45%; top: 13.5%; width: 32%; height: 17%; color: #8fe3a8; line-height: 1.3;
  font: 700 clamp(6px, 0.95vh, 9px) ui-monospace, Menlo, Consolas, monospace; overflow: hidden; overflow-wrap: anywhere; }

/* --- the agent: the loop and messages[] side by side, the tools under them */
.agent-body { display: grid; grid-template-columns: minmax(230px, 360px) minmax(0, 1fr); gap: 0.8rem; overflow: hidden; }
.graph, .history, .side { min-height: 0; display: flex; flex-direction: column; }
.side { gap: 0.55rem; }
.history { flex: 1; }
/* Our instructions: written by us into the agent, so drawn as part of it */
.sys { flex: none; border: 1px solid var(--border); border-left: 4px solid var(--r-sys); border-radius: 6px; padding: 0.3rem 0.5rem; background: var(--raw); }
.sys h3 { margin-bottom: 0.15rem; }
.sys p { margin: 0; font-size: 0.8rem; line-height: 1.35; }
.loop { width: 100%; height: 100%; min-height: 0; flex: 1; }
.loop .ge { fill: none; stroke: var(--dim); stroke-width: 1.6; opacity: 0.7; }
.loop marker path { fill: var(--dim); }
.loop .ge.taken { stroke: var(--accent); stroke-width: 3; opacity: 1; stroke-dasharray: 6 5; animation: al-flow 0.8s linear infinite; }
.loop .ge.next { stroke: var(--accent); opacity: 1; }
@keyframes al-flow { to { stroke-dashoffset: -11; } }
.loop .gl { font: 600 13px ui-monospace, Menlo, monospace; fill: var(--dim); }
.loop .gn rect, .loop .gn path, .loop .gn circle { fill: var(--raw); stroke: var(--border); stroke-width: 1.5; transition: fill 0.3s; }
.loop .gn text { font: 600 17px -apple-system, 'Segoe UI', Roboto, sans-serif; fill: var(--text); text-anchor: middle; }
.loop .gn text.side { font-size: 14px; }
.loop .gn text.side.mid { text-anchor: middle; }
.loop .gn text.side { text-anchor: start; font-weight: 400; fill: var(--dim); }
.loop .gn.at rect, .loop .gn.at path, .loop .gn.at circle { fill: var(--accent); stroke: var(--accent); }
.loop .gn.at text:not(.side) { fill: #fff; }
.loop .gn.term circle { fill: var(--dim); stroke: none; }
.loop .gn.term.at circle { fill: var(--accent); }

.chips { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 0; position: relative;
  display: flex; flex-direction: column; gap: 0.25rem; }
.chip { display: grid; grid-template-columns: 5.6rem minmax(0, 1fr); gap: 0.4rem; align-items: baseline;
  padding: 0.22rem 0.5rem; border-radius: 6px; border-left: 4px solid; background: var(--raw); font-size: 0.78rem; }
.chip b { font: 700 0.72rem ui-monospace, Menlo, monospace; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.unsent { border-style: dashed; border-left-style: solid; outline: 1px dashed var(--border); }
.chip.r-user, .seg.c-user { border-color: var(--r-user); } .chip.r-user b { color: var(--r-user); }
.chip.r-assistant, .seg.c-assistant { border-color: var(--r-assistant); } .chip.r-assistant b { color: var(--r-assistant); }
.chip.r-tool, .seg.c-tool { border-color: var(--r-tool); } .chip.r-tool b { color: var(--r-tool); }
.chip.r-developer, .seg.c-developer, .seg.c-sys { border-color: var(--r-sys); } .chip.r-developer b { color: var(--r-sys); }
/* A tool result the Messages API carries in a user message is still a result */
.chips .empty { color: var(--dim); font-style: italic; }

.tools { flex: none; padding: 0.45rem 0.7rem 0.6rem; border-top: 1px solid var(--border); }
.tool-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.45rem; }
.tool { border: 1px solid var(--border); border-top: 4px solid; border-radius: 7px; padding: 0.3rem 0.5rem; background: var(--raw); min-width: 0; }
.tool i { display: block; font-style: normal; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.tool b { display: block; font: 700 0.9rem ui-monospace, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; }
.tool span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.78rem; color: var(--dim); line-height: 1.3; }
.k-function { border-top-color: var(--k-function); } .k-function i { color: var(--k-function); }

/* --- the model, and its context window drawn to one scale */
.model-body { display: flex; flex-direction: column; gap: 0.5rem; overflow: hidden; }
.status { margin: 0; padding: 0.35rem 0.55rem; border-radius: 7px; background: var(--raw); font-size: 0.8rem; font-weight: 600; }
.status.s-reading, .status.s-answered { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.ctx { flex: 1; min-height: 0; display: flex; flex-direction: column; transition: opacity 0.4s; }
.stack { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 2px;
  border: 2px solid var(--border); border-radius: 8px; padding: 3px; background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--border) 45%, transparent) 6px 7px); }
.seg { flex: none; height: calc(var(--h) * 1%); min-height: 19px; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.35rem;
  align-items: start; padding: 0 0.4rem; border-left: 4px solid; border-radius: 4px; background: var(--card); font-size: 0.8rem; line-height: 17px; }
.seg b { font: 700 0.76rem ui-monospace, Menlo, monospace; }
.seg span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg em { font-style: normal; color: var(--dim); font-family: ui-monospace, Menlo, monospace; }
.seg.c-tools { border-color: var(--k-function); background: color-mix(in srgb, var(--k-function) 10%, var(--card)); }
/* The reply being written: a tinted row, readable at any height */
.seg.c-out { min-height: 26px; align-items: center; border-color: var(--r-assistant); font-weight: 700;
  background: color-mix(in srgb, var(--r-assistant) 18%, var(--card)); }

/* --- the wire: JSON line by line */
.wire-body { padding: 0.4rem 0.6rem; position: relative; }
.wire-body h4 { margin: 0.5rem 0 0.2rem; font-size: 0.72rem; color: var(--dim); }
.wire-body h4:first-child { margin-top: 0; }
.wire-body h4.new-h { color: var(--text); }
pre.json, pre.text { margin: 0; font: 0.74rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--code-bg);
  border-radius: 7px; padding: 0.35rem 0.5rem; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.json .ln { display: block; }
pre.json .ln.old { opacity: 0.45; }
pre.json .ln.new { background: color-mix(in srgb, var(--flash) 55%, transparent); }
pre.json .ln.fold { white-space: pre; overflow: hidden; text-overflow: ellipsis; }
pre.json .ln.stop, pre.json .ln.callkey { font-weight: 700; outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 3px; }
pre.json .ln.role { font-weight: 700; }
pre.json .ln.r-user .js { color: var(--r-user); } pre.json .ln.r-assistant .js { color: var(--r-assistant); }
pre.json .ln.r-tool .js { color: var(--r-tool); } pre.json .ln.r-developer .js { color: var(--r-sys); }
pre.json .jk { color: var(--jk); } pre.json .js { color: var(--js); }

/* --- the events */
.log { list-style: none; margin: 0; padding: 0; }
.log-intro { font-size: 0.84rem; line-height: 1.45; }
.log-intro p { margin: 0 0 0.4rem; }
.log-intro .main { font-weight: 600; }
.log li { border-bottom: 1px dashed var(--border); }
.log-head { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto; gap: 0.4rem; align-items: baseline; padding: 0.15rem 0.3rem; cursor: pointer; }
.log-head::after { content: '▸'; color: var(--dim); font-size: 0.7rem; }
.log li.open .log-head::after { content: '▾'; }
.log-head:focus-visible { outline: 2px solid var(--accent); }
.log li:hover .log-head { background: color-mix(in srgb, var(--flash) 40%, transparent); }
.log li.now .log-head { background: color-mix(in srgb, var(--flash) 75%, transparent); }
.log li.now.open .log-body { background: color-mix(in srgb, var(--flash) 30%, transparent); }
.log-body { padding: 0.2rem 0.5rem 0.5rem 2.1rem; font-size: 0.8rem; line-height: 1.42; }
.log-body p { margin: 0 0 0.3rem; }
.log-body .main { font-weight: 600; font-size: 0.9rem; }
.log .n { color: var(--dim); font-family: ui-monospace, Menlo, monospace; font-size: 0.72rem; }
.log .scene { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); padding: 0.5rem 0.3rem 0.15rem; border-bottom: none; }
.log-body ul.steps, .log-intro ul.steps { margin: 0 0 0.35rem; padding-left: 1.05rem; list-style: disc; }
.log-body ul.steps li, .log-intro ul.steps li { border: 0; margin: 0 0 0.15rem; }
.log-body ul.steps ul.steps, .log-intro ul.steps ul.steps { margin: 0.1rem 0; list-style: circle; }
.log code, .log-intro code { font-size: 0.92em; background: var(--code-bg); padding: 0 0.2em; border-radius: 3px; }

/* --- a tour step's spotlight: what it names pulses, the rest dims */
.al-stage.spotlight .kv-card:not(.here) { opacity: 0.35; transition: opacity 0.4s; }
.al-stage.spotlight .kv-card.al-log, .al-stage.spotlight .kv-card.al-wire { opacity: 1; }
.al-stage.spotlight .act { animation: al-pulse 1.1s ease-in-out 3; outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
.al-stage.spotlight .loop .act { outline: none; }
.al-stage.spotlight .loop .act rect, .al-stage.spotlight .loop .act path, .al-stage.spotlight .loop .act circle { stroke: var(--accent); stroke-width: 3; }
@keyframes al-pulse { 50% { filter: brightness(1.12); } }
.act.rbox, .tool.act { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }

/* --- what is in the air: a message flying along its arrow */
#al-fly { position: absolute; left: 0; top: 0; width: 0; height: 0; overflow: visible; pointer-events: none; z-index: 50; }
#al-fly .trail { position: absolute; left: 0; top: 0; overflow: visible; }
#al-fly .trail polyline { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 3 7; }
#al-fly .trail path { fill: var(--accent); }
#al-fly .msg { position: absolute; transform: translate(-50%, -50%); background: var(--panel); color: var(--panel-text);
  border-radius: 6px; padding: 0.12rem 0.5rem; font-size: 0.74rem; font-weight: 600; white-space: nowrap;
  font-family: ui-monospace, Menlo, Consolas, monospace; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); }
#al-fly .msg.doc { background: #fffdf4; color: #22272e; border: 1px solid #c9b98a; border-radius: 3px 10px 3px 3px; font-size: 0.78rem; }

/* A request in the air: copies of everything the agent sends, in one frame */
#al-fly .copy { position: absolute; margin: 0; transform-origin: top left; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); overflow: hidden; }
#al-fly .copy.ghost-stack { box-shadow: none; background-color: var(--card); transform-origin: center bottom; }
#al-fly .chunk { position: absolute; transform-origin: top left; border: 3px dashed var(--accent); border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 7%, transparent); }
#al-fly .chunk span { position: absolute; left: 10px; top: -0.8rem; background: var(--accent); color: #fff; border-radius: 6px;
  padding: 0.05rem 0.5rem; font: 700 0.76rem ui-monospace, Menlo, monospace; white-space: nowrap; }

.al-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.45); }
.al-modal[hidden] { display: none; }
.al-modal .box { width: min(640px, 100%); max-height: 90vh; display: flex; flex-direction: column; background: var(--card);
  border: 1px solid var(--border); border-top: 4px solid var(--k-rag); border-radius: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35); }
.al-modal header { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--border); }
.al-modal h2 { flex: 1; margin: 0; font: 700 0.95rem ui-monospace, Menlo, monospace; }
.al-modal pre { margin: 0; padding: 0.7rem 0.9rem; overflow: auto; font: 0.84rem/1.5 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap; background: var(--code-bg); }
.al-modal .note { margin: 0; padding: 0.5rem 0.9rem; font-size: 0.8rem; color: var(--dim); }

/* A prompt with passages in the context window: its text, four lines in
   view, the rest a scroll away inside the part */
.seg.c-file { min-height: calc(19px + 4 * 1.25em + 8px); }
.seg-text { grid-column: 1 / -1; margin: 2px 0 4px; max-height: calc(4 * 1.25em + 6px); overflow: auto; padding: 2px 6px;
  font: 0.72rem/1.25 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; background: var(--code-bg); border-radius: 3px; }

/* --- the loop's RAG step, and the prompt the harness holds while it searches */
.loop .gl.rag { fill: var(--k-rag); font-weight: 800; }
.held { flex: none; margin: 0 0 0.3rem; padding: 0.2rem 0.5rem; border: 1px dashed var(--r-user); border-radius: 6px;
  font-size: 0.78rem; color: var(--dim); }
.chip.rag { background: color-mix(in srgb, var(--k-rag) 12%, var(--raw)); }
.seg.c-rag { background: color-mix(in srgb, var(--k-rag) 9%, var(--card)); }

/* --- retrieval: the notes, the embedding model, the index and its map */
.rag-body { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.25fr); gap: 0.6rem; overflow: hidden; }
.rbox { min-width: 0; border: 1px solid var(--border); border-top: 4px solid var(--k-rag); border-radius: 7px; padding: 0.3rem 0.5rem; background: var(--raw); }
.rbox h3 { margin-bottom: 0.25rem; }
.rbox p { margin: 0 0 0.3rem; font-size: 0.78rem; color: var(--dim); }
.rbox .files { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.rbox .file { all: unset; cursor: pointer; font: 600 0.74rem ui-monospace, Menlo, monospace; padding: 0.08rem 0.4rem;
  border: 1px solid; border-radius: 4px; }
.rbox .file:hover, .rbox .file:focus-visible { background: color-mix(in srgb, currentColor 14%, transparent); }
/* A file's colour, on its button and on its passages' dots */
.map .f-trips, .rbox .f-trips { color: var(--f-trips); } .map .f-gear, .rbox .f-gear { color: var(--f-gear); }
.map .f-health, .rbox .f-health { color: var(--f-health); } .map .f-home, .rbox .f-home { color: var(--f-home); }
.vec { font-size: 0.74rem; line-height: 1.35; }
.vec span { display: block; }
.vec code { display: block; background: var(--code-bg); border-radius: 4px; padding: 0.15rem 0.35rem; overflow-wrap: anywhere; font-size: 0.72rem; }
.rbox { display: flex; flex-direction: column; }
.map { display: block; width: 100%; flex: 1; min-height: 112px; padding: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; }
.map-empty { margin: 0; flex: 1; min-height: 112px; display: grid; place-items: center; border: 1px dashed var(--border); border-radius: 6px; font-style: italic; }
.map .pt { fill: currentColor; stroke: var(--card); stroke-width: 1; transform-box: fill-box; transform-origin: center; }
.map .pt.kept { stroke: var(--text); stroke-width: 1.6; }
.map .qpt rect { fill: var(--q); stroke: var(--card); stroke-width: 1; }
.map .qpt { transform-box: fill-box; transform-origin: center; }
.map .hit line { stroke: var(--dim); stroke-width: 1; stroke-dasharray: 2 2; }
.map .hit.kept line { stroke: var(--q); stroke-width: 1.6; stroke-dasharray: none; }
.map .hit text { font: 700 8.5px ui-monospace, Menlo, monospace; fill: var(--dim); text-anchor: middle; dominant-baseline: middle; }
.map .hit.kept text { fill: var(--q); }

/* The index being built: a passage's text on its way into the embedding
   model, in its file's colour, and the vector coming out */
#al-fly .msg.pass { background: var(--card); color: var(--text); border: 2px solid currentColor; font-weight: 500; }
#al-fly .msg.pass.f-trips { border-color: var(--f-trips); } #al-fly .msg.pass.f-gear { border-color: var(--f-gear); }
#al-fly .msg.pass.f-health { border-color: var(--f-health); } #al-fly .msg.pass.f-home { border-color: var(--f-home); }
#al-fly .msg.vecmsg { color: #fff; font-size: 0.68rem; }
#al-fly .msg.vecmsg.f-trips { background: var(--f-trips); } #al-fly .msg.vecmsg.f-gear { background: var(--f-gear); }
#al-fly .msg.vecmsg.f-health { background: var(--f-health); } #al-fly .msg.vecmsg.f-home { background: var(--f-home); }

/* A dot clicked: the passage it stands for */
.map [data-pt] { cursor: pointer; }
.map .pt:hover, .map .pt.sel { stroke: var(--text); stroke-width: 2; }
.al-tip { position: absolute; z-index: 55; width: min(300px, calc(100vw - 16px)); padding: 0.45rem 0.6rem; border-radius: 8px;
  background: var(--card); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); font-size: 0.8rem; line-height: 1.4; }
.al-tip[hidden] { display: none; }
.al-tip b { font: 700 0.76rem ui-monospace, Menlo, monospace; }
.al-tip b.f-trips { color: var(--f-trips); } .al-tip b.f-gear { color: var(--f-gear); }
.al-tip b.f-health { color: var(--f-health); } .al-tip b.f-home { color: var(--f-home); } .al-tip b.q { color: var(--q); }
.al-tip p { margin: 0.15rem 0 0.3rem; }
.al-tip code { display: block; font-size: 0.7rem; color: var(--dim); overflow-wrap: anywhere; }

/* The embedding model's gear */
.rbox .gear { width: 1.25rem; height: 1.25rem; vertical-align: -0.35rem; margin-right: 0.3rem; fill: var(--k-rag); transform-origin: center; }
#al-fly .msg.filemsg { background: #fffdf4; color: #22272e; border: 2px solid; border-radius: 3px 10px 3px 3px; font-size: 0.78rem; }
#al-fly .msg.filemsg.f-trips { border-color: var(--f-trips); } #al-fly .msg.filemsg.f-gear { border-color: var(--f-gear); }
#al-fly .msg.filemsg.f-health { border-color: var(--f-health); } #al-fly .msg.filemsg.f-home { border-color: var(--f-home); }
#al-fly .msg.pass { font-size: 0.7rem; }
.rbox .gear.turning { animation: al-turn 2.4s linear infinite; }
@keyframes al-turn { to { transform: rotate(360deg); } }

/* For the reader, on the picture: a line at the foot of the vector index,
   and a window in the middle of the screen while the index is being built */
.rbox { position: relative; }
.rbox .hint.dots { align-self: flex-start; margin: 0.25rem 0 0; pointer-events: none;
  color: var(--accent); font-weight: 800; font-size: 0.86rem; padding: 0.05rem 0.4rem; border-radius: 4px;
  background: color-mix(in srgb, var(--card) 85%, transparent); animation: al-hint 1.8s ease-in-out infinite; }
@keyframes al-hint { 50% { opacity: 0.55; } }
.al-pop { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 58; width: min(600px, calc(100vw - 32px));
  padding: 2rem 2rem 1.6rem; border-radius: 16px; background: var(--card); border: 3px solid var(--accent);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); text-align: center; }
.al-pop[hidden] { display: none; }
.al-pop .pop-title { margin: 0.2rem 0 1rem; font-size: 1.45rem; font-weight: 700; line-height: 1.35; }
.al-pop ul.steps { text-align: left; margin: 0 0 1.2rem; padding-left: 1.3rem; font-size: 1.05rem; line-height: 1.45; }
.al-pop ul.steps li { margin: 0 0 0.45rem; }
.al-pop code { background: var(--code-bg); padding: 0 0.25em; border-radius: 3px; }
.al-pop .play { font-size: 1.05rem; padding: 0.5rem 1.6rem; }
.al-pop .x { position: absolute; top: 0.4rem; right: 0.4rem; }
/* The prompt's vector, in the query's own colour */
.vec code { border-left: 3px solid var(--q); }
.vec span { color: var(--q); font-weight: 600; }

/* A user message in the context window and in messages[]: the RAG result
   in green, the prompt in orange */
.rg, .pq { font-style: normal; font-weight: 700; }
.rg { color: var(--k-rag); } .pq { color: var(--q); }
.seg.c-split { min-height: calc(19px + 4 * 1.25em + 14px + 38px); background: var(--card); }
.seg .sub { grid-column: 1 / -1; border-left: 3px solid; padding: 0 0 0 6px; margin: 1px 0 3px; min-width: 0; }
.seg .sub i { display: block; font: normal 800 0.66rem ui-monospace, Menlo, monospace; text-transform: uppercase; letter-spacing: 0.04em; }
.seg .s-rag { border-color: var(--k-rag); background: color-mix(in srgb, var(--k-rag) 10%, transparent); }
.seg .s-rag i { color: var(--k-rag); }
.seg .s-rag .seg-text { margin: 1px 0 3px; }
.seg .s-prompt { border-color: var(--q); color: var(--q); font-weight: 700; font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--q) 10%, transparent); }
.seg .s-prompt i { display: inline; }

/* The search in the air: the prompt and its vector in orange, the passages it keeps in green */
#al-fly .msg.qmsg { background: var(--q); color: #fff; }
#al-fly .msg.ragmsg { background: var(--k-rag); color: #fff; }
.map text.none { font: 800 9px ui-monospace, Menlo, monospace; fill: var(--q); }
