/**
 * 5G NR Type I Codebook Visualizer - local styles (max-width 800px, Courier New)
 */
#cb5g-root {
  max-width: 800px;
  margin: 0 auto;
  background: #000;
  color: #eee;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  padding: 12px;
  box-sizing: border-box;
}

#cb5g-root * {
  box-sizing: border-box;
}

.cb5g-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}

.cb5g-controls {
  flex: 0 0 260px;
  min-width: 200px;
  padding: 12px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
}

.cb5g-controls h3 {
  margin: 0 0 10px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #0fa;
}

.cb5g-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.cb5g-row label {
  flex-shrink: 0;
  min-width: 100px;
  font-size: 12px;
  color: #ccc;
}

.cb5g-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: #0fa;
}

.cb5g-row .cb5g-spin {
  width: 72px;
  min-width: 72px;
  background: #2a2a2a;
  color: #fff;
  border: 1px solid #444;
  padding: 6px 8px;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  text-align: left;
}

.cb5g-row .cb5g-spin::-webkit-inner-spin-button,
.cb5g-row .cb5g-spin::-webkit-outer-spin-button {
  opacity: 0.5;
  filter: brightness(0.85);
}

.cb5g-row .cb5g-val {
  flex-shrink: 0;
  min-width: 48px;
  font-size: 11px;
  color: #0fa;
  text-align: right;
}

.cb5g-row select {
  flex: 1;
  min-width: 0;
  background: #2a2a2a;
  color: #fff;
  border: 1px solid #444;
  padding: 6px 8px;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
}

.cb5g-legend {
  font-size: 11px;
  margin-top: 10px;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 8px;
}

.cb5g-main {
  flex: 1;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cb5g-viewport-wrap {
  flex: 0 0 320px;
  min-height: 320px;
  height: 420px;
  position: relative;
  background: #0a0a0a;
  border-radius: 6px 6px 0 0;
  overflow: hidden;
  border: 1px solid #333;
  border-bottom: none;
}

.cb5g-viewport-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.cb5g-viewport-wrap .cb5g-3d-scale-btn {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 10;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #555;
  border-radius: 4px;
  background: rgba(26, 26, 26, 0.9);
  color: #0fa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cb5g-viewport-wrap .cb5g-3d-scale-btn:hover {
  background: rgba(0, 255, 170, 0.25);
  border-color: #0fa;
}
.cb5g-viewport-wrap .cb5g-3d-scale-btn .cb5g-scale-icon {
  display: block;
}

.cb5g-viewport-wrap .cb5g-pol-canvas {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 105px;
  height: 105px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #333;
  border-radius: 4px;
  z-index: 5;
  pointer-events: none;
}

.cb5g-viewport-wrap .cb5g-w-complex-canvas {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 110px;
  height: 110px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #333;
  border-radius: 4px;
  z-index: 5;
  pointer-events: none;
}

.cb5g-cam-btns {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.cb5g-cam-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #555;
  border-radius: 4px;
  background: rgba(26, 26, 26, 0.9);
  color: #0fa;
  cursor: pointer;
  font-family: "Courier New", Courier, monospace;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.cb5g-cam-btn:hover {
  background: rgba(0, 255, 170, 0.25);
  border-color: #0fa;
}

.cb5g-plots-row {
  flex: 0 0 180px;
  display: flex;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 0 0 6px 6px;
  min-height: 160px;
}

.cb5g-polar-cell {
  flex: 1;
  position: relative;
  border-right: 1px solid #333;
  min-width: 0;
}

.cb5g-polar-cell:last-child {
  border-right: none;
}

.cb5g-polar-cell canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.cb5g-polar-scale-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 5;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #555;
  border-radius: 4px;
  background: rgba(26, 26, 26, 0.9);
  color: #0fa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}

.cb5g-polar-scale-btn:hover {
  background: rgba(0, 255, 170, 0.25);
  border-color: #0fa;
}

.cb5g-polar-scale-btn .cb5g-scale-icon {
  display: block;
}

.cb5g-polar-label {
  position: absolute;
  bottom: 5px;
  left: 0;
  right: 0;
  font-size: 10px;
  color: #fff;
  text-align: center;
  pointer-events: none;
}

.cb5g-matrix-wrap {
  background: #111;
  padding: 10px;
  font-family: "Courier New", Courier, monospace;
  font-size: 11px;
  border: 1px solid #333;
  border-radius: 6px;
  margin-top: 12px;
  overflow-x: auto;
}

.cb5g-matrix-title {
  color: #0fa;
  margin-bottom: 6px;
  font-size: 11px;
}

.cb5g-matrix-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 11px;
  color: #ccc;
}

.cb5g-matrix-table th {
  text-align: right;
  padding: 4px 12px 4px 4px;
  color: #0fa;
  border-bottom: 1px solid #333;
}

.cb5g-matrix-table td {
  padding: 2px 12px 2px 4px;
  border-bottom: 1px solid #222;
}

.cb5g-table-reference {
  margin-top: 12px;
  padding: 10px;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 12px;
  color: #ccc;
}

.cb5g-table-reference .ref-title {
  color: #0fa;
  margin: 10px 0;
  font-size: 11px;
}

.cb5g-table-reference .reference-grid {
  width: 100%;
  border-collapse: collapse;
  background: #1a1a1a;
  color: #ccc;
  font-size: 11px;
  text-align: center;
}

.cb5g-table-reference .reference-grid th,
.cb5g-table-reference .reference-grid td {
  border: 1px solid #444;
  padding: 6px;
  color: #fff;
}

.cb5g-table-reference .reference-grid th {
  background: #252525;
  color: #0fa;
}

.cb5g-table-reference .reference-grid .cell-active {
  background: rgba(0, 255, 0, 0.1);
  border: 2px solid #0f0 !important;
  color: #fff;
  font-weight: bold;
}

.cb5g-table-reference .reference-grid .ref-cell-values {
  color: #00ff00;
  font-size: 10px;
  margin-top: 2px;
  font-weight: normal;
}

/* 2×3 indices mini table: i1,1 / i1,2 with range and current values (green on dark) */
.cb5g-indices-mini {
  border-collapse: collapse;
  margin-top: 5px;
  width: 100%;
  font-size: 10px;
  color: #00ff00;
  background: #1a1a1a;
  border-top: 1px solid rgba(0, 255, 0, 0.3);
}
.cb5g-indices-mini th,
.cb5g-indices-mini td {
  padding: 2px !important;
  text-align: center;
  color: #00ff00;
}
.cb5g-table-reference .reference-grid .cell-active .cb5g-indices-mini {
  font-size: 9px;
  color: #0f0;
}
.cb5g-table-reference .reference-grid .cell-active .cb5g-indices-mini th,
.cb5g-table-reference .reference-grid .cell-active .cb5g-indices-mini td {
  border: none !important;
  padding: 2px !important;
}
.cb5g-matrix-wrap .cb5g-indices-mini {
  margin: 0 auto 6px;
  max-width: 140px;
}

/* Table 5.2.2.2.1-3 (k1, k2 mapping) — visible when Rank 2 is selected */
#cb5g-k-table-reference {
  margin-top: 0;
}
#cb5g-k-table-reference .ref-title {
  color: #0fa;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  margin-bottom: 8px;
}
.k-table-ref {
  width: 100%;
  margin-top: 10px;
  border: 1px solid #444;
  border-collapse: collapse;
  background: #1a1a1a;
}
.k-table-ref th,
.k-table-ref td {
  border: 1px solid #444;
  padding: 6px;
  color: #fff;
}
.k-table-ref th {
  background: #252525;
  color: #0fa;
}
.k-table-ref tr.cell-active {
  background: rgba(0, 255, 0, 0.15) !important;
  outline: 2px solid #0f0;
}
.k-table-ref tr.cell-active td {
  border-color: #0f0;
}
