/* 로직 소자 탐험기 (/logic/) — app colors. Site-wide look comes from /lab.css (--lab-*). */
:root{
  --bg:var(--lab-bg);--surface:var(--lab-surface);--surface2:var(--lab-surface2);--text:var(--lab-text);--muted:var(--lab-muted);--line:var(--lab-line);
  --primary:var(--lab-ink);--on-primary:var(--lab-on-ink);
  --hl:#d61f69;--flow:#d61f69;
  --nfin:#1f9d55;--pfin:#d97706;--gate:#dc2626;--dgate:#9aa1ad;--tc:#475569;--m1:#3b82f6;--nw:#fdf3d1;--via:#0f172a;
  --si:#c9ccd4;--sti:#d5e3f6;--nplus:#86d9a5;--pplus:#f7b77a;--gmetal:#8e98a8;--hk:#e0a100;
  --e:#1d4ed8;--h:#c2410c;
  --vhi:#c81e1e;--vlo:#1d4ed8;--vmid:#7e22ce;
  --soft:#eef2ff;--pin-tx:#ffffff;--ct3:#8d96a6;--poly:#b48a4e;--sige:#7fb3c8;--vcur:#7e22ce;
}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
  --hl:#ff6fae;--flow:#ff6fae;
  --nfin:#34c77b;--pfin:#f2a93b;--gate:#ef5350;--dgate:#5d6573;--tc:#9aa6b8;--m1:#60a5fa;--nw:#2b2614;--via:#e2e8f0;
  --si:#3a404d;--sti:#1f3047;--nplus:#1f7a45;--pplus:#9a4a14;--gmetal:#6d7789;--hk:#e8b923;
  --e:#7fb0ff;--h:#ff9a5c;
  --vhi:#ff7b7b;--vlo:#7fb0ff;--vmid:#d19bff;
  --soft:#1b2033;--pin-tx:#10131a;--ct3:#7d8798;--poly:#8a6a3c;--sige:#3f7387;--vcur:#d19bff;
}}
:root[data-theme="dark"]{
  --hl:#ff6fae;--flow:#ff6fae;
  --nfin:#34c77b;--pfin:#f2a93b;--gate:#ef5350;--dgate:#5d6573;--tc:#9aa6b8;--m1:#60a5fa;--nw:#2b2614;--via:#e2e8f0;
  --si:#3a404d;--sti:#1f3047;--nplus:#1f7a45;--pplus:#9a4a14;--gmetal:#6d7789;--hk:#e8b923;
  --e:#7fb0ff;--h:#ff9a5c;
  --vhi:#ff7b7b;--vlo:#7fb0ff;--vmid:#d19bff;
  --soft:#1b2033;--pin-tx:#10131a;--ct3:#7d8798;--poly:#8a6a3c;--sige:#3f7387;--vcur:#d19bff;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--text);font-family:var(--lab-sans);line-height:1.5;word-break:keep-all;-webkit-font-smoothing:antialiased}
.wrap{max-width:1200px;margin:0 auto;padding:0 16px 40px}
.app-head{padding:28px 0 18px}
.app-head h1{margin:0 0 8px;font-size:clamp(1.5rem,3.2vw,2rem);letter-spacing:-.03em;line-height:1.2}
.intro{margin:0;max-width:62em;color:var(--muted);font-size:.95rem}
.btn{font:inherit;font-size:.86rem;font-weight:600;border:1px solid var(--line);background:var(--surface);color:var(--text);border-radius:8px;padding:6px 12px;cursor:pointer}
.btn:hover{border-color:var(--lab-line-strong)}
.btn[aria-pressed="true"]{background:var(--primary);color:var(--on-primary);border-color:var(--primary)}
.btn:focus-visible,.seg button:focus-visible,input:focus-visible,.tt tr:focus-visible{outline:3px solid var(--lab-accent);outline-offset:2px}
.card{background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:14px;margin-bottom:14px;min-width:0}
.card h2{margin:0 0 8px;font-size:1rem;display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}
.card h2 small{color:var(--muted);font-weight:500;font-size:.82rem}
.controls{display:flex;flex-wrap:wrap;gap:14px 22px;align-items:flex-end}
.ctl{display:grid;gap:5px}
.ctl>span{font-size:.78rem;font-weight:700;color:var(--muted)}
.ctl[hidden]{display:none}
.seg{display:inline-flex;border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--surface2)}
.seg button{font:inherit;font-size:.86rem;font-weight:600;border:0;background:transparent;color:var(--text);padding:6px 12px;cursor:pointer;min-width:2.4em}
.seg button+button{border-left:1px solid var(--line)}
.seg button[aria-pressed="true"]{background:var(--primary);color:var(--on-primary)}
.seg.io button[aria-pressed="true"]{font-weight:800}
.basics{margin:0 0 10px;padding:8px 14px;border-radius:8px;border:1px solid var(--line);background:var(--surface);font-size:.92rem}
.basics summary{cursor:pointer;font-weight:700}
.basics ul{margin:8px 0 2px;padding-left:1.3em}.basics li{margin:4px 0}
.status{margin:0 0 14px;padding:12px 14px;border-radius:8px;background:var(--surface2);border:1px solid var(--line);font-size:.92rem}
.status .st-h{font-weight:800;font-size:1rem;margin-bottom:4px}
.status ol{margin:4px 0 6px;padding-left:1.4em}.status li{margin:3px 0}
.status .st-key{border-left:4px solid var(--hl);padding:5px 10px;background:var(--surface);border-radius:6px;font-weight:600;margin-top:6px}
.status .st-tr{border-left:4px solid var(--lab-accent);padding:5px 10px;background:var(--surface);border-radius:6px;margin-top:6px}
.v1{color:var(--vhi);font-weight:800}.v0{color:var(--vlo);font-weight:800}.vz{color:var(--vmid);font-weight:800}
.on{font-weight:700}.off{color:var(--muted)}
.grid2{display:grid;grid-template-columns:1fr;gap:14px}
.grid2>*{min-width:0}
@media (min-width:900px){.grid2{grid-template-columns:1fr 1fr}}
svg{display:block;width:100%;height:auto;touch-action:manipulation}
.hint{font-size:.8rem;color:var(--muted);margin:6px 0 0}
.selbar{font-size:.85rem;margin:0 0 10px;min-height:1.6em;color:var(--text)}
.selbar b{color:var(--text)}
.legend{display:flex;flex-wrap:wrap;gap:6px 14px;margin-top:8px;font-size:.78rem;color:var(--text)}
.legend i{display:inline-block;width:12px;height:12px;border-radius:3px;margin-right:5px;vertical-align:-1px;border:1px solid var(--line)}
.chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.lchip{font:inherit;font-size:.78rem;color:var(--text);background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:3px 10px;cursor:pointer;display:inline-flex;align-items:center}
.lchip i{display:inline-block;width:11px;height:11px;border-radius:3px;margin-right:5px;border:1px solid var(--line)}
.lchip[aria-pressed=true]{border-color:var(--text);background:var(--surface2);font-weight:700}
.lchip[aria-pressed=false]{text-decoration:line-through;color:var(--muted)}.lchip[aria-pressed=false] i{opacity:.25}
.row3{display:flex;flex-wrap:wrap;gap:10px 20px;align-items:flex-end;margin-bottom:10px}
.chk{display:flex;gap:14px;flex-wrap:wrap;font-size:.84rem;color:var(--text)}
.chk label{display:flex;gap:5px;align-items:center;cursor:pointer}
/* SVG text */
.lbl{fill:var(--text);font-size:12px;font-weight:600;paint-order:stroke;stroke:var(--surface);stroke-width:3px;stroke-linejoin:round;pointer-events:none}
.lbl.m{fill:var(--muted);font-weight:500}
.lbl.s{font-size:10px}
.lbl.b{font-weight:800;font-size:13px}
/* schematic */
.sch .w{fill:none;stroke:var(--text);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.sch .w.vhi{stroke:var(--vhi)}.sch .w.vlo{stroke:var(--vlo)}.sch .w.vmid{stroke:var(--vmid)}
.sch .rail{stroke-width:3.2}
.sch .mos path{fill:none;stroke:var(--text);stroke-width:2;stroke-linecap:round}
.sch .mos path.b{stroke-width:3.4}
.sch .mos circle.bub{fill:var(--surface);stroke:var(--text);stroke-width:2}
.sch .mos.off path,.sch .mos.off circle.bub{opacity:.4}
.sch .pin{stroke-width:2}.sch .pin.vhi{fill:var(--vhi);stroke:var(--vhi)}.sch .pin.vlo{fill:var(--vlo);stroke:var(--vlo)}
.sch .pint{fill:var(--pin-tx);font-size:11px;font-weight:800;pointer-events:none;text-anchor:middle;dominant-baseline:central}
.sch .dot{stroke:none}.sch .dot.vhi{fill:var(--vhi)}.sch .dot.vlo{fill:var(--vlo)}.sch .dot.vmid{fill:var(--vmid)}
.sch .hit{fill:transparent;cursor:pointer}
.sch .wh{fill:none;stroke:transparent;stroke-width:14;cursor:pointer}
.sch .conn{fill:none;stroke:var(--hl);stroke-width:7;opacity:.22;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
.sch .flow{fill:none;stroke:var(--flow);stroke-width:4;stroke-dasharray:3 9;stroke-linecap:round;stroke-linejoin:round;animation:flow .55s linear infinite;pointer-events:none}
@keyframes flow{to{stroke-dashoffset:-12}}
.focus [data-k]:not(.hl):not(.keep){opacity:.22}
.sch .hl.w,.sch .hl path{stroke:var(--hl)!important}
.sch .hl.w{stroke-width:3.6}
.sch .hl.mos path.b{stroke-width:4.4}
/* layout */
.lay [data-k]{cursor:pointer}
.L-nw{fill:var(--nw)}
.L-fin.n{fill:var(--nfin)}.L-fin.p{fill:var(--pfin)}
.L-gate{fill:var(--gate);opacity:.8}.L-gate.d{fill:var(--dgate);opacity:.8}
.L-ts{fill:var(--tc);opacity:.85}
.L-gc{fill:var(--tc);stroke:var(--surface);stroke-width:1px;vector-effect:non-scaling-stroke}
.L-m1{fill:var(--m1);opacity:.38}
.L-via{fill:var(--via)}
.lay .bnd{fill:none;stroke:var(--text);stroke-width:1.2px;stroke-dasharray:5 4;vector-effect:non-scaling-stroke;pointer-events:none}
.lay .hl{stroke:var(--hl);stroke-width:2.4px;vector-effect:non-scaling-stroke;opacity:1!important}
.lay .lbl{font-size:9px;stroke-width:2.4px}
.lay .lbl.b{font-size:10.5px}
.lay .pathx{fill:none;stroke:var(--flow);stroke-width:3px;stroke-dasharray:3 6;vector-effect:non-scaling-stroke;animation:flow .55s linear infinite;pointer-events:none}
.lay .connx{fill:none;stroke:var(--hl);stroke-width:7px;opacity:.25;vector-effect:non-scaling-stroke;stroke-linecap:round;pointer-events:none}
.lay .chon{opacity:.75;pointer-events:none}.lay .chon.n{fill:var(--e)}.lay .chon.p{fill:var(--h)}
/* 3D */
#wrap3{position:relative;border-radius:8px;overflow:hidden;border:1px solid var(--line);background:var(--surface)}
#c3{display:block;width:100%;cursor:grab;touch-action:pan-y}
#c3:active{cursor:grabbing}
#lab3{position:absolute;inset:0;pointer-events:none;overflow:hidden}
.l3{position:absolute;transform:translate(-50%,-100%);font-size:.72rem;font-weight:700;background:var(--surface);color:var(--text);border:1px solid var(--line);border-radius:6px;padding:0 5px;white-space:nowrap}
.l3.io{border-width:2px}.l3.v1{border-color:var(--vhi);color:var(--text)}.l3.v0{border-color:var(--vlo);color:var(--text)}
.l3.hl{border-color:var(--hl);box-shadow:0 0 0 2px var(--hl)}
.no3{padding:30px 16px;text-align:center;color:var(--muted)}
/* cross-section */
.xs .si{fill:var(--si)}.xs .sti{fill:var(--sti)}.xs .np{fill:var(--nplus)}.xs .pp{fill:var(--pplus)}
.xs .gm{fill:var(--gmetal)}.xs .gm.act{fill:var(--gate);opacity:.85}.xs .hk{fill:var(--hk)}.xs .ts{fill:var(--tc)}
.xs .chn{fill:color-mix(in srgb,var(--nfin) 30%,var(--si))}.xs .chp{fill:color-mix(in srgb,var(--pfin) 30%,var(--si))}
.xs .inv-n{fill:var(--e);opacity:.28}.xs .inv-p{fill:var(--h);opacity:.28}
.xs .e{fill:var(--e)}.xs .ho{fill:var(--surface);stroke:var(--h);stroke-width:1.6}
.xs .frame{fill:none;stroke:var(--line)}
.xs [data-k]{cursor:pointer}
.xs .hl{stroke:var(--hl);stroke-width:2.4px}
/* truth table + waves */
.tt{border-collapse:collapse;width:100%;font-size:.88rem;margin-bottom:10px}
.tt th,.tt td{border-bottom:1px solid var(--line);padding:6px 8px;text-align:center}
.tt th{color:var(--muted);font-size:.78rem;font-weight:700}
.tt td.dv{text-align:left;color:var(--text);font-size:.82rem}
.tt tbody tr{cursor:pointer}
.tt tbody tr:hover{background:var(--surface2)}
.tt tbody tr[aria-current=true]{background:var(--surface2);box-shadow:inset 4px 0 0 var(--hl)}
.wv .ax{stroke:var(--line);stroke-width:1}
.wv .sig{fill:none;stroke:var(--text);stroke-width:2.2;stroke-linejoin:round}
.wv .sig.out{stroke:var(--hl);stroke-width:2.6}
.wv .cur{fill:var(--hl);opacity:.12}
.wv [data-i]{cursor:pointer}
details.more{margin-top:4px}
details.more summary{cursor:pointer;font-weight:700}
details.more p,details.more li{font-size:.92rem;color:var(--text)}
footer{border-top:1px solid var(--line);margin-top:24px;padding-top:20px;color:var(--muted);font-size:.8rem;text-align:center}
footer a{color:var(--muted)}
@media (prefers-reduced-motion:reduce){.sch .flow,.lay .pathx{animation-duration:2.4s}}
/* v2: more gates, process steps, video, voltage curve */
.seg.wrap{flex-wrap:wrap}
.steps{margin:0 0 10px}
.steprow{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.steprow input[type=range]{flex:1 1 140px;min-width:120px}
.steprow b{font-size:.9rem;min-width:9em}
.ctl-l{font-size:.78rem;font-weight:700;color:var(--muted);margin:0}
.stepbox{margin:6px 0 0;padding:8px 12px;border:1px solid var(--line);border-radius:8px;background:var(--surface2);color:var(--text);font-size:.9rem;line-height:1.5;min-height:3.2em}
input[type=range]{accent-color:var(--primary)}
.sl{display:grid;gap:2px;min-width:200px;flex:1 1 260px}
.sl label{font-size:.78rem;font-weight:700;color:var(--muted);display:flex;justify-content:space-between;gap:8px}
.sl label b{color:var(--text)}
.sl input{width:100%}
.opv{max-width:960px;margin:0 auto}
.opv video{display:block;width:100%;height:auto;aspect-ratio:16/9;background:#0b1020;border-radius:8px}
.opcap{margin:8px 0 0;padding:10px 14px;min-height:4.6em;border:1px solid var(--line);border-radius:8px;background:var(--surface2);color:var(--text);font-size:1rem;font-weight:600;line-height:1.5}
.opchap{display:flex;flex-wrap:wrap;gap:6px;max-width:960px;margin:10px auto 6px}
.opchap .btn .t{color:var(--muted);font-weight:500;font-variant-numeric:tabular-nums;margin-right:2px}
.opchap .btn[aria-current=true]{border-color:var(--primary);box-shadow:inset 0 0 0 1px var(--primary)}
.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}
.vtc .mk{stroke:var(--muted);stroke-width:1}
.vtc .mkd{fill:var(--hl);stroke:var(--surface);stroke-width:2}
.vtc .mki{fill:var(--vcur);stroke:var(--surface);stroke-width:1.5}
.vtcv{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:0 0 12px}
.vtcv div{border:1px solid var(--line);border-radius:8px;padding:6px 10px;background:var(--surface2)}
.vtcv dt{font-size:.75rem;font-weight:700;color:var(--muted)}
.vtcv dd{margin:0;font-size:1.05rem;font-weight:800;color:var(--text);font-variant-numeric:tabular-nums}
.drv{display:grid;grid-template-columns:9.5em 1fr 3.4em;gap:8px;align-items:center;font-size:.84rem;margin:6px 0}
.drv i{display:block;height:12px;border-radius:6px;background:var(--surface2);border:1px solid var(--line);overflow:hidden}
.drv b{display:block;height:100%}
.drv b.pu{background:var(--h)}.drv b.pd{background:var(--e)}
.drv em{font-style:normal;font-weight:700;text-align:right;font-variant-numeric:tabular-nums}
.vleg{display:flex;flex-wrap:wrap;gap:6px 14px;font-size:.8rem;color:var(--text);margin:10px 0 0}
.vleg i{display:inline-block;width:18px;height:0;vertical-align:middle;margin-right:5px;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)}
.btn:disabled{opacity:.45;cursor:default}
.opv [hidden]{display:none!important}
.opyt{aspect-ratio:16/9;background:#0b1020;border-radius:8px;overflow:hidden}
.opyt iframe{display:block;width:100%;height:100%;border:0}
#new3{display:none}
#wrap3.is-new #new3{display:block;height:clamp(300px,58vw,600px)}
