/* Editorial tools appear only after an administrator chooses Edit, from the
   account menu or a work's context menu; the archive header never changes. */
.gallery-editor[hidden], .gallery-edit-entry[hidden], .gallery-editor [hidden] { display: none; }
.gallery-editor {
  margin: 0;
  padding: 0 var(--page-gutter) calc(var(--lh) * 5);
  scroll-margin-top: calc(var(--chrome-h) + var(--lh));
}
.gallery-edit-bar {
  position: sticky;
  top: var(--chrome-h);
  z-index: calc(var(--z-chrome) - 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--gutter);
  padding: var(--gutter) 0;
  margin-bottom: var(--gutter);
  background: var(--surface-page);
}
.gallery-edit-selection, .gallery-edit-finish, .gallery-dialog-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--bl);
}
.gallery-editor button, .gallery-edit-dialog button {
  font: inherit;
  font-size: var(--type-control-size);
  line-height: var(--type-control-line);
  font-weight: 400;
  color: var(--text-secondary);
  border: 0;
  background: transparent;
  padding: var(--bl);
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gallery-editor button:hover, .gallery-edit-dialog button:hover { color: var(--text-primary); }
.gallery-editor button:focus-visible, .gallery-edit-dialog button:focus-visible {
  outline: var(--focus-ring-strong);
  outline-offset: var(--focus-offset);
}
.gallery-editor button:disabled { color: var(--text-disabled); cursor: default; }
.gallery-editor .gallery-edit-save, .gallery-edit-dialog [data-edit-action="confirm"] {
  color: var(--text-inverse);
  background: var(--ink);
  border-radius: 999px;
  padding-inline: calc(var(--bl) * 2);
  min-width: 88px;
}
.gallery-editor .gallery-edit-save:disabled { opacity: .4; }
/* the ink pills keep inverse text on hover (the generic button hover
   would otherwise paint ink on ink) */
.gallery-editor .gallery-edit-save:hover,
.gallery-edit-dialog [data-edit-action="confirm"]:hover { color: var(--text-inverse); }
.gallery-edit-count {
  color: var(--text-secondary);
  font-size: var(--type-control-size);
  line-height: var(--type-control-line);
  min-width: 72px;
}
.gallery-edit-error, .gallery-edit-empty {
  color: var(--text-secondary);
  font-size: var(--type-control-size);
  line-height: var(--type-control-line);
  margin: 0 0 var(--lh);
}
.gallery-edit-error { color: var(--text-primary); }
.gallery-edit-bar .gallery-edit-error { flex-basis: 100%; order: 3; margin: 0; }
.gallery-edit-grid { row-gap: calc(var(--lh) * 1.5); }
.gallery-editor .gallery-edit-card {
  position: relative;
  display: grid;
  width: 100%;
  padding: 0;
  text-align: left;
  align-self: start;
  min-width: 0;
  cursor: grab;
  touch-action: pan-y;
  scroll-margin-block: calc(var(--chrome-h) + var(--lh) * 5) var(--lh);
  user-select: none;
  transition: opacity var(--duration-ui) ease;
}
.gallery-edit-card img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  background: var(--surface-page);
}
.gallery-edit-name {
  display: block;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-top: var(--bl);
}
.gallery-edit-mark {
  position: absolute;
  top: var(--bl);
  right: var(--bl);
  width: 28px;
  height: 28px;
  border: 1px solid var(--text-muted);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-page);
  color: transparent;
}
.gallery-edit-card[aria-pressed="true"] .gallery-edit-mark { color: var(--text-inverse); background: var(--ink); border-color: var(--ink); }
.gallery-edit-card[aria-pressed="true"] img { outline: 2px solid var(--ink); outline-offset: -2px; }
.gallery-edit-card.is-dragging { opacity: .35; }
.gallery-edit-card[data-drop]::after {
  content: '';
  position: absolute;
  inset-block: 0;
  width: 2px;
  background: var(--ink);
}
.gallery-edit-card[data-drop="before"]::after { left: calc(var(--gutter) / -2); }
.gallery-edit-card[data-drop="after"]::after { right: calc(var(--gutter) / -2); }
.is-gallery-editing .work-modes, .is-gallery-editing .work-search { display: none; }
.is-gallery-editing .other-hero { display: none; }
.is-gallery-editing #collections { margin-top: calc(var(--chrome-h) + var(--lh)); }
.is-gallery-editing .works-title { max-width: 100%; }
.is-gallery-editing .works-title > span { display: none; }
.gallery-edit-dialog {
  width: min(440px, calc(100vw - 48px));
  box-sizing: border-box;
  padding: calc(var(--lh) * 1.5);
  border: var(--border-popout-shell);
  box-shadow: var(--shadow-popout);
  --corner: var(--popout-radius);
  /* the seam-proof fill under the paint (styles.css) */
  border-radius: calc(var(--corner) * var(--squircle-fill));
  background: var(--popout-fill) padding-box;
  border-image: var(--squircle-shell-28);
  color: var(--text-primary);
}
/* focus lives on the dialog's buttons; the box itself never wears a ring
   that would round differently from its corners */
.gallery-edit-dialog:focus { outline: none; }
.gallery-edit-dialog::backdrop { background: var(--overlay-scrim); }
.gallery-edit-dialog h2 { font: inherit; font-size: var(--type-title-size); line-height: var(--type-title-line); font-weight: 500; margin: 0 0 var(--gutter); }
.gallery-edit-dialog p { font-size: var(--type-control-size); line-height: var(--type-control-line); color: var(--text-secondary); margin: 0 0 var(--lh); }
.gallery-dialog-actions { justify-content: flex-end; }
/* An explicitly ordered wall keeps the saved sequence in its DOM (keyboard
   and screen-reader order). Without script it reads as a row-major grid;
   app.js then packs it like the feed (.is-packed, styles.css). */
.masonry.is-ordered:not(.is-packed) { row-gap: calc(var(--lh) * 1.5); }
@media (max-width: 1120px) {
  .other-demo:is(.is-collection-view, .is-gallery-editing) .gesso-filter-tabs {
    height: auto;
    row-gap: var(--gutter);
  }
  .other-demo:is(.is-collection-view, .is-gallery-editing) .gesso-filter-tabs > .works-title {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .other-demo:is(.is-collection-view) .work-modes { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 640px) {
  .gallery-edit-bar { gap: 0; padding-block: var(--bl); }
  .gallery-edit-selection { order: 2; width: 100%; gap: 0; }
  .gallery-edit-finish { width: 100%; justify-content: flex-end; }
  .gallery-edit-count { min-width: 0; margin-right: auto; }
  .gallery-edit-grid { --masonry-cols: 2; }
  .gallery-edit-dialog { padding: var(--lh); }
}
@media (prefers-reduced-motion: reduce) {
  .gallery-editor *, .gallery-edit-dialog * { transition: none !important; animation: none !important; }
}
