/* SRAM 구조 탐험기 (/sram/) — design pass matching /lab.css and /logic/design.css.
 * Loaded after /lab.css and the inline <style> block in sram/index.html.
 * Selectors only; no content: text injection; no overrides inside #wrap3 / .s3d*,
 * svg.s6sch / .s6*, or layout/cross-section SVG drawing colors. */

html:root:not(#_),
html:root:not(#_)[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;
  --soft: var(--lab-surface2, #eeede8);
  --accent: var(--lab-accent, #b83b0a);
  --accent-soft: #fdf0e7;
  --hl: #be185d;
  --hl-soft: #fdf2f8;
  --vhi: #b91c1c;
  --vhi-soft: #fef2f2;
  --vlo: #1d4ed8;
  --vlo-soft: #eff6ff;
  --vmid: #6d28d9;
  --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) {
  html:root:not(#_):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;
    --soft: var(--lab-surface2, #202023);
    --accent: var(--lab-accent, #ff8a4c);
    --accent-soft: #2a1a10;
    --hl: #ff6fae;
    --hl-soft: #2b1521;
    --vhi: #ff7b7b;
    --vhi-soft: #2a1418;
    --vlo: #7fb0ff;
    --vlo-soft: #122136;
    --vmid: #d19bff;
    --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;
  }
}

html:root:not(#_)[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;
  --soft: var(--lab-surface2, #202023);
  --accent: var(--lab-accent, #ff8a4c);
  --accent-soft: #2a1a10;
  --hl: #ff6fae;
  --hl-soft: #2b1521;
  --vhi: #ff7b7b;
  --vhi-soft: #2a1418;
  --vlo: #7fb0ff;
  --vlo-soft: #122136;
  --vmid: #d19bff;
  --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;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

[hidden] {
  display: none !important;
}

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

.wrap,
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;
}

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

header.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 22px 0 12px;
}

header.top a.back {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
}

header.top a.back:hover {
  color: var(--accent);
}

header.top h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.25;
  flex: 1 1 auto;
  min-width: 0;
}

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

/* ---------- cards & headings ---------- */
.card {
  min-width: 0;
  max-width: 100%;
  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;
  margin-left: 0;
}

/* ---------- 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;
}

/* ---------- controls, segmented buttons, select & sliders ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.card > .controls:last-child {
  margin-bottom: 0;
}

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

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

.ctl[hidden] {
  display: none;
}

.ctl select,
.controls select {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  min-height: 36px;
  max-width: 100%;
  padding: 6px 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}

.ctl select:hover,
.controls select:hover {
  border-color: var(--text);
  background: var(--surface2);
}

.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 button {
  height: auto;
  min-height: 30px;
  min-width: 0;
  max-width: 100%;
  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:disabled {
  color: var(--faint);
  cursor: default;
  opacity: 1;
}

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

.sliders {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-bottom: 12px;
}

.card > .sliders:last-child,
.ctl3 .sliders {
  margin-bottom: 0;
}

.sl {
  display: grid;
  gap: 5px;
  min-width: 0;
  flex: 1 1 160px;
  max-width: 100%;
}

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

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

input[type="range"] {
  width: 100%;
  max-width: 100%;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

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

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

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

.chk label:has(input:checked),
.chk1:has(input:checked) {
  background: var(--bg);
  border-color: var(--text);
}

.chk input,
.chk1 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;
  color: var(--text);
}

.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 card ---------- */
#opVideoCard .opv {
  max-width: 960px;
  margin: 0 auto;
}

.opsel {
  max-width: 960px;
  margin: 0 auto 12px;
  justify-items: start;
}

.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;
}

.opyt iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.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);
}

#opVideoCard a {
  color: var(--accent);
  text-underline-offset: 3px;
}

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

/* ---------- status & selection bar ---------- */
.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;
  color: var(--text);
}

.status b:not(.v1):not(.v0):not(.vz) {
  color: var(--text);
}

.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 .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;
}

.status .st-note {
  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;
}

.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: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  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);
  font-weight: 700;
}

.selbar button {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--hl);
  border-radius: 999px;
  padding: 3px 11px;
  cursor: pointer;
  white-space: normal;
  text-align: center;
  transition: border-color .15s, background-color .15s, color .15s;
}

.selbar button:hover {
  background: var(--hl-soft);
}

.selbar button.clr {
  border: 1px solid var(--line-strong);
  font-weight: 600;
  color: var(--muted);
}

.selbar button.clr:hover {
  border-color: var(--text);
  background: var(--surface);
  color: var(--text);
}

/* ---------- two-column grids & diagram wrappers ---------- */
.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,
.xswrap {
  min-width: 0;
  max-width: 100%;
}

.xswrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.lay .lbl,
.xs .lbl {
  font-family: var(--lab-sans);
}

/* ---------- diagram toolbars, mode switchers & process steps ---------- */
.lmode {
  margin: 0 0 10px;
  max-width: 100%;
}

.lmode .seg button {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12.5px;
}

.mbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.mbar label {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}

.mbar select,
.arrSel {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  min-height: 32px;
  max-width: 100%;
  padding: 4px 8px;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}

.mbar select:hover,
.arrSel:hover {
  border-color: var(--text);
  background: var(--surface2);
}

.mbar .seg {
  box-shadow: none;
}

.mbar .seg button {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12.5px;
}

.mbar .mbl {
  color: var(--text);
  font-weight: 600;
}

.mbar .mbs {
  flex: 1 1 180px;
  min-width: 0;
  max-width: 100%;
}

.mbar .mbs input {
  flex: 1 1 72px;
  min-width: 60px;
  margin: 0;
}

.mbar .mbs b {
  min-width: 4.5em;
  text-align: right;
  color: var(--text);
  font-family: var(--lab-mono);
  font-variant-numeric: tabular-nums;
}

.modrow {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.modrow span {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  margin-right: 2px;
}

.modrow button {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  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;
  padding: 3px 10px;
  cursor: pointer;
  white-space: normal;
  text-align: center;
  transition: border-color .15s, background-color .15s, color .15s;
}

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

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

.mb-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 100%;
}

.mb-nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  max-width: 100%;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, color .15s;
}

.mb-nav button:not(:disabled):hover {
  border-color: var(--text);
  background: var(--surface2);
}

.mb-nav button:disabled {
  cursor: default;
  color: var(--faint);
  background: var(--surface2);
  border: 1px dashed var(--line-strong);
}

.mb-nav .mb-st {
  min-width: 0;
  font-family: var(--lab-mono);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--text);
}

.arrPick {
  display: flex;
  gap: 8px 12px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 100%;
}

.arrPick label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  max-width: 100%;
}

.arrsch {
  margin: 12px auto 0;
  max-width: 100%;
}

/* ---------- 3D card outer controls & process stepper ---------- */
.ctl3 {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.ctl3 .sl {
  min-width: 0;
  flex: 1 1 200px;
  max-width: 100%;
}

.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;
}

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

.steprow .btn {
  min-height: 34px;
  padding: 4px 10px;
  box-shadow: none;
}

#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;
  color: var(--text);
}

#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;
}

#stepTitle {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}

#stepTitle small {
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  margin-left: 0;
}

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

/* ---------- layer chips & legends ---------- */
.laysub {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  gap: 6px 10px;
  align-items: center;
  flex-wrap: wrap;
}

.laysub small {
  color: var(--muted);
  font-weight: 500;
  font-size: 12.5px;
}

.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 > span > i {
  margin-right: 0;
}

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

.lg-sym {
  font-weight: 800;
}

#layLegend {
  gap: 6px;
}

.laysub + #layLegend {
  margin-top: 8px;
  padding-top: 0;
  border-top: 0;
}

.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;
  max-width: 100%;
  padding: 4px 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: normal;
  text-align: center;
  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;
  border: 1px solid var(--line-strong);
  margin-right: 5px !important;
}

.lchip i + i {
  margin-left: -2px;
}

.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;
}

.lchip em {
  font-style: normal;
  color: var(--muted);
  margin-left: 4px;
  font-weight: 500;
}

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

.hatchn {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ---------- transistor info card, tags & tables ---------- */
.info {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
}

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

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

.kv {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 6px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  margin: 0;
}

.kv dt {
  color: var(--muted);
  font-weight: 700;
  min-width: 0;
}

.kv dd {
  margin: 0;
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
}

.catb {
  display: inline-block;
  border: 1px solid var(--line-strong);
  border-left-width: 5px;
  border-left-style: solid;
  border-radius: 6px;
  padding: 1px 7px;
  margin-right: 6px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface2);
  color: var(--text);
  vertical-align: 1px;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  border: 1px solid currentColor;
  white-space: nowrap;
}

:root .tag.good {
  color: #146c3a;
  background: #eef9f2;
  border-color: #9dd8b6;
}

:root .tag.mid {
  color: #92400e;
  background: #fff7eb;
  border-color: #f3c88c;
}

:root .tag.bad {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #f5b4b4;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag.good {
    color: #4ade80;
    background: #102618;
    border-color: #265938;
  }
  :root:not([data-theme="light"]) .tag.mid {
    color: #fbbf24;
    background: #261b0c;
    border-color: #634619;
  }
  :root:not([data-theme="light"]) .tag.bad {
    color: #ff7b7b;
    background: #2a1418;
    border-color: #6e2830;
  }
}

:root[data-theme="dark"] .tag.good {
  color: #4ade80;
  background: #102618;
  border-color: #265938;
}

:root[data-theme="dark"] .tag.mid {
  color: #fbbf24;
  background: #261b0c;
  border-color: #634619;
}

:root[data-theme="dark"] .tag.bad {
  color: #ff7b7b;
  background: #2a1418;
  border-color: #6e2830;
}

.card table,
.info table {
  border-collapse: collapse;
  width: 100%;
  max-width: 100%;
  font-size: 13.5px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.card th,
.card td,
.info th,
.info td {
  border-bottom: 1px solid var(--line);
  padding: 8px 8px;
  text-align: left;
  vertical-align: top;
  color: var(--text);
}

.card th,
.info th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  border-bottom-color: var(--line-strong);
}

.card tbody tr:last-child td,
.info tbody tr:last-child td {
  border-bottom: 0;
}

.card tbody tr:hover,
.info tbody tr:hover {
  background: var(--surface2);
}

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

.card > h2 + details:not(.basics),
.card > details:not(.basics):first-child {
  border-top: 0;
  padding-top: 4px;
}

.card > details:not(.basics):last-child {
  padding-bottom: 2px;
}

.wrap > details:not(.basics) {
  margin: 0 0 16px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

details:not(.basics) 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:not(.basics) summary:hover,
details:not(.basics)[open] summary {
  color: var(--accent);
}

details:not(.basics) p,
details:not(.basics) 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;
  }

  .ctl3 {
    gap: 10px 14px;
  }
}

@media (max-width: 420px) {
  .wrap,
  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;
    white-space: normal;
    text-align: center;
  }

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

  .mbar {
    padding: 8px;
    gap: 6px 8px;
  }

  .steps {
    padding: 10px 12px;
  }

  .steprow {
    gap: 6px;
  }

  #stepPrev,
  #stepNext {
    min-width: 32px;
    min-height: 34px;
    padding: 0 8px;
  }

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

  #stepPlay {
    margin-left: 0;
  }

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

  .kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .kv dd {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }

  .kv dd:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
  }

  .card th,
  .card td,
  .info th,
  .info td {
    padding: 6px 4px;
    font-size: 12px;
    overflow-wrap: anywhere;
  }

  .card th,
  .info th {
    font-size: 11.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .card,
  .seg button,
  .chk label,
  .chk1,
  .ctl select,
  .controls select,
  .mbar select,
  .arrSel,
  .selbar button,
  .modrow button,
  .mb-nav button,
  .basics summary,
  .lchip,
  .card tbody tr,
  .info tbody tr,
  details:not(.basics) summary {
    transition: none;
  }
}
