/* 로직 소자 탐험기 (/logic/) — design pass matching /lab.css tokens and typography.
 * Loaded after /lab.css, logic/logic.css and logic/sch2.css.
 * Selectors only; no content: text injection; no overrides of .s3d-root or svg.sch2 internals. */

:root,
:root[data-theme="light"] {
  --bg: var(--lab-bg, #f6f5f2);
  --surface: var(--lab-surface, #ffffff);
  --surface2: var(--lab-surface2, #eeede8);
  --text: var(--lab-text, #161615);
  --muted: var(--lab-muted, #56575c);
  --faint: var(--lab-faint, #65666c);
  --line: var(--lab-line, #e2e0da);
  --line-strong: var(--lab-line-strong, #c8c5bd);
  --primary: var(--lab-ink, #181816);
  --on-primary: var(--lab-on-ink, #ffffff);
  --on-ink-muted: #d6d5d0;
  --accent: var(--lab-accent, #b83b0a);
  --accent-soft: #fdf0e7;
  --hl: #be185d;
  --flow: #be185d;
  --hl-soft: #fdf2f8;
  --vhi: #b91c1c;
  --vhi-soft: #fef2f2;
  --vlo: #1d4ed8;
  --vlo-soft: #eff6ff;
  --vmid: #6d28d9;
  --e: #1d4ed8;
  --h: #b83b0a;
  --vcur: #6d28d9;
  --pin-tx: #ffffff;
  --radius: 12px;
  --radius-md: 10px;
  --radius-sm: var(--lab-radius, 8px);
  --shadow: var(--lab-shadow-sm, 0 1px 2px rgba(20, 20, 18, .04), 0 2px 8px rgba(20, 20, 18, .03));
  --shadow-lg: var(--lab-shadow-lg, 0 14px 36px rgba(20, 20, 18, .12));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--lab-bg, #0f0f10);
    --surface: var(--lab-surface, #171719);
    --surface2: var(--lab-surface2, #202023);
    --text: var(--lab-text, #ededeb);
    --muted: var(--lab-muted, #a4a5ab);
    --faint: var(--lab-faint, #8e9097);
    --line: var(--lab-line, #29292d);
    --line-strong: var(--lab-line-strong, #3e3e44);
    --primary: var(--lab-ink, #ededeb);
    --on-primary: var(--lab-on-ink, #121213);
    --on-ink-muted: #4e4f54;
    --accent: var(--lab-accent, #ff8a4c);
    --accent-soft: #2a1a10;
    --hl: #ff6fae;
    --flow: #ff6fae;
    --hl-soft: #2b1521;
    --vhi: #ff7b7b;
    --vhi-soft: #2a1418;
    --vlo: #7fb0ff;
    --vlo-soft: #122136;
    --vmid: #d19bff;
    --e: #7fb0ff;
    --h: #ff9a5c;
    --vcur: #d19bff;
    --pin-tx: #10131a;
    --shadow: var(--lab-shadow-sm, 0 1px 2px rgba(0, 0, 0, .22));
    --shadow-lg: var(--lab-shadow-lg, 0 20px 50px rgba(0, 0, 0, .48));
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: var(--lab-bg, #0f0f10);
  --surface: var(--lab-surface, #171719);
  --surface2: var(--lab-surface2, #202023);
  --text: var(--lab-text, #ededeb);
  --muted: var(--lab-muted, #a4a5ab);
  --faint: var(--lab-faint, #8e9097);
  --line: var(--lab-line, #29292d);
  --line-strong: var(--lab-line-strong, #3e3e44);
  --primary: var(--lab-ink, #ededeb);
  --on-primary: var(--lab-on-ink, #121213);
  --on-ink-muted: #4e4f54;
  --accent: var(--lab-accent, #ff8a4c);
  --accent-soft: #2a1a10;
  --hl: #ff6fae;
  --flow: #ff6fae;
  --hl-soft: #2b1521;
  --vhi: #ff7b7b;
  --vhi-soft: #2a1418;
  --vlo: #7fb0ff;
  --vlo-soft: #122136;
  --vmid: #d19bff;
  --e: #7fb0ff;
  --h: #ff9a5c;
  --vcur: #d19bff;
  --pin-tx: #10131a;
  --shadow: var(--lab-shadow-sm, 0 1px 2px rgba(0, 0, 0, .22));
  --shadow-lg: var(--lab-shadow-lg, 0 20px 50px rgba(0, 0, 0, .48));
  color-scheme: dark;
}

/* ---------- base, typography & focus ---------- */
html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--lab-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
  overflow-x: clip;
}

[hidden] {
  display: none !important;
}

:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

main.wrap,
#app.wrap {
  max-width: 1200px;
  min-height: calc(100dvh - 57px);
  margin: 0 auto;
  padding: 0 16px 84px;
}

/* ---------- page header ---------- */
.app-head {
  padding: 26px 0 18px;
}

.app-head h1 {
  margin: 0 0 8px;
  font-size: clamp(1.45rem, 3.2vw, 1.95rem);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.intro {
  margin: 0;
  max-width: 64ch;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.62;
}

/* ---------- cards ---------- */
.card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 0 16px;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.04rem;
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1.35;
  display: flex;
  align-items: baseline;
  gap: 4px 10px;
  flex-wrap: wrap;
  color: var(--text);
}

.card h2 small {
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: auto;
  min-height: 36px;
  max-width: 100%;
  padding: 6px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: normal;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .15s, background-color .15s, color .15s, opacity .15s;
}

.btn:not([aria-pressed="true"]):not(:disabled):hover {
  border-color: var(--text);
  background: var(--surface2);
}

.btn:not(:disabled):active {
  opacity: .84;
}

.btn[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
}

.btn[aria-pressed="true"]:not(:disabled):hover {
  opacity: .88;
}

.btn:disabled,
.btn:disabled:hover {
  opacity: 1;
  background: var(--surface2);
  border-color: var(--line);
  color: var(--faint);
  box-shadow: none;
  cursor: default;
}

#autoBtn {
  min-height: 38px;
  padding: 6px 14px;
}

/* ---------- controls & segmented controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: flex-end;
}

.row3 {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.ctl {
  display: grid;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.ctl > span,
.ctl-l {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.35;
  margin: 0;
}

.ctl[hidden] {
  display: none;
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  max-width: 100%;
  overflow: visible;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.seg.wrap {
  flex-wrap: wrap;
  max-width: 100%;
  min-height: 0;
  margin: 0;
  padding: 3px;
}

.seg button {
  height: auto;
  min-height: 30px;
  min-width: 2.3em;
  padding: 5px 11px;
  border: 0;
  border-radius: calc(var(--radius-sm) - 3px);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  transition: color .15s, background-color .15s, opacity .15s;
}

.seg button + button {
  border-left: 0;
}

.seg button:not([aria-pressed="true"]):not(:disabled):hover {
  color: var(--text);
  background: var(--surface2);
}

.seg button:not(:disabled):active {
  opacity: .86;
}

.seg button[aria-pressed="true"] {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
}

.seg button[aria-pressed="true"]:hover {
  opacity: .9;
}

.seg button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  position: relative;
  z-index: 1;
}

.seg.io button {
  min-width: 2.5em;
  font-family: var(--lab-mono);
  font-variant-numeric: tabular-nums;
}

.seg.io button[aria-pressed="true"] {
  font-weight: 800;
}

#outBox {
  font-family: var(--lab-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  padding: 5px 12px;
  color: var(--text);
  background: var(--surface2);
  opacity: 1;
}

#outBox.v1 {
  color: var(--vhi);
  background: var(--vhi-soft);
}

#outBox.v0 {
  color: var(--vlo);
  background: var(--vlo-soft);
}

/* ---------- checkbox pills ---------- */
.chk {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13.5px;
  color: var(--text);
}

.chk label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background-color .15s;
}

.chk label:hover {
  border-color: var(--text);
  background: var(--surface2);
}

.chk label:has(input:checked) {
  background: var(--bg);
}

.chk input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- basics accordion ---------- */
.basics {
  margin: 0 0 16px;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.6;
}

.basics summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text);
  padding: 2px 0;
  border-radius: 6px;
  transition: color .15s;
}

.basics summary:hover,
.basics[open] summary {
  color: var(--accent);
}

.basics ul {
  margin: 10px 0 2px;
  padding: 10px 0 0 1.35em;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
}

.basics li {
  margin: 0;
  color: var(--text);
}

.basics li::marker {
  color: var(--accent);
}

/* ---------- explainer video ---------- */
#opVideoCard .opv {
  max-width: 960px;
  margin: 0 auto;
}

.opv video,
.opyt {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0b1020;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.opcap {
  margin: 10px 0 0;
  padding: 11px 14px;
  min-height: 4.4em;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.55;
}

.opchap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 960px;
  margin: 12px auto 2px;
}

.opchap .btn {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 13px;
  text-align: left;
  box-shadow: none;
}

.opchap .btn .t {
  font-family: var(--lab-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 4px;
}

.opchap .btn[aria-current="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  box-shadow: none;
}

.opchap .btn[aria-current="true"] .t {
  color: var(--on-ink-muted);
}

/* ---------- status & selection readout ---------- */
.status {
  margin: 0 0 12px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 14.5px;
  line-height: 1.58;
}

.status .st-h {
  font-weight: 700;
  font-size: 1.04rem;
  letter-spacing: -.015em;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.status ol {
  margin: 0 0 10px;
  padding-left: 1.45em;
  display: grid;
  gap: 4px;
}

.status li {
  margin: 0;
  font-size: 14px;
}

.status li::marker {
  color: var(--muted);
  font-family: var(--lab-mono);
  font-size: 12.5px;
  font-weight: 600;
}

.status .hint {
  margin: 8px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--vmid);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
}

.status .st-tr {
  margin-top: 10px;
  padding: 10px 13px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.status .st-key {
  margin-top: 10px;
  padding: 10px 13px;
  border: 1px solid color-mix(in srgb, var(--hl) 28%, var(--line));
  border-left: 3px solid var(--hl);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--hl-soft);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.55;
}

.v1 {
  color: var(--vhi);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.v0 {
  color: var(--vlo);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.vz {
  color: var(--vmid);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.on {
  font-weight: 700;
}

.off {
  color: var(--muted);
}

.selbar {
  display: block;
  margin: 0 0 16px;
  padding: 9px 14px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface2);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
}

.selbar b {
  color: var(--text);
}

/* ---------- two-column grids & diagram containers ---------- */
.grid2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin: 0 0 16px;
}

.grid2 > * {
  min-width: 0;
}

.grid2 > .card {
  margin-bottom: 0;
}

.card .grid2 {
  margin-bottom: 10px;
}

@media (min-width: 900px) {
  .grid2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

#sch,
#lay,
#xs,
#vtcPlot {
  min-width: 0;
  max-width: 100%;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 0;
  vertical-align: 0;
  border: 1px solid var(--line-strong);
}

.hint {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  margin: 10px 0 0;
}

/* ---------- layout layer toggle chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.lchip {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  min-height: 30px;
  padding: 4px 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
  transition: border-color .15s, background-color .15s, color .15s, opacity .15s;
}

.lchip i {
  display: inline-block;
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  margin-right: 0;
  border: 1px solid var(--line-strong);
}

.lchip:hover {
  border-color: var(--text);
  background: var(--surface2);
}

.lchip[aria-pressed="true"] {
  border-color: var(--line-strong);
  background: var(--surface2);
  color: var(--text);
  font-weight: 700;
}

.lchip[aria-pressed="true"]:hover {
  border-color: var(--text);
}

.lchip[aria-pressed="false"] {
  border-style: dashed;
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: none;
  text-decoration: line-through;
  color: var(--muted);
}

.lchip[aria-pressed="false"] i {
  opacity: .3;
}

/* ---------- SVG text & non-sch2 SVG refinements ---------- */
.lbl {
  font-family: var(--lab-sans);
}

.lay,
.xs,
.vtc,
.wv {
  display: block;
  width: 100%;
  height: auto;
  touch-action: manipulation;
}

.wv .cur {
  fill: var(--hl);
  opacity: .14;
}

/* ---------- 3D structure & process steps ---------- */
.steps {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.steprow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.steprow .ctl-l {
  flex: none;
}

input[type="range"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.steprow input[type="range"] {
  flex: 1 1 130px;
  min-width: 100px;
  margin: 0;
}

#stepPrev,
#stepNext {
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
  flex: none;
}

.steprow b {
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  flex: 0 1 auto;
  overflow-wrap: anywhere;
}

#stepPlay {
  margin-left: auto;
  min-height: 36px;
  flex: none;
}

.stepbox {
  margin: 10px 0 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
  min-height: 3.2em;
}

#wrap3 {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
}

#new3 {
  display: none;
}

#wrap3.is-new #new3 {
  display: block;
  height: clamp(300px, 58vw, 600px);
}

#c3 {
  display: block;
  width: 100%;
  cursor: grab;
  touch-action: pan-y;
}

#c3:active {
  cursor: grabbing;
}

.l3 {
  position: absolute;
  transform: translate(-50%, -100%);
  font-family: var(--lab-mono);
  font-size: 11.5px;
  font-weight: 700;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  padding: 1px 6px;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.l3.io {
  border-width: 2px;
}

.l3.v1 {
  border-color: var(--vhi);
  background: var(--vhi-soft);
  color: var(--vhi);
}

.l3.v0 {
  border-color: var(--vlo);
  background: var(--vlo-soft);
  color: var(--vlo);
}

.l3.hl {
  border-color: var(--hl);
  box-shadow: 0 0 0 2px var(--hl);
}

.no3 {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

/* ---------- voltage curve & drive strength ---------- */
.sl {
  display: grid;
  gap: 5px;
  min-width: 0;
  flex: 1 1 220px;
}

.sl label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.sl label b {
  font-family: var(--lab-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.sl input {
  width: 100%;
  margin: 0;
}

.vtc {
  width: 100%;
  height: auto;
  display: block;
}

.vtc .grid {
  stroke: var(--line);
  stroke-width: 1;
}

.vtc .vout {
  fill: none;
  stroke: var(--text);
  stroke-width: 2.6;
  stroke-linejoin: round;
}

.vtc .cur-i {
  fill: none;
  stroke: var(--vcur);
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

.vtc .vm {
  stroke: var(--hl);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

.vtcv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}

.vtcv div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: var(--bg);
}

.vtcv dt {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
}

.vtcv dd {
  margin: 3px 0 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.drv {
  display: grid;
  grid-template-columns: minmax(0, 9.8em) minmax(56px, 1fr) 3.4em;
  gap: 8px 10px;
  align-items: center;
  font-size: 13px;
  margin: 7px 0;
}

.drv span {
  min-width: 0;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.drv i {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.drv b {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width .25s ease;
}

.drv b.pu {
  background: var(--h);
}

.drv b.pd {
  background: var(--e);
}

.drv em {
  font-style: normal;
  font-family: var(--lab-mono);
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.vleg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12.5px;
  color: var(--muted);
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.vleg span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.vleg i {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 0;
  vertical-align: middle;
  margin-right: 0;
  border-top: 2.6px solid var(--text);
}

.vleg i.li {
  border-top: 2px dashed var(--vcur);
}

.vleg i.lm {
  border-top: 1.5px dashed var(--hl);
}

/* ---------- truth table & waveform ---------- */
#tt {
  max-width: 100%;
  overflow-x: auto;
  margin-bottom: 12px;
}

.tt {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0;
}

.tt th,
.tt td {
  border-bottom: 1px solid var(--line);
  padding: 7px 6px;
  text-align: center;
}

.tt th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  border-bottom-color: var(--line-strong);
  white-space: nowrap;
}

.tt td.dv {
  text-align: left;
  color: var(--text);
  font-size: 13px;
  font-family: var(--lab-mono);
}

.tt tbody tr {
  cursor: pointer;
  transition: background-color .12s;
}

.tt tbody tr:hover {
  background: var(--surface2);
}

.tt tbody tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tt tbody tr[aria-current="true"] {
  background: var(--hl-soft);
  box-shadow: inset 3px 0 0 var(--hl);
}

.tt tbody tr[aria-current="true"] td.dv {
  font-weight: 600;
}

#wv {
  min-width: 0;
  max-width: 100%;
}

/* ---------- learn more & footer ---------- */
details.more {
  margin: 0;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

details.more:first-of-type {
  border-top: 0;
  padding-top: 4px;
}

details.more:last-of-type {
  padding-bottom: 2px;
}

details.more summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--text);
  padding: 2px 0;
  border-radius: 6px;
  transition: color .15s;
}

details.more summary:hover,
details.more[open] summary {
  color: var(--accent);
}

details.more p,
details.more li {
  margin: 8px 0 2px;
  font-size: 14px;
  line-height: 1.64;
  color: var(--text);
  max-width: 72ch;
}

footer {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding: 20px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

footer a {
  color: var(--muted);
  text-underline-offset: 3px;
}

footer a:hover {
  color: var(--text);
}

/* ---------- mobile responsiveness (360px - 520px) ---------- */
@media (max-width: 520px) {
  .controls {
    gap: 12px 14px;
  }

  .row3 {
    gap: 10px 14px;
  }

  .vtcv dd {
    font-size: 14.5px;
  }
}

@media (max-width: 420px) {
  main.wrap,
  #app.wrap {
    padding: 0 12px 72px;
  }

  .app-head {
    padding: 18px 0 14px;
  }

  .card {
    padding: 14px 12px;
    margin-bottom: 14px;
  }

  .grid2 {
    gap: 14px;
    margin-bottom: 14px;
  }

  .basics {
    padding: 12px 14px;
    margin-bottom: 14px;
  }

  .status {
    padding: 14px;
    margin-bottom: 10px;
  }

  .selbar {
    padding: 8px 12px;
    margin-bottom: 14px;
    font-size: 13px;
  }

  .seg button {
    padding: 5px 8px;
    font-size: 12.5px;
  }

  #outBox {
    padding: 5px 10px;
    font-size: 12.5px;
  }

  .chk label {
    min-height: 36px;
    padding: 5px 10px;
    font-size: 13px;
  }

  .steps {
    padding: 10px 12px;
  }

  .steprow input[type="range"] {
    min-width: 80px;
  }

  #stepPlay {
    margin-left: 0;
  }

  .opcap {
    padding: 10px 12px;
    font-size: 14px;
  }

  .vtcv div {
    padding: 8px 10px;
  }

  .drv {
    grid-template-columns: minmax(0, 9em) minmax(52px, 1fr) 3.1em;
    gap: 6px 8px;
    font-size: 12.5px;
  }

  .tt th,
  .tt td {
    padding: 6px 4px;
    font-size: 12.5px;
  }

  .tt th {
    font-size: 11.5px;
  }

  .tt td.dv {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .card,
  .seg button,
  .chk label,
  .basics summary,
  .lchip,
  .tt tbody tr,
  .drv b,
  details.more summary {
    transition: none;
  }
}
