/* MonkeyPatch components — requires tokens.css
 * Canonical copy: design-system/mp.css (synced by scripts/sync-design-tokens.mjs)
 * All resets are wrapped in :where() so component classes always win.
 * Colors come only from semantic tokens. Class prefix: mp-
 */

/* ---------- Base ---------- */
:where(.mp-root) {
  margin: 0;
  background: var(--mp-surface-base);
  color: var(--mp-text-primary);
  font-family: var(--mp-font);
  font-size: var(--mp-fs-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
:where(.mp-root) :where(*, *::before, *::after) { box-sizing: border-box; }
:where(.mp-root) :where(button, input, textarea, select) { font: inherit; color: inherit; }
:where(.mp-root) :where(a) { color: inherit; text-decoration: none; }
:where(.mp-root) :focus-visible { outline: 2px solid var(--mp-focus); outline-offset: 2px; }

.mp-mono { font-family: var(--mp-mono); }
.mp-trunc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mp-link { color: var(--mp-action-ink); text-decoration: underline; text-underline-offset: 2px; }

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--mp-border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--mp-border-strong); }

/* Icons (Lucide, inline SVG) */
.mp-icon {
  width: var(--mp-icon); height: var(--mp-icon); flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: var(--mp-icon-stroke);
  stroke-linecap: round; stroke-linejoin: round;
}
.mp-icon--sm { width: var(--mp-icon-sm); height: var(--mp-icon-sm); }

/* ---------- Shell ---------- */
.mp-app { position: relative; display: flex; flex-direction: column; height: 100vh; min-width: 320px; overflow: hidden; background: var(--mp-surface-base); }
.mp-header {
  height: 36px; flex-shrink: 0;
  display: flex; align-items: center; gap: 6px; padding: 0 8px 0 10px;
}
.mp-header__logo { width: 26px; height: 26px; flex-shrink: 0; }
.mp-header__brand { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin-left: 2px; white-space: nowrap; }
.mp-header__spacer { flex: 1; }
.mp-workspace {
  display: inline-flex; align-items: center; gap: 3px; min-width: 0;
  height: 28px; padding: 0 6px 0 8px; border: 0; border-radius: var(--mp-radius-sm);
  background: transparent; color: var(--mp-text-tertiary); font-size: var(--mp-fs-meta); cursor: pointer;
}
.mp-workspace:hover { background: var(--mp-surface-muted); color: var(--mp-text-primary); }
.mp-sync {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px;
  border: 0; border-radius: var(--mp-radius-pill); background: transparent;
  font-size: var(--mp-fs-meta); color: var(--mp-text-secondary); white-space: nowrap; cursor: pointer;
}
.mp-sync:hover { background: var(--mp-surface-muted); color: var(--mp-text-primary); }
.mp-sync .mp-status__dot { box-shadow: 0 0 0 3px var(--mp-status-success-surface); }
.mp-sync--offline { color: var(--mp-status-attention); background: var(--mp-status-attention-surface); }
.mp-sync--offline .mp-icon { color: var(--mp-status-attention-icon); }
.mp-account-link {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px; height: 28px; max-width: 190px;
  padding: 0 8px; border: 0; border-radius: var(--mp-radius-pill); background: transparent;
  font-size: var(--mp-fs-meta); color: var(--mp-text-secondary); cursor: pointer;
  min-width: 0;
}
.mp-account-link:hover { background: var(--mp-surface-muted); color: var(--mp-text-primary); }
.mp-account-link--active { background: var(--mp-surface-card); color: var(--mp-text-primary); font-weight: 500; }
.mp-account-link--offline { color: var(--mp-status-attention); background: var(--mp-status-attention-surface); }
.mp-account-link--offline .mp-icon { color: var(--mp-status-attention-icon); }
.mp-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--mp-surface-card); border: 1px solid var(--mp-border-default);
  font-size: 11px; font-weight: 600; color: var(--mp-text-primary);
}
/* Update pip — coral = "an update needs your attention" */
.mp-pip { position: absolute; top: 3px; right: 3px; width: 9px; height: 9px; border-radius: 50%; background: var(--mp-status-attention-fill); border: 2px solid var(--mp-surface-base); }

/* Primary nav — selected = amber */
.mp-nav {
  flex-shrink: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px;
  margin: 0 8px 6px; padding: 3px; border-radius: 12px;
  background: var(--mp-surface-sunken); border: 1px solid var(--mp-border-subtle);
}
.mp-nav__tab {
  position: relative;
  height: var(--mp-nav-tab-h); display: flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; background: transparent; cursor: pointer;
  border-radius: 9px; color: var(--mp-text-secondary); font-size: var(--mp-fs-label); font-weight: 500;
  transition: color var(--mp-dur-fast) var(--mp-ease), background var(--mp-dur-fast) var(--mp-ease);
}
.mp-nav__tab:hover { color: var(--mp-text-primary); background: var(--mp-surface-card); }
.mp-nav__tab[aria-current="page"] {
  background: var(--mp-action-primary); color: var(--mp-action-on-primary); font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--mp-action-primary-edge);
}
.mp-nav__tab[aria-current="page"] .mp-icon { color: var(--mp-action-on-primary); }
.mp-nav__tab[aria-current="page"] .mp-badge { background: color-mix(in srgb, var(--mp-action-on-primary) 12%, transparent); color: var(--mp-action-on-primary); }

.mp-main { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px var(--mp-space-5); display: flex; flex-direction: column; gap: var(--mp-space-3); }

/* Sub-nav & segmented — selected = subtle amber */
.mp-subnav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mp-subnav__item {
  height: 32px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--mp-radius-pill); border: 1px solid transparent; background: transparent;
  font-size: var(--mp-fs-label); font-weight: 500; color: var(--mp-text-secondary); cursor: pointer;
}
.mp-subnav__item:hover { color: var(--mp-text-primary); background: var(--mp-surface-muted); }
.mp-subnav__item[aria-current="page"] { color: var(--mp-action-ink-strong); background: var(--mp-action-subtle); border-color: var(--mp-action-subtle-edge); }

.mp-back {
  display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 10px 0 4px; margin-left: -4px;
  border: 0; background: transparent; cursor: pointer;
  border-radius: var(--mp-radius-sm); color: var(--mp-text-secondary); font-size: var(--mp-fs-label); font-weight: 500;
}
.mp-back:hover { background: var(--mp-surface-muted); color: var(--mp-text-primary); }

/* Context strip (current website) */
.mp-context {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 12px;
  border-radius: var(--mp-radius-group); background: var(--mp-surface-card); border: 1px solid var(--mp-border-subtle);
}
.mp-favicon { width: 32px; height: 32px; border-radius: var(--mp-radius-sm); background: var(--mp-surface-muted); color: var(--mp-text-primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }

/* ---------- Output Patch Picker ---------- */
.mp-picker-wrap { position: relative; }
.mp-picker {
  width: 100%; min-height: 54px; padding: 8px 10px 8px 12px;
  display: flex; align-items: center; gap: 10px;
  border-radius: var(--mp-radius-group); background: var(--mp-surface-card); border: 1px solid var(--mp-border-subtle);
  text-align: left; cursor: pointer;
}
.mp-picker:hover { border-color: var(--mp-border-default); background: var(--mp-surface-overlay); }
.mp-picker--static { cursor: default; }
.mp-picker--static:hover { background: var(--mp-surface-card); border-color: var(--mp-border-subtle); }

/* ---------- Surface Card & Stats ---------- */
.mp-card {
  padding: var(--mp-space-4); border-radius: var(--mp-radius-group);
  background: var(--mp-surface-card); display: flex; flex-direction: column; gap: var(--mp-space-3);
}
.mp-card--bordered { border: 1px solid var(--mp-border-subtle); }
.mp-stats-grid { display: grid; gap: var(--mp-space-2); }
.mp-stat-card {
  padding: 10px 12px; border-radius: var(--mp-radius-card);
  background: var(--mp-surface-card); border: 1px solid var(--mp-border-subtle);
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.mp-stat-card__label { font-size: var(--mp-fs-meta); color: var(--mp-text-secondary); }
.mp-stat-card__value { font-size: var(--mp-fs-heading); font-weight: 600; color: var(--mp-text-primary); font-variant-numeric: tabular-nums; }

/* ---------- Callout (Dusk Crimson) ----------
 * The signature inverted surface: AI creation, announcements, featured
 * moments. Forced dark scheme inside, so every token flips to cream text.
 * At most one per view. */
.mp-callout {
  color-scheme: dark;
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px; border-radius: var(--mp-radius-group);
  background: var(--mp-callout-gradient);
  border: 1px solid var(--mp-callout-border);
  color: var(--mp-callout-text);
}
.mp-callout__eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: var(--mp-fs-meta); font-weight: 600; color: var(--color-crisp-amber-200); }
.mp-callout__title { margin: 0; font-size: var(--mp-fs-heading); line-height: var(--mp-lh-heading); font-weight: 600; color: var(--mp-callout-text); }
.mp-callout__body { margin: 0; font-size: var(--mp-fs-label); color: var(--mp-callout-text-2); }
.mp-callout__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Buttons ---------- */
.mp-btn {
  height: var(--mp-control-h); padding: 0 14px; border-radius: var(--mp-radius-control);
  border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: var(--mp-fs-label); font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background var(--mp-dur-fast) var(--mp-ease), color var(--mp-dur-fast) var(--mp-ease), border-color var(--mp-dur-fast) var(--mp-ease);
}
.mp-btn--sm { height: var(--mp-control-h-sm); padding: 0 10px; font-size: var(--mp-fs-meta); border-radius: var(--mp-radius-sm); }
.mp-btn--block { width: 100%; }
.mp-btn--primary { background: var(--mp-action-primary); border-color: var(--mp-action-primary-edge); color: var(--mp-action-on-primary); box-shadow: var(--mp-shadow-sm); }
.mp-btn--primary:hover { background: var(--mp-action-primary-hover); }
.mp-btn--primary:active { background: var(--mp-action-primary-pressed); }
.mp-btn--secondary { background: var(--mp-surface-card); border-color: var(--mp-border-default); color: var(--mp-text-primary); }
.mp-btn--secondary:hover { background: var(--mp-action-subtle-hover); border-color: var(--mp-action-subtle-edge); }
.mp-btn--secondary:active { background: var(--mp-action-subtle); }
.mp-btn--tertiary { background: transparent; color: var(--mp-text-secondary); padding: 0 10px; }
.mp-btn--tertiary:hover { background: var(--mp-surface-muted); color: var(--mp-text-primary); }
.mp-btn--destructive { background: transparent; border-color: var(--mp-status-error-border); color: var(--mp-status-error); }
.mp-btn--destructive:hover { background: var(--mp-status-error-surface); }
.mp-btn--danger-fill { background: var(--mp-status-error-fill); color: var(--mp-status-on-error-fill); } /* confirm dialogs only */
.mp-btn--danger-fill:hover { background: var(--color-dusk-crimson-800); }
.mp-btn:focus-visible { outline: none; box-shadow: var(--mp-focus-ring); }
.mp-btn:disabled, .mp-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.mp-btn--primary:disabled { opacity: 1; background: var(--mp-surface-muted); border-color: var(--mp-border-subtle); color: var(--mp-text-tertiary); box-shadow: none; }
.mp-btn[aria-busy="true"] { color: transparent; position: relative; pointer-events: none; }
.mp-btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--mp-text-primary) 25%, transparent); border-top-color: var(--mp-text-primary);
  animation: mp-spin 0.8s linear infinite;
}
.mp-btn--primary[aria-busy="true"]::after { border-color: color-mix(in srgb, var(--mp-action-on-primary) 25%, transparent); border-top-color: var(--mp-action-on-primary); }

.mp-icon-btn {
  width: 40px; height: 40px; flex-shrink: 0; padding: 0; position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--mp-radius-control); background: transparent; color: var(--mp-text-secondary); cursor: pointer;
}
.mp-icon-btn:hover { background: var(--mp-surface-muted); color: var(--mp-text-primary); }
.mp-icon-btn:focus-visible { outline: none; box-shadow: var(--mp-focus-ring); }
.mp-icon-btn--muted { width: 36px; color: var(--mp-text-tertiary); }

/* ---------- Form fields ---------- */
.mp-field { display: flex; flex-direction: column; gap: 6px; }
.mp-field__label { font-size: var(--mp-fs-body); font-weight: 600; color: var(--mp-text-primary); padding-left: 2px; }
.mp-field__error { display: flex; align-items: center; gap: 6px; font-size: var(--mp-fs-meta); color: var(--mp-status-error); }
.mp-field__hint { font-size: var(--mp-fs-label); color: var(--mp-text-secondary); line-height: 1.45; }
.mp-input, .mp-select, .mp-textarea {
  width: 100%; border-radius: var(--mp-radius-control); border: 1px solid var(--mp-border-default);
  background: var(--mp-surface-input); color: var(--mp-text-primary); font-size: var(--mp-fs-body);
  transition: border-color var(--mp-dur-fast) var(--mp-ease), box-shadow var(--mp-dur-fast) var(--mp-ease);
}
.mp-input, .mp-select { height: var(--mp-control-h); padding: 0 12px; }
.mp-textarea { min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.mp-input::placeholder, .mp-textarea::placeholder { color: var(--mp-text-placeholder); font-size: var(--mp-fs-label); }
.mp-input:hover, .mp-select:hover, .mp-textarea:hover { border-color: var(--mp-border-strong); }
.mp-input:focus, .mp-select:focus, .mp-textarea:focus { outline: none; border-color: var(--mp-focus); box-shadow: 0 0 0 3px var(--mp-action-subtle); }
.mp-input[aria-invalid="true"], .mp-textarea[aria-invalid="true"] { border-color: var(--mp-status-error); }
.mp-input--mono { font-family: var(--mp-mono); font-size: 12.5px; }
/* Chevron uses cream-500 (#868076): the ramp's fixed midpoint, legible in both themes. */
.mp-select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23868076' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.mp-select--sm { height: 32px; padding: 0 30px 0 10px; font-size: var(--mp-fs-meta); border-radius: var(--mp-radius-sm); background-position: right 8px center; }

/* ---------- Switch (button role="switch") — on = amber ---------- */
.mp-switch { width: var(--mp-hit); height: var(--mp-hit); flex-shrink: 0; padding: 0; border: 0; background: transparent; position: relative; cursor: pointer; }
.mp-switch::before { content: ""; position: absolute; left: 4px; top: 12px; width: 36px; height: 20px; border-radius: 10px; background: var(--mp-surface-muted); box-shadow: inset 0 0 0 1px var(--mp-border-strong); transition: background var(--mp-dur-base) var(--mp-ease), box-shadow var(--mp-dur-base) var(--mp-ease); }
.mp-switch::after { content: ""; position: absolute; left: 7px; top: 15px; width: 14px; height: 14px; border-radius: 50%; background: var(--mp-text-tertiary); transition: transform var(--mp-dur-base) var(--mp-ease), background var(--mp-dur-base) var(--mp-ease); }
.mp-switch[aria-checked="true"]::before { background: var(--mp-action-primary); box-shadow: inset 0 0 0 1px var(--mp-action-primary-edge); }
.mp-switch[aria-checked="true"]::after { transform: translateX(16px); background: var(--mp-action-on-primary); }
.mp-switch:disabled { opacity: 0.45; cursor: not-allowed; }
.mp-switch:focus-visible { outline: none; }
.mp-switch:focus-visible::before { box-shadow: var(--mp-focus-ring); }

/* ---------- Checkbox (native input) ---------- */
.mp-checkbox {
  appearance: none; -webkit-appearance: none; margin: 0; flex-shrink: 0; cursor: pointer;
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--mp-border-strong); background: var(--mp-surface-input);
  display: inline-grid; place-content: center;
}
.mp-checkbox:checked { background: var(--mp-action-primary); border-color: var(--mp-action-primary-edge); }
.mp-checkbox:checked::after { content: ""; width: 10px; height: 5px; border-left: 2px solid var(--mp-action-on-primary); border-bottom: 2px solid var(--mp-action-on-primary); transform: rotate(-45deg) translate(1px, -1px); }
.mp-checkbox:focus-visible { outline: none; box-shadow: var(--mp-focus-ring); }
.mp-check-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px; cursor: pointer; }
.mp-check-row + .mp-check-row { border-top: 1px solid var(--mp-border-subtle); }

/* ---------- Segmented control ---------- */
.mp-seg { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 3px; padding: 4px; border-radius: var(--mp-radius-control); background: var(--mp-surface-sunken); border: 1px solid var(--mp-border-subtle); }
.mp-seg__item { height: 36px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--mp-text-secondary); font-size: var(--mp-fs-label); font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-seg__item:hover { color: var(--mp-text-primary); }
.mp-seg__item[aria-pressed="true"], .mp-seg__item[aria-selected="true"], .mp-seg__item[aria-checked="true"] { background: var(--mp-surface-overlay); color: var(--mp-action-ink-strong); box-shadow: inset 0 0 0 1px var(--mp-action-subtle-edge), var(--mp-shadow-sm); font-weight: 600; }

/* ---------- Chips ---------- */
.mp-chip-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mp-chip {
  height: 28px; padding: 0 10px; border-radius: var(--mp-radius-pill);
  border: 1px solid var(--mp-border-subtle); background: var(--mp-surface-card);
  color: var(--mp-text-secondary); font-size: var(--mp-fs-meta); font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
}
.mp-chip:hover { color: var(--mp-text-primary); border-color: var(--mp-border-default); }
.mp-chip[aria-pressed="true"] { color: var(--mp-action-ink-strong); background: var(--mp-action-subtle); border-color: var(--mp-action-subtle-edge); }
.mp-chip__remove {
  margin-left: 2px; margin-right: -4px; padding: 0 4px; border: 0; background: transparent;
  color: var(--mp-text-tertiary); font-size: 13px; cursor: pointer; border-radius: 99px;
}
.mp-chip__remove:hover { color: var(--mp-status-error); }

/* ---------- Lists ---------- */
.mp-section { display: flex; align-items: center; gap: 8px; margin: var(--mp-space-2) 0 var(--mp-space-1); padding: 0 4px; }
.mp-section__title { margin: 0; flex: 1; font-size: var(--mp-fs-label); font-weight: 600; color: var(--mp-text-secondary); }
.mp-section__count { margin-left: 6px; font-weight: 400; color: var(--mp-text-tertiary); }
.mp-group { background: var(--mp-surface-card); border-radius: var(--mp-radius-group); border: 1px solid var(--mp-border-subtle); }
.mp-row { display: flex; align-items: center; gap: 2px; min-height: 60px; padding: 6px 4px; position: relative; }
.mp-row--compact { min-height: 46px; padding: 4px 12px; justify-content: space-between; gap: 10px; }
button.mp-row, .mp-row--interactive { width: 100%; border: 0; border-radius: var(--mp-radius-group); background: transparent; color: var(--mp-text-primary); font: inherit; text-align: left; cursor: pointer; transition: background var(--mp-dur-fast) var(--mp-ease); }
button.mp-row:hover, .mp-row--interactive:hover { background: var(--mp-surface-muted); }
.mp-row--note { align-items: flex-start; padding: 10px 6px 10px 12px; gap: 8px; }
.mp-row + .mp-row { border-top: 1px solid var(--mp-border-subtle); }
.mp-row__main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 6px 8px; border: 0; background: transparent; text-align: left; border-radius: var(--mp-radius-control); }
a.mp-row__main, button.mp-row__main { cursor: pointer; }
a.mp-row__main:hover, button.mp-row__main:hover { background: var(--mp-surface-muted); }
.mp-row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mp-row__name { font-size: var(--mp-fs-body); font-weight: 500; color: var(--mp-text-primary); }
.mp-tile { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--mp-surface-muted); color: var(--mp-text-secondary); }
.mp-tile--lg { width: 44px; height: 44px; border-radius: 11px; }
.mp-tile--accent { background: var(--mp-action-subtle); color: var(--mp-action-ink); }
.mp-tile--running { background: var(--mp-status-success-surface); color: var(--mp-status-success); }
.mp-tile--callout { background: var(--mp-callout-surface); color: var(--color-crisp-amber-300); }

.mp-meta { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--mp-fs-meta); color: var(--mp-text-tertiary); }

/* Status line — always icon + words. Green = running/healthy, coral = attention. */
.mp-status { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--mp-fs-meta); color: var(--mp-text-tertiary); }
.mp-status__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mp-status-success-icon); flex-shrink: 0; }
.mp-status--running { color: var(--mp-status-success); font-weight: 500; }
.mp-status--error { color: var(--mp-status-error); font-weight: 500; }
.mp-status--error .mp-status__dot { background: var(--mp-status-error-icon); }
.mp-status--warning { color: var(--mp-status-attention); }
.mp-status--warning .mp-status__dot, .mp-status--warning .mp-icon { background: none; color: var(--mp-status-attention-icon); }
.mp-status--off .mp-icon { stroke-dasharray: 3 3; }

/* ---------- Badge ---------- */
.mp-badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--mp-radius-badge); background: var(--mp-surface-muted); color: var(--mp-text-secondary); font-size: var(--mp-fs-badge); font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.mp-badge--success, .mp-badge--running { background: var(--mp-status-success-surface); color: var(--mp-status-success); }
.mp-badge--warning { background: var(--mp-status-attention-surface); color: var(--mp-status-attention); }
.mp-badge--error { background: var(--mp-status-error-surface); color: var(--mp-status-error); }
/* "New version", "Update" — coral: an update that wants attention */
.mp-badge--new, .mp-badge--update { background: var(--mp-status-attention-surface); color: var(--mp-status-attention); box-shadow: inset 0 0 0 1px var(--mp-status-attention-border); }
.mp-badge--accent { background: var(--mp-action-subtle); color: var(--mp-action-ink-strong); }

/* ---------- Alert ---------- */
.mp-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--mp-radius-card); font-size: var(--mp-fs-label); }
.mp-alert__title { font-weight: 600; font-size: var(--mp-fs-body); }
.mp-alert__body { color: var(--mp-text-secondary); margin-top: 2px; word-break: break-word; }
.mp-alert__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.mp-alert--error { background: var(--mp-status-error-surface); border: 1px solid var(--mp-status-error-border); box-shadow: inset 3px 0 0 var(--mp-status-error-icon); }
.mp-alert--error > .mp-icon, .mp-alert--error .mp-alert__title { color: var(--mp-status-error); }
.mp-alert--warning { background: var(--mp-status-attention-surface); border: 1px solid var(--mp-status-attention-border); }
.mp-alert--warning > .mp-icon { color: var(--mp-status-attention-icon); }
.mp-alert--success { background: var(--mp-status-success-surface); border: 1px solid var(--mp-status-success-border); }
.mp-alert--success > .mp-icon { color: var(--mp-status-success); }
.mp-alert--info { background: var(--mp-surface-card); border: 1px solid var(--mp-border-default); }
.mp-alert--info > .mp-icon { color: var(--mp-text-secondary); }
/* Updates: coral info, distinct from errors */
.mp-alert--update { background: var(--mp-status-attention-surface); border: 1px solid var(--mp-status-attention-border); }
.mp-alert--update > .mp-icon { color: var(--mp-status-attention-icon); }
.mp-trace { margin-top: 10px; padding: 10px; border-radius: var(--mp-radius-sm); background: var(--mp-surface-input); border: 1px solid var(--mp-border-subtle); font-family: var(--mp-mono); font-size: 11.5px; line-height: 1.5; color: var(--mp-text-secondary); white-space: pre-wrap; word-break: break-all; }

/* ---------- Menu ---------- */
.mp-menu { min-width: 210px; padding: 6px; border-radius: var(--mp-radius-card); background: var(--mp-surface-overlay); border: 1px solid var(--mp-border-default); box-shadow: var(--mp-shadow-menu); z-index: 40; }
.mp-menu--popover { position: absolute; right: 6px; top: calc(100% - 4px); }
.mp-menu__item { width: 100%; height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: var(--mp-radius-sm); background: transparent; color: var(--mp-text-primary); font-size: var(--mp-fs-label); text-align: left; cursor: pointer; }
.mp-menu__item .mp-icon { color: var(--mp-text-tertiary); }
.mp-menu__item:hover, .mp-menu__item:focus-visible { background: var(--mp-surface-muted); outline: none; }
.mp-menu__item:disabled { opacity: 0.45; cursor: default; }
.mp-menu__item--danger, .mp-menu__item--danger .mp-icon { color: var(--mp-status-error); }
.mp-menu__label { padding: 6px 10px 4px; font-size: 11px; color: var(--mp-text-tertiary); }
.mp-menu__divider { height: 1px; margin: 4px 8px; background: var(--mp-border-subtle); }

/* ---------- Toast ---------- */
.mp-toast-region { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 50; pointer-events: none; display: flex; flex-direction: column; gap: 8px; }
.mp-toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 6px 6px 6px 14px; border-radius: var(--mp-radius-card); background: var(--mp-surface-overlay); border: 1px solid var(--mp-border-default); box-shadow: var(--mp-shadow-menu); font-size: var(--mp-fs-label); color: var(--mp-text-primary); }
.mp-toast__text { flex: 1; min-width: 0; }
.mp-toast__action { color: var(--mp-action-ink); font-weight: 600; }
/* Branded toast (crimson) — for meaningful feedback, e.g. "Your patch is live" */
.mp-toast--callout { color-scheme: dark; background: var(--mp-callout-gradient); border-color: var(--mp-callout-border); color: var(--mp-callout-text); }
.mp-toast--callout .mp-toast__action { color: var(--color-crisp-amber-300); }

/* ---------- Sheet & dialog ---------- */
.mp-overlay-container { position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column; justify-content: center; padding: 16px; }
.mp-scrim { position: absolute; inset: 0; background: var(--mp-scrim); border: 0; padding: 0; cursor: pointer; }
.mp-sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 61; padding: 8px 12px 20px; background: var(--mp-surface-overlay); border-top: 1px solid var(--mp-border-default); border-radius: var(--mp-radius-sheet) var(--mp-radius-sheet) 0 0; box-shadow: var(--mp-shadow-dialog); }
.mp-sheet__grab { width: 36px; height: 4px; border-radius: 2px; background: var(--mp-border-default); margin: 2px auto 10px; }
.mp-option { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 10px; border: 0; border-radius: var(--mp-radius-card); background: transparent; color: var(--mp-text-primary); text-align: left; cursor: pointer; }
.mp-option:hover { background: var(--mp-surface-muted); }
/* Featured option = the AI creation moment → crimson callout */
.mp-option--featured { color-scheme: dark; background: var(--mp-callout-gradient); border: 1px solid var(--mp-callout-border); color: var(--mp-callout-text); margin-bottom: 4px; }
.mp-option--featured:hover { background: var(--mp-callout-gradient); border-color: var(--color-crisp-amber-500); }
.mp-option--featured .mp-tile { background: color-mix(in srgb, var(--color-crisp-amber-300) 16%, transparent); color: var(--color-crisp-amber-300); }
.mp-dialog { position: relative; z-index: 61; padding: 20px; border-radius: 16px; background: var(--mp-surface-overlay); border: 1px solid var(--mp-border-default); box-shadow: var(--mp-shadow-dialog); }
.mp-dialog__title { margin: 0; font-size: var(--mp-fs-heading); font-weight: 600; }
.mp-dialog__body { margin: 6px 0 0; font-size: var(--mp-fs-label); color: var(--mp-text-secondary); }
.mp-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- Empty, loading ---------- */
.mp-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 32px 20px; text-align: center; }
.mp-empty__icon { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 8px; display: flex; align-items: center; justify-content: center; background: var(--mp-action-subtle); color: var(--mp-action-ink); }
.mp-empty__icon .mp-icon { width: 28px; height: 28px; stroke-width: 1.5; }
.mp-empty__title { font-size: 15px; font-weight: 600; }
.mp-empty__body { max-width: 280px; font-size: var(--mp-fs-label); color: var(--mp-text-secondary); }
.mp-empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }

.mp-skeleton { background: var(--mp-surface-muted); border-radius: 6px; animation: mp-pulse 1.4s ease-in-out infinite; }
.mp-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--mp-border-default); border-top-color: var(--mp-action-ink); animation: mp-spin 0.8s linear infinite; }

/* ---------- Progress, code ---------- */
.mp-progress { height: 6px; border-radius: 3px; background: var(--mp-surface-muted); overflow: hidden; }
.mp-progress__bar { display: block; height: 100%; border-radius: 3px; background: var(--mp-action-primary); transition: width var(--mp-dur-slow) var(--mp-ease); }
.mp-code { margin: 0; padding: 10px 12px; border-radius: var(--mp-radius-card); border: 1px solid var(--mp-border-subtle); background: var(--mp-surface-input); font-family: var(--mp-mono); font-size: var(--mp-fs-code); line-height: var(--mp-lh-code); color: var(--mp-text-primary); white-space: pre; overflow-x: auto; }
.mp-code .tok-comment { color: var(--mp-syntax-comment); font-style: italic; }
.mp-code .tok-prop { color: var(--mp-text-secondary); }
.mp-code .tok-value { color: var(--mp-syntax-string); }

@keyframes mp-spin { to { transform: rotate(360deg); } }
@keyframes mp-pulse { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) {
  .mp-skeleton, .mp-spinner, .mp-btn[aria-busy="true"]::after { animation: none; }
}
