.block-content-wrapper {
  /* 38px is the width of block-control */
  width: calc(100% - 22px);
  user-select: text;
  @screen sm {
    width: calc(100% - 33px);
    overflow-x: visible;
  }
}

.block-content {
  min-height: 24px;
  max-width: 100%;
  overflow: initial;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
  cursor: text;

  img {
    max-width: 100%;

    /* FIXME: img macros */

    &.left {
      float: left;
    }

    &.right {
      float: right;
    }

    &.loading-asset {
      width: 9px;
    }
  }

  .asset-container {
    @apply relative inline-block;

    margin-top: 0.5rem;

    .asset-overlay {
      @apply inset-0 absolute p-2;

      opacity: 0;
      transition: opacity 300ms;
      background-image: linear-gradient(var(--ls-primary-background-color), transparent);
      pointer-events: none;
    }

    .asset-action-bar {
      @apply top-0 left-0 w-full flex absolute items-start justify-between px-1;

      transition: opacity 300ms;
      opacity: 0;
      color: var(--ls-primary-text-color);
    }

    .asset-action-btn {
      @apply m-1 p-1 rounded truncate;

      opacity: 0.8;
      user-select: none;

      &:hover,
      &:active {
        opacity: 1;
      }
    }

    &:hover,
    &:focus {
      .asset-overlay {
        opacity: 0.9;
      }

      .asset-action-bar {
        opacity: 1;
      }
    }
  }

  .resize {
    display: inline-flex;
    /* Fix chrome missing resize handle issue https://bugs.chromium.org/p/chromium/issues/detail?id=1135676&q=css%20resize%20type%3DBug&can=2.*/
    transform: translate3d(0, 0, 0);
  }

  .draw [aria-labelledby="shapes-title"] {
    position: absolute;
    left: 50%;
    transform: translate(-50%);
  }

  &-fallback-ui {
    padding: 10px 15px;
    border-color: var(--ls-secondary-border-color);
  }
}

.breadcrumb {
  .asset-container > img {
    height: 18px;
    width: unset !important;
  }

  .inline-wrap {
    & > div, & > div > div {
      display: inherit;
    }
  }

  &.block-parents {
    .ui__icon {
      position: relative;
      top: 4px;
    }

    a {
      color: var(--ls-primary-text-color);

      &:hover {
        opacity: 1;
      }
    }
  }
}

.open-block-ref-link {
  background-color: var(--ls-page-properties-background-color);
  padding: 1px 4px;
  border-radius: 2px;
}

.block-body {
  blockquote:first-child,
  pre:first-child {
    margin-top: 8px;
    margin-bottom: 8px;
  }
}

.block-body ul,
.block-body ol,
.block-body dl {
  margin-bottom: 0;

  > li {
    margin: 0;
  }
}

.block-body ol {
  list-style-position: inside;
  margin-left: 0;

  > li {
    &::marker,
    > p {
      display: initial;
    }
  }
}

.block-children-container {
  position: relative;
  margin-left: 29px;
}

.block-children-left-border {
  z-index: 1;
  width: 4px;
  left: -1px;
  top: 0;
  height: 100%;
  cursor: pointer;
  background-clip: content-box;
  background-color: transparent;
  position: absolute;
  border-radius: 2px;
  opacity: 0.6;
}

.block-children-left-border:hover {
  background-color: var(--ls-primary-text-color);
}

.block-children {
  border-left: 1px solid;
  border-left-color: var(--ls-guideline-color, #ddd);

  padding-top: 2px;
  padding-bottom: 3px;

  > .ls-block {
    &:last-child {
      margin-bottom: -5px;
    }
  }
}

.block-control-wrap {
  @apply h-[24px] mt-0 pr-[6px];

  &.is-order-list {
    @apply mr-0 pr-0;

    .bullet-link-wrap {
      @apply relative left-[-3px];
    }
  }
}

.block-control, .block-control:hover {
  text-decoration: none;
  cursor: default;
  font-size: 14px;
  min-width: 22px;
  min-height: 22px;
  padding: 2px;
  color: var(--ls-secondary-text-color);
  user-select: none;
  opacity: .4;

  .control-hide {
    display: none;
  }
}

.block-left-menu {
  background-color: var(--ls-secondary-background-color);
  background: linear-gradient(90deg, var(--ls-primary-background-color) 0%, var(--ls-secondary-background-color) 100%);

  .commands-button {
    @apply overflow-hidden flex max-w-[40px];

    .indent {
      @apply flex items-center w-full justify-center opacity-30;
    }
  }
}

.block-right-menu {
  background-color: var(--ls-secondary-background-color);
  /* background: linear-gradient(-90deg, var(--ls-primary-background-color) 0%, var(--ls-secondary-background-color) 100%); */

  .commands-button {
    @apply overflow-hidden flex flex-nowrap;

    .outdent, .more {
      @apply flex items-center justify-center
      overflow-hidden opacity-30 m-0 w-[40px];
    }
  }
}

.block-ref {
  border-bottom: 0.5px solid;
  border-bottom-color: var(--ls-block-ref-link-text-color);
  cursor: alias;
  padding: 2px 0;
  display: inherit;

  &:hover {
    color: var(--ls-link-text-hover-color);
  }

  .block-content {
    cursor: inherit;

    &-inner {
      display: inherit;

      > * {
        display: inherit;
      }
    }
  }
}

.block-ref-no-title {
  border-bottom: 0.5px solid;
  border-bottom-color: var(--ls-block-ref-link-text-color);
  cursor: alias;
  padding: 2px 5px;
  display: block;

  &:hover {
    color: var(--ls-link-text-hover-color);
  }

  .block-content {
    cursor: inherit;
  }
}

.page-ref {
  color: var(--ls-link-ref-text-color);

  &:hover {
    color: var(--ls-link-ref-text-hover-color);
  }
}

.asset-ref {
  &-wrap {
    &[data-ext=pdf] {
      display: inline-flex;
      align-items: center;
    }
  }

  &.is-doc {
    &:before {
      content: "[[📜";
      opacity: .7;
      margin-right: 4px;
    }

    &:after {
      content: "]]";
      opacity: .7;
    }
  }
}

.embed-page {
  @apply py-2 my-2 px-2;

  > section {
    margin-bottom: 5px;
  }

  &.in-sidebar {
    background-color: var(--ls-tertiary-background-color);
  }
}

.block-properties {
  margin: 4px 0;
  padding: 4px 8px;
  background-color: var(--ls-block-properties-background-color, #f0f8ff);
}

.page-properties {
  background-color: var(--ls-page-properties-background-color);
}

.block-marker {
  padding: 2px 4px;
  opacity: 0.7;
  font-size: 85%;
  margin: 0 2px 0 0;
  font-weight: 650;
  border: 0;
}

.marker-switch {
  &:hover {
    color: var(--ls-link-text-hover-color);
    opacity: 1;
  }
}

.ls-block {
  position: relative;
  min-height: 24px;
  padding: 2px 0;
  border-bottom: 1px solid transparent;
  transition: background-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);

  &.selected {
    border-bottom-color: var(--ls-primary-background-color);
    border-radius: 2px;

    &:last-child {
      border-bottom-color: transparent;
    }
  }
}

.ls-block,
.editor-wrapper {
  margin-right: auto;
  margin-left: auto;
}

.ls-block h1,
.editor-inner .h1.uniline-block {
  font-size: 2em;
  min-height: 1.5em;
}

.ls-block h2,
.editor-inner .h2.uniline-block {
  font-size: 1.5em;
  min-height: 1.5em;
}

.ls-block h3,
.editor-inner .h3.uniline-block {
  font-size: 1.2em;
  min-height: 1.2em;
}

.ls-block h4,
.editor-inner .h4.uniline-block {
  font-size: 1em;
  min-height: 1em;
}

.ls-block h5,
.editor-inner .h5.uniline-block {
  font-size: 0.83em;
  min-height: 0.83em;
}

.ls-block h6,
.editor-inner .h6.uniline-block {
  font-size: 0.75em;
  min-height: 0.75em;
}

.ls-block :is(h1, h2, h3, h4, h5, h6),
.editor-inner .uniline-block:is(.h1, .h2, .h3, .h4, .h5, .h6),
.editor-inner .multiline-block:is(.h1, .h2, .h3, .h4, .h5, .h6)::first-line {
  font-weight: 600;
}

.ls-block :is(h1, h2),
.editor-inner .uniline-block:is(.h1, .h2) {
  border-bottom: 1px solid var(--ls-quaternary-background-color);
  margin: 0.125em 0;
  padding-bottom: 0.125em;
}

.block-ref .ls-block :is(h1, h2),
.block-ref .editor-inner :is(.h1, .h2) {
  border-bottom: none;
}

.block-ref :is(h1, h2, h3, h4, h5, h6) {
  border-bottom: none;
  font-size: 1rem;
}

.document-mode {
  & .ls-block h1,
  & .editor-inner .h1 {
    margin: 0.67em 0;
  }

  & .ls-block h2,
  & .editor-inner .h2 {
    margin: 0.75em 0;
  }

  & .ls-block h3,
  & .editor-inner .h3 {
    margin: 0.83em 0;
  }

  & .ls-block h4,
  & .editor-inner .h4 {
    margin: 1.12em 0;
  }

  & .ls-block h5,
  & .editor-inner .h5 {
    margin: 1.5em 0;
  }

  & .ls-block h6,
  & .editor-inner .h6 {
    margin: 1.67em 0;
  }
}

.color-level {
  background-color: var(--color-level-1);

  & .color-level {
    background-color: var(--color-level-2);

    & .color-level {
      background-color: var(--color-level-3);

      & .color-level {
        background-color: var(--color-level-4);

        & .color-level {
          background-color: var(--color-level-5);

          & .color-level {
            background-color: var(--color-level-6);

            & .color-level {
              background-color: var(--color-level-4);

              & .color-level {
                background-color: var(--color-level-5);

                & .color-level {
                  background-color: var(--color-level-6);

                  & .color-level {
                    background-color: var(--color-level-4);

                    & .color-level {
                      background-color: var(--color-level-6);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

.bullet-container {
  display: flex;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  justify-content: center;
  align-items: center;

  .bullet-heading {
    background-color: var(--ls-block-bullet-color, #8fbc8f);
  }

  &.as-order-list {
    @apply w-[22px] whitespace-nowrap justify-center pl-[3px];
  }

  .bullet {
    @apply rounded-full w-[6px] h-[6px];

    font-size: 14px;

    background-color: var(--ls-block-bullet-color, #394b59);
    transition: transform 0.2s;

    > * {
      @apply cursor-pointer;
    }
  }

  &:not(.typed-list) {
    &.bullet-closed {
      background-color: var(--ls-block-bullet-border-color, #ced9e0);
    }
  }

  &.typed-list:not(:focus-within) {
    .bullet {
      background-color: unset;
      height: unset;
      width: unset;
      box-shadow: none;
    }
  }
}

.bullet-link-wrap {
  color: var(--ls-primary-text-color);

  &:hover > .bullet-container .bullet {
    transform: scale(1.4);
  }

  &:hover > .bullet-container:not(.typed-list) {
    background-color: var(--ls-block-bullet-border-color, #ced9e0);
  }
}

.content.doc-mode {
  margin-left: -16px;

  .block-children-left-border {
    display: none;
  }

  .block-children {
    border-left: none;
  }

  .hide-inner-bullet .bullet {
    display: none;
  }

  .block-children-container {
    margin-left: 18px;
  }
}

.ls-block .custom-query {
  > .th {
    @apply flex flex-row flex-1 items-center justify-between my-1 text-xs opacity-90;
  }
}

/* copied from https://github.com/drdogbot7/tailwindcss-responsive-embed */
.embed-responsive {
  position: relative;
  display: block;
  height: 0;
  padding: 0;
  overflow: hidden;

  .embed-responsive-item,
  iframe,
  embed,
  object,
  video {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100%;
    width: 100%;
    border: 0;
  }
}

.embed {
  border-radius: var(--ls-border-radius-low);
}

.embed-header {
  font-weight: 600;
}

a.filter svg {
  transform: scale(0.9);
}

.table-query-properties svg {
  display: inline;
}

.query-title {
  background: var(--ls-page-properties-background-color);
}

.ls-card {
  height: 100%;
}

@media (min-width: 1024px) {
  .ui__modal-panel .ls-card {
    min-height: 24rem;
  }
}

a[data-ref="card"], .page-reference[data-ref="card"] {
  opacity: 0.3;
}

.ls-card a[data-ref="card"], .ls-card .page-reference[data-ref="card"] {
  display: none;
}

a.cloze {
  color: var(--ls-cloze-text-color);
}

a.cloze-revealed {
  color: var(--ls-cloze-text-color);
  text-decoration: underline;
  text-underline-position: under;
}

.page-property-key {
  @apply font-medium whitespace-nowrap;
  color: var(--ls-secondary-text-color);
}

.page-property-key:hover {
  background-color: var(--ls-selection-background-color);
}

.cp__fenced-code-block {
  .not-edit {
    cursor: default;
  }
}

html.is-native-ios {
  audio {
    width: 100%;
    max-width: 350px;
  }
}

html:not(.is-mac) {
  body[data-active-keystroke="Control"] {
    .block-content {
      cursor: pointer;
    }
  }
}

html.is-mac {
  body[data-active-keystroke="Meta"] {
    .block-content {
      cursor: pointer;
    }
  }
}
