/* =========================================================
   LLM 101｜PART 02 · UNIT 08
   unit-08.css：只放本單元的 p2-* 元件樣式。
   顏色全部使用 main.css 的 tokens，不改 :root。
   ========================================================= */

#unit-08 {
  --p2-radius: 12px;
  --p2-line: 1.75;
}

/* ---------- 共用小元件 ---------- */
#unit-08 .p2-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

#unit-08 .p2-control-label {
  display: block;
  margin: 0 0 8px;
  font-size: .86rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--text);
}

#unit-08 .p2-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

#unit-08 .p2-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

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

#unit-08 .p2-chip[aria-pressed="true"]::before {
  content: "●";
  font-size: .62em;
  line-height: 1;
}

#unit-08 .p2-chip-ext {
  border-style: dashed;
  border-color: var(--accent);
}

#unit-08 .p2-chip-ext[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--surface-2);
  color: var(--text);
}

#unit-08 .p2-badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1.6;
}

#unit-08 .p2-status {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .84rem;
  line-height: 1.7;
}

#unit-08 .p2-readouts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
}

#unit-08 .p2-readout {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}

#unit-08 .p2-readout dt {
  margin: 0;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-readout dd {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

#unit-08 .p2-control {
  margin: 0;
}

#unit-08 .p2-range {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

#unit-08 .p2-range-scale {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: -4px;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-range-scale span:nth-child(2) {
  text-align: center;
}

#unit-08 .p2-range-scale span:last-child {
  text-align: right;
}

/* ---------- 08-1 五層堆疊 ---------- */
#unit-08 .p2-layer-map-body {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: 18px;
  align-items: start;
}

#unit-08 .p2-layers {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#unit-08 .p2-layer {
  display: grid;
  grid-template-columns: 2.4em minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: 9px;
  background: var(--surface);
  transition: background .15s ease, border-color .15s ease;
}

#unit-08 .p2-layer:hover {
  background: var(--surface-2);
}

#unit-08 .p2-layer.is-active {
  border-color: var(--primary);
  border-left-color: var(--primary);
  background: var(--primary-weak);
}

#unit-08 .p2-layer-num {
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--primary);
}

#unit-08 .p2-layer-text {
  display: grid;
  gap: 1px;
  min-width: 0;
  font-size: .82rem;
  line-height: 1.55;
  color: var(--muted);
}

#unit-08 .p2-layer-text strong {
  font-size: .9rem;
  font-weight: 800;
  color: var(--text);
}

#unit-08 .p2-layer.is-active .p2-layer-text strong {
  color: var(--primary);
}

#unit-08 .p2-layer-tools {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  background: var(--surface-2);
}

#unit-08 .p2-layer-tools-title {
  margin: 0 0 8px;
  font-size: .82rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--text);
}

#unit-08 .p2-tool-chips,
#unit-08 .p2-tag-chips,
#unit-08 .p2-need-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- 08-2 offload 與指令卡 ---------- */
#unit-08 .p2-offload {
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border);
}

#unit-08 .p2-command-card {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  background: var(--surface);
  overflow: hidden;
}

#unit-08 .p2-command-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}

#unit-08 .p2-command-note {
  margin: 12px 14px 0;
  font-size: .82rem;
  line-height: 1.7;
  color: var(--muted);
}

#unit-08 .p2-command-card pre {
  margin: 12px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#unit-08 .p2-command-card pre + pre {
  margin-top: -4px;
}

#unit-08 .p2-annotations {
  margin: 0;
  padding: 0 14px 14px 30px;
  font-size: .82rem;
  line-height: 1.7;
  color: var(--muted);
}

#unit-08 .p2-annotations li {
  margin-top: 4px;
}

#unit-08 .p2-annotations code {
  color: var(--text);
}

/* ---------- 08-3 tag picker ---------- */
#unit-08 .p2-tag-output {
  display: grid;
  gap: 0;
  margin: 14px 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  background: var(--surface);
}

#unit-08 .p2-tag-output > div {
  display: grid;
  grid-template-columns: 7.5em minmax(0, 1fr);
  gap: 10px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
}

#unit-08 .p2-tag-output > div:first-child {
  border-top: 0;
}

#unit-08 .p2-tag-output dt {
  font-size: .78rem;
  font-weight: 800;
  line-height: 1.6;
  color: var(--muted);
}

#unit-08 .p2-tag-output dd {
  margin: 0;
  font-size: .86rem;
  line-height: 1.65;
  color: var(--text);
}

#unit-08 .p2-tag-chips .p2-chip {
  font-family: var(--font-mono);
  font-size: .82rem;
}

#unit-08 .p2-tag-chart {
  padding: 12px 14px 14px;
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  background: var(--surface);
}

#unit-08 .p2-tag-chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  margin-bottom: 6px;
}

#unit-08 .p2-tag-chart-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: .82rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--text);
}

#unit-08 .p2-tag-chart-sub {
  margin: 0;
  font-size: .72rem;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-gb-plot {
  position: relative;
  padding-top: 24px;
}

#unit-08 .p2-gb-threshold-label {
  position: absolute;
  top: 0;
  left: 80%;
  transform: translateX(-50%);
  padding: 0 4px;
  background: var(--surface);
  font-size: .7rem;
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--warn);
}

#unit-08 .p2-gb-track {
  position: relative;
  height: 54px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: visible;
}

#unit-08 .p2-gb-range {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 46%;
  width: 29%;
  border-left: 2px solid var(--primary);
  border-right: 2px solid var(--primary);
  background: var(--primary-weak);
}

#unit-08 .p2-gb-reserve {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 75%;
  right: 0;
  border-left: 2px dashed var(--warn);
  border-radius: 0 7px 7px 0;
  background: repeating-linear-gradient(
    135deg,
    var(--surface) 0,
    var(--surface) 5px,
    var(--surface-2) 5px,
    var(--surface-2) 10px
  );
}

#unit-08 .p2-gb-threshold {
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: 80%;
  width: 2px;
  background: var(--warn);
}

#unit-08 .p2-gb-edge {
  position: absolute;
  top: calc(100% + 2px);
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--primary);
}

#unit-08 .p2-gb-edge-start {
  left: 46%;
}

#unit-08 .p2-gb-edge-end {
  left: 75%;
}

#unit-08 .p2-gb-axis {
  position: relative;
  height: 18px;
  margin-top: 18px;
  font-size: .7rem;
  line-height: 1.4;
  color: var(--muted);
}

#unit-08 .p2-gb-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

#unit-08 .p2-gb-tick-0 {
  left: 0;
  transform: none;
}

#unit-08 .p2-gb-tick-2 {
  left: 20%;
}

#unit-08 .p2-gb-tick-4 {
  left: 40%;
}

#unit-08 .p2-gb-tick-6 {
  left: 60%;
}

#unit-08 .p2-gb-tick-8 {
  left: 80%;
}

#unit-08 .p2-gb-tick-10 {
  left: 100%;
  transform: translateX(-100%);
}

#unit-08 .p2-gb-legend {
  display: grid;
  gap: 4px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: .74rem;
  line-height: 1.6;
  color: var(--muted);
}

#unit-08 .p2-gb-legend li {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

#unit-08 .p2-gb-swatch {
  flex: none;
  width: 12px;
  height: 12px;
  margin-top: .2em;
  border-radius: 2px;
}

#unit-08 .p2-gb-swatch-range {
  border: 1px solid var(--primary);
  background: var(--primary-weak);
}

#unit-08 .p2-gb-swatch-reserve {
  border: 1px dashed var(--warn);
  background: repeating-linear-gradient(
    135deg,
    var(--surface) 0,
    var(--surface) 3px,
    var(--surface-2) 3px,
    var(--surface-2) 6px
  );
}

#unit-08 .p2-gb-swatch-threshold {
  width: 2px;
  margin-left: 5px;
  margin-right: 5px;
  border-radius: 0;
  background: var(--warn);
}

#unit-08 .p2-gb-note {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: .8rem;
  line-height: 1.7;
  color: var(--text);
}

#unit-08 .p2-tag-summary {
  margin: 12px 0 0;
  padding: 9px 12px;
  border: 1px dashed var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: .84rem;
  line-height: 1.7;
  color: var(--text);
}

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

#unit-08 .p2-tag-table-wrap:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

#unit-08 .p2-tag-table caption {
  text-align: left;
}

#unit-08 .p2-tag-table th,
#unit-08 .p2-tag-table td {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

#unit-08 .p2-tag-table thead th {
  border-top: 0;
  background: var(--surface-2);
  font-size: .74rem;
  font-weight: 800;
  color: var(--muted);
}

#unit-08 .p2-tag-table tbody th {
  font-weight: 700;
}

#unit-08 .p2-tag-table tbody th code {
  font-size: .78rem;
}

#unit-08 .p2-tag-table tbody tr.is-current {
  background: var(--primary-weak);
}

#unit-08 .p2-tag-status {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: .62rem;
  font-style: normal;
  font-weight: 800;
  line-height: 1.6;
  white-space: nowrap;
  color: var(--muted);
}

#unit-08 .p2-tag-status.is-verified {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- 08-4 工具比較 ---------- */
#unit-08 .p2-need-chips {
  margin-bottom: 12px;
}

#unit-08 .p2-compare-scroll {
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  overflow: hidden;
  background: var(--surface);
}

#unit-08 .p2-compare-scroll:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

#unit-08 .p2-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
  line-height: 1.65;
}

#unit-08 .p2-compare-table caption {
  text-align: left;
}

#unit-08 .p2-compare-table th,
#unit-08 .p2-compare-table td {
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

#unit-08 .p2-compare-table thead th {
  border-top: 0;
  background: var(--surface-2);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .02em;
  color: var(--muted);
}

#unit-08 .p2-compare-dim {
  width: 7.5em;
  font-size: .8rem;
  font-weight: 800;
  color: var(--text);
  background: var(--surface);
}

#unit-08 .p2-compare-table tr.is-focus td,
#unit-08 .p2-compare-table tr.is-focus .p2-compare-dim {
  background: var(--primary-weak);
}

#unit-08 .p2-compare-table tr.is-focus .p2-compare-dim {
  box-shadow: inset 3px 0 0 var(--primary);
}

#unit-08 .p2-compare-table code {
  font-size: .9em;
}

/* ---------- 08-5 請求佇列 ---------- */
#unit-08 .p2-queue .p2-readouts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#unit-08 .p2-queue-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

#unit-08 .p2-request {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: .76rem;
  line-height: 1.5;
}

#unit-08 .p2-request-name {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--text);
}

#unit-08 .p2-request-state {
  font-weight: 800;
}

#unit-08 .p2-request-slot {
  margin-left: auto;
  font-size: .72rem;
  color: var(--muted);
  white-space: nowrap;
}

#unit-08 .p2-request.is-running {
  border-left-color: var(--primary);
  background: var(--primary-weak);
}

#unit-08 .p2-request.is-running .p2-request-state {
  color: var(--primary);
}

#unit-08 .p2-request.is-queued {
  border-left-color: var(--warn);
}

#unit-08 .p2-request.is-queued .p2-request-state {
  color: var(--warn);
}

/* ---------- 08-6 框架比較 ---------- */
#unit-08 .p2-framework-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#unit-08 .p2-framework-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  background: var(--surface);
}

#unit-08 .p2-framework-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#unit-08 .p2-framework-head h4 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.4;
}

#unit-08 .p2-framework-focus {
  margin: 6px 0 10px;
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.6;
  color: var(--primary);
}

#unit-08 .p2-framework-card dl {
  margin: 0;
}

#unit-08 .p2-framework-card dl > div {
  padding: 7px 0;
  border-top: 1px dashed var(--border);
}

#unit-08 .p2-framework-card dt {
  font-size: .74rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-framework-card dd {
  margin: 2px 0 0;
  font-size: .82rem;
  line-height: 1.65;
}

#unit-08 .p2-verify {
  margin-top: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

#unit-08 .p2-verify summary {
  min-height: 32px;
  font-size: .8rem;
  font-weight: 800;
  line-height: 2;
  color: var(--primary);
  cursor: pointer;
}

#unit-08 .p2-verify summary:hover {
  text-decoration: underline;
}

#unit-08 .p2-verify ul {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: .8rem;
  line-height: 1.7;
  color: var(--muted);
}

/* ---------- 08-6 共用前綴負載對照 ---------- */
#unit-08 .p2-prefix-compare {
  display: grid;
  gap: 12px;
}

#unit-08 .p2-workload {
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-2);
}

#unit-08 .p2-workload-label {
  margin: 0 0 4px;
}

#unit-08 .p2-workload-text {
  margin: 0;
  font-size: .84rem;
  line-height: 1.65;
  color: var(--text);
}

#unit-08 .p2-prefix-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#unit-08 .p2-prefix-panel {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  background: var(--surface);
}

#unit-08 .p2-prefix-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

#unit-08 .p2-prefix-head h4 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.4;
}

#unit-08 .p2-prefix-pattern {
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-req-list {
  display: grid;
  gap: 5px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

#unit-08 .p2-req-list.is-reuse {
  margin-left: 4px;
  padding-left: 8px;
  border-left: 2px dashed var(--accent);
}

#unit-08 .p2-req {
  display: grid;
  grid-template-columns: 2.1em minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 30px;
}

#unit-08 .p2-req-id {
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--muted);
}

#unit-08 .p2-req-prefix,
#unit-08 .p2-req-reuse {
  min-width: 0;
  padding: 4px 7px;
  border-radius: 5px;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#unit-08 .p2-req-prefix {
  border: 1px solid var(--primary);
  background: var(--primary-weak);
  color: var(--text);
}

#unit-08 .p2-req-reuse {
  border: 1px dashed var(--accent);
  background: var(--surface-2);
  color: var(--accent);
}

#unit-08 .p2-req-suffix {
  font-size: .72rem;
  line-height: 1.5;
  color: var(--muted);
  white-space: nowrap;
}

#unit-08 .p2-shared-prefix {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--primary-weak);
  font-size: .76rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--text);
}

#unit-08 .p2-shared-tag {
  padding: 1px 6px;
  border: 1px dashed var(--accent);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: .62rem;
  font-weight: 800;
  white-space: nowrap;
  color: var(--accent);
}

#unit-08 .p2-prefix-foot {
  margin: auto 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: .76rem;
  line-height: 1.6;
  color: var(--muted);
}

#unit-08 .p2-prefix-foot strong {
  font-family: var(--font-mono);
  color: var(--text);
}

#unit-08 .p2-framework-diff {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  background: var(--surface);
}

#unit-08 .p2-framework-diff h4 {
  margin: 0 0 6px;
  font-size: .84rem;
  line-height: 1.5;
}

#unit-08 .p2-framework-diff ol {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 20px;
  font-size: .82rem;
  line-height: 1.65;
}

/* ---------- 08-7 工具光譜 ---------- */
#unit-08 .p2-spectrum-scale {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-spectrum-scale span:last-child {
  text-align: right;
}

#unit-08 .p2-spectrum-track {
  position: relative;
  height: 132px;
  margin: 8px 0 4px;
  border-bottom: 1px solid var(--border);
}

#unit-08 .p2-spectrum-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 62px;
  height: 2px;
  background: var(--border);
}

#unit-08 .p2-spectrum-chip {
  position: absolute;
  top: 6px;
  transform: translateX(-50%);
  white-space: nowrap;
}

#unit-08 .p2-spectrum-chip:nth-child(even) {
  top: 76px;
}

#unit-08 .p2-pos-15 { left: 15%; }
#unit-08 .p2-pos-30 { left: 30%; }
#unit-08 .p2-pos-52 { left: 52%; }
#unit-08 .p2-pos-72 { left: 72%; }
#unit-08 .p2-pos-84 { left: 84%; }
#unit-08 .p2-pos-91 { left: 91%; }

#unit-08 .p2-spectrum-detail {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  background: var(--surface-2);
  min-height: 92px;
}

#unit-08 .p2-detail-empty {
  margin: 0;
  font-size: .84rem;
  line-height: 1.7;
  color: var(--muted);
}

#unit-08 .p2-detail-name {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: .92rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--primary);
}

#unit-08 .p2-detail-line {
  margin: 0 0 4px;
  font-size: .82rem;
  line-height: 1.7;
}

#unit-08 .p2-detail-line:last-child {
  margin-bottom: 0;
}

#unit-08 .p2-detail-line strong {
  font-weight: 800;
  color: var(--muted);
}

#unit-08 .p2-callout--extension {
  border-left-color: var(--accent);
  background: var(--surface-2);
}

#unit-08 .p2-callout--extension strong {
  color: var(--accent);
}

#unit-08 .p2-callout--extension.is-highlight {
  box-shadow: 0 0 0 2px var(--accent);
}

/* ---------- 08-8 API 生命週期 ---------- */
#unit-08 .p2-lifecycle {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#unit-08 .p2-lifecycle-step {
  position: relative;
  padding: 12px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 10px;
  background: var(--surface);
}

#unit-08 .p2-lifecycle-step:not(:last-child)::after {
  content: "→";
  position: absolute;
  top: 50%;
  right: -12px;
  transform: translateY(-50%);
  font-size: .9rem;
  font-weight: 800;
  line-height: 1;
  color: var(--muted);
}

#unit-08 .p2-lifecycle-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 800;
  color: var(--primary);
}

#unit-08 .p2-lifecycle-name {
  display: block;
  font-family: var(--font-mono);
  font-size: .82rem;
  font-weight: 800;
  line-height: 1.5;
}

#unit-08 .p2-lifecycle-detail {
  display: block;
  margin-top: 3px;
  font-size: .78rem;
  line-height: 1.65;
  color: var(--muted);
}

#unit-08 .p2-api-lifecycle .hint {
  margin-top: 14px;
}

/* ---------- 手機 ---------- */
@media (max-width: 859px) {
  #unit-08 .p2-layer-map-body {
    grid-template-columns: 1fr;
  }

  #unit-08 .p2-layer-tools {
    padding: 10px;
  }

  #unit-08 .p2-readouts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #unit-08 .p2-queue .p2-readouts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #unit-08 .p2-compare-table,
  #unit-08 .p2-compare-table tbody,
  #unit-08 .p2-compare-table tr,
  #unit-08 .p2-compare-table th,
  #unit-08 .p2-compare-table td {
    display: block;
    width: auto;
  }

  #unit-08 .p2-compare-table thead {
    display: none;
  }

  #unit-08 .p2-compare-table tr {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
  }

  #unit-08 .p2-compare-table tr:first-child {
    border-top: 0;
  }

  #unit-08 .p2-compare-dim {
    padding: 0 0 6px;
    border-top: 0;
    background: transparent;
    font-size: .86rem;
    color: var(--primary);
  }

  #unit-08 .p2-compare-table td {
    display: block;
    padding: 5px 0;
    border-top: 1px dashed var(--border);
  }

  #unit-08 .p2-compare-table td::before {
    display: block;
    content: attr(data-label);
    margin-bottom: 1px;
    font-size: .76rem;
    font-weight: 800;
    line-height: 1.65;
    color: var(--muted);
  }

  #unit-08 .p2-compare-table tr.is-focus {
    background: var(--primary-weak);
  }

  #unit-08 .p2-compare-table tr.is-focus .p2-compare-dim {
    box-shadow: none;
    background: transparent;
  }

  #unit-08 .p2-framework-compare {
    grid-template-columns: 1fr;
  }

  #unit-08 .p2-prefix-grid {
    grid-template-columns: 1fr;
  }

  #unit-08 .p2-tag-table,
  #unit-08 .p2-tag-table tbody,
  #unit-08 .p2-tag-table tr,
  #unit-08 .p2-tag-table th,
  #unit-08 .p2-tag-table td {
    display: block;
    width: auto;
  }

  #unit-08 .p2-tag-table thead {
    display: none;
  }

  #unit-08 .p2-tag-table tbody tr {
    padding: 8px 10px;
    border-top: 1px solid var(--border);
  }

  #unit-08 .p2-tag-table tbody tr:first-child {
    border-top: 0;
  }

  #unit-08 .p2-tag-table th,
  #unit-08 .p2-tag-table td {
    padding: 2px 0;
    border-top: 0;
  }

  #unit-08 .p2-tag-table tbody th {
    padding-bottom: 4px;
  }

  #unit-08 .p2-tag-table td::before {
    content: attr(data-label) "：";
    font-weight: 800;
    color: var(--muted);
  }

  #unit-08 .p2-spectrum-track {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    height: auto;
    padding: 10px 0 4px;
    border-bottom: 0;
  }

  #unit-08 .p2-spectrum-track::before {
    display: none;
  }

  #unit-08 .p2-spectrum-chip,
  #unit-08 .p2-spectrum-chip:nth-child(even) {
    position: static;
    top: auto;
    transform: none;
    white-space: normal;
  }

  #unit-08 .p2-spectrum-detail {
    min-height: 0;
  }

  #unit-08 .p2-lifecycle {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  #unit-08 .p2-lifecycle-step:not(:last-child)::after {
    content: "↓";
    top: auto;
    right: 50%;
    bottom: -17px;
    transform: translateX(50%);
  }
}

@media (max-width: 460px) {
  #unit-08 .p2-readouts {
    grid-template-columns: 1fr;
  }

  #unit-08 .p2-queue .p2-readouts {
    grid-template-columns: 1fr;
  }

  #unit-08 .p2-tag-output > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  #unit-08 .p2-tag-chart {
    padding: 10px 10px 12px;
  }

  #unit-08 .p2-gb-threshold-label {
    font-size: .66rem;
  }

  #unit-08 .p2-req {
    grid-template-columns: 1.9em minmax(0, 1fr) auto;
    gap: 4px;
  }

  #unit-08 .p2-prefix-panel {
    padding: 10px;
  }

  #unit-08 .p2-queue-list {
    grid-template-columns: 1fr;
  }
}

/* ---------- 列印與動態偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  #unit-08 .p2-chip,
  #unit-08 .p2-layer {
    transition: none;
  }
}

@media print {
  #unit-08 .p2-chip,
  #unit-08 .p2-range,
  #unit-08 .p2-verify {
    display: none !important;
  }

  #unit-08 .p2-compare-table tr.is-focus td,
  #unit-08 .p2-compare-table tr.is-focus .p2-compare-dim {
    background: transparent;
  }
}

/* =========================================================
   P2／P3 修復新增（VE-25／26／28／29／31／32）
   只新增元件樣式；舊版 index 的 spectrum／lifecycle／layer 樣式保留。
   ========================================================= */

/* ---------- 08-1 五層 × 跨層 span ---------- */
#unit-08 .p2-layer-direction {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
  margin: 0 0 8px;
  font-size: .7rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-layer-direction-line {
  font-family: var(--font-mono);
  letter-spacing: .04em;
  color: var(--primary);
}

#unit-08 .p2-layer-matrix {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  background: var(--surface);
}

#unit-08 .p2-layer-head {
  display: grid;
  grid-template-columns: 7.4em minmax(0, 1fr) 4.4em;
  gap: 10px;
  align-items: end;
}

#unit-08 .p2-layer-head-spacer,
#unit-08 .p2-layer-head-end {
  padding-bottom: 6px;
  font-size: .66rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-layer-head-end {
  text-align: right;
}

#unit-08 .p2-layer-names {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#unit-08 .p2-layer-cell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  align-content: start;
  min-width: 0;
  padding: 7px 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  text-align: center;
  transition: background .15s ease, border-color .15s ease;
}

#unit-08 .p2-layer-cell:not(:last-child)::after {
  content: "›";
  position: absolute;
  top: 50%;
  right: -6px;
  z-index: 1;
  transform: translateY(-50%);
  font-size: .8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--muted);
}

#unit-08 .p2-layer-cell.is-active {
  border-color: var(--primary);
  background: var(--primary-weak);
}

#unit-08 .p2-layer-num {
  display: block;
  grid-area: auto;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-family: var(--font-mono);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1.4;
  color: var(--primary);
}

#unit-08 .p2-layer-name {
  font-size: .78rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--text);
  overflow-wrap: anywhere;
}

#unit-08 .p2-layer-desc {
  font-size: .64rem;
  line-height: 1.4;
  color: var(--muted);
  overflow-wrap: anywhere;
}

#unit-08 .p2-span-rows {
  display: grid;
  gap: 2px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

#unit-08 .p2-span-row {
  display: grid;
  grid-template-columns: 7.4em minmax(0, 1fr) 4.4em;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background .15s ease, opacity .15s ease;
}

#unit-08 .p2-span-row.is-focus {
  background: var(--primary-weak);
}

#unit-08 .p2-span-rows.has-focus .p2-span-row:not(.is-focus) {
  opacity: .46;
}

#unit-08 .p2-span-tool {
  min-height: 36px;
  padding: 4px 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .86rem;
  font-weight: 800;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

#unit-08 .p2-span-tool:hover {
  color: var(--primary);
}

#unit-08 .p2-span-tool:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

#unit-08 .p2-span-row.is-focus .p2-span-tool {
  color: var(--primary);
}

#unit-08 .p2-span-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  height: 36px;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

#unit-08 .p2-span-cell {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
}

#unit-08 .p2-span-cell.is-on {
  border-color: var(--primary);
  background: var(--primary-weak);
  box-shadow: inset 0 -2px 0 var(--primary);
}

#unit-08 .p2-span-range {
  display: grid;
  gap: 1px;
  text-align: right;
  line-height: 1.3;
}

#unit-08 .p2-span-range strong {
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
}

#unit-08 .p2-span-range span {
  font-size: .64rem;
  color: var(--muted);
}

#unit-08 .p2-layer-legend {
  display: none;
  margin: 8px 0 0;
  padding-top: 7px;
  border-top: 1px dashed var(--border);
  font-size: .68rem;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- 08-2 offload 分段長條與指令輸出 ---------- */
#unit-08 .p2-offload-viz {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  background: var(--surface-2);
}

#unit-08 .p2-offload-bar {
  position: relative;
  display: flex;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

#unit-08 .p2-offload-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  transition: width .15s ease;
}

#unit-08 .p2-offload-seg-gpu {
  width: 50%;
  background: var(--primary);
  color: var(--on-primary);
}

#unit-08 .p2-offload-seg-cpu {
  flex: 1 1 auto;
  border-left: 2px solid var(--warn);
  background: repeating-linear-gradient(
    135deg,
    var(--surface) 0,
    var(--surface) 5px,
    var(--surface-2) 5px,
    var(--surface-2) 10px
  );
  color: var(--text);
}

#unit-08 .p2-offload-seg-label {
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
}

#unit-08 .p2-offload-seg.is-slim .p2-offload-seg-label,
#unit-08 .p2-offload-seg.is-empty .p2-offload-seg-label {
  display: none;
}

#unit-08 .p2-offload-divider {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 50%;
  width: 2px;
  background: var(--warn);
  transform: translateX(-1px);
  transition: left .15s ease;
  pointer-events: none;
}

#unit-08 .p2-offload-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: .68rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-offload-legend {
  display: grid;
  gap: 3px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: .72rem;
  line-height: 1.55;
  color: var(--muted);
}

#unit-08 .p2-offload-legend li {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

#unit-08 .p2-offload-swatch {
  flex: none;
  width: 13px;
  height: 13px;
  margin-top: .18em;
  border-radius: 3px;
}

#unit-08 .p2-offload-swatch-gpu {
  background: var(--primary);
}

#unit-08 .p2-offload-swatch-cpu {
  border: 1px dashed var(--warn);
  background: repeating-linear-gradient(
    135deg,
    var(--surface) 0,
    var(--surface) 3px,
    var(--surface-2) 3px,
    var(--surface-2) 6px
  );
}

#unit-08 .p2-offload-move {
  margin: 7px 0 0;
  font-size: .72rem;
  line-height: 1.55;
  color: var(--text);
}

#unit-08 .p2-command-output {
  margin: 0 14px 14px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-2);
}

#unit-08 .p2-command-output-title {
  margin: 0 0 6px;
  font-size: .8rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--text);
}

#unit-08 .p2-command-output dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

#unit-08 .p2-command-output dl > div {
  display: grid;
  grid-template-columns: 6.6em minmax(0, 1fr);
  gap: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

#unit-08 .p2-command-output dl > div:first-child {
  padding-top: 0;
  border-top: 0;
}

#unit-08 .p2-command-output dt {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 800;
  line-height: 1.6;
  color: var(--muted);
}

#unit-08 .p2-command-output dd {
  margin: 0;
  font-size: .78rem;
  line-height: 1.65;
  color: var(--text);
}

/* ---------- 08-4 兩條路徑 ---------- */
#unit-08 .p2-path-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 12px;
}

#unit-08 .p2-path-panel {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--p2-radius);
  background: var(--surface);
}

#unit-08 .p2-path-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
}

#unit-08 .p2-path-head h4 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.4;
}

#unit-08 .p2-path-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  margin: 10px 0;
  padding: 0;
  list-style: none;
}

#unit-08 .p2-path-steps li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: .76rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

#unit-08 .p2-path-steps li:not(:last-child)::after {
  content: "→";
  margin-left: 2px;
  font-weight: 800;
  color: var(--primary);
}

#unit-08 .p2-path-num {
  font-family: var(--font-mono);
  font-size: .62rem;
  font-weight: 800;
  color: var(--primary);
}

#unit-08 .p2-path-cost {
  margin: auto 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: .76rem;
  line-height: 1.6;
  color: var(--muted);
}

#unit-08 .p2-path-shared {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: .8rem;
  line-height: 1.65;
  color: var(--text);
}

/* ---------- 08-5 這一輪／下一輪與回傳 ---------- */
#unit-08 .p2-queue-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  margin-top: 12px;
}

#unit-08 .p2-queue-band {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

#unit-08 .p2-band-now {
  border-top: 3px solid var(--primary);
}

#unit-08 .p2-band-next {
  border-top: 3px solid var(--warn);
}

#unit-08 .p2-band-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 8px;
}

#unit-08 .p2-band-name {
  font-size: .86rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--text);
}

#unit-08 .p2-band-sub {
  font-size: .68rem;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-queue-group {
  display: grid;
  gap: 5px;
  margin: 8px 0;
  padding: 0;
  list-style: none;
}

#unit-08 .p2-band-foot {
  margin: 0;
  font-size: .68rem;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-queue-next-arrow {
  align-self: center;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  color: var(--primary);
}

#unit-08 .p2-queue-return {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  padding: 7px 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: .76rem;
  line-height: 1.55;
  color: var(--text);
}

#unit-08 .p2-queue-return-arrow {
  flex: none;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
  color: var(--primary);
}

#unit-08 .p2-queue-empty {
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: .72rem;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
}

/* ---------- 08-7 2×2 定位 ---------- */
#unit-08 .p2-quadrant {
  margin: 8px 0 0;
}

#unit-08 .p2-quad-frame {
  display: grid;
  grid-template-columns: 3.2em minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
}

#unit-08 .p2-quad-yaxis {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  padding: 4px 0;
  font-size: .64rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--muted);
  text-align: right;
}

#unit-08 .p2-quad-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

#unit-08 .p2-quad-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 112px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

#unit-08 .p2-quad-cell[data-quad="local-manage"],
#unit-08 .p2-quad-cell[data-quad="server-engine"] {
  background: var(--surface-2);
}

#unit-08 .p2-quad-label {
  margin: 0;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.45;
  color: var(--muted);
}

#unit-08 .p2-quad-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
}

#unit-08 .p2-quad-chip {
  min-height: 40px;
  padding: 6px 10px;
  font-size: .78rem;
}

#unit-08 .p2-quad-empty {
  margin: auto 0;
  font-size: .72rem;
  line-height: 1.55;
  color: var(--muted);
}

#unit-08 .p2-quad-xaxis {
  display: flex;
  justify-content: space-between;
  margin: 6px 0 0 3.2em;
  padding: 0 4px;
  font-size: .66rem;
  font-weight: 800;
  line-height: 1.45;
  color: var(--muted);
}

#unit-08 .p2-quad-note {
  margin: 10px 0 0;
  font-size: .76rem;
  line-height: 1.65;
  color: var(--muted);
}

/* ---------- 08-8 API 生命週期 ---------- */
#unit-08 .p2-api-map {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(150px, .8fr) minmax(0, 1.2fr);
  gap: 12px;
  align-items: stretch;
}

#unit-08 .p2-api-row {
  display: contents;
}

#unit-08 .p2-api-node {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

#unit-08 .p2-api-client {
  border-top: 3px solid var(--primary);
}

#unit-08 .p2-api-server {
  border-top: 3px solid var(--accent);
}

#unit-08 .p2-api-node-kicker {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .03em;
  line-height: 1.5;
  color: var(--primary);
}

#unit-08 .p2-api-node-text {
  margin: 6px 0 0;
  font-size: .82rem;
  line-height: 1.6;
}

#unit-08 .p2-api-node-muted {
  font-size: .74rem;
  line-height: 1.55;
  color: var(--muted);
}

#unit-08 .p2-api-link {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
}

#unit-08 .p2-api-link-out,
#unit-08 .p2-api-link-back {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--muted);
}

#unit-08 .p2-api-arrow {
  display: inline-block;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  color: var(--primary);
}

#unit-08 .p2-api-label {
  padding: 4px 6px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary-weak);
  font-size: .74rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--primary);
}

#unit-08 .p2-api-steps {
  margin: 6px 0;
  padding-left: 1.2em;
  font-size: .8rem;
  line-height: 1.7;
}

#unit-08 .p2-api-wait {
  display: grid;
  gap: 2px;
  margin: 8px 0;
  padding: 6px 8px;
  border: 1px dashed var(--warn);
  border-radius: 7px;
  background: repeating-linear-gradient(
    135deg,
    var(--surface) 0,
    var(--surface) 5px,
    var(--surface-2) 5px,
    var(--surface-2) 10px
  );
  font-size: .72rem;
  line-height: 1.55;
  color: var(--text);
}

#unit-08 .p2-api-wait-label {
  font-family: var(--font-mono);
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--warn);
}

#unit-08 .p2-api-return-note {
  margin: 0;
  font-size: .72rem;
  line-height: 1.55;
  color: var(--muted);
}

#unit-08 .p2-api-cloud {
  position: relative;
  grid-column: 2 / 4;
  margin-top: 2px;
  padding: 8px 10px 8px 14px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: .76rem;
  line-height: 1.6;
  color: var(--text);
}

#unit-08 .p2-api-cloud-line {
  position: absolute;
  top: -14px;
  left: 72%;
  height: 14px;
  border-left: 1px dashed var(--accent);
}

#unit-08 .p2-quad-y-short {
  display: none;
}

#unit-08 .p2-api-cloud p {
  display: grid;
  gap: 2px;
  margin: 0;
}

#unit-08 .p2-api-cloud span {
  font-size: .72rem;
  line-height: 1.55;
  color: var(--muted);
}

#unit-08 .p2-api-map .hint {
  grid-column: 1 / -1;
  margin-top: 2px;
}

/* ---------- 新增元件的斷點 ---------- */
@media (max-width: 859px) {
  #unit-08 .p2-layer-head,
  #unit-08 .p2-span-row {
    grid-template-columns: 6.2em minmax(0, 1fr) 3.8em;
    gap: 8px;
  }

  #unit-08 .p2-layer-matrix {
    padding: 8px;
  }

  #unit-08 .p2-path-compare {
    grid-template-columns: 1fr;
  }

  #unit-08 .p2-api-map {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #unit-08 .p2-api-row {
    display: grid;
    gap: 6px;
  }

  #unit-08 .p2-api-cloud,
  #unit-08 .p2-api-map .hint {
    grid-column: 1 / -1;
  }

  #unit-08 .p2-api-cloud-line {
    top: -9px;
    left: 50%;
    height: 9px;
  }

  #unit-08 .p2-api-arrow-out {
    transform: rotate(90deg);
  }

  #unit-08 .p2-api-arrow-back {
    transform: rotate(-90deg);
  }

  #unit-08 .p2-quad-frame {
    grid-template-columns: 2.9em minmax(0, 1fr);
  }

  #unit-08 .p2-quad-xaxis {
    margin-left: 2.9em;
  }

  #unit-08 .p2-quad-cell {
    min-height: 104px;
    padding: 8px;
  }
}

@media (max-width: 460px) {
  #unit-08 .p2-layer-direction {
    font-size: .64rem;
  }

  #unit-08 .p2-layer-head {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  #unit-08 .p2-layer-head-spacer,
  #unit-08 .p2-layer-head-end {
    display: none;
  }

  #unit-08 .p2-layer-cell {
    padding: 5px 3px;
  }

  #unit-08 .p2-layer-cell:not(:last-child)::after {
    display: none;
  }

  #unit-08 .p2-layer-name {
    font-size: .66rem;
  }

  #unit-08 .p2-layer-desc {
    display: none;
  }

  #unit-08 .p2-span-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "tool range"
      "track track";
    gap: 4px 8px;
    min-height: 0;
    padding: 6px 4px;
  }

  #unit-08 .p2-span-tool {
    grid-area: tool;
    min-height: 32px;
  }

  #unit-08 .p2-span-range {
    grid-area: range;
    display: flex;
    align-items: baseline;
    gap: 4px;
  }

  #unit-08 .p2-span-track {
    grid-area: track;
    height: 26px;
  }

  #unit-08 .p2-layer-legend {
    display: block;
  }

  #unit-08 .p2-offload-bar {
    height: 40px;
  }

  #unit-08 .p2-offload-legend {
    grid-template-columns: 1fr;
  }

  #unit-08 .p2-command-output {
    margin: 0 10px 10px;
  }

  #unit-08 .p2-command-output dl > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  #unit-08 .p2-path-steps li {
    white-space: normal;
  }

  #unit-08 .p2-queue-board {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  #unit-08 .p2-queue-next-arrow {
    justify-self: center;
    transform: rotate(90deg);
  }

  #unit-08 .p2-quad-frame {
    grid-template-columns: 2.5em minmax(0, 1fr);
    gap: 4px;
  }

  #unit-08 .p2-quad-xaxis {
    margin-left: 2.5em;
    font-size: .62rem;
  }

  #unit-08 .p2-quad-grid {
    gap: 4px;
  }

  #unit-08 .p2-quad-cell {
    min-height: 96px;
    padding: 7px;
    gap: 6px;
  }

  #unit-08 .p2-quad-label {
    font-size: .6rem;
  }

  #unit-08 .p2-quad-chip {
    min-height: 36px;
    padding: 5px 8px;
    font-size: .74rem;
  }

  #unit-08 .p2-quad-yaxis {
    font-size: .6rem;
  }

  #unit-08 .p2-quad-y-full {
    display: none;
  }

  #unit-08 .p2-quad-y-short {
    display: inline;
  }

  #unit-08 .p2-api-node {
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #unit-08 .p2-layer-cell,
  #unit-08 .p2-span-row,
  #unit-08 .p2-offload-seg,
  #unit-08 .p2-offload-divider {
    transition: none;
  }
}

@media print {
  #unit-08 .p2-quad-chip,
  #unit-08 .p2-span-tool,
  #unit-08 .p2-api-map .hint {
    display: none !important;
  }
}
