/* 第2章 デジタル化の部品（w-c2-media.js） */
.w-c2-media { background: #fff; border: 1px solid var(--line, #e2e8f0); border-radius: 14px; padding: 12px; margin: 8px 0 14px; }
.cm-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.cm-lab { font-size: 0.88rem; font-weight: 700; color: var(--sub, #4b5563); }
.cm-chip { font: inherit; font-size: 0.92rem; font-weight: 700; cursor: pointer; min-height: 44px; min-width: 44px; padding: 4px 12px; border: 2px solid var(--line, #e2e8f0); background: #fff; border-radius: 999px; color: var(--sub, #4b5563); }
.cm-chip[aria-pressed="true"] { border-color: var(--blue, #2563eb); color: var(--blue-d, #1d4ed8); background: var(--blue-l, #eaf1ff); }
.cm-ctrl { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin: 8px 0; }
.cm-b { font: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer; min-height: 44px; min-width: 44px; padding: 6px 14px; border-radius: 10px; border: 2px solid var(--line, #e2e8f0); background: #fff; color: var(--ink, #1f2937); }
.cm-b.main { border-color: var(--blue, #2563eb); background: var(--blue, #2563eb); color: #fff; }
.cm-b:disabled { opacity: .45; cursor: default; }
.cm-b.sm { padding: 4px 0; width: 44px; }
.cm-msg { margin: 8px 0 0; padding: 8px 10px; background: #f8fafc; border-left: 4px solid var(--blue, #2563eb); border-radius: 6px; font-size: 0.95rem; min-height: 1.6em; }
.cm-hint { font-size: 0.88rem; color: var(--sub, #4b5563); margin: 0 0 6px; }
.cm-sub { font-size: 0.92rem; font-weight: 700; margin: 12px 0 6px; color: var(--navy, #1e3a8a); }
.cm-eq { text-align: center; font-size: 0.98rem; margin: 8px 0 0; line-height: 1.7; }
.cm-eq b { color: var(--navy, #1e3a8a); font-size: 1.05rem; }
.cm-eq b.cm-o, b.cm-o { color: #b45309; }
.cm-note { font-size: 0.8rem; color: var(--sub, #4b5563); margin: 4px 0 0; text-align: center; }
.cm-mono { font-family: var(--mono, monospace); }
.cm-big { display: inline-block; min-width: 2.2em; text-align: center; font: 700 1.5rem/1 var(--mono, monospace); color: var(--navy, #1e3a8a); }
.cm-svg svg { width: 100%; max-width: 600px; height: auto; display: block; margin: 0 auto; }
.cm-svg.small svg { max-width: 240px; }
.cm-tree { overflow-x: auto; }
.cm-tx { font-size: 15px; fill: #4b5563; font-family: inherit; }
.cm-tblwrap { overflow-x: auto; }
.cm-tbl { border-collapse: collapse; margin: 6px auto; font-size: 0.95rem; }
.cm-tbl th, .cm-tbl td { border: 1px solid #cbd5e1; padding: 6px 10px; text-align: center; }
.cm-tbl th { background: #f1f5f9; font-size: 0.82rem; }

/* 足し算 */
.cm-addscroll { overflow-x: auto; padding-bottom: 4px; }
.cm-add { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: max-content; margin: 0 auto; }
.cm-arow { display: flex; align-items: center; gap: 4px; }
.cm-alab { width: 5.4em; text-align: right; font-size: 0.82rem; font-weight: 700; color: var(--sub, #4b5563); padding-right: 4px; flex: none; }
.cm-cell { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; border-radius: 8px; font: 700 1.3rem/1 var(--mono, monospace); color: #1f2937; box-sizing: border-box; }
button.cm-bit { border: 2px solid #2563eb; background: #eaf1ff; cursor: pointer; padding: 0; }
button.cm-bit.on { background: #fff4dc; border-color: #f59e0b; color: #b45309; border-width: 3px; }
.cm-carry .cm-cell { height: 26px; font-size: 1rem; }
.cm-c.on { color: #b45309; background: #fff4dc; border: 2px dashed #f59e0b; }
.cm-res { border-top: 3px solid #1f2937; padding-top: 4px; }
.cm-sum { border: 2px solid #1e3a8a; background: #fff; }
.cm-over.on { border: 2px dashed #b45309; color: #b45309; text-decoration: line-through; }
.cm-w .cm-cell { height: 20px; font: 0.78rem/1 var(--mono, monospace); color: #4b5563; }
.cm-add.b8 .cm-cell { width: 44px; font-size: 1.15rem; }
.cm-add.b8 button.cm-bit { height: 44px; }
.cm-add.b8 .cm-w .cm-cell { font-size: 0.66rem; }
.cm-add.b8 .cm-alab { width: 4.2em; font-size: 0.75rem; }
.cm-range { text-align: center; font-size: 0.85rem; color: var(--sub, #4b5563); margin: 2px 0 0; }
@media (max-width: 520px) {
  .cm-arow { gap: 3px; }
  .cm-alab, .cm-add.b8 .cm-alab { width: 3.2em; font-size: 0.68rem; line-height: 1.2; }


  .cm-add.b8 .cm-cell, .cm-add.b8 button.cm-bit { width: 44px; font-size: 1.15rem; }
}

/* 2の補数 */
.cm-comp { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 6px 0; }
.cm-crow { display: grid; grid-template-columns: 9em auto; align-items: center; gap: 2px 8px; }
.cm-clab { font-size: 0.85rem; font-weight: 700; color: var(--sub, #4b5563); text-align: right; }
.cm-cbits { display: flex; gap: 4px; }
.cm-cbits .cm-cell { border: 2px solid #94a3b8; background: #fff; width: 40px; height: 42px; }
.cm-cbits .cm-cell.on { border-color: #2563eb; background: #eaf1ff; }
.cm-crow.hot .cm-cell { border-color: #f59e0b; background: #fff4dc; color: #b45309; }
.cm-cbits .cm-out { border: 2px dashed #b45309; color: #b45309; text-decoration: line-through; background: #fff; }
.cm-cnote { grid-column: 2; font-size: 0.82rem; color: #b45309; font-weight: 700; }
.cm-comp.b8 .cm-cbits .cm-cell { width: 28px; font-size: 1rem; }
@media (max-width: 420px) { .cm-crow { grid-template-columns: 1fr; } .cm-clab { text-align: left; } .cm-cnote { grid-column: 1; } }

/* 文字コード */
.cm-text { font: inherit; font-size: 1.1rem; min-height: 44px; padding: 4px 10px; border: 2px solid #94a3b8; border-radius: 10px; flex: 1 1 12em; min-width: 0; }
.cm-ch { font-size: 1.3rem; font-weight: 700; }
.cm-nb.n1 { color: #1e3a8a; } .cm-nb.n3 { color: #b45309; font-weight: 700; } .cm-nb.n4 { color: #b45309; font-weight: 700; }
.cm-decoded { text-align: center; font-size: 1.4rem; font-weight: 700; padding: 10px; border: 2px solid #2563eb; border-radius: 10px; background: #eaf1ff; margin: 6px 0; word-break: break-all; min-height: 1.4em; }
.cm-decoded.bad { border-color: #f59e0b; background: #fff4dc; border-style: dashed; color: #92400e; }

/* 標本化・量子化 */
.cm-lv { stroke: #e2e8f0; stroke-width: 1; }
.cm-ax { stroke: #94a3b8; stroke-width: 2; }
.cm-org { fill: none; stroke: #2563eb; stroke-width: 3; }
.cm-q { fill: none; stroke: #f59e0b; stroke-width: 3.5; stroke-linejoin: round; }
.cm-qd { fill: #fff; stroke: #b45309; stroke-width: 2.5; }
.cm-st { stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 3 3; }
.cm-err { fill: #fca5a5; opacity: .55; }
.cm-legend { font-size: 0.82rem; color: var(--sub, #4b5563); margin: 4px 0 0; }
.cm-legend .k { display: inline-block; width: 22px; height: 0; vertical-align: middle; margin-right: 4px; }
.cm-legend .k-org { border-top: 3px solid #2563eb; } .cm-legend .k-q { border-top: 3.5px solid #f59e0b; } .cm-legend .k-d { height: 10px; background: #fca5a5; }
.cm-sinfo { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 6px 0; }
@media (max-width: 520px) { .cm-sinfo { grid-template-columns: 1fr; } }
.cm-irow { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 0.9rem; }
.cm-ik { color: var(--sub, #4b5563); font-weight: 700; font-size: 0.82rem; }
.cm-iv { color: var(--navy, #1e3a8a); }
.cm-bar { flex: 1 1 120px; height: 14px; background: #f1f5f9; border-radius: 7px; overflow: hidden; border: 1px solid #cbd5e1; }
.cm-barf { display: block; height: 100%; background: #f87171; transition: width .25s; }
.cm-codes { font: 0.9rem/1.5 var(--mono, monospace); margin: 4px 0 0; word-break: break-all; color: #1f2937; }

/* 画素 */
.cm-cvwrap { text-align: center; }
.cm-canvas { width: 100%; max-width: 320px; aspect-ratio: 1; image-rendering: pixelated; border: 2px solid #94a3b8; border-radius: 6px; }

/* RGB */
.cm-rgb { display: grid; grid-template-columns: 1fr 240px; gap: 12px; align-items: center; }
@media (max-width: 560px) { .cm-rgb { grid-template-columns: 1fr; } }
.cm-sl { margin-bottom: 8px; }
.cm-sllab { font-weight: 700; font-size: 0.92rem; }
.cm-sl.r .cm-sllab { color: #b91c1c; } .cm-sl.g .cm-sllab { color: #15803d; } .cm-sl.b .cm-sllab { color: #1d4ed8; }
.cm-slline { display: flex; align-items: center; gap: 6px; }
.cm-slline input[type=range] { flex: 1; min-width: 0; height: 44px; accent-color: #2563eb; }
.cm-sl.r input { accent-color: #dc2626; } .cm-sl.g input { accent-color: #16a34a; }
.cm-slvals { display: flex; gap: 10px; font-size: 0.9rem; }
.cm-slv { font: 700 1rem var(--mono, monospace); min-width: 2.5em; }
.cm-slb { font: 0.95rem var(--mono, monospace); color: var(--sub, #4b5563); }
.cm-swatch { height: 64px; border-radius: 10px; border: 2px solid #94a3b8; margin-bottom: 8px; }

/* 動画 */
.cm-strip { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; margin: 6px 0; }
.cm-fr { width: 14px; height: 18px; border: 1.5px solid #94a3b8; border-radius: 3px; background: #fff; }
.cm-fr.on { background: #f59e0b; border-color: #b45309; }
.cm-calc { border-top: 1px dashed #cbd5e1; margin-top: 12px; padding-top: 4px; }
.cm-calcout p { margin: 4px 0; font-size: 0.95rem; word-break: break-word; }
.cm-calcout b { color: var(--navy, #1e3a8a); }

/* ランレングス */
.cm-rle { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; }
@media (max-width: 620px) { .cm-rle { grid-template-columns: 1fr; } }
.cm-grid { display: grid; grid-template-columns: repeat(6, 44px); gap: 1px; justify-content: center; }
.cm-px { width: 44px; height: 44px; border: 1px solid #94a3b8; background: #fff; border-radius: 3px; cursor: pointer; padding: 0; }
.cm-px.on { background: #1f2937; border-color: #1f2937; }
.cm-rcodes { font-size: 0.9rem; min-width: 0; }
.cm-rhead { margin: 0 0 4px; font-weight: 700; font-size: 0.85rem; color: var(--sub, #4b5563); }
.cm-rlist { display: flex; flex-wrap: wrap; gap: 4px; }
.cm-run { display: inline-flex; flex-direction: column; align-items: center; padding: 2px 6px; border: 1.5px solid #94a3b8; border-radius: 6px; background: #fff; min-width: 3.4em; }
.cm-run.k { background: #1f2937; color: #fff; border-color: #1f2937; }
.cm-run small { font: 0.72rem var(--mono, monospace); opacity: .85; }
.cm-rbar { margin: 8px 0 0; }
.cm-rbrow { display: grid; grid-template-columns: 6.5em 1fr; align-items: center; gap: 6px; margin: 3px 0; font-size: 0.85rem; }
.cm-rbtrack { display: block; }
.cm-rb1, .cm-rb2 { display: block; height: 24px; line-height: 24px; border-radius: 5px; color: #fff; font-weight: 700; padding-left: 6px; white-space: nowrap; transition: width .25s; box-sizing: border-box; min-width: 4.5em; }
.cm-rb1 { background: #94a3b8; }
.cm-rb2 { background: #2563eb; }
.cm-rb2.over { background: #f59e0b; color: #1f2937; }

/* ハフマン */
.cm-src { text-align: center; font: 700 1.05rem var(--mono, monospace); word-break: break-all; margin: 4px 0; }
.cm-hlog { font-size: 0.9rem; margin: 6px 0; padding-left: 1.6em; }
.cm-hlog li.on { color: #b45309; font-weight: 700; }
.cm-cnts { text-align: center; font-weight: 700; }
.cm-edge { stroke: #94a3b8; stroke-width: 2.5; }
.cm-bitl { font: 700 17px var(--mono, monospace); fill: #b45309; }
.cm-leaf { fill: #eaf1ff; stroke: #2563eb; stroke-width: 2; }
.cm-node { fill: #fff; stroke: #94a3b8; stroke-width: 2; }
.cm-tch { font: 700 17px sans-serif; font-family: inherit; fill: #1f2937; }
.cm-tw { font-size: 14px; fill: #4b5563; font-family: inherit; }

@media (prefers-reduced-motion: reduce) {
  .cm-barf, .cm-rb1, .cm-rb2 { transition: none; }
}
