/* ========== Modal ========== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5,7,12,0.65);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  z-index: 200;
  animation: fadeIn 160ms ease;
}
.modal {
  width: 640px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn 200ms ease;
}
@keyframes modalIn {
  from { transform: translateY(10px) scale(0.98); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.modal-head {
  display: flex; align-items: center;
  flex-shrink: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.modal-head > :first-child { flex: 1; }
.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex; flex-direction: column;
  gap: 14px;
}
.modal-foot {
  display: flex; align-items: center;
  flex-shrink: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  gap: 8px;
  background: var(--bg-0);
}
.modal-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.modal-section-head {
  display: flex; align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-3);
}
.modal-section-body { padding: 12px; }
.modal-toggle-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 4px 0;
}
.source-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.source-type-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  text-align: left;
  cursor: pointer;
  transition: border 80ms, background 80ms;
}
.source-type-card:hover { border-color: var(--border-stronger); }
.source-type-card.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.source-type-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--text-2);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.source-type-card.active .source-type-icon { background: var(--accent-soft-2); color: var(--accent); }

.switch { display: inline-block; position: relative; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  display: block;
  width: 32px; height: 18px;
  background: var(--bg-3);
  border-radius: 99px;
  transition: background 120ms;
  position: relative;
}
.switch input:checked ~ .switch-track { background: var(--accent); }
.switch-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  transition: left 120ms;
}
.switch input:checked ~ .switch-track .switch-knob { left: 16px; }

.sdi-port-mini {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 12px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  align-items: stretch;
}
.sdi-mini-card {
  background: linear-gradient(180deg, #1c1f28, #0d0e13);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 8px 2px;
  display: flex;
}
.sdi-mini-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  color: var(--text-3);
  margin: 0 auto;
}
.sdi-mini-ports { display: flex; flex-direction: column; gap: 4px; }
.sdi-mini-port {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: left;
  cursor: pointer;
}
.sdi-mini-port:hover { border-color: var(--border-stronger); }
.sdi-mini-port.active { background: var(--accent-soft); border-color: var(--accent); }
.sdi-mini-radio {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--text-4);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.sdi-mini-port.active .sdi-mini-radio { border-color: var(--accent); }
.sdi-mini-radio-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
}
.sdi-mini-port.active .sdi-mini-radio-dot { opacity: 1; }
