/* One proportional close mark, scoped to actual close/dismiss controls only.
   Center the ink without changing native button display, position or behavior. */
:root :is(
  #nja-casework-cleanup-close,
  .nja-view-recent-heading button[aria-label="Close history"],
  #nja-presentation-close, #nja-book-vote-close, .nja-ops-close,
  .nja-casework-window-actions button[aria-label^="Close casework"],
  .nja-community-letter-dialog .nja-letter-bar button[aria-label^="Close"],
  .nja-community-book-close, .transition-close,
  .nja-status-link-close, .nja-welcome-close, .nja-status-dialog-close,
  .nja-history-dialog header button[aria-label="Close status history"],
  .recognition-lightbox-close, .nj-award-card-close,
  .hero-veterans-dialog > button[aria-label="Close award recognition"],
  #nja-blwb-wallet .blwb-close,
  .press-preview-palette button[aria-label="Close preview"],
  .nja-share-panel [data-close],
  button#close, button#reader-close, button#letter-close, button#close-pack,
  button#press-close,
  .nja-pr-chrome-button[aria-label="Hide and deactivate the Pop Round bookshelf"],
  .nja-pr-edge-hide, .nja-sharing-dock [data-off],
  .nja-office-status-controls button[title="Hide status"]
) {
  --office-close-mark: 20px;
  box-sizing: border-box;
  min-width: 36px;
  min-height: 36px;
  padding: 0 !important;
  font: var(--office-close-fallback, 26px)/1 Arial, sans-serif !important;
  text-align: center;
  align-content: center;
  flex-shrink: 0;
  opacity: 1 !important;
  cursor: pointer;
}

/* Tight chrome keeps its existing bar height and adjacent controls intact. */
:root :is(
  .nja-view-recent-heading button[aria-label="Close history"],
  #nja-presentation-close,
  .nja-casework-window-actions button[aria-label^="Close casework"],
  #nja-blwb-wallet .blwb-close,
  .press-preview-palette button[aria-label="Close preview"],
  .nja-sharing-dock [data-off],
  .nja-office-status-controls button[title="Hide status"]
) { --office-close-mark: 16px; --office-close-fallback: 22px; min-width: 28px; min-height: 28px; }

/* Align the small dock's mixed-size controls around one shared centerline. */
:root .nja-sharing-dock button { vertical-align: middle; }

:root :is(
  #nja-pop-round-floater .nja-pr-chrome-button[aria-label="Hide and deactivate the Pop Round bookshelf"],
  .nja-pr-edge-hide
) { --office-close-mark: 12px; --office-close-fallback: 18px; width: 24px; height: 24px; min-width: 24px; min-height: 24px; }

:root #nja-casework-cleanup-close {
  --office-close-mark: 20px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

/* Keep the word on Close/Retract buttons; center only its companion mark. */
.office-close-symbol {
  --office-close-mark: 16px;
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-inline-start: 3px;
  vertical-align: middle;
  font: 22px/20px Arial, sans-serif;
  align-content: center;
  pointer-events: none;
}

@supports (mask-image: url("/assets/office-close.svg")) or (-webkit-mask-image: url("/assets/office-close.svg")) {
  :root :is(
    #nja-casework-cleanup-close,
    .nja-view-recent-heading button[aria-label="Close history"],
    #nja-presentation-close, #nja-book-vote-close, .nja-ops-close,
    .nja-casework-window-actions button[aria-label^="Close casework"],
    .nja-community-letter-dialog .nja-letter-bar button[aria-label^="Close"],
    .nja-community-book-close, .transition-close,
    .nja-status-link-close, .nja-welcome-close, .nja-status-dialog-close,
    .nja-history-dialog header button[aria-label="Close status history"],
    .recognition-lightbox-close, .nj-award-card-close,
    .hero-veterans-dialog > button[aria-label="Close award recognition"],
    #nja-blwb-wallet .blwb-close,
    .press-preview-palette button[aria-label="Close preview"],
    .nja-share-panel [data-close],
    button#close, button#reader-close, button#letter-close, button#close-pack,
    button#press-close,
    .nja-pr-chrome-button[aria-label="Hide and deactivate the Pop Round bookshelf"],
    .nja-pr-edge-hide, .nja-sharing-dock [data-off],
    .nja-office-status-controls button[title="Hide status"]
  ) { font-size: 0 !important; line-height: 0 !important; }

  :root :is(
    #nja-casework-cleanup-close,
    .nja-view-recent-heading button[aria-label="Close history"],
    #nja-presentation-close, #nja-book-vote-close, .nja-ops-close,
    .nja-casework-window-actions button[aria-label^="Close casework"],
    .nja-community-letter-dialog .nja-letter-bar button[aria-label^="Close"],
    .nja-community-book-close, .transition-close,
    .nja-status-link-close, .nja-welcome-close, .nja-status-dialog-close,
    .nja-history-dialog header button[aria-label="Close status history"],
    .recognition-lightbox-close, .nj-award-card-close,
    .hero-veterans-dialog > button[aria-label="Close award recognition"],
    #nja-blwb-wallet .blwb-close,
    .press-preview-palette button[aria-label="Close preview"],
    .nja-share-panel [data-close],
    button#close, button#reader-close, button#letter-close, button#close-pack,
    button#press-close,
    .nja-pr-chrome-button[aria-label="Hide and deactivate the Pop Round bookshelf"],
    .nja-pr-edge-hide, .nja-sharing-dock [data-off],
    .nja-office-status-controls button[title="Hide status"]
  )::before,
  .office-close-symbol::before {
    content: "";
    display: block;
    width: var(--office-close-mark, 20px);
    height: var(--office-close-mark, 20px);
    margin: auto;
    vertical-align: middle;
    background-color: currentColor;
    -webkit-mask: url("/assets/office-close.svg") center / contain no-repeat;
    mask: url("/assets/office-close.svg") center / contain no-repeat;
    pointer-events: none;
  }
  .office-close-symbol { font-size: 0; line-height: 0; }
}

/* Keep the close slot in the navy ribbon, outside the body's scrollbar.
   The dialog's width/height cap, content, native close and backdrop stay intact. */
#nja-book-vote-dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
#nja-book-vote-dialog .nja-book-vote-ribbon { flex: 0 0 auto; }
#nja-book-vote-dialog .nja-book-vote-body { min-height: 0; overflow-y: auto; }
#nja-book-vote-dialog #nja-book-vote-close {
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
}

/* Share and Close form adjacent equal-height header slots; Close stays last. */
#reader .reader-head #reader-publisher { flex: 1; min-width: 0; }
#reader .reader-head .nja-share-icon { order: 1; margin-inline-start: auto; align-self: flex-start; }
#reader .reader-head #reader-close { order: 2; margin-inline-start: 0; align-self: flex-start; }

/* Account for the recognition panel's 6px gold top border: 10px each edge. */
:root .recognition-lightbox .recognition-lightbox-close { top: 4px; }

/* Sorting may wrap on a phone; reserve a first-row corner for Close. */
@media (max-width: 560px) {
  :root .nja-status-dialog-header { position: relative; padding-inline-end: 70px; }
  :root .nja-status-dialog-header .nja-status-dialog-close { position: absolute; top: 13px; right: 18px; }
}
