/* COPY of sites/_shared/magic/magic.css — edit the source there and run node _shared/sync.mjs */
/* The magic button and sheet. Source: sites/_shared/magic/ — edit there, then sync.

   Reads the shared chassis token names (sites/_shared/chassis/tokens.css), with fallbacks
   so it also looks right in an app that hasn't moved to them yet. Set --magic on :root to
   colour the mark differently from the app's --accent (rarely needed). */

.mg-scrim, .mg-mark {
  --mg-accent: var(--magic, var(--accent, #3d4fd8));
  --mg-on-accent: var(--text-on-accent, #fff);
}
.mg-scrim {
  --mg-surface: var(--surface, var(--card, #fff));
  --mg-surface-2: var(--surface-2, var(--card2, #f2f2f5));
  --mg-text: var(--text, #1c1d21);
  --mg-text-2: var(--text-2, var(--muted, #5c5f6a));
  --mg-border: var(--border-strong, var(--border, #d9d8d3));
  --mg-r: var(--r-lg, var(--radius, 16px));
  --mg-r-sm: var(--r-md, var(--radius-sm, 12px));
  --mg-shadow: var(--shadow-lg, 0 20px 60px rgba(0, 0, 0, .28));
}

/* the mark — inherits size from the text, colour from the app's accent */
.mg-mark { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.18em; color: var(--mg-accent); }
magic-mark { display: inline-flex; }
/* on a filled (primary) button the mark takes the button's text colour */
.btn-primary .mg-mark, .primary .mg-mark, .mg-solid .mg-mark, .mg-go .mg-mark { color: currentColor; }

/* sheet: centred dialog on desktop, bottom sheet on phones */
.mg-scrim { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
  background: var(--overlay, rgba(10, 12, 20, .45)); font: inherit; color: var(--mg-text); }
.mg-sheet { width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain;
  background: var(--mg-surface); color: var(--mg-text); border-radius: var(--mg-r); box-shadow: var(--mg-shadow);
  padding: 18px; display: grid; gap: 14px; text-align: left; }
@media (max-width: 560px) {
  .mg-scrim { place-items: end stretch; padding: 0; }
  .mg-sheet { width: 100%; border-radius: var(--mg-r) var(--mg-r) 0 0; max-height: 92dvh;
    padding-bottom: max(18px, env(safe-area-inset-bottom, 0px)); }
}
.mg-head { display: flex; align-items: center; gap: 10px; }
.mg-head h2 { flex: 1; margin: 0; font-size: 1.1rem; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; color: var(--mg-text); }
.mg-badge { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--mg-accent) 14%, transparent); }
.mg-badge .mg-mark { width: 19px; height: 19px; }
.mg-x { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--mg-surface-2); color: var(--mg-text-2);
  font-size: 15px; cursor: pointer; flex: none; }
.mg-using { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .85rem; color: var(--mg-text-2); }
.mg-using[hidden] { display: none; }
.mg-chip { display: inline-flex; padding: 4px 10px; border-radius: 999px; background: var(--mg-surface-2); color: var(--mg-text);
  font-size: .8rem; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-body { display: grid; gap: 14px; }
.mg-opts { display: flex; flex-wrap: wrap; gap: 12px; }
.mg-opt { display: grid; gap: 4px; font-size: .82rem; font-weight: 600; color: var(--mg-text-2); }
.mg-opt select { min-height: 44px; min-width: 88px; font: inherit; font-size: 16px; font-weight: 600; padding: 0 10px;
  border-radius: 10px; border: 1px solid var(--mg-border); background: var(--mg-surface); color: var(--mg-text); }
.mg-opt select:focus-visible { outline: 2px solid var(--mg-accent); outline-offset: 2px; }

.mg-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border-radius: var(--mg-r-sm); background: var(--mg-surface-2); }
.mg-seg button { border: 0; background: transparent; border-radius: calc(var(--mg-r-sm) - 3px); padding: 9px 6px; min-height: 48px;
  font: inherit; font-weight: 700; font-size: .9rem; color: var(--mg-text-2); cursor: pointer; display: grid; gap: 1px; justify-items: center; }
.mg-seg button small { font-size: .74rem; font-weight: 500; color: var(--mg-text-2); }
.mg-seg button[aria-pressed="true"] { background: var(--mg-surface); color: var(--mg-text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.mg-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.mg-steps li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: start; font-size: .92rem; }
.mg-steps li > span { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .78rem;
  background: var(--mg-surface-2); color: var(--mg-text-2); }
.mg-steps li.mg-done > span { background: var(--mg-accent); color: var(--mg-on-accent); }
.mg-steps a { color: var(--mg-accent); font-weight: 600; }
.mg-stack { display: grid; gap: 8px; }
.mg-sheet input[type="password"] { width: 100%; min-height: 44px; font: inherit; font-size: 16px; padding: 0 10px;
  border-radius: 10px; border: 1px solid var(--mg-border); background: var(--mg-surface); color: var(--mg-text); }
.mg-link { border: 0; background: none; padding: 0; font: inherit; color: var(--mg-accent); font-weight: 600; text-decoration: underline; cursor: pointer; }
.mg-sheet textarea { width: 100%; min-height: 96px; resize: vertical; font: inherit; font-size: .85rem; line-height: 1.4; padding: 10px;
  border-radius: 10px; border: 1px solid var(--mg-border); background: var(--mg-surface); color: var(--mg-text); }

.mg-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.mg-actions.mg-split { justify-content: space-between; }
.mg-go, .mg-ghost { min-height: 44px; padding: 0 18px; border-radius: var(--mg-r-sm); font: inherit; font-weight: 700; font-size: .92rem;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; touch-action: manipulation; }
.mg-go { border: 1px solid var(--mg-accent); background: var(--mg-accent); color: var(--mg-on-accent); }
.mg-go:hover { filter: brightness(.94); }
.mg-ghost { border: 1px solid var(--mg-border); background: var(--mg-surface); color: var(--mg-text); }
.mg-go[disabled], .mg-ghost[disabled] { opacity: .45; cursor: default; filter: none; }
.mg-sheet button:focus-visible, .mg-sheet a:focus-visible, .mg-sheet textarea:focus-visible, .mg-sheet input:focus-visible {
  outline: 2px solid var(--mg-accent); outline-offset: 2px; }

.mg-note { margin: 0; font-size: .82rem; color: var(--mg-text-2); }
.mg-error { margin: 0; font-size: .85rem; color: var(--danger, var(--red, #c4423a)); }
.mg-status { margin: 0; display: flex; gap: 8px; align-items: center; font-size: .88rem; color: var(--mg-text-2); }
.mg-status i { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 2px solid var(--mg-border); border-top-color: var(--mg-accent);
  animation: mg-spin .8s linear infinite; }
@keyframes mg-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mg-status i { animation: none; } }
.mg-preview { display: grid; gap: 6px; }
