/* ========== 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(2, 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; }

/* ========== Toasts ========== */
/* In-app, non-blocking replacement for native window.alert().
   Mounted once on its own ReactDOM root (#df-toast-host) — see visuals.jsx.
   Info/success/warning auto-dismiss; errors stay until manually dismissed. */
.toast-container {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 400; /* above modals (200) */
  display: flex; flex-direction: column;
  gap: 10px;
  width: 360px;
  max-width: calc(100vw - 32px);
  pointer-events: none; /* let clicks pass through gaps; buttons re-enable */
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  pointer-events: all;
  animation: toastIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastIn {
  from { transform: translateX(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.toast-icon {
  flex-shrink: 0;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  margin-top: 1px;
  color: var(--text-3);
}
.toast-icon svg { width: 16px; height: 16px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title {
  font-size: 12px; font-weight: 600;
  color: var(--text-1);
  margin-bottom: 2px;
}
.toast-msg {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-2);
  word-break: break-word;
}
.toast .icon-btn {
  flex-shrink: 0;
  width: 22px; height: 22px;
  margin: -2px -2px 0 0;
}
.toast .icon-btn svg { width: 13px; height: 13px; }

.toast--success .toast-icon { color: var(--success); }
.toast--error .toast-icon { color: var(--danger); }
.toast--warning .toast-icon { color: var(--warning); }
.toast--info .toast-icon { color: var(--accent); }

/* ========== Recorder multi-select (New Schedule dialog) ========== */
.rec-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  /* Two columns fit a full cluster (~12 recorders) without scrolling; only
     longer lists scroll, handled by the app's themed scrollbar. */
  max-height: 264px;
  overflow-y: auto;
  padding: 1px;
}
.rec-option {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  min-width: 0;
  transition: border-color 80ms, background 80ms;
}
.rec-option:hover { border-color: var(--border-stronger); }
.rec-option.sel { background: var(--accent-soft); border-color: var(--accent); }
.rec-option:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Checkbox ONLY — was `.rec-option input`, which also squashed the per-recorder
   clip-name text field into a 15px black box. */
.rec-option input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px; height: 15px; margin: 0; flex-shrink: 0; cursor: pointer;
}
/* Per-recorder clip name field sits full-width under the checkbox row. */
.rec-option .field-input { width: 100%; box-sizing: border-box; }
/* Secondary recorder name shown next to the crosspoint in the picker. */
.rec-option-sub {
  font-size: var(--fs-2xs); color: var(--text-3); font-family: var(--font-mono);
  flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%;
}
.rec-option-name {
  flex: 1; min-width: 0;
  font-size: 13px; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rec-option.sel .rec-option-name { color: var(--accent-text); }
.rec-option-kind { font-size: 10.5px; letter-spacing: 0.04em; color: var(--text-3); flex-shrink: 0; }
.rec-picker-empty { grid-column: 1 / -1; padding: 12px; text-align: center; color: var(--text-3); font-size: 13px; }
