/* 回路パズルと実験ウィジェット（論理回路CPUクエスト） */
.cp{background:var(--paper2);border:1.5px solid #9fcfc8;border-radius:12px;padding:12px 12px 10px;margin:16px 0}
.cp.solved{border-color:var(--ok-bd);background:linear-gradient(180deg,#f3fbf6,var(--paper2))}
.cp-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.cp-badge{background:linear-gradient(#45b3a8,#1f766e);color:#fff;border-radius:6px;padding:2px 9px;font-size:11.5px;font-weight:950}
.cp.solved .cp-badge{background:var(--ok)}
.cp-title{font-size:15px;font-weight:950;color:#1c2f2b}
.cp-desc{font-size:13.5px;margin:6px 0 8px;color:#24403a}
.cp-palette{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}
.cp-gate{border:1.5px solid #6fb8ae;background:#e9f7f4;color:#14524b;border-radius:8px;padding:.4rem .8rem;font-size:13px;font-weight:900;cursor:pointer;font-family:var(--f)}
.cp-gate:hover{background:#d4efe9}
.cp-canvas{border:1px solid #c5d8d4;border-radius:10px;overflow:hidden;background:#fbfdfc;touch-action:none}
.cp-canvas svg{display:block;width:100%;height:auto;user-select:none;-webkit-user-select:none}
.cp-bg{fill:#fbfdfc}
.cp-wire{stroke:#8ea3a0;stroke-width:4;fill:none;cursor:pointer}
.cp-wire.on{stroke:#f0a91e}
.cp-wire-temp{stroke:#1aa65d;stroke-width:3;stroke-dasharray:6 5;fill:none}
.cp-box{fill:#e3eef0;stroke:#6f8f93;stroke-width:1.6}
.cp-input .cp-box{fill:#e5f5ea;stroke:#3a9e63;cursor:pointer}
.cp-input .cp-box.on{fill:#ffe8a3;stroke:#d99a12}
.cp-output .cp-box{fill:#fdf0e5;stroke:#c56a2a}
.cp-output .cp-box.on{fill:#ffd66b;stroke:#d99a12}
.cp-node{cursor:grab}
.cp-label{font-size:14px;font-weight:900;fill:#1c2f2b;pointer-events:none}
.cp-del{font-size:12px;fill:#97a8a6;cursor:pointer}
.cp-pin{stroke-width:2}
.cp-pin.in{fill:#8ea3a0;stroke:#5d7472}
.cp-pin.out{fill:#378add;stroke:#22609e}
.cp-pin.sel{fill:#ffd54f;stroke:#ffb700;stroke-width:3}
.cp-pinlabel{font-size:10px;font-weight:900;fill:#22609e;pointer-events:none}
.cp-tools{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:8px}
.cp-tools .btn{padding:.5rem .95rem;font-size:13px}
.cp-status{font-size:13px;font-weight:900;color:var(--muted)}
.cp-status.ok{color:var(--ok)}
.cp-status.ng{color:var(--ng)}
.cp-table{overflow-x:auto}
.cp-tt{border-collapse:collapse;margin-top:10px;font-size:13px;font-variant-numeric:tabular-nums}
.cp-tt caption{text-align:left;font-weight:900;padding-bottom:4px;font-size:13px}
.cp-tt th,.cp-tt td{border:1px solid #c9d6d3;padding:3px 10px;text-align:center}
.cp-tt th{background:#eef5f3}
.cp-tt th small{font-weight:700;color:var(--muted)}
.cp-tt tr.ok td{background:#f1faf4}
.cp-tt tr.ng td{background:var(--ng-bg);color:var(--ng)}
.cp-help{margin-top:8px;font-size:12.5px;color:#3b5550}
.cp-help summary{cursor:pointer;font-weight:900}
.cp-help ul{margin:6px 0 0 1.2em}

/* 大きく表示（スマホで組みやすくする全画面表示） */
.cp.full{position:fixed;inset:0;z-index:200;margin:0;border-radius:0;overflow:auto;-webkit-overflow-scrolling:touch;padding:10px}
.cp.full .cp-canvas{min-width:680px}
.cp.full .cp-help::after{content:"横に動かすときは、作業台の外（ボタンのあたり）を左右になぞる";display:block;margin-top:4px;color:var(--muted)}
html.cp-lock,html.cp-lock body{overflow:hidden}
@media (max-width:700px){.cp-tools .btn{padding:.45rem .7rem;font-size:12.5px}}

/* 真理値表（本文用） */
.tt{border-collapse:collapse;margin:8px auto;font-size:14px;font-variant-numeric:tabular-nums}
.tt th,.tt td{border:1px solid #c9d6d3;padding:3px 12px;text-align:center}
.tt th{background:#eef5f3}
.tt td.hl{background:#fff1c9;font-weight:900}

/* 実験ウィジェット共通 */
.lab{background:var(--paper2);border:1.5px solid #9fcfc8;border-radius:12px;padding:12px 14px;margin:16px 0}
.lab.solved{border-color:var(--ok-bd)}
.lab-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:6px}
.lab-badge{background:#2f6f8f;color:#fff;border-radius:6px;padding:2px 9px;font-size:11.5px;font-weight:950}
.lab.solved .lab-badge{background:var(--ok)}
.lab-title{font-size:15px;font-weight:950;color:#1c2f2b}
.lab p{font-size:13.5px;margin:4px 0}
.lab .row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:center;margin:8px 0}
.lab .readout{font-size:14px;font-weight:900;text-align:center;font-variant-numeric:tabular-nums}
.lab svg{display:block;margin:0 auto;max-width:100%;height:auto}
.lab-status{font-size:13px;font-weight:900;color:var(--muted);text-align:center}
.lab-status.ok{color:var(--ok)}

/* 2進数のランプ */
.bits{display:flex;gap:8px;justify-content:center;flex-wrap:wrap}
.bit{display:flex;flex-direction:column;align-items:center;gap:3px}
.bit button{width:54px;height:54px;border-radius:50%;border:3px solid #6f8f93;background:#2b3a3c;color:#fff;font-size:20px;font-weight:950;cursor:pointer;font-family:var(--f)}
.bit button.on{background:radial-gradient(circle at 40% 35%,#fff6c9,#f0b81e 70%);border-color:#c48a06;color:#4a3300}
.bit small{font-size:12px;font-weight:900;color:#4b6460}
.target-list{display:flex;gap:6px;flex-wrap:wrap;justify-content:center}
.target-chip{border:1.5px solid #9fcfc8;border-radius:999px;padding:2px 12px;font-size:13px;font-weight:900;background:#fff}
.target-chip.done{background:var(--ok-bg);border-color:var(--ok-bd);color:var(--ok)}
.target-chip.now{border-color:#d99a12;background:#fff4d6}

/* CPU の1サイクル */
.cpu-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin-top:8px}
.cpu-box{border:1px solid #c5d8d4;border-radius:10px;background:#fff;padding:8px 10px}
.cpu-box h4{font-size:12.5px;font-weight:950;color:#1f766e;margin-bottom:4px}
.cpu-box table{width:100%;border-collapse:collapse;font-size:12.5px;font-variant-numeric:tabular-nums}
.cpu-box td{border-bottom:1px dashed #dde7e5;padding:2px 4px}
.cpu-box tr.hl td{background:#fff1c9;font-weight:900}
.cpu-box tr.pc td:first-child::before{content:"▶ ";color:#d9822b}
.cpu-log{font-size:13px;font-weight:800;min-height:3em;margin-top:8px;background:#f2f7f6;border-radius:8px;padding:6px 10px}
