/* Signal lab: independent flows and per-device PEP controls. */
.signal-lab { --current-signal: #d7f5a5; }
.signal-lab button, .signal-lab select, .signal-lab input { touch-action: manipulation; }
.signal-lab :is(button, select, input, summary, [tabindex]):focus-visible { outline: 2px solid #e3ffb7; outline-offset: 4px; }
.signal-lab .lab-scene-row { gap: 14px; flex-wrap: wrap; padding-block: 22px; }
.signal-lab .scene-button { font-size: 12px; padding: 8px 15px; }
.signal-lab .connection-summary { font-size: 12px; gap: 9px; }
#blocked-count { color: #ffc399; }
.signal-step-heading, .selection-tools, .wiring-figure figcaption, .wiring-legend, #signal-legend { display: flex; align-items: center; gap: 10px; }
.signal-step-heading { margin-bottom: 12px; }
.signal-step-heading h3, .wiring-figure h3 { font-size: 14px; font-weight: 500; }
.signal-step-heading small, #view-signal { font-size: 11px; color: #b0c0a6; }
.selection-tools { margin-left: auto; gap: 4px; }
.selection-tools button, .signal-only { font-size: 11px; color: #c9d9bd; border-radius: 3px; padding: 5px 8px; min-height: 30px; }
.selection-tools button:hover, .signal-only:hover { color: #edffd9; background: #354b39; }
.selection-tools button[aria-disabled="true"] { color: #8a9d80; cursor: default; background: transparent; }
.signal-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.signal-option { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; min-width: 0; border: 1px solid #455b49; border-radius: 6px; background: #20362a; padding-right: 5px; }
.signal-option.active { background: #2b4031; border-color: var(--signal-color); }
.signal-button { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 9px; align-items: center; min-height: 63px; min-width: 0; padding: 10px; text-align: left; color: #d9e4d2; border-radius: 5px; }
.signal-button:hover { background: #d7f5a509; }
.signal-button > .icon { width: 20px; height: 20px; color: var(--signal-color); }
.signal-button strong { font-size: 13px; font-weight: 500; }
.signal-button small { display: block; color: #aebeaa; font-size: 10px; margin-top: 3px; }
.signal-active-marker { display: grid; place-items: center; color: #213725; width: 15px; height: 15px; border: 1px solid #829279; border-radius: 3px; }
.signal-active-marker .icon { width: 12px; height: 12px; stroke-width: 2.5; opacity: 0; }
.signal-button.active .signal-active-marker { background: var(--signal-color); border-color: var(--signal-color); }
.signal-button.active .signal-active-marker .icon { opacity: 1; }
.signal-only { color: #acbda3; white-space: nowrap; border-left: 1px solid #475d47; padding-inline: 8px; border-radius: 0 3px 3px 0; }
.wiring-figure { margin: 18px 0 0; padding: 18px 20px 14px; background: #192f25; border: 1px solid #3c5240; border-radius: 8px; }
.wiring-figure figcaption { justify-content: space-between; }
.signal-hint { color: #b0c2a5; font-size: 12px; line-height: 1.7; margin: 5px 0 14px; }
.wiring-board { display: grid; grid-template-columns: minmax(0, min(25%, 206px)) minmax(0, 1fr) minmax(0, min(25%, 206px)); align-items: center; position: relative; isolation: isolate; background-image: radial-gradient(#8ca58126 .85px, transparent .85px); background-size: 14px 14px; }
.wiring-board .route-lines { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; overflow: visible; pointer-events: none; }
.map-column { z-index: 1; min-width: 0; }
.map-column-label { display: block; color: #adc19d; font-size: 11px; margin: 0 0 7px 2px; }
.map-column:last-child .map-column-label { text-align: right; margin-right: 2px; }
.map-endpoints { display: grid; gap: 12px; }
.map-node { width: 100%; min-width: 0; min-height: 49px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; position: relative; border: 1px solid #547050; border-radius: 6px; background: #253e2f; color: #eff5e9; text-align: left; }
.map-node[aria-pressed="true"] { background: #334d35; border-color: #cbe99e; }
.map-node:hover:enabled { background: #334b37; border-color: #bdd8a4; }
.map-node:disabled { cursor: not-allowed; color: #a5b49c; border-color: #445646; background: #203428; }
.map-node > .icon { width: 20px; height: 20px; flex-shrink: 0; color: #bfd7ad; }
.map-identity { min-width: 0; }
.map-identity strong, .map-identity small { display: block; }
.map-identity strong { font-size: 13px; line-height: 1.4; font-weight: 500; }
.map-identity small { font-size: 10px; color: #b2c2a6; line-height: 1.4; margin-top: 2px; }
.map-hub { z-index: 1; justify-self: center; display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; width: 90px; height: 78px; margin-top: 20px; border-radius: 7px; border: 1px solid #6e8b5a; background: #304b32; color: #d9edbf; }
.map-hub .icon { width: 22px; height: 22px; }
.map-hub strong { font-size: 12px; font-weight: 500; }
.map-ports { position: absolute; top: 50%; transform: translateY(-50%); display: grid; grid-auto-rows: 8px; align-items: center; pointer-events: none; }
[data-map-device="sources"] .map-ports { right: -4px; }
[data-map-device="receivers"] .map-ports { left: -4px; }
.map-ports i { width: 6px; height: 6px; visibility: hidden; border-radius: 50%; border: 1.5px solid var(--signal-color); }
.map-ports i.connected { visibility: visible; background: var(--signal-color); }
.map-ports i.blocked { background: #192f25; }
.wiring-legend { flex-wrap: wrap; justify-content: space-between; margin-top: 15px; padding-top: 11px; border-top: 1px solid #3b4f3c; font-size: 11px; color: #bbcab2; }
#signal-legend { flex-wrap: wrap; gap: 12px; }
#signal-legend span { display: inline-flex; align-items: center; gap: 5px; }
#signal-legend span::before { content: ''; width: 13px; height: 3px; border-radius: 2px; background: var(--signal-color); }
.line-style-key { font-size: 10px; color: #a6b79c; }
.signal-route .route-path { fill: none; stroke: var(--route-color); stroke-width: 2.4; stroke-linecap: round; opacity: 1; pointer-events: stroke; }
.signal-route .lab-route-blocked { stroke-dasharray: 4 5; }
.signal-route .route-pulse { stroke: #f7ffef; stroke-width: 1.5; opacity: .78; pointer-events: none; }
.device-settings { padding-block: 16px 22px; border-top: 1px solid #35473a; }
.device-settings > summary { font-size: 14px; font-weight: 500; color: #dce9d2; cursor: pointer; width: fit-content; }
.settings-group { margin-top: 15px; }
.settings-group h4 { font-size: 12px; color: #b4c6a7; margin-bottom: 8px; font-weight: 500; }
.device-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.device-card { min-width: 0; border: 1px solid #4a5c48; border-radius: 7px; background: #21392c; overflow: hidden; transition: border-color .2s, background .2s; }
.device-card.selected { border-color: var(--current-signal); background: #2c4432; box-shadow: 0 0 0 1px var(--current-signal); }
.device-card.unsupported { background: #1b3026; border-color: #3c4c3e; }
.device-connect { display: flex; align-items: center; gap: 11px; width: 100%; padding: 14px 14px 11px; min-height: 67px; text-align: left; color: #edf2e7; }
.device-connect:hover:enabled { background: #cfea9e0c; }
.device-connect:disabled { cursor: not-allowed; color: #acb7a7; }
.device-symbol { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 5px; background: #354d38; color: var(--current-signal); flex-shrink: 0; }
.device-symbol .icon { width: 22px; height: 22px; }
.unsupported .device-symbol { color: #8c9e83; background: #2c3f31; }
.device-identity { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.device-identity strong { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.device-identity small { font-size: 11px; color: #a4b99b; }
.device-action-icon { color: #a8bd98; margin-left: auto; flex-shrink: 0; width: 20px; height: 20px; }
.device-action-icon .icon { width: 18px; height: 18px; }
[data-device="sources"] .device-action-icon { visibility: hidden; }
[data-device="sources"].selected .device-action-icon { visibility: visible; color: var(--current-signal); }
.unsupported .device-action-icon { visibility: hidden; }
.device-capabilities { display: flex; flex-wrap: wrap; gap: 4px; margin-inline: 14px; }
.capability { font: 10px/1.5 var(--mono); padding: 2px 5px; border: 1px solid #4a5f46; border-radius: 3px; color: #c4d2ba; }
.capability.current:not(.unavailable) { color: var(--signal-color); border-color: var(--signal-color); }
.capability.unavailable { color: #93a08d; border-color: #3e5041; }
.device-route { padding: 11px 14px; min-height: 62px; display: flex; align-items: center; gap: 4px; }
.device-route > div { min-width: 0; }
.device-route-title { display: block; color: #dce9d2; font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.device-route-status { display: block; font-size: 11px; color: #9eb490; margin-top: 2px; }
.device-flows { padding: 7px 14px 0; }
.device-flow { display: grid; grid-template-columns: 60px 1fr 28px; align-items: center; gap: 6px; min-height: 34px; padding-block: 4px; border-bottom: 1px solid #41543c; }
.device-flow[hidden] { display: none; }
.flow-label { color: var(--signal-color); font: 11px/1.5 var(--mono); }
.flow-source, .flow-status { display: block; font-size: 11px; font-weight: 400; }
.flow-status { color: #acbc9f; font-size: 10px; }
.device-flow[data-status="blocked"] .flow-status { color: #ffcca3; }
.device-flow[data-status="encrypted"] .flow-status { color: #d7f5a5; }
.device-flow[data-status="unsupported"] :is(.flow-label, .flow-source, .flow-status) { color: #98ab90; }
.receiver-connect-hint { font-size: 11px; color: #c0d0b5; padding: 9px 14px; }
.unsupported .device-route-title, .unsupported .device-route-status { color: #9fad96; }
.route-disconnect { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 1px solid #4a6047; border-radius: 4px; margin-left: auto; color: #b5c7aa; }
.route-disconnect .icon { width: 13px; height: 13px; }
.route-disconnect:enabled:hover { background: #405440; color: #fff; }
.route-disconnect:disabled { visibility: hidden; }
.pep-controls { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-inline: 14px; padding-top: 10px; border-top: 1px solid #41543f; }
.pep-toggle { display: flex; align-items: center; gap: 5px; font-size: 11px; white-space: nowrap; cursor: pointer; color: #c8d7bd; min-height: 28px; }
.pep-toggle input { accent-color: #d7f5a5; width: 14px; height: 14px; cursor: pointer; margin: 0 1px 0 0; }
.pep-toggle .icon { width: 12px; height: 12px; }
.pep-enabled .pep-toggle { color: #ddf5ba; }
.pep-key { display: flex; gap: 5px; align-items: center; color: #a7b89c; font-size: 11px; white-space: nowrap; }
.pep-key select { padding: 3px 6px; min-width: 45px; height: 28px; border: 1px solid #5e7551; border-radius: 4px; background: #1b3025; color: #e0f2cf; font-size: 12px; color-scheme: dark; }
.pep-key select:disabled { opacity: .45; }
.pep-help { color: #a3b597; font-size: 10px; line-height: 1.6; margin: 3px 14px 11px; }
.signal-lab .lab-bottom { font-size: 12px; line-height: 1.8; padding-block: 15px; min-height: 64px; }
.signal-lab .lab-bottom p { color: #d4e5c3; }
.signal-lab .lab-bottom > span { font-size: 11px; color: #a1b390; }
.route-overview { padding-block: 22px 24px; border-top: 1px solid #35473a; }
.route-overview-heading { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.route-overview-heading h3 { font-size: 14px; font-weight: 500; }
.route-overview-heading > p { font-size: 11px; color: #a4b899; }
.route-overview-heading > span { font-size: 11px; color: #c9e4ab; margin-left: auto; }
.table-scroll { overflow-x: auto; border: 1px solid #40523f; border-radius: 6px; scrollbar-color: #6b8359 #20352a; }
.routing-table { width: 100%; min-width: 800px; border-collapse: collapse; font-size: 12px; text-align: left; }
.routing-table th, .routing-table td { padding: 13px 12px; border-bottom: 1px solid #384c3b; }
.routing-table tr:last-child :is(th, td) { border-bottom: 0; }
.routing-table thead th { background: #263d2e; color: #c5d8b6; font-size: 11px; font-weight: 500; }
.routing-table th:first-child { width: 16%; }
.routing-table th:not(:first-child) { width: 21%; }
.routing-table tbody th { background: #1b3126; font-weight: 500; }
.routing-table th strong { display: block; font-weight: 500; }
.routing-table th small { display: block; color: #97ae89; font-weight: 400; font-size: 10px; margin-top: 4px; }
.table-signal { display: inline-flex; align-items: center; gap: 7px; }
.table-signal::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--signal-color); }
.route-cell { display: flex; align-items: center; gap: 6px; }
.cell-source { display: block; font-weight: 400; color: #d9e6ce; font-size: 12px; }
.cell-status { display: block; font-size: 10px; color: #9db28f; margin-top: 4px; }
.current-signal { background: #cfea9e05; }
[data-status="blocked"] .cell-status { color: #ffc399; }
[data-status="encrypted"] .cell-status { color: #d7f5a5; }
[data-status="unsupported"] :is(.cell-source, .cell-status) { color: #8ea181; }
.pep-explainer { border-top: 1px solid #35473a; padding-block: 16px 20px; }
.pep-explainer summary { color: #c4d4b7; font-size: 12px; cursor: pointer; width: fit-content; }
.pep-explainer p { color: #a6b89a; font-size: 12px; line-height: 1.9; margin-top: 11px; max-width: 900px; }
.pep-explainer a { color: #d1ecae; text-decoration: underline; text-underline-offset: 3px; }
.lab-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.lab-no-script { margin-block: 20px; font-size: 14px; color: #ffcdab; }

@media (max-width: 1100px) {
  .signal-button { grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
  .signal-button > .icon { display: none; }
}
@media (max-width: 850px) {
  .device-list { grid-template-columns: repeat(3, minmax(232px, 1fr)); overflow-x: auto; gap: 12px; padding: 3px 2px 12px; scrollbar-color: #6b8359 #20352a; scroll-snap-type: x proximity; }
  .device-card { scroll-snap-align: start; }
  .settings-group h4::after { content: ' · 可横向滑动'; font-size: 10px; color: #9aac90; }
  .wiring-figure { padding-inline: 16px; }
  .signal-option { padding-right: 2px; }
  .signal-only { padding-inline: 6px; }
}
@media (max-width: 690px) {
  .signal-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .wiring-board { grid-template-columns: minmax(0, 28%) minmax(0, 1fr) minmax(0, 28%); }
  .map-node { justify-content: center; min-height: 51px; padding: 6px 4px; text-align: center; }
  .map-node > .icon { display: none; }
  .map-hub { width: 50px; height: 67px; }
  .map-hub strong, .map-identity strong { font-size: 11px; }
  .map-identity small { font-size: 9px; }
}
@media (max-width: 600px) {
  #lab .section-heading h2 { text-wrap: balance; }
  .signal-lab { padding-inline: 14px; }
  .signal-lab .lab-toolbar { height: 64px; }
  .signal-lab .reset-button { font-size: 11px; padding: 10px 0 10px 10px; }
  .signal-lab .simulation-badge { font-size: 9px; }
  .signal-lab .lab-scene-row { padding-block: 17px 15px; gap: 10px; }
  .signal-lab .scene-picker { width: 100%; }
  .signal-lab .scene-button { flex: 1; font-size: 11px; padding: 8px; }
  .signal-lab .connection-summary { font-size: 11px; }
  .signal-step-heading { gap: 6px; }
  .selection-tools { gap: 0; }
  .selection-tools button { padding-inline: 6px; }
  .signal-button { min-height: 53px; padding: 7px; }
  .signal-active-marker { width: 13px; height: 13px; }
  .signal-button strong { font-size: 12px; }
  .wiring-figure { margin-top: 13px; padding: 13px 10px 10px; }
  .signal-hint { font-size: 11px; margin-bottom: 9px; }
  .wiring-legend { align-items: start; gap: 6px; margin-top: 12px; }
  .signal-lab .lab-bottom { font-size: 11px; line-height: 1.9; }
  .route-overview-heading > p { width: 100%; order: 3; }
  .route-overview-heading > span { font-size: 10px; }
  .pep-explainer summary, .pep-explainer p { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .signal-route .route-pulse { display: none; }
}
