.lex-viz {
  --lv-a: var(--brand-700);
  --lv-b: #268478;
  --lv-c: #bb742e;
  --lv-d: #637188;
  container-type: inline-size;
  box-sizing: border-box;
  margin: 0 0 clamp(1.5rem, 3vw, 2.5rem);
  padding: clamp(1rem, 3vw, 2rem);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  scroll-margin-top: 5.5rem;
}
.lex-viz figcaption { margin: 0; padding: 0; text-align: left; color: var(--ink); }
.lex-viz h2 { max-width: 35ch; margin: 0 0 1rem; font-size: clamp(1.45rem, 3vw, 2.15rem); line-height: 1.14; letter-spacing: -.035em; color: var(--ink); }
.lex-viz fieldset { position: relative; margin: 0; padding: 0; border: 0; min-inline-size: 0; font-size: 0; }
.lv-sr, .lv-radio { position: absolute; margin: -1px; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.lex-viz input + label {
  display: inline-flex; align-items: center; min-height: 44px; padding: .45rem .85rem; margin: 0 .45rem .45rem 0;
  border: 1px solid var(--line-strong); border-radius: var(--radius-md); color: var(--ink-2);
  font-size: .96rem; line-height: 1.24; font-weight: 700; cursor: pointer;
}
.lex-viz input + label::before { content: ''; margin-right: .5em; width: .9em; height: .9em; flex: none; border: 1.5px solid currentColor; border-radius: 50%; box-sizing: border-box; }
.lex-viz input:checked + label { color: var(--surface); background: var(--accent-strong); border-color: var(--accent-strong); }
.lex-viz input:checked + label::before { background: currentColor; box-shadow: inset 0 0 0 2px var(--accent-strong); }
.lex-viz input:focus-visible + label, .lv-tool:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.lex-viz input + label:hover { border-color: var(--accent); }
.lv-panel { display: none; min-width: 0; grid-template-columns: minmax(0,.85fr) minmax(0,1.15fr); align-items: center; gap: clamp(1rem,3vw,2rem); margin: .45rem 0 0; padding: clamp(.9rem,2.5vw,1.6rem); border-radius: var(--radius-md); background: var(--surface-2); font-size: 1rem; }
.lv-choice-0:checked ~ .lv-case-0, .lv-choice-1:checked ~ .lv-case-1 { display: grid; }
.lv-summary, .lv-drawing { min-width: 0; }
.lv-summary .lv-answer { display: block; max-width: 23ch; color: var(--accent-strong); font-size: clamp(1.45rem,3.2vw,2.55rem); line-height: 1.07; letter-spacing: -.04em; overflow-wrap: anywhere; }
.lv-summary p { margin: .65rem 0 0; font-size: 1rem; line-height: 1.48; color: var(--ink-2); }
.lv-drawing { padding: clamp(.75rem,1.7vw,1.2rem); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.lv-drawing .lv-unit { margin: 0 0 .6rem; font-size: .82rem; line-height: 1.3; font-weight: 700; color: var(--ink-2); }
.lv-pair { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; font-size: .91rem; }
.lv-row + .lv-row { margin-top: .6rem; }
.lv-track, .lv-strip { overflow: hidden; border-radius: .32rem; background: var(--surface-sunken); }
.lv-track { height: .65rem; margin-top: .18rem; }
.lv-track i { display: block; height: 100%; background: var(--lv-a); border-radius: .32rem; }
.lv-row:nth-of-type(even) .lv-track i { background: var(--lv-b); }
.lv-strip { display: flex; height: 1.65rem; margin: .3rem 0 .75rem; }
.lv-series-0 { background: var(--lv-a); }
.lv-series-1 { background: repeating-linear-gradient(135deg,transparent 0 5px,#ffffff4a 5px 7px), var(--lv-b); }
.lv-series-2 { background: repeating-linear-gradient(90deg,transparent 0 5px,#ffffff65 5px 7px), var(--lv-c); }
.lv-series-3 { background: repeating-linear-gradient(0deg,transparent 0 3px,#ffffff65 3px 5px), var(--lv-d); }
.lex-viz ul, .lex-viz ol { list-style: none; margin: 0; padding: 0; }
.lv-key li, .lv-points li { display: flex; align-items: baseline; gap: .5rem; padding: .2rem 0; font-size: .9rem; line-height: 1.3; }
.lv-key li i { width: .8rem; height: .8rem; align-self: center; flex: none; border-radius: 2px; }
.lv-key b, .lv-points b { margin-left: auto; white-space: nowrap; }
.lv-slots { display: flex; gap: .23rem; margin-top: .2rem; }
.lv-slots i { height: 1.05rem; width: 13.5%; border: 1px dashed var(--ink-3); border-radius: 2px; }
.lv-slots .lv-filled { background: var(--lv-a); border: 1px solid var(--lv-a); }
.lv-line { display: block; width: 100%; max-height: 11rem; }
.lv-line text { font: 13px Helvetica,Arial,sans-serif; fill: var(--ink-2); }
.lv-line path, .lv-line polyline { fill: none; }
.lv-line .lv-grid { stroke: var(--line-strong); stroke-dasharray: 4 3; }
.lv-line .lv-axis { stroke: var(--ink-3); }
.lv-line polyline { stroke: var(--lv-a); stroke-width: 3; }
.lv-line circle { fill: var(--surface); stroke: var(--lv-a); stroke-width: 2; }
.lv-flow { display: flex; gap: .7rem; align-items: stretch; }
.lv-flow li, .lv-tree li { position: relative; flex: 1 1 0; min-width: 0; padding: .55rem; background: var(--surface-2); border-top: 3px solid var(--lv-a); border-radius: 3px; overflow-wrap: anywhere; }
.lv-flow li:last-child, .lv-tree li:last-child { border-color: var(--lv-b); }
.lv-tree { position: relative; }
.lv-tree ol { display: grid; grid-template-columns: minmax(0,1fr) 1.5rem minmax(0,1fr); grid-template-rows: 1fr 1fr; grid-template-areas: "root . leaf-a" "root . leaf-b"; row-gap: .45rem; align-items: center; }
.lv-tree li:nth-child(1) { grid-area: root; }
.lv-tree li:nth-child(2) { grid-area: leaf-a; }
.lv-tree li:nth-child(3) { grid-area: leaf-b; }
.lv-merge ol { grid-template-areas: "leaf-a . root" "leaf-b . root"; }
.lv-merge li:nth-child(1) { grid-area: leaf-a; }
.lv-merge li:nth-child(2) { grid-area: leaf-b; }
.lv-merge li:nth-child(3) { grid-area: root; }
.lv-connector { display: block; position: absolute; inset: 0 auto 0 calc(50% - .75rem); width: 1.5rem; height: 100%; fill: none; stroke: var(--ink-3); stroke-width: 1.5; }
.lv-merge .lv-connector { transform: scaleX(-1); }
.lv-flow li + li::before { content: '›'; position: absolute; left: -.56rem; top: 45%; color: var(--ink-3); font-size: .9rem; line-height: 1; }
.lv-flow li span, .lv-tree li span { display: block; font-size: .8rem; line-height: 1.22; color: var(--ink-2); }
.lv-flow li strong, .lv-tree li strong { display: block; margin-top: .45rem; font-size: 1rem; line-height: 1.22; }
.lv-tool { display: inline-flex; align-items: center; min-height: 44px; gap: .45rem; margin-top: .35rem; color: var(--accent-ink); font-size: .98rem; font-weight: 700; text-decoration: underline; text-underline-offset: .2em; }
.lex-example-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 1rem; }
.lex-example-links .lex-jump + .lex-jump { margin-inline-start: 0; }
@container (max-width: 45rem) { .lv-panel { grid-template-columns: minmax(0,1fr); } }
@container (max-width: 27rem) {
  .lv-flow { flex-direction: column; }
  .lv-flow li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; border-top: 0; border-left: 3px solid var(--lv-a); }
  .lv-flow li strong, .lv-tree li strong { margin: 0 0 0 auto; }
  .lv-flow li + li::before { content: '⌄'; left: 47%; top: -.8rem; }
}
@media (forced-colors: active) {
  .lv-radio:checked + label { outline: 2px solid Highlight; }
  .lv-radio:focus-visible + label { outline: 3px dashed Highlight; }
  .lv-track i, .lv-strip i, .lv-filled { forced-color-adjust: none; }
}
