/* .rich-text-content h1 {
  display: block;
  font-size: 2em;
  margin-block-start: 0.67em;
  margin-block-end: 0.67em;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
  font-weight: bold;
  unicode-bidi: isolate;
}

.rich-text-content li {
  display: list-item;
  unicode-bidi: isolate;
} */

.rich-text-content {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  line-height: 1.4;
  margin: 1rem;
  word-wrap: break-word;

  p {
    display: block;
    margin-block-start: 1em;
    margin-block-end: 1em;
    margin-inline-start: 0;
    margin-inline-end: 0;
  }

  div {
    display: block;
  }

  article,
  aside,
  footer,
  header,
  hgroup,
  main,
  nav,
  search,
  section {
    display: block;
  }

  marquee {
    display: inline-block;
    width: -webkit-fill-available;
  }

  address {
    display: block;
  }

  blockquote {
    display: block;
    margin-block-start: 1em;
    margin-block-end: 1em;
    margin-inline-start: 40px;
    margin-inline-end: 40px;
  }

  figcaption {
    display: block;
  }

  figure {
    display: block;
    margin-block-start: 1em;
    margin-block-end: 1em;
    margin-inline-start: 40px;
    margin-inline-end: 40px;
  }

  q {
    display: inline;
  }

  q:before {
    content: open-quote;
  }

  q:after {
    content: close-quote;
  }

  center {
    display: block;
    /* special centering to be able to emulate the html4/netscape behaviour */
    text-align: -webkit-center;
  }

  hr {
    display: block;
    overflow: hidden;
    margin-block-start: 0.5em;
    margin-block-end: 0.5em;
    margin-inline-start: auto;
    margin-inline-end: auto;
    border-style: inset;
    border-width: 1px;
    color: gray;
  }

  map {
    display: inline;
  }

  video {
    object-fit: contain;
  }

  video:-webkit-full-page-media {
    margin: auto;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    max-height: 100%;
    max-width: 100%;
  }

  audio:not([controls]) {
    display: none !important;
  }

  /** TODO(crbug.com/985623): Remove these hard-coded audio tag size.
 * This fixed audio tag width/height leads to fail the wpt tests below.
 * crbug.com/955170 external/wpt/css/css-contain/contain-size-replaced-003a.html
 * crbug.com/955163 external/wpt/css/css-contain/contain-size-replaced-003b.html
 * crbug.com/955163 external/wpt/css/css-contain/contain-size-replaced-003c.html
 */
  audio {
    width: 300px;
    height: 54px;
  }

  video,
  canvas,
  img {
    overflow: clip;
    overflow-clip-margin: content-box;
  }

  iframe,
  embed,
  object,
  fencedframe {
    overflow: clip !important;
    overflow-clip-margin: content-box !important;
  }

  /* heading elements */

  h1 {
    display: block;
    font-size: 2em;
    margin-block-start: 0.67em;
    margin-block-end: 0.67em;
    margin-inline-start: 0;
    margin-inline-end: 0;
    font-weight: bold;
  }

  @supports blink-feature(SpecialRulesForNestedH1Elements) {
    :-webkit-any(article, aside, nav, section) h1 {
      font-size: 1.5em;
      margin-block-start: 0.83em;
      margin-block-end: 0.83em;
    }

    :-webkit-any(article, aside, nav, section)
      :-webkit-any(article, aside, nav, section)
      h1 {
      font-size: 1.17em;
      margin-block-start: 1em;
      margin-block-end: 1em;
    }

    :-webkit-any(article, aside, nav, section)
      :-webkit-any(article, aside, nav, section)
      :-webkit-any(article, aside, nav, section)
      h1 {
      font-size: 1em;
      margin-block-start: 1.33em;
      margin-block-end: 1.33em;
    }

    :-webkit-any(article, aside, nav, section)
      :-webkit-any(article, aside, nav, section)
      :-webkit-any(article, aside, nav, section)
      :-webkit-any(article, aside, nav, section)
      h1 {
      font-size: 0.83em;
      margin-block-start: 1.67em;
      margin-block-end: 1.67em;
    }

    :-webkit-any(article, aside, nav, section)
      :-webkit-any(article, aside, nav, section)
      :-webkit-any(article, aside, nav, section)
      :-webkit-any(article, aside, nav, section)
      :-webkit-any(article, aside, nav, section)
      h1 {
      font-size: 0.67em;
      margin-block-start: 2.33em;
      margin-block-end: 2.33em;
    }
  }

  h2 {
    display: block;
    font-size: 1.5em;
    margin-block-start: 0.83em;
    margin-block-end: 0.83em;
    margin-inline-start: 0;
    margin-inline-end: 0;
    font-weight: bold;
  }

  h3 {
    display: block;
    font-size: 1.17em;
    margin-block-start: 1em;
    margin-block-end: 1em;
    margin-inline-start: 0;
    margin-inline-end: 0;
    font-weight: bold;
  }

  h4 {
    display: block;
    margin-block-start: 1.33em;
    margin-block-end: 1.33em;
    margin-inline-start: 0;
    margin-inline-end: 0;
    font-weight: bold;
  }

  h5 {
    display: block;
    font-size: 0.83em;
    margin-block-start: 1.67em;
    margin-block-end: 1.67em;
    margin-inline-start: 0;
    margin-inline-end: 0;
    font-weight: bold;
  }

  h6 {
    display: block;
    font-size: 0.67em;
    margin-block-start: 2.33em;
    margin-block-end: 2.33em;
    margin-inline-start: 0;
    margin-inline-end: 0;
    font-weight: bold;
  }

  /* tables */

  table {
    display: block;
    border-collapse: separate;
    border-spacing: 2px;
    border-color: gray;
    box-sizing: border-box;
    text-indent: initial;
    width: 100%;
    border-collapse: collapse;
    overflow-x: auto;
    white-space: wrap;
  }

  thead {
    display: table-header-group;
    vertical-align: middle;
    border-color: inherit;
  }

  tbody {
    display: table-row-group;
    vertical-align: middle;
    border-color: inherit;
  }

  tfoot {
    display: table-footer-group;
    vertical-align: middle;
    border-color: inherit;
  }

  /* for tables without table section elements (can happen with XHTML or dynamically created tables) */
  table > tr {
    vertical-align: middle;
  }

  col {
    display: table-column;
  }

  colgroup {
    display: table-column-group;
  }

  tr {
    display: table-row;
    vertical-align: inherit;
    border-color: inherit;
  }

  td,
  th {
    display: table-cell;
    vertical-align: inherit;
  }

  /* When the td/th are inside a table (the normal case), the padding is taken
   care of by HTMLTableCellElement::AdditionalPresentationAttributeStyle(). */
  td:not(table td),
  th:not(table th) {
    padding: 1px;
  }

  th {
    font-weight: bold;
    text-align: -internal-center;
  }

  caption {
    display: table-caption;
    text-align: -webkit-center;
  }

  /* lists */

  ul,
  menu,
  dir {
    display: block;
    list-style-type: disc;
    margin-block-start: 1em;
    margin-block-end: 1em;
    padding-inline-start: 40px;
  }

  ol {
    display: block;
    list-style-type: decimal;
    margin-block-start: 1em;
    margin-block-end: 1em;
    padding-inline-start: 40px;
  }

  li {
    display: list-item;
    text-align: match-parent;
  }

  :is(dir, dl, menu, ol, ul) dir,
  :is(dir, dl, menu, ol, ul) dl,
  :is(dir, dl, menu, ol, ul) menu,
  :is(dir, dl, menu, ol, ul) ol,
  :is(dir, dl, menu, ol, ul) ul {
    margin-block-start: 0;
    margin-block-end: 0;
  }

  :is(dir, menu, ol, ul) dir,
  :is(dir, menu, ol, ul) menu,
  :is(dir, menu, ol, ul) ul {
    list-style-type: circle;
  }

  :is(dir, menu, ol, ul) :is(dir, menu, ol, ul) dir,
  :is(dir, menu, ol, ul) :is(dir, menu, ol, ul) menu,
  :is(dir, menu, ol, ul) :is(dir, menu, ol, ul) ul {
    list-style-type: square;
  }

  /* TODO(crbug.com/40774317, crbug.com/354025385): We should add rule
   ol, ul, menu { counter-reset: list-item; }
   once it is supported. */

  dd {
    display: block;
    margin-inline-start: 40px;
  }

  dl {
    display: block;
    margin-block-start: 1em;
    margin-block-end: 1em;
  }

  dt {
    display: block;
  }

  /* form elements */

  form {
    display: block;
    margin-top: 0em;
  }

  :-webkit-any(table, thead, tbody, tfoot, tr) > form:-internal-is-html {
    display: none !important;
  }

  label {
    cursor: default;
  }

  fieldset {
    display: block;
    margin-inline: 2px;
    border: groove 2px ThreeDFace;
    padding-block: 0.35em 0.625em;
    padding-inline: 0.75em;
    min-inline-size: min-content;
  }

  legend {
    display: block;
    padding-inline: 2px;
  }

  legend[align="left" i] {
    justify-self: left;
  }

  legend[align="center" i] {
    justify-self: center;
  }

  legend[align="right" i] {
    justify-self: right;
  }

  optgroup {
    font-weight: bolder;
    display: block;
  }

  optgroup::-internal-optgroup-label {
    padding: 0 2px 1px 2px;
    min-height: 1.2em;
  }

  /* inline elements */

  u,
  ins {
    text-decoration: underline;
  }

  abbr[title],
  acronym[title] {
    text-decoration: dotted underline;
  }

  strong,
  b {
    font-weight: bolder;
  }

  i,
  cite,
  em,
  var,
  address,
  dfn {
    font-style: italic;
  }

  tt,
  code,
  kbd,
  samp {
    font-family: monospace;
  }

  pre,
  xmp,
  plaintext,
  listing {
    display: block;
    font-family: monospace;
    white-space: pre;
    margin-block: 1em;
    margin-inline: 0;
  }

  mark {
    background-color: Mark;
    color: MarkText;
  }

  big {
    font-size: larger;
  }

  small {
    font-size: smaller;
  }

  s,
  strike,
  del {
    text-decoration: line-through;
  }

  sub {
    vertical-align: sub;
    font-size: smaller;
  }

  sup {
    vertical-align: super;
    font-size: smaller;
  }

  nobr {
    white-space: nowrap;
  }

  a:-webkit-any-link {
    color: -webkit-link;
    text-decoration: underline;
    cursor: pointer;
  }

  a:-webkit-any-link:active {
    color: -webkit-activelink;
  }

  a:-webkit-any-link:read-write {
    cursor: text;
  }

  a:-webkit-any-link:focus-visible {
    outline-offset: 1px;
  }

  /* HTML5 ruby elements */

  ruby,
  rt {
    text-indent: 0; /* blocks used for ruby rendering should not trigger this */
  }

  ruby {
    display: ruby;
  }

  rt {
    line-height: normal;
    text-emphasis: none;
  }

  ruby > rt {
    display: ruby-text;
    font-size: 50%;
    text-align: start;
  }

  /* other elements */

  frameset,
  frame {
    display: block;
  }

  frameset {
    border-color: inherit;
  }

  iframe {
    border: 2px inset;
  }

  fencedframe {
    border: 2px inset;
    object-fit: contain !important;
    object-position: 50% 50% !important;
  }

  details {
    display: block;
  }

  summary {
    display: block;
  }

  /*
 * https://html.spec.whatwg.org/C/#the-details-and-summary-elements
 * The specification doesn't have |details >| and |:first-of-type|.
 * We add them because:
 *   - We had provided |summary { display: block }| for a long time,
 *     there are sites using <summary> without details, and they
 *     expect that <summary> is not a list-item.
 *   - Firefox does so.
 */
  details > summary:first-of-type {
    display: list-item;
    counter-increment: list-item 0;
    list-style: disclosure-closed inside;
  }

  details[open] > summary:first-of-type {
    list-style-type: disclosure-open;
  }

  /* https://html.spec.whatwg.org/multipage/rendering.html#bidi-rendering */
  /* This chunk of styles interacts with the `name == html_names::kDirAttr` case
   in HTMLElement::CollectStyleForPresentationAttribute(). Make sure any changes
   here are congruent with changes made there. */
  address,
  blockquote,
  center,
  div,
  figure,
  figcaption,
  footer,
  form,
  header,
  hr,
  legend,
  listing,
  main,
  p,
  plaintext,
  pre,
  summary,
  xmp,
  article,
  aside,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  hgroup,
  nav,
  section,
  search,
  table,
  caption,
  colgroup,
  col,
  thead,
  tbody,
  tfoot,
  tr,
  td,
  th,
  dir,
  dd,
  dl,
  dt,
  menu,
  ol,
  ul,
  li,
  bdi,
  output,
  [dir="ltr" i],
  [dir="rtl" i],
  [dir="auto" i] {
    unicode-bidi: isolate;
  }
  bdo,
  bdo[dir] {
    unicode-bidi: isolate-override;
  }
  textarea[dir="auto" i],
  pre[dir="auto" i] {
    unicode-bidi: plaintext;
  }

  dialog {
    /* https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3 */
    position: absolute;
    inset-inline-start: 0;
    inset-inline-end: 0;
    width: fit-content;
    height: fit-content;
    margin: auto;
    border: solid;
    padding: 1em;
    background-color: Canvas;
    color: CanvasText;
  }

  /* Note that these can't use `dialog:modal` because a dialog stops matching
   :modal as soon as dialog.close() is called, but it needs to retain its
   styling until it's removed from the top layer, which can happen later due
   to animations of the `overlay` property. */
  dialog:-internal-dialog-in-top-layer {
    /* https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3 */
    position: fixed;
    overflow: auto;
    inset-block-start: 0;
    inset-block-end: 0;
    max-width: calc(100% - 6px - 2em);
    max-height: calc(100% - 6px - 2em);
    /* https://github.com/w3c/csswg-drafts/issues/6939#issuecomment-1016679588 */
    user-select: text;
    visibility: visible;
  }

  [popover] {
    position: fixed;
    position-anchor: auto;
    inset: 0;
    width: fit-content;
    height: fit-content;
    margin: auto;
    border: solid;
    padding: 0.25em;
    overflow: auto;
    color: CanvasText;
    background-color: Canvas;
  }

  /* dialog and popover handling of `display`. We need to be careful to get the
   `<dialog popover>` case working correctly, when open as a dialog.
   The `:where()` is added to lower the specificity so it doesn't take
   precedence over the [popover]:popover-open` rule just below. */
  /* TODO(crbug.com/428039233): it would be cleaner if this was dialog:open,
   rather than dialog[open]. But that crashes. */
  dialog:not([open]),
  [popover]:where(:not(:popover-open)) {
    display: none;
  }
  /* TODO(crbug.com/428039233): it would be cleaner if this was dialog:open,
   rather than dialog[open]. But that crashes. */
  dialog[open],
  [popover]:popover-open {
    display: block;
  }

  dialog:-internal-dialog-in-top-layer::backdrop,
  [popover]:-internal-popover-in-top-layer::backdrop {
    /* From the (modified) fullscreen spec: https://fullscreen.spec.whatwg.org/#user-agent-level-style-sheet-defaults: */
    position: fixed;
    inset: 0;
  }

  /* Note that these can't use `:modal` or `:popover-open`, because those pseudo
   classes stop matching as soon as the element is requested to be removed from
   the top layer (e.g. via popover.hidePopover() or dialog.close()). But the
   ::backdrop needs to be retained until the element is actually removed from
   the top layer, which can happen later due to animations of the
   `overlay` property. */
  dialog:-internal-dialog-in-top-layer::backdrop {
    /* https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3 */
    background-color: rgba(0, 0, 0, 0.1);
  }

  [popover]:-internal-popover-in-top-layer::backdrop {
    pointer-events: none !important;
    background-color: transparent;
  }

  /* The `overlay:auto` UA rule goes away as soon as the modal is requested to
   close, or popover.hidePopover() is called. However, it can stay in the top
   layer after this point, if developer CSS animates the `overlay` property. */
  dialog:modal,
  [popover]:popover-open {
    overlay: auto !important;
  }

  @supports blink-feature(MenuElements) {
    /* TODO(crbug.com/422803239): This should be combined with the [popover]
     * rule above when we remove this flag. */
    menulist:not(:popover-open) {
      display: none;
    }
  }

  @supports blink-feature(HTMLAnchorAttribute) {
    /* Popovers using anchor positioning get their inset properties reset, to make
    * it easier to position them. */
    [popover][anchor] {
      inset: auto;
    }
  }

  slot {
    display: contents;
  }

  img:is([sizes="auto" i], [sizes^="auto," i]) {
    contain: size !important;
    contain-intrinsic-size: 300px 150px;
  }
}
