.trace-lab { border:1px solid var(--line,#cbd7da); border-radius:12px; padding:clamp(.85rem,2vw,1.45rem); }
.trace-selectors,.trace-dimensions {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,10rem),1fr));gap:.8rem;}
.trace-field {display:grid;gap:.35rem;align-content:end;min-width:0;font-weight:600;font-size:.87rem;}
.trace-field[hidden] {display:none;}
.trace-field select,.trace-field input {box-sizing:border-box;width:100%;min-height:42px;border:1px solid #9cabad;border-radius:6px;padding:.45rem;background:#fff;color:#17333c;font:inherit;font-size:1rem;}
.trace-figure {margin:1rem 0;padding:.4rem;background:#f2f7f6;border-radius:6px;}
.trace-figure canvas {display:block;width:100%;height:130px;}
.trace-figure figcaption,.trace-result p {font-size:.85rem;line-height:1.5;}
.trace-figure figcaption {padding:0 .5rem .35rem;}
.trace-result {margin-top:1rem;padding:1rem;background:#eaf5f2;border-left:4px solid #267769;}
.trace-result strong {display:block;font-size:clamp(1.65rem,4vw,2.4rem);line-height:1.25;font-variant-numeric:tabular-nums;color:#144d44;}
.trace-result p {margin:.35rem 0 0;}
.trace-result p:empty,.trace-lab .input-warning:empty {display:none;}

.diagram-choices { min-width: 0; border: 0; padding: 0; margin: 0 0 .9rem; }
.diagram-choices legend { padding: 0; margin-bottom: .35rem; font-size: .87rem; font-weight: 700; }
.diagram-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); gap: .45rem; }
.diagram-options label { position: relative; display: grid; min-width: 0; cursor: pointer; }
.diagram-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
}
.diagram-option {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 44px;
  padding: .35rem .45rem;
  border: 1px solid #9cabad;
  border-radius: 8px;
  background: #fff;
  color: #17333c;
  text-align: center;
  font-size: .8rem;
  font-weight: 650;
  line-height: 1.35;
}
.diagram-option svg { display: block; width: 100%; height: 46px; margin-bottom: .15rem; }
.diagram-options label:hover .diagram-option { background: #f2f7f6; }
.diagram-options input:checked + .diagram-option {
  box-shadow: inset 0 0 0 1px #267769;
  border-color: #267769;
  background: #eaf5f2;
  color: #144d44;
}
.diagram-options input:focus-visible + .diagram-option { outline: 2px solid #267769; outline-offset: 2px; }
.diagram-ground { fill: #316561; }
.diagram-substrate { fill: #d7e9e3; }
.diagram-signal { fill: #a24e17; }
.diagram-wire, .diagram-victim, .diagram-wire-under { fill: none; stroke-width: 7; stroke-linecap: round; }
.diagram-wire { stroke: #a24e17; }
.diagram-victim { stroke: #245b9a; }
.diagram-wire-under { stroke: #fff; stroke-width: 12; }
.diagram-measure { stroke: #637c83; stroke-dasharray: 2 2; stroke-width: 1.5; }
.trace-selectors { grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.trace-dimensions[hidden], .pcb-crosstalk [hidden] { display: none; }
.trace-field input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.trace-field input:focus-visible { outline: 2px solid #267769; outline-offset: 1px; }

.pcb-crosstalk { margin: 1.5rem 0; scroll-margin-top: 5rem; }
.pcb-crosstalk h2 { margin-top: 0; }
.pcb-crosstalk > p { margin: .6rem 0 .9rem; }
.xt-common { padding-top: .75rem; margin-top: .75rem; border-top: 1px solid var(--line); }
.pcb-crosstalk [data-xt-results][aria-busy="true"] { opacity: .55; }
.xt-peaks { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .5rem; margin-top: .75rem; }
.xt-peaks > div { padding: .6rem .75rem; border-radius: 6px; background: #eef5f8; font-size: .85rem; }
.xt-peaks strong { display: block; margin-top: .2rem; font-size: 1.15rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.xt-key { display: inline-block; width: 1rem; margin-right: .35rem; vertical-align: .2em; border-top: 2px solid #245b9a; }
.xt-key-far { border-top: 2px dashed #795091; }
.xt-waveform { display: block; width: 100%; height: 220px; margin: .65rem 0; background: #f7fafb; border-radius: 6px; }
.xt-waveform text { fill: #294652; font-size: 11px; font-family: system-ui, sans-serif; }
.xt-grid line { stroke: #d4e1e5; }
.xt-next, .xt-fext { fill: none; stroke: #245b9a; stroke-width: 2; }
.xt-fext { stroke: #795091; stroke-dasharray: 5 4; }
.xt-details { font-size: .85rem; line-height: 1.55; color: var(--ink-2); margin: .45rem 0 0; }
.pcb-crosstalk .input-warning:empty { display: none; }

@media (max-width: 479px) {
  #trace-type .diagram-options, #xt-kind .diagram-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
