.bit-threshold-lab {
  --btl-bg: #0f1724;
  --btl-card: rgba(255, 255, 255, 0.075);
  --btl-card-strong: rgba(255, 255, 255, 0.11);
  --btl-line: rgba(255, 255, 255, 0.16);
  --btl-text: #eef3f8;
  --btl-muted: #b9c5d3;
  --btl-low: #4f88ff;
  --btl-high: #5bd68b;
  --btl-amb: #f6b23d;
  --btl-danger: #ff6b6b;
  margin: 2.5rem auto;
  color: var(--btl-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.bit-threshold-lab * {
  box-sizing: border-box;
}

.btl-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1.1rem, 2.4vw, 2rem);
  border: 1px solid var(--btl-line);
  border-radius: 26px;
  background:
    radial-gradient(circle at 20% 10%, rgba(79, 136, 255, 0.18), transparent 34%),
    radial-gradient(circle at 82% 20%, rgba(91, 214, 139, 0.14), transparent 30%),
    linear-gradient(135deg, #111827, var(--btl-bg));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.btl-header {
  max-width: 960px;
  margin-bottom: 1.25rem;
}

.btl-kicker {
  display: inline-block;
  margin: 0 0 0.4rem;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--btl-line);
  border-radius: 999px;
  color: var(--btl-muted);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.btl-header h2 {
  margin: 0 0 0.65rem;
  color: var(--btl-text);
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  line-height: 1.08;
}

.btl-header p,
.btl-note,
.btl-explanation,
.btl-quantum-note,
.btl-model-note {
  color: var(--btl-muted);
  line-height: 1.65;
}

.btl-model-note {
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--btl-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.055);
}

.btl-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(300px, 1.55fr);
  gap: 1rem;
  align-items: stretch;
}

.btl-card {
  border: 1px solid var(--btl-line);
  border-radius: 20px;
  padding: 1rem;
  background: var(--btl-card);
  backdrop-filter: blur(10px);
}

.btl-card h3 {
  margin: 0 0 0.55rem;
  color: var(--btl-text);
  font-size: 1.08rem;
}

.btl-controls,
.btl-reading,
.btl-combo,
.btl-criterion {
  min-width: 0;
}

.btl-visual {
  min-width: 0;
}

.btl-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.btl-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 168px;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--btl-line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--btl-text);
  font-weight: 800;
  font-size: 0.92rem;
}

.btl-pill-low {
  border-color: rgba(79, 136, 255, 0.55);
  background: rgba(79, 136, 255, 0.16);
}

.btl-pill-high {
  border-color: rgba(91, 214, 139, 0.55);
  background: rgba(91, 214, 139, 0.16);
}

.btl-pill-amb {
  border-color: rgba(246, 178, 61, 0.70);
  background: rgba(246, 178, 61, 0.18);
}

.btl-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem 0.75rem;
  align-items: center;
  margin: 0.88rem 0;
  color: var(--btl-muted);
}

.btl-control span {
  font-weight: 650;
}

.btl-control strong {
  color: var(--btl-text);
  font-variant-numeric: tabular-nums;
}

.btl-control input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--btl-amb);
}

#btl-canvas {
  display: block;
  width: 100%;
  height: 360px;
  border: 1px solid var(--btl-line);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.18);
}

.btl-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.9rem;
  margin-top: 0.8rem;
  color: var(--btl-muted);
  font-size: 0.88rem;
}

.btl-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btl-legend i {
  width: 18px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.btl-low { background: rgba(79, 136, 255, 0.55); }
.btl-high { background: rgba(91, 214, 139, 0.55); }
.btl-amb { background: rgba(246, 178, 61, 0.70); }
.btl-line { background: rgba(255, 255, 255, 0.92); }
.btl-noise-mark { background: rgba(255, 255, 255, 0.22); border: 1px solid rgba(255, 255, 255, 0.65); }

.btl-readout {
  display: grid;
  gap: 0.65rem;
}

.btl-readout div,
.btl-power,
.btl-formula {
  padding: 0.8rem;
  border: 1px solid var(--btl-line);
  border-radius: 16px;
  background: var(--btl-card-strong);
}

.btl-readout span,
.btl-power span {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--btl-muted);
  font-size: 0.86rem;
}

.btl-readout strong,
.btl-power strong,
.btl-formula {
  color: var(--btl-text);
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
}

.btl-formula {
  margin-top: 0.7rem;
  text-align: center;
  font-weight: 800;
  color: var(--btl-amb);
}

.btl-explanation {
  margin-bottom: 0;
}

.btl-power {
  margin: 0.7rem 0 0.85rem;
  text-align: center;
}

.btl-power span {
  font-size: 1.15rem;
  color: var(--btl-amb);
  font-weight: 800;
}

.btl-cells {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16px, 1fr));
  gap: 4px;
  min-height: 58px;
  align-items: center;
}

.btl-cells span,
.btl-cells em {
  min-height: 16px;
  border-radius: 5px;
  background: linear-gradient(135deg, rgba(79, 136, 255, 0.55), rgba(91, 214, 139, 0.55));
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.btl-cells em {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 0.45rem;
  color: var(--btl-text);
  background: rgba(255, 255, 255, 0.10);
  font-style: normal;
  font-size: 0.76rem;
  white-space: nowrap;
}

.btl-quantum-note {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-left: 4px solid var(--btl-amb);
  border-radius: 18px;
  background: rgba(246, 178, 61, 0.10);
}

.btl-quantum-note strong {
  color: var(--btl-text);
}

@media (max-width: 860px) {
  .btl-grid {
    grid-template-columns: 1fr;
  }

  #btl-canvas {
    height: 300px;
  }
}

@media (max-width: 520px) {
  .btl-shell {
    border-radius: 18px;
    padding: 1rem;
  }

  .btl-card {
    border-radius: 16px;
    padding: 0.85rem;
  }

  .btl-control {
    grid-template-columns: 1fr;
  }

  .btl-control strong {
    justify-self: start;
  }

  #btl-canvas {
    height: 260px;
  }
}
