/* Application actions share a neutral palette, including legacy Bootstrap and
   dynamically created dialogs. Authored content and custom blog themes keep
   their own styling. Important colors bridge the legacy theme specificity. */
body:is(.desktop-ui, .app-button-ui) {
  --button-text: #475467;
  --button-surface: #fff;
  --button-border: #d9e0e8;
  --button-hover: #f4f6f8;
  --button-selected: #edf1f5;
  --button-strong-border: #aab6c4;
  --button-danger: #9f3a42;
  --button-danger-border: #e7d9dc;
  --button-danger-hover: #fff4f5;
  --button-focus: rgba(71, 84, 103, .28);
}

body.desktop-ui.modern-note-workspace {
  --button-text: var(--note-muted);
  --button-surface: var(--note-surface);
  --button-border: var(--note-border);
  --button-hover: var(--note-hover);
  --button-selected: var(--note-hover);
}

/* Dialog actions use the shared light palette. */
body.desktop-ui.modern-note-workspace :is(.modal, .aui_outer, .tox-dialog) {
  --button-text: #475467;
  --button-surface: #fff;
  --button-border: #d9e0e8;
  --button-hover: #f4f6f8;
  --button-selected: #edf1f5;
  --button-strong-border: #aab6c4;
  --button-danger: #9f3a42;
  --button-danger-border: #e7d9dc;
  --button-danger-hover: #fff4f5;
  --button-focus: rgba(71, 84, 103, .28);
}

body:is(.desktop-ui, .app-button-ui) :is(
  .btn, .aui_buttons button, .tox .tox-button, .pwa-sheet-primary,
  .pwa-sheet-list button, .primary-link, #editorMaskBtns a,
  .pagination > li > :is(a, span), .pager > li > :is(a, span)
):not(:where(
  #editorContent, #noteReadContent, #wmd-preview, #preview-contents,
  .history-content, .post-content, .post-excerpt, .single-content,
  .comment-content, .vditor-reset, #tplContent
) *) {
  color: var(--button-text) !important;
  border-color: var(--button-border) !important;
  background: var(--button-surface) !important;
  background-image: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
  filter: none !important;
}

body:is(.desktop-ui, .app-button-ui) :is(
  .btn, .aui_buttons button, .tox .tox-button, .pwa-sheet-primary,
  .pwa-sheet-list button, .primary-link, #editorMaskBtns a,
  .pagination > li > :is(a, span), .pager > li > :is(a, span)
):not(:where(
  #editorContent, #noteReadContent, #wmd-preview, #preview-contents,
  .history-content, .post-content, .post-excerpt, .single-content,
  .comment-content, .vditor-reset, #tplContent
) *):is(:hover, :focus-visible) {
  color: var(--button-text) !important;
  border-color: var(--button-strong-border) !important;
  background: var(--button-hover) !important;
}

body:is(.desktop-ui, .app-button-ui) :is(
  .btn, .aui_buttons button, .tox .tox-button, .pwa-sheet-primary,
  .pwa-sheet-list button, .primary-link, #editorMaskBtns a,
  .pagination > li > :is(a, span), .pager > li > :is(a, span)
):not(:where(
  #editorContent, #noteReadContent, #wmd-preview, #preview-contents,
  .history-content, .post-content, .post-excerpt, .single-content,
  .comment-content, .vditor-reset, #tplContent
) *):is(:active, .active, [aria-pressed="true"], .btn-share-or-not.btn-success, .pagination > .active > *) {
  color: var(--button-text) !important;
  border-color: var(--button-strong-border) !important;
  background: var(--button-selected) !important;
}

body:is(.desktop-ui, .app-button-ui) :is(
  .btn, .aui_buttons button, .tox .tox-button, .pwa-sheet-primary,
  .pwa-sheet-list button, .primary-link, #editorMaskBtns a,
  .pagination > li > :is(a, span), .pager > li > :is(a, span)
):not(:where(
  #editorContent, #noteReadContent, #wmd-preview, #preview-contents,
  .history-content, .post-content, .post-excerpt, .single-content,
  .comment-content, .vditor-reset, #tplContent
) *):is(.btn-primary, .btn-success, .aui_state_highlight) {
  font-weight: 600;
}

body:is(.desktop-ui, .app-button-ui) :is(
  .btn, .aui_buttons button, .tox .tox-button, .pwa-sheet-primary,
  .pwa-sheet-list button, .primary-link, #editorMaskBtns a,
  .pagination > li > :is(a, span), .pager > li > :is(a, span)
):not(:where(
  #editorContent, #noteReadContent, #wmd-preview, #preview-contents,
  .history-content, .post-content, .post-excerpt, .single-content,
  .comment-content, .vditor-reset, #tplContent
) *):is(.btn-danger, .btn-delete, .delete-share, .delete-image, [onclick^="deleteShare"]) {
  color: var(--button-danger) !important;
  border-color: var(--button-danger-border) !important;
}

body:is(.desktop-ui, .app-button-ui) :is(
  .btn, .aui_buttons button, .tox .tox-button, .pwa-sheet-primary,
  .pwa-sheet-list button, .primary-link, #editorMaskBtns a,
  .pagination > li > :is(a, span), .pager > li > :is(a, span)
):not(:where(
  #editorContent, #noteReadContent, #wmd-preview, #preview-contents,
  .history-content, .post-content, .post-excerpt, .single-content,
  .comment-content, .vditor-reset, #tplContent
) *):is(.btn-danger, .btn-delete, .delete-share, .delete-image, [onclick^="deleteShare"]):is(:hover, :focus-visible, :active) {
  color: var(--button-danger) !important;
  border-color: var(--button-danger-border) !important;
  background: var(--button-danger-hover) !important;
}

body:is(.desktop-ui, .app-button-ui) :is(
  .btn, .aui_buttons button, .tox .tox-button, .pwa-sheet-primary,
  .pwa-sheet-list button, .primary-link, #editorMaskBtns a,
  .pagination > li > :is(a, span), .pager > li > :is(a, span)
):not(:where(
  #editorContent, #noteReadContent, #wmd-preview, #preview-contents,
  .history-content, .post-content, .post-excerpt, .single-content,
  .comment-content, .vditor-reset, #tplContent
) *):is(.btn-link, .tox-button--icon) {
  border-color: transparent !important;
  background: transparent !important;
}

body:is(.desktop-ui, .app-button-ui) :is(
  .btn, .aui_buttons button, .tox .tox-button, .pwa-sheet-primary,
  .pwa-sheet-list button, .primary-link, #editorMaskBtns a,
  .pagination > li > :is(a, span), .pager > li > :is(a, span)
):not(:where(
  #editorContent, #noteReadContent, #wmd-preview, #preview-contents,
  .history-content, .post-content, .post-excerpt, .single-content,
  .comment-content, .vditor-reset, #tplContent
) *):focus:not(:focus-visible) {
  outline: none !important;
}

body:is(.desktop-ui, .app-button-ui) :is(
  .btn, .aui_buttons button, .tox .tox-button, .pwa-sheet-primary,
  .pwa-sheet-list button, .primary-link, #editorMaskBtns a,
  .pagination > li > :is(a, span), .pager > li > :is(a, span)
):not(:where(
  #editorContent, #noteReadContent, #wmd-preview, #preview-contents,
  .history-content, .post-content, .post-excerpt, .single-content,
  .comment-content, .vditor-reset, #tplContent
) *):focus-visible {
  outline: 2px solid var(--button-focus) !important;
  outline-offset: 2px;
}

body:is(.desktop-ui, .app-button-ui) :is(
  .btn, .aui_buttons button, .tox .tox-button, .pwa-sheet-primary,
  .pwa-sheet-list button, .primary-link, #editorMaskBtns a,
  .pagination > li > :is(a, span), .pager > li > :is(a, span)
):not(:where(
  #editorContent, #noteReadContent, #wmd-preview, #preview-contents,
  .history-content, .post-content, .post-excerpt, .single-content,
  .comment-content, .vditor-reset, #tplContent
) *):is(:disabled, .disabled, [aria-disabled="true"]) {
  color: var(--button-text) !important;
  border-color: var(--button-border) !important;
  background: var(--button-surface) !important;
  opacity: .55;
  cursor: not-allowed;
}

/* These sheet actions previously depended on a filled background for shape. */
body.desktop-ui :is(.pwa-sheet-primary, .pwa-sheet-list button) {
  border: 1px solid var(--button-border);
}

body.desktop-ui.modern-note-workspace #noteItemList .item-blog {
  color: var(--button-text);
  border-color: transparent;
  background: transparent;
}

body.desktop-ui.modern-note-workspace #noteItemList .item-blog .fa {
  color: inherit !important;
}

body.desktop-ui.modern-note-workspace #noteItemList .item-blog:is(:hover, :focus-visible) {
  background: var(--button-hover);
}

/* Close controls stay transparent, including their hover and pressed states. */
body.desktop-ui .modal button.close {
  color: var(--button-text);
  border: 0;
  background: transparent;
  box-shadow: none;
  text-shadow: none;
  opacity: 1;
}

body.desktop-ui .modal button.close:is(:hover, :focus-visible, :active) {
  color: var(--ui-text, #17212b);
  background: transparent;
  box-shadow: none;
}

body.desktop-ui .modal button.close:focus:not(:focus-visible) {
  outline: none;
}

body.desktop-ui .modal button.close:focus-visible {
  outline: 2px solid var(--button-focus);
  outline-offset: 2px;
}

body.desktop-ui .history-modal .history-content-header {
  position: relative;
  padding-right: 56px;
}

/* Override the legacy history padding that displaced the glyph outside its box. */
body.desktop-ui .history-modal .modal-dialog .modal-content .modal-body .history-content-wrap button.close {
  position: absolute;
  top: 7px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  float: none;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  line-height: 1;
}
