:root {
  --twoslash-border: #d0d7de;
  --twoslash-code-bg: #f6f8fa;
  --twoslash-hover-bg: #ddf4ff;
  --twoslash-popup-bg: #ffffff;
  --twoslash-popup-fg: #24292f;
  --twoslash-popup-muted: #57606a;
  --twoslash-shadow: 0 8px 24px rgb(140 149 159 / 24%);
}

/* The outer code sample. These selectors intentionally beat Flex's generic
   blockquote/pre rules without affecting existing Pygments blocks. */
main article pre.twoslash {
  background: var(--twoslash-code-bg) !important;
  border: 1px solid var(--twoslash-border);
  border-radius: 8px;
  box-sizing: border-box;
  color: #24292f !important;
  font-size: 0.9em;
  height: auto;
  line-height: 1.55;
  margin: 1.5em 0;
  max-height: none;
  overflow: visible;
  overflow-wrap: anywhere;
  padding: 16px 18px;
  tab-size: 2;
  white-space: pre-wrap;
}

main article pre.twoslash > code {
  display: block;
  max-width: 100%;
  min-width: 0;
  white-space: inherit;
}

.twoslash .twoslash-hover {
  border-radius: 3px;
  cursor: help;
  margin: -2px;
  padding: 2px;
  position: relative;
}

.twoslash .twoslash-hover:hover {
  background: var(--twoslash-hover-bg) !important;
  box-shadow: inset 0 -1px #54aeff;
}

.twoslash .twoslash-popup-container {
  background: var(--twoslash-popup-bg) !important;
  border: 1px solid var(--twoslash-border);
  border-radius: 6px;
  box-shadow: var(--twoslash-shadow);
  box-sizing: border-box;
  color: var(--twoslash-popup-fg) !important;
  display: inline-flex;
  flex-direction: column;
  left: 0;
  line-height: 1.45;
  max-width: min(38rem, 80vw);
  opacity: 0;
  padding: 8px 10px;
  pointer-events: none;
  position: absolute;
  text-align: left;
  top: 100%;
  transform: translateY(7px);
  transition: opacity 120ms ease, visibility 120ms ease;
  user-select: none;
  visibility: hidden;
  width: max-content;
  z-index: 20;
}

.twoslash .twoslash-hover:hover > .twoslash-popup-container,
.twoslash .twoslash-error-hover:hover > .twoslash-popup-container,
.twoslash .twoslash-query-line .twoslash-popup-container {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.twoslash .twoslash-hover:hover > .twoslash-popup-container,
.twoslash .twoslash-error-hover:hover > .twoslash-popup-container {
  z-index: 30;
}

.twoslash .twoslash-popup-container:hover {
  user-select: text;
}

/* Undo Flex's inline-code and nested-pre styling inside type popovers. */
main article .twoslash .twoslash-popup-code,
main article .twoslash .twoslash-popup-docs,
main article .twoslash .twoslash-popup-error {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0;
  color: var(--twoslash-popup-fg) !important;
  font-family: Source Code Pro, Consolas, Liberation Mono, DejaVu Sans Mono,
    monospace;
  font-size: 0.82rem !important;
  line-height: inherit;
  padding: 0 !important;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

main article .twoslash .twoslash-popup-code > pre {
  background: transparent !important;
  border: 0;
  border-radius: 0;
  color: inherit !important;
  font-size: inherit;
  line-height: inherit;
  margin: 0;
  overflow: visible;
  overflow-wrap: anywhere;
  padding: 0;
  white-space: pre-wrap;
}

.twoslash .twoslash-popup-docs {
  border-top: 1px solid var(--twoslash-border) !important;
  color: var(--twoslash-popup-muted) !important;
  font-family: Source Sans Pro, Roboto, Open Sans, sans-serif !important;
  margin: 8px -10px -8px;
  padding: 8px 10px !important;
  white-space: normal;
}

.twoslash .twoslash-popup-arrow {
  background: var(--twoslash-popup-bg);
  border-left: 1px solid var(--twoslash-border);
  border-top: 1px solid var(--twoslash-border);
  height: 7px;
  left: 12px;
  position: absolute;
  top: -4px;
  transform: rotate(45deg);
  width: 7px;
}

.twoslash .twoslash-query-line {
  display: block;
  line-height: 1.45;
  max-width: 100%;
  padding: 7px 0 8px;
}

.twoslash .twoslash-query-line .twoslash-popup-container {
  left: auto;
  position: relative;
  top: auto;
  transform: none;
  vertical-align: top;
  z-index: 10;
}

.twoslash .twoslash-error {
  text-decoration: underline wavy #cf222e;
  text-underline-offset: 3px;
}

.twoslash .twoslash-error-line {
  background: #ffebe9;
  border-left: 3px solid #cf222e;
  color: #82071e;
  display: block;
  margin: 4px -18px;
  padding: 6px 18px;
  width: max-content;
}

@media (max-width: 600px) {
  main article pre.twoslash {
    border-radius: 6px;
    padding: 14px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .twoslash * {
    transition: none !important;
  }
}
