/* TinyMCE content isolation.
   Keep this linked after the Discourse theme CSS. The selectors also cover the
   old .content-html container so legacy rich text cannot inherit Discourse prose
   styles while pages are being migrated to TinyMceContentView. */

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) {
  all: revert;
  box-sizing: border-box;
  display: flow-root;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 1rem;
  color: CanvasText;
  background: transparent;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  overflow-x: auto;
  overflow-y: visible;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(*) {
  all: revert;
  max-width: none;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(a) {
  color: revert;
  text-decoration: revert;
  cursor: pointer;
  background-color: transparent;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(a:visited, a:hover, a:active) {
  color: revert;
  text-decoration: revert;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(ul, ol) {
  margin: 1em 0;
  padding-inline-start: 1.75em;
  list-style-position: outside;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(dd) {
  margin: 1em 0 1em 1.75em;
  padding: 0;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(ul) {
  list-style-type: disc;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(ol) {
  list-style-type: decimal;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(li) {
  display: list-item;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(li > ul, li > ol) {
  margin: 0;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(table) {
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: auto;
  max-width: 100%;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(thead, tbody, tfoot) {
  border: 0;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(tr) {
  border: 0;
  background: transparent;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(td, th) {
  border: revert;
  color: inherit;
  background: transparent;
  padding: 0;
  text-align: revert;
  vertical-align: revert;
}

/* Apply TinyMCE's default padding when legacy cellpadding is missing. */
#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(table:not([cellpadding]) th, table:not([cellpadding]) td) {
  padding: 0.4rem;
}

/* Apply TinyMCE's fallback cell border only when the HTML asks for a border. */
#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(table[border]:not([border="0"]):not([style*="border-width"]) th, table[border]:not([border="0"]):not([style*="border-width"]) td) {
  border-width: 1px;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(table[border]:not([border="0"]):not([style*="border-style"]) th, table[border]:not([border="0"]):not([style*="border-style"]) td) {
  border-style: solid;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(table[border]:not([border="0"]):not([style*="border-color"]) th, table[border]:not([border="0"]):not([style*="border-color"]) td) {
  border-color: #ccc;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(pre, code, kbd, samp) {
  font-family: monospace;
  font-size: 1em;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(code) {
  color: inherit;
  background-color: #e8e8e8;
  border: 0;
  border-radius: 3px;
  padding: 0.1rem 0.2rem;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(pre) {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(pre code) {
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html):not([dir='rtl']) :where(blockquote) {
  border: 0;
  border-left: 2px solid #ccc;
  margin-left: 1.5rem;
  padding-left: 1rem;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html)[dir='rtl'] :where(blockquote) {
  border: 0;
  border-right: 2px solid #ccc;
  margin-right: 1.5rem;
  padding-right: 1rem;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(hr) {
  border-color: #ccc;
  border-style: solid;
  border-width: 1px 0 0;
  box-sizing: content-box;
  height: 0;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(figure) {
  display: table;
  margin: 1rem auto;
  max-width: 100%;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(figure figcaption) {
  color: #999;
  display: block;
  margin-top: 0.25rem;
  text-align: center;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(figure.align-left) {
  float: left;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(figure.align-right) {
  float: right;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(figure.image.align-center) {
  display: table;
  margin-left: auto;
  margin-right: auto;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(img) {
  max-width: 100%;
  height: auto;
  border-style: none;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(.lightbox-wrapper, .lightbox) {
  max-width: 100%;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(.mce-pagebreak) {
  border: 1px dashed #aaa;
  cursor: default;
  display: block;
  height: 5px;
  margin-top: 15px;
  page-break-before: always;
  width: 100%;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(.mce-preview-object) {
  border: 1px solid gray;
  display: inline-block;
  line-height: 0;
  margin: 0 2px;
  position: relative;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(.mce-preview-object .mce-shim) {
  background: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(.mce-preview-object[data-mce-selected='2'] .mce-shim) {
  display: none;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(.mce-object) {
  background: transparent url("data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%3E%3Cpath%20d%3D%22M4%203h16a1%201%200%200%201%201%201v16a1%201%200%200%201-1%201H4a1%201%200%200%201-1-1V4a1%201%200%200%201%201-1zm1%202v14h14V5H5zm4.79%202.565l5.64%204.028a.5.5%200%200%201%200%20.814l-5.64%204.028a.5.5%200%200%201-.79-.407V7.972a.5.5%200%200%201%20.79-.407z%22%2F%3E%3C%2Fsvg%3E%0A") no-repeat center;
  border: 1px dashed #aaa;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(tiny-math-block) {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

#main-outlet :is(.tinymce-content-view.mce-content-body, .content-html) :where(tiny-math-inline) {
  display: inline-block;
}
