/* Edit panel on the AI page preview (make-edit.js; docs/design/ai-creator.md State 4). Tokens from app.css only;
   the palette swatches take their colours from the page palettes. */
.mk-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-1); }
.mk-dock:has(#mk-publish:not([hidden])) .mk-tools { margin-bottom: var(--s-3); }
.mk-tool {
  display: grid; justify-items: center; align-content: center; gap: var(--s-1); min-width: 0; min-height: 56px; padding: var(--s-1) 0;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); font: inherit; font-size: var(--fs-xs); font-weight: 650; cursor: pointer;
}
.mk-tool-ic { position: relative; display: grid; place-items: center; }
.mk-tool-ic > .i { width: 22px; height: 22px; color: var(--ink-2); }
.mk-tool-l { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-tool[aria-disabled='true'] { opacity: 0.4; }
/* focus returns to the opener while the dock is disabled (Changing…): no ring until it re-enables */
.mk-tool[aria-disabled='true']:focus-visible { outline-color: transparent; }
.mk-badge {
  position: absolute; top: calc(-1 * var(--s-2)); left: calc(100% - var(--s-1)); display: grid; place-items: center; min-width: 20px; height: 20px;
  padding: 0 var(--s-1); border-radius: var(--r-pill); background: var(--paper-deep); color: var(--ink); font-size: var(--fs-xs); font-weight: 700;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.mk-badge .i { width: 14px; height: 14px; color: var(--gold-ink); }
#undo[hidden] { display: none; }
#undo { flex: none; color: var(--ink); }
#undo[aria-disabled='true'] { opacity: 0.4; cursor: default; }
body.is-ready .topbar { gap: var(--s-2); }
/* Small phones: back, Draft, Undo and the language toggle only fit with the back arrow alone (label kept for readers). */
@media (max-width: 399px) {
  body.is-ready .topbar { gap: var(--s-1); }
  body.is-ready .topbar-back { min-width: 44px; justify-content: center; padding: 0; }
  body.is-ready #back-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* sheets */
.mk-sheet .sheet-head h2 { flex: 1; min-width: 0; }
.mk-sheet .sheet-head .meta-r { flex: none; }
.mk-sheet .sheet-body { display: grid; gap: var(--s-4); align-content: start; padding-top: var(--s-2); }
.mk-note { margin: 0; color: var(--ink-2); font-size: var(--fs-sm); }
.mk-sheet .mk-chip { white-space: nowrap; }

/* Colours: 3 × 2 so every name stays on screen at 360 px */
.mk-pals { display: grid; grid-template-columns: repeat(3, 72px); justify-content: space-between; row-gap: var(--s-4); }
.mk-pal {
  display: grid; justify-items: center; align-content: start; gap: var(--s-2); width: 72px; height: 88px; padding: var(--s-1) 0 0;
  border: 0; background: transparent; color: var(--ink); font: inherit; cursor: pointer;
}
.mk-swatch {
  position: relative; display: grid; place-items: center; width: 56px; height: 56px; border-radius: var(--r-md);
  box-shadow: inset 0 0 0 1px rgb(43 24 56 / 0.12);
}
.mk-swatch .i { width: 24px; height: 24px; stroke-width: 2.6; }
.mk-dot { position: absolute; right: var(--s-1); bottom: var(--s-1); width: 12px; height: 12px; border-radius: 50%; }
.mk-pal[aria-checked='true'] .mk-swatch { outline: 2px solid var(--ink); outline-offset: 2px; }
.mk-pal-l { max-width: 100%; font-size: var(--fs-xs); font-weight: 650; white-space: nowrap; }
.mk-pal:focus-visible { outline: none; }
.mk-pal:focus-visible .mk-pal-l { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-xs); }

/* Text */
.mk-fields { display: grid; gap: var(--s-4); }
.mk-field .label { font-size: var(--fs-sm); }
.mk-field.is-group { padding-top: var(--s-4); border-top: 1px solid var(--line); }

/* Photos */
.mk-ptile { display: block; width: 100%; padding: 0; border: 0; font: inherit; cursor: pointer; }
.mk-ptile[aria-pressed='true'] { outline: 3px solid var(--ink); outline-offset: 2px; }
.mk-prow { display: flex; }

/* Ask AI */
.mk-sheet .meta { margin-top: calc(-1 * var(--s-3)); }
/* empty counter row would add 26px above the chips: textarea → chips stays one 16px gap */
.mk-sheet .sheet-body > .meta:has(> .counter[hidden]:only-child) { display: none; }
.mk-suggest .mk-chip { cursor: pointer; font: inherit; font-size: var(--fs-sm); font-weight: 650; }

/* changing: scrim + bar over the preview */
.mk-scrim { position: absolute; inset: 0; background: var(--paper); opacity: 0; }
.mk-scrim.is-on { opacity: 0.6; }
.mk-ebar { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--paper-deep); overflow: hidden; }
.mk-ebar i { display: block; height: 100%; background: var(--sindoor); transform-origin: left; transform: scaleX(0); }

/* toast: above the dock; at the top while a sheet is open */
.mk-toast {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: calc(var(--mk-dock-h, 0px) + var(--s-3)); width: fit-content;
  max-width: calc(100% - 2 * var(--s-4)); margin: 0 auto; padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--ink); color: var(--paper); font-size: var(--fs-sm); font-weight: 650; line-height: 1.4; text-align: center;
  box-shadow: var(--sh-2); opacity: 0; pointer-events: none;
}
.mk-toast.is-in { opacity: 1; }
.mk-sheet .mk-toast { top: calc(var(--s-4) + env(safe-area-inset-top)); bottom: auto; }
@media (min-width: 1024px) { .mk-toast { bottom: var(--s-6); } }

@media (prefers-reduced-motion: no-preference) {
  .mk-tool { transition: transform var(--d-press) var(--ease-out); }
  .mk-tool:active { transform: scale(0.97); }
  .mk-pal .mk-swatch { transition: transform var(--d-press) var(--ease-out); }
  .mk-pal:active .mk-swatch { transform: scale(0.95); }
  .mk-scrim { transition: opacity 200ms ease; }
  .mk-ebar i { transition: transform 2s linear; }
  .mk-ebar.is-done i { transition: transform var(--d-base) var(--ease-out); }
  .mk-toast { transform: translateY(8px); transition: opacity 150ms ease-in, transform 150ms ease-in; }
  .mk-toast.is-in { transform: none; transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out); }
}
