/* =========================================================
   LLM 101｜PART 02 · UNIT 06
   單元專屬樣式（unit-06.css）
   只包含 p2-* 元件；顏色全部來自 main.css 的 tokens。
   斷點沿用 859px／460px。
   ========================================================= */

/* ---------- 共用小元件 ---------- */
.p2-block-title {
  margin: 0;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--primary);
}

.p2-block-sub {
  margin: 2px 0 0;
  font-size: .78rem;
  line-height: 1.6;
  color: var(--muted);
}

.p2-note {
  margin: 8px 0 0;
  font-size: .78rem;
  line-height: 1.7;
  color: var(--muted);
}

.p2-control-label {
  display: block;
  margin: 0 0 6px;
  font-size: .82rem;
  font-weight: 800;
  color: var(--text);
}

.p2-status {
  margin: 14px 0 0;
  padding: 9px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.65;
}

.p2-status[data-state="warn"] {
  border-style: solid;
  border-color: var(--warn);
  background: var(--warn-weak);
  color: var(--text);
}

.p2-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.p2-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .76rem;
  font-weight: 700;
  line-height: 1.4;
}

.p2-chip-btn {
  font-family: var(--font-sans);
  cursor: pointer;
}

.p2-chip-btn:hover { border-color: var(--primary); color: var(--primary); }

.p2-chip-btn[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-weak);
  color: var(--primary);
}

.p2-plain-list {
  margin: 6px 0 0;
  padding-left: 1.15em;
  font-size: .84rem;
  line-height: 1.75;
  color: var(--text);
}

.p2-plain-list li { margin-bottom: .25em; }
.p2-plain-list li:last-child { margin-bottom: 0; }

.p2-warn {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  background: var(--warn-weak);
  color: var(--text);
  font-size: .8rem;
  line-height: 1.7;
}

.p2-field-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: .78rem;
  font-weight: 700;
}

/* ---------- 06-1 檔案套件 ---------- */
.p2-file-package {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.p2-file-col {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.p2-file-col-head { margin-bottom: 10px; }

.p2-file-list { display: grid; gap: 6px; }

.p2-file-node {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  overflow: hidden;
}

.p2-file-node > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 1em;
  grid-template-areas:
    "name size arrow"
    "role size arrow";
  gap: 1px 8px;
  align-items: center;
  min-height: 44px;
  padding: 7px 10px;
  cursor: pointer;
  list-style: none;
}

.p2-file-node > summary::-webkit-details-marker { display: none; }

.p2-file-node > summary::after {
  content: "＋";
  grid-area: arrow;
  justify-self: end;
  margin-left: 6px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 800;
}

.p2-file-node[open] > summary::after { content: "－"; }

.p2-file-node[open] > summary {
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.p2-file-name {
  grid-area: name;
  min-width: 0;
  font-size: .74rem;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.p2-file-role {
  grid-area: role;
  font-size: .76rem;
  line-height: 1.55;
  color: var(--muted);
}

.p2-file-size {
  grid-area: size;
  align-self: start;
  justify-self: end;
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  white-space: nowrap;
}

.p2-file-missing {
  margin: 0;
  padding: 8px 10px 10px;
  font-size: .78rem;
  line-height: 1.65;
  color: var(--text);
}

.p2-file-missing strong { color: var(--warn); }

.p2-file-side-note {
  margin: 10px 0 0;
  padding-top: 9px;
  border-top: 1px dashed var(--border);
  font-size: .78rem;
  line-height: 1.7;
  color: var(--muted);
}

/* ---------- 06-2 容器與格式切換 ---------- */
.p2-containers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.p2-container {
  min-width: 0;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
}

.p2-container-head { margin-bottom: 10px; }

.p2-container-name {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--primary);
}

.p2-container-sub {
  margin: 2px 0 0;
  font-size: .76rem;
  line-height: 1.6;
  color: var(--muted);
}

.p2-container-layers { display: grid; gap: 6px; }

.p2-container-layer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: var(--surface);
}

.p2-container-layer-ghost {
  border-left-style: dashed;
  border-left-color: var(--muted);
  background: transparent;
}

.p2-layer-name {
  font-size: .8rem;
  font-weight: 800;
}

.p2-layer-desc {
  font-size: .76rem;
  line-height: 1.55;
  color: var(--muted);
}

.p2-container-tools-label {
  margin: 12px 0 0;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--muted);
}

.p2-not-guaranteed {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.p2-not-guaranteed ul {
  margin: 6px 0 0;
  padding-left: 1.15em;
  font-size: .82rem;
  line-height: 1.7;
}

.p2-not-guaranteed li { margin-bottom: .2em; }

.p2-format-switch {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.p2-switch-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
}

.p2-switch-head .p2-control-label { margin: 0; }

.p2-switch-head .segmented { margin-bottom: 0; }

.p2-format-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.p2-format-block {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.p2-format-block .p2-chip-row { margin-top: 8px; }

.p2-format-text {
  margin: 6px 0 0;
  font-size: .83rem;
  line-height: 1.7;
}

/* ---------- 06-3 位元比例 ---------- */
.p2-bit-bars { display: grid; gap: 10px; }

.p2-bit-row {
  display: grid;
  grid-template-columns: 4.2em minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.p2-bit-row-label {
  margin: 0;
  font-size: .8rem;
  font-weight: 800;
  color: var(--muted);
  text-align: right;
}

.p2-bit-track {
  position: relative;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  overflow: hidden;
}

.p2-bit-fill {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  border-right: 2px solid var(--primary);
}

.p2-bit-fill-16 { width: 100%; background: var(--primary); opacity: .16; }
.p2-bit-fill-8 { width: 50%; background: var(--primary); opacity: .26; }
.p2-bit-fill-4 {
  width: 25%;
  background:
    repeating-linear-gradient(45deg, var(--primary) 0 3px, transparent 3px 8px),
    var(--surface-2);
  opacity: .55;
}

.p2-bit-label {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 12px;
  font-size: .82rem;
  font-weight: 800;
  color: var(--text);
}

.p2-ratio-warning {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: .8rem;
  line-height: 1.7;
  color: var(--text);
}

.p2-prec-table-wrap {
  margin-top: 16px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.p2-prec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
  line-height: 1.6;
}

.p2-prec-table caption {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: .74rem;
  font-weight: 700;
  text-align: left;
}

.p2-prec-table th,
.p2-prec-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.p2-prec-table thead th {
  background: var(--surface-2);
  font-size: .74rem;
  font-weight: 800;
  color: var(--muted);
}

.p2-prec-table tbody th {
  font-family: var(--font-mono);
  font-size: .78rem;
  white-space: nowrap;
}

.p2-prec-table tbody tr:last-child th,
.p2-prec-table tbody tr:last-child td { border-bottom: 0; }

.p2-bit-slider {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.p2-control-row {
  display: grid;
  grid-template-columns: 9.5em minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.p2-control-row label {
  font-size: .82rem;
  font-weight: 800;
}

.p2-control-row input[type="range"] {
  width: 100%;
  min-height: 32px;
  accent-color: var(--primary);
}

.p2-range-scale {
  grid-column: 2 / -1;
  display: flex;
  justify-content: space-between;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--muted);
}

.p2-range-output {
  min-width: 4em;
  font-family: var(--font-mono);
  font-size: .84rem;
  font-weight: 800;
  color: var(--primary);
  text-align: right;
}

.p2-bit-result {
  margin-top: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.p2-result-big {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.2;
  color: var(--text);
}

.p2-result-unit {
  margin-left: 4px;
  font-family: var(--font-sans);
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
}

.p2-result-formula {
  margin: 6px 0 0;
  font-size: .8rem;
  line-height: 1.6;
  color: var(--muted);
}

.p2-result-ratio {
  margin: 8px 0 0;
  font-size: .86rem;
}

.p2-result-ratio strong { color: var(--primary); }

.p2-assumptions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: .74rem;
  color: var(--muted);
}

.p2-assumptions li::before {
  content: "・";
  font-weight: 800;
}

/* ---------- 06-4 量化命名 ---------- */
.p2-name-breakdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.p2-name-cell {
  display: grid;
  gap: 3px;
  justify-items: center;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  text-align: center;
}

.p2-name-char {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--primary);
}

.p2-name-desc {
  font-size: .76rem;
  line-height: 1.5;
  color: var(--muted);
}

.p2-quant-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.p2-quant-card {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.p2-quant-name {
  margin: 0 0 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
}

.p2-quant-card dl {
  margin: 0;
  display: grid;
  gap: 5px;
}

.p2-quant-card dl > div {
  display: grid;
  grid-template-columns: 6.5em minmax(0, 1fr);
  gap: 6px;
}

.p2-quant-card dt {
  font-size: .72rem;
  font-weight: 800;
  color: var(--muted);
  line-height: 1.6;
}

.p2-quant-card dd {
  margin: 0;
  font-size: .8rem;
  line-height: 1.65;
}

.p2-decision-belt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.p2-decision-step {
  padding: 3px 10px;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: var(--surface);
  font-size: .8rem;
  font-weight: 800;
  color: var(--primary);
}

.p2-decision-arrow {
  color: var(--muted);
  font-weight: 800;
}

/* ---------- 06-5 VRAM 容器 ---------- */
.p2-vram-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.p2-vram-panel {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.p2-vram-head { margin-bottom: 10px; }

.p2-vram-stack {
  display: flex;
  flex-direction: column;
  height: 280px;
  border: 2px solid var(--muted);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.p2-vram-stack-gpu { height: 280px; }

.p2-vram-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 6px;
  border-bottom: 1px solid var(--border);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  color: var(--text);
}

.p2-vram-seg:last-child { border-bottom: 0; }

.p2-vram-seg span { overflow-wrap: anywhere; }

.p2-seg-weights {
  flex: 45;
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .1) 0 4px, transparent 4px 9px),
    var(--primary-weak);
}

.p2-seg-part {
  flex: 22;
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .1) 0 4px, transparent 4px 9px),
    var(--primary-weak);
}

.p2-seg-rest {
  flex: 60;
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .1) 0 4px, transparent 4px 9px),
    var(--primary-weak);
}

.p2-seg-kv {
  flex: 18;
  background:
    radial-gradient(circle, rgba(0, 0, 0, .22) 1px, transparent 1.4px) 0 0 / 7px 7px,
    var(--warn-weak);
}

.p2-seg-buffer {
  flex: 9;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .12) 0 2px, transparent 2px 7px),
    var(--surface-2);
}

.p2-seg-runtime {
  flex: 22;
  background:
    repeating-linear-gradient(135deg, rgba(0, 0, 0, .08) 0 2px, transparent 2px 8px),
    var(--surface-2);
}

.p2-seg-free {
  flex: 6;
  background: var(--surface);
  border-top: 1px dashed var(--muted);
  color: var(--muted);
}

.p2-vram-stack-gpu .p2-seg-free { flex: 29; }
.p2-vram-stack-gpu .p2-seg-kv { flex: 18; }
.p2-vram-stack-gpu .p2-seg-runtime { flex: 22; }

.p2-vram-duo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, .78fr);
  align-items: center;
  gap: 8px;
}

.p2-vram-transfer {
  display: grid;
  justify-items: center;
  gap: 2px;
  max-width: 5.4em;
}

.p2-transfer-arrows {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  color: var(--primary);
}

.p2-transfer-label {
  font-size: .66rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--muted);
  text-align: center;
}

.p2-ram-stack {
  display: flex;
  flex-direction: column;
  height: 190px;
  border: 2px dashed var(--muted);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.p2-ram-stack .p2-vram-seg { font-size: .68rem; }

.p2-ram-label {
  margin: 0;
  padding: 3px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: .68rem;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
}

.p2-vram-foot {
  margin: 8px 0 0;
  font-size: .74rem;
  line-height: 1.6;
  color: var(--muted);
}

.p2-vram-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
  font-size: .74rem;
  color: var(--muted);
}

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

.p2-dot {
  width: 12px;
  height: 12px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.p2-dot-weights {
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .18) 0 3px, transparent 3px 6px),
    var(--primary-weak);
}
.p2-dot-kv {
  background:
    radial-gradient(circle, rgba(0, 0, 0, .25) 1px, transparent 1.4px) 0 0 / 5px 5px,
    var(--warn-weak);
}
.p2-dot-buffer {
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .2) 0 2px, transparent 2px 5px),
    var(--surface-2);
}
.p2-dot-runtime {
  background:
    repeating-linear-gradient(135deg, rgba(0, 0, 0, .16) 0 2px, transparent 2px 6px),
    var(--surface-2);
}
.p2-dot-free { background: var(--surface); border-style: dashed; }

.p2-vram-note {
  margin: 10px 0 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: .78rem;
  line-height: 1.7;
}

.p2-vram-note strong { color: var(--warn); }

/* ---------- 06-5 記憶體試算 ---------- */
.p2-memory-lab {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.p2-lab-controls {
  display: grid;
  gap: 14px;
}

.p2-control { min-width: 0; }

#unit-06 { min-width: 0; }

.p2-control label,
.p2-control .p2-control-label { font-size: .82rem; font-weight: 800; }

.p2-control input[type="range"] {
  width: 100%;
  min-height: 32px;
  accent-color: var(--primary);
}

.p2-control select,
.p2-control input[type="number"],
.p2-control input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .88rem;
}

.p2-input-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5em;
  align-items: center;
  gap: 10px;
}

.p2-control-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.p2-switch {
  min-width: 5.5em;
  min-height: 40px;
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: .82rem;
  font-weight: 800;
  cursor: pointer;
}

.p2-switch[aria-checked="true"] {
  border-color: var(--primary);
  background: var(--primary-weak);
  color: var(--primary);
}

.p2-switch:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.p2-advanced {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.p2-advanced > summary {
  min-height: 42px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 800;
  color: var(--muted);
  list-style: none;
}

.p2-advanced > summary::-webkit-details-marker { display: none; }

.p2-advanced > summary::after {
  content: "＋";
  float: right;
  font-weight: 800;
}

.p2-advanced[open] > summary::after { content: "－"; }

.p2-advanced-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 12px;
}

.p2-advanced-grid label {
  display: grid;
  gap: 4px;
  font-size: .74rem;
  font-weight: 700;
  color: var(--muted);
}

.p2-advanced .p2-note { padding: 0 12px 10px; }

.p2-lab-result {
  min-width: 0;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.p2-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.p2-metric {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.p2-metric-total {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.p2-metric-label {
  margin: 0;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--muted);
}

.p2-metric-value {
  margin: 3px 0 0;
  font-size: .95rem;
  font-weight: 800;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.p2-bar { margin-top: 14px; }

.p2-bar-track {
  position: relative;
  display: flex;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}

.p2-bar-seg {
  display: block;
  flex: 0 0 auto;
  height: 100%;
  width: 0;
  border-right: 1px solid var(--surface);
  transition: width .18s ease;
}

.p2-bar-weights {
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .12) 0 3px, transparent 3px 7px),
    var(--primary);
}

.p2-bar-overhead {
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .12) 0 2px, transparent 2px 6px),
    var(--accent);
}

.p2-bar-kv {
  background:
    radial-gradient(circle, rgba(0, 0, 0, .2) 1px, transparent 1.4px) 0 0 / 6px 6px,
    var(--warn);
}

.p2-bar-budget {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: 85%;
  width: 3px;
  background: var(--text);
  opacity: .7;
}

.p2-bar-axis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 0;
  font-size: .68rem;
  color: var(--muted);
}

.p2-bar-axis span:nth-child(2) { text-align: center; }

.p2-verdict {
  margin: 12px 0 0;
  font-size: .95rem;
  line-height: 1.65;
}

.p2-verdict strong { color: var(--primary); }

.p2-verdict[data-state="mid"] strong { color: var(--warn); }
.p2-verdict[data-state="bad"] strong { color: var(--danger); }
.p2-verdict[data-state="ok"] strong { color: var(--ok); }

.p2-verdict-why {
  margin: 3px 0 0;
  font-size: .82rem;
  line-height: 1.7;
  color: var(--muted);
}

.p2-formula {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.p2-formula pre {
  margin: 6px 0 0;
  padding: 9px 10px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  font-size: .74rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.p2-formula-now {
  margin: 7px 0 0;
  font-size: .74rem;
  line-height: 1.65;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* ---------- 06-6 MoE 靜態圖 ---------- */
.p2-moe-schematic {
  position: relative;
  padding: 30px 12px 12px;
  border: 2px dashed var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.p2-moe-badge {
  position: absolute;
  top: 8px;
  left: 12px;
  margin: 0;
  padding: 2px 9px;
  border: 1px solid var(--warn);
  border-radius: 999px;
  background: var(--warn-weak);
  color: var(--warn);
  font-size: .68rem;
  font-weight: 800;
}

.p2-moe-flow {
  display: grid;
  grid-template-columns: auto 18px auto 18px minmax(0, 1fr) 18px auto;
  align-items: center;
  gap: 4px;
}

.p2-moe-token {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.p2-moe-token-label {
  font-size: .64rem;
  font-weight: 700;
  color: var(--muted);
}

.p2-moe-token-value {
  font-size: .9rem;
  font-weight: 800;
}

.p2-moe-arrow {
  color: var(--muted);
  font-size: .95rem;
  font-weight: 800;
  text-align: center;
}

.p2-moe-router {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--primary);
  border-radius: 10px;
  background: var(--primary-weak);
  text-align: center;
}

.p2-moe-router-label {
  font-size: .8rem;
  font-weight: 800;
  color: var(--primary);
}

.p2-moe-router-sub {
  font-size: .62rem;
  line-height: 1.4;
  color: var(--muted);
}

.p2-moe-box {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.p2-moe-box-title {
  margin: 0 0 5px;
  font-size: .7rem;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
}

.p2-moe-grid-static {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.p2-expert-static {
  display: grid;
  place-items: center;
  min-height: 30px;
  padding: 3px 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 800;
  line-height: 1.2;
}

.p2-expert-static-name {
  font-size: .68rem;
  font-weight: 800;
}

.p2-expert-static-score {
  font-size: .58rem;
  font-weight: 600;
  color: var(--muted);
  opacity: .85;
}

.p2-expert-static.is-on {
  border-color: var(--primary);
  background: var(--primary-weak);
  color: var(--primary);
}

.p2-expert-static.is-on .p2-expert-static-score { color: var(--primary); opacity: 1; }

.p2-moe-box-note {
  margin: 6px 0 0;
  font-size: .62rem;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

.p2-moe-merge {
  padding: 8px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
  font-size: .7rem;
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
  color: var(--accent);
}

.p2-moe-merge span {
  font-size: .62rem;
  font-weight: 600;
  color: var(--muted);
}

.p2-config-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.p2-config-card {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.p2-config-name {
  margin: 0 0 7px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: .8rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--primary);
}

.p2-config-card dl {
  margin: 0;
  display: grid;
  gap: 4px;
}

.p2-config-card dl > div {
  display: grid;
  gap: 1px;
}

.p2-config-card dt {
  font-size: .66rem;
  font-weight: 700;
  color: var(--muted);
}

.p2-config-card dd {
  margin: 0;
  font-size: .76rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* ---------- 06-6 MoE 步進器 ---------- */
.p2-moe-stepper {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.p2-moe-controls {
  display: grid;
  gap: 12px;
}

.p2-moe-controls .p2-chip-row { margin-top: 8px; }

.p2-moe-step-text {
  margin: 14px 0 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: var(--surface);
  font-size: .84rem;
  font-weight: 800;
  line-height: 1.65;
}

.p2-moe-stage {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.p2-moe-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.p2-expert {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 52px;
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.p2-expert-name {
  font-size: .72rem;
  font-weight: 800;
}

.p2-expert-score {
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
}

.p2-expert.is-scored { color: var(--text); }

.p2-expert.is-top {
  border-color: var(--primary);
  border-width: 2px;
  background: var(--primary-weak);
  color: var(--primary);
}

.p2-expert.is-muted { opacity: .55; }

.p2-moe-grid-note {
  margin: 8px 0 0;
  font-size: .74rem;
  line-height: 1.6;
  color: var(--muted);
}

.p2-moe-detail {
  margin: 6px 0 0;
  font-size: .8rem;
  line-height: 1.7;
}

.p2-moe-memory { margin-top: 10px; }

.p2-moe-memory-bar {
  position: relative;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .08) 0 4px, transparent 4px 9px),
    var(--surface-2);
  overflow: hidden;
}

.p2-moe-memory-used {
  display: block;
  width: 25%;
  height: 100%;
  border-right: 2px solid var(--text);
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .14) 0 3px, transparent 3px 7px),
    var(--primary);
  transition: width .18s ease;
}

.p2-moe-memory-label {
  margin: 6px 0 0;
  font-size: .76rem;
  line-height: 1.6;
  color: var(--muted);
}

.p2-moe-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* ---------- 06-7 三裝置與下載選擇器 ---------- */
.p2-flow-belt {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.p2-flow-belt li {
  position: relative;
  padding: 4px 22px 4px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: .76rem;
  font-weight: 800;
  color: var(--text);
}

.p2-flow-belt li::after {
  content: "→";
  position: absolute;
  right: 6px;
  color: var(--muted);
  font-weight: 800;
}

.p2-flow-belt li:last-child { padding-right: 10px; }
.p2-flow-belt li:last-child::after { content: ""; }

.p2-device-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.p2-device-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.p2-device-name {
  margin: 0 0 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: .82rem;
  font-weight: 800;
  color: var(--primary);
}

.p2-device-block { margin-bottom: 8px; }

.p2-device-label {
  margin: 0;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--muted);
}

.p2-device-block p:last-child {
  margin: 1px 0 0;
  font-size: .78rem;
  line-height: 1.65;
}

.p2-device-warn {
  margin: 8px 0 0;
  padding-top: 7px;
  border-top: 1px dashed var(--border);
  font-size: .72rem;
  line-height: 1.6;
  color: var(--warn);
}

.p2-download-picker {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.p2-dp-controls {
  display: grid;
  gap: 12px;
}

.p2-dp-result {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.p2-dp-result .p2-metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.p2-dp-verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin: 12px 0 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: .88rem;
  line-height: 1.65;
}

.p2-dp-verdict strong { font-size: 1rem; }

.p2-dp-verdict-icon {
  font-size: .8rem;
  line-height: 1;
}

.p2-dp-verdict[data-state="ok"] {
  border-left-color: var(--ok);
  background: var(--ok-weak);
}

.p2-dp-verdict[data-state="ok"] strong,
.p2-dp-verdict[data-state="ok"] .p2-dp-verdict-icon { color: var(--ok); }

.p2-dp-verdict[data-state="mid"] {
  border-left-color: var(--warn);
  background: var(--warn-weak);
}

.p2-dp-verdict[data-state="mid"] strong,
.p2-dp-verdict[data-state="mid"] .p2-dp-verdict-icon { color: var(--warn); }

.p2-dp-verdict[data-state="bad"] {
  border-left-color: var(--danger);
  background: var(--danger-weak);
}

.p2-dp-verdict[data-state="bad"] strong,
.p2-dp-verdict[data-state="bad"] .p2-dp-verdict-icon { color: var(--danger); }

.p2-dp-why {
  margin: 4px 0 0;
  font-size: .8rem;
  line-height: 1.7;
  color: var(--muted);
}

.p2-dp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.p2-dp-block {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.p2-dp-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 12px;
}

.p2-dp-fill-note {
  margin: 0;
  padding: 5px 10px;
  border: 1px solid var(--ok);
  border-radius: 8px;
  background: var(--ok-weak);
  color: var(--text);
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.6;
}

.p2-dp-model-note {
  margin: 12px 0 0;
  padding: 9px 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: .78rem;
  line-height: 1.7;
  color: var(--muted);
}

/* ---------- 深色主題的紋理對比 ---------- */
[data-theme="dark"] .p2-seg-weights,
[data-theme="dark"] .p2-seg-part,
[data-theme="dark"] .p2-seg-rest,
[data-theme="dark"] .p2-seg-buffer,
[data-theme="dark"] .p2-seg-runtime,
[data-theme="dark"] .p2-dot-weights,
[data-theme="dark"] .p2-dot-buffer,
[data-theme="dark"] .p2-dot-runtime,
[data-theme="dark"] .p2-bar-overhead,
[data-theme="dark"] .p2-moe-memory-bar,
[data-theme="dark"] .p2-moe-memory-used {
  background-blend-mode: normal;
}

[data-theme="dark"] .p2-seg-weights,
[data-theme="dark"] .p2-seg-part,
[data-theme="dark"] .p2-seg-rest {
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .14) 0 4px, transparent 4px 9px),
    none;
}

[data-theme="dark"] .p2-seg-kv,
[data-theme="dark"] .p2-dot-kv {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, .2) 1px, transparent 1.4px),
    none;
}

[data-theme="dark"] .p2-seg-buffer,
[data-theme="dark"] .p2-dot-buffer,
[data-theme="dark"] .p2-bar-overhead {
  background-image:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .16) 0 2px, transparent 2px 7px),
    none;
}

[data-theme="dark"] .p2-seg-runtime,
[data-theme="dark"] .p2-dot-runtime {
  background-image:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .13) 0 2px, transparent 2px 8px),
    none;
}

/* ---------- 回應式：<= 859px ---------- */
@media (max-width: 859px) {
  .p2-file-package,
  .p2-containers,
  .p2-vram-compare { grid-template-columns: 1fr; }

  .p2-file-col,
  .p2-vram-panel { padding: 12px; }

  .p2-format-grid { grid-template-columns: 1fr; }

  .p2-control-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
  }

  .p2-control-row label { grid-column: 1 / -1; }

  .p2-range-scale { grid-column: 1 / -1; }

  .p2-prec-table-wrap { overflow-x: visible; }

  .p2-prec-table,
  .p2-prec-table thead,
  .p2-prec-table tbody,
  .p2-prec-table tr,
  .p2-prec-table th,
  .p2-prec-table td { display: block; }

  .p2-prec-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /* 表格在手機改成 block 卡片列；caption 也必須脫離 table-caption，
     否則會被縮成 min-content 的垂直紙條（UI-P1-01）。 */
  .p2-prec-table caption {
    display: block;
    width: auto;
    text-align: left;
    border-bottom: 1px solid var(--border);
  }

  .p2-prec-table tbody tr {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
  }

  .p2-prec-table tbody tr:last-child { border-bottom: 0; }

  .p2-prec-table tbody th {
    padding: 0 0 4px;
    border-bottom: 0;
    font-size: .84rem;
    color: var(--primary);
  }

  .p2-prec-table tbody td {
    display: grid;
    grid-template-columns: 5.5em minmax(0, 1fr);
    gap: 8px;
    padding: 2px 0;
    border-bottom: 0;
    font-size: .82rem;
  }

  .p2-prec-table tbody td::before {
    font-size: .7rem;
    font-weight: 800;
    color: var(--muted);
  }

  .p2-prec-table tbody td:nth-of-type(1)::before { content: "這是什麼"; }
  .p2-prec-table tbody td:nth-of-type(2)::before { content: "常見用途"; }
  .p2-prec-table tbody td:nth-of-type(3)::before { content: "不要誤會"; }

  .p2-name-breakdown { grid-template-columns: 1fr; }

  .p2-name-cell {
    grid-template-columns: 2.2em minmax(0, 1fr);
    align-items: center;
    justify-items: start;
    padding: 7px 10px;
    text-align: left;
  }

  .p2-name-char { font-size: 1rem; }
  .p2-name-desc { font-size: .8rem; }

  .p2-quant-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .p2-quant-card dl > div {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .p2-vram-stack,
  .p2-vram-stack-gpu { height: 230px; }

  .p2-vram-duo {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .p2-vram-transfer {
    flex-direction: row;
    grid-auto-flow: column;
    align-items: center;
    justify-self: center;
    max-width: none;
  }

  .p2-transfer-arrows { transform: rotate(90deg); }

  .p2-ram-stack { height: 130px; }

  .p2-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .p2-advanced-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .p2-moe-flow {
    grid-template-columns: minmax(0, 1fr);
    justify-items: stretch;
    gap: 5px;
  }

  .p2-moe-token,
  .p2-moe-router,
  .p2-moe-merge { justify-items: center; }

  .p2-moe-arrow { transform: rotate(90deg); }

  .p2-config-cards { grid-template-columns: 1fr; }

  .p2-moe-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .p2-device-cards { grid-template-columns: 1fr; }

  .p2-dp-grid { grid-template-columns: 1fr; }

  .p2-dp-result .p2-metric-grid { grid-template-columns: 1fr; }

  /* 手機：滑桿與輸入框維持可點擊高度 */
  .p2-control input[type="range"],
  .p2-control-row input[type="range"] { min-height: 44px; }

  .p2-control select,
  .p2-control input[type="number"],
  .p2-control input[type="text"],
  .p2-switch { min-height: 44px; }

  .p2-chip-btn { min-height: 40px; }

  .p2-dp-actions .btn { flex: 1 1 auto; min-height: 44px; }
}

/* ---------- 回應式：<= 460px ---------- */
@media (max-width: 460px) {
  .p2-quant-cards { grid-template-columns: 1fr; }

  .p2-flow-belt li { font-size: .72rem; }

  .p2-moe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .p2-moe-grid-static { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .p2-moe-buttons .btn { flex: 1 1 45%; }

  .p2-advanced-grid { grid-template-columns: 1fr; }

  .p2-input-pair { grid-template-columns: 1fr; }

  .p2-bit-row { grid-template-columns: 3.4em minmax(0, 1fr); gap: 8px; }

  .p2-bit-label { padding: 0 10px; font-size: .78rem; }

  .p2-result-big { font-size: 1.45rem; }

  .p2-moe-step-text { font-size: .8rem; }

  .p2-vram-stack,
  .p2-vram-stack-gpu { height: 210px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .p2-bar-seg,
  .p2-moe-memory-used,
  .p2-expert {
    transition: none !important;
  }
}

/* ---------- Print ---------- */
@media print {
  .p2-format-switch,
  .p2-memory-lab,
  .p2-moe-stepper,
  .p2-download-picker,
  .p2-status { break-inside: avoid; }

  .p2-vram-stack,
  .p2-ram-stack { border-color: #666; }
}

/* =========================================================
   full-fix-06｜P2／P3 圖解補強
   VE-07／08／09／10／11／12／13／15／16
   ========================================================= */

/* ---------- 06-1 共同基準（VE-07） ---------- */
.p2-file-baseline {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: .82rem;
  line-height: 1.7;
}

.p2-baseline-tag {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--primary-weak);
  color: var(--primary);
  font-size: .7rem;
  font-weight: 800;
}

/* ---------- 06-2 切換卡只留單一差異（VE-08） ---------- */
.p2-format-diff {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--primary);
  border-radius: 12px;
  background: var(--primary-weak);
}

.p2-format-diff .p2-format-text {
  margin-top: 6px;
  font-size: .88rem;
  line-height: 1.75;
}

.p2-format-diff-extra {
  margin: 6px 0 0;
  font-size: .78rem;
  line-height: 1.7;
  color: var(--muted);
}

.p2-format-same {
  margin: 10px 0 0;
  font-size: .78rem;
  line-height: 1.7;
  color: var(--muted);
}

/* ---------- 06-3 位元比例＋可表示刻度（VE-09／09b／09c） ---------- */
.p2-bit-visual {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: 16px;
  align-items: start;
}

.p2-bit-precision {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.p2-ladder { margin-top: 10px; }

.p2-ladder-label {
  margin: 0 0 4px;
  font-size: .72rem;
  font-weight: 800;
  color: var(--muted);
}

.p2-ladder-track {
  height: 46px;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--muted);
  border-radius: 6px 6px 0 0;
  background-color: var(--surface-2);
}

.p2-ladder-fine {
  background-image: repeating-linear-gradient(90deg, var(--primary) 0 1px, transparent 1px 7px);
  opacity: .8;
}

.p2-ladder-coarse {
  background-image: repeating-linear-gradient(90deg, var(--warn) 0 3px, transparent 3px 46px);
}

.p2-ladder-note {
  margin: 5px 0 0;
  font-size: .72rem;
  line-height: 1.6;
  color: var(--muted);
}

.p2-bit-fill-actual {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 25%;
  width: 6%;
  border-left: 2px dashed var(--text);
  border-right: 2px dashed var(--text);
  background: repeating-linear-gradient(45deg, var(--text) 0 2px, transparent 2px 6px);
  opacity: .3;
}

.p2-bit-sub {
  grid-column: 2;
  margin: 4px 0 0;
  font-size: .72rem;
  line-height: 1.6;
  color: var(--muted);
}

.p2-bit-sub strong { color: var(--warn); }

.p2-bit-axis {
  position: relative;
  height: 1.2em;
  margin-top: 6px;
  font-size: .64rem;
  color: var(--muted);
}

.p2-bit-axis span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.p2-bit-axis span:nth-child(1) { left: 0; transform: none; }
.p2-bit-axis span:nth-child(2) { left: 25%; }
.p2-bit-axis span:nth-child(3) { left: 50%; }
.p2-bit-axis span:nth-child(4) { left: 100%; transform: translateX(-100%); }

.p2-scale-note {
  margin: 6px 0 0;
  font-size: .74rem;
  line-height: 1.65;
  color: var(--muted);
}

.p2-scale-note strong { color: var(--warn); }

.p2-lookup-label {
  margin: 20px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: .78rem;
  line-height: 1.7;
  color: var(--muted);
}

.p2-lookup-label strong { color: var(--primary); }

/* ---------- 06-4 共同 bits/weight 尺（VE-10） ---------- */
.p2-bpw-ruler {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.p2-ruler-title {
  margin: 0 0 10px;
  font-size: .8rem;
  font-weight: 800;
  color: var(--primary);
}

.p2-ruler-rows { display: grid; gap: 7px; }

.p2-ruler-row {
  display: grid;
  grid-template-columns: 5.4em minmax(0, 1fr) 4.2em;
  align-items: center;
  gap: 8px;
}

.p2-ruler-name {
  margin: 0;
  font-size: .74rem;
  font-weight: 800;
  white-space: nowrap;
}

.p2-ruler-track {
  position: relative;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}

.p2-ruler-fill {
  display: block;
  height: 100%;
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .12) 0 3px, transparent 3px 7px),
    var(--primary);
}

.p2-ruler-fill-4 { width: 54.3%; }
.p2-ruler-fill-5 { width: 63.3%; }
.p2-ruler-fill-6 { width: 72.9%; }
.p2-ruler-fill-8 { width: 94.4%; }

.p2-ruler-nominal {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 44.4%;
  border-left: 2px dashed var(--text);
  opacity: .65;
}

.p2-ruler-value {
  display: grid;
  justify-items: end;
  gap: 1px;
  margin: 0;
  line-height: 1.2;
}

.p2-ruler-value strong {
  font-size: .8rem;
  color: var(--primary);
}

.p2-ruler-value span {
  font-size: .62rem;
  color: var(--muted);
  white-space: nowrap;
}

.p2-ruler-axis {
  position: relative;
  height: 1.2em;
  margin: 6px 4.2rem 0 5.4rem;
  font-size: .64rem;
  color: var(--muted);
}

.p2-ruler-axis span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.p2-ruler-axis span:nth-child(1) { left: 0; transform: none; }
.p2-ruler-axis span:nth-child(2) { left: 22.2%; }
.p2-ruler-axis span:nth-child(3) { left: 44.4%; }
.p2-ruler-axis span:nth-child(4) { left: 66.7%; }
.p2-ruler-axis span:nth-child(5) { left: 88.9%; }
.p2-ruler-axis span:nth-child(6) { left: 100%; transform: translateX(-100%); }

.p2-ruler-note {
  margin: 8px 0 0;
  font-size: .74rem;
  line-height: 1.65;
  color: var(--muted);
}

.p2-ruler-key {
  display: inline-block;
  width: 1.4em;
  margin-right: 4px;
  border-top: 2px dashed var(--text);
  vertical-align: middle;
}

/* ---------- 06-5 A／B 共用尺（VE-11） ---------- */
.p2-vram-scale {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.p2-vram-scale-title {
  margin: 0 0 8px;
  font-size: .8rem;
  font-weight: 800;
  color: var(--primary);
}

.p2-vram-axis {
  position: relative;
  height: 1.2em;
  margin: 0 0 6px calc(10.5rem + 10px);
  font-size: .64rem;
  color: var(--muted);
}

.p2-vram-axis span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.p2-vram-axis span:nth-child(1) { left: 0; transform: none; }
.p2-vram-axis span:nth-child(2) { left: 25%; }
.p2-vram-axis span:nth-child(3) { left: 50%; }
.p2-vram-axis span:nth-child(4) { left: 75%; }
.p2-vram-axis span:nth-child(5) { left: 100%; transform: translateX(-100%); }

.p2-vram-row {
  display: grid;
  grid-template-columns: 10.5em minmax(0, 1fr);
  grid-template-areas:
    "head track"
    "comp comp";
  gap: 4px 10px;
  align-items: center;
}

.p2-vram-row-head { grid-area: head; min-width: 0; }

.p2-vram-row-sub {
  margin: 3px 0 0;
  font-size: .7rem;
  line-height: 1.55;
  color: var(--muted);
}

.p2-vram-track {
  position: relative;
  display: flex;
  grid-area: track;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  overflow: hidden;
}

.p2-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 100%;
  padding: 2px 3px;
  border-right: 1px solid var(--surface);
  font-size: .64rem;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.p2-vs-weights {
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .12) 0 4px, transparent 4px 9px),
    var(--primary-weak);
}

.p2-vs-kv {
  background:
    radial-gradient(circle, rgba(0, 0, 0, .22) 1px, transparent 1.4px) 0 0 / 7px 7px,
    var(--warn-weak);
}

.p2-vs-buffer {
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .12) 0 2px, transparent 2px 7px),
    var(--surface-2);
}

.p2-vs-runtime {
  background:
    repeating-linear-gradient(135deg, rgba(0, 0, 0, .08) 0 2px, transparent 2px 8px),
    var(--surface-2);
}

.p2-vs-free {
  border-left: 1px dashed var(--muted);
  background: var(--surface);
  color: var(--muted);
}

.p2-gb-760 { flex: 0 0 47.5%; }
.p2-gb-440 { flex: 0 0 27.5%; }
.p2-gb-320 { flex: 0 0 20%; }
.p2-gb-120 { flex: 0 0 7.5%; }
.p2-gb-100 { flex: 0 0 6.25%; }
.p2-gb-080 { flex: 0 0 5%; }
.p2-gb-060 { flex: 0 0 3.75%; }
.p2-gb-1280 { flex: 0 0 80%; }

.p2-vram-cap-line {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 50%;
  width: 2px;
  background: var(--text);
  opacity: .8;
  z-index: 2;
}

.p2-vram-over {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 15%;
  background: repeating-linear-gradient(45deg, var(--danger) 0 3px, transparent 3px 8px);
  opacity: .35;
  z-index: 1;
}

.p2-vram-composition {
  grid-area: comp;
  margin: 2px 0 10px;
  font-size: .72rem;
  line-height: 1.6;
  color: var(--muted);
}

.p2-vram-composition strong { color: var(--text); }
.p2-vram-composition .p2-over-text { color: var(--danger); }

.p2-vram-move {
  margin: 2px 0 10px calc(10.5rem + 10px);
  padding: 6px 10px;
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  background: var(--surface-2);
  font-size: .74rem;
  line-height: 1.65;
}

.p2-dot-cap {
  width: 3px;
  border: 0;
  background: var(--text);
}

/* ---------- 06-6 容器標題與 8／2 標記（VE-13） ---------- */
.p2-moe-box-meter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin: 6px 0 0;
  font-size: .6rem;
  line-height: 1.4;
}

.p2-moe-box-meter span {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}

.p2-moe-box-meter .p2-moe-box-meter-on {
  border-color: var(--primary);
  background: var(--primary-weak);
  color: var(--primary);
  font-weight: 800;
}

/* ---------- 06-7 容量軸（VE-15） ---------- */
.p2-cap-axis {
  margin: 0 0 14px;
  padding: 10px 14px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.p2-cap-title {
  margin: 0 0 40px;
  font-size: .78rem;
  font-weight: 800;
  color: var(--primary);
}

.p2-cap-track {
  position: relative;
  height: 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), var(--border) calc(25% - 1px) 25%),
    var(--surface);
}

.p2-cap-mark {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  border-radius: 2px;
  background: var(--primary);
}

.p2-cap-mark span {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: .62rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--primary);
  white-space: nowrap;
}

.p2-cap-mark-8 { left: 6.25%; }
.p2-cap-mark-16 { left: 12.5%; background: var(--accent); }
.p2-cap-mark-128 { left: 100%; transform: translateX(-100%); }
.p2-cap-mark-128 span { left: auto; right: 0; transform: none; }

.p2-cap-mark-8 span { bottom: calc(100% + 20px); }

.p2-cap-mark-128 span { bottom: calc(100% + 4px); }

.p2-cap-mark-16 span { top: auto; bottom: calc(100% + 4px); color: var(--accent); }

.p2-cap-ticks {
  position: relative;
  height: 1.2em;
  margin-top: 12px;
  font-size: .6rem;
  color: var(--muted);
}

.p2-cap-ticks span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.p2-cap-ticks span:nth-child(1) { left: 0; transform: none; }
.p2-cap-ticks span:nth-child(2) { left: 25%; }
.p2-cap-ticks span:nth-child(3) { left: 50%; }
.p2-cap-ticks span:nth-child(4) { left: 75%; }
.p2-cap-ticks span:nth-child(5) { left: 100%; transform: translateX(-100%); }

.p2-cap-note {
  margin: 8px 0 0;
  font-size: .7rem;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- 06-5／06-7 長條的刻度、標線與圖例（VE-12／16） ---------- */
.p2-bar-cap {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: 100%;
  width: 2px;
  background: var(--text);
  opacity: .8;
  z-index: 2;
}

.p2-bar-budget {
  top: -3px;
  bottom: -3px;
  left: 85%;
  width: 0;
  border-left: 2px dashed var(--text);
  background: none;
  opacity: .7;
  z-index: 2;
}

.p2-bar-kv.is-ghost {
  background:
    repeating-linear-gradient(45deg, var(--muted) 0 2px, transparent 2px 6px),
    var(--surface-2);
  opacity: .5;
}

.p2-bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 6px 0 0;
  font-size: .68rem;
  color: var(--muted);
}

.p2-bar-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.p2-bar-key {
  flex: none;
  width: 10px;
  height: 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
}

.p2-bar-key-weights { background: var(--primary); }
.p2-bar-key-overhead { background: var(--accent); }

.p2-bar-key-cap {
  width: 2px;
  border: 0;
  background: var(--text);
}

.p2-bar-key-budget {
  width: 2px;
  border: 0;
  border-left: 2px dashed var(--text);
  background: none;
}

.p2-bar-key-ghost {
  border-style: dashed;
  background: repeating-linear-gradient(45deg, var(--muted) 0 2px, transparent 2px 5px);
}

.p2-bar-overflow {
  margin: 7px 0 0;
  font-size: .74rem;
  line-height: 1.65;
  color: var(--text);
}

.p2-bar-axis span:nth-child(2) { text-align: right; }

.p2-dp-bar { margin-top: 14px; }

.p2-dp-overflow {
  margin: 7px 0 0;
  font-size: .74rem;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- 深色主題：新紋理 ---------- */
[data-theme="dark"] .p2-ruler-fill,
[data-theme="dark"] .p2-vs-weights {
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .14) 0 4px, transparent 4px 9px),
    none;
}

[data-theme="dark"] .p2-vs-kv {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, .2) 1px, transparent 1.4px),
    none;
}

[data-theme="dark"] .p2-vs-buffer {
  background-image:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .16) 0 2px, transparent 2px 7px),
    none;
}

[data-theme="dark"] .p2-vs-runtime {
  background-image:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .13) 0 2px, transparent 2px 8px),
    none;
}

[data-theme="dark"] .p2-vram-over {
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .35) 0 3px, transparent 3px 8px);
}

[data-theme="dark"] .p2-bit-fill-actual {
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .35) 0 2px, transparent 2px 6px);
}

/* ---------- 回應式：新元件 <= 859px ---------- */
@media (max-width: 859px) {
  .p2-bit-visual { grid-template-columns: 1fr; }

  .p2-vram-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "track"
      "comp";
  }

  .p2-vram-axis { margin-left: 0; }
  .p2-vram-move { margin-left: 0; }

  .p2-ruler-row { grid-template-columns: 4.6em minmax(0, 1fr) 3.8em; }

  .p2-ruler-axis { margin-left: 4.6rem; margin-right: 3.8rem; }
}

/* ---------- 回應式：新元件 <= 460px ---------- */
@media (max-width: 460px) {
  .p2-ruler-row { grid-template-columns: 4.2em minmax(0, 1fr) 3.4em; gap: 6px; }
  .p2-ruler-axis { margin-left: 4.2rem; margin-right: 3.4rem; }
  .p2-ruler-name { font-size: .68rem; }
  .p2-ruler-value strong { font-size: .74rem; }

  .p2-vram-track { height: 30px; }
  .p2-vs { font-size: .58rem; padding: 1px 2px; }
  .p2-vram-composition { font-size: .68rem; }

  .p2-cap-title { margin-bottom: 40px; }
  .p2-cap-mark span { font-size: .58rem; }

  .p2-bit-axis { font-size: .58rem; }
  .p2-bit-precision { padding: 10px; }
}
