/* =============================================================================
   Shared modal system
   .modal-backdrop       fixed overlay
   .modal-box            dialog container (straight corners = mature/enterprise)
   .modal-header         title bar + close button
   .modal-close          × icon button
   .modal-body           scrollable content
   .modal-footer         action buttons row
   .modal-btn            button base
   .modal-btn--cancel    secondary action
   .modal-btn--apply     primary action
   .modal-title-label    modal type name (bold)
   .modal-title-subject  item/context name (muted)
   =========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.modal-box {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 80vw;
  max-height: 80vh;
  min-width: 500px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 11px;
  border-bottom: 1px solid var(--c-border);
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-1);
  flex-shrink: 0;
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--c-text-2);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  transition: background .12s;
}
.modal-close:hover { background: var(--c-hover); }
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}
.modal-btn {
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--c-border);
  transition: background .12s, opacity .12s;
}
.modal-btn--cancel { background: none; color: var(--c-text-2); }
.modal-btn--cancel:hover { background: var(--c-hover); }
.modal-btn--apply  { background: var(--c-accent); color: #fff; border-color: var(--c-accent); font-weight: 600; }
.modal-btn--apply:hover  { opacity: .85; }
.modal-btn--secondary { color: var(--c-accent); border-color: var(--c-accent); background: color-mix(in srgb, var(--c-accent) 8%, transparent); }
.modal-btn--secondary:hover { background: color-mix(in srgb, var(--c-accent) 16%, transparent); }
.modal-title-label   { font-weight: 700; }
.modal-title-subject { font-weight: 400; color: var(--c-text-2); margin-left: 4px; }

/* === Per-modal sizes ========================================================= */
[data-testid="variablesModal"] .modal-box  { width: min(600px, 94vw); max-height: 80vh; }
[data-testid="validateModal"] .modal-box   { width: 560px; max-width: 94vw; max-height: 80vh; }
[data-testid="showWhenModal"] .modal-box   { width: min(680px, 92vw); }
[data-testid="constraintModal"] .modal-box { width: min(560px, 94vw); }
[data-testid="expressionModal"] .modal-box { width: min(560px, 94vw); }
[data-testid="initialModal"] .modal-box    { width: min(420px, 94vw); }
[data-testid="appearanceModal"] .modal-box { width: min(380px, 94vw); }
[data-testid="designNoteModal"] .modal-box { width: min(560px, 94vw); }
[data-testid="answerTypeModal"] .modal-box { width: clamp(480px, 60vw, 900px); }
[data-testid="repeatableModal"] .modal-box { width: min(360px, 94vw); }
[data-testid="patientCtxModal"] .modal-box { width: 380px; max-width: 94vw; max-height: none; overflow: visible; }
[data-testid="explainModal"] .modal-box    { width: min(640px, 94vw); }
[data-testid="fhirJsonModal"] .modal-box   { width: min(700px, 94vw); max-height: 80vh; display: flex; flex-direction: column; }

/* === Per-modal body overrides ================================================ */
/* Help modal — iframe wrapper */
.help-modal-body { padding: 0; overflow: hidden; }
.help-iframe { display: block; width: 100%; height: 65vh; border: none; }
[data-testid="helpModal"] .modal-box { width: min(900px, 94vw); min-width: min(60vw, 94vw); max-height: 85vh; }

/* JSON viewer — scrollable pre */
.fhir-json-modal-body { overflow: auto; flex: 1; }
.fhir-json-pre {
  margin: 0;
  font-size: 12px;
  font-family: var(--f-mono, monospace);
  white-space: pre;
  color: var(--c-text-1);
  line-height: 1.5;
}

/* === Per-modal body overrides ================================================ */
/* Variables — flex column with gap for variable rows */
[data-testid="variablesModal"] .modal-body { display: flex; flex-direction: column; gap: 10px; }
/* Explain — zero horizontal padding so tree rows span full width */
[data-testid="explainModal"] .modal-body   { padding: 0; }
/* Show When — extra padding for the condition editor */
[data-testid="showWhenModal"] .modal-body  { padding: 16px 20px 20px; }
/* Constraint — padding for the card list */
[data-testid="constraintModal"] .modal-body { padding: 12px 16px 16px; }
/* Expression — padding for the textarea */
[data-testid="expressionModal"] .modal-body { padding: 12px 16px 16px; }
.expr-modal-sep  { border-top: 1px solid var(--c-border); margin: 12px 0 6px; }
.expr-section-hdr {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  font-size: 12px;
  color: var(--c-text-1);
  padding: 5px 8px;
  background: var(--c-bg-2, #f5f5f5);
  border-radius: 4px;
  border-left: 3px solid var(--c-primary, #5c6bc0);
  margin-bottom: 4px;
}
.expr-section-key {
  font-size: 10px;
  font-weight: 400;
  color: var(--c-text-3, #9e9e9e);
  font-family: var(--f-mono, monospace);
}
/* Initial — padding for the control */
[data-testid="initialModal"] .modal-body    { padding: 12px 16px 16px; }
/* Appearance — padding for the style controls */
[data-testid="appearanceModal"] .modal-body { padding: 12px 16px 16px; }
[data-testid="answerTypeModal"] .modal-body { padding: 12px 16px 16px; }
/* Repeatable — padding */
[data-testid="repeatableModal"] .modal-body { padding: 12px 16px 16px; }
.repeat-modal-toggle-row   { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.repeat-modal-cb           { width: 16px; height: 16px; cursor: pointer; }
.repeat-modal-cb-label     { font-size: 13px; font-weight: 500; cursor: pointer; }
.repeat-modal-card         { background: var(--c-surface-2, #f8f9fa); border: 1px solid var(--c-border); border-radius: 6px; padding: 12px; margin-top: 4px; }
.repeat-modal-card-title   { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--c-text-2); margin-bottom: 10px; }
.repeat-modal-grid         { display: grid; grid-template-columns: auto 90px 1fr; gap: 8px 12px; align-items: center; }
.repeat-modal-lbl          { font-size: 13px; white-space: nowrap; }
.repeat-modal-hint         { font-size: 11px; color: var(--c-text-2); font-family: monospace; }
/* Answer Type modal */
.at-modal-type-row     { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.at-modal-lbl          { font-size: 13px; font-weight: 600; white-space: nowrap; min-width: 42px; }
.at-modal-type-sel     { flex: 1; min-width: 0; }
.at-modal-source-row   { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.at-modal-src-lbl      { font-size: 13px; cursor: pointer; margin-right: 12px; }
.at-modal-sub          { background: var(--c-surface-2, #f8f9fa); border: 1px solid var(--c-border); border-radius: 6px; padding: 10px 12px; margin-bottom: 10px; }
.at-modal-multiline-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; margin-bottom: 8px; cursor: pointer; font-size: 13px; color: var(--c-text-1); }
.at-modal-sub-lbl      { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--c-text-2); margin-bottom: 6px; }
.at-modal-sub-lbl:not(:first-child) { margin-top: 10px; }
.at-modal-sub-lbl--mt  { margin-top: 10px; }
.at-modal-sub-lbl--mb0 { margin-bottom: 0; }
.at-modal-sub-inp      { width: 100%; box-sizing: border-box; resize: vertical; font-family: inherit; font-size: inherit; }
.at-modal-opt-inp      { width: 100%; box-sizing: border-box; resize: vertical; min-height: 2rem; font-family: inherit; font-size: inherit; }
.at-modal-avs-drop     { margin-bottom: 6px; }
.at-modal-avs-url      { width: 100%; box-sizing: border-box; margin-top: 2px; }
.at-modal-sub-sel      { min-width: 0; }

/* Choice columns section */
.cc-list               { margin-bottom: 6px; }
.cc-empty              { font-size: 12px; color: var(--c-muted); font-style: italic; padding: 4px 0; }
.cc-row                { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.cc-input              { flex: 1; min-width: 0; padding: 3px 6px; font-size: 12px; border: 1px solid var(--c-border); border-radius: var(--r-sm); }
.cc-input--sm          { flex: 0 0 60px; }
.cc-fd-label           { display: flex; align-items: center; gap: 2px; font-size: 11px; white-space: nowrap; cursor: pointer; }
.cc-del-btn            { background: none; border: none; font-size: 15px; cursor: pointer; color: var(--c-muted); padding: 0 2px; line-height: 1; }
.cc-del-btn:hover      { color: var(--c-danger, #d33); }

/* States modal (Required / Read-only / Hidden) */
.states-modal-row       { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.states-modal-label     { font-size: 13px; font-weight: 600; white-space: nowrap; min-width: 80px; }
.states-modal-sel       { flex: 1; }
.states-modal-check-row { display: flex; align-items: baseline; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.states-modal-field-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.states-modal-chk-label { font-size: 13px; font-weight: 600; cursor: pointer; }
.states-modal-chk-hint  { font-size: 11px; color: var(--c-text-2); flex-basis: 100%; padding-left: 18px; }
.appearance-modal-form { margin-top: 10px; }
.style-modal-raw-ta    { width: 100%; box-sizing: border-box; resize: vertical;
                          min-height: 26px; font-size: 11px; font-family: monospace;
                          margin-top: 4px; padding: 3px 5px; }
.initial-modal-label         { display: block; font-size: 12px; font-weight: 600; color: var(--c-text-2); margin-bottom: 6px; }
/* Show When — widen condition row widgets */
[data-testid="showWhenModal"] .vis-q-sel        { min-width: 180px; max-width: 300px; }
[data-testid="showWhenModal"] .vis-cond-val-inp { max-width: 180px; }
/* Patient context — compact body */
[data-testid="patientCtxModal"] .modal-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }

/* === Patient context — specific internal styles ============================== */
.patient-ctx-hint {
  padding: 8px 16px;
  font-size: 11px; color: var(--c-text-2);
  background: #f7f9ff;
  border-bottom: 1px solid var(--c-border);
}
.patient-ctx-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.patient-ctx-lbl {
  font-size: 12px; color: var(--c-text); flex: 0 0 130px;
}
.patient-ctx-inp {
  flex: 1; height: 26px; padding: 0 6px;
  border: 1px solid var(--c-border); border-radius: var(--r-sm); font-size: 12px;
}
.patient-ctx-sel  { flex: 1; min-width: 0; font-size: 12px; }
.patient-ctx-cb { width: 16px; height: 16px; }

/* === Questionnaire Properties (metadata) modal ============================== */
[data-testid="metadataModal"] .modal-box { width: min(900px, 94vw); min-width: min(60vw, 94vw); }
[data-testid="codesModal"] .modal-box    { width: min(480px, 94vw); }
[data-testid="qrExportModal"] .modal-box { width: min(380px, 94vw); }
/* ── Load / Save format modals ─────────────────────────────────────────────── */
[data-testid="loadFormatModal"] .modal-body,
[data-testid="saveFormatModal"] .modal-body { padding: 20px 20px 8px; }
.lf-format-row   { display: flex; align-items: center; gap: 12px; }
.lf-format-label { flex: 0 0 56px; font-size: 13px; font-weight: 500; }
.lf-format-row .sc-trigger { flex: 1; }

[data-testid="metadataModal"] .modal-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
[data-testid="codesModal"] .modal-body    { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
[data-testid="qrExportModal"] .modal-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
[data-testid="terminologyModal"] .modal-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.meta-modal-row      { display: flex; align-items: flex-end; gap: 8px; }
.meta-modal-row--col { flex-direction: column; align-items: flex-start; gap: 4px; }
.meta-modal-row--col .meta-modal-lbl { flex: none; }
.meta-modal-lbl      { flex: 0 0 90px; font-size: 13px; font-weight: 500; line-height: 26px; padding-bottom: 1px; }
.meta-modal-inp      { flex: 1; height: 26px; padding: 0 6px; font-size: 13px;
                        border: 1px solid var(--c-border); border-radius: var(--r-sm); background: var(--c-bg); color: var(--c-text); }
.meta-modal-inp--date { max-width: 160px; flex: 0 0 160px; }
.meta-modal-sel      { flex: 1; font-size: 13px;
                        border: 1px solid var(--c-border); border-radius: var(--r-sm); height: 26px; background: var(--c-bg); color: var(--c-text); }
.meta-modal-textarea { flex: 1; padding: 4px 6px; font-size: 13px; font-family: inherit;
                        border: 1px solid var(--c-border); border-radius: var(--r-sm); resize: vertical;
                        background: var(--c-bg); color: var(--c-text); min-height: 54px; }
.meta-modal-inp:focus, .meta-modal-sel:focus, .meta-modal-textarea:focus { outline: 1px solid var(--c-accent); }

/* Terminology modal — Test connection */
.term-test-wrap        { display: flex; align-items: center; gap: 8px; }
.at-modal-sub .term-test-wrap { margin-top: 6px; }
.term-test-status      { font-size: 12px; color: var(--c-muted); }
.term-test-status--loading { color: var(--c-muted); font-style: italic; }
.term-test-status--ok  { color: #2a9d2a; }
.term-test-status--err { color: var(--c-danger, #c0392b); }

.meta-modal-advanced   { border-top: 1px solid var(--c-border); margin-top: 4px; padding-top: 6px; }
.meta-modal-adv-toggle { background: none; border: none; cursor: pointer; font-size: 12px; font-weight: 600;
                          color: var(--c-accent); padding: 0; letter-spacing: .02em; }
.meta-modal-adv-toggle:hover { opacity: .75; }
.meta-modal-adv-body   { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; padding-left: 10px; }

/* meta-modal helpers for Resource Meta section */
.meta-modal-inp-group  { flex: 1; display: flex; gap: 6px; }
.meta-modal-gen-btn    { height: 26px; padding: 0 10px; font-size: 12px; font-weight: 600;
                          background: var(--c-accent); color: #fff; border: none; border-radius: var(--r-sm);
                          cursor: pointer; white-space: nowrap; }
.meta-modal-gen-btn:hover { opacity: .85; }
.meta-modal-readonly   { flex: 1; font-size: 12px; color: var(--c-text-2); line-height: 26px; font-style: italic; }
.meta-modal-narrative  { flex: 1; font-size: 11px; font-family: monospace; color: var(--c-text-2);
                          white-space: pre-wrap; word-break: break-all; max-height: 120px;
                          overflow-y: auto; background: var(--c-bg-2); border: 1px solid var(--c-border);
                          border-radius: var(--r-sm); padding: 4px 6px; margin-top: 2px; }
.meta-modal-form       { display: flex; flex-direction: column; gap: 10px; }
.meta-modal-subsection { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.meta-modal-subhdr     { font-size: 11px; font-weight: 700; text-transform: uppercase;
                          letter-spacing: .06em; color: var(--c-text-2); }

/* === Clear form confirmation modal ========================================== */
.clear-confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clear-confirm-box {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  padding: 24px 28px 20px;
  min-width: 340px;
  max-width: 440px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.clear-confirm-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 8px;
}
.clear-confirm-msg {
  font-size: 13px;
  color: var(--c-text-2);
  margin-bottom: 20px;
  line-height: 1.5;
}
.clear-confirm-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.btn-danger {
  background: #c62828;
  color: #fff;
  border-color: #b71c1c;
}
.btn-danger:hover { background: #b71c1c; }

/* === Export validation modal content ======================================== */
.validate-modal-summary { font-size: 13px; color: #555; margin-bottom: 10px; }
.validate-ok {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 14px;
  background: #f1f8f1;
  border: 1px solid #a5d6a7;
  border-radius: 7px;
  font-size: 14px;
  color: #2e7d32;
}
.validate-ok-icon { font-size: 22px; line-height: 1; }
.validate-issue {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px;
}
.validate-issue:last-child { border-bottom: none; }
.validate-issue-badge {
  flex-shrink: 0; font-size: 11px; font-weight: 700;
  padding: 2px 6px; border-radius: 3px; margin-top: 1px; text-transform: uppercase;
}
.validate-badge-error   { background: #ffebee; color: #c62828; }
.validate-badge-warning { background: #fff8e1; color: #e65100; }
.validate-issue-content { flex: 1; }
.validate-issue-id {
  font-family: monospace; font-size: 12px; color: var(--c-primary);
  background: var(--c-primary-lt); padding: 0 4px; border-radius: 2px;
  margin-right: 4px;
}
.validate-nav-btn {
  flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--c-primary);
  padding: 1px 5px; border-radius: 3px;
  opacity: 0.7; transition: opacity .1s;
}
.validate-nav-btn:hover { opacity: 1; background: var(--c-primary-lt); }

/* Validator sections (one per registered validator) */
.validate-section { margin-bottom: 14px; }
.validate-section:last-child { margin-bottom: 0; }

.validate-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-2);
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--c-border);
}
.validate-section-name { color: var(--c-text-1); font-size: 13px; }
.validate-section-type {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 500;
  text-transform: uppercase;
}
.validate-section-type--local    { background: #e8f5e9; color: #2e7d32; }
.validate-section-type--external { background: #e3f2fd; color: #1565c0; }

.validate-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  margin-left: auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.validate-ext-error {
  font-size: 12px;
  color: var(--c-danger, #c62828);
  padding: 6px 0;
}

.validate-footer-loading {
  font-size: 12px;
  color: var(--c-text-2);
  font-style: italic;
}

/* === Item Properties modal (item.definition + item.code[]) ================= */
/* Subject Type chips */
.subtype-chips       { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; min-height: 20px; }
.subtype-chips-empty { font-size: 12px; color: var(--c-text-2); }
.subtype-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--c-primary-lt); border: 1px solid var(--c-primary);
  border-radius: 10px; padding: 2px 4px 2px 8px; font-size: 12px; color: var(--c-text);
}
.subtype-chip-remove {
  background: none; border: none; cursor: pointer; font-size: 14px; line-height: 1;
  padding: 0 3px; color: var(--c-primary);
}
.subtype-chip-remove:hover { color: #dc2626; }
.subtype-custom-row { display: flex; gap: 6px; margin-top: 8px; }

/* Signature required section */
.states-sig-wrap  { flex-wrap: wrap; }
.states-sig-chips { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.states-sig-add-row { flex-basis: 100%; margin-top: 4px; }
.subtype-custom-row .codes-inp { flex: 1; }

.codes-empty-msg { font-size: 13px; color: var(--c-text-2); padding: 4px 0 8px; }
.codes-row {
  display: flex; align-items: center; gap: 6px;
}
.codes-inp {
  flex: 1; height: 28px; padding: 0 6px; border: 1px solid var(--c-border);
  border-radius: 4px; font-size: 12px; background: var(--c-bg); color: var(--c-text);
  min-width: 0;
}
.codes-inp:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary-lt); }
.codes-remove-btn {
  flex-shrink: 0; width: 24px; height: 24px; padding: 0;
  background: none; border: 1px solid transparent; border-radius: 4px;
  cursor: pointer; font-size: 15px; color: var(--c-text-2); line-height: 1;
}
.codes-remove-btn:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
.codes-add-btn {
  align-self: flex-start; margin-top: 4px; padding: 3px 10px;
  background: none; border: 1px dashed var(--c-border); border-radius: 4px;
  font-size: 12px; color: var(--c-primary); cursor: pointer;
}
.codes-add-btn:hover { background: var(--c-primary-lt); }

/* Identifier rows inside the Identifiers collapsible section */
.identifier-use-sel {
  flex: 0 0 88px; height: 28px; font-size: 12px;
  border: 1px solid var(--c-border); border-radius: 4px;
  background: var(--c-bg); color: var(--c-text);
}
.identifier-use-sel:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary-lt); }

/* Support Links rows inside Props modal */
.support-link-row { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.support-link-input {
  flex: 1; height: 28px; padding: 0 6px; border: 1px solid var(--c-border);
  border-radius: 4px; font-size: 12px; background: var(--c-bg); color: var(--c-text);
  min-width: 0;
}
.support-link-input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary-lt); }

/* Unknown Extensions structured rows inside Props modal */
.ext-card { border: 1px solid var(--c-border); border-radius: 4px; padding: 6px 8px; margin-bottom: 6px; }
.ext-url-row { display: flex; gap: 4px; margin-bottom: 4px; align-items: center; }
.ext-type-row { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.ext-field-lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-2); flex: 0 0 38px; }
.ext-url-input {
  flex: 1; height: 26px; padding: 0 6px; border: 1px solid var(--c-border);
  border-radius: 4px; font-size: 12px; background: var(--c-bg); color: var(--c-text); min-width: 0;
}
.ext-url-input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary-lt); }
.ext-val-row { display: flex; gap: 4px; align-items: flex-start; }
.ext-type-select {
  width: 170px; flex-shrink: 0; height: 26px; padding: 0 4px;
  border: 1px solid var(--c-border); border-radius: 4px; font-size: 11px;
  background: var(--c-bg); color: var(--c-text);
}
.ext-type-select:focus { outline: none; border-color: var(--c-primary); }
.ext-val-container { flex: 1; min-width: 0; }
.ext-val-input {
  width: 100%; height: 26px; padding: 0 6px; border: 1px solid var(--c-border);
  border-radius: 4px; font-size: 12px; background: var(--c-bg); color: var(--c-text); box-sizing: border-box;
}
.ext-val-input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary-lt); }
.ext-val-textarea {
  width: 100%; padding: 4px 6px; border: 1px solid var(--c-border);
  border-radius: 4px; font-size: 11px; font-family: monospace;
  background: var(--c-bg); color: var(--c-text); resize: vertical; box-sizing: border-box;
}
.ext-val-textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary-lt); }

/* === Library modal ========================================================== */
[data-testid="libraryModal"] .modal-box  { max-width: 640px; width: 90vw; }
[data-testid="libraryModal"] .modal-body { padding: 6px 0; max-height: 65vh; overflow-y: auto; }

.lib-group + .lib-group   { border-top: 1px solid var(--c-border); }

.lib-group-hdr {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--c-text-2); cursor: pointer; user-select: none;
}
.lib-group-hdr:hover { background: var(--c-hover); }
.lib-group-toggle { font-size: 8px; opacity: .6; }

.lib-item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 16px 7px 30px;
  font-size: 13px; cursor: pointer; color: var(--c-text);
}
.lib-item:hover { background: var(--c-hover); }
.lib-item-icon  { font-size: 11px; opacity: .7; flex-shrink: 0; }
.lib-item-note  { font-size: 10px; opacity: .55; margin-left: 2px; }

/* === Preview placeholder (empty state) ====================================== */
.preview-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; min-height: 260px;
  text-align: center; padding: 32px 24px; color: #999;
  user-select: none;
}
.preview-placeholder-icon  { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.preview-placeholder-title { font-size: 16px; font-weight: 600; color: #bbb; margin-bottom: 8px; }
.preview-placeholder-hint  { font-size: 13px; line-height: 1.6; color: #bbb; }

/* ── Design Note modal textarea ─────────────────────────────────────────────── */
.note-modal-textarea {
  display: block;
  width: 100%;
  min-height: 140px;
  margin-top: 10px;
  padding: 8px;
  box-sizing: border-box;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  background: var(--c-surface);
  color: var(--c-text);
  resize: vertical;
}

/* ── Contact editor (metadata modal) ─────────────────────────────────────────
 */
.contact-block {
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 6px 8px 4px;
  margin-bottom: 6px;
  background: var(--c-surface);
}
.telecom-row { padding-left: 12px; }
.codes-add-btn--sub { margin-left: 12px; font-size: 11px; padding: 2px 8px; }

/* ── Paste Warning modal ────────────────────────────────────────────────────── */
.paste-warn-heading {
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 4px;
  color: var(--c-text);
}
.paste-warn-heading:first-child { margin-top: 0; }
.paste-warn-hint {
  font-size: 12px;
  color: var(--c-text-2);
  margin: 0 0 8px;
  line-height: 1.45;
}
.paste-warn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 16px;
}
.paste-warn-table thead tr { background: var(--c-surface-alt, #f4f4f4); }
.paste-warn-table th,
.paste-warn-table td {
  padding: 5px 8px;
  text-align: left;
  border: 1px solid var(--c-border);
  vertical-align: top;
}
.paste-warn-table th { font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.paste-warn-id   { font-family: monospace; white-space: nowrap; color: var(--c-accent); }
.paste-warn-type { white-space: nowrap; font-style: italic; color: var(--c-text-2); }
.paste-warn-expr { font-family: monospace; word-break: break-all; }

/* ── Node Picker modal ─────────────────────────────────────────────────────── */
[data-testid="nodePickerModal"] { z-index: 10100; }
[data-testid="nodePickerModal"] .modal-body { padding: 0; display: flex; flex-direction: column; max-height: 60vh; }
.node-picker-search-wrap {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.node-picker-search {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text);
  outline: none;
}
.node-picker-search:focus { border-color: var(--c-accent); }
.node-picker-tree {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}
.node-picker-empty {
  padding: 20px 16px;
  font-size: 12px;
  color: var(--c-text-2);
  text-align: center;
}
.node-picker-group {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-top: 6px;
  padding-bottom: 3px;
  padding-right: 12px;
  user-select: none;
  cursor: default;
}
.node-picker-group-icon {
  font-size: 10px;
  color: var(--c-text-2);
  flex-shrink: 0;
}
.node-picker-group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-picker-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 3px;
  padding-bottom: 3px;
  padding-right: 12px;
  cursor: pointer;
  border-radius: 3px;
}
.node-picker-item:hover { background: var(--c-hover); }
.node-picker-cb { flex-shrink: 0; cursor: pointer; }
.node-picker-item-title {
  font-size: 12px;
  color: var(--c-text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-picker-linkid {
  font-size: 11px;
  color: var(--c-text-2);
  font-family: monospace;
  white-space: nowrap;
  flex-shrink: 0;
}
.modal-btn--copy-to {
  margin-right: auto;
}
