/* ==========================================================================
   Smart Group — Full View modal (auto "Field Recipe" + manual cohort modes).
   Ported from the MINT design-system project; all values resolve against the
   SDK token set in styles/variables.css. Fira Sans for UI, Fira Code for
   sample identifiers (data). Group colors are --mint-sample-1…8 (3a).
   ========================================================================== */

.sg-modal {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* ---- Header ---- */
.sg-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.sg-head__title {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.sg-head__sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
}
.sg-head__spacer { flex: 1; }
.sg-head__close {
  display: flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem;
  border: none; background: none; cursor: pointer;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 1.25rem; line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}
.sg-head__close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ---- Mode pill (Auto / Manual) — the single mode switch ---- */
.sg-mode {
  display: inline-flex; padding: 0.1875rem; gap: 0.125rem;
  background: var(--bg-tertiary); border-radius: var(--radius-md);
}
.sg-mode__btn {
  border: none; background: none; cursor: pointer;
  font: inherit; font-size: 0.8125rem; font-weight: 500;
  color: var(--text-secondary);
  padding: 0.25rem 0.625rem; border-radius: var(--radius);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.sg-mode__btn:hover { color: var(--text-primary); }
.sg-mode__btn--on {
  background: var(--bg-secondary); color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.sg-mode__btn--on:hover { color: var(--text-primary); }

/* ---- Body ---- */
.sg-body {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
}
.sg-body__main {
  padding: 1rem 1.25rem;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.sg-body__side {
  border-left: 1px solid var(--border-color);
  background: var(--bg-primary);
  padding: 1.125rem 1.25rem;
  display: flex; flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  gap: 0.75rem;
}

/* Section lead */
.sg-lead { display: flex; flex-direction: column; gap: 0.25rem; }
.sg-lead__q {
  font-size: 0.9375rem; font-weight: 600; color: var(--text-primary);
}
.sg-lead__hint {
  font-size: 0.8125rem; color: var(--text-secondary); line-height: 1.45;
}

/* Plain-english summary callout */
.sg-summary {
  display: flex; gap: 0.5rem; align-items: flex-start;
  padding: 0.625rem 0.75rem;
  background: var(--color-primary-soft);
  border-radius: var(--radius-md);
  font-size: 0.8125rem; line-height: 1.5; color: var(--text-primary);
}
.sg-summary b { font-weight: 600; }
.sg-summary__icon {
  flex-shrink: 0; width: 1rem; height: 1rem; color: var(--color-primary);
  margin-top: 0.0625rem;
}
.sg-summary--warn {
  background: var(--mint-warning-bg);
  box-shadow: inset 0 0 0 1px var(--mint-warning-border);
}
.sg-summary--warn .sg-summary__icon { color: var(--mint-warning); }

/* ==========================================================================
   Field Recipe (auto mode) — field toggle list
   ========================================================================== */
.sg-recipe { display: flex; flex-direction: column; gap: 0.25rem; }
.sg-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.sg-field--on {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}
.sg-field__name { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.sg-field__role {
  font-size: 0.6875rem; font-weight: 600;
  color: var(--text-secondary);
  padding: 0.0625rem 0.375rem; border-radius: 9999px;
  background: var(--bg-tertiary); margin-left: 0.5rem;
}
.sg-field__role--rep { color: var(--mint-warning); background: var(--mint-warning-bg); }
.sg-field__vals {
  grid-column: 1 / 2;
  font-family: var(--font-mono); font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sg-field__toggle { grid-row: 1 / 3; grid-column: 2; align-self: center; }

/* ==========================================================================
   Shared — live group preview (right rail)
   ========================================================================== */
.sg-preview__head {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.6875rem; font-weight: 600;
  color: var(--text-secondary);
}
.sg-preview__count {
  margin-left: auto; font-size: 0.6875rem; font-weight: 600;
  color: var(--text-muted); font-variant-numeric: tabular-nums;
  text-transform: none; letter-spacing: 0; white-space: nowrap;
}
.sg-grouplist { display: flex; flex-direction: column; gap: 0.25rem; }
.sg-group {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.4375rem 0.5rem; border-radius: var(--radius);
  transition: background 0.15s ease;
}
.sg-group:hover { background: var(--bg-hover); }
.sg-dot {
  box-sizing: border-box;
  width: 0.6875rem; height: 0.6875rem; border-radius: 50%;
  flex-shrink: 0; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12);
}
.sg-group__name {
  flex: 1; min-width: 0;
  font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sg-group__count {
  font-size: 0.6875rem; font-weight: 600; color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 0.0625rem 0.4375rem; border-radius: 9999px;
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.sg-group__bar {
  flex-shrink: 0; height: 0.25rem; border-radius: 9999px;
  background: var(--g, var(--text-muted)); opacity: 0.85;
}

.sg-qc {
  margin-top: 0.5rem; padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}
.sg-qc__head {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem;
}
.sg-qc__title {
  font-size: 0.6875rem; font-weight: 600;
  color: var(--text-secondary);
}
.fr-qc__route { margin-left: auto; }
.fr-qc__chips { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.sg-qc__chip {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.25rem 0.5rem; border-radius: var(--radius);
  background: var(--bg-tertiary);
  font-family: var(--font-mono); font-size: 0.75rem;
  color: var(--text-secondary);
}
.sg-qc__chip .sg-dot { width: 0.5rem; height: 0.5rem; }

/* ---- Footer ---- */
.sg-foot {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.sg-foot__spacer { flex: 1; }
.sg-foot__hint {
  font-size: 0.75rem; color: var(--text-muted);
}
.sg-foot__link {
  font: inherit; font-size: 0.8125rem; font-weight: 500;
  color: var(--color-primary); background: none; border: none;
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.3125rem 0.5rem; border-radius: var(--radius); white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.sg-foot__link:hover { background: var(--color-primary-soft); color: var(--_ink-primary); }
.sg-btn {
  font: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer;
  padding: 0.5rem 1rem; border-radius: var(--radius-md);
  border: 1px solid transparent; transition: all 0.15s ease;
  display: inline-flex; align-items: center; gap: 0.4375rem;
}
.sg-btn--primary { background: var(--color-primary); color: #fff; }
.sg-btn--primary:hover { background: var(--color-primary-hover); }
.sg-btn--ghost {
  background: var(--bg-secondary); color: var(--text-primary);
  border-color: var(--border-color);
}
.sg-btn--ghost:hover { background: var(--bg-tertiary); }

/* ==========================================================================
   Field Recipe refinements (layered on the shared chrome above)
   ========================================================================== */
/* Section label above the anatomy and each field list. */
.fr-label { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }

/* One-line field row: [grip] [layer] name [rename] values [hint] [toggle]. */
.fr .sg-field {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.375rem 0.625rem;
}
.fr .sg-field__name { white-space: nowrap; }
.fr .sg-field__role { margin-left: 0; white-space: nowrap; }
.fr .sg-field__vals { flex: 1; min-width: 0; }
.fr-row__grip,
.fr-row__rename {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.25rem; height: 1.25rem; padding: 0; flex-shrink: 0;
  border: none; border-radius: var(--radius-sm); background: none;
  color: var(--text-muted); cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.fr-row__grip { cursor: grab; }
.fr-row__grip:hover,
.fr-row__rename:hover { color: var(--text-primary); background: var(--bg-hover); }
.fr-row__grip:focus-visible,
.fr-row__rename:focus-visible { outline: none; box-shadow: var(--focus-ring-soft); }
/* Which hierarchy layer this field forms (1 = the sample selector's major group). */
.fr-row__layer {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 1.25rem; height: 1.25rem; border-radius: 9999px;
  border: 1px solid var(--color-primary);
  background: var(--bg-secondary); color: var(--_ink-primary);
  font-size: 0.6875rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.fr-row__name-input {
  width: 9rem; padding: 0.0625rem 0.375rem;
  font: inherit; font-size: 0.875rem; font-weight: 600; color: var(--text-primary);
  border: 1px solid var(--color-primary); border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}
.fr-row__name-input:focus-visible { outline: none; box-shadow: var(--focus-ring-soft); }
/* Groups that remain when this field is switched off. */
.fr-row__hint {
  font-size: 0.75rem; font-weight: 500; color: var(--text-secondary-strong);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
/* The message is dark text (AA on the tinted row); the input border carries the error colour. */
.fr-row__error { font-size: 0.75rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.fr-row__name-input[aria-invalid='true'] { border-color: var(--_ink-error); box-shadow: var(--focus-ring-error); }
.fr-row--dragging { opacity: 0.5; }
.fr-row--over { box-shadow: inset 0 2px 0 var(--color-primary); }

/* Replicate-on: the field row itself warns instead of silently shattering. */
.fr-field--warn.sg-field--on {
  border-color: var(--mint-warning-border);
  background: var(--mint-warning-bg);
}
.fr-field--warn.sg-field--on .fr-row__layer { border-color: var(--mint-warning); color: var(--text-primary); }

/* Name anatomy: the tokens of one example sample and the role of each. */
.fr-anatomy { display: flex; flex-direction: column; gap: 0.375rem; }
.fr-anatomy__tokens { display: flex; flex-wrap: wrap; gap: 0.375rem 0.5rem; }
.fr-token { display: inline-flex; flex-direction: column; align-items: center; gap: 0.125rem; }
.fr-token__text {
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500;
  padding: 0.125rem 0.375rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--bg-tertiary);
  color: var(--text-secondary-strong);
}
.fr-token__caption { font-size: 0.6875rem; color: var(--text-secondary-strong); white-space: nowrap; }
.fr-token--on .fr-token__text {
  border-color: var(--color-primary); background: var(--color-primary-soft);
  color: var(--text-primary);
}
.fr-token--on .fr-token__caption { color: var(--_ink-primary); font-weight: 700; }
.fr-token--off .fr-token__text { border-style: dashed; background: transparent; }

/* No samples: say what to do. */
.fr-blank {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem;
  padding: 1rem 0;
}

/* Neutral (no-selection) summary variant. */
.fr-summary--mute {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.fr-summary--mute .sg-summary__icon { color: var(--text-muted); }
.sg-summary code {
  font-family: var(--font-mono); font-size: 0.78em;
  background: rgba(0, 0, 0, 0.06); padding: 0 0.25rem; border-radius: 3px;
}
html.dark .sg-summary code { background: rgba(255, 255, 255, 0.1); }

/* Rail header: wrap the count under the label rather than clip it. */
.fr .sg-preview__head { flex-wrap: wrap; row-gap: 0.15rem; }

/* QC chip when excluded reads as struck-through / dimmed. */
.fr-qc__chip--off {
  opacity: 0.5; text-decoration: line-through;
  text-decoration-color: var(--text-muted);
}

.fr .sg-qc__chip { white-space: nowrap; }

.fr-empty {
  font-size: 0.8125rem; color: var(--text-muted);
  padding: 0.75rem 0.5rem; font-style: italic;
}

/* Disabled primary. */
.sg-btn--primary:disabled {
  /* Disabled = opacity AND a visual cue: shift to a neutral surface (mirrors
     the SDK button.css approach) so it reads as non-actionable, not just faded. */
  background: var(--bg-tertiary); color: var(--text-muted); border-color: var(--border-color);
  opacity: 0.7; cursor: not-allowed;
}
.sg-btn--primary:disabled:hover { background: var(--bg-tertiary); }

/* ==========================================================================
   Manual grouping (manual mode) — selection-first layout
   ========================================================================== */
.mg2-body {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1.55fr 1fr;
}

/* ───────── LEFT · find & select ───────── */
.mg2-find {
  display: flex; flex-direction: column; min-width: 0;
  /* min-height:0 lets this grid item shrink below content so .mg2-list scrolls
     inside the fixed modal height instead of growing the grid track. */
  min-height: 0;
  border-right: 1px solid var(--border-color);
}

.mg2-search {
  position: relative; display: flex; align-items: center;
  margin: 0.875rem 1rem 0.625rem;
}
.mg2-search > svg {
  position: absolute; left: 0.6875rem; color: var(--text-muted); pointer-events: none;
}
.mg2-search input {
  width: 100%; font: inherit; font-size: 0.8125rem;
  padding: 0.5rem 2rem 0.5rem 2.125rem;
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  background: var(--bg-tertiary); color: var(--text-primary); outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.mg2-search input:focus {
  border-color: var(--color-primary); background: var(--bg-secondary);
  box-shadow: var(--focus-ring-soft);
}
.mg2-search__clr {
  position: absolute; right: 0.5rem; display: flex; padding: 0.1875rem;
  border: none; background: none; cursor: pointer; color: var(--text-muted);
  border-radius: 9999px;
}
.mg2-search__clr:hover { background: var(--bg-hover); color: var(--text-primary); }

.mg2-chips {
  display: flex; gap: 0.375rem; padding: 0 1rem 0.625rem;
}
.mg2-chip {
  display: inline-flex; align-items: center; gap: 0.375rem;
  font: inherit; font-size: 0.75rem; font-weight: 500; color: var(--text-secondary);
  padding: 0.3125rem 0.625rem; cursor: pointer;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color); border-radius: 9999px;
  transition: all 0.13s ease;
}
.mg2-chip:hover { border-color: var(--text-muted); }
.mg2-chip--on {
  background: var(--color-primary); border-color: var(--color-primary); color: #fff;
}
.mg2-chip__n {
  font-variant-numeric: tabular-nums; font-weight: 600;
  font-size: 0.6875rem; color: var(--text-muted);
}
.mg2-chip--on .mg2-chip__n { color: rgba(255, 255, 255, 0.8); }

.mg2-selbar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0; margin: 0 1rem;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}
.mg2-check {
  display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer;
  font-size: 0.75rem; font-weight: 600; color: var(--text-secondary);
}
.mg2-check input { width: 0.9375rem; height: 0.9375rem; accent-color: var(--color-primary); cursor: pointer; }
.mg2-selbar__n {
  margin-left: auto; font-size: 0.75rem; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.mg2-list {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 0.375rem 0.5rem 0.5rem;
}
.mg2-list__empty {
  padding: 1.5rem 0.75rem; font-size: 0.8125rem; color: var(--text-muted);
  font-style: italic; text-align: center;
}
.mg2-row {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.4375rem 0.5rem; border-radius: var(--radius);
  cursor: pointer; transition: background 0.12s ease;
}
.mg2-row:hover { background: var(--bg-hover); }
.mg2-row--on { background: var(--color-primary-soft); }
.mg2-cb {
  width: 0.9375rem; height: 0.9375rem; accent-color: var(--color-primary);
  flex-shrink: 0; pointer-events: none;
}
.mg2-row__name {
  flex: 1; min-width: 0;
  font-family: var(--font-mono); font-size: 0.8125rem;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mg2-row__tag {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 0.375rem;
  font-size: 0.6875rem; font-weight: 600; color: var(--text-secondary);
  padding: 0.125rem 0.5rem 0.125rem 0.375rem; border-radius: 9999px;
  background: var(--bg-tertiary);
  white-space: nowrap;
}
.mg2-row__tag .sg-dot { width: 0.5rem; height: 0.5rem; }
.mg2-row__tag--none {
  background: none; color: var(--text-muted); font-weight: 400;
  font-style: italic; padding-left: 0.5rem;
}

/* ───────── RIGHT · cohorts rail ───────── */
.mg2-cohorts {
  display: flex; flex-direction: column; min-width: 0;
  /* min-height:0 lets this grid item shrink so .mg2-tree scrolls within height. */
  min-height: 0;
  background: var(--bg-primary);
  padding: 0.875rem 1.125rem 1rem;
  gap: 0.75rem;
}
.mg2-cohorts__head { display: flex; align-items: baseline; gap: 0.5rem; }
.mg2-cohorts__t {
  font-size: 0.6875rem; font-weight: 600;
  color: var(--text-secondary);
}
.mg2-cohorts__n {
  margin-left: auto; font-size: 0.75rem; color: var(--text-muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

.mg2-progress { display: flex; flex-direction: column; gap: 0.4375rem; }
.mg2-progress__top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
  font-size: 0.8125rem; color: var(--text-secondary); white-space: nowrap;
}
.mg2-progress__top b { color: var(--text-primary); font-weight: 600; }
.mg2-progress__pct {
  font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums;
}
.mg2-progress__track {
  height: 0.4375rem; border-radius: 9999px; background: var(--bg-tertiary); overflow: hidden;
}
.mg2-progress__fill {
  height: 100%; border-radius: 9999px;
  background: var(--color-primary);
  transition: width 0.3s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.mg2-tree { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.mg2-tree__empty {
  font-size: 0.8125rem; color: var(--text-muted); line-height: 1.5;
  padding: 0.5rem 0; font-style: italic;
}
.mg2-grp {
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  background: var(--bg-card); overflow: hidden;
}
.mg2-grp__row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.625rem;
}
.mg2-grp__name { flex: 1; min-width: 0; font-size: 0.8125rem; font-weight: 600; color: var(--text-primary); }
.mg2-grp__n {
  font-size: 0.6875rem; font-weight: 600; color: var(--text-secondary);
  background: var(--bg-tertiary); padding: 0.0625rem 0.4375rem; border-radius: 9999px;
  font-variant-numeric: tabular-nums;
}
.mg2-sub {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3125rem 0.625rem 0.3125rem 1.625rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.75rem; color: var(--text-secondary);
}
.mg2-sub__name { flex: 1; font-family: var(--font-mono); }
.mg2-sub__n { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.mg2-sub2 {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0.625rem 0.25rem 2.625rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.6875rem; color: var(--text-muted);
}
.mg2-sub2__name { flex: 1; font-family: var(--font-mono); }
.mg2-sub2__name::before { content: '└ '; color: var(--border-color); }
.mg2-sub2__n { font-variant-numeric: tabular-nums; }

.mg2-unassigned {
  display: flex; align-items: center; gap: 0.5rem;
  font: inherit; font-size: 0.8125rem; color: var(--text-secondary);
  padding: 0.5625rem 0.625rem; cursor: pointer; text-align: left; width: 100%;
  border: 1px dashed var(--border-color); border-radius: var(--radius-md);
  background: none; transition: all 0.13s ease;
}
.mg2-unassigned:hover { border-color: var(--text-muted); background: var(--bg-hover); }
.mg2-unassigned--on { border-style: solid; border-color: var(--color-primary); background: var(--color-primary-soft); }
.mg2-unassigned b { color: var(--text-primary); font-weight: 600; }
.mg2-unassigned__act {
  margin-left: auto; font-size: 0.6875rem; font-weight: 600;
  color: var(--color-primary);
}

/* ───────── contextual assignment bar ───────── */
.mg2-bar {
  flex-shrink: 0; overflow: hidden;
  max-height: 0; opacity: 0;
  border-top: 1px solid transparent;
  background: linear-gradient(0deg, var(--color-primary-soft), var(--color-primary-soft)), var(--bg-secondary);
  transition: max-height 0.22s cubic-bezier(0.2, 0.7, 0.3, 1), opacity 0.18s ease, border-color 0.2s ease;
}
.mg2-bar--open {
  max-height: 160px; opacity: 1;
  border-top-color: var(--color-primary);
}
.mg2-bar__inner {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 0.625rem 0.75rem;
  padding: 0.6875rem 1.25rem; color: var(--text-secondary);
}
.mg2-bar .sg-btn { white-space: nowrap; flex-shrink: 0; }
.mg2-bar__count {
  display: inline-flex; align-items: center; white-space: nowrap;
  font-size: 0.8125rem; color: var(--text-primary); padding-bottom: 0.4375rem;
}
.mg2-bar__count b { font-weight: 700; font-variant-numeric: tabular-nums; }
.mg2-bar__inner > svg { color: var(--color-primary); margin-bottom: 0.5rem; flex-shrink: 0; }

.mg2-field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.mg2-field--grow { flex: 1 1 7rem; }
.mg2-field__l {
  font-size: 0.75rem; font-weight: 600;
  color: var(--text-secondary);
}
.mg2-combo {
  position: relative; display: flex; align-items: center; gap: 0.4375rem;
  padding: 0 0.625rem; height: 2.125rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color); border-radius: var(--radius);
}
.mg2-combo:focus-within { border-color: var(--color-primary); box-shadow: var(--focus-ring-soft); }
.mg2-combo input {
  flex: 1; min-width: 4rem; border: none; background: none; outline: none;
  font: inherit; font-size: 0.8125rem; color: var(--text-primary);
}
.mg2-combo__chev { color: var(--text-muted); pointer-events: none; display: flex; }

.mg2-swatches { display: flex; gap: 0.3125rem; align-items: center; height: 2.125rem; }
.mg2-swatch {
  width: 1.125rem; height: 1.125rem; border-radius: 9999px; cursor: pointer;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12);
  transition: transform 0.12s ease;
}
.mg2-swatch:hover { transform: scale(1.12); }
.mg2-swatch--on {
  border-color: var(--bg-secondary);
  box-shadow: 0 0 0 2px currentColor, inset 0 0 0 1px rgb(0 0 0 / 0.12);
}

.mg2-bar__spacer { flex: 1; }
.mg2-bar__clear {
  font: inherit; font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary);
  background: none; border: none; cursor: pointer; padding: 0.5rem 0.625rem;
  border-radius: var(--radius); margin-bottom: 0.0625rem;
}
.mg2-bar__clear:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ==========================================================================
   CSV upload control (Field Recipe header) + drag-and-drop zone
   ========================================================================== */
.fr-upload {
  display: inline-flex; align-items: center; gap: 0.3125rem;
  font: inherit; font-size: 0.75rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  padding: 0.25rem 0.5rem; border-radius: var(--radius);
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.fr-upload:hover {
  background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--text-muted);
}
.fr-upload:focus-visible { outline: none; box-shadow: var(--focus-ring-soft); }
/* anchor the drop overlay to the main panel */
.sg-body__main { position: relative; }
.fr-dropzone {
  position: absolute; inset: 0.5rem; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.5rem; pointer-events: none;
  border: 2px dashed var(--color-primary); border-radius: var(--radius-md);
  background: var(--color-primary-soft);
  color: var(--_ink-primary); font-size: 0.8125rem; font-weight: 600;
}
.fr-loading {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.625rem;
  background: var(--bg-secondary);
  color: var(--text-secondary); font-size: 0.8125rem;
}

/* ==========================================================================
   Host adapter — when AutoGroupModal renders the Smart Group card inside
   BaseModal, strip BaseModal's own chrome/padding so the .sg-modal card is the
   only visible frame, and size it to the design.
   ========================================================================== */
/* Keyed on the presence of .sg-modal (not the fallthrough `.sg-host` class,
   which doesn't reliably reach BaseModal's Teleport root) so the flatten always
   applies under BaseModal, and never matches the bare-rendered standalone
   stories (they have no .mint-modal ancestor). After this there is exactly one
   card edge — the .sg-modal one. */
.mint-modal__container:has(.sg-modal) {
  width: 980px;
  max-width: calc(100vw - 2rem);
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.mint-modal__body:has(.sg-modal) {
  padding: 0;
  background: transparent;
}
.mint-modal__container:has(.sg-modal) .sg-modal {
  height: min(640px, calc(100vh - 4rem));
}
.sg-host__error { margin: 0 0 0.75rem; }
