/* Java Streams diagrams: stream-pipeline, stream-builder, stream-collectors, parallel-stream ("vs-" prefix). */

.vs-wrap { container-type: inline-size; min-width: 0; }
.vs-wrap [hidden], .vs-builder [hidden] { display: none !important; }
.vs-wrap, .vs-wrap code, .vs-builder, .vs-wrap .field { font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0; }
.vs-still .vs-tok, .vs-still .vs-st, .vs-still .vs-chip, .vs-still .vs-blk { transition: none !important; animation: none !important; }

/* ---------- pipeline track ---------- */
.vs-track { position: relative; width: 100%; min-width: 0; margin: 2px 0 14px; }
.vs-lane { position: absolute; background: var(--rule); border-radius: 2px; z-index: 0; }
.vs-zone { position: absolute; font: 700 12px/1 var(--font-body); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.vs-st {
  position: absolute; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  padding: 4px 8px; text-align: center; border: 2px solid var(--rule); border-radius: 12px; background: var(--surface);
  transition: border-color .25s, background-color .25s, box-shadow .25s;
}
.vs-st::after { content: ''; position: absolute; left: calc(50% - 1px); top: 100%; width: 2px; height: var(--stem, 0px); background: var(--rule); }
.vs-st-name { font: 700 13px/1.25 var(--font-mono); color: var(--ink); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.vs-st-arg { font: 12px/1.3 var(--font-mono); color: var(--muted); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.vs-st-stat { font: 600 12px/1.3 var(--font-body); color: var(--muted); min-height: 16px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.vs-st-source { background: var(--surface-2); }
.vs-st-terminal { border-color: color-mix(in srgb, var(--java) 55%, var(--rule)); }
.vs-st.vs-on { border-color: var(--focus); background: color-mix(in srgb, var(--focus) 12%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.vs-st.vs-on::after { background: var(--focus); }
.vs-st.vs-wait { border-style: dashed; border-color: var(--signal); }
.vs-st.vs-stop { border-color: var(--bad); }
.vs-st.vs-stop .vs-st-stat { color: var(--bad); font-weight: 800; }
.vs-st.vs-missing { border-style: dashed; opacity: .75; }
.vs-vert .vs-st { align-items: flex-start; text-align: left; padding: 4px 10px; }
.vs-vert .vs-st-source { flex-direction: row; align-items: center; justify-content: space-between; }

.vs-tok {
  position: absolute; left: 0; top: 0; z-index: 2; display: grid; place-items: center;
  border: 2px solid var(--rule); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: 700 13px/1 var(--font-mono); will-change: transform;
  transition: transform .45s var(--ease-out), opacity .3s ease, background-color .25s, border-color .25s, box-shadow .25s;
}
.vs-tok span { display: block; max-width: 100%; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-tok.vs-p-at { z-index: 3; box-shadow: 0 2px 8px rgb(0 0 0 / .14); }
.vs-tok.vs-s-hl { border-color: var(--focus); background: color-mix(in srgb, var(--focus) 16%, var(--surface)); }
.vs-tok.vs-s-ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 18%, var(--surface)); }
.vs-tok.vs-s-bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--surface)); }
.vs-tok.vs-s-sig { border-color: var(--signal); background: color-mix(in srgb, var(--signal) 34%, var(--surface)); }
.vs-tok.vs-s-dim { opacity: .55; }
.vs-tok.vs-p-drop { opacity: .62; border-style: dashed; }
.vs-tok.vs-p-drop::after { content: '✕'; position: absolute; top: -7px; right: -7px; width: 15px; height: 15px; border-radius: 50%; display: grid; place-items: center; font: 800 9px/1 var(--font-body); color: var(--surface); background: var(--bad); }
.vs-tok.vs-p-never { opacity: .8; border-style: dashed; border-color: var(--muted); background: transparent; color: var(--muted); }
.vs-slot0 { position: absolute; left: 0; top: 0; z-index: 1; border: 1.5px dashed var(--rule); border-radius: 8px; }
.vs-tok.vs-p-out { border-color: var(--ok); }
.vs-tok.vs-p-out.vs-s-dim { opacity: .5; }
.vs-tok.vs-cur { box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent), 0 2px 8px rgb(0 0 0 / .14); }
.vs-tok.vs-hidden { opacity: 0; pointer-events: none; }
@keyframes vs-morph { 0% { scale: 1; } 40% { scale: 1.22; } 100% { scale: 1; } }
.vs-tok.vs-morph { animation: vs-morph .42s var(--ease-out); }

/* ---------- code / trace panels ---------- */
.vs-panels { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; align-items: stretch; }
@container (max-width: 620px) { .vs-panels { grid-template-columns: minmax(0, 1fr); } }
.vs-codebox, .vs-trace, .vs-box { min-width: 0; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); display: flex; flex-direction: column; overflow: hidden; }
.vs-panel-h { font: 700 12px/1 var(--font-body); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 9px 12px; border-bottom: 1px solid var(--rule); background: var(--surface-2); }
.vs-code { font: 13px/1.6 var(--font-mono); padding: 8px 0; overflow-x: auto; color: var(--ink); }
.vs-line { padding: 0 12px 0 10px; white-space: pre; border-left: 3px solid transparent; transition: background-color .25s, border-color .25s; width: max-content; min-width: 100%; }
.vs-line.vs-on { background: color-mix(in srgb, var(--focus) 16%, transparent); border-left-color: var(--focus); }
.vs-line.vs-err { background: color-mix(in srgb, var(--bad) 14%, transparent); border-left-color: var(--bad); }
.vs-trace-list { list-style: none; margin: 0; padding: 6px 0; height: 200px; overflow-y: auto; font: 12.5px/1.55 var(--font-mono); overscroll-behavior: contain; }
.vs-tl { padding: 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.vs-tl-sep { color: var(--muted); font-weight: 700; margin-top: 4px; }
.vs-tl-sep:first-child { margin-top: 0; }
.vs-tl-ok { color: var(--ok); }
.vs-tl-bad { color: var(--bad); }
.vs-tl-info { color: var(--ink); }
.vs-tl-log { color: var(--ink); font-weight: 700; background: color-mix(in srgb, var(--signal) 22%, transparent); }
.vs-tl-stop { color: var(--bad); font-weight: 800; }
.vs-tl-empty { color: var(--muted); font-family: var(--font-body); }
.vs-tl-last { box-shadow: inset 3px 0 0 var(--focus); background: color-mix(in srgb, var(--focus) 12%, transparent); }
.vs-result { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; border-top: 1px solid var(--rule); font: 700 13px/1.4 var(--font-mono); min-width: 0; }
.vs-result code { overflow-wrap: anywhere; min-width: 0; }
.vs-result-k { font: 700 12px/1 var(--font-body); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; flex: none; }
.vs-faint { color: var(--muted); font-weight: 400; }
.vs-bad { color: var(--bad); }
.vs-ok { color: var(--ok); }

/* ---------- builder ---------- */
.vs-builder { display: grid; gap: 10px; margin: 12px 0 0; min-width: 0; }
.vs-chain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.vs-chain > .vs-blk:not(.vs-blk-src) { margin-left: clamp(12px, 3vw, 28px); max-width: calc(100% - clamp(12px, 3vw, 28px)); }
.vs-blk {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; max-width: 100%;
  padding: 6px 8px; border: 2px solid var(--rule); border-radius: 10px; background: var(--surface);
  transition: border-color .2s, background-color .2s;
}
.vs-blk.pop-in { animation-duration: .3s; }
.vs-blk-name { font: 700 13px/1.2 var(--font-mono); color: var(--ink); }
.vs-blk-type { font: 12px/1.2 var(--font-mono); color: var(--muted); }
.vs-blk .field { min-height: 34px; padding-top: 4px; padding-bottom: 4px; font: 13px var(--font-mono); max-width: 100%; min-width: 0; }
.vs-blk .btn.small { min-width: 32px; min-height: 32px; padding: 0 6px; font-size: 15px; line-height: 1; }
.vs-blk-tools { display: inline-flex; gap: 4px; margin-left: auto; }
.vs-blk-src { background: var(--surface-2); }
.vs-blk-term { border-color: color-mix(in srgb, var(--java) 55%, var(--rule)); }
.vs-arrow { align-self: center; color: var(--muted); font: 700 14px var(--font-mono); }
.vs-palette { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vs-palette-h { font: 700 12px/1 var(--font-body); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-right: 4px; }
.vs-palette .btn.small { font: 600 13px var(--font-mono); }
.vs-insight { border-left: 3px solid var(--signal); background: color-mix(in srgb, var(--signal) 10%, var(--surface)); border-radius: 0 var(--r) var(--r) 0; padding: 8px 12px; font-size: .94rem; line-height: 1.5; }
.vs-insight p { margin: 0 0 4px; }
.vs-insight p:last-child { margin: 0; }
.vs-insight code { font-size: .88em; }
.vs-stats { font: 600 13px/1.5 var(--font-mono); color: var(--muted); }

/* ---------- collectors ---------- */
.vs-coll { position: relative; width: 100%; min-width: 0; }
.vs-row { position: absolute; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 8px; border-radius: 8px; border: 1px dashed transparent; font: 12px/1.2 var(--font-mono); color: var(--muted); transition: border-color .25s, background-color .25s; }
.vs-row.vs-taken { border-color: var(--rule); }
.vs-row > span:last-child { white-space: nowrap; font-family: var(--font-body); font-size: 12.5px; }
.vs-ghost { flex: none; width: 58px; margin-left: -2px; text-align: center; font: 700 12px var(--font-mono); color: var(--muted); opacity: 0; transition: opacity .3s; }
.vs-taken .vs-ghost { opacity: .55; }
.vs-ctl[hidden] { display: none; }
.vs-row.vs-on { border-color: var(--focus); border-style: solid; background: color-mix(in srgb, var(--focus) 8%, transparent); }
.vs-bucket { position: absolute; border: 2px solid var(--rule); border-radius: 12px; background: var(--surface); transition: border-color .25s, background-color .25s, box-shadow .25s, opacity .3s; }
.vs-bucket-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--rule); font: 700 13px/1.2 var(--font-mono); min-width: 0; }
.vs-bucket-k { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.vs-bucket-v { font: 700 12px/1.2 var(--font-mono); color: var(--muted); white-space: nowrap; }
.vs-bucket.vs-new { opacity: 0; }
.vs-bucket.vs-on { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.vs-bucket.vs-bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }
.vs-bucket.vs-ok .vs-bucket-v { color: var(--ok); }
.vs-bucket.vs-t { border-color: color-mix(in srgb, var(--ok) 60%, var(--rule)); }
.vs-bucket.vs-f { border-color: color-mix(in srgb, var(--bad) 45%, var(--rule)); }
.vs-chip.vs-in { font-size: 12px; }
.vs-chip.vs-absorb { opacity: .35; }
.vs-map { margin: 0; padding: 10px 12px; font: 13px/1.6 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); min-height: 3.4em; }
.vs-map .vs-hot { background: color-mix(in srgb, var(--signal) 35%, transparent); border-radius: 3px; }
.vs-ctl { display: inline-flex; align-items: center; gap: 8px; font: 600 13px var(--font-body); color: var(--muted); }
.vs-ctl input[type=range] { width: 130px; accent-color: var(--c, var(--focus)); }
.vs-ctl b { font: 700 13px var(--font-mono); color: var(--ink); min-width: 6ch; }

/* ---------- parallel ---------- */
.vs-par { display: grid; gap: 14px; min-width: 0; }
.vs-src { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 4px; position: relative; }
@container (max-width: 520px) { .vs-src { grid-template-columns: repeat(8, minmax(0, 1fr)); row-gap: 12px; } }
.vs-cell { position: relative; display: grid; place-items: center; height: 34px; border-radius: 7px; border: 2px solid var(--rule); background: var(--surface); font: 700 13px var(--font-mono); color: var(--ink); transition: border-color .3s, background-color .3s, opacity .3s, transform .3s var(--ease-out); }
.vs-cell.vs-done { opacity: .45; }
.vs-cell.vs-now { transform: translateY(-3px); box-shadow: 0 3px 8px rgb(0 0 0 / .16); }
.vs-cell.vs-cut::before { content: ''; position: absolute; left: -5px; top: -6px; bottom: -6px; width: 3px; border-radius: 2px; background: var(--ink); animation: vs-cut .35s var(--ease-out); }
@keyframes vs-cut { from { transform: scaleY(0); } }
.vs-w0 { --w: var(--focus); } .vs-w1 { --w: var(--ok); } .vs-w2 { --w: var(--signal); } .vs-w3 { --w: var(--java); }
.vs-cell[class*="vs-w"] { border-color: var(--w); background: color-mix(in srgb, var(--w) 14%, var(--surface)); }
.vs-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font: 600 12px/1.3 var(--font-body); color: var(--muted); }
.vs-legend span::before { content: ''; display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--w); }
.vs-lanes { display: grid; gap: 6px; min-width: 0; }
.vs-lane-row { display: grid; grid-template-columns: minmax(74px, 128px) minmax(0, 1fr) minmax(52px, 84px); gap: 8px; align-items: center; min-width: 0; }
.vs-lane-name { font: 700 12px/1.2 var(--font-mono); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-lane-name small { display: block; font-weight: 400; color: var(--muted); }
.vs-time { position: relative; height: 30px; border-radius: 7px; background: var(--surface); border: 1px solid var(--rule); overflow: hidden; }
.vs-blk-t { position: absolute; top: 3px; bottom: 3px; display: grid; place-items: center; border-radius: 5px; font: 700 12px var(--font-mono); color: var(--ink); background: color-mix(in srgb, var(--w, var(--muted)) 30%, var(--surface)); border: 1.5px solid var(--w, var(--muted)); overflow: hidden; white-space: nowrap; animation: vs-grow .3s var(--ease-out); transform-origin: left center; }
.vs-blk-t.vs-ovh { --w: var(--muted); background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--muted) 22%, var(--surface)) 0 5px, var(--surface) 5px 10px); }
.vs-blk-t.vs-badblk { --w: var(--bad); }
@keyframes vs-grow { from { transform: scaleX(0); opacity: 0; } }
.vs-now-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); opacity: .6; transition: left .4s var(--ease-out); }
.vs-part { font: 700 12.5px/1.2 var(--font-mono); text-align: right; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs-part.vs-pop { animation: pop-in .35s var(--ease-out); }
.vs-axis { display: flex; justify-content: space-between; font: 12px var(--font-mono); color: var(--muted); }
.vs-combine { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; font: 700 13px var(--font-mono); }
.vs-combine .cell { min-width: 0; height: 36px; font-size: 13px; }
.vs-list { display: flex; flex-wrap: wrap; gap: 4px; min-height: 34px; }
.vs-list .vs-slot { display: grid; place-items: center; min-width: 34px; height: 30px; padding: 0 4px; border-radius: 6px; border: 2px solid var(--rule); background: var(--surface); font: 700 12.5px var(--font-mono); color: var(--ink); }
.vs-list .vs-slot.vs-lost { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--surface)); }
.vs-list .vs-slot.vs-new { animation: pop-in .3s var(--ease-out); }
.vs-list .vs-slot[class*="vs-w"] { border-color: var(--w); }
.vs-console { display: flex; flex-wrap: wrap; gap: 4px; min-height: 34px; padding: 8px 10px; font: 700 13px var(--font-mono); }
.vs-console span { padding: 2px 6px; border-radius: 5px; border: 1.5px solid var(--w, var(--rule)); background: color-mix(in srgb, var(--w, var(--muted)) 14%, var(--surface)); }
.vs-bars { display: grid; gap: 8px; }
.vs-bar-row { display: grid; grid-template-columns: minmax(84px, 120px) minmax(0, 1fr); gap: 8px; align-items: center; font: 700 12px var(--font-mono); }
.vs-bar { display: flex; height: 28px; border-radius: 6px; overflow: hidden; border: 1px solid var(--rule); background: var(--surface); }
.vs-bar i { display: grid; place-items: center; font: 700 12px var(--font-body); font-style: normal; color: var(--ink); white-space: nowrap; overflow: hidden; transition: flex-basis .45s var(--ease-out); border-right: 1px solid var(--surface); }
.vs-bar .vs-b-work { background: color-mix(in srgb, var(--ok) 35%, var(--surface)); }
.vs-bar .vs-b-ovh { background: color-mix(in srgb, var(--bad) 26%, var(--surface)); }
.vs-bar .vs-b-box { background: color-mix(in srgb, var(--signal) 34%, var(--surface)); }

@container (max-width: 520px) {
  .vs-lane-row { grid-template-columns: 70px minmax(0, 1fr) 54px; gap: 6px; }
  .vs-code { font-size: 12.5px; }
}

/* JetBrains Mono turns -> and == into glyphs; learners should see the real characters */
.vs-wrap *, .vs-builder *, .vs-cap code, .vs-wrap .field, .vs-builder .field, .vs-blk .field { font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0; }

/* parallel: extras */
.vs-src.vs-src8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.vs-blk-t.vs-comb { --w: var(--ink); background: var(--surface-2); }
.vs-tiny .vs-blk-t { font-size: 0; }
.vs-lane-row.vs-seq { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--rule); }
.vs-seq .vs-blk-t { --w: var(--muted); }
.vs-axis-row .vs-axis { padding: 0 2px; }
.vs-panel-body { display: grid; gap: 8px; padding: 6px 0; min-width: 0; }
.vs-pad { padding: 4px 12px; }
.vs-small { font: 600 12.5px/1.4 var(--font-mono); color: var(--muted); white-space: pre-wrap; }
.vs-listrow { display: grid; gap: 4px; }
.vs-combine .cell[class*="vs-w"] { border-color: var(--w); background: color-mix(in srgb, var(--w) 14%, var(--surface)); }
