.CodeMirror {
  border-top: none;
  border-right: 1px solid $lbry-gray-1;
  border-bottom: 1px solid $lbry-gray-1;
  border-left: 1px solid $lbry-gray-1;
  border-bottom-left-radius: var(--input-border-radius);
  border-bottom-right-radius: var(--input-border-radius);
  background: $lbry-white;
  color: $lbry-black;

  .CodeMirror-cursor {
    border-color: $lbry-teal-3;
  }

  .CodeMirror-placeholder {
    opacity: 0.5;
  }

  .cm-spell-error:not(.cm-url):not(.cm-comment):not(.cm-tag):not(.cm-word) {
    text-decoration: underline;
    text-decoration-color: $lbry-red-3;
    text-decoration-style: dotted;
  }

  [data-mode='dark'] & {
    border-left: 1px solid rgba($lbry-white, 0.2);
    border-right: 1px solid rgba($lbry-white, 0.2);
    border-bottom: 1px solid rgba($lbry-white, 0.2);
    background-color: rgba($lbry-white, 0.1);
    color: $lbry-white;

    .CodeMirror-selectedtext {
      color: $lbry-black;
    }

    .editor-preview.editor-preview-active {
      background-color: $lbry-black;
      color: $lbry-white;
    }
  }
}

// Fix selection
.CodeMirror-line::selection,
.CodeMirror-line > span::selection,
.CodeMirror-line > span > span::selection {
  background-color: $lbry-teal-1;
}

.editor-toolbar {
  background-color: $lbry-gray-1;
  border: none;
  border-top-left-radius: var(--input-border-radius);
  border-top-right-radius: var(--input-border-radius);
  opacity: 1; // ?

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

  &.disabled-for-preview a:not(.no-disable) {
    background-color: $lbry-gray-1;
    border-color: transparent;
    opacity: 0.3;
  }

  &.fullscreen {
    background-color: $lbry-gray-1;

    &::before,
    &::after {
      display: none;
    }
  }

  button {
    color: $lbry-black !important;
    border-color: transparent;
    transition: opacity 0.3s ease;

    &:not(.active),
    &:not(:hover) {
      opacity: 0.6;
    }

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

  i.separator {
    border: none;
  }

  [data-mode='dark'] & {
    background-color: rgba($lbry-white, 0.2);

    button {
      color: $lbry-white !important; // We need to use !important to override the CodeMirror styles

      &.active {
        background-color: rgba($lbry-black, 0.4);
      }

      &:hover {
        color: $lbry-black !important;
      }
    }

    &.disabled-for-preview {
      button:not(.no-disable) {
        background-color: transparent;
      }

      // The markdown preview button is highlighted during preview when the other buttons are disabled
      button.no-disable {
        background-color: rgba($lbry-white, 0.3);
      }
    }
  }
}

.editor-statusbar {
  color: rgba($lbry-black, 0.5);
  font-size: var(--font-label);
  // padding: var(--spacing-medium) 0; // overriding styles from elsewhere

  [data-mode='dark'] & {
    color: inherit;
  }
}

.form-field--SimpleMDE {
  margin-top: var(--spacing-large);

  // Overriding the lbry/components form styling
  .editor-toolbar {
    button:not(.button) {
      padding-right: 0;
      padding-left: 0;
      background-color: transparent !important;
      border: transparent;

      &:hover {
        background-color: $lbry-white !important;
      }
    }
  }
}
